… | |
… | |
217 | } |
217 | } |
218 | |
218 | |
219 | return 0; |
219 | return 0; |
220 | } |
220 | } |
221 | |
221 | |
222 | /* When the map is loaded, load_object does not actually insert objects |
|
|
223 | * into inventory, but just links them. What this does is go through |
|
|
224 | * and insert them properly. |
|
|
225 | * The object 'container' is the object that contains the inventory. |
|
|
226 | * This is needed so that we can update the containers weight. |
|
|
227 | */ |
|
|
228 | static void |
|
|
229 | fix_container (object *container) |
|
|
230 | { |
|
|
231 | object *tmp = container->inv, *next; |
|
|
232 | |
|
|
233 | container->inv = 0; |
|
|
234 | while (tmp) |
|
|
235 | { |
|
|
236 | next = tmp->below; |
|
|
237 | if (tmp->inv) |
|
|
238 | fix_container (tmp); |
|
|
239 | |
|
|
240 | insert_ob_in_ob (tmp, container); |
|
|
241 | tmp = next; |
|
|
242 | } |
|
|
243 | |
|
|
244 | // go through and calculate what all the containers are carrying. |
|
|
245 | //TODO: remove |
|
|
246 | container->update_weight (); |
|
|
247 | } |
|
|
248 | |
|
|
249 | //-GPL |
222 | //-GPL |
250 | |
223 | |
251 | void |
224 | void |
252 | maptile::set_object_flag (int flag, int value) |
225 | maptile::set_object_flag (int flag, int value) |
253 | { |
226 | { |
… | |
… | |
268 | set_object_flag (FLAG_OBJ_ORIGINAL); |
241 | set_object_flag (FLAG_OBJ_ORIGINAL); |
269 | |
242 | |
270 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
243 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
271 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
244 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
272 | INVOKE_OBJECT (RESET, tmp); |
245 | INVOKE_OBJECT (RESET, tmp); |
|
|
246 | } |
|
|
247 | |
|
|
248 | void |
|
|
249 | maptile::post_load () |
|
|
250 | { |
|
|
251 | #if 0 |
|
|
252 | if (!spaces) |
|
|
253 | return; |
|
|
254 | |
|
|
255 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
|
|
256 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
|
|
257 | ; // nop |
|
|
258 | #endif |
273 | } |
259 | } |
274 | |
260 | |
275 | //+GPL |
261 | //+GPL |
276 | |
262 | |
277 | /* link_multipart_objects go through all the objects on the map looking |
263 | /* link_multipart_objects go through all the objects on the map looking |
… | |
… | |
728 | //-GPL |
714 | //-GPL |
729 | |
715 | |
730 | bool |
716 | bool |
731 | maptile::_save_header (object_freezer &freezer) |
717 | maptile::_save_header (object_freezer &freezer) |
732 | { |
718 | { |
733 | #define MAP_OUT(k) freezer.put (KW_ ## k, k) |
719 | #define MAP_OUT(k) freezer.put (KW(k), k) |
734 | #define MAP_OUT2(k,v) freezer.put (KW_ ## k, v) |
720 | #define MAP_OUT2(k,v) freezer.put (KW(k), v) |
735 | |
721 | |
736 | MAP_OUT2 (arch, "map"); |
722 | MAP_OUT2 (arch, CS(map)); |
737 | |
723 | |
738 | if (name) MAP_OUT (name); |
724 | if (name) MAP_OUT (name); |
739 | MAP_OUT (swap_time); |
725 | MAP_OUT (swap_time); |
740 | MAP_OUT (reset_time); |
726 | MAP_OUT (reset_time); |
741 | MAP_OUT (reset_timeout); |
727 | MAP_OUT (reset_timeout); |
… | |
… | |
755 | MAP_OUT (width); |
741 | MAP_OUT (width); |
756 | MAP_OUT (height); |
742 | MAP_OUT (height); |
757 | MAP_OUT (enter_x); |
743 | MAP_OUT (enter_x); |
758 | MAP_OUT (enter_y); |
744 | MAP_OUT (enter_y); |
759 | |
745 | |
760 | if (msg) freezer.put (KW_msg , KW_endmsg , msg); |
746 | if (msg) freezer.put (KW(msg) , KW(endmsg) , msg); |
761 | if (maplore) freezer.put (KW_maplore, KW_endmaplore, maplore); |
747 | if (maplore) freezer.put (KW(maplore), KW(endmaplore), maplore); |
762 | |
748 | |
763 | MAP_OUT (outdoor); |
749 | MAP_OUT (outdoor); |
764 | MAP_OUT (temp); |
750 | MAP_OUT (temp); |
765 | MAP_OUT (pressure); |
751 | MAP_OUT (pressure); |
766 | MAP_OUT (humid); |
752 | MAP_OUT (humid); |
… | |
… | |
775 | if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]); |
761 | if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]); |
776 | if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); |
762 | if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); |
777 | if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); |
763 | if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); |
778 | |
764 | |
779 | freezer.put (this); |
765 | freezer.put (this); |
780 | freezer.put (KW_end); |
766 | freezer.put (KW(end)); |
781 | |
767 | |
782 | return true; |
768 | return true; |
783 | } |
769 | } |
784 | |
770 | |
785 | bool |
771 | bool |