1 | %{ |
1 | %{ |
2 | /* |
2 | /* |
3 | * static char *rcsid_object_c = |
3 | * static char *rcsid_object_c = |
4 | * "$Id: loader.l,v 1.10 2006/08/27 16:15:11 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 | |
… | |
… | |
743 | char *yv=yval(); |
743 | char *yv=yval(); |
744 | |
744 | |
745 | op->arch=find_archetype(yv); |
745 | op->arch=find_archetype(yv); |
746 | if (op->arch!=NULL) { |
746 | if (op->arch!=NULL) { |
747 | copy_object(&op->arch->clone,op); |
747 | copy_object(&op->arch->clone,op); |
748 | op->instantiate (); |
|
|
749 | } else if (!arch_init) { |
748 | } else if (!arch_init) { |
750 | if (op->name) free_string(op->name); |
749 | if (op->name) free_string(op->name); |
751 | /* record the name of the broken object */ |
750 | /* record the name of the broken object */ |
752 | op->name = add_string(yv); |
751 | op->name = add_string(yv); |
753 | } |
752 | } |
… | |
… | |
768 | ^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, |
769 | * so the calling function can glue things back together |
768 | * so the calling function can glue things back together |
770 | */ |
769 | */ |
771 | ismore=1; |
770 | ismore=1; |
772 | } |
771 | } |
773 | |
|
|
774 | ^end{WS}$ { check_loaded_object(op); |
772 | ^end{WS}$ { check_loaded_object(op); |
775 | thawer.get (op); |
773 | |
|
|
774 | if (!arch_init) |
|
|
775 | op->instantiate (); |
|
|
776 | |
776 | if (ismore) return LL_MORE; |
777 | if (ismore) return LL_MORE; |
777 | else return LL_NORMAL; |
778 | else return LL_NORMAL; |
778 | } |
779 | } |
|
|
780 | ^oid{S} { |
|
|
781 | thawer.get (op, IVAL); |
|
|
782 | } |
779 | ^last_heal{S} op->last_heal = IVAL; |
783 | ^last_heal{S} op->last_heal = IVAL; |
780 | ^last_sp{S} op->last_sp = IVAL; |
784 | ^last_sp{S} op->last_sp = IVAL; |
781 | ^last_grace{S} op->last_grace = IVAL; |
785 | ^last_grace{S} op->last_grace = IVAL; |
782 | ^last_eat{S} op->last_eat = IVAL; |
786 | ^last_eat{S} op->last_eat = IVAL; |
783 | ^speed{S} { op->speed = FVAL; |
787 | ^speed{S} { op->speed = FVAL; |
… | |
… | |
1052 | ^range_modifier{S} op->range_modifier = IVAL; |
1056 | ^range_modifier{S} op->range_modifier = IVAL; |
1053 | ^dam_modifier{S} op->dam_modifier = IVAL; |
1057 | ^dam_modifier{S} op->dam_modifier = IVAL; |
1054 | ^duration_modifier{S} op->duration_modifier = IVAL; |
1058 | ^duration_modifier{S} op->duration_modifier = IVAL; |
1055 | ^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 ); |
1056 | |
1060 | |
1057 | ^event_apply{S} { |
1061 | ^event_ { |
1058 | char *yv=yval(); |
1062 | LOG (llevError, "stray event_* in map file, skipping."); |
1059 | if (*yv=='\0') |
|
|
1060 | LOG(llevError,"Event (apply) without val\n"); |
|
|
1061 | else |
|
|
1062 | insert_event(op,EVENT_APPLY,yv,NULL,NULL); |
|
|
1063 | } |
1063 | } |
1064 | |
|
|
1065 | ^event_apply_plugin{S} { |
|
|
1066 | char *yv=yval(); |
|
|
1067 | if (*yv=='\0') |
|
|
1068 | LOG(llevError,"Event (apply) without plugin\n"); |
|
|
1069 | else |
|
|
1070 | insert_event(op,EVENT_APPLY,NULL,yv,NULL); |
|
|
1071 | } |
|
|
1072 | |
|
|
1073 | ^event_apply_options{S} { |
|
|
1074 | char *yv=yval(); |
|
|
1075 | if (*yv=='\0') |
|
|
1076 | LOG(llevError,"Event (apply) without options\n"); |
|
|
1077 | else |
|
|
1078 | insert_event(op,EVENT_APPLY,NULL,NULL,yv); |
|
|
1079 | } |
|
|
1080 | |
|
|
1081 | ^event_attack{S} { |
|
|
1082 | char *yv=yval(); |
|
|
1083 | if (*yv=='\0') |
|
|
1084 | LOG(llevError,"Event (attack) without val\n"); |
|
|
1085 | else |
|
|
1086 | insert_event(op,EVENT_ATTACK,yv,NULL,NULL); |
|
|
1087 | } |
|
|
1088 | |
|
|
1089 | ^event_attack_plugin{S} { |
|
|
1090 | char *yv=yval(); |
|
|
1091 | if (*yv=='\0') |
|
|
1092 | LOG(llevError,"Event (attack) without plugin\n"); |
|
|
1093 | else |
|
|
1094 | insert_event(op,EVENT_ATTACK,NULL,yv,NULL); |
|
|
1095 | } |
|
|
1096 | |
|
|
1097 | ^event_attack_options{S} { |
|
|
1098 | char *yv=yval(); |
|
|
1099 | if (*yv=='\0') |
|
|
1100 | LOG(llevError,"Event (attack) without options\n"); |
|
|
1101 | else |
|
|
1102 | insert_event(op,EVENT_ATTACK,NULL,NULL,yv); |
|
|
1103 | } |
|
|
1104 | ^event_death{S} { |
|
|
1105 | char *yv=yval(); |
|
|
1106 | if (*yv=='\0') |
|
|
1107 | LOG(llevError,"Event (death) without val\n"); |
|
|
1108 | else |
|
|
1109 | insert_event(op,EVENT_DEATH,yv,NULL,NULL); |
|
|
1110 | } |
|
|
1111 | |
|
|
1112 | ^event_death_plugin{S} { |
|
|
1113 | char *yv=yval(); |
|
|
1114 | if (*yv=='\0') |
|
|
1115 | LOG(llevError,"Event (death) without plugin\n"); |
|
|
1116 | else |
|
|
1117 | insert_event(op,EVENT_DEATH,NULL,yv,NULL); |
|
|
1118 | } |
|
|
1119 | |
|
|
1120 | ^event_death_options{S} { |
|
|
1121 | char *yv=yval(); |
|
|
1122 | if (*yv=='\0') |
|
|
1123 | LOG(llevError,"Event (death) without options\n"); |
|
|
1124 | else |
|
|
1125 | insert_event(op,EVENT_DEATH,NULL,NULL,yv); |
|
|
1126 | } |
|
|
1127 | ^event_drop{S} { |
|
|
1128 | char *yv=yval(); |
|
|
1129 | if (*yv=='\0') |
|
|
1130 | LOG(llevError,"Event (drop) without val\n"); |
|
|
1131 | else |
|
|
1132 | insert_event(op,EVENT_DROP,yv,NULL,NULL); |
|
|
1133 | } |
|
|
1134 | |
|
|
1135 | ^event_drop_plugin{S} { |
|
|
1136 | char *yv=yval(); |
|
|
1137 | if (*yv=='\0') |
|
|
1138 | LOG(llevError,"Event (drop) without plugin\n"); |
|
|
1139 | else |
|
|
1140 | insert_event(op,EVENT_DROP,NULL,yv,NULL); |
|
|
1141 | } |
|
|
1142 | |
|
|
1143 | ^event_drop_options{S} { |
|
|
1144 | char *yv=yval(); |
|
|
1145 | if (*yv=='\0') |
|
|
1146 | LOG(llevError,"Event (drop) without options\n"); |
|
|
1147 | else |
|
|
1148 | insert_event(op,EVENT_DROP,NULL,NULL,yv); |
|
|
1149 | } |
|
|
1150 | ^event_pickup{S} { |
|
|
1151 | char *yv=yval(); |
|
|
1152 | if (*yv=='\0') |
|
|
1153 | LOG(llevError,"Event (pickup) without val\n"); |
|
|
1154 | else |
|
|
1155 | insert_event(op,EVENT_PICKUP,yv,NULL,NULL); |
|
|
1156 | } |
|
|
1157 | |
|
|
1158 | ^event_pickup_plugin{S} { |
|
|
1159 | char *yv=yval(); |
|
|
1160 | if (*yv=='\0') |
|
|
1161 | LOG(llevError,"Event (pickup) without plugin\n"); |
|
|
1162 | else |
|
|
1163 | insert_event(op,EVENT_PICKUP,NULL,yv,NULL); |
|
|
1164 | } |
|
|
1165 | |
|
|
1166 | ^event_pickup_options{S} { |
|
|
1167 | char *yv=yval(); |
|
|
1168 | if (*yv=='\0') |
|
|
1169 | LOG(llevError,"Event (pickup) without options\n"); |
|
|
1170 | else |
|
|
1171 | insert_event(op,EVENT_PICKUP,NULL,NULL,yv); |
|
|
1172 | } |
|
|
1173 | ^event_say{S} { |
|
|
1174 | char *yv=yval(); |
|
|
1175 | if (*yv=='\0') |
|
|
1176 | LOG(llevError,"Event (say) without val\n"); |
|
|
1177 | else |
|
|
1178 | insert_event(op,EVENT_SAY,yv,NULL,NULL); |
|
|
1179 | } |
|
|
1180 | |
|
|
1181 | ^event_say_plugin{S} { |
|
|
1182 | char *yv=yval(); |
|
|
1183 | if (*yv=='\0') |
|
|
1184 | LOG(llevError,"Event (say) without plugin\n"); |
|
|
1185 | else |
|
|
1186 | insert_event(op,EVENT_SAY,NULL,yv,NULL); |
|
|
1187 | } |
|
|
1188 | |
|
|
1189 | ^event_say_options{S} { |
|
|
1190 | char *yv=yval(); |
|
|
1191 | if (*yv=='\0') |
|
|
1192 | LOG(llevError,"Event (say) without options\n"); |
|
|
1193 | else |
|
|
1194 | insert_event(op,EVENT_SAY,NULL,NULL,yv); |
|
|
1195 | } |
|
|
1196 | ^event_stop{S} { |
|
|
1197 | char *yv=yval(); |
|
|
1198 | if (*yv=='\0') |
|
|
1199 | LOG(llevError,"Event (stop) without val\n"); |
|
|
1200 | else |
|
|
1201 | insert_event(op,EVENT_STOP,yv,NULL,NULL); |
|
|
1202 | } |
|
|
1203 | |
|
|
1204 | ^event_stop_plugin{S} { |
|
|
1205 | char *yv=yval(); |
|
|
1206 | if (*yv=='\0') |
|
|
1207 | LOG(llevError,"Event (stop) without plugin\n"); |
|
|
1208 | else |
|
|
1209 | insert_event(op,EVENT_STOP,NULL,yv,NULL); |
|
|
1210 | } |
|
|
1211 | |
|
|
1212 | ^event_stop_options{S} { |
|
|
1213 | char *yv=yval(); |
|
|
1214 | if (*yv=='\0') |
|
|
1215 | LOG(llevError,"Event (stop) without options\n"); |
|
|
1216 | else |
|
|
1217 | insert_event(op,EVENT_STOP,NULL,NULL,yv); |
|
|
1218 | } |
|
|
1219 | ^event_time{S} { |
|
|
1220 | char *yv=yval(); |
|
|
1221 | if (*yv=='\0') |
|
|
1222 | LOG(llevError,"Event (time) without val\n"); |
|
|
1223 | else |
|
|
1224 | insert_event(op,EVENT_TIME,yv,NULL,NULL); |
|
|
1225 | } |
|
|
1226 | |
|
|
1227 | ^event_time_plugin{S} { |
|
|
1228 | char *yv=yval(); |
|
|
1229 | if (*yv=='\0') |
|
|
1230 | LOG(llevError,"Event (time) without plugin\n"); |
|
|
1231 | else |
|
|
1232 | insert_event(op,EVENT_TIME,NULL,yv,NULL); |
|
|
1233 | } |
|
|
1234 | |
|
|
1235 | ^event_time_options{S} { |
|
|
1236 | char *yv=yval(); |
|
|
1237 | if (*yv=='\0') |
|
|
1238 | LOG(llevError,"Event (time) without options\n"); |
|
|
1239 | else |
|
|
1240 | insert_event(op,EVENT_TIME,NULL,NULL,yv); |
|
|
1241 | } |
|
|
1242 | ^event_throw{S} { |
|
|
1243 | char *yv=yval(); |
|
|
1244 | if (*yv=='\0') |
|
|
1245 | LOG(llevError,"Event (throw) without val\n"); |
|
|
1246 | else |
|
|
1247 | insert_event(op,EVENT_THROW,yv,NULL,NULL); |
|
|
1248 | } |
|
|
1249 | |
|
|
1250 | ^event_throw_plugin{S} { |
|
|
1251 | char *yv=yval(); |
|
|
1252 | if (*yv=='\0') |
|
|
1253 | LOG(llevError,"Event (throw) without plugin\n"); |
|
|
1254 | else |
|
|
1255 | insert_event(op,EVENT_THROW,NULL,yv,NULL); |
|
|
1256 | } |
|
|
1257 | |
|
|
1258 | ^event_throw_options{S} { |
|
|
1259 | char *yv=yval(); |
|
|
1260 | if (*yv=='\0') |
|
|
1261 | LOG(llevError,"Event (apply) without options\n"); |
|
|
1262 | else |
|
|
1263 | insert_event(op,EVENT_THROW,NULL,NULL,yv); |
|
|
1264 | } |
|
|
1265 | ^event_trigger{S} { |
|
|
1266 | char *yv=yval(); |
|
|
1267 | if (*yv=='\0') |
|
|
1268 | LOG(llevError,"Event (trigger) without val\n"); |
|
|
1269 | else |
|
|
1270 | insert_event(op,EVENT_TRIGGER,yv,NULL,NULL); |
|
|
1271 | } |
|
|
1272 | |
|
|
1273 | ^event_trigger_plugin{S} { |
|
|
1274 | char *yv=yval(); |
|
|
1275 | if (*yv=='\0') |
|
|
1276 | LOG(llevError,"Event (trigger) without plugin\n"); |
|
|
1277 | else |
|
|
1278 | insert_event(op,EVENT_TRIGGER,NULL,yv,NULL); |
|
|
1279 | } |
|
|
1280 | |
|
|
1281 | ^event_trigger_options{S} { |
|
|
1282 | char *yv=yval(); |
|
|
1283 | if (*yv=='\0') |
|
|
1284 | LOG(llevError,"Event (trigger) without options\n"); |
|
|
1285 | else |
|
|
1286 | insert_event(op,EVENT_TRIGGER,NULL,NULL,yv); |
|
|
1287 | } |
|
|
1288 | ^event_close{S} { |
|
|
1289 | char *yv=yval(); |
|
|
1290 | if (*yv=='\0') |
|
|
1291 | LOG(llevError,"Event (close) without val\n"); |
|
|
1292 | else |
|
|
1293 | insert_event(op,EVENT_CLOSE,yv,NULL,NULL); |
|
|
1294 | } |
|
|
1295 | |
|
|
1296 | ^event_close_plugin{S} { |
|
|
1297 | char *yv=yval(); |
|
|
1298 | if (*yv=='\0') |
|
|
1299 | LOG(llevError,"Event (close) without plugin\n"); |
|
|
1300 | else |
|
|
1301 | insert_event(op,EVENT_CLOSE,NULL,yv,NULL); |
|
|
1302 | } |
|
|
1303 | |
|
|
1304 | ^event_close_options{S} { |
|
|
1305 | char *yv=yval(); |
|
|
1306 | if (*yv=='\0') |
|
|
1307 | LOG(llevError,"Event (close) without options\n"); |
|
|
1308 | else |
|
|
1309 | insert_event(op,EVENT_CLOSE,NULL,NULL,yv); |
|
|
1310 | } |
|
|
1311 | ^event_timer{S} { |
|
|
1312 | char *yv=yval(); |
|
|
1313 | if (*yv=='\0') |
|
|
1314 | LOG(llevError,"Event (timer) without val\n"); |
|
|
1315 | else |
|
|
1316 | insert_event(op,EVENT_TIMER,yv,NULL,NULL); |
|
|
1317 | } |
|
|
1318 | |
|
|
1319 | ^event_timer_plugin{S} { |
|
|
1320 | char *yv=yval(); |
|
|
1321 | if (*yv=='\0') |
|
|
1322 | LOG(llevError,"Event (timer) without plugin\n"); |
|
|
1323 | else |
|
|
1324 | insert_event(op,EVENT_TIMER,NULL,yv,NULL); |
|
|
1325 | } |
|
|
1326 | |
|
|
1327 | ^event_timer_options{S} { |
|
|
1328 | char *yv=yval(); |
|
|
1329 | if (*yv=='\0') |
|
|
1330 | LOG(llevError,"Event (timer) without options\n"); |
|
|
1331 | else |
|
|
1332 | insert_event(op,EVENT_TIMER,NULL,NULL,yv); |
|
|
1333 | } |
|
|
1334 | |
|
|
1335 | ^current_weapon_script{S} { char *yv=yval(); |
|
|
1336 | |
|
|
1337 | if (*yv=='\0') LOG(llevError,"Script (current weapon) without val\n"); |
|
|
1338 | else |
|
|
1339 | { |
|
|
1340 | FREE_AND_COPY(op->current_weapon_script, yv); |
|
|
1341 | }; |
|
|
1342 | } |
|
|
1343 | |
1064 | |
1344 | <*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} |
1065 | <*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} |
1345 | #.*\n {} |
1066 | #.*\n {} |
1346 | |
1067 | |
1347 | <<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 */ |
… | |
… | |
1405 | * be reset. |
1126 | * be reset. |
1406 | * 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) |
1407 | * |
1128 | * |
1408 | */ |
1129 | */ |
1409 | |
1130 | |
1410 | int load_object(FILE *fp, object_thawer &thawer, object *op, int bufstate, int map_flags) { |
1131 | int load_object(object_thawer &fp, object *op, int bufstate, int map_flags) { |
1411 | int retval; |
1132 | int retval; |
1412 | char inbuf[MAX_BUF]; |
1133 | char inbuf[MAX_BUF]; |
1413 | |
1134 | |
1414 | strcpy(msgbuf, ""); |
1135 | strcpy(msgbuf, ""); |
1415 | strcpy(lorebuf, ""); |
1136 | strcpy(lorebuf, ""); |
… | |
… | |
1421 | } |
1142 | } |
1422 | if (bufstate==LO_LINEMODE) { |
1143 | if (bufstate==LO_LINEMODE) { |
1423 | YY_BUFFER_STATE yybufstate; |
1144 | YY_BUFFER_STATE yybufstate; |
1424 | while (fgets(inbuf, MAX_BUF-3, fp)) { |
1145 | while (fgets(inbuf, MAX_BUF-3, fp)) { |
1425 | yybufstate=yy_scan_string(inbuf); |
1146 | yybufstate=yy_scan_string(inbuf); |
1426 | retval=lex_load(op, thawer, map_flags); |
1147 | retval=lex_load(op, fp, map_flags); |
1427 | yy_delete_buffer(yybufstate); |
1148 | yy_delete_buffer(yybufstate); |
1428 | if (retval==LL_NORMAL) return retval; |
1149 | if (retval==LL_NORMAL) return retval; |
1429 | } |
1150 | } |
1430 | LOG(llevDebug,"Got eof while scanning strings\n"); |
1151 | LOG(llevDebug,"Got eof while scanning strings\n"); |
1431 | return LL_EOF; |
1152 | return LL_EOF; |
1432 | } |
1153 | } |
1433 | |
1154 | |
1434 | retval=lex_load(op, thawer, map_flags); |
1155 | retval=lex_load(op, fp, map_flags); |
1435 | if (op->current_weapon_script != NULL) |
|
|
1436 | { |
|
|
1437 | op->current_weapon = find_best_weapon_used_match(op, op->current_weapon_script); |
|
|
1438 | LOG(llevDebug, "CurrentWeapon Loaded !\n"); |
|
|
1439 | }; |
|
|
1440 | |
1156 | |
1441 | /* LOG(llevDebug," load completed, object=%s\n",op->name);*/ |
1157 | /* LOG(llevDebug," load completed, object=%s\n",op->name);*/ |
1442 | return retval; |
1158 | return retval; |
1443 | } |
1159 | } |
1444 | |
1160 | |
… | |
… | |
1450 | * override values and in c_wiz to mutate values. |
1166 | * override values and in c_wiz to mutate values. |
1451 | */ |
1167 | */ |
1452 | int set_variable(object *op,char *buf) { |
1168 | int set_variable(object *op,char *buf) { |
1453 | YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; |
1169 | YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; |
1454 | int retval; |
1170 | int retval; |
1455 | object_thawer thawer; |
1171 | object_thawer thawer (0); |
1456 | |
1172 | |
1457 | strcpy(msgbuf, ""); |
1173 | strcpy(msgbuf, ""); |
1458 | strcpy(lorebuf, ""); |
1174 | strcpy(lorebuf, ""); |
1459 | yy_push_state(INITIAL); |
1175 | yy_push_state(INITIAL); |
1460 | yybufstate=yy_scan_string(buf); |
1176 | yybufstate=yy_scan_string(buf); |
… | |
… | |
1917 | if (op->will_apply!=op2->will_apply) |
1633 | if (op->will_apply!=op2->will_apply) |
1918 | FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11); |
1634 | FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11); |
1919 | if(op->smoothlevel!=op2->smoothlevel) |
1635 | if(op->smoothlevel!=op2->smoothlevel) |
1920 | FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12); |
1636 | FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12); |
1921 | |
1637 | |
1922 | if (op->current_weapon_script!=op2->current_weapon_script){ |
|
|
1923 | ADD_STRINGLINE_ENTRY(fastbuf,"current_weapon_script ",op->current_weapon_script,22); |
|
|
1924 | }; |
|
|
1925 | |
|
|
1926 | if(op->weapontype && op->weapontype!=op2->weapontype) { |
1638 | if(op->weapontype && op->weapontype!=op2->weapontype) { |
1927 | FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11); |
1639 | FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11); |
1928 | } |
1640 | } |
1929 | if(op->tooltype && op->tooltype!=op2->tooltype) { |
1641 | if(op->tooltype && op->tooltype!=op2->tooltype) { |
1930 | FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9); |
1642 | FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9); |
… | |
… | |
2033 | * 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. |
2034 | * 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, |
2035 | * all of the callers are setting this. |
1747 | * all of the callers are setting this. |
2036 | */ |
1748 | */ |
2037 | |
1749 | |
2038 | void save_object(FILE *fp,object_freezer &freezer,object *op, int flag) { |
1750 | void save_object(object_freezer &fp,object *op, int flag) { |
2039 | archetype *at; |
1751 | archetype *at; |
2040 | char *cp; |
1752 | char *cp; |
2041 | object *tmp,*old; |
1753 | object *tmp,*old; |
2042 | |
1754 | |
2043 | /* 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 |
2044 | * still save it. |
1756 | * still save it. |
2045 | */ |
1757 | */ |
2046 | if(op->owner!=NULL || fp == NULL) |
1758 | if(op->owner!=NULL) |
2047 | return; |
1759 | return; |
2048 | |
1760 | |
2049 | /* 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. */ |
2050 | if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) { |
1762 | if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) { |
2051 | return; |
1763 | return; |
… | |
… | |
2061 | |
1773 | |
2062 | old=NULL; |
1774 | old=NULL; |
2063 | |
1775 | |
2064 | if (flag & 2 ) |
1776 | if (flag & 2 ) |
2065 | for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) |
1777 | for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) |
2066 | save_object(fp,freezer,tmp,flag); |
1778 | save_object(fp,tmp,flag); |
2067 | |
1779 | |
2068 | /* Slightly different logic because tmp/op will be removed by |
1780 | /* Slightly different logic because tmp/op will be removed by |
2069 | * the save_object we call. So we just keep looking at op->inv |
1781 | * the save_object we call. So we just keep looking at op->inv |
2070 | * until there is nothing left. In theory, the variable old |
1782 | * until there is nothing left. In theory, the variable old |
2071 | * should not be needed, as recursive loops shouldn't happen. |
1783 | * should not be needed, as recursive loops shouldn't happen. |
… | |
… | |
2073 | else while ((tmp=op->inv)!=NULL) { |
1785 | else while ((tmp=op->inv)!=NULL) { |
2074 | if(old==tmp) { |
1786 | if(old==tmp) { |
2075 | LOG(llevError," Recursive loop in inventory\n"); |
1787 | LOG(llevError," Recursive loop in inventory\n"); |
2076 | break; |
1788 | break; |
2077 | } |
1789 | } |
2078 | save_object(fp,freezer,tmp,flag); |
1790 | save_object(fp,tmp,flag); |
2079 | old=tmp; |
1791 | old=tmp; |
2080 | } |
1792 | } |
2081 | |
1793 | |
2082 | if (!(flag&2)) { |
1794 | if (!(flag&2)) { |
2083 | remove_ob(op); |
1795 | remove_ob(op); |
2084 | free_object (op); |
1796 | free_object (op); |
2085 | } |
1797 | } |
2086 | |
1798 | |
|
|
1799 | fp.put (op); |
2087 | fprintf(fp,"end\n"); |
1800 | fprintf(fp,"end\n"); |
2088 | freezer.put (op); |
|
|
2089 | } |
1801 | } |
2090 | |
1802 | |
2091 | void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions) |
1803 | void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions) |
2092 | { |
1804 | { |
2093 | event *evt; |
1805 | event *evt; |