… | |
… | |
260 | * to check for objects to make sure there are no common errors. |
260 | * to check for objects to make sure there are no common errors. |
261 | */ |
261 | */ |
262 | void |
262 | void |
263 | object::post_load_check () |
263 | object::post_load_check () |
264 | { |
264 | { |
265 | // as a kind of a hack, we now adjust the range, shield and combat slots |
265 | if (type >= NUM_TYPES) |
|
|
266 | { |
|
|
267 | LOG (llevError, "%s: type out of range, resetting to 0.\n", debug_desc ()); |
|
|
268 | type = 0; |
|
|
269 | } |
|
|
270 | |
266 | switch (type) |
271 | switch (type) |
267 | { |
272 | { |
268 | case BOW: |
273 | case BOW: |
269 | case WAND: |
274 | case WAND: |
270 | case ROD: |
275 | case ROD: |
271 | case HORN: |
276 | case HORN: |
272 | case SKILL: // maybe have to think about this one, as skills get applied togethr with their governing weapons |
|
|
273 | case SKILL_TOOL: |
|
|
274 | if (slot [body_range].info != -1) |
277 | if (slot [body_range].info != -1) |
275 | { |
278 | { |
276 | LOG (llevInfo, "%s: body_range %d != -1\n", debug_desc (), slot [body_range].info); |
279 | LOG (llevError, "%s: body_range %d != -1\n", debug_desc (), slot [body_range].info); |
277 | slot [body_range].info = -1; |
280 | slot [body_range].info = -1; |
278 | } |
281 | } |
279 | break; |
282 | break; |
280 | |
283 | |
281 | case WEAPON: |
284 | case WEAPON: |
282 | if (slot [body_combat].info != -1) |
285 | if (slot [body_combat].info != -1) |
283 | { |
286 | { |
284 | LOG (llevInfo, "%s: body_combat %d != -1\n", debug_desc (), slot [body_combat].info); |
287 | LOG (llevError, "%s: body_combat %d != -1\n", debug_desc (), slot [body_combat].info); |
285 | slot [body_combat].info = -1; |
288 | slot [body_combat].info = -1; |
286 | } |
289 | } |
287 | break; |
290 | break; |
288 | |
291 | |
289 | case SHIELD: |
292 | case SHIELD: |
290 | if (slot [body_shield].info != -1) |
293 | if (slot [body_shield].info != -1) |
291 | { |
294 | { |
292 | LOG (llevInfo, "%s: body_shield %d != -1\n", debug_desc (), slot [body_shield].info); |
295 | LOG (llevError, "%s: body_shield %d != -1\n", debug_desc (), slot [body_shield].info); |
293 | slot [body_shield].info = -1; |
296 | slot [body_shield].info = -1; |
294 | } |
297 | } |
295 | break; |
298 | break; |
296 | |
299 | |
297 | case PLAYER: |
300 | case PLAYER: |
298 | if (slot [body_shield].info != 1) |
301 | if (slot [body_shield].info != 1) |
299 | { |
302 | { |
300 | LOG (llevInfo, "%s: body_shield %d != 1\n", debug_desc (), slot [body_shield].info); |
303 | LOG (llevError, "%s: body_shield %d != 1\n", debug_desc (), slot [body_shield].info); |
301 | slot [body_shield].info = 1; |
304 | slot [body_shield].info = 1; |
302 | } |
305 | } |
303 | |
306 | |
304 | if (slot [body_combat].info != 1) |
307 | if (slot [body_combat].info != 1) |
305 | { |
308 | { |
306 | LOG (llevInfo, "%s: body_combat %d != 1\n", debug_desc (), slot [body_combat].info); |
309 | LOG (llevError, "%s: body_combat %d != 1\n", debug_desc (), slot [body_combat].info); |
307 | slot [body_combat].info = 1; |
310 | slot [body_combat].info = 1; |
308 | } |
311 | } |
309 | |
312 | |
310 | if (slot [body_range].info != 1) |
313 | if (slot [body_range].info != 1) |
311 | { |
314 | { |
312 | LOG (llevInfo, "%s: body_range %d != 1\n", debug_desc (), slot [body_range].info); |
315 | LOG (llevError, "%s: body_range %d != 1\n", debug_desc (), slot [body_range].info); |
313 | slot [body_range].info = 1; |
316 | slot [body_range].info = 1; |
314 | } |
317 | } |
315 | break; |
318 | break; |
316 | } |
319 | } |
317 | |
320 | |
… | |
… | |
381 | * something that has item_power 1 is probably just fine if our calculated |
384 | * something that has item_power 1 is probably just fine if our calculated |
382 | * value is 1 or 2 - these values are small enough that hard to be precise. |
385 | * value is 1 or 2 - these values are small enough that hard to be precise. |
383 | * similarly, it item_power is 0, the first check will always pass, |
386 | * similarly, it item_power is 0, the first check will always pass, |
384 | * but not the second one. |
387 | * but not the second one. |
385 | */ |
388 | */ |
|
|
389 | #if 0 //TODO |
386 | if (ip > 2 * item_power && ip > (item_power + 3)) |
390 | if (ip > 2 * item_power && ip > (item_power + 3)) |
387 | LOG (llevDebug, "Object %s seems to have too low item power? %d > %d\n", debug_desc (), ip, item_power); |
391 | LOG (llevDebug, "Object %s seems to have too low item power? %d > %d\n", debug_desc (), ip, item_power); |
|
|
392 | #endif |
388 | } |
393 | } |
389 | |
394 | |
390 | /* Old spellcasting object - need to load in the appropiate object */ |
395 | /* Old spellcasting object - need to load in the appropiate object */ |
391 | if ((type == ROD || type == WAND || type == SCROLL || type == HORN || type == FIREWALL || |
396 | if ((type == ROD || type == WAND || type == SCROLL || type == HORN || type == FIREWALL || |
392 | /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ |
397 | /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ |
… | |
… | |
512 | |
517 | |
513 | next: ; |
518 | next: ; |
514 | } |
519 | } |
515 | } |
520 | } |
516 | |
521 | |
517 | #define GET_FLAG(op,flag) \ |
522 | #define GET_FLAG(op,flg) op->flag [flg] = f.get_bool () |
518 | if (f.get_sint32 ()) \ |
|
|
519 | SET_FLAG (op, flag); \ |
|
|
520 | else \ |
|
|
521 | CLEAR_FLAG (op, flag) \ |
|
|
522 | |
523 | |
523 | bool |
524 | bool |
524 | object::parse_kv (object_thawer &f) |
525 | object::parse_kv (object_thawer &f) |
525 | { |
526 | { |
526 | object *op_inv = inv; |
527 | object *op_inv = inv; |
… | |
… | |
771 | if (QUERY_FLAG (this, FLAG_IDENTIFIED)) |
772 | if (QUERY_FLAG (this, FLAG_IDENTIFIED)) |
772 | CLEAR_FLAG (this, FLAG_KNOWN_MAGICAL); |
773 | CLEAR_FLAG (this, FLAG_KNOWN_MAGICAL); |
773 | |
774 | |
774 | break; |
775 | break; |
775 | |
776 | |
776 | case KW_wiz: |
|
|
777 | GET_FLAG (this, FLAG_WIZ); |
|
|
778 | //TODO: move to check_object |
|
|
779 | if (QUERY_FLAG (this, FLAG_WIZ)) |
|
|
780 | { |
|
|
781 | SET_FLAG (this, FLAG_WAS_WIZ); |
|
|
782 | SET_FLAG (this, FLAG_WIZPASS); |
|
|
783 | SET_FLAG (this, FLAG_WIZCAST); |
|
|
784 | } |
|
|
785 | else |
|
|
786 | { |
|
|
787 | CLEAR_FLAG (this, FLAG_WIZPASS); |
|
|
788 | CLEAR_FLAG (this, FLAG_WIZCAST); |
|
|
789 | } |
|
|
790 | break; |
|
|
791 | |
|
|
792 | case KW_friendly: |
777 | case KW_friendly: |
793 | if (f.get_sint32 ()) |
778 | if (f.get_bool ()) |
794 | if (type != PLAYER) |
779 | if (type != PLAYER) |
795 | add_friendly_object (this); |
780 | add_friendly_object (this); |
796 | |
781 | |
797 | break; |
782 | break; |
798 | |
783 | |
… | |
… | |
827 | case KW_reflect_missile: GET_FLAG (this, FLAG_REFL_MISSILE); break; |
812 | case KW_reflect_missile: GET_FLAG (this, FLAG_REFL_MISSILE); break; |
828 | case KW_reflect_spell: GET_FLAG (this, FLAG_REFL_SPELL); break; |
813 | case KW_reflect_spell: GET_FLAG (this, FLAG_REFL_SPELL); break; |
829 | case KW_no_magic: GET_FLAG (this, FLAG_NO_MAGIC); break; |
814 | case KW_no_magic: GET_FLAG (this, FLAG_NO_MAGIC); break; |
830 | case KW_no_drop: GET_FLAG (this, FLAG_NO_DROP); break; |
815 | case KW_no_drop: GET_FLAG (this, FLAG_NO_DROP); break; |
831 | case KW_random_movement: GET_FLAG (this, FLAG_RANDOM_MOVE); break; |
816 | case KW_random_movement: GET_FLAG (this, FLAG_RANDOM_MOVE); break; |
832 | case KW_was_wiz: GET_FLAG (this, FLAG_WAS_WIZ); break; |
|
|
833 | case KW_no_fix_player: GET_FLAG (this, FLAG_NO_FIX_PLAYER); break; |
817 | case KW_no_fix_player: GET_FLAG (this, FLAG_NO_FIX_PLAYER); break; |
834 | case KW_is_lightable: GET_FLAG (this, FLAG_IS_LIGHTABLE); break; |
818 | case KW_is_lightable: GET_FLAG (this, FLAG_IS_LIGHTABLE); break; |
835 | case KW_tear_down: GET_FLAG (this, FLAG_TEAR_DOWN); break; |
819 | case KW_tear_down: GET_FLAG (this, FLAG_TEAR_DOWN); break; |
836 | case KW_can_use_shield: GET_FLAG (this, FLAG_USE_SHIELD); break; |
820 | case KW_can_use_shield: GET_FLAG (this, FLAG_USE_SHIELD); break; |
837 | case KW_can_cast_spell: GET_FLAG (this, FLAG_CAST_SPELL); break; |
821 | case KW_can_cast_spell: GET_FLAG (this, FLAG_CAST_SPELL); break; |
… | |
… | |
1137 | * the 15'th element of this array should match that name. |
1121 | * the 15'th element of this array should match that name. |
1138 | * If an entry is NULL, that is a flag not to loaded/saved. |
1122 | * If an entry is NULL, that is a flag not to loaded/saved. |
1139 | */ |
1123 | */ |
1140 | static const keyword flag_names [NUM_FLAGS] = { |
1124 | static const keyword flag_names [NUM_FLAGS] = { |
1141 | KW_alive, |
1125 | KW_alive, |
1142 | KW_wiz, |
|
|
1143 | KW_NULL, |
1126 | KW_NULL, |
1144 | KW_NULL, |
1127 | KW_NULL, |
1145 | KW_was_wiz, |
1128 | KW_NULL, |
|
|
1129 | KW_NULL, |
1146 | KW_applied, |
1130 | KW_applied, |
1147 | KW_unpaid, |
1131 | KW_unpaid, |
1148 | KW_can_use_shield, |
1132 | KW_can_use_shield, |
1149 | KW_no_pick, |
1133 | KW_no_pick, |
1150 | KW_NULL, // walk_on |
1134 | KW_NULL, // walk_on |