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.14 by root, Tue Aug 29 05:03:54 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.14 2006/08/29 05:03:54 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
1060 1060
1061^event_ { 1061^event_ {
1062 LOG (llevError, "stray event_* in map file, skipping."); 1062 LOG (llevError, "stray event_* in map file, skipping.");
1063} 1063}
1064 1064
1065^current_weapon_script{S} { LOG (llevError, "stray current_weapon_script in map file, skipping."); }
1066
1067<*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} 1065<*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */}
1068#.*\n {} 1066#.*\n {}
1069 1067
1070<<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 */
1071 if (lex_error!=0) return lex_error; else return LL_EOF;} 1069 if (lex_error!=0) return lex_error; else return LL_EOF;}
1239/*For get_ob_diff speed reason*/ 1237/*For get_ob_diff speed reason*/
1240typedef struct { 1238typedef struct {
1241 const char *name; 1239 const char *name;
1242 int length; 1240 int length;
1243}genericname; 1241}genericname;
1244static genericname evtnames[13]=
1245{
1246 {"event_none ",11},
1247 {"event_apply ",12},
1248 {"event_attack ",13},
1249 {"event_death ",12},
1250 {"event_drop ",11},
1251 {"event_pickup ",13},
1252 {"event_say ",10},
1253 {"event_stop ",11},
1254 {"event_time ",11},
1255 {"event_throw ",12},
1256 {"event_trigger ",14},
1257 {"event_close ",12},
1258 {"event_timer ",12}
1259} ;
1260
1261static genericname plgnames[13]=
1262{
1263 {"event_none_plugin ",18},
1264 {"event_apply_plugin ",19},
1265 {"event_attack_plugin ",20},
1266 {"event_death_plugin ",19},
1267 {"event_drop_plugin ",18},
1268 {"event_pickup_plugin ",20},
1269 {"event_say_plugin ",17},
1270 {"event_stop_plugin ",18},
1271 {"event_time_plugin ",18},
1272 {"event_throw_plugin ",19},
1273 {"event_trigger_plugin ",21},
1274 {"event_close_plugin ",19},
1275 {"event_timer_plugin ",19}
1276};
1277
1278static genericname plgoptions[13]=
1279{
1280 {"event_none_options ",19},
1281 {"event_apply_options ",20},
1282 {"event_attack_options ",21},
1283 {"event_death_options ",20},
1284 {"event_drop_options ",19},
1285 {"event_pickup_options ",21},
1286 {"event_say_options ",18},
1287 {"event_stop_options ",19},
1288 {"event_time_options ",19},
1289 {"event_throw_options ",20},
1290 {"event_trigger_options ",22},
1291 {"event_close_options ",20},
1292 {"event_timer_options ",20}
1293};
1294 1242
1295/* This returns a string of the integer movement type */ 1243/* This returns a string of the integer movement type */
1296static char* get_string_move_type(MoveType mt) 1244static char* get_string_move_type(MoveType mt)
1297{ 1245{
1298 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF]; 1246 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF];
1453 op->other_arch->name) { 1401 op->other_arch->name) {
1454 ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11); 1402 ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11);
1455 } 1403 }
1456 if(op->face!=op2->face) { 1404 if(op->face!=op2->face) {
1457 ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5); 1405 ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5);
1458 }
1459
1460 for(etmp=op->events;etmp!=NULL;etmp=etmp->next)
1461 {
1462 /* First we find the event for the reference object */
1463 etmp2=find_event(op2,etmp->type);
1464 if ((etmp->hook != NULL) && ((etmp2 == NULL) || (etmp2->hook == NULL) || (strcmp(etmp2->hook,etmp->hook))))
1465 /* Either there's no matching event in the reference object,
1466 * or the hook is different */
1467 {
1468 ADD_STRINGLINE_ENTRY(fastbuf,evtnames[etmp->type].name,etmp->hook,evtnames[etmp->type].length);
1469 }
1470 if ((etmp->plugin != NULL) && ((etmp2 == NULL) || (etmp2->plugin == NULL) || (strcmp(etmp2->plugin,etmp->plugin))))
1471 {
1472
1473 ADD_STRINGLINE_ENTRY(fastbuf,plgnames[etmp->type].name,etmp->plugin,plgnames[etmp->type].length);
1474 }
1475 if ((etmp->options != NULL) && ((etmp2 == NULL) || (etmp2->options == NULL) || (strcmp(etmp2->options,etmp->options))))
1476 {
1477 ADD_STRINGLINE_ENTRY(fastbuf,plgoptions[etmp->type].name,etmp->options,plgoptions[etmp->type].length);
1478 }
1479
1480 } 1406 }
1481 1407
1482 if (op->animation_id != op2->animation_id) { 1408 if (op->animation_id != op2->animation_id) {
1483 if (op->animation_id) { 1409 if (op->animation_id) {
1484 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);
1755 object *tmp,*old; 1681 object *tmp,*old;
1756 1682
1757 /* 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
1758 * still save it. 1684 * still save it.
1759 */ 1685 */
1760 if(op->owner!=NULL || fp == NULL) 1686 if(op->owner!=NULL)
1761 return; 1687 return;
1762 1688
1763 /* 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. */
1764 if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) { 1690 if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) {
1765 return; 1691 return;
1800 1726
1801 fp.put (op); 1727 fp.put (op);
1802 fprintf(fp,"end\n"); 1728 fprintf(fp,"end\n");
1803} 1729}
1804 1730
1805void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions)
1806{
1807 event *evt;
1808 event *tmp;
1809
1810 evt = find_event(op,etype);
1811 if (evt == NULL)
1812 {
1813 evt = (event *)malloc(sizeof(event));
1814 evt->next = NULL;
1815 evt->type = etype;
1816 evt->hook = NULL;
1817 evt->plugin = NULL;
1818 evt->options = NULL;
1819 if (op->events==NULL)
1820 {
1821 op->events=evt;
1822 }
1823 else
1824 {
1825 for(tmp=op->events;;tmp=tmp->next)
1826 {
1827 if (tmp->next == NULL)
1828 {
1829 tmp->next = evt;
1830 break;
1831 }
1832 }
1833 }
1834 }
1835 if (ehook != NULL)
1836 FREE_AND_COPY(evt->hook,ehook);
1837 if (eplug != NULL)
1838 FREE_AND_COPY(evt->plugin,eplug);
1839 if (eoptions != NULL)
1840 FREE_AND_COPY(evt->options,eoptions);
1841}
1842
1843event* find_event(object* op, int etype) 1731event* find_event(object* op, int etype)
1844{ 1732{
1845 event *found; 1733 event *found;
1846 for(found=op->events;found!=NULL;found=found->next) 1734 for(found=op->events;found!=NULL;found=found->next)
1847 { 1735 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines