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.10 by root, Sun Aug 27 16:15:11 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.10 2006/08/27 16:15:11 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
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
1410int load_object(FILE *fp, object_thawer &thawer, object *op, int bufstate, int map_flags) { 1131int 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 */
1452int set_variable(object *op,char *buf) { 1168int 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);
1521/*For get_ob_diff speed reason*/ 1237/*For get_ob_diff speed reason*/
1522typedef struct { 1238typedef struct {
1523 const char *name; 1239 const char *name;
1524 int length; 1240 int length;
1525}genericname; 1241}genericname;
1526static genericname evtnames[13]=
1527{
1528 {"event_none ",11},
1529 {"event_apply ",12},
1530 {"event_attack ",13},
1531 {"event_death ",12},
1532 {"event_drop ",11},
1533 {"event_pickup ",13},
1534 {"event_say ",10},
1535 {"event_stop ",11},
1536 {"event_time ",11},
1537 {"event_throw ",12},
1538 {"event_trigger ",14},
1539 {"event_close ",12},
1540 {"event_timer ",12}
1541} ;
1542
1543static genericname plgnames[13]=
1544{
1545 {"event_none_plugin ",18},
1546 {"event_apply_plugin ",19},
1547 {"event_attack_plugin ",20},
1548 {"event_death_plugin ",19},
1549 {"event_drop_plugin ",18},
1550 {"event_pickup_plugin ",20},
1551 {"event_say_plugin ",17},
1552 {"event_stop_plugin ",18},
1553 {"event_time_plugin ",18},
1554 {"event_throw_plugin ",19},
1555 {"event_trigger_plugin ",21},
1556 {"event_close_plugin ",19},
1557 {"event_timer_plugin ",19}
1558};
1559
1560static genericname plgoptions[13]=
1561{
1562 {"event_none_options ",19},
1563 {"event_apply_options ",20},
1564 {"event_attack_options ",21},
1565 {"event_death_options ",20},
1566 {"event_drop_options ",19},
1567 {"event_pickup_options ",21},
1568 {"event_say_options ",18},
1569 {"event_stop_options ",19},
1570 {"event_time_options ",19},
1571 {"event_throw_options ",20},
1572 {"event_trigger_options ",22},
1573 {"event_close_options ",20},
1574 {"event_timer_options ",20}
1575};
1576 1242
1577/* This returns a string of the integer movement type */ 1243/* This returns a string of the integer movement type */
1578static char* get_string_move_type(MoveType mt) 1244static char* get_string_move_type(MoveType mt)
1579{ 1245{
1580 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF]; 1246 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF];
1735 op->other_arch->name) { 1401 op->other_arch->name) {
1736 ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11); 1402 ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11);
1737 } 1403 }
1738 if(op->face!=op2->face) { 1404 if(op->face!=op2->face) {
1739 ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5); 1405 ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5);
1740 }
1741
1742 for(etmp=op->events;etmp!=NULL;etmp=etmp->next)
1743 {
1744 /* First we find the event for the reference object */
1745 etmp2=find_event(op2,etmp->type);
1746 if ((etmp->hook != NULL) && ((etmp2 == NULL) || (etmp2->hook == NULL) || (strcmp(etmp2->hook,etmp->hook))))
1747 /* Either there's no matching event in the reference object,
1748 * or the hook is different */
1749 {
1750 ADD_STRINGLINE_ENTRY(fastbuf,evtnames[etmp->type].name,etmp->hook,evtnames[etmp->type].length);
1751 }
1752 if ((etmp->plugin != NULL) && ((etmp2 == NULL) || (etmp2->plugin == NULL) || (strcmp(etmp2->plugin,etmp->plugin))))
1753 {
1754
1755 ADD_STRINGLINE_ENTRY(fastbuf,plgnames[etmp->type].name,etmp->plugin,plgnames[etmp->type].length);
1756 }
1757 if ((etmp->options != NULL) && ((etmp2 == NULL) || (etmp2->options == NULL) || (strcmp(etmp2->options,etmp->options))))
1758 {
1759 ADD_STRINGLINE_ENTRY(fastbuf,plgoptions[etmp->type].name,etmp->options,plgoptions[etmp->type].length);
1760 }
1761
1762 } 1406 }
1763 1407
1764 if (op->animation_id != op2->animation_id) { 1408 if (op->animation_id != op2->animation_id) {
1765 if (op->animation_id) { 1409 if (op->animation_id) {
1766 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);
1917 if (op->will_apply!=op2->will_apply) 1561 if (op->will_apply!=op2->will_apply)
1918 FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11); 1562 FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11);
1919 if(op->smoothlevel!=op2->smoothlevel) 1563 if(op->smoothlevel!=op2->smoothlevel)
1920 FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12); 1564 FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12);
1921 1565
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) { 1566 if(op->weapontype && op->weapontype!=op2->weapontype) {
1927 FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11); 1567 FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11);
1928 } 1568 }
1929 if(op->tooltype && op->tooltype!=op2->tooltype) { 1569 if(op->tooltype && op->tooltype!=op2->tooltype) {
1930 FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9); 1570 FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9);
2033 * 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.
2034 * 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,
2035 * all of the callers are setting this. 1675 * all of the callers are setting this.
2036 */ 1676 */
2037 1677
2038void save_object(FILE *fp,object_freezer &freezer,object *op, int flag) { 1678void save_object(object_freezer &fp,object *op, int flag) {
2039 archetype *at; 1679 archetype *at;
2040 char *cp; 1680 char *cp;
2041 object *tmp,*old; 1681 object *tmp,*old;
2042 1682
2043 /* 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
2044 * still save it. 1684 * still save it.
2045 */ 1685 */
2046 if(op->owner!=NULL || fp == NULL) 1686 if(op->owner!=NULL)
2047 return; 1687 return;
2048 1688
2049 /* 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. */
2050 if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) { 1690 if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) {
2051 return; 1691 return;
2061 1701
2062 old=NULL; 1702 old=NULL;
2063 1703
2064 if (flag & 2 ) 1704 if (flag & 2 )
2065 for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) 1705 for(tmp=op->inv;tmp!=NULL;tmp=tmp->below)
2066 save_object(fp,freezer,tmp,flag); 1706 save_object(fp,tmp,flag);
2067 1707
2068 /* Slightly different logic because tmp/op will be removed by 1708 /* Slightly different logic because tmp/op will be removed by
2069 * 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
2070 * until there is nothing left. In theory, the variable old 1710 * until there is nothing left. In theory, the variable old
2071 * should not be needed, as recursive loops shouldn't happen. 1711 * should not be needed, as recursive loops shouldn't happen.
2073 else while ((tmp=op->inv)!=NULL) { 1713 else while ((tmp=op->inv)!=NULL) {
2074 if(old==tmp) { 1714 if(old==tmp) {
2075 LOG(llevError," Recursive loop in inventory\n"); 1715 LOG(llevError," Recursive loop in inventory\n");
2076 break; 1716 break;
2077 } 1717 }
2078 save_object(fp,freezer,tmp,flag); 1718 save_object(fp,tmp,flag);
2079 old=tmp; 1719 old=tmp;
2080 } 1720 }
2081 1721
2082 if (!(flag&2)) { 1722 if (!(flag&2)) {
2083 remove_ob(op); 1723 remove_ob(op);
2084 free_object (op); 1724 free_object (op);
2085 } 1725 }
2086 1726
1727 fp.put (op);
2087 fprintf(fp,"end\n"); 1728 fprintf(fp,"end\n");
2088 freezer.put (op);
2089}
2090
2091void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions)
2092{
2093 event *evt;
2094 event *tmp;
2095
2096 evt = find_event(op,etype);
2097 if (evt == NULL)
2098 {
2099 evt = (event *)malloc(sizeof(event));
2100 evt->next = NULL;
2101 evt->type = etype;
2102 evt->hook = NULL;
2103 evt->plugin = NULL;
2104 evt->options = NULL;
2105 if (op->events==NULL)
2106 {
2107 op->events=evt;
2108 }
2109 else
2110 {
2111 for(tmp=op->events;;tmp=tmp->next)
2112 {
2113 if (tmp->next == NULL)
2114 {
2115 tmp->next = evt;
2116 break;
2117 }
2118 }
2119 }
2120 }
2121 if (ehook != NULL)
2122 FREE_AND_COPY(evt->hook,ehook);
2123 if (eplug != NULL)
2124 FREE_AND_COPY(evt->plugin,eplug);
2125 if (eoptions != NULL)
2126 FREE_AND_COPY(evt->options,eoptions);
2127} 1729}
2128 1730
2129event* find_event(object* op, int etype) 1731event* find_event(object* op, int etype)
2130{ 1732{
2131 event *found; 1733 event *found;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines