… | |
… | |
255 | NULL |
255 | NULL |
256 | }; |
256 | }; |
257 | |
257 | |
258 | extern int arch_init; |
258 | extern int arch_init; |
259 | |
259 | |
260 | // return a suitable strign describign an objetc in enough detail to find it |
|
|
261 | // used only in check_loaded_object: TODO remove static, move it elsewhere and |
|
|
262 | // use it in more log messages. |
|
|
263 | static char * |
|
|
264 | op_debug_info_ (object *op, char *info) |
|
|
265 | { |
|
|
266 | char info2[256 * 3]; |
|
|
267 | char *p = info; |
|
|
268 | |
|
|
269 | p += snprintf (p, 256, "%d=\"%s%s%s\"", |
|
|
270 | op->count, op->name ? (const char *) op->name : "(anon)", op->title ? " " : "", op->title ? (const char *) op->title : ""); |
|
|
271 | |
|
|
272 | if (op->env) |
|
|
273 | p += snprintf (p, 256, "(in %s)", op_debug_info_ (op->env, info2)); |
|
|
274 | |
|
|
275 | if (op->map) |
|
|
276 | p += snprintf (p, 256, "(on %s@%d+%d)", op->map->path, op->x, op->y); |
|
|
277 | |
|
|
278 | return info; |
|
|
279 | } |
|
|
280 | |
|
|
281 | static char * |
|
|
282 | op_debug_info (object *op) |
|
|
283 | { |
|
|
284 | static char info[256 * 3]; |
|
|
285 | |
|
|
286 | return op_debug_info_ (op, info); |
|
|
287 | } |
|
|
288 | |
|
|
289 | /* This function checks the object after it has been loaded (when we |
260 | /* This function checks the object after it has been loaded (when we |
290 | * get the 'end' in the input stream). This function can be used to |
261 | * get the 'end' in the input stream). This function can be used to |
291 | * deal with legacy objects where fields may have changed. It can also be used |
262 | * deal with legacy objects where fields may have changed. It can also be used |
292 | * to check for objects to make sure there are no common errors. |
263 | * to check for objects to make sure there are no common errors. |
293 | */ |
264 | */ |
… | |
… | |
326 | */ |
297 | */ |
327 | if ((op->type == WEAPON || op->type == BOW) && arch_init) |
298 | if ((op->type == WEAPON || op->type == BOW) && arch_init) |
328 | { |
299 | { |
329 | if (!op->skill) |
300 | if (!op->skill) |
330 | { |
301 | { |
331 | LOG (llevError, "Weapon %s lacks a skill.\n", op_debug_info (op)); |
302 | LOG (llevError, "Weapon %s lacks a skill.\n", op->debug_desc ()); |
332 | } |
303 | } |
333 | else if ((!strcmp (op->skill, "one handed weapons") && op->body_info[1] != -1) || |
304 | else if ((!strcmp (op->skill, "one handed weapons") && op->body_info[1] != -1) || |
334 | (!strcmp (op->skill, "two handed weapons") && op->body_info[1] != -2)) |
305 | (!strcmp (op->skill, "two handed weapons") && op->body_info[1] != -2)) |
335 | { |
306 | { |
336 | LOG (llevError, "weapon %s arm usage does not match skill: %d, %s\n", op_debug_info (op), op->body_info[1], &op->skill); |
307 | LOG (llevError, "weapon %s arm usage does not match skill: %d, %s\n", op->debug_desc (), op->body_info[1], &op->skill); |
337 | } |
308 | } |
338 | } |
309 | } |
339 | |
310 | |
340 | /* We changed last_heal to gen_sp_armour, which is what it |
311 | /* We changed last_heal to gen_sp_armour, which is what it |
341 | * really does for many objects. Need to catch any in maps |
312 | * really does for many objects. Need to catch any in maps |
… | |
… | |
347 | (op->type == BOOTS) || (op->type == GLOVES) || |
318 | (op->type == BOOTS) || (op->type == GLOVES) || |
348 | (op->type == AMULET) || (op->type == GIRDLE) || (op->type == BRACERS) || (op->type == CLOAK)) |
319 | (op->type == AMULET) || (op->type == GIRDLE) || (op->type == BRACERS) || (op->type == CLOAK)) |
349 | { |
320 | { |
350 | if (op->last_heal) |
321 | if (op->last_heal) |
351 | { |
322 | { |
352 | LOG (llevDebug, "Object %s still has last_heal set, not gen_sp_armour\n", op_debug_info (op)); |
323 | LOG (llevDebug, "Object %s still has last_heal set, not gen_sp_armour\n", op->debug_desc ()); |
353 | op->gen_sp_armour = op->last_heal; |
324 | op->gen_sp_armour = op->last_heal; |
354 | op->last_heal = 0; |
325 | op->last_heal = 0; |
355 | } |
326 | } |
356 | if (editor) |
327 | if (editor) |
357 | ip = 0; |
328 | ip = 0; |
… | |
… | |
360 | /* Legacy objects from before item power was in the game */ |
331 | /* Legacy objects from before item power was in the game */ |
361 | if (!op->item_power && ip) |
332 | if (!op->item_power && ip) |
362 | { |
333 | { |
363 | if (ip > 3) |
334 | if (ip > 3) |
364 | { |
335 | { |
365 | LOG (llevDebug, "Object %s had no item power, using %d\n", op_debug_info (op), ip); |
336 | LOG (llevDebug, "Object %s had no item power, using %d\n", op->debug_desc (), ip); |
366 | } |
337 | } |
367 | op->item_power = ip; |
338 | op->item_power = ip; |
368 | } |
339 | } |
369 | /* Check for possibly bogus values. Has to meet both these criteria - |
340 | /* Check for possibly bogus values. Has to meet both these criteria - |
370 | * something that has item_power 1 is probably just fine if our calculated |
341 | * something that has item_power 1 is probably just fine if our calculated |
… | |
… | |
372 | * similarly, it item_power is 0, the first check will always pass, |
343 | * similarly, it item_power is 0, the first check will always pass, |
373 | * but not the second one. |
344 | * but not the second one. |
374 | */ |
345 | */ |
375 | if (ip > 2 * op->item_power && ip > (op->item_power + 3)) |
346 | if (ip > 2 * op->item_power && ip > (op->item_power + 3)) |
376 | { |
347 | { |
377 | LOG (llevDebug, "Object %s seems to have too low item power? %d > %d\n", op_debug_info (op), ip, op->item_power); |
348 | LOG (llevDebug, "Object %s seems to have too low item power? %d > %d\n", op->debug_desc (), ip, op->item_power); |
378 | } |
349 | } |
379 | |
350 | |
380 | } |
351 | } |
381 | /* Old spellcasting object - need to load in the appropiate object */ |
352 | /* Old spellcasting object - need to load in the appropiate object */ |
382 | if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN || op->type == FIREWALL || |
353 | if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN || op->type == FIREWALL || |
… | |
… | |
406 | } |
377 | } |
407 | |
378 | |
408 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
379 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
409 | { |
380 | { |
410 | if (op->stats.hp > op->stats.maxhp) |
381 | if (op->stats.hp > op->stats.maxhp) |
411 | LOG (llevDebug, "Monster %s has hp set higher than maxhp (%d>%d)\n", op_debug_info (op), op->stats.hp, op->stats.maxhp); |
382 | LOG (llevDebug, "Monster %s has hp set higher than maxhp (%d>%d)\n", op->debug_desc (), op->stats.hp, op->stats.maxhp); |
412 | |
383 | |
413 | /* The archs just need to be updated for this */ |
384 | /* The archs just need to be updated for this */ |
414 | if (op->move_type == 0) |
385 | if (op->move_type == 0) |
415 | op->move_type = MOVE_WALK; |
386 | op->move_type = MOVE_WALK; |
416 | } |
387 | } |
|
|
388 | |
417 | if ((QUERY_FLAG (op, FLAG_GENERATOR) && QUERY_FLAG (op, FLAG_CONTENT_ON_GEN)) || op->type == CREATOR || op->type == CONVERTER) |
389 | if ((QUERY_FLAG (op, FLAG_GENERATOR) && QUERY_FLAG (op, FLAG_CONTENT_ON_GEN)) || op->type == CREATOR || op->type == CONVERTER) |
418 | { |
390 | { |
419 | /* Object will duplicate it's content as part of the |
391 | /* Object will duplicate it's content as part of the |
420 | * generation process. To do this, we must flag inventory |
392 | * generation process. To do this, we must flag inventory |
421 | * so it remains unevaluated concerning the randomitems and |
393 | * so it remains unevaluated concerning the randomitems and |