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

Comparing deliantra/server/common/loader.C (file contents):
Revision 1.28 by root, Mon Dec 25 11:25:49 2006 UTC vs.
Revision 1.30 by root, Tue Dec 26 08:54:59 2006 UTC

638 case KW_last_grace: thawer.get (op->last_grace); break; 638 case KW_last_grace: thawer.get (op->last_grace); break;
639 case KW_last_eat: thawer.get (op->last_eat); break; 639 case KW_last_eat: thawer.get (op->last_eat); break;
640 case KW_speed_left: thawer.get (op->speed_left); break; 640 case KW_speed_left: thawer.get (op->speed_left); break;
641 641
642 case KW_speed: 642 case KW_speed:
643 {
644 float speed;
643 thawer.get (op->speed); 645 thawer.get (speed);
646 op->set_speed (speed);
644 647
645 //TODO: maybe do in check_object 648 //TODO: maybe do in check_object
646 if (!(map_flags & MAP_STYLE)) 649 if (!(map_flags & MAP_STYLE))
647 {
648 if (op->speed < 0) 650 if (op->speed < 0)
649 op->speed_left = op->speed_left - RANDOM () % 100 / 100.0; 651 op->speed_left = op->speed_left - RANDOM () % 100 / 100.0;
650
651 update_ob_speed (op);
652 } 652 }
653
654 break; 653 break;
655 654
656 case KW_slow_move: 655 case KW_slow_move:
657 op->move_slow |= MOVE_WALK; 656 op->move_slow |= MOVE_WALK;
658 thawer.get (op->move_slow_penalty); 657 thawer.get (op->move_slow_penalty);
1441 1440
1442/* 1441/*
1443 * Dumps all variables in an object to a file. 1442 * Dumps all variables in an object to a file.
1444 * If bit 0 of flag is set, unpaid objects will be saved. As of now, 1443 * If bit 0 of flag is set, unpaid objects will be saved. As of now,
1445 * the only place this is not set is when saving the player. 1444 * the only place this is not set is when saving the player.
1446 * If bit 1 of flag is set, don't remove the object after save. As of now,
1447 * all of the callers are setting this.
1448 */ 1445 */
1449
1450void 1446void
1451save_object (object_freezer & fp, object *op, int flag) 1447save_object (object_freezer &fp, object *op, int flag)
1452{ 1448{
1453 archetype *at;
1454 object *tmp, *old;
1455
1456 /* Even if the object does have an owner, it would seem that we should 1449 /* Even if the object does have an owner, it would seem that we should
1457 * still save it. 1450 * still save it.
1458 */ 1451 */
1459 if (op->owner) 1452 if (op->owner)
1460 return; 1453 return;
1461 1454
1462 /* If it is unpaid and we don't want to save those, just return. */ 1455 /* If it is unpaid and we don't want to save those, just return. */
1463 if (!(flag & 1) && (QUERY_FLAG (op, FLAG_UNPAID))) 1456 if (!(flag & 1) && op->flag [FLAG_UNPAID])
1464 return; 1457 return;
1465 1458
1466 if ((at = op->arch) == NULL) 1459 archetype *at = op->arch ? (archetype *)op->arch : empty_archetype;
1467 at = empty_archetype;
1468 1460
1469 fp.put (KW_arch, at->name); 1461 fp.put (KW_arch, at->name);
1470
1471 put (fp, op, &at->clone); 1462 put (fp, op, &at->clone);
1472 1463
1473 /* Eneq(@csd.uu.se): Added this to allow containers being saved with contents */ 1464 /* Eneq(@csd.uu.se): Added this to allow containers being saved with contents */
1474 1465
1475 old = NULL;
1476
1477 if (flag & 2)
1478 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1466 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1479 save_object (fp, tmp, flag); 1467 save_object (fp, tmp, flag);
1480 else
1481 /* Slightly different logic because tmp/op will be removed by
1482 * the save_object we call. So we just keep looking at op->inv
1483 * until there is nothing left. In theory, the variable old
1484 * should not be needed, as recursive loops shouldn't happen.
1485 */
1486 while ((tmp = op->inv) != NULL)
1487 {
1488 if (old == tmp)
1489 {
1490 LOG (llevError, " Recursive loop in inventory\n");
1491 break;
1492 }
1493
1494 save_object (fp, tmp, flag);
1495 old = tmp;
1496 }
1497
1498 if (!(flag & 2))
1499 op->destroy ();
1500 1468
1501 fp.put (op); 1469 fp.put (op);
1502 fprintf (fp, "end\n"); 1470 fprintf (fp, "end\n");
1503} 1471}
1504 1472

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines