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.16 by root, Thu Aug 31 06:23:19 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.16 2006/08/31 06:23:19 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
1237/*For get_ob_diff speed reason*/ 1237/*For get_ob_diff speed reason*/
1238typedef struct { 1238typedef struct {
1239 const char *name; 1239 const char *name;
1240 int length; 1240 int length;
1241}genericname; 1241}genericname;
1242static genericname evtnames[13]=
1243{
1244 {"event_none ",11},
1245 {"event_apply ",12},
1246 {"event_attack ",13},
1247 {"event_death ",12},
1248 {"event_drop ",11},
1249 {"event_pickup ",13},
1250 {"event_say ",10},
1251 {"event_stop ",11},
1252 {"event_time ",11},
1253 {"event_throw ",12},
1254 {"event_trigger ",14},
1255 {"event_close ",12},
1256 {"event_timer ",12}
1257} ;
1258
1259static genericname plgnames[13]=
1260{
1261 {"event_none_plugin ",18},
1262 {"event_apply_plugin ",19},
1263 {"event_attack_plugin ",20},
1264 {"event_death_plugin ",19},
1265 {"event_drop_plugin ",18},
1266 {"event_pickup_plugin ",20},
1267 {"event_say_plugin ",17},
1268 {"event_stop_plugin ",18},
1269 {"event_time_plugin ",18},
1270 {"event_throw_plugin ",19},
1271 {"event_trigger_plugin ",21},
1272 {"event_close_plugin ",19},
1273 {"event_timer_plugin ",19}
1274};
1275
1276static genericname plgoptions[13]=
1277{
1278 {"event_none_options ",19},
1279 {"event_apply_options ",20},
1280 {"event_attack_options ",21},
1281 {"event_death_options ",20},
1282 {"event_drop_options ",19},
1283 {"event_pickup_options ",21},
1284 {"event_say_options ",18},
1285 {"event_stop_options ",19},
1286 {"event_time_options ",19},
1287 {"event_throw_options ",20},
1288 {"event_trigger_options ",22},
1289 {"event_close_options ",20},
1290 {"event_timer_options ",20}
1291};
1292 1242
1293/* This returns a string of the integer movement type */ 1243/* This returns a string of the integer movement type */
1294static char* get_string_move_type(MoveType mt) 1244static char* get_string_move_type(MoveType mt)
1295{ 1245{
1296 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF]; 1246 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF];
1451 op->other_arch->name) { 1401 op->other_arch->name) {
1452 ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11); 1402 ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11);
1453 } 1403 }
1454 if(op->face!=op2->face) { 1404 if(op->face!=op2->face) {
1455 ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5); 1405 ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5);
1456 }
1457
1458 for(etmp=op->events;etmp!=NULL;etmp=etmp->next)
1459 {
1460 /* First we find the event for the reference object */
1461 etmp2=find_event(op2,etmp->type);
1462 if ((etmp->hook != NULL) && ((etmp2 == NULL) || (etmp2->hook == NULL) || (strcmp(etmp2->hook,etmp->hook))))
1463 /* Either there's no matching event in the reference object,
1464 * or the hook is different */
1465 {
1466 ADD_STRINGLINE_ENTRY(fastbuf,evtnames[etmp->type].name,etmp->hook,evtnames[etmp->type].length);
1467 }
1468 if ((etmp->plugin != NULL) && ((etmp2 == NULL) || (etmp2->plugin == NULL) || (strcmp(etmp2->plugin,etmp->plugin))))
1469 {
1470
1471 ADD_STRINGLINE_ENTRY(fastbuf,plgnames[etmp->type].name,etmp->plugin,plgnames[etmp->type].length);
1472 }
1473 if ((etmp->options != NULL) && ((etmp2 == NULL) || (etmp2->options == NULL) || (strcmp(etmp2->options,etmp->options))))
1474 {
1475 ADD_STRINGLINE_ENTRY(fastbuf,plgoptions[etmp->type].name,etmp->options,plgoptions[etmp->type].length);
1476 }
1477
1478 } 1406 }
1479 1407
1480 if (op->animation_id != op2->animation_id) { 1408 if (op->animation_id != op2->animation_id) {
1481 if (op->animation_id) { 1409 if (op->animation_id) {
1482 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);
1798 1726
1799 fp.put (op); 1727 fp.put (op);
1800 fprintf(fp,"end\n"); 1728 fprintf(fp,"end\n");
1801} 1729}
1802 1730
1803void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions)
1804{
1805 event *evt;
1806 event *tmp;
1807
1808 evt = find_event(op,etype);
1809 if (evt == NULL)
1810 {
1811 evt = (event *)malloc(sizeof(event));
1812 evt->next = NULL;
1813 evt->type = etype;
1814 evt->hook = NULL;
1815 evt->plugin = NULL;
1816 evt->options = NULL;
1817 if (op->events==NULL)
1818 {
1819 op->events=evt;
1820 }
1821 else
1822 {
1823 for(tmp=op->events;;tmp=tmp->next)
1824 {
1825 if (tmp->next == NULL)
1826 {
1827 tmp->next = evt;
1828 break;
1829 }
1830 }
1831 }
1832 }
1833 if (ehook != NULL)
1834 FREE_AND_COPY(evt->hook,ehook);
1835 if (eplug != NULL)
1836 FREE_AND_COPY(evt->plugin,eplug);
1837 if (eoptions != NULL)
1838 FREE_AND_COPY(evt->options,eoptions);
1839}
1840
1841event* find_event(object* op, int etype) 1731event* find_event(object* op, int etype)
1842{ 1732{
1843 event *found; 1733 event *found;
1844 for(found=op->events;found!=NULL;found=found->next) 1734 for(found=op->events;found!=NULL;found=found->next)
1845 { 1735 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines