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.99 by root, Sat Aug 25 22:19:26 2007 UTC vs.
Revision 1.102 by root, Mon Sep 10 12:44:06 2007 UTC

28#include <global.h> 28#include <global.h>
29#include <loader.h> 29#include <loader.h>
30#include <sproto.h> 30#include <sproto.h>
31 31
32///////////////////////////////////////////////////////////////////////////// 32/////////////////////////////////////////////////////////////////////////////
33
34extern archetype *loading_arch;
33 35
34/* This table is only necessary to convert objects that existed before the 36/* This table is only necessary to convert objects that existed before the
35 * spell object conversion to the new object. It was not practical 37 * spell object conversion to the new object. It was not practical
36 * to go through every mapping looking for every potion, rod, wand, etc 38 * to go through every mapping looking for every potion, rod, wand, etc
37 * that had a sp set and update to the new value. So this maps the 39 * that had a sp set and update to the new value. So this maps the
249 "spell_cause_rabies", /* 204 */ 251 "spell_cause_rabies", /* 204 */
250 "spell_glyph", /* 205 */ 252 "spell_glyph", /* 205 */
251 NULL 253 NULL
252}; 254};
253 255
254extern bool loading_arch;
255
256/* This function checks the object after it has been loaded (when we 256/* This function checks the object after it has been loaded (when we
257 * get the 'end' in the input stream). This function can be used to 257 * get the 'end' in the input stream). This function can be used to
258 * deal with legacy objects where fields may have changed. It can also be used 258 * deal with legacy objects where fields may have changed. It can also be used
259 * to check for objects to make sure there are no common errors. 259 * to check for objects to make sure there are no common errors.
260 */ 260 */
394 /* Old spellcasting object - need to load in the appropiate object */ 394 /* Old spellcasting object - need to load in the appropiate object */
395 if ((type == ROD || type == WAND || type == SCROLL || type == HORN || type == FIREWALL || 395 if ((type == ROD || type == WAND || type == SCROLL || type == HORN || type == FIREWALL ||
396 /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ 396 /* POTIONS and ALTARS don't always cast spells, but if they do, update them */
397 ((type == POTION || type == ALTAR) && stats.sp)) && !inv && !loading_arch) 397 ((type == POTION || type == ALTAR) && stats.sp)) && !inv && !loading_arch)
398 { 398 {
399 /* Fireall is bizarre in that spell type was stored in dam. Rest are 'normal' 399 /* Firewall is bizarre in that spell type was stored in dam. Rest are 'normal'
400 * in that spell was stored in sp. 400 * in that spell was stored in sp.
401 */ 401 */
402 object *tmp = get_archetype (spell_mapping[type == FIREWALL ? stats.dam : stats.sp]); 402 object *tmp = get_archetype (spell_mapping[type == FIREWALL ? stats.dam : stats.sp]);
403 insert_ob_in_ob (tmp, this); 403 insert_ob_in_ob (tmp, this);
404 randomitems = NULL; /* So another spell isn't created for this object */ 404 randomitems = NULL; /* So another spell isn't created for this object */
556 556
557 case KW_attach: f.get_ornull (attach); break; 557 case KW_attach: f.get_ornull (attach); break;
558 case KW_skill: f.get_ornull (skill); break; 558 case KW_skill: f.get_ornull (skill); break;
559 case KW_race: f.get_ornull (race); break; 559 case KW_race: f.get_ornull (race); break;
560 case KW_slaying: f.get_ornull (slaying); break; 560 case KW_slaying: f.get_ornull (slaying); break;
561 case KW_tag: f.get_ornull (tag); break;
561 562
562 case KW_arch: 563 case KW_arch:
563 { 564 {
564 object *tmp = object::read (f); 565 object *tmp = object::read (f);
565 tmp->deactivate (); 566 tmp->deactivate ();
602 if (!other_arch) 603 if (!other_arch)
603 LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ()); 604 LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ());
604 break; 605 break;
605 606
606 case KW_owner: 607 case KW_owner:
607 if (const char *s = f.get_str ()) 608 f.delayed_deref (this, owner, f.get_str ());
608 {
609 unsigned int version;
610 unsigned long long seq;
611 char name[256];
612
613 if (3 == sscanf (s, "<%d.%llx>/%256s", &version, &seq, name) && version == 1)
614 {
615 UUID uuid = seq;
616 player *pl = player::find (name);
617
618 if (pl && pl->ob->uuid == uuid)
619 owner = pl->ob;
620 }
621 }
622 break; 609 break;
623 610
624 case KW_animation: 611 case KW_animation:
625 { 612 {
626 CLEAR_FLAG (this, FLAG_ANIMATE); 613 CLEAR_FLAG (this, FLAG_ANIMATE);
1065int 1052int
1066set_variable (object *op, char *buf) 1053set_variable (object *op, char *buf)
1067{ 1054{
1068 object_thawer f (buf, (AV *)0); 1055 object_thawer f (buf, (AV *)0);
1069 1056
1070 f.next ();
1071 return op->parse_kv (f); 1057 return op->parse_kv (f);
1072} 1058}
1073 1059
1074/* This returns a string of the integer movement type */ 1060/* This returns a string of the integer movement type */
1075#if 0 1061#if 0
1290 } 1276 }
1291 1277
1292#define CMP_OUT(v) if (expect_false (op->v != tmp->v)) f.put (KW_ ## v, op->v) 1278#define CMP_OUT(v) if (expect_false (op->v != tmp->v)) f.put (KW_ ## v, op->v)
1293#define CMP_OUT2(k,v) if (expect_false (op->v != tmp->v)) f.put (KW_ ## k, op->v) 1279#define CMP_OUT2(k,v) if (expect_false (op->v != tmp->v)) f.put (KW_ ## k, op->v)
1294 1280
1295 if (object *pl = op->owner) 1281 if (object *owner = op->owner)
1296 if (pl->contr) 1282 f.put (KW_owner, static_cast<const char *>(owner->ref ()));
1297 {
1298 char owner[256];
1299 snprintf (owner, sizeof (owner), "<1.%llx>/%s", (unsigned long long)pl->uuid.seq, &pl->name);
1300 f.put (KW_owner, (const char *)owner);
1301 }
1302 1283
1303 CMP_OUT (name); 1284 CMP_OUT (name);
1304 CMP_OUT (name_pl); 1285 CMP_OUT (name_pl);
1305 CMP_OUT (custom_name); 1286 CMP_OUT (custom_name);
1306 CMP_OUT (title); 1287 CMP_OUT (title);
1307 CMP_OUT (race); 1288 CMP_OUT (race);
1308 CMP_OUT (slaying); 1289 CMP_OUT (slaying);
1290 CMP_OUT (tag);
1309 CMP_OUT (other_arch); 1291 CMP_OUT (other_arch);
1310 1292
1311 if (op->msg != tmp->msg ) f.put (KW_msg , KW_endmsg , op->msg ); 1293 if (op->msg != tmp->msg ) f.put (KW_msg , KW_endmsg , op->msg );
1312 if (op->lore != tmp->lore) f.put (KW_lore, KW_endlore, op->lore); 1294 if (op->lore != tmp->lore) f.put (KW_lore, KW_endlore, op->lore);
1313 1295
1457 object_thawer f (filename); 1439 object_thawer f (filename);
1458 1440
1459 bool success = false; 1441 bool success = false;
1460 bool seen_arch = false; 1442 bool seen_arch = false;
1461 1443
1462 f.next ();
1463
1464 for (;;) 1444 for (;;)
1465 { 1445 {
1466 switch (f.kw) 1446 switch (f.kw)
1467 { 1447 {
1468 case KW_region: 1448 case KW_region:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines