--- deliantra/server/common/loader.l 2006/05/11 18:37:20 1.2 +++ deliantra/server/common/loader.l 2006/05/11 20:15:30 1.4 @@ -327,6 +327,35 @@ LOG(llevError,"set_body_info called with bogus params: %s\n", params); } +// return a suitable strign describign an objetc in enough detail to find it +// used only in check_loaded_object: TODO remove static, move it elsewhere and +// use it in more log messages. +static char *op_debug_info_ (object *op, char *info) +{ + char info2[256 * 3]; + char *p = info; + + p += snprintf (p, 256, "%d=\"%s%s%s\"", + op->count, + op->name ? op->name : "(anon)", + op->title ? " " : "", + op->title ? op->title : ""); + + if (op->env) + p += snprintf (p, 256, "(in %s)", op_debug_info_ (op->env, info2)); + + if (op->map) + p += snprintf (p, 256, "(on %s@%d+%d)", op->map->path, op->x, op->y); + + return info; +} + +static char *op_debug_info (object *op) +{ + static char info[256 * 3]; + + return op_debug_info_ (op, info); +} /* This function checks the object after it has been loaded (when we * get the 'end' in the input stream). This function can be used to @@ -365,11 +394,11 @@ */ if ((op->type == WEAPON || op->type==BOW) && arch_init) { if (!op->skill) { - LOG(llevError,"Weapon %s lacks a skill.\n", op->name); + LOG(llevError,"Weapon %s lacks a skill.\n", op_debug_info (op)); } else if ((!strcmp(op->skill,"one handed weapons") && op->body_info[1] != -1) || (!strcmp(op->skill,"two handed weapons") && op->body_info[1] != -2)) { LOG(llevError,"weapon %s arm usage does not match skill: %d, %s\n", - op->name, op->body_info[1], op->skill); + op_debug_info (op), op->body_info[1], op->skill); } } @@ -384,8 +413,7 @@ (op->type == AMULET ) || (op->type == GIRDLE) || (op->type == BRACERS ) || (op->type == CLOAK)) { if (op->last_heal) { - LOG(llevDebug,"Object %s still has last_heal set, not gen_sp_armour\n", - op->name?op->name:"NULL"); + LOG(llevDebug,"Object %s still has last_heal set, not gen_sp_armour\n", op_debug_info (op)); op->gen_sp_armour = op->last_heal; op->last_heal = 0; } @@ -394,8 +422,7 @@ /* Legacy objects from before item power was in the game */ if (!op->item_power && ip) { if (ip > 3) { - LOG(llevDebug,"Object %s had no item power, using %d\n", - op->name?op->name:"NULL", ip); + LOG(llevDebug,"Object %s had no item power, using %d\n", op_debug_info (op), ip); } op->item_power = ip; } @@ -407,7 +434,7 @@ */ if (ip > 2 *op->item_power && ip > (op->item_power + 3)) { LOG(llevDebug,"Object %s seems to have too low item power? %d > %d\n", - op->name?op->name:"NULL", ip, op->item_power); + op_debug_info (op), ip, op->item_power); } } @@ -440,7 +467,7 @@ if (QUERY_FLAG(op, FLAG_MONSTER)) { if (op->stats.hp > op->stats.maxhp) LOG(llevDebug,"Monster %s has hp set higher than maxhp (%d>%d)\n", - op->name, + op_debug_info (op), op->stats.hp, op->stats.maxhp); /* The archs just need to be updated for this */