--- deliantra/server/common/loader.l 2006/08/27 16:15:11 1.10 +++ deliantra/server/common/loader.l 2006/08/31 06:23:19 1.16 @@ -745,7 +745,6 @@ op->arch=find_archetype(yv); if (op->arch!=NULL) { copy_object(&op->arch->clone,op); - op->instantiate (); } else if (!arch_init) { if (op->name) free_string(op->name); /* record the name of the broken object */ @@ -770,12 +769,17 @@ */ ismore=1; } - ^end{WS}$ { check_loaded_object(op); - thawer.get (op); + + if (!arch_init) + op->instantiate (); + if (ismore) return LL_MORE; else return LL_NORMAL; } +^oid{S} { + thawer.get (op, IVAL); + } ^last_heal{S} op->last_heal = IVAL; ^last_sp{S} op->last_sp = IVAL; ^last_grace{S} op->last_grace = IVAL; @@ -1054,293 +1058,10 @@ ^duration_modifier{S} op->duration_modifier = 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_ { + LOG (llevError, "stray event_* in map file, skipping."); } -^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(); - - if (*yv=='\0') LOG(llevError,"Script (current weapon) without val\n"); - else - { - FREE_AND_COPY(op->current_weapon_script, yv); - }; - } - <*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} #.*\n {} @@ -1407,7 +1128,7 @@ * */ -int load_object(FILE *fp, object_thawer &thawer, object *op, int bufstate, int map_flags) { +int load_object(object_thawer &fp, object *op, int bufstate, int map_flags) { int retval; char inbuf[MAX_BUF]; @@ -1423,7 +1144,7 @@ YY_BUFFER_STATE yybufstate; while (fgets(inbuf, MAX_BUF-3, fp)) { yybufstate=yy_scan_string(inbuf); - retval=lex_load(op, thawer, map_flags); + retval=lex_load(op, fp, map_flags); yy_delete_buffer(yybufstate); if (retval==LL_NORMAL) return retval; } @@ -1431,12 +1152,7 @@ return LL_EOF; } - retval=lex_load(op, thawer, map_flags); - if (op->current_weapon_script != NULL) - { - op->current_weapon = find_best_weapon_used_match(op, op->current_weapon_script); - LOG(llevDebug, "CurrentWeapon Loaded !\n"); - }; + retval=lex_load(op, fp, map_flags); /* LOG(llevDebug," load completed, object=%s\n",op->name);*/ return retval; @@ -1452,7 +1168,7 @@ int set_variable(object *op,char *buf) { YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; int retval; - object_thawer thawer; + object_thawer thawer (0); strcpy(msgbuf, ""); strcpy(lorebuf, ""); @@ -1919,10 +1635,6 @@ if(op->smoothlevel!=op2->smoothlevel) FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12); - if (op->current_weapon_script!=op2->current_weapon_script){ - ADD_STRINGLINE_ENTRY(fastbuf,"current_weapon_script ",op->current_weapon_script,22); - }; - if(op->weapontype && op->weapontype!=op2->weapontype) { FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11); } @@ -2035,7 +1747,7 @@ * all of the callers are setting this. */ -void save_object(FILE *fp,object_freezer &freezer,object *op, int flag) { +void save_object(object_freezer &fp,object *op, int flag) { archetype *at; char *cp; object *tmp,*old; @@ -2043,7 +1755,7 @@ /* Even if the object does have an owner, it would seem that we should * still save it. */ - if(op->owner!=NULL || fp == NULL) + if(op->owner!=NULL) return; /* If it is unpaid and we don't want to save those, just return. */ @@ -2063,7 +1775,7 @@ if (flag & 2 ) for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) - save_object(fp,freezer,tmp,flag); + save_object(fp,tmp,flag); /* Slightly different logic because tmp/op will be removed by * the save_object we call. So we just keep looking at op->inv @@ -2075,7 +1787,7 @@ LOG(llevError," Recursive loop in inventory\n"); break; } - save_object(fp,freezer,tmp,flag); + save_object(fp,tmp,flag); old=tmp; } @@ -2084,8 +1796,8 @@ free_object (op); } + fp.put (op); fprintf(fp,"end\n"); - freezer.put (op); } void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions)