… | |
… | |
329 | * carrying. |
329 | * carrying. |
330 | */ |
330 | */ |
331 | sum_weight (container); |
331 | sum_weight (container); |
332 | } |
332 | } |
333 | |
333 | |
|
|
334 | void |
|
|
335 | maptile::set_object_flag (int flag, int value) |
|
|
336 | { |
|
|
337 | if (!spaces) |
|
|
338 | return; |
|
|
339 | |
|
|
340 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
|
|
341 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
|
|
342 | tmp->flag [flag] = value; |
|
|
343 | } |
|
|
344 | |
334 | /* link_multipart_objects go through all the objects on the map looking |
345 | /* link_multipart_objects go through all the objects on the map looking |
335 | * for objects whose arch says they are multipart yet according to the |
346 | * for objects whose arch says they are multipart yet according to the |
336 | * info we have, they only have the head (as would be expected when |
347 | * info we have, they only have the head (as would be expected when |
337 | * they are saved). We do have to look for the old maps that did save |
348 | * they are saved). We do have to look for the old maps that did save |
338 | * the more sections and not re-add sections for them. |
349 | * the more sections and not re-add sections for them. |
… | |
… | |
476 | } |
487 | } |
477 | |
488 | |
478 | bool |
489 | bool |
479 | maptile::save_objects (object_freezer &freezer, int flags) |
490 | maptile::save_objects (object_freezer &freezer, int flags) |
480 | { |
491 | { |
|
|
492 | static int cede_count = 0; |
|
|
493 | |
481 | if (flags & IO_HEADER) |
494 | if (flags & IO_HEADER) |
482 | save_header (freezer); |
495 | save_header (freezer); |
483 | |
496 | |
484 | if (!spaces) |
497 | if (!spaces) |
485 | return false; |
498 | return false; |
486 | |
499 | |
487 | for (int i = 0; i < size (); ++i) |
500 | for (int i = 0; i < size (); ++i) |
488 | { |
501 | { |
|
|
502 | if (cede_count >= 500) |
|
|
503 | { |
|
|
504 | cede_count = 0; |
|
|
505 | coroapi::cede (); |
|
|
506 | } |
|
|
507 | |
489 | int unique = 0; |
508 | int unique = 0; |
490 | for (object *op = spaces [i].bot; op; op = op->above) |
509 | for (object *op = spaces [i].bot; op; op = op->above) |
491 | { |
510 | { |
|
|
511 | // count per-object, but cede only when modification-safe |
|
|
512 | cede_count++; |
|
|
513 | |
492 | if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]) |
514 | if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]) |
493 | unique = 1; |
515 | unique = 1; |
494 | |
516 | |
495 | if (!op->can_map_save ()) |
517 | if (!op->can_map_save ()) |
496 | continue; |
518 | continue; |
… | |
… | |
888 | if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]); |
910 | if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]); |
889 | if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]); |
911 | if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]); |
890 | if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); |
912 | if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); |
891 | if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); |
913 | if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); |
892 | |
914 | |
|
|
915 | freezer.put (this); |
893 | freezer.put (KW_end); |
916 | freezer.put (KW_end); |
894 | |
917 | |
895 | return true; |
918 | return true; |
896 | } |
919 | } |
897 | |
920 | |
… | |
… | |
1214 | |
1237 | |
1215 | /* If two top faces are already set, quit processing */ |
1238 | /* If two top faces are already set, quit processing */ |
1216 | if ((top != blank_face) && (middle != blank_face)) |
1239 | if ((top != blank_face) && (middle != blank_face)) |
1217 | break; |
1240 | break; |
1218 | |
1241 | |
1219 | /* Only show visible faces, unless its the editor - show all */ |
1242 | /* Only show visible faces */ |
1220 | if (!tmp->invisible || editor) |
1243 | if (!tmp->invisible) |
1221 | { |
1244 | { |
1222 | /* Fill in top if needed */ |
1245 | /* Fill in top if needed */ |
1223 | if (top == blank_face) |
1246 | if (top == blank_face) |
1224 | { |
1247 | { |
1225 | top = tmp->face; |
1248 | top = tmp->face; |
… | |
… | |
1360 | |
1383 | |
1361 | /* This is basically the same as out_of_map above, but |
1384 | /* This is basically the same as out_of_map above, but |
1362 | * instead we return NULL if no map is valid (coordinates |
1385 | * instead we return NULL if no map is valid (coordinates |
1363 | * out of bounds and no tiled map), otherwise it returns |
1386 | * out of bounds and no tiled map), otherwise it returns |
1364 | * the map as that the coordinates are really on, and |
1387 | * the map as that the coordinates are really on, and |
1365 | * updates x and y to be the localized coordinates. |
1388 | * updates x and y to be the localised coordinates. |
1366 | * Using this is more efficient of calling out_of_map |
1389 | * Using this is more efficient of calling out_of_map |
1367 | * and then figuring out what the real map is |
1390 | * and then figuring out what the real map is |
1368 | */ |
1391 | */ |
1369 | maptile * |
1392 | maptile * |
1370 | get_map_from_coord (maptile *m, sint16 *x, sint16 *y) |
1393 | get_map_from_coord (maptile *m, sint16 *x, sint16 *y) |