1 | %{ |
1 | %{ |
2 | /* |
2 | /* |
3 | * static char *rcsid_object_c = |
3 | * static char *rcsid_object_c = |
4 | * "$Id: loader.l,v 1.5 2006/06/26 21:46:04 root Exp $"; |
4 | * "$Id: loader.l,v 1.8 2006/08/26 08:44:04 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 | |
… | |
… | |
40 | #define YY_DECL int lex_load(object *op, int map_flags) |
40 | #define YY_DECL int lex_load(object *op, int map_flags) |
41 | |
41 | |
42 | static char *yval(); |
42 | static char *yval(); |
43 | |
43 | |
44 | static int lex_error; |
44 | static int lex_error; |
45 | static char msgbuf[HUGE_BUF]; |
45 | static char msgbuf[65536]; |
46 | static char lorebuf[HUGE_BUF]; |
46 | static char lorebuf[65536]; |
47 | |
47 | |
48 | /* Maps the MOVE_* values to names */ |
48 | /* Maps the MOVE_* values to names */ |
49 | static const char *const move_name[] = {"walk", "fly_low", "fly_high", "swim", "boat", |
49 | static const char *const move_name[] = {"walk", "fly_low", "fly_high", "swim", "boat", |
50 | NULL}; |
50 | NULL}; |
51 | |
51 | |
… | |
… | |
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 | */ |
62 | const char *const spell_mapping[] = { |
62 | const 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 */ |
… | |
… | |
693 | ^name_pl{S} { char *yv=yval(); |
693 | ^name_pl{S} { char *yv=yval(); |
694 | |
694 | |
695 | if (*yv=='\0') LOG(llevError,"Name without val\n"); |
695 | if (*yv=='\0') LOG(llevError,"Name without val\n"); |
696 | else FREE_AND_COPY(op->name_pl, yv); |
696 | else FREE_AND_COPY(op->name_pl, yv); |
697 | } |
697 | } |
|
|
698 | ^attach{S} { char *yv=yval(); |
|
|
699 | if (*yv) |
|
|
700 | op->attach = add_string (yv); |
|
|
701 | } |
698 | ^skill{S} FREE_AND_COPY(op->skill,yval()); |
702 | ^skill{S} FREE_AND_COPY(op->skill,yval()); |
699 | ^custom_name{S} { char *yv=yval(); |
703 | ^custom_name{S} { char *yv=yval(); |
700 | |
704 | |
701 | if (*yv=='\0') LOG(llevError,"Custom name without val\n"); |
705 | if (*yv=='\0') LOG(llevError,"Custom name without val\n"); |
702 | else FREE_AND_COPY(op->custom_name, yv); |
706 | else FREE_AND_COPY(op->custom_name, yv); |
… | |
… | |
984 | ^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL); |
988 | ^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL); |
985 | |
989 | |
986 | /* Old style resistances */ |
990 | /* Old style resistances */ |
987 | ^immune{S} set_protection(op, IVAL, RESIST_IMMUNE); |
991 | ^immune{S} set_protection(op, IVAL, RESIST_IMMUNE); |
988 | ^protected{S} set_protection(op, IVAL, RESIST_PROT); |
992 | ^protected{S} set_protection(op, IVAL, RESIST_PROT); |
989 | ^vulnerable{S} set_protection(op, IVAL, RESIST_VULN); |
993 | ^vulnerable{S} set_protection(op, IVAL, (uint16) RESIST_VULN); |
990 | |
994 | |
991 | /* old values - keep them around for now, but they should be removed at some point */ |
995 | /* old values - keep them around for now, but they should be removed at some point */ |
992 | ^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
996 | ^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
993 | ^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
997 | ^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
994 | ^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
998 | ^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
… | |
… | |
1033 | ^can_impale{S} { /* That these are for the new combat code */ } |
1037 | ^can_impale{S} { /* That these are for the new combat code */ } |
1034 | ^can_cut{S} { /* just ignore for now */ } |
1038 | ^can_cut{S} { /* just ignore for now */ } |
1035 | ^can_dam_armour{S} { } |
1039 | ^can_dam_armour{S} { } |
1036 | ^weapontype{S} op->weapontype = IVAL; |
1040 | ^weapontype{S} op->weapontype = IVAL; |
1037 | ^tooltype{S} op->tooltype = IVAL; |
1041 | ^tooltype{S} op->tooltype = IVAL; |
1038 | ^casting_time{S} op->casting_time = FVAL; |
1042 | ^casting_time{S} op->casting_time = (sint16) FVAL; |
1039 | ^elevation{S} op->elevation = IVAL; |
1043 | ^elevation{S} op->elevation = IVAL; |
1040 | ^smoothlevel{S} op->smoothlevel = IVAL; |
1044 | ^smoothlevel{S} op->smoothlevel = IVAL; |
1041 | ^client_type{S} op->client_type = IVAL; |
1045 | ^client_type{S} op->client_type = IVAL; |
1042 | ^body_{A} set_body_info(op, yytext); |
1046 | ^body_{A} set_body_info(op, yytext); |
1043 | ^duration{S} op->duration = IVAL; |
1047 | ^duration{S} op->duration = IVAL; |
… | |
… | |
1647 | * NEVER touch buf between PREPARE_FASTCAT(buf) and |
1651 | * NEVER touch buf between PREPARE_FASTCAT(buf) and |
1648 | * FINISH_FASTCAT(buf) |
1652 | * FINISH_FASTCAT(buf) |
1649 | */ |
1653 | */ |
1650 | static int already_run = 0; |
1654 | static int already_run = 0; |
1651 | static int flag_lens[NUM_FLAGS]; |
1655 | static int flag_lens[NUM_FLAGS]; |
1652 | static char buf2[HUGE_BUF]; |
1656 | char buf2[4096]; // / was HUFE_BUF, which was hugely incorrect, as is this value, but much less so |
1653 | static char buf[HUGE_BUF]; |
1657 | static char buf[128*1024]; // < the assumption is that every object always fits. fixing this bug, however |
1654 | char* fastbuf; |
1658 | char* fastbuf; // \ requires a large rewrite of the code, so its left to the next total rewrite. |
1655 | int tmp; |
1659 | int tmp; |
1656 | int i; |
1660 | int i; |
1657 | #if 0 |
|
|
1658 | /*Memory polluting code. Should help detect problems, very slow*/ |
|
|
1659 | for (i=0;i<HUGE_BUF;i++){ |
|
|
1660 | buf[i]='a'+(unsigned short)(i%25); |
|
|
1661 | } |
|
|
1662 | #endif |
|
|
1663 | event *etmp; |
1661 | event *etmp; |
1664 | event *etmp2; |
1662 | event *etmp2; |
1665 | key_value * my_field; |
1663 | key_value * my_field; |
1666 | key_value * arch_field; |
1664 | key_value * arch_field; |
1667 | |
1665 | |
… | |
… | |
1998 | get_string_move_type(op->move_slow), |
1996 | get_string_move_type(op->move_slow), |
1999 | 10); |
1997 | 10); |
2000 | } |
1998 | } |
2001 | |
1999 | |
2002 | if (op->move_slow_penalty != op2->move_slow_penalty) { |
2000 | if (op->move_slow_penalty != op2->move_slow_penalty) { |
2003 | FAST_SAVE_LONG(fastbuf,"move_slow_penalty ",op->move_slow_penalty,18); |
2001 | FAST_SAVE_LONG(fastbuf,"move_slow_penalty ",(long) op->move_slow_penalty,18); |
2004 | } |
2002 | } |
2005 | |
2003 | |
2006 | if (!COMPARE_FLAGS(op,op2)) { |
2004 | if (!COMPARE_FLAGS(op,op2)) { |
2007 | for (tmp=0; tmp <= NUM_FLAGS; tmp++) { |
2005 | for (tmp=0; tmp <= NUM_FLAGS; tmp++) { |
2008 | if (flag_names[tmp] && (QUERY_FLAG(op, tmp) != QUERY_FLAG(op2, tmp))) { |
2006 | if (flag_names[tmp] && (QUERY_FLAG(op, tmp) != QUERY_FLAG(op2, tmp))) { |