… | |
… | |
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_shield %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; |
|
|
311 | } |
|
|
312 | |
|
|
313 | if (slot [body_range].info != 1) |
|
|
314 | { |
|
|
315 | LOG (llevError, "%s: body_range %d != 1\n", debug_desc (), slot [body_range].info); |
|
|
316 | slot [body_range].info = 1; |
308 | } |
317 | } |
309 | break; |
318 | break; |
310 | } |
319 | } |
311 | |
320 | |
312 | /* We do some specialised handling to handle legacy cases of name_pl. |
321 | /* We do some specialised handling to handle legacy cases of name_pl. |
… | |
… | |
324 | if (!name_pl) |
333 | if (!name_pl) |
325 | name_pl = name; |
334 | name_pl = name; |
326 | |
335 | |
327 | /* objects now have a materialname. try to patch it in */ |
336 | /* objects now have a materialname. try to patch it in */ |
328 | if (!(is_weapon () && level > 0)) |
337 | if (!(is_weapon () && level > 0)) |
329 | { |
|
|
330 | if (map != NULL) |
|
|
331 | set_materialname (this, map->difficulty, NULL); |
338 | set_materialname (this, map ? map->difficulty : 5, 0); |
332 | else |
|
|
333 | set_materialname (this, 5, NULL); |
|
|
334 | } |
|
|
335 | |
339 | |
336 | /* only do these when program is first run - a bit |
340 | /* only do these when program is first run - a bit |
337 | * excessive to do this at every run - most of this is |
341 | * excessive to do this at every run - most of this is |
338 | * really just to catch any errors - program will still run, but |
342 | * really just to catch any errors - program will still run, but |
339 | * not in the ideal fashion. |
343 | * not in the ideal fashion. |
… | |
… | |
768 | GET_FLAG (this, FLAG_IDENTIFIED); |
772 | GET_FLAG (this, FLAG_IDENTIFIED); |
769 | //TODO: move to check_object or so |
773 | //TODO: move to check_object or so |
770 | if (QUERY_FLAG (this, FLAG_IDENTIFIED)) |
774 | if (QUERY_FLAG (this, FLAG_IDENTIFIED)) |
771 | CLEAR_FLAG (this, FLAG_KNOWN_MAGICAL); |
775 | CLEAR_FLAG (this, FLAG_KNOWN_MAGICAL); |
772 | |
776 | |
773 | break; |
|
|
774 | |
|
|
775 | case KW_wiz: |
|
|
776 | GET_FLAG (this, FLAG_WIZ); |
|
|
777 | //TODO: move to check_object |
|
|
778 | if (QUERY_FLAG (this, FLAG_WIZ)) |
|
|
779 | { |
|
|
780 | SET_FLAG (this, FLAG_WAS_WIZ); |
|
|
781 | SET_FLAG (this, FLAG_WIZPASS); |
|
|
782 | SET_FLAG (this, FLAG_WIZCAST); |
|
|
783 | } |
|
|
784 | else |
|
|
785 | { |
|
|
786 | CLEAR_FLAG (this, FLAG_WIZPASS); |
|
|
787 | CLEAR_FLAG (this, FLAG_WIZCAST); |
|
|
788 | } |
|
|
789 | break; |
777 | break; |
790 | |
778 | |
791 | case KW_friendly: |
779 | case KW_friendly: |
792 | if (f.get_sint32 ()) |
780 | if (f.get_sint32 ()) |
793 | if (type != PLAYER) |
781 | if (type != PLAYER) |
… | |
… | |
826 | case KW_reflect_missile: GET_FLAG (this, FLAG_REFL_MISSILE); break; |
814 | case KW_reflect_missile: GET_FLAG (this, FLAG_REFL_MISSILE); break; |
827 | case KW_reflect_spell: GET_FLAG (this, FLAG_REFL_SPELL); break; |
815 | case KW_reflect_spell: GET_FLAG (this, FLAG_REFL_SPELL); break; |
828 | case KW_no_magic: GET_FLAG (this, FLAG_NO_MAGIC); break; |
816 | case KW_no_magic: GET_FLAG (this, FLAG_NO_MAGIC); break; |
829 | case KW_no_drop: GET_FLAG (this, FLAG_NO_DROP); break; |
817 | case KW_no_drop: GET_FLAG (this, FLAG_NO_DROP); break; |
830 | case KW_random_movement: GET_FLAG (this, FLAG_RANDOM_MOVE); break; |
818 | case KW_random_movement: GET_FLAG (this, FLAG_RANDOM_MOVE); break; |
831 | case KW_was_wiz: GET_FLAG (this, FLAG_WAS_WIZ); break; |
|
|
832 | case KW_no_fix_player: GET_FLAG (this, FLAG_NO_FIX_PLAYER); break; |
819 | case KW_no_fix_player: GET_FLAG (this, FLAG_NO_FIX_PLAYER); break; |
833 | case KW_is_lightable: GET_FLAG (this, FLAG_IS_LIGHTABLE); break; |
820 | case KW_is_lightable: GET_FLAG (this, FLAG_IS_LIGHTABLE); break; |
834 | case KW_tear_down: GET_FLAG (this, FLAG_TEAR_DOWN); break; |
821 | case KW_tear_down: GET_FLAG (this, FLAG_TEAR_DOWN); break; |
835 | case KW_can_use_shield: GET_FLAG (this, FLAG_USE_SHIELD); break; |
822 | case KW_can_use_shield: GET_FLAG (this, FLAG_USE_SHIELD); break; |
836 | case KW_can_cast_spell: GET_FLAG (this, FLAG_CAST_SPELL); break; |
823 | case KW_can_cast_spell: GET_FLAG (this, FLAG_CAST_SPELL); break; |
… | |
… | |
1136 | * the 15'th element of this array should match that name. |
1123 | * the 15'th element of this array should match that name. |
1137 | * If an entry is NULL, that is a flag not to loaded/saved. |
1124 | * If an entry is NULL, that is a flag not to loaded/saved. |
1138 | */ |
1125 | */ |
1139 | static const keyword flag_names [NUM_FLAGS] = { |
1126 | static const keyword flag_names [NUM_FLAGS] = { |
1140 | KW_alive, |
1127 | KW_alive, |
1141 | KW_wiz, |
|
|
1142 | KW_NULL, |
1128 | KW_NULL, |
1143 | KW_NULL, |
1129 | KW_NULL, |
1144 | KW_was_wiz, |
1130 | KW_NULL, |
|
|
1131 | KW_NULL, |
1145 | KW_applied, |
1132 | KW_applied, |
1146 | KW_unpaid, |
1133 | KW_unpaid, |
1147 | KW_can_use_shield, |
1134 | KW_can_use_shield, |
1148 | KW_no_pick, |
1135 | KW_no_pick, |
1149 | KW_NULL, // walk_on |
1136 | KW_NULL, // walk_on |