1 | %{ |
1 | %{ |
2 | /* |
2 | /* |
3 | * static char *rcsid_object_c = |
3 | * static char *rcsid_object_c = |
4 | * "$Id: loader.l,v 1.12 2006/08/28 07:07:41 root Exp $"; |
4 | * "$Id: loader.l,v 1.17 2006/08/31 09:19:33 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 | |
… | |
… | |
1056 | ^range_modifier{S} op->range_modifier = IVAL; |
1056 | ^range_modifier{S} op->range_modifier = IVAL; |
1057 | ^dam_modifier{S} op->dam_modifier = IVAL; |
1057 | ^dam_modifier{S} op->dam_modifier = IVAL; |
1058 | ^duration_modifier{S} op->duration_modifier = IVAL; |
1058 | ^duration_modifier{S} op->duration_modifier = IVAL; |
1059 | ^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 ); |
1060 | |
1060 | |
1061 | ^event_apply{S} { |
1061 | ^event_ { |
1062 | char *yv=yval(); |
1062 | LOG (llevError, "stray event_* in map file, skipping."); |
1063 | if (*yv=='\0') |
|
|
1064 | LOG(llevError,"Event (apply) without val\n"); |
|
|
1065 | else |
|
|
1066 | insert_event(op,EVENT_APPLY,yv,NULL,NULL); |
|
|
1067 | } |
1063 | } |
1068 | |
|
|
1069 | ^event_apply_plugin{S} { |
|
|
1070 | char *yv=yval(); |
|
|
1071 | if (*yv=='\0') |
|
|
1072 | LOG(llevError,"Event (apply) without plugin\n"); |
|
|
1073 | else |
|
|
1074 | insert_event(op,EVENT_APPLY,NULL,yv,NULL); |
|
|
1075 | } |
|
|
1076 | |
|
|
1077 | ^event_apply_options{S} { |
|
|
1078 | char *yv=yval(); |
|
|
1079 | if (*yv=='\0') |
|
|
1080 | LOG(llevError,"Event (apply) without options\n"); |
|
|
1081 | else |
|
|
1082 | insert_event(op,EVENT_APPLY,NULL,NULL,yv); |
|
|
1083 | } |
|
|
1084 | |
|
|
1085 | ^event_attack{S} { |
|
|
1086 | char *yv=yval(); |
|
|
1087 | if (*yv=='\0') |
|
|
1088 | LOG(llevError,"Event (attack) without val\n"); |
|
|
1089 | else |
|
|
1090 | insert_event(op,EVENT_ATTACK,yv,NULL,NULL); |
|
|
1091 | } |
|
|
1092 | |
|
|
1093 | ^event_attack_plugin{S} { |
|
|
1094 | char *yv=yval(); |
|
|
1095 | if (*yv=='\0') |
|
|
1096 | LOG(llevError,"Event (attack) without plugin\n"); |
|
|
1097 | else |
|
|
1098 | insert_event(op,EVENT_ATTACK,NULL,yv,NULL); |
|
|
1099 | } |
|
|
1100 | |
|
|
1101 | ^event_attack_options{S} { |
|
|
1102 | char *yv=yval(); |
|
|
1103 | if (*yv=='\0') |
|
|
1104 | LOG(llevError,"Event (attack) without options\n"); |
|
|
1105 | else |
|
|
1106 | insert_event(op,EVENT_ATTACK,NULL,NULL,yv); |
|
|
1107 | } |
|
|
1108 | ^event_death{S} { |
|
|
1109 | char *yv=yval(); |
|
|
1110 | if (*yv=='\0') |
|
|
1111 | LOG(llevError,"Event (death) without val\n"); |
|
|
1112 | else |
|
|
1113 | insert_event(op,EVENT_DEATH,yv,NULL,NULL); |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | ^event_death_plugin{S} { |
|
|
1117 | char *yv=yval(); |
|
|
1118 | if (*yv=='\0') |
|
|
1119 | LOG(llevError,"Event (death) without plugin\n"); |
|
|
1120 | else |
|
|
1121 | insert_event(op,EVENT_DEATH,NULL,yv,NULL); |
|
|
1122 | } |
|
|
1123 | |
|
|
1124 | ^event_death_options{S} { |
|
|
1125 | char *yv=yval(); |
|
|
1126 | if (*yv=='\0') |
|
|
1127 | LOG(llevError,"Event (death) without options\n"); |
|
|
1128 | else |
|
|
1129 | insert_event(op,EVENT_DEATH,NULL,NULL,yv); |
|
|
1130 | } |
|
|
1131 | ^event_drop{S} { |
|
|
1132 | char *yv=yval(); |
|
|
1133 | if (*yv=='\0') |
|
|
1134 | LOG(llevError,"Event (drop) without val\n"); |
|
|
1135 | else |
|
|
1136 | insert_event(op,EVENT_DROP,yv,NULL,NULL); |
|
|
1137 | } |
|
|
1138 | |
|
|
1139 | ^event_drop_plugin{S} { |
|
|
1140 | char *yv=yval(); |
|
|
1141 | if (*yv=='\0') |
|
|
1142 | LOG(llevError,"Event (drop) without plugin\n"); |
|
|
1143 | else |
|
|
1144 | insert_event(op,EVENT_DROP,NULL,yv,NULL); |
|
|
1145 | } |
|
|
1146 | |
|
|
1147 | ^event_drop_options{S} { |
|
|
1148 | char *yv=yval(); |
|
|
1149 | if (*yv=='\0') |
|
|
1150 | LOG(llevError,"Event (drop) without options\n"); |
|
|
1151 | else |
|
|
1152 | insert_event(op,EVENT_DROP,NULL,NULL,yv); |
|
|
1153 | } |
|
|
1154 | ^event_pickup{S} { |
|
|
1155 | char *yv=yval(); |
|
|
1156 | if (*yv=='\0') |
|
|
1157 | LOG(llevError,"Event (pickup) without val\n"); |
|
|
1158 | else |
|
|
1159 | insert_event(op,EVENT_PICKUP,yv,NULL,NULL); |
|
|
1160 | } |
|
|
1161 | |
|
|
1162 | ^event_pickup_plugin{S} { |
|
|
1163 | char *yv=yval(); |
|
|
1164 | if (*yv=='\0') |
|
|
1165 | LOG(llevError,"Event (pickup) without plugin\n"); |
|
|
1166 | else |
|
|
1167 | insert_event(op,EVENT_PICKUP,NULL,yv,NULL); |
|
|
1168 | } |
|
|
1169 | |
|
|
1170 | ^event_pickup_options{S} { |
|
|
1171 | char *yv=yval(); |
|
|
1172 | if (*yv=='\0') |
|
|
1173 | LOG(llevError,"Event (pickup) without options\n"); |
|
|
1174 | else |
|
|
1175 | insert_event(op,EVENT_PICKUP,NULL,NULL,yv); |
|
|
1176 | } |
|
|
1177 | ^event_say{S} { |
|
|
1178 | char *yv=yval(); |
|
|
1179 | if (*yv=='\0') |
|
|
1180 | LOG(llevError,"Event (say) without val\n"); |
|
|
1181 | else |
|
|
1182 | insert_event(op,EVENT_SAY,yv,NULL,NULL); |
|
|
1183 | } |
|
|
1184 | |
|
|
1185 | ^event_say_plugin{S} { |
|
|
1186 | char *yv=yval(); |
|
|
1187 | if (*yv=='\0') |
|
|
1188 | LOG(llevError,"Event (say) without plugin\n"); |
|
|
1189 | else |
|
|
1190 | insert_event(op,EVENT_SAY,NULL,yv,NULL); |
|
|
1191 | } |
|
|
1192 | |
|
|
1193 | ^event_say_options{S} { |
|
|
1194 | char *yv=yval(); |
|
|
1195 | if (*yv=='\0') |
|
|
1196 | LOG(llevError,"Event (say) without options\n"); |
|
|
1197 | else |
|
|
1198 | insert_event(op,EVENT_SAY,NULL,NULL,yv); |
|
|
1199 | } |
|
|
1200 | ^event_stop{S} { |
|
|
1201 | char *yv=yval(); |
|
|
1202 | if (*yv=='\0') |
|
|
1203 | LOG(llevError,"Event (stop) without val\n"); |
|
|
1204 | else |
|
|
1205 | insert_event(op,EVENT_STOP,yv,NULL,NULL); |
|
|
1206 | } |
|
|
1207 | |
|
|
1208 | ^event_stop_plugin{S} { |
|
|
1209 | char *yv=yval(); |
|
|
1210 | if (*yv=='\0') |
|
|
1211 | LOG(llevError,"Event (stop) without plugin\n"); |
|
|
1212 | else |
|
|
1213 | insert_event(op,EVENT_STOP,NULL,yv,NULL); |
|
|
1214 | } |
|
|
1215 | |
|
|
1216 | ^event_stop_options{S} { |
|
|
1217 | char *yv=yval(); |
|
|
1218 | if (*yv=='\0') |
|
|
1219 | LOG(llevError,"Event (stop) without options\n"); |
|
|
1220 | else |
|
|
1221 | insert_event(op,EVENT_STOP,NULL,NULL,yv); |
|
|
1222 | } |
|
|
1223 | ^event_time{S} { |
|
|
1224 | char *yv=yval(); |
|
|
1225 | if (*yv=='\0') |
|
|
1226 | LOG(llevError,"Event (time) without val\n"); |
|
|
1227 | else |
|
|
1228 | insert_event(op,EVENT_TIME,yv,NULL,NULL); |
|
|
1229 | } |
|
|
1230 | |
|
|
1231 | ^event_time_plugin{S} { |
|
|
1232 | char *yv=yval(); |
|
|
1233 | if (*yv=='\0') |
|
|
1234 | LOG(llevError,"Event (time) without plugin\n"); |
|
|
1235 | else |
|
|
1236 | insert_event(op,EVENT_TIME,NULL,yv,NULL); |
|
|
1237 | } |
|
|
1238 | |
|
|
1239 | ^event_time_options{S} { |
|
|
1240 | char *yv=yval(); |
|
|
1241 | if (*yv=='\0') |
|
|
1242 | LOG(llevError,"Event (time) without options\n"); |
|
|
1243 | else |
|
|
1244 | insert_event(op,EVENT_TIME,NULL,NULL,yv); |
|
|
1245 | } |
|
|
1246 | ^event_throw{S} { |
|
|
1247 | char *yv=yval(); |
|
|
1248 | if (*yv=='\0') |
|
|
1249 | LOG(llevError,"Event (throw) without val\n"); |
|
|
1250 | else |
|
|
1251 | insert_event(op,EVENT_THROW,yv,NULL,NULL); |
|
|
1252 | } |
|
|
1253 | |
|
|
1254 | ^event_throw_plugin{S} { |
|
|
1255 | char *yv=yval(); |
|
|
1256 | if (*yv=='\0') |
|
|
1257 | LOG(llevError,"Event (throw) without plugin\n"); |
|
|
1258 | else |
|
|
1259 | insert_event(op,EVENT_THROW,NULL,yv,NULL); |
|
|
1260 | } |
|
|
1261 | |
|
|
1262 | ^event_throw_options{S} { |
|
|
1263 | char *yv=yval(); |
|
|
1264 | if (*yv=='\0') |
|
|
1265 | LOG(llevError,"Event (apply) without options\n"); |
|
|
1266 | else |
|
|
1267 | insert_event(op,EVENT_THROW,NULL,NULL,yv); |
|
|
1268 | } |
|
|
1269 | ^event_trigger{S} { |
|
|
1270 | char *yv=yval(); |
|
|
1271 | if (*yv=='\0') |
|
|
1272 | LOG(llevError,"Event (trigger) without val\n"); |
|
|
1273 | else |
|
|
1274 | insert_event(op,EVENT_TRIGGER,yv,NULL,NULL); |
|
|
1275 | } |
|
|
1276 | |
|
|
1277 | ^event_trigger_plugin{S} { |
|
|
1278 | char *yv=yval(); |
|
|
1279 | if (*yv=='\0') |
|
|
1280 | LOG(llevError,"Event (trigger) without plugin\n"); |
|
|
1281 | else |
|
|
1282 | insert_event(op,EVENT_TRIGGER,NULL,yv,NULL); |
|
|
1283 | } |
|
|
1284 | |
|
|
1285 | ^event_trigger_options{S} { |
|
|
1286 | char *yv=yval(); |
|
|
1287 | if (*yv=='\0') |
|
|
1288 | LOG(llevError,"Event (trigger) without options\n"); |
|
|
1289 | else |
|
|
1290 | insert_event(op,EVENT_TRIGGER,NULL,NULL,yv); |
|
|
1291 | } |
|
|
1292 | ^event_close{S} { |
|
|
1293 | char *yv=yval(); |
|
|
1294 | if (*yv=='\0') |
|
|
1295 | LOG(llevError,"Event (close) without val\n"); |
|
|
1296 | else |
|
|
1297 | insert_event(op,EVENT_CLOSE,yv,NULL,NULL); |
|
|
1298 | } |
|
|
1299 | |
|
|
1300 | ^event_close_plugin{S} { |
|
|
1301 | char *yv=yval(); |
|
|
1302 | if (*yv=='\0') |
|
|
1303 | LOG(llevError,"Event (close) without plugin\n"); |
|
|
1304 | else |
|
|
1305 | insert_event(op,EVENT_CLOSE,NULL,yv,NULL); |
|
|
1306 | } |
|
|
1307 | |
|
|
1308 | ^event_close_options{S} { |
|
|
1309 | char *yv=yval(); |
|
|
1310 | if (*yv=='\0') |
|
|
1311 | LOG(llevError,"Event (close) without options\n"); |
|
|
1312 | else |
|
|
1313 | insert_event(op,EVENT_CLOSE,NULL,NULL,yv); |
|
|
1314 | } |
|
|
1315 | ^event_timer{S} { |
|
|
1316 | char *yv=yval(); |
|
|
1317 | if (*yv=='\0') |
|
|
1318 | LOG(llevError,"Event (timer) without val\n"); |
|
|
1319 | else |
|
|
1320 | insert_event(op,EVENT_TIMER,yv,NULL,NULL); |
|
|
1321 | } |
|
|
1322 | |
|
|
1323 | ^event_timer_plugin{S} { |
|
|
1324 | char *yv=yval(); |
|
|
1325 | if (*yv=='\0') |
|
|
1326 | LOG(llevError,"Event (timer) without plugin\n"); |
|
|
1327 | else |
|
|
1328 | insert_event(op,EVENT_TIMER,NULL,yv,NULL); |
|
|
1329 | } |
|
|
1330 | |
|
|
1331 | ^event_timer_options{S} { |
|
|
1332 | char *yv=yval(); |
|
|
1333 | if (*yv=='\0') |
|
|
1334 | LOG(llevError,"Event (timer) without options\n"); |
|
|
1335 | else |
|
|
1336 | insert_event(op,EVENT_TIMER,NULL,NULL,yv); |
|
|
1337 | } |
|
|
1338 | |
|
|
1339 | ^current_weapon_script{S} { char *yv=yval(); |
|
|
1340 | |
|
|
1341 | if (*yv=='\0') LOG(llevError,"Script (current weapon) without val\n"); |
|
|
1342 | else |
|
|
1343 | { |
|
|
1344 | FREE_AND_COPY(op->current_weapon_script, yv); |
|
|
1345 | }; |
|
|
1346 | } |
|
|
1347 | |
1064 | |
1348 | <*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} |
1065 | <*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} |
1349 | #.*\n {} |
1066 | #.*\n {} |
1350 | |
1067 | |
1351 | <<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 */ |
… | |
… | |
1409 | * be reset. |
1126 | * be reset. |
1410 | * 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) |
1411 | * |
1128 | * |
1412 | */ |
1129 | */ |
1413 | |
1130 | |
1414 | 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) { |
1415 | int retval; |
1132 | int retval; |
1416 | char inbuf[MAX_BUF]; |
1133 | char inbuf[MAX_BUF]; |
1417 | |
1134 | |
1418 | strcpy(msgbuf, ""); |
1135 | strcpy(msgbuf, ""); |
1419 | strcpy(lorebuf, ""); |
1136 | strcpy(lorebuf, ""); |
… | |
… | |
1425 | } |
1142 | } |
1426 | if (bufstate==LO_LINEMODE) { |
1143 | if (bufstate==LO_LINEMODE) { |
1427 | YY_BUFFER_STATE yybufstate; |
1144 | YY_BUFFER_STATE yybufstate; |
1428 | while (fgets(inbuf, MAX_BUF-3, fp)) { |
1145 | while (fgets(inbuf, MAX_BUF-3, fp)) { |
1429 | yybufstate=yy_scan_string(inbuf); |
1146 | yybufstate=yy_scan_string(inbuf); |
1430 | retval=lex_load(op, thawer, map_flags); |
1147 | retval=lex_load(op, fp, map_flags); |
1431 | yy_delete_buffer(yybufstate); |
1148 | yy_delete_buffer(yybufstate); |
1432 | if (retval==LL_NORMAL) return retval; |
1149 | if (retval==LL_NORMAL) return retval; |
1433 | } |
1150 | } |
1434 | LOG(llevDebug,"Got eof while scanning strings\n"); |
1151 | LOG(llevDebug,"Got eof while scanning strings\n"); |
1435 | return LL_EOF; |
1152 | return LL_EOF; |
1436 | } |
1153 | } |
1437 | |
1154 | |
1438 | retval=lex_load(op, thawer, map_flags); |
1155 | retval=lex_load(op, fp, map_flags); |
1439 | if (op->current_weapon_script != NULL) |
|
|
1440 | { |
|
|
1441 | op->current_weapon = find_best_weapon_used_match(op, op->current_weapon_script); |
|
|
1442 | LOG(llevDebug, "CurrentWeapon Loaded !\n"); |
|
|
1443 | }; |
|
|
1444 | |
1156 | |
1445 | /* LOG(llevDebug," load completed, object=%s\n",op->name);*/ |
1157 | /* LOG(llevDebug," load completed, object=%s\n",op->name);*/ |
1446 | return retval; |
1158 | return retval; |
1447 | } |
1159 | } |
1448 | |
1160 | |
… | |
… | |
1454 | * override values and in c_wiz to mutate values. |
1166 | * override values and in c_wiz to mutate values. |
1455 | */ |
1167 | */ |
1456 | int set_variable(object *op,char *buf) { |
1168 | int set_variable(object *op,char *buf) { |
1457 | YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; |
1169 | YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; |
1458 | int retval; |
1170 | int retval; |
1459 | object_thawer thawer; |
1171 | object_thawer thawer (0); |
1460 | |
1172 | |
1461 | strcpy(msgbuf, ""); |
1173 | strcpy(msgbuf, ""); |
1462 | strcpy(lorebuf, ""); |
1174 | strcpy(lorebuf, ""); |
1463 | yy_push_state(INITIAL); |
1175 | yy_push_state(INITIAL); |
1464 | yybufstate=yy_scan_string(buf); |
1176 | yybufstate=yy_scan_string(buf); |
… | |
… | |
1525 | /*For get_ob_diff speed reason*/ |
1237 | /*For get_ob_diff speed reason*/ |
1526 | typedef struct { |
1238 | typedef struct { |
1527 | const char *name; |
1239 | const char *name; |
1528 | int length; |
1240 | int length; |
1529 | }genericname; |
1241 | }genericname; |
1530 | static genericname evtnames[13]= |
|
|
1531 | { |
|
|
1532 | {"event_none ",11}, |
|
|
1533 | {"event_apply ",12}, |
|
|
1534 | {"event_attack ",13}, |
|
|
1535 | {"event_death ",12}, |
|
|
1536 | {"event_drop ",11}, |
|
|
1537 | {"event_pickup ",13}, |
|
|
1538 | {"event_say ",10}, |
|
|
1539 | {"event_stop ",11}, |
|
|
1540 | {"event_time ",11}, |
|
|
1541 | {"event_throw ",12}, |
|
|
1542 | {"event_trigger ",14}, |
|
|
1543 | {"event_close ",12}, |
|
|
1544 | {"event_timer ",12} |
|
|
1545 | } ; |
|
|
1546 | |
|
|
1547 | static genericname plgnames[13]= |
|
|
1548 | { |
|
|
1549 | {"event_none_plugin ",18}, |
|
|
1550 | {"event_apply_plugin ",19}, |
|
|
1551 | {"event_attack_plugin ",20}, |
|
|
1552 | {"event_death_plugin ",19}, |
|
|
1553 | {"event_drop_plugin ",18}, |
|
|
1554 | {"event_pickup_plugin ",20}, |
|
|
1555 | {"event_say_plugin ",17}, |
|
|
1556 | {"event_stop_plugin ",18}, |
|
|
1557 | {"event_time_plugin ",18}, |
|
|
1558 | {"event_throw_plugin ",19}, |
|
|
1559 | {"event_trigger_plugin ",21}, |
|
|
1560 | {"event_close_plugin ",19}, |
|
|
1561 | {"event_timer_plugin ",19} |
|
|
1562 | }; |
|
|
1563 | |
|
|
1564 | static genericname plgoptions[13]= |
|
|
1565 | { |
|
|
1566 | {"event_none_options ",19}, |
|
|
1567 | {"event_apply_options ",20}, |
|
|
1568 | {"event_attack_options ",21}, |
|
|
1569 | {"event_death_options ",20}, |
|
|
1570 | {"event_drop_options ",19}, |
|
|
1571 | {"event_pickup_options ",21}, |
|
|
1572 | {"event_say_options ",18}, |
|
|
1573 | {"event_stop_options ",19}, |
|
|
1574 | {"event_time_options ",19}, |
|
|
1575 | {"event_throw_options ",20}, |
|
|
1576 | {"event_trigger_options ",22}, |
|
|
1577 | {"event_close_options ",20}, |
|
|
1578 | {"event_timer_options ",20} |
|
|
1579 | }; |
|
|
1580 | |
1242 | |
1581 | /* This returns a string of the integer movement type */ |
1243 | /* This returns a string of the integer movement type */ |
1582 | static char* get_string_move_type(MoveType mt) |
1244 | static char* get_string_move_type(MoveType mt) |
1583 | { |
1245 | { |
1584 | static char retbuf[MAX_BUF], retbuf_all[MAX_BUF]; |
1246 | static char retbuf[MAX_BUF], retbuf_all[MAX_BUF]; |
… | |
… | |
1739 | op->other_arch->name) { |
1401 | op->other_arch->name) { |
1740 | ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11); |
1402 | ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11); |
1741 | } |
1403 | } |
1742 | if(op->face!=op2->face) { |
1404 | if(op->face!=op2->face) { |
1743 | ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5); |
1405 | ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5); |
1744 | } |
|
|
1745 | |
|
|
1746 | for(etmp=op->events;etmp!=NULL;etmp=etmp->next) |
|
|
1747 | { |
|
|
1748 | /* First we find the event for the reference object */ |
|
|
1749 | etmp2=find_event(op2,etmp->type); |
|
|
1750 | if ((etmp->hook != NULL) && ((etmp2 == NULL) || (etmp2->hook == NULL) || (strcmp(etmp2->hook,etmp->hook)))) |
|
|
1751 | /* Either there's no matching event in the reference object, |
|
|
1752 | * or the hook is different */ |
|
|
1753 | { |
|
|
1754 | ADD_STRINGLINE_ENTRY(fastbuf,evtnames[etmp->type].name,etmp->hook,evtnames[etmp->type].length); |
|
|
1755 | } |
|
|
1756 | if ((etmp->plugin != NULL) && ((etmp2 == NULL) || (etmp2->plugin == NULL) || (strcmp(etmp2->plugin,etmp->plugin)))) |
|
|
1757 | { |
|
|
1758 | |
|
|
1759 | ADD_STRINGLINE_ENTRY(fastbuf,plgnames[etmp->type].name,etmp->plugin,plgnames[etmp->type].length); |
|
|
1760 | } |
|
|
1761 | if ((etmp->options != NULL) && ((etmp2 == NULL) || (etmp2->options == NULL) || (strcmp(etmp2->options,etmp->options)))) |
|
|
1762 | { |
|
|
1763 | ADD_STRINGLINE_ENTRY(fastbuf,plgoptions[etmp->type].name,etmp->options,plgoptions[etmp->type].length); |
|
|
1764 | } |
|
|
1765 | |
|
|
1766 | } |
1406 | } |
1767 | |
1407 | |
1768 | if (op->animation_id != op2->animation_id) { |
1408 | if (op->animation_id != op2->animation_id) { |
1769 | if (op->animation_id) { |
1409 | if (op->animation_id) { |
1770 | ADD_STRINGLINE_ENTRY(fastbuf,"animation ",animations[GET_ANIM_ID(op)].name,10); |
1410 | ADD_STRINGLINE_ENTRY(fastbuf,"animation ",animations[GET_ANIM_ID(op)].name,10); |
… | |
… | |
1921 | if (op->will_apply!=op2->will_apply) |
1561 | if (op->will_apply!=op2->will_apply) |
1922 | FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11); |
1562 | FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11); |
1923 | if(op->smoothlevel!=op2->smoothlevel) |
1563 | if(op->smoothlevel!=op2->smoothlevel) |
1924 | FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12); |
1564 | FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12); |
1925 | |
1565 | |
1926 | if (op->current_weapon_script!=op2->current_weapon_script){ |
|
|
1927 | ADD_STRINGLINE_ENTRY(fastbuf,"current_weapon_script ",op->current_weapon_script,22); |
|
|
1928 | }; |
|
|
1929 | |
|
|
1930 | if(op->weapontype && op->weapontype!=op2->weapontype) { |
1566 | if(op->weapontype && op->weapontype!=op2->weapontype) { |
1931 | FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11); |
1567 | FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11); |
1932 | } |
1568 | } |
1933 | if(op->tooltype && op->tooltype!=op2->tooltype) { |
1569 | if(op->tooltype && op->tooltype!=op2->tooltype) { |
1934 | FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9); |
1570 | FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9); |
… | |
… | |
2037 | * the only place this is not set is when saving the player. |
1673 | * the only place this is not set is when saving the player. |
2038 | * If bit 1 of flag is set, don't remove the object after save. As of now, |
1674 | * If bit 1 of flag is set, don't remove the object after save. As of now, |
2039 | * all of the callers are setting this. |
1675 | * all of the callers are setting this. |
2040 | */ |
1676 | */ |
2041 | |
1677 | |
2042 | void save_object(FILE *fp,object_freezer &freezer,object *op, int flag) { |
1678 | void save_object(object_freezer &fp,object *op, int flag) { |
2043 | archetype *at; |
1679 | archetype *at; |
2044 | char *cp; |
1680 | char *cp; |
2045 | object *tmp,*old; |
1681 | object *tmp,*old; |
2046 | |
1682 | |
2047 | /* Even if the object does have an owner, it would seem that we should |
1683 | /* Even if the object does have an owner, it would seem that we should |
2048 | * still save it. |
1684 | * still save it. |
2049 | */ |
1685 | */ |
2050 | if(op->owner!=NULL || fp == NULL) |
1686 | if(op->owner!=NULL) |
2051 | return; |
1687 | return; |
2052 | |
1688 | |
2053 | /* If it is unpaid and we don't want to save those, just return. */ |
1689 | /* If it is unpaid and we don't want to save those, just return. */ |
2054 | if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) { |
1690 | if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) { |
2055 | return; |
1691 | return; |
… | |
… | |
2065 | |
1701 | |
2066 | old=NULL; |
1702 | old=NULL; |
2067 | |
1703 | |
2068 | if (flag & 2 ) |
1704 | if (flag & 2 ) |
2069 | for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) |
1705 | for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) |
2070 | save_object(fp,freezer,tmp,flag); |
1706 | save_object(fp,tmp,flag); |
2071 | |
1707 | |
2072 | /* Slightly different logic because tmp/op will be removed by |
1708 | /* Slightly different logic because tmp/op will be removed by |
2073 | * the save_object we call. So we just keep looking at op->inv |
1709 | * the save_object we call. So we just keep looking at op->inv |
2074 | * until there is nothing left. In theory, the variable old |
1710 | * until there is nothing left. In theory, the variable old |
2075 | * should not be needed, as recursive loops shouldn't happen. |
1711 | * should not be needed, as recursive loops shouldn't happen. |
… | |
… | |
2077 | else while ((tmp=op->inv)!=NULL) { |
1713 | else while ((tmp=op->inv)!=NULL) { |
2078 | if(old==tmp) { |
1714 | if(old==tmp) { |
2079 | LOG(llevError," Recursive loop in inventory\n"); |
1715 | LOG(llevError," Recursive loop in inventory\n"); |
2080 | break; |
1716 | break; |
2081 | } |
1717 | } |
2082 | save_object(fp,freezer,tmp,flag); |
1718 | save_object(fp,tmp,flag); |
2083 | old=tmp; |
1719 | old=tmp; |
2084 | } |
1720 | } |
2085 | |
1721 | |
2086 | if (!(flag&2)) { |
1722 | if (!(flag&2)) { |
2087 | remove_ob(op); |
1723 | remove_ob(op); |
2088 | free_object (op); |
1724 | free_object (op); |
2089 | } |
1725 | } |
2090 | |
1726 | |
2091 | freezer.put (fp, op); |
1727 | fp.put (op); |
2092 | fprintf(fp,"end\n"); |
1728 | fprintf(fp,"end\n"); |
2093 | } |
|
|
2094 | |
|
|
2095 | void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions) |
|
|
2096 | { |
|
|
2097 | event *evt; |
|
|
2098 | event *tmp; |
|
|
2099 | |
|
|
2100 | evt = find_event(op,etype); |
|
|
2101 | if (evt == NULL) |
|
|
2102 | { |
|
|
2103 | evt = (event *)malloc(sizeof(event)); |
|
|
2104 | evt->next = NULL; |
|
|
2105 | evt->type = etype; |
|
|
2106 | evt->hook = NULL; |
|
|
2107 | evt->plugin = NULL; |
|
|
2108 | evt->options = NULL; |
|
|
2109 | if (op->events==NULL) |
|
|
2110 | { |
|
|
2111 | op->events=evt; |
|
|
2112 | } |
|
|
2113 | else |
|
|
2114 | { |
|
|
2115 | for(tmp=op->events;;tmp=tmp->next) |
|
|
2116 | { |
|
|
2117 | if (tmp->next == NULL) |
|
|
2118 | { |
|
|
2119 | tmp->next = evt; |
|
|
2120 | break; |
|
|
2121 | } |
|
|
2122 | } |
|
|
2123 | } |
|
|
2124 | } |
|
|
2125 | if (ehook != NULL) |
|
|
2126 | FREE_AND_COPY(evt->hook,ehook); |
|
|
2127 | if (eplug != NULL) |
|
|
2128 | FREE_AND_COPY(evt->plugin,eplug); |
|
|
2129 | if (eoptions != NULL) |
|
|
2130 | FREE_AND_COPY(evt->options,eoptions); |
|
|
2131 | } |
1729 | } |
2132 | |
1730 | |
2133 | event* find_event(object* op, int etype) |
1731 | event* find_event(object* op, int etype) |
2134 | { |
1732 | { |
2135 | event *found; |
1733 | event *found; |