version 1.83 | | version 1.84 |
---|
| | |
%{ | | %{ |
/* | | /* |
* static char *rcsid_object_c = | | * static char *rcsid_object_c = |
* "$Id: loader.l,v 1.83 2006/08/08 18:17:53 qal21 Exp $"; | | * "$Id: loader.l,v 1.84 2006/08/26 17:56:21 ryo_saeba Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
^dam_modifier{S} op->dam_modifier = IVAL; | | ^dam_modifier{S} op->dam_modifier = IVAL; |
^duration_modifier{S} op->duration_modifier = IVAL; | | ^duration_modifier{S} op->duration_modifier = IVAL; |
^is_buildable{S} SET_OR_CLEAR_FLAG( op, FLAG_IS_BUILDABLE, IVAL ); | | ^is_buildable{S} SET_OR_CLEAR_FLAG( op, FLAG_IS_BUILDABLE, IVAL ); |
| | |
^event_apply{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (apply) without val\n"); | | |
else | | |
insert_event(op,EVENT_APPLY,yv,NULL,NULL); | | |
} | | |
| | |
^event_apply_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (apply) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_APPLY,NULL,yv,NULL); | | |
} | | |
| | |
^event_apply_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (apply) without options\n"); | | |
else | | |
insert_event(op,EVENT_APPLY,NULL,NULL,yv); | | |
} | | |
| | |
^event_attack{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (attack) without val\n"); | | |
else | | |
insert_event(op,EVENT_ATTACK,yv,NULL,NULL); | | |
} | | |
| | |
^event_attack_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (attack) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_ATTACK,NULL,yv,NULL); | | |
} | | |
| | |
^event_attack_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (attack) without options\n"); | | |
else | | |
insert_event(op,EVENT_ATTACK,NULL,NULL,yv); | | |
} | | |
^event_death{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (death) without val\n"); | | |
else | | |
insert_event(op,EVENT_DEATH,yv,NULL,NULL); | | |
} | | |
| | |
^event_death_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (death) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_DEATH,NULL,yv,NULL); | | |
} | | |
| | |
^event_death_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (death) without options\n"); | | |
else | | |
insert_event(op,EVENT_DEATH,NULL,NULL,yv); | | |
} | | |
^event_drop{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (drop) without val\n"); | | |
else | | |
insert_event(op,EVENT_DROP,yv,NULL,NULL); | | |
} | | |
| | |
^event_drop_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (drop) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_DROP,NULL,yv,NULL); | | |
} | | |
| | |
^event_drop_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (drop) without options\n"); | | |
else | | |
insert_event(op,EVENT_DROP,NULL,NULL,yv); | | |
} | | |
^event_pickup{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (pickup) without val\n"); | | |
else | | |
insert_event(op,EVENT_PICKUP,yv,NULL,NULL); | | |
} | | |
| | |
^event_pickup_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (pickup) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_PICKUP,NULL,yv,NULL); | | |
} | | |
| | |
^event_pickup_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (pickup) without options\n"); | | |
else | | |
insert_event(op,EVENT_PICKUP,NULL,NULL,yv); | | |
} | | |
^event_say{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (say) without val\n"); | | |
else | | |
insert_event(op,EVENT_SAY,yv,NULL,NULL); | | |
} | | |
| | |
^event_say_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (say) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_SAY,NULL,yv,NULL); | | |
} | | |
| | |
^event_say_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (say) without options\n"); | | |
else | | |
insert_event(op,EVENT_SAY,NULL,NULL,yv); | | |
} | | |
^event_stop{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (stop) without val\n"); | | |
else | | |
insert_event(op,EVENT_STOP,yv,NULL,NULL); | | |
} | | |
| | |
^event_stop_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (stop) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_STOP,NULL,yv,NULL); | | |
} | | |
| | |
^event_stop_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (stop) without options\n"); | | |
else | | |
insert_event(op,EVENT_STOP,NULL,NULL,yv); | | |
} | | |
^event_time{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (time) without val\n"); | | |
else | | |
insert_event(op,EVENT_TIME,yv,NULL,NULL); | | |
} | | |
| | |
^event_time_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (time) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_TIME,NULL,yv,NULL); | | |
} | | |
| | |
^event_time_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (time) without options\n"); | | |
else | | |
insert_event(op,EVENT_TIME,NULL,NULL,yv); | | |
} | | |
^event_throw{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (throw) without val\n"); | | |
else | | |
insert_event(op,EVENT_THROW,yv,NULL,NULL); | | |
} | | |
| | |
^event_throw_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (throw) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_THROW,NULL,yv,NULL); | | |
} | | |
| | |
^event_throw_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (apply) without options\n"); | | |
else | | |
insert_event(op,EVENT_THROW,NULL,NULL,yv); | | |
} | | |
^event_trigger{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (trigger) without val\n"); | | |
else | | |
insert_event(op,EVENT_TRIGGER,yv,NULL,NULL); | | |
} | | |
| | |
^event_trigger_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (trigger) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_TRIGGER,NULL,yv,NULL); | | |
} | | |
| | |
^event_trigger_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (trigger) without options\n"); | | |
else | | |
insert_event(op,EVENT_TRIGGER,NULL,NULL,yv); | | |
} | | |
^event_close{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (close) without val\n"); | | |
else | | |
insert_event(op,EVENT_CLOSE,yv,NULL,NULL); | | |
} | | |
| | |
^event_close_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (close) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_CLOSE,NULL,yv,NULL); | | |
} | | |
| | |
^event_close_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (close) without options\n"); | | |
else | | |
insert_event(op,EVENT_CLOSE,NULL,NULL,yv); | | |
} | | |
^event_timer{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (timer) without val\n"); | | |
else | | |
insert_event(op,EVENT_TIMER,yv,NULL,NULL); | | |
} | | |
| | |
^event_timer_plugin{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (timer) without plugin\n"); | | |
else | | |
insert_event(op,EVENT_TIMER,NULL,yv,NULL); | | |
} | | |
| | |
^event_timer_options{S} { | | |
char *yv=yval(); | | |
if (*yv=='\0') | | |
LOG(llevError,"Event (timer) without options\n"); | | |
else | | |
insert_event(op,EVENT_TIMER,NULL,NULL,yv); | | |
} | | |
| | |
^current_weapon_script{S} { char *yv=yval(); | | ^current_weapon_script{S} { char *yv=yval(); |
| | |
if (*yv=='\0') LOG(llevError,"Script (current weapon) without val\n"); | | if (*yv=='\0') LOG(llevError,"Script (current weapon) without val\n"); |
| | |
const char *name; | | const char *name; |
int length; | | int length; |
}genericname; | | }genericname; |
static genericname evtnames[13]= | | |
{ | | |
{"event_none ",11}, | | |
{"event_apply ",12}, | | |
{"event_attack ",13}, | | |
{"event_death ",12}, | | |
{"event_drop ",11}, | | |
{"event_pickup ",13}, | | |
{"event_say ",10}, | | |
{"event_stop ",11}, | | |
{"event_time ",11}, | | |
{"event_throw ",12}, | | |
{"event_trigger ",14}, | | |
{"event_close ",12}, | | |
{"event_timer ",12} | | |
} ; | | |
| | |
static genericname plgnames[13]= | | |
{ | | |
{"event_none_plugin ",18}, | | |
{"event_apply_plugin ",19}, | | |
{"event_attack_plugin ",20}, | | |
{"event_death_plugin ",19}, | | |
{"event_drop_plugin ",18}, | | |
{"event_pickup_plugin ",20}, | | |
{"event_say_plugin ",17}, | | |
{"event_stop_plugin ",18}, | | |
{"event_time_plugin ",18}, | | |
{"event_throw_plugin ",19}, | | |
{"event_trigger_plugin ",21}, | | |
{"event_close_plugin ",19}, | | |
{"event_timer_plugin ",19} | | |
}; | | |
| | |
static genericname plgoptions[13]= | | |
{ | | |
{"event_none_options ",19}, | | |
{"event_apply_options ",20}, | | |
{"event_attack_options ",21}, | | |
{"event_death_options ",20}, | | |
{"event_drop_options ",19}, | | |
{"event_pickup_options ",21}, | | |
{"event_say_options ",18}, | | |
{"event_stop_options ",19}, | | |
{"event_time_options ",19}, | | |
{"event_throw_options ",20}, | | |
{"event_trigger_options ",22}, | | |
{"event_close_options ",20}, | | |
{"event_timer_options ",20} | | |
}; | | |
| | |
/* This returns a string of the integer movement type */ | | /* This returns a string of the integer movement type */ |
static char* get_string_move_type(MoveType mt) | | static char* get_string_move_type(MoveType mt) |
| | |
buf[i]='a'+(unsigned short)(i%25); | | buf[i]='a'+(unsigned short)(i%25); |
} | | } |
#endif | | #endif |
event *etmp; | | |
event *etmp2; | | |
key_value * my_field; | | key_value * my_field; |
key_value * arch_field; | | key_value * arch_field; |
| | |
| | |
ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5); | | ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5); |
} | | } |
| | |
for(etmp=op->events;etmp!=NULL;etmp=etmp->next) | | |
{ | | |
/* First we find the event for the reference object */ | | |
etmp2=find_event(op2,etmp->type); | | |
if ((etmp->hook != NULL) && ((etmp2 == NULL) || (etmp2->hook == NULL) || (strcmp(etmp2->hook,etmp->hook)))) | | |
/* Either there's no matching event in the reference object, | | |
* or the hook is different */ | | |
{ | | |
ADD_STRINGLINE_ENTRY(fastbuf,evtnames[etmp->type].name,etmp->hook,evtnames[etmp->type].length); | | |
} | | |
if ((etmp->plugin != NULL) && ((etmp2 == NULL) || (etmp2->plugin == NULL) || (strcmp(etmp2->plugin,etmp->plugin)))) | | |
{ | | |
| | |
ADD_STRINGLINE_ENTRY(fastbuf,plgnames[etmp->type].name,etmp->plugin,plgnames[etmp->type].length); | | |
} | | |
if ((etmp->options != NULL) && ((etmp2 == NULL) || (etmp2->options == NULL) || (strcmp(etmp2->options,etmp->options)))) | | |
{ | | |
ADD_STRINGLINE_ENTRY(fastbuf,plgoptions[etmp->type].name,etmp->options,plgoptions[etmp->type].length); | | |
} | | |
| | |
} | | |
| | |
if (op->animation_id != op2->animation_id) { | | if (op->animation_id != op2->animation_id) { |
if (op->animation_id) { | | if (op->animation_id) { |
ADD_STRINGLINE_ENTRY(fastbuf,"animation ",animations[GET_ANIM_ID(op)].name,10); | | ADD_STRINGLINE_ENTRY(fastbuf,"animation ",animations[GET_ANIM_ID(op)].name,10); |
| | |
| | |
fprintf(fp,"end\n"); | | fprintf(fp,"end\n"); |
} | | } |
| | |
void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions) | | |
{ | | |
event *evt; | | |
event *tmp; | | |
| | |
evt = find_event(op,etype); | | |
if (evt == NULL) | | |
{ | | |
evt = (event *)malloc(sizeof(event)); | | |
evt->next = NULL; | | |
evt->type = etype; | | |
evt->hook = NULL; | | |
evt->plugin = NULL; | | |
evt->options = NULL; | | |
if (op->events==NULL) | | |
{ | | |
op->events=evt; | | |
} | | |
else | | |
{ | | |
for(tmp=op->events;;tmp=tmp->next) | | |
{ | | |
if (tmp->next == NULL) | | |
{ | | |
tmp->next = evt; | | |
break; | | |
} | | |
} | | |
} | | |
} | | |
if (ehook != NULL) | | |
FREE_AND_COPY(evt->hook,ehook); | | |
if (eplug != NULL) | | |
FREE_AND_COPY(evt->plugin,eplug); | | |
if (eoptions != NULL) | | |
FREE_AND_COPY(evt->options,eoptions); | | |
} | | |
| | |
event* find_event(object* op, int etype) | | |
{ | | |
event *found; | | |
for(found=op->events;found!=NULL;found=found->next) | | |
{ | | |
if (found->type == etype) | | |
return found; | | |
} | | |
return NULL; | | |
} | | |