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.29 by root, Mon Dec 25 17:11:16 2006 UTC

1441 1441
1442/* 1442/*
1443 * Dumps all variables in an object to a file. 1443 * 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, 1444 * 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. 1445 * 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 */ 1446 */
1449
1450void 1447void
1451save_object (object_freezer & fp, object *op, int flag) 1448save_object (object_freezer &fp, object *op, int flag)
1452{ 1449{
1453 archetype *at;
1454 object *tmp, *old;
1455
1456 /* Even if the object does have an owner, it would seem that we should 1450 /* Even if the object does have an owner, it would seem that we should
1457 * still save it. 1451 * still save it.
1458 */ 1452 */
1459 if (op->owner) 1453 if (op->owner)
1460 return; 1454 return;
1461 1455
1462 /* If it is unpaid and we don't want to save those, just return. */ 1456 /* If it is unpaid and we don't want to save those, just return. */
1463 if (!(flag & 1) && (QUERY_FLAG (op, FLAG_UNPAID))) 1457 if (!(flag & 1) && op->flag [FLAG_UNPAID])
1464 return; 1458 return;
1465 1459
1466 if ((at = op->arch) == NULL) 1460 archetype *at = op->arch ? (archetype *)op->arch : empty_archetype;
1467 at = empty_archetype;
1468 1461
1469 fp.put (KW_arch, at->name); 1462 fp.put (KW_arch, at->name);
1470
1471 put (fp, op, &at->clone); 1463 put (fp, op, &at->clone);
1472 1464
1473 /* Eneq(@csd.uu.se): Added this to allow containers being saved with contents */ 1465 /* Eneq(@csd.uu.se): Added this to allow containers being saved with contents */
1474 1466
1475 old = NULL;
1476
1477 if (flag & 2)
1478 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1467 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1479 save_object (fp, tmp, flag); 1468 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 1469
1501 fp.put (op); 1470 fp.put (op);
1502 fprintf (fp, "end\n"); 1471 fprintf (fp, "end\n");
1503} 1472}
1504 1473

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines