… | |
… | |
344 | } |
344 | } |
345 | |
345 | |
346 | /* link_multipart_objects go through all the objects on the map looking |
346 | /* link_multipart_objects go through all the objects on the map looking |
347 | * for objects whose arch says they are multipart yet according to the |
347 | * for objects whose arch says they are multipart yet according to the |
348 | * info we have, they only have the head (as would be expected when |
348 | * info we have, they only have the head (as would be expected when |
349 | * they are saved). We do have to look for the old maps that did save |
349 | * they are saved). |
350 | * the more sections and not re-add sections for them. |
|
|
351 | */ |
350 | */ |
352 | void |
351 | void |
353 | maptile::link_multipart_objects () |
352 | maptile::link_multipart_objects () |
354 | { |
353 | { |
355 | if (!spaces) |
354 | if (!spaces) |
… | |
… | |
399 | bool |
398 | bool |
400 | maptile::_load_objects (object_thawer &f) |
399 | maptile::_load_objects (object_thawer &f) |
401 | { |
400 | { |
402 | for (;;) |
401 | for (;;) |
403 | { |
402 | { |
404 | coroapi::cede_every (1000); // cede once in a while |
403 | coroapi::cede_to_tick_every (100); // cede once in a while |
405 | |
404 | |
406 | switch (f.kw) |
405 | switch (f.kw) |
407 | { |
406 | { |
408 | case KW_arch: |
407 | case KW_arch: |
409 | if (object *op = object::read (f, this)) |
408 | if (object *op = object::read (f, this)) |
… | |
… | |
454 | } |
453 | } |
455 | |
454 | |
456 | bool |
455 | bool |
457 | maptile::_save_objects (object_freezer &f, int flags) |
456 | maptile::_save_objects (object_freezer &f, int flags) |
458 | { |
457 | { |
459 | coroapi::cede (); |
458 | coroapi::cede_to_tick (); |
460 | |
459 | |
461 | if (flags & IO_HEADER) |
460 | if (flags & IO_HEADER) |
462 | _save_header (f); |
461 | _save_header (f); |
463 | |
462 | |
464 | if (!spaces) |
463 | if (!spaces) |
465 | return false; |
464 | return false; |
466 | |
465 | |
467 | for (int i = 0; i < size (); ++i) |
466 | for (int i = 0; i < size (); ++i) |
468 | { |
467 | { |
469 | #if 0 // disabled, there still seem to be races somewhere |
|
|
470 | static int cede_count = 0; |
|
|
471 | |
|
|
472 | if (cede_count >= 500) |
|
|
473 | { |
|
|
474 | cede_count = 0; |
|
|
475 | coroapi::cede (); |
|
|
476 | } |
|
|
477 | #endif |
|
|
478 | |
|
|
479 | int unique = 0; |
468 | int unique = 0; |
480 | for (object *op = spaces [i].bot; op; op = op->above) |
469 | for (object *op = spaces [i].bot; op; op = op->above) |
481 | { |
470 | { |
482 | // count per-object, but cede only when modification-safe |
|
|
483 | cede_count++; |
|
|
484 | |
|
|
485 | if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]) |
471 | if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]) |
486 | unique = 1; |
472 | unique = 1; |
487 | |
473 | |
488 | if (!op->can_map_save ()) |
474 | if (!op->can_map_save ()) |
489 | continue; |
475 | continue; |
… | |
… | |
496 | else if (flags & IO_OBJECTS) |
482 | else if (flags & IO_OBJECTS) |
497 | op->write (f); |
483 | op->write (f); |
498 | } |
484 | } |
499 | } |
485 | } |
500 | |
486 | |
501 | coroapi::cede (); |
487 | coroapi::cede_to_tick (); |
502 | |
488 | |
503 | return true; |
489 | return true; |
504 | } |
490 | } |
505 | |
491 | |
506 | bool |
492 | bool |