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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines