ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.96 by root, Thu Mar 15 14:23:02 2007 UTC vs.
Revision 1.100 by root, Tue Apr 17 10:06:32 2007 UTC

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 */
352void 351void
353maptile::link_multipart_objects () 352maptile::link_multipart_objects ()
354{ 353{
355 if (!spaces) 354 if (!spaces)
399bool 398bool
400maptile::_load_objects (object_thawer &f) 399maptile::_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
456bool 455bool
457maptile::_save_objects (object_freezer &f, int flags) 456maptile::_save_objects (object_freezer &f, int flags)
458{ 457{
459 static int cede_count = 0; 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 (cede_count >= 500)
470 {
471 cede_count = 0;
472 coroapi::cede ();
473 }
474
475 int unique = 0; 468 int unique = 0;
476 for (object *op = spaces [i].bot; op; op = op->above) 469 for (object *op = spaces [i].bot; op; op = op->above)
477 { 470 {
478 // count per-object, but cede only when modification-safe
479 cede_count++;
480
481 if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]) 471 if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR])
482 unique = 1; 472 unique = 1;
483 473
484 if (!op->can_map_save ()) 474 if (!op->can_map_save ())
485 continue; 475 continue;
491 } 481 }
492 else if (flags & IO_OBJECTS) 482 else if (flags & IO_OBJECTS)
493 op->write (f); 483 op->write (f);
494 } 484 }
495 } 485 }
486
487 coroapi::cede_to_tick ();
496 488
497 return true; 489 return true;
498} 490}
499 491
500bool 492bool

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines