ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/loader.l
(Generate patch)

Comparing deliantra/server/common/loader.l (file contents):
Revision 1.2 by root, Thu May 11 18:37:20 2006 UTC vs.
Revision 1.3 by root, Thu May 11 19:07:40 2006 UTC

1%{ 1%{
2/* 2/*
3 * static char *rcsid_object_c = 3 * static char *rcsid_object_c =
4 * "$Id: loader.l,v 1.2 2006/05/11 18:37:20 root Exp $"; 4 * "$Id: loader.l,v 1.3 2006/05/11 19:07:40 root Exp $";
5 */ 5 */
6 6
7/* 7/*
8 CrossFire, A Multiplayer game for X-windows 8 CrossFire, A Multiplayer game for X-windows
9 9
325 } 325 }
326 } 326 }
327 LOG(llevError,"set_body_info called with bogus params: %s\n", params); 327 LOG(llevError,"set_body_info called with bogus params: %s\n", params);
328} 328}
329 329
330// return a suitable strign describign an objetc in enough detail to find it
331// used only in check_loaded_object: TODO remove static, move it elsewhere and
332// use it in more log messages.
333static char *op_debug_info_ (object *op, char *info)
334{
335 char info2[256 * 3];
336 char *p = info;
337
338 p += snprintf (p, 256, "%s%s%s=%d",
339 op->name ? op->name : "(anon)",
340 op->title ? " " : "",
341 op->title ? op->title : "",
342 op->count);
343
344 if (op->env)
345 p += snprintf (p, 256, "(in %s)", op_debug_info_ (op->env, info2));
346
347 if (op->map)
348 p += snprintf (p, 256, "(%d+%d@%s)", op->x, op->y, op->map->path);
349
350 return info;
351}
352
353static char *op_debug_info (object *op)
354{
355 static char info[256 * 3];
356
357 return op_debug_info_ (op, info);
358}
330 359
331/* This function checks the object after it has been loaded (when we 360/* This function checks the object after it has been loaded (when we
332 * get the 'end' in the input stream). This function can be used to 361 * get the 'end' in the input stream). This function can be used to
333 * deal with legacy objects where fields may have changed. It can also be used 362 * deal with legacy objects where fields may have changed. It can also be used
334 * to check for objects to make sure there are no common errors. 363 * to check for objects to make sure there are no common errors.
363 * really just to catch any errors - program will still run, but 392 * really just to catch any errors - program will still run, but
364 * not in the ideal fashion. 393 * not in the ideal fashion.
365 */ 394 */
366 if ((op->type == WEAPON || op->type==BOW) && arch_init) { 395 if ((op->type == WEAPON || op->type==BOW) && arch_init) {
367 if (!op->skill) { 396 if (!op->skill) {
368 LOG(llevError,"Weapon %s lacks a skill.\n", op->name); 397 LOG(llevError,"Weapon %s lacks a skill.\n", op_debug_info (op));
369 } else if ((!strcmp(op->skill,"one handed weapons") && op->body_info[1] != -1) || 398 } else if ((!strcmp(op->skill,"one handed weapons") && op->body_info[1] != -1) ||
370 (!strcmp(op->skill,"two handed weapons") && op->body_info[1] != -2)) { 399 (!strcmp(op->skill,"two handed weapons") && op->body_info[1] != -2)) {
371 LOG(llevError,"weapon %s arm usage does not match skill: %d, %s\n", 400 LOG(llevError,"weapon %s arm usage does not match skill: %d, %s\n",
372 op->name, op->body_info[1], op->skill); 401 op_debug_info (op), op->body_info[1], op->skill);
373 } 402 }
374 } 403 }
375 404
376 /* We changed last_heal to gen_sp_armour, which is what it 405 /* We changed last_heal to gen_sp_armour, which is what it
377 * really does for many objects. Need to catch any in maps 406 * really does for many objects. Need to catch any in maps
382 (op->type == SHIELD) || (op->type == RING) || 411 (op->type == SHIELD) || (op->type == RING) ||
383 (op->type == BOOTS) || (op->type == GLOVES) || 412 (op->type == BOOTS) || (op->type == GLOVES) ||
384 (op->type == AMULET ) || (op->type == GIRDLE) || 413 (op->type == AMULET ) || (op->type == GIRDLE) ||
385 (op->type == BRACERS ) || (op->type == CLOAK)) { 414 (op->type == BRACERS ) || (op->type == CLOAK)) {
386 if (op->last_heal) { 415 if (op->last_heal) {
387 LOG(llevDebug,"Object %s still has last_heal set, not gen_sp_armour\n", 416 LOG(llevDebug,"Object %s still has last_heal set, not gen_sp_armour\n", op_debug_info (op));
388 op->name?op->name:"NULL");
389 op->gen_sp_armour = op->last_heal; 417 op->gen_sp_armour = op->last_heal;
390 op->last_heal = 0; 418 op->last_heal = 0;
391 } 419 }
392 if (editor) ip =0; 420 if (editor) ip =0;
393 else ip = calc_item_power(op, 0); 421 else ip = calc_item_power(op, 0);
394 /* Legacy objects from before item power was in the game */ 422 /* Legacy objects from before item power was in the game */
395 if (!op->item_power && ip) { 423 if (!op->item_power && ip) {
396 if (ip > 3) { 424 if (ip > 3) {
397 LOG(llevDebug,"Object %s had no item power, using %d\n", 425 LOG(llevDebug,"Object %s had no item power, using %d\n", op_debug_info (op), ip);
398 op->name?op->name:"NULL", ip);
399 } 426 }
400 op->item_power = ip; 427 op->item_power = ip;
401 } 428 }
402 /* Check for possibly bogus values. Has to meet both these criteria - 429 /* Check for possibly bogus values. Has to meet both these criteria -
403 * something that has item_power 1 is probably just fine if our calculated 430 * something that has item_power 1 is probably just fine if our calculated
405 * similarly, it item_power is 0, the first check will always pass, 432 * similarly, it item_power is 0, the first check will always pass,
406 * but not the second one. 433 * but not the second one.
407 */ 434 */
408 if (ip > 2 *op->item_power && ip > (op->item_power + 3)) { 435 if (ip > 2 *op->item_power && ip > (op->item_power + 3)) {
409 LOG(llevDebug,"Object %s seems to have too low item power? %d > %d\n", 436 LOG(llevDebug,"Object %s seems to have too low item power? %d > %d\n",
410 op->name?op->name:"NULL", ip, op->item_power); 437 op_debug_info (op), ip, op->item_power);
411 } 438 }
412 439
413 } 440 }
414 /* Old spellcasting object - need to load in the appropiate object */ 441 /* Old spellcasting object - need to load in the appropiate object */
415 if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN 442 if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN
438 } 465 }
439 466
440 if (QUERY_FLAG(op, FLAG_MONSTER)) { 467 if (QUERY_FLAG(op, FLAG_MONSTER)) {
441 if (op->stats.hp > op->stats.maxhp) 468 if (op->stats.hp > op->stats.maxhp)
442 LOG(llevDebug,"Monster %s has hp set higher than maxhp (%d>%d)\n", 469 LOG(llevDebug,"Monster %s has hp set higher than maxhp (%d>%d)\n",
443 op->name, 470 op_debug_info (op),
444 op->stats.hp, op->stats.maxhp); 471 op->stats.hp, op->stats.maxhp);
445 472
446 /* The archs just need to be updated for this */ 473 /* The archs just need to be updated for this */
447 if (op->move_type ==0) op->move_type = MOVE_WALK; 474 if (op->move_type ==0) op->move_type = MOVE_WALK;
448 } 475 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines