… | |
… | |
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 | |
|
|
34 | extern 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 | |
254 | extern 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 */ |
… | |
… | |
602 | if (!other_arch) |
602 | if (!other_arch) |
603 | LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ()); |
603 | LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ()); |
604 | break; |
604 | break; |
605 | |
605 | |
606 | case KW_owner: |
606 | case KW_owner: |
607 | if (const char *s = f.get_str ()) |
607 | 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; |
608 | break; |
623 | |
609 | |
624 | case KW_animation: |
610 | case KW_animation: |
625 | { |
611 | { |
626 | CLEAR_FLAG (this, FLAG_ANIMATE); |
612 | CLEAR_FLAG (this, FLAG_ANIMATE); |
… | |
… | |
1065 | int |
1051 | int |
1066 | set_variable (object *op, char *buf) |
1052 | set_variable (object *op, char *buf) |
1067 | { |
1053 | { |
1068 | object_thawer f (buf, (AV *)0); |
1054 | object_thawer f (buf, (AV *)0); |
1069 | |
1055 | |
1070 | f.next (); |
|
|
1071 | return op->parse_kv (f); |
1056 | return op->parse_kv (f); |
1072 | } |
1057 | } |
1073 | |
1058 | |
1074 | /* This returns a string of the integer movement type */ |
1059 | /* This returns a string of the integer movement type */ |
1075 | #if 0 |
1060 | #if 0 |
… | |
… | |
1290 | } |
1275 | } |
1291 | |
1276 | |
1292 | #define CMP_OUT(v) if (expect_false (op->v != tmp->v)) f.put (KW_ ## v, op->v) |
1277 | #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) |
1278 | #define CMP_OUT2(k,v) if (expect_false (op->v != tmp->v)) f.put (KW_ ## k, op->v) |
1294 | |
1279 | |
1295 | if (object *pl = op->owner) |
1280 | if (object *owner = op->owner) |
1296 | if (pl->contr) |
1281 | 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 | |
1282 | |
1303 | CMP_OUT (name); |
1283 | CMP_OUT (name); |
1304 | CMP_OUT (name_pl); |
1284 | CMP_OUT (name_pl); |
1305 | CMP_OUT (custom_name); |
1285 | CMP_OUT (custom_name); |
1306 | CMP_OUT (title); |
1286 | CMP_OUT (title); |
… | |
… | |
1457 | object_thawer f (filename); |
1437 | object_thawer f (filename); |
1458 | |
1438 | |
1459 | bool success = false; |
1439 | bool success = false; |
1460 | bool seen_arch = false; |
1440 | bool seen_arch = false; |
1461 | |
1441 | |
1462 | f.next (); |
|
|
1463 | |
|
|
1464 | for (;;) |
1442 | for (;;) |
1465 | { |
1443 | { |
1466 | switch (f.kw) |
1444 | switch (f.kw) |
1467 | { |
1445 | { |
1468 | case KW_region: |
1446 | case KW_region: |