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.1.1.3 by elmex, Wed Mar 15 14:04:37 2006 UTC vs.
Revision 1.7 by elmex, Sun Aug 13 17:16:00 2006 UTC

1%{ 1%{
2/* 2/*
3 * static char *rcsid_object_c = 3 * static char *rcsid_object_c =
4 * "$Id: loader.l,v 1.1.1.3 2006/03/15 14:04:37 elmex Exp $"; 4 * "$Id: loader.l,v 1.7 2006/08/13 17:16:00 elmex 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
57 * If you are adding a new spell, you should not modify this - you 57 * If you are adding a new spell, you should not modify this - you
58 * new spell won't have been used, and thus won't have any legacy object. 58 * new spell won't have been used, and thus won't have any legacy object.
59 * NULL entries in this table are valid - to denote objects that should 59 * NULL entries in this table are valid - to denote objects that should
60 * not be updated for whatever reason. 60 * not be updated for whatever reason.
61 */ 61 */
62const char *const spell_mapping[] = { 62const char *spell_mapping[] = {
63"spell_magic_bullet", /* 0 */ 63"spell_magic_bullet", /* 0 */
64"spell_small_fireball", /* 1 */ 64"spell_small_fireball", /* 1 */
65"spell_medium_fireball", /* 2 */ 65"spell_medium_fireball", /* 2 */
66"spell_large_fireball", /* 3 */ 66"spell_large_fireball", /* 3 */
67"spell_burning_hands", /* 4 */ 67"spell_burning_hands", /* 4 */
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, "%d=\"%s%s%s\"",
339 op->count,
340 op->name ? op->name : "(anon)",
341 op->title ? " " : "",
342 op->title ? op->title : "");
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, "(on %s@%d+%d)", op->map->path, op->x, op->y);
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 }
616 643
617%} 644%}
618 645
619^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; } 646^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; }
620<MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL ); 647<MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL );
621 op->msg=add_string(msgbuf);
622 /* Just print a warning so we can be reasonably safe 648 /* Just print a warning so we can be reasonably safe
623 * about not overflowing the buffer. 649 * about not overflowing the buffer.
624 */ 650 */
625 if (strlen(op->msg) > (HUGE_BUF/2)) 651 if (strlen(msgbuf) >= HUGE_BUF)
652 {
626 LOG(llevDebug, "\n\tWarning message length > %d (max allowed=%d): %d\n>%.80s<\n", 653 LOG(llevDebug, "\n\tError message length >= %d: %d\n>%.80s<\n",
627 HUGE_BUF/2, HUGE_BUF, strlen(op->msg),op->msg); 654 HUGE_BUF, strlen(op->msg),op->msg);
655 op->msg = add_string ("ERROR, please report: string too long, winged.\n");
656 }
657 else
658 op->msg = add_string (msgbuf);
628 } 659 }
629<MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); } 660<MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); }
630 661
631^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; } 662^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; }
632<LORE>^endlore{WS}$ { BEGIN( INITIAL ); 663<LORE>^endlore{WS}$ { BEGIN( INITIAL );
834^neutral{S} SET_OR_CLEAR_FLAG(op, FLAG_NEUTRAL, IVAL); 865^neutral{S} SET_OR_CLEAR_FLAG(op, FLAG_NEUTRAL, IVAL);
835^no_attack{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_ATTACK, IVAL); 866^no_attack{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_ATTACK, IVAL);
836^no_damage{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_DAMAGE, IVAL); 867^no_damage{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_DAMAGE, IVAL);
837^friendly{S} { if (IVAL) { 868^friendly{S} { if (IVAL) {
838 SET_FLAG(op, FLAG_FRIENDLY); 869 SET_FLAG(op, FLAG_FRIENDLY);
839 if (op->type != PLAYER) { 870 if (op->type != PLAYER)
840 LOG(llevDebug," Adding friendly object %s.\n",op->name);
841 add_friendly_object(op); 871 add_friendly_object (op);
842 }
843 } 872 }
844 else CLEAR_FLAG(op, FLAG_FRIENDLY); 873 else CLEAR_FLAG(op, FLAG_FRIENDLY);
845 } 874 }
846^generator{S} SET_OR_CLEAR_FLAG(op, FLAG_GENERATOR, IVAL); 875^generator{S} SET_OR_CLEAR_FLAG(op, FLAG_GENERATOR, IVAL);
847^use_content_on_gen{S} SET_OR_CLEAR_FLAG (op,FLAG_CONTENT_ON_GEN, IVAL); 876^use_content_on_gen{S} SET_OR_CLEAR_FLAG (op,FLAG_CONTENT_ON_GEN, IVAL);
955^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL); 984^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL);
956 985
957 /* Old style resistances */ 986 /* Old style resistances */
958^immune{S} set_protection(op, IVAL, RESIST_IMMUNE); 987^immune{S} set_protection(op, IVAL, RESIST_IMMUNE);
959^protected{S} set_protection(op, IVAL, RESIST_PROT); 988^protected{S} set_protection(op, IVAL, RESIST_PROT);
960^vulnerable{S} set_protection(op, IVAL, RESIST_VULN); 989^vulnerable{S} set_protection(op, IVAL, (uint16) RESIST_VULN);
961 990
962 /* old values - keep them around for now, but they should be removed at some point */ 991 /* old values - keep them around for now, but they should be removed at some point */
963^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); 992^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL);
964^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); 993^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL);
965^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); 994^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL);
1004^can_impale{S} { /* That these are for the new combat code */ } 1033^can_impale{S} { /* That these are for the new combat code */ }
1005^can_cut{S} { /* just ignore for now */ } 1034^can_cut{S} { /* just ignore for now */ }
1006^can_dam_armour{S} { } 1035^can_dam_armour{S} { }
1007^weapontype{S} op->weapontype = IVAL; 1036^weapontype{S} op->weapontype = IVAL;
1008^tooltype{S} op->tooltype = IVAL; 1037^tooltype{S} op->tooltype = IVAL;
1009^casting_time{S} op->casting_time = FVAL; 1038^casting_time{S} op->casting_time = (sint16) FVAL;
1010^elevation{S} op->elevation = IVAL; 1039^elevation{S} op->elevation = IVAL;
1011^smoothlevel{S} op->smoothlevel = IVAL; 1040^smoothlevel{S} op->smoothlevel = IVAL;
1012^client_type{S} op->client_type = IVAL; 1041^client_type{S} op->client_type = IVAL;
1013^body_{A} set_body_info(op, yytext); 1042^body_{A} set_body_info(op, yytext);
1014^duration{S} op->duration = IVAL; 1043^duration{S} op->duration = IVAL;
1618 * NEVER touch buf between PREPARE_FASTCAT(buf) and 1647 * NEVER touch buf between PREPARE_FASTCAT(buf) and
1619 * FINISH_FASTCAT(buf) 1648 * FINISH_FASTCAT(buf)
1620 */ 1649 */
1621 static int already_run = 0; 1650 static int already_run = 0;
1622 static int flag_lens[NUM_FLAGS]; 1651 static int flag_lens[NUM_FLAGS];
1623 static char buf2[HUGE_BUF]; 1652 char buf2[4096]; // / was HUFE_BUF, which was hugely incorrect, as is this value, but much less so
1624 static char buf[HUGE_BUF]; 1653 static char buf[128*1024]; // < the assumption is that every object always fits. fixing this bug, however
1625 char* fastbuf; 1654 char* fastbuf; // \ requires a large rewrite of the code, so its left to the next total rewrite.
1626 int tmp; 1655 int tmp;
1627 int i; 1656 int i;
1628#if 0
1629/*Memory polluting code. Should help detect problems, very slow*/
1630 for (i=0;i<HUGE_BUF;i++){
1631 buf[i]='a'+(unsigned short)(i%25);
1632 }
1633#endif
1634 event *etmp; 1657 event *etmp;
1635 event *etmp2; 1658 event *etmp2;
1636 key_value * my_field; 1659 key_value * my_field;
1637 key_value * arch_field; 1660 key_value * arch_field;
1638 1661
1969 get_string_move_type(op->move_slow), 1992 get_string_move_type(op->move_slow),
1970 10); 1993 10);
1971 } 1994 }
1972 1995
1973 if (op->move_slow_penalty != op2->move_slow_penalty) { 1996 if (op->move_slow_penalty != op2->move_slow_penalty) {
1974 FAST_SAVE_LONG(fastbuf,"move_slow_penalty ",op->move_slow_penalty,18); 1997 FAST_SAVE_LONG(fastbuf,"move_slow_penalty ",(long) op->move_slow_penalty,18);
1975 } 1998 }
1976 1999
1977 if (!COMPARE_FLAGS(op,op2)) { 2000 if (!COMPARE_FLAGS(op,op2)) {
1978 for (tmp=0; tmp <= NUM_FLAGS; tmp++) { 2001 for (tmp=0; tmp <= NUM_FLAGS; tmp++) {
1979 if (flag_names[tmp] && (QUERY_FLAG(op, tmp) != QUERY_FLAG(op2, tmp))) { 2002 if (flag_names[tmp] && (QUERY_FLAG(op, tmp) != QUERY_FLAG(op2, tmp))) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines