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.8 by root, Sat Aug 26 08:44:04 2006 UTC vs.
Revision 1.17 by root, Thu Aug 31 09:19:33 2006 UTC

1%{ 1%{
2/* 2/*
3 * static char *rcsid_object_c = 3 * static char *rcsid_object_c =
4 * "$Id: loader.l,v 1.8 2006/08/26 08:44:04 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
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[65536]; 45static char msgbuf[65536];
716 */ 716 */
717 if (op->arch) { 717 if (op->arch) {
718 object *tmp; 718 object *tmp;
719 char *yv=yval(); 719 char *yv=yval();
720 720
721 tmp=get_object();
722 tmp->arch = find_archetype(yv); 721 archetype *arch = find_archetype(yv);
723 if (tmp->arch!=NULL) 722 if (arch!=NULL)
724 copy_object(&tmp->arch->clone,tmp); 723 tmp = arch_to_object (arch);
725 else { 724 else {
725 tmp = get_object ();
726 if (tmp->name) free_string(tmp->name); 726 if (tmp->name) free_string(tmp->name);
727 /* record the name of the broken object */ 727 /* record the name of the broken object */
728 tmp->name = add_string(yv); 728 tmp->name = add_string(yv);
729 } 729 }
730 strcpy(msgbuf, ""); 730 strcpy(msgbuf, "");
731 strcpy(lorebuf, ""); 731 strcpy(lorebuf, "");
732 lex_load(tmp, map_flags); 732 lex_load(tmp, thawer, map_flags);
733 if (tmp->arch) { 733 if (tmp->arch) {
734 insert_ob_in_ob(tmp,op); 734 insert_ob_in_ob(tmp,op);
735 } 735 }
736 else { 736 else {
737 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)");
741 /* This is the actual archetype definition then */ 741 /* This is the actual archetype definition then */
742 else { 742 else {
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) copy_object(&op->arch->clone,op); 746 if (op->arch!=NULL) {
747 else if (!arch_init) { 747 copy_object(&op->arch->clone,op);
748 } else if (!arch_init) {
748 if (op->name) free_string(op->name); 749 if (op->name) free_string(op->name);
749 /* record the name of the broken object */ 750 /* record the name of the broken object */
750 op->name = add_string(yv); 751 op->name = add_string(yv);
751 } 752 }
752 } 753 }
766^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,
767 * so the calling function can glue things back together 768 * so the calling function can glue things back together
768 */ 769 */
769 ismore=1; 770 ismore=1;
770 } 771 }
771
772^end{WS}$ { check_loaded_object(op); 772^end{WS}$ { check_loaded_object(op);
773
774 if (!arch_init)
775 op->instantiate ();
776
773 if (ismore) return LL_MORE; 777 if (ismore) return LL_MORE;
774 else return LL_NORMAL; 778 else return LL_NORMAL;
775 } 779 }
780^oid{S} {
781 thawer.get (op, IVAL);
782 }
776^last_heal{S} op->last_heal = IVAL; 783^last_heal{S} op->last_heal = IVAL;
777^last_sp{S} op->last_sp = IVAL; 784^last_sp{S} op->last_sp = IVAL;
778^last_grace{S} op->last_grace = IVAL; 785^last_grace{S} op->last_grace = IVAL;
779^last_eat{S} op->last_eat = IVAL; 786^last_eat{S} op->last_eat = IVAL;
780^speed{S} { op->speed = FVAL; 787^speed{S} { op->speed = FVAL;
1049^range_modifier{S} op->range_modifier = IVAL; 1056^range_modifier{S} op->range_modifier = IVAL;
1050^dam_modifier{S} op->dam_modifier = IVAL; 1057^dam_modifier{S} op->dam_modifier = IVAL;
1051^duration_modifier{S} op->duration_modifier = IVAL; 1058^duration_modifier{S} op->duration_modifier = IVAL;
1052^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 );
1053 1060
1054^event_apply{S} { 1061^event_ {
1055 char *yv=yval(); 1062 LOG (llevError, "stray event_* in map file, skipping.");
1056 if (*yv=='\0')
1057 LOG(llevError,"Event (apply) without val\n");
1058 else
1059 insert_event(op,EVENT_APPLY,yv,NULL,NULL);
1060} 1063}
1061
1062^event_apply_plugin{S} {
1063 char *yv=yval();
1064 if (*yv=='\0')
1065 LOG(llevError,"Event (apply) without plugin\n");
1066 else
1067 insert_event(op,EVENT_APPLY,NULL,yv,NULL);
1068}
1069
1070^event_apply_options{S} {
1071 char *yv=yval();
1072 if (*yv=='\0')
1073 LOG(llevError,"Event (apply) without options\n");
1074 else
1075 insert_event(op,EVENT_APPLY,NULL,NULL,yv);
1076}
1077
1078^event_attack{S} {
1079 char *yv=yval();
1080 if (*yv=='\0')
1081 LOG(llevError,"Event (attack) without val\n");
1082 else
1083 insert_event(op,EVENT_ATTACK,yv,NULL,NULL);
1084}
1085
1086^event_attack_plugin{S} {
1087 char *yv=yval();
1088 if (*yv=='\0')
1089 LOG(llevError,"Event (attack) without plugin\n");
1090 else
1091 insert_event(op,EVENT_ATTACK,NULL,yv,NULL);
1092}
1093
1094^event_attack_options{S} {
1095 char *yv=yval();
1096 if (*yv=='\0')
1097 LOG(llevError,"Event (attack) without options\n");
1098 else
1099 insert_event(op,EVENT_ATTACK,NULL,NULL,yv);
1100}
1101^event_death{S} {
1102 char *yv=yval();
1103 if (*yv=='\0')
1104 LOG(llevError,"Event (death) without val\n");
1105 else
1106 insert_event(op,EVENT_DEATH,yv,NULL,NULL);
1107}
1108
1109^event_death_plugin{S} {
1110 char *yv=yval();
1111 if (*yv=='\0')
1112 LOG(llevError,"Event (death) without plugin\n");
1113 else
1114 insert_event(op,EVENT_DEATH,NULL,yv,NULL);
1115}
1116
1117^event_death_options{S} {
1118 char *yv=yval();
1119 if (*yv=='\0')
1120 LOG(llevError,"Event (death) without options\n");
1121 else
1122 insert_event(op,EVENT_DEATH,NULL,NULL,yv);
1123}
1124^event_drop{S} {
1125 char *yv=yval();
1126 if (*yv=='\0')
1127 LOG(llevError,"Event (drop) without val\n");
1128 else
1129 insert_event(op,EVENT_DROP,yv,NULL,NULL);
1130}
1131
1132^event_drop_plugin{S} {
1133 char *yv=yval();
1134 if (*yv=='\0')
1135 LOG(llevError,"Event (drop) without plugin\n");
1136 else
1137 insert_event(op,EVENT_DROP,NULL,yv,NULL);
1138}
1139
1140^event_drop_options{S} {
1141 char *yv=yval();
1142 if (*yv=='\0')
1143 LOG(llevError,"Event (drop) without options\n");
1144 else
1145 insert_event(op,EVENT_DROP,NULL,NULL,yv);
1146}
1147^event_pickup{S} {
1148 char *yv=yval();
1149 if (*yv=='\0')
1150 LOG(llevError,"Event (pickup) without val\n");
1151 else
1152 insert_event(op,EVENT_PICKUP,yv,NULL,NULL);
1153}
1154
1155^event_pickup_plugin{S} {
1156 char *yv=yval();
1157 if (*yv=='\0')
1158 LOG(llevError,"Event (pickup) without plugin\n");
1159 else
1160 insert_event(op,EVENT_PICKUP,NULL,yv,NULL);
1161}
1162
1163^event_pickup_options{S} {
1164 char *yv=yval();
1165 if (*yv=='\0')
1166 LOG(llevError,"Event (pickup) without options\n");
1167 else
1168 insert_event(op,EVENT_PICKUP,NULL,NULL,yv);
1169}
1170^event_say{S} {
1171 char *yv=yval();
1172 if (*yv=='\0')
1173 LOG(llevError,"Event (say) without val\n");
1174 else
1175 insert_event(op,EVENT_SAY,yv,NULL,NULL);
1176}
1177
1178^event_say_plugin{S} {
1179 char *yv=yval();
1180 if (*yv=='\0')
1181 LOG(llevError,"Event (say) without plugin\n");
1182 else
1183 insert_event(op,EVENT_SAY,NULL,yv,NULL);
1184}
1185
1186^event_say_options{S} {
1187 char *yv=yval();
1188 if (*yv=='\0')
1189 LOG(llevError,"Event (say) without options\n");
1190 else
1191 insert_event(op,EVENT_SAY,NULL,NULL,yv);
1192}
1193^event_stop{S} {
1194 char *yv=yval();
1195 if (*yv=='\0')
1196 LOG(llevError,"Event (stop) without val\n");
1197 else
1198 insert_event(op,EVENT_STOP,yv,NULL,NULL);
1199}
1200
1201^event_stop_plugin{S} {
1202 char *yv=yval();
1203 if (*yv=='\0')
1204 LOG(llevError,"Event (stop) without plugin\n");
1205 else
1206 insert_event(op,EVENT_STOP,NULL,yv,NULL);
1207}
1208
1209^event_stop_options{S} {
1210 char *yv=yval();
1211 if (*yv=='\0')
1212 LOG(llevError,"Event (stop) without options\n");
1213 else
1214 insert_event(op,EVENT_STOP,NULL,NULL,yv);
1215}
1216^event_time{S} {
1217 char *yv=yval();
1218 if (*yv=='\0')
1219 LOG(llevError,"Event (time) without val\n");
1220 else
1221 insert_event(op,EVENT_TIME,yv,NULL,NULL);
1222}
1223
1224^event_time_plugin{S} {
1225 char *yv=yval();
1226 if (*yv=='\0')
1227 LOG(llevError,"Event (time) without plugin\n");
1228 else
1229 insert_event(op,EVENT_TIME,NULL,yv,NULL);
1230}
1231
1232^event_time_options{S} {
1233 char *yv=yval();
1234 if (*yv=='\0')
1235 LOG(llevError,"Event (time) without options\n");
1236 else
1237 insert_event(op,EVENT_TIME,NULL,NULL,yv);
1238}
1239^event_throw{S} {
1240 char *yv=yval();
1241 if (*yv=='\0')
1242 LOG(llevError,"Event (throw) without val\n");
1243 else
1244 insert_event(op,EVENT_THROW,yv,NULL,NULL);
1245}
1246
1247^event_throw_plugin{S} {
1248 char *yv=yval();
1249 if (*yv=='\0')
1250 LOG(llevError,"Event (throw) without plugin\n");
1251 else
1252 insert_event(op,EVENT_THROW,NULL,yv,NULL);
1253}
1254
1255^event_throw_options{S} {
1256 char *yv=yval();
1257 if (*yv=='\0')
1258 LOG(llevError,"Event (apply) without options\n");
1259 else
1260 insert_event(op,EVENT_THROW,NULL,NULL,yv);
1261}
1262^event_trigger{S} {
1263 char *yv=yval();
1264 if (*yv=='\0')
1265 LOG(llevError,"Event (trigger) without val\n");
1266 else
1267 insert_event(op,EVENT_TRIGGER,yv,NULL,NULL);
1268}
1269
1270^event_trigger_plugin{S} {
1271 char *yv=yval();
1272 if (*yv=='\0')
1273 LOG(llevError,"Event (trigger) without plugin\n");
1274 else
1275 insert_event(op,EVENT_TRIGGER,NULL,yv,NULL);
1276}
1277
1278^event_trigger_options{S} {
1279 char *yv=yval();
1280 if (*yv=='\0')
1281 LOG(llevError,"Event (trigger) without options\n");
1282 else
1283 insert_event(op,EVENT_TRIGGER,NULL,NULL,yv);
1284}
1285^event_close{S} {
1286 char *yv=yval();
1287 if (*yv=='\0')
1288 LOG(llevError,"Event (close) without val\n");
1289 else
1290 insert_event(op,EVENT_CLOSE,yv,NULL,NULL);
1291}
1292
1293^event_close_plugin{S} {
1294 char *yv=yval();
1295 if (*yv=='\0')
1296 LOG(llevError,"Event (close) without plugin\n");
1297 else
1298 insert_event(op,EVENT_CLOSE,NULL,yv,NULL);
1299}
1300
1301^event_close_options{S} {
1302 char *yv=yval();
1303 if (*yv=='\0')
1304 LOG(llevError,"Event (close) without options\n");
1305 else
1306 insert_event(op,EVENT_CLOSE,NULL,NULL,yv);
1307}
1308^event_timer{S} {
1309 char *yv=yval();
1310 if (*yv=='\0')
1311 LOG(llevError,"Event (timer) without val\n");
1312 else
1313 insert_event(op,EVENT_TIMER,yv,NULL,NULL);
1314}
1315
1316^event_timer_plugin{S} {
1317 char *yv=yval();
1318 if (*yv=='\0')
1319 LOG(llevError,"Event (timer) without plugin\n");
1320 else
1321 insert_event(op,EVENT_TIMER,NULL,yv,NULL);
1322}
1323
1324^event_timer_options{S} {
1325 char *yv=yval();
1326 if (*yv=='\0')
1327 LOG(llevError,"Event (timer) without options\n");
1328 else
1329 insert_event(op,EVENT_TIMER,NULL,NULL,yv);
1330}
1331
1332^current_weapon_script{S} { char *yv=yval();
1333
1334 if (*yv=='\0') LOG(llevError,"Script (current weapon) without val\n");
1335 else
1336 {
1337 FREE_AND_COPY(op->current_weapon_script, yv);
1338 };
1339 }
1340 1064
1341<*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} 1065<*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */}
1342#.*\n {} 1066#.*\n {}
1343 1067
1344<<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 */
1402 * be reset. 1126 * be reset.
1403 * 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)
1404 * 1128 *
1405 */ 1129 */
1406 1130
1407int load_object(FILE *fp, object *op, int bufstate, int map_flags) { 1131int load_object(object_thawer &fp, object *op, int bufstate, int map_flags) {
1408 int retval; 1132 int retval;
1409 char inbuf[MAX_BUF]; 1133 char inbuf[MAX_BUF];
1410 1134
1411 strcpy(msgbuf, ""); 1135 strcpy(msgbuf, "");
1412 strcpy(lorebuf, ""); 1136 strcpy(lorebuf, "");
1418 } 1142 }
1419 if (bufstate==LO_LINEMODE) { 1143 if (bufstate==LO_LINEMODE) {
1420 YY_BUFFER_STATE yybufstate; 1144 YY_BUFFER_STATE yybufstate;
1421 while (fgets(inbuf, MAX_BUF-3, fp)) { 1145 while (fgets(inbuf, MAX_BUF-3, fp)) {
1422 yybufstate=yy_scan_string(inbuf); 1146 yybufstate=yy_scan_string(inbuf);
1423 retval=lex_load(op, map_flags); 1147 retval=lex_load(op, fp, map_flags);
1424 yy_delete_buffer(yybufstate); 1148 yy_delete_buffer(yybufstate);
1425 if (retval==LL_NORMAL) return retval; 1149 if (retval==LL_NORMAL) return retval;
1426 } 1150 }
1427 LOG(llevDebug,"Got eof while scanning strings\n"); 1151 LOG(llevDebug,"Got eof while scanning strings\n");
1428 return LL_EOF; 1152 return LL_EOF;
1429 } 1153 }
1430 1154
1431 retval=lex_load(op, map_flags); 1155 retval=lex_load(op, fp, map_flags);
1432 if (op->current_weapon_script != NULL)
1433 {
1434 op->current_weapon = find_best_weapon_used_match(op, op->current_weapon_script);
1435 LOG(llevDebug, "CurrentWeapon Loaded !\n");
1436 };
1437 1156
1438/* LOG(llevDebug," load completed, object=%s\n",op->name);*/ 1157/* LOG(llevDebug," load completed, object=%s\n",op->name);*/
1439 return retval; 1158 return retval;
1440} 1159}
1441 1160
1447 * override values and in c_wiz to mutate values. 1166 * override values and in c_wiz to mutate values.
1448 */ 1167 */
1449int set_variable(object *op,char *buf) { 1168int set_variable(object *op,char *buf) {
1450 YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; 1169 YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER;
1451 int retval; 1170 int retval;
1171 object_thawer thawer (0);
1452 1172
1453 strcpy(msgbuf, ""); 1173 strcpy(msgbuf, "");
1454 strcpy(lorebuf, ""); 1174 strcpy(lorebuf, "");
1455 yy_push_state(INITIAL); 1175 yy_push_state(INITIAL);
1456 yybufstate=yy_scan_string(buf); 1176 yybufstate=yy_scan_string(buf);
1457 retval=lex_load(op,0); 1177 retval=lex_load(op,thawer,0);
1458 yy_switch_to_buffer(yycurbuf); 1178 yy_switch_to_buffer(yycurbuf);
1459 yy_delete_buffer(yybufstate); 1179 yy_delete_buffer(yybufstate);
1460 yy_pop_state(); 1180 yy_pop_state();
1461 return retval; 1181 return retval;
1462} 1182}
1517/*For get_ob_diff speed reason*/ 1237/*For get_ob_diff speed reason*/
1518typedef struct { 1238typedef struct {
1519 const char *name; 1239 const char *name;
1520 int length; 1240 int length;
1521}genericname; 1241}genericname;
1522static genericname evtnames[13]=
1523{
1524 {"event_none ",11},
1525 {"event_apply ",12},
1526 {"event_attack ",13},
1527 {"event_death ",12},
1528 {"event_drop ",11},
1529 {"event_pickup ",13},
1530 {"event_say ",10},
1531 {"event_stop ",11},
1532 {"event_time ",11},
1533 {"event_throw ",12},
1534 {"event_trigger ",14},
1535 {"event_close ",12},
1536 {"event_timer ",12}
1537} ;
1538
1539static genericname plgnames[13]=
1540{
1541 {"event_none_plugin ",18},
1542 {"event_apply_plugin ",19},
1543 {"event_attack_plugin ",20},
1544 {"event_death_plugin ",19},
1545 {"event_drop_plugin ",18},
1546 {"event_pickup_plugin ",20},
1547 {"event_say_plugin ",17},
1548 {"event_stop_plugin ",18},
1549 {"event_time_plugin ",18},
1550 {"event_throw_plugin ",19},
1551 {"event_trigger_plugin ",21},
1552 {"event_close_plugin ",19},
1553 {"event_timer_plugin ",19}
1554};
1555
1556static genericname plgoptions[13]=
1557{
1558 {"event_none_options ",19},
1559 {"event_apply_options ",20},
1560 {"event_attack_options ",21},
1561 {"event_death_options ",20},
1562 {"event_drop_options ",19},
1563 {"event_pickup_options ",21},
1564 {"event_say_options ",18},
1565 {"event_stop_options ",19},
1566 {"event_time_options ",19},
1567 {"event_throw_options ",20},
1568 {"event_trigger_options ",22},
1569 {"event_close_options ",20},
1570 {"event_timer_options ",20}
1571};
1572 1242
1573/* This returns a string of the integer movement type */ 1243/* This returns a string of the integer movement type */
1574static char* get_string_move_type(MoveType mt) 1244static char* get_string_move_type(MoveType mt)
1575{ 1245{
1576 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF]; 1246 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF];
1731 op->other_arch->name) { 1401 op->other_arch->name) {
1732 ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11); 1402 ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11);
1733 } 1403 }
1734 if(op->face!=op2->face) { 1404 if(op->face!=op2->face) {
1735 ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5); 1405 ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5);
1736 }
1737
1738 for(etmp=op->events;etmp!=NULL;etmp=etmp->next)
1739 {
1740 /* First we find the event for the reference object */
1741 etmp2=find_event(op2,etmp->type);
1742 if ((etmp->hook != NULL) && ((etmp2 == NULL) || (etmp2->hook == NULL) || (strcmp(etmp2->hook,etmp->hook))))
1743 /* Either there's no matching event in the reference object,
1744 * or the hook is different */
1745 {
1746 ADD_STRINGLINE_ENTRY(fastbuf,evtnames[etmp->type].name,etmp->hook,evtnames[etmp->type].length);
1747 }
1748 if ((etmp->plugin != NULL) && ((etmp2 == NULL) || (etmp2->plugin == NULL) || (strcmp(etmp2->plugin,etmp->plugin))))
1749 {
1750
1751 ADD_STRINGLINE_ENTRY(fastbuf,plgnames[etmp->type].name,etmp->plugin,plgnames[etmp->type].length);
1752 }
1753 if ((etmp->options != NULL) && ((etmp2 == NULL) || (etmp2->options == NULL) || (strcmp(etmp2->options,etmp->options))))
1754 {
1755 ADD_STRINGLINE_ENTRY(fastbuf,plgoptions[etmp->type].name,etmp->options,plgoptions[etmp->type].length);
1756 }
1757
1758 } 1406 }
1759 1407
1760 if (op->animation_id != op2->animation_id) { 1408 if (op->animation_id != op2->animation_id) {
1761 if (op->animation_id) { 1409 if (op->animation_id) {
1762 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);
1913 if (op->will_apply!=op2->will_apply) 1561 if (op->will_apply!=op2->will_apply)
1914 FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11); 1562 FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11);
1915 if(op->smoothlevel!=op2->smoothlevel) 1563 if(op->smoothlevel!=op2->smoothlevel)
1916 FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12); 1564 FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12);
1917 1565
1918 if (op->current_weapon_script!=op2->current_weapon_script){
1919 ADD_STRINGLINE_ENTRY(fastbuf,"current_weapon_script ",op->current_weapon_script,22);
1920 };
1921
1922 if(op->weapontype && op->weapontype!=op2->weapontype) { 1566 if(op->weapontype && op->weapontype!=op2->weapontype) {
1923 FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11); 1567 FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11);
1924 } 1568 }
1925 if(op->tooltype && op->tooltype!=op2->tooltype) { 1569 if(op->tooltype && op->tooltype!=op2->tooltype) {
1926 FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9); 1570 FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9);
2029 * 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.
2030 * 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,
2031 * all of the callers are setting this. 1675 * all of the callers are setting this.
2032 */ 1676 */
2033 1677
2034void save_object(FILE *fp,object *op, int flag) { 1678void save_object(object_freezer &fp,object *op, int flag) {
2035 archetype *at; 1679 archetype *at;
2036 char *cp; 1680 char *cp;
2037 object *tmp,*old; 1681 object *tmp,*old;
2038 1682
2039 /* 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
2040 * still save it. 1684 * still save it.
2041 */ 1685 */
2042 if(op->owner!=NULL || fp == NULL) 1686 if(op->owner!=NULL)
2043 return; 1687 return;
2044 1688
2045 /* 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. */
2046 if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) { 1690 if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) {
2047 return; 1691 return;
2078 if (!(flag&2)) { 1722 if (!(flag&2)) {
2079 remove_ob(op); 1723 remove_ob(op);
2080 free_object (op); 1724 free_object (op);
2081 } 1725 }
2082 1726
1727 fp.put (op);
2083 fprintf(fp,"end\n"); 1728 fprintf(fp,"end\n");
2084}
2085
2086void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions)
2087{
2088 event *evt;
2089 event *tmp;
2090
2091 evt = find_event(op,etype);
2092 if (evt == NULL)
2093 {
2094 evt = (event *)malloc(sizeof(event));
2095 evt->next = NULL;
2096 evt->type = etype;
2097 evt->hook = NULL;
2098 evt->plugin = NULL;
2099 evt->options = NULL;
2100 if (op->events==NULL)
2101 {
2102 op->events=evt;
2103 }
2104 else
2105 {
2106 for(tmp=op->events;;tmp=tmp->next)
2107 {
2108 if (tmp->next == NULL)
2109 {
2110 tmp->next = evt;
2111 break;
2112 }
2113 }
2114 }
2115 }
2116 if (ehook != NULL)
2117 FREE_AND_COPY(evt->hook,ehook);
2118 if (eplug != NULL)
2119 FREE_AND_COPY(evt->plugin,eplug);
2120 if (eoptions != NULL)
2121 FREE_AND_COPY(evt->options,eoptions);
2122} 1729}
2123 1730
2124event* find_event(object* op, int etype) 1731event* find_event(object* op, int etype)
2125{ 1732{
2126 event *found; 1733 event *found;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines