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.4 by root, Thu May 11 20:15:30 2006 UTC vs.
Revision 1.16 by root, Thu Aug 31 06:23:19 2006 UTC

1%{ 1%{
2/* 2/*
3 * static char *rcsid_object_c = 3 * static char *rcsid_object_c =
4 * "$Id: loader.l,v 1.4 2006/05/11 20:15:30 root Exp $"; 4 * "$Id: loader.l,v 1.16 2006/08/31 06:23:19 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
35#include <global.h> 35#include <global.h>
36#include <loader.h> 36#include <loader.h>
37#include <newserver.h> 37#include <newserver.h>
38#include <sproto.h> 38#include <sproto.h>
39 39
40#define YY_DECL int lex_load(object *op, int map_flags) 40#define YY_DECL int lex_load(object *op, object_thawer &thawer, int map_flags)
41 41
42static char *yval(); 42static char *yval();
43 43
44static int lex_error; 44static int lex_error;
45static char msgbuf[HUGE_BUF]; 45static char msgbuf[65536];
46static char lorebuf[HUGE_BUF]; 46static char lorebuf[65536];
47 47
48/* Maps the MOVE_* values to names */ 48/* Maps the MOVE_* values to names */
49static const char *const move_name[] = {"walk", "fly_low", "fly_high", "swim", "boat", 49static 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 */
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 */
643 643
644%} 644%}
645 645
646^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; } 646^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; }
647<MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL ); 647<MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL );
648 op->msg=add_string(msgbuf);
649 /* Just print a warning so we can be reasonably safe 648 /* Just print a warning so we can be reasonably safe
650 * about not overflowing the buffer. 649 * about not overflowing the buffer.
651 */ 650 */
652 if (strlen(op->msg) > (HUGE_BUF/2)) 651 if (strlen(msgbuf) >= HUGE_BUF)
652 {
653 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",
654 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);
655 } 659 }
656<MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); } 660<MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); }
657 661
658^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; } 662^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; }
659<LORE>^endlore{WS}$ { BEGIN( INITIAL ); 663<LORE>^endlore{WS}$ { BEGIN( INITIAL );
689^name_pl{S} { char *yv=yval(); 693^name_pl{S} { char *yv=yval();
690 694
691 if (*yv=='\0') LOG(llevError,"Name without val\n"); 695 if (*yv=='\0') LOG(llevError,"Name without val\n");
692 else FREE_AND_COPY(op->name_pl, yv); 696 else FREE_AND_COPY(op->name_pl, yv);
693 } 697 }
698^attach{S} { char *yv=yval();
699 if (*yv)
700 op->attach = add_string (yv);
701 }
694^skill{S} FREE_AND_COPY(op->skill,yval()); 702^skill{S} FREE_AND_COPY(op->skill,yval());
695^custom_name{S} { char *yv=yval(); 703^custom_name{S} { char *yv=yval();
696 704
697 if (*yv=='\0') LOG(llevError,"Custom name without val\n"); 705 if (*yv=='\0') LOG(llevError,"Custom name without val\n");
698 else FREE_AND_COPY(op->custom_name, yv); 706 else FREE_AND_COPY(op->custom_name, yv);
708 */ 716 */
709 if (op->arch) { 717 if (op->arch) {
710 object *tmp; 718 object *tmp;
711 char *yv=yval(); 719 char *yv=yval();
712 720
713 tmp=get_object();
714 tmp->arch = find_archetype(yv); 721 archetype *arch = find_archetype(yv);
715 if (tmp->arch!=NULL) 722 if (arch!=NULL)
716 copy_object(&tmp->arch->clone,tmp); 723 tmp = arch_to_object (arch);
717 else { 724 else {
725 tmp = get_object ();
718 if (tmp->name) free_string(tmp->name); 726 if (tmp->name) free_string(tmp->name);
719 /* record the name of the broken object */ 727 /* record the name of the broken object */
720 tmp->name = add_string(yv); 728 tmp->name = add_string(yv);
721 } 729 }
722 strcpy(msgbuf, ""); 730 strcpy(msgbuf, "");
723 strcpy(lorebuf, ""); 731 strcpy(lorebuf, "");
724 lex_load(tmp, map_flags); 732 lex_load(tmp, thawer, map_flags);
725 if (tmp->arch) { 733 if (tmp->arch) {
726 insert_ob_in_ob(tmp,op); 734 insert_ob_in_ob(tmp,op);
727 } 735 }
728 else { 736 else {
729 LOG(llevDebug,"Discarding object without arch: %s\n", tmp->name?tmp->name:"(null)"); 737 LOG(llevDebug,"Discarding object without arch: %s\n", tmp->name?tmp->name:"(null)");
733 /* This is the actual archetype definition then */ 741 /* This is the actual archetype definition then */
734 else { 742 else {
735 char *yv=yval(); 743 char *yv=yval();
736 744
737 op->arch=find_archetype(yv); 745 op->arch=find_archetype(yv);
738 if (op->arch!=NULL) copy_object(&op->arch->clone,op); 746 if (op->arch!=NULL) {
739 else if (!arch_init) { 747 copy_object(&op->arch->clone,op);
748 } else if (!arch_init) {
740 if (op->name) free_string(op->name); 749 if (op->name) free_string(op->name);
741 /* record the name of the broken object */ 750 /* record the name of the broken object */
742 op->name = add_string(yv); 751 op->name = add_string(yv);
743 } 752 }
744 } 753 }
758^more{WS}$ { /* We need to record that this is a multipart object, 767^more{WS}$ { /* We need to record that this is a multipart object,
759 * so the calling function can glue things back together 768 * so the calling function can glue things back together
760 */ 769 */
761 ismore=1; 770 ismore=1;
762 } 771 }
763
764^end{WS}$ { check_loaded_object(op); 772^end{WS}$ { check_loaded_object(op);
773
774 if (!arch_init)
775 op->instantiate ();
776
765 if (ismore) return LL_MORE; 777 if (ismore) return LL_MORE;
766 else return LL_NORMAL; 778 else return LL_NORMAL;
767 } 779 }
780^oid{S} {
781 thawer.get (op, IVAL);
782 }
768^last_heal{S} op->last_heal = IVAL; 783^last_heal{S} op->last_heal = IVAL;
769^last_sp{S} op->last_sp = IVAL; 784^last_sp{S} op->last_sp = IVAL;
770^last_grace{S} op->last_grace = IVAL; 785^last_grace{S} op->last_grace = IVAL;
771^last_eat{S} op->last_eat = IVAL; 786^last_eat{S} op->last_eat = IVAL;
772^speed{S} { op->speed = FVAL; 787^speed{S} { op->speed = FVAL;
980^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL); 995^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL);
981 996
982 /* Old style resistances */ 997 /* Old style resistances */
983^immune{S} set_protection(op, IVAL, RESIST_IMMUNE); 998^immune{S} set_protection(op, IVAL, RESIST_IMMUNE);
984^protected{S} set_protection(op, IVAL, RESIST_PROT); 999^protected{S} set_protection(op, IVAL, RESIST_PROT);
985^vulnerable{S} set_protection(op, IVAL, RESIST_VULN); 1000^vulnerable{S} set_protection(op, IVAL, (uint16) RESIST_VULN);
986 1001
987 /* old values - keep them around for now, but they should be removed at some point */ 1002 /* old values - keep them around for now, but they should be removed at some point */
988^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); 1003^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL);
989^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); 1004^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL);
990^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); 1005^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL);
1029^can_impale{S} { /* That these are for the new combat code */ } 1044^can_impale{S} { /* That these are for the new combat code */ }
1030^can_cut{S} { /* just ignore for now */ } 1045^can_cut{S} { /* just ignore for now */ }
1031^can_dam_armour{S} { } 1046^can_dam_armour{S} { }
1032^weapontype{S} op->weapontype = IVAL; 1047^weapontype{S} op->weapontype = IVAL;
1033^tooltype{S} op->tooltype = IVAL; 1048^tooltype{S} op->tooltype = IVAL;
1034^casting_time{S} op->casting_time = FVAL; 1049^casting_time{S} op->casting_time = (sint16) FVAL;
1035^elevation{S} op->elevation = IVAL; 1050^elevation{S} op->elevation = IVAL;
1036^smoothlevel{S} op->smoothlevel = IVAL; 1051^smoothlevel{S} op->smoothlevel = IVAL;
1037^client_type{S} op->client_type = IVAL; 1052^client_type{S} op->client_type = IVAL;
1038^body_{A} set_body_info(op, yytext); 1053^body_{A} set_body_info(op, yytext);
1039^duration{S} op->duration = IVAL; 1054^duration{S} op->duration = IVAL;
1041^range_modifier{S} op->range_modifier = IVAL; 1056^range_modifier{S} op->range_modifier = IVAL;
1042^dam_modifier{S} op->dam_modifier = IVAL; 1057^dam_modifier{S} op->dam_modifier = IVAL;
1043^duration_modifier{S} op->duration_modifier = IVAL; 1058^duration_modifier{S} op->duration_modifier = IVAL;
1044^is_buildable{S} SET_OR_CLEAR_FLAG( op, FLAG_IS_BUILDABLE, IVAL ); 1059^is_buildable{S} SET_OR_CLEAR_FLAG( op, FLAG_IS_BUILDABLE, IVAL );
1045 1060
1046^event_apply{S} { 1061^event_ {
1047 char *yv=yval(); 1062 LOG (llevError, "stray event_* in map file, skipping.");
1048 if (*yv=='\0')
1049 LOG(llevError,"Event (apply) without val\n");
1050 else
1051 insert_event(op,EVENT_APPLY,yv,NULL,NULL);
1052} 1063}
1053
1054^event_apply_plugin{S} {
1055 char *yv=yval();
1056 if (*yv=='\0')
1057 LOG(llevError,"Event (apply) without plugin\n");
1058 else
1059 insert_event(op,EVENT_APPLY,NULL,yv,NULL);
1060}
1061
1062^event_apply_options{S} {
1063 char *yv=yval();
1064 if (*yv=='\0')
1065 LOG(llevError,"Event (apply) without options\n");
1066 else
1067 insert_event(op,EVENT_APPLY,NULL,NULL,yv);
1068}
1069
1070^event_attack{S} {
1071 char *yv=yval();
1072 if (*yv=='\0')
1073 LOG(llevError,"Event (attack) without val\n");
1074 else
1075 insert_event(op,EVENT_ATTACK,yv,NULL,NULL);
1076}
1077
1078^event_attack_plugin{S} {
1079 char *yv=yval();
1080 if (*yv=='\0')
1081 LOG(llevError,"Event (attack) without plugin\n");
1082 else
1083 insert_event(op,EVENT_ATTACK,NULL,yv,NULL);
1084}
1085
1086^event_attack_options{S} {
1087 char *yv=yval();
1088 if (*yv=='\0')
1089 LOG(llevError,"Event (attack) without options\n");
1090 else
1091 insert_event(op,EVENT_ATTACK,NULL,NULL,yv);
1092}
1093^event_death{S} {
1094 char *yv=yval();
1095 if (*yv=='\0')
1096 LOG(llevError,"Event (death) without val\n");
1097 else
1098 insert_event(op,EVENT_DEATH,yv,NULL,NULL);
1099}
1100
1101^event_death_plugin{S} {
1102 char *yv=yval();
1103 if (*yv=='\0')
1104 LOG(llevError,"Event (death) without plugin\n");
1105 else
1106 insert_event(op,EVENT_DEATH,NULL,yv,NULL);
1107}
1108
1109^event_death_options{S} {
1110 char *yv=yval();
1111 if (*yv=='\0')
1112 LOG(llevError,"Event (death) without options\n");
1113 else
1114 insert_event(op,EVENT_DEATH,NULL,NULL,yv);
1115}
1116^event_drop{S} {
1117 char *yv=yval();
1118 if (*yv=='\0')
1119 LOG(llevError,"Event (drop) without val\n");
1120 else
1121 insert_event(op,EVENT_DROP,yv,NULL,NULL);
1122}
1123
1124^event_drop_plugin{S} {
1125 char *yv=yval();
1126 if (*yv=='\0')
1127 LOG(llevError,"Event (drop) without plugin\n");
1128 else
1129 insert_event(op,EVENT_DROP,NULL,yv,NULL);
1130}
1131
1132^event_drop_options{S} {
1133 char *yv=yval();
1134 if (*yv=='\0')
1135 LOG(llevError,"Event (drop) without options\n");
1136 else
1137 insert_event(op,EVENT_DROP,NULL,NULL,yv);
1138}
1139^event_pickup{S} {
1140 char *yv=yval();
1141 if (*yv=='\0')
1142 LOG(llevError,"Event (pickup) without val\n");
1143 else
1144 insert_event(op,EVENT_PICKUP,yv,NULL,NULL);
1145}
1146
1147^event_pickup_plugin{S} {
1148 char *yv=yval();
1149 if (*yv=='\0')
1150 LOG(llevError,"Event (pickup) without plugin\n");
1151 else
1152 insert_event(op,EVENT_PICKUP,NULL,yv,NULL);
1153}
1154
1155^event_pickup_options{S} {
1156 char *yv=yval();
1157 if (*yv=='\0')
1158 LOG(llevError,"Event (pickup) without options\n");
1159 else
1160 insert_event(op,EVENT_PICKUP,NULL,NULL,yv);
1161}
1162^event_say{S} {
1163 char *yv=yval();
1164 if (*yv=='\0')
1165 LOG(llevError,"Event (say) without val\n");
1166 else
1167 insert_event(op,EVENT_SAY,yv,NULL,NULL);
1168}
1169
1170^event_say_plugin{S} {
1171 char *yv=yval();
1172 if (*yv=='\0')
1173 LOG(llevError,"Event (say) without plugin\n");
1174 else
1175 insert_event(op,EVENT_SAY,NULL,yv,NULL);
1176}
1177
1178^event_say_options{S} {
1179 char *yv=yval();
1180 if (*yv=='\0')
1181 LOG(llevError,"Event (say) without options\n");
1182 else
1183 insert_event(op,EVENT_SAY,NULL,NULL,yv);
1184}
1185^event_stop{S} {
1186 char *yv=yval();
1187 if (*yv=='\0')
1188 LOG(llevError,"Event (stop) without val\n");
1189 else
1190 insert_event(op,EVENT_STOP,yv,NULL,NULL);
1191}
1192
1193^event_stop_plugin{S} {
1194 char *yv=yval();
1195 if (*yv=='\0')
1196 LOG(llevError,"Event (stop) without plugin\n");
1197 else
1198 insert_event(op,EVENT_STOP,NULL,yv,NULL);
1199}
1200
1201^event_stop_options{S} {
1202 char *yv=yval();
1203 if (*yv=='\0')
1204 LOG(llevError,"Event (stop) without options\n");
1205 else
1206 insert_event(op,EVENT_STOP,NULL,NULL,yv);
1207}
1208^event_time{S} {
1209 char *yv=yval();
1210 if (*yv=='\0')
1211 LOG(llevError,"Event (time) without val\n");
1212 else
1213 insert_event(op,EVENT_TIME,yv,NULL,NULL);
1214}
1215
1216^event_time_plugin{S} {
1217 char *yv=yval();
1218 if (*yv=='\0')
1219 LOG(llevError,"Event (time) without plugin\n");
1220 else
1221 insert_event(op,EVENT_TIME,NULL,yv,NULL);
1222}
1223
1224^event_time_options{S} {
1225 char *yv=yval();
1226 if (*yv=='\0')
1227 LOG(llevError,"Event (time) without options\n");
1228 else
1229 insert_event(op,EVENT_TIME,NULL,NULL,yv);
1230}
1231^event_throw{S} {
1232 char *yv=yval();
1233 if (*yv=='\0')
1234 LOG(llevError,"Event (throw) without val\n");
1235 else
1236 insert_event(op,EVENT_THROW,yv,NULL,NULL);
1237}
1238
1239^event_throw_plugin{S} {
1240 char *yv=yval();
1241 if (*yv=='\0')
1242 LOG(llevError,"Event (throw) without plugin\n");
1243 else
1244 insert_event(op,EVENT_THROW,NULL,yv,NULL);
1245}
1246
1247^event_throw_options{S} {
1248 char *yv=yval();
1249 if (*yv=='\0')
1250 LOG(llevError,"Event (apply) without options\n");
1251 else
1252 insert_event(op,EVENT_THROW,NULL,NULL,yv);
1253}
1254^event_trigger{S} {
1255 char *yv=yval();
1256 if (*yv=='\0')
1257 LOG(llevError,"Event (trigger) without val\n");
1258 else
1259 insert_event(op,EVENT_TRIGGER,yv,NULL,NULL);
1260}
1261
1262^event_trigger_plugin{S} {
1263 char *yv=yval();
1264 if (*yv=='\0')
1265 LOG(llevError,"Event (trigger) without plugin\n");
1266 else
1267 insert_event(op,EVENT_TRIGGER,NULL,yv,NULL);
1268}
1269
1270^event_trigger_options{S} {
1271 char *yv=yval();
1272 if (*yv=='\0')
1273 LOG(llevError,"Event (trigger) without options\n");
1274 else
1275 insert_event(op,EVENT_TRIGGER,NULL,NULL,yv);
1276}
1277^event_close{S} {
1278 char *yv=yval();
1279 if (*yv=='\0')
1280 LOG(llevError,"Event (close) without val\n");
1281 else
1282 insert_event(op,EVENT_CLOSE,yv,NULL,NULL);
1283}
1284
1285^event_close_plugin{S} {
1286 char *yv=yval();
1287 if (*yv=='\0')
1288 LOG(llevError,"Event (close) without plugin\n");
1289 else
1290 insert_event(op,EVENT_CLOSE,NULL,yv,NULL);
1291}
1292
1293^event_close_options{S} {
1294 char *yv=yval();
1295 if (*yv=='\0')
1296 LOG(llevError,"Event (close) without options\n");
1297 else
1298 insert_event(op,EVENT_CLOSE,NULL,NULL,yv);
1299}
1300^event_timer{S} {
1301 char *yv=yval();
1302 if (*yv=='\0')
1303 LOG(llevError,"Event (timer) without val\n");
1304 else
1305 insert_event(op,EVENT_TIMER,yv,NULL,NULL);
1306}
1307
1308^event_timer_plugin{S} {
1309 char *yv=yval();
1310 if (*yv=='\0')
1311 LOG(llevError,"Event (timer) without plugin\n");
1312 else
1313 insert_event(op,EVENT_TIMER,NULL,yv,NULL);
1314}
1315
1316^event_timer_options{S} {
1317 char *yv=yval();
1318 if (*yv=='\0')
1319 LOG(llevError,"Event (timer) without options\n");
1320 else
1321 insert_event(op,EVENT_TIMER,NULL,NULL,yv);
1322}
1323
1324^current_weapon_script{S} { char *yv=yval();
1325
1326 if (*yv=='\0') LOG(llevError,"Script (current weapon) without val\n");
1327 else
1328 {
1329 FREE_AND_COPY(op->current_weapon_script, yv);
1330 };
1331 }
1332 1064
1333<*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} 1065<*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */}
1334#.*\n {} 1066#.*\n {}
1335 1067
1336<<EOF>> {/* If we got an error, return the error. Otherwise, return that we got EOF */ 1068<<EOF>> {/* If we got an error, return the error. Otherwise, return that we got EOF */
1394 * be reset. 1126 * be reset.
1395 * LO_NOREAD (3): Reset the buffers, but don't read from it. (op can be null) 1127 * LO_NOREAD (3): Reset the buffers, but don't read from it. (op can be null)
1396 * 1128 *
1397 */ 1129 */
1398 1130
1399int load_object(FILE *fp, object *op, int bufstate, int map_flags) { 1131int load_object(object_thawer &fp, object *op, int bufstate, int map_flags) {
1400 int retval; 1132 int retval;
1401 char inbuf[MAX_BUF]; 1133 char inbuf[MAX_BUF];
1402 1134
1403 strcpy(msgbuf, ""); 1135 strcpy(msgbuf, "");
1404 strcpy(lorebuf, ""); 1136 strcpy(lorebuf, "");
1410 } 1142 }
1411 if (bufstate==LO_LINEMODE) { 1143 if (bufstate==LO_LINEMODE) {
1412 YY_BUFFER_STATE yybufstate; 1144 YY_BUFFER_STATE yybufstate;
1413 while (fgets(inbuf, MAX_BUF-3, fp)) { 1145 while (fgets(inbuf, MAX_BUF-3, fp)) {
1414 yybufstate=yy_scan_string(inbuf); 1146 yybufstate=yy_scan_string(inbuf);
1415 retval=lex_load(op, map_flags); 1147 retval=lex_load(op, fp, map_flags);
1416 yy_delete_buffer(yybufstate); 1148 yy_delete_buffer(yybufstate);
1417 if (retval==LL_NORMAL) return retval; 1149 if (retval==LL_NORMAL) return retval;
1418 } 1150 }
1419 LOG(llevDebug,"Got eof while scanning strings\n"); 1151 LOG(llevDebug,"Got eof while scanning strings\n");
1420 return LL_EOF; 1152 return LL_EOF;
1421 } 1153 }
1422 1154
1423 retval=lex_load(op, map_flags); 1155 retval=lex_load(op, fp, map_flags);
1424 if (op->current_weapon_script != NULL)
1425 {
1426 op->current_weapon = find_best_weapon_used_match(op, op->current_weapon_script);
1427 LOG(llevDebug, "CurrentWeapon Loaded !\n");
1428 };
1429 1156
1430/* LOG(llevDebug," load completed, object=%s\n",op->name);*/ 1157/* LOG(llevDebug," load completed, object=%s\n",op->name);*/
1431 return retval; 1158 return retval;
1432} 1159}
1433 1160
1439 * override values and in c_wiz to mutate values. 1166 * override values and in c_wiz to mutate values.
1440 */ 1167 */
1441int set_variable(object *op,char *buf) { 1168int set_variable(object *op,char *buf) {
1442 YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; 1169 YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER;
1443 int retval; 1170 int retval;
1171 object_thawer thawer (0);
1444 1172
1445 strcpy(msgbuf, ""); 1173 strcpy(msgbuf, "");
1446 strcpy(lorebuf, ""); 1174 strcpy(lorebuf, "");
1447 yy_push_state(INITIAL); 1175 yy_push_state(INITIAL);
1448 yybufstate=yy_scan_string(buf); 1176 yybufstate=yy_scan_string(buf);
1449 retval=lex_load(op,0); 1177 retval=lex_load(op,thawer,0);
1450 yy_switch_to_buffer(yycurbuf); 1178 yy_switch_to_buffer(yycurbuf);
1451 yy_delete_buffer(yybufstate); 1179 yy_delete_buffer(yybufstate);
1452 yy_pop_state(); 1180 yy_pop_state();
1453 return retval; 1181 return retval;
1454} 1182}
1643 * NEVER touch buf between PREPARE_FASTCAT(buf) and 1371 * NEVER touch buf between PREPARE_FASTCAT(buf) and
1644 * FINISH_FASTCAT(buf) 1372 * FINISH_FASTCAT(buf)
1645 */ 1373 */
1646 static int already_run = 0; 1374 static int already_run = 0;
1647 static int flag_lens[NUM_FLAGS]; 1375 static int flag_lens[NUM_FLAGS];
1648 static char buf2[HUGE_BUF]; 1376 char buf2[4096]; // / was HUFE_BUF, which was hugely incorrect, as is this value, but much less so
1649 static char buf[HUGE_BUF]; 1377 static char buf[128*1024]; // < the assumption is that every object always fits. fixing this bug, however
1650 char* fastbuf; 1378 char* fastbuf; // \ requires a large rewrite of the code, so its left to the next total rewrite.
1651 int tmp; 1379 int tmp;
1652 int i; 1380 int i;
1653#if 0
1654/*Memory polluting code. Should help detect problems, very slow*/
1655 for (i=0;i<HUGE_BUF;i++){
1656 buf[i]='a'+(unsigned short)(i%25);
1657 }
1658#endif
1659 event *etmp; 1381 event *etmp;
1660 event *etmp2; 1382 event *etmp2;
1661 key_value * my_field; 1383 key_value * my_field;
1662 key_value * arch_field; 1384 key_value * arch_field;
1663 1385
1911 if (op->will_apply!=op2->will_apply) 1633 if (op->will_apply!=op2->will_apply)
1912 FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11); 1634 FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11);
1913 if(op->smoothlevel!=op2->smoothlevel) 1635 if(op->smoothlevel!=op2->smoothlevel)
1914 FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12); 1636 FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12);
1915 1637
1916 if (op->current_weapon_script!=op2->current_weapon_script){
1917 ADD_STRINGLINE_ENTRY(fastbuf,"current_weapon_script ",op->current_weapon_script,22);
1918 };
1919
1920 if(op->weapontype && op->weapontype!=op2->weapontype) { 1638 if(op->weapontype && op->weapontype!=op2->weapontype) {
1921 FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11); 1639 FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11);
1922 } 1640 }
1923 if(op->tooltype && op->tooltype!=op2->tooltype) { 1641 if(op->tooltype && op->tooltype!=op2->tooltype) {
1924 FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9); 1642 FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9);
1994 get_string_move_type(op->move_slow), 1712 get_string_move_type(op->move_slow),
1995 10); 1713 10);
1996 } 1714 }
1997 1715
1998 if (op->move_slow_penalty != op2->move_slow_penalty) { 1716 if (op->move_slow_penalty != op2->move_slow_penalty) {
1999 FAST_SAVE_LONG(fastbuf,"move_slow_penalty ",op->move_slow_penalty,18); 1717 FAST_SAVE_LONG(fastbuf,"move_slow_penalty ",(long) op->move_slow_penalty,18);
2000 } 1718 }
2001 1719
2002 if (!COMPARE_FLAGS(op,op2)) { 1720 if (!COMPARE_FLAGS(op,op2)) {
2003 for (tmp=0; tmp <= NUM_FLAGS; tmp++) { 1721 for (tmp=0; tmp <= NUM_FLAGS; tmp++) {
2004 if (flag_names[tmp] && (QUERY_FLAG(op, tmp) != QUERY_FLAG(op2, tmp))) { 1722 if (flag_names[tmp] && (QUERY_FLAG(op, tmp) != QUERY_FLAG(op2, tmp))) {
2027 * the only place this is not set is when saving the player. 1745 * the only place this is not set is when saving the player.
2028 * If bit 1 of flag is set, don't remove the object after save. As of now, 1746 * If bit 1 of flag is set, don't remove the object after save. As of now,
2029 * all of the callers are setting this. 1747 * all of the callers are setting this.
2030 */ 1748 */
2031 1749
2032void save_object(FILE *fp,object *op, int flag) { 1750void save_object(object_freezer &fp,object *op, int flag) {
2033 archetype *at; 1751 archetype *at;
2034 char *cp; 1752 char *cp;
2035 object *tmp,*old; 1753 object *tmp,*old;
2036 1754
2037 /* Even if the object does have an owner, it would seem that we should 1755 /* Even if the object does have an owner, it would seem that we should
2038 * still save it. 1756 * still save it.
2039 */ 1757 */
2040 if(op->owner!=NULL || fp == NULL) 1758 if(op->owner!=NULL)
2041 return; 1759 return;
2042 1760
2043 /* If it is unpaid and we don't want to save those, just return. */ 1761 /* If it is unpaid and we don't want to save those, just return. */
2044 if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) { 1762 if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) {
2045 return; 1763 return;
2076 if (!(flag&2)) { 1794 if (!(flag&2)) {
2077 remove_ob(op); 1795 remove_ob(op);
2078 free_object (op); 1796 free_object (op);
2079 } 1797 }
2080 1798
1799 fp.put (op);
2081 fprintf(fp,"end\n"); 1800 fprintf(fp,"end\n");
2082} 1801}
2083 1802
2084void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions) 1803void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions)
2085{ 1804{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines