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.87 by root, Thu Feb 15 21:07:48 2007 UTC vs.
Revision 1.88 by root, Fri Feb 16 19:43:40 2007 UTC

397} 397}
398 398
399/* 399/*
400 * Loads (ands parses) the objects into a given map from the specified 400 * Loads (ands parses) the objects into a given map from the specified
401 * file pointer. 401 * file pointer.
402 * mapflags is the same as we get with load_original_map
403 */ 402 */
404bool 403bool
405maptile::_load_objects (object_thawer &thawer) 404maptile::_load_objects (object_thawer &f)
406{ 405{
407 int unique; 406 for (;;)
408 object *op, *prev = NULL, *last_more = NULL, *otmp;
409
410 op = object::create ();
411 op->map = this; /* To handle buttons correctly */
412
413 while (int i = load_object (thawer, op, 0))
414 { 407 {
415 /* if the archetype for the object is null, means that we 408 coroapi::cede_every (1000); // cede once in a while
416 * got an invalid object. Don't do anything with it - the game 409
417 * or editor will not be able to do anything with it either. 410 switch (f.kw)
418 */
419 if (op->arch == NULL)
420 { 411 {
421 LOG (llevDebug, "Discarding object without arch: %s\n", op->name ? (const char *) op->name : "(null)"); 412 case KW_arch:
422 continue; 413 if (object *op = object::read (f))
423 }
424
425 switch (i)
426 { 414 {
427 case LL_NORMAL: 415 if (op->inv)
416 sum_weight (op);
417
428 insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD); 418 insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD);
419 }
429 420
430 if (op->inv) 421 continue;
431 sum_weight (op);
432 422
433 prev = op, last_more = op;
434 break;
435
436 case LL_MORE: 423 case KW_EOF:
437 insert_ob_in_map (op, this, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY); 424 return true;
438 op->head = prev, last_more->more = op, last_more = op; 425
426 default:
427 if (!f.parse_error ("map file"))
428 return false;
439 break; 429 break;
440 } 430 }
441 431
442 op = object::create (); 432 f.next ();
443 op->map = this;
444 }
445
446 op->destroy ();
447
448#if 0
449 for (i = 0; i < width; i++)
450 for (j = 0; j < height; j++)
451 {
452 unique = 0;
453 /* check for unique items, or unique squares */
454 for (otmp = GET_MAP_OB (m, i, j); otmp; otmp = otmp->above)
455 {
456 if (QUERY_FLAG (otmp, FLAG_UNIQUE) || QUERY_FLAG (otmp, FLAG_OBJ_SAVE_ON_OVL))
457 unique = 1;
458
459 if (!(mapflags & (MAP_OVERLAY | MAP_PLAYER_UNIQUE) || unique))
460 SET_FLAG (otmp, FLAG_OBJ_ORIGINAL);
461 }
462 } 433 }
463#endif
464 434
465 return true; 435 return true;
466} 436}
467 437
468void 438void
486 for (object *op = ms->bot; op; op = op->above) 456 for (object *op = ms->bot; op; op = op->above)
487 op->deactivate_recursive (); 457 op->deactivate_recursive ();
488} 458}
489 459
490bool 460bool
491maptile::_save_objects (object_freezer &freezer, int flags) 461maptile::_save_objects (object_freezer &f, int flags)
492{ 462{
493 static int cede_count = 0; 463 static int cede_count = 0;
494 464
495 if (flags & IO_HEADER) 465 if (flags & IO_HEADER)
496 _save_header (freezer); 466 _save_header (f);
497 467
498 if (!spaces) 468 if (!spaces)
499 return false; 469 return false;
500 470
501 for (int i = 0; i < size (); ++i) 471 for (int i = 0; i < size (); ++i)
521 continue; 491 continue;
522 492
523 if (unique || op->flag [FLAG_UNIQUE]) 493 if (unique || op->flag [FLAG_UNIQUE])
524 { 494 {
525 if (flags & IO_UNIQUES) 495 if (flags & IO_UNIQUES)
526 save_object (freezer, op, 1); 496 op->write (f);
527 } 497 }
528 else if (flags & IO_OBJECTS) 498 else if (flags & IO_OBJECTS)
529 save_object (freezer, op, 1); 499 op->write (f);
530 } 500 }
531 } 501 }
532 502
533 return true; 503 return true;
534} 504}
535 505
536bool 506bool
537maptile::_load_objects (const char *path, bool skip_header) 507maptile::_load_objects (const char *path, bool skip_header)
538{ 508{
539 object_thawer thawer (path); 509 object_thawer f (path);
540 510
541 if (!thawer) 511 if (!f)
542 return false; 512 return false;
513
514 f.next ();
543 515
544 if (skip_header) 516 if (skip_header)
545 for (;;) 517 for (;;)
546 { 518 {
519 keyword kw = f.kw;
520 f.skip ();
547 if (thawer.kw == KW_end) 521 if (kw == KW_end)
548 break; 522 break;
549
550 thawer.skip_kv ();
551 } 523 }
552 524
553 return _load_objects (thawer); 525 return _load_objects (f);
554} 526}
555 527
556bool 528bool
557maptile::_save_objects (const char *path, int flags) 529maptile::_save_objects (const char *path, int flags)
558{ 530{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines