--- deliantra/server/common/loader.l 2006/08/13 17:16:00 1.7 +++ deliantra/server/common/loader.l 2006/08/27 17:59:25 1.11 @@ -37,13 +37,13 @@ #include #include -#define YY_DECL int lex_load(object *op, int map_flags) +#define YY_DECL int lex_load(object *op, object_thawer &thawer, int map_flags) static char *yval(); static int lex_error; -static char msgbuf[HUGE_BUF]; -static char lorebuf[HUGE_BUF]; +static char msgbuf[65536]; +static char lorebuf[65536]; /* Maps the MOVE_* values to names */ static const char *const move_name[] = {"walk", "fly_low", "fly_high", "swim", "boat", @@ -695,6 +695,10 @@ if (*yv=='\0') LOG(llevError,"Name without val\n"); else FREE_AND_COPY(op->name_pl, yv); } +^attach{S} { char *yv=yval(); + if (*yv) + op->attach = add_string (yv); + } ^skill{S} FREE_AND_COPY(op->skill,yval()); ^custom_name{S} { char *yv=yval(); @@ -714,18 +718,18 @@ object *tmp; char *yv=yval(); - tmp=get_object(); - tmp->arch = find_archetype(yv); - if (tmp->arch!=NULL) - copy_object(&tmp->arch->clone,tmp); + archetype *arch = find_archetype(yv); + if (arch!=NULL) + tmp = arch_to_object (arch); else { + tmp = get_object (); if (tmp->name) free_string(tmp->name); /* record the name of the broken object */ tmp->name = add_string(yv); } strcpy(msgbuf, ""); strcpy(lorebuf, ""); - lex_load(tmp, map_flags); + lex_load(tmp, thawer, map_flags); if (tmp->arch) { insert_ob_in_ob(tmp,op); } @@ -739,8 +743,9 @@ char *yv=yval(); op->arch=find_archetype(yv); - if (op->arch!=NULL) copy_object(&op->arch->clone,op); - else if (!arch_init) { + if (op->arch!=NULL) { + copy_object(&op->arch->clone,op); + } else if (!arch_init) { if (op->name) free_string(op->name); /* record the name of the broken object */ op->name = add_string(yv); @@ -766,6 +771,13 @@ } ^end{WS}$ { check_loaded_object(op); + + if (!arch_init) + { + thawer.get (op); + op->instantiate (); + } + if (ismore) return LL_MORE; else return LL_NORMAL; } @@ -1400,7 +1412,7 @@ * */ -int load_object(FILE *fp, object *op, int bufstate, int map_flags) { +int load_object(FILE *fp, object_thawer &thawer, object *op, int bufstate, int map_flags) { int retval; char inbuf[MAX_BUF]; @@ -1416,7 +1428,7 @@ YY_BUFFER_STATE yybufstate; while (fgets(inbuf, MAX_BUF-3, fp)) { yybufstate=yy_scan_string(inbuf); - retval=lex_load(op, map_flags); + retval=lex_load(op, thawer, map_flags); yy_delete_buffer(yybufstate); if (retval==LL_NORMAL) return retval; } @@ -1424,7 +1436,7 @@ return LL_EOF; } - retval=lex_load(op, map_flags); + 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); @@ -1445,12 +1457,13 @@ int set_variable(object *op,char *buf) { YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; int retval; + object_thawer thawer; strcpy(msgbuf, ""); strcpy(lorebuf, ""); yy_push_state(INITIAL); yybufstate=yy_scan_string(buf); - retval=lex_load(op,0); + retval=lex_load(op,thawer,0); yy_switch_to_buffer(yycurbuf); yy_delete_buffer(yybufstate); yy_pop_state(); @@ -2027,7 +2040,7 @@ * all of the callers are setting this. */ -void save_object(FILE *fp,object *op, int flag) { +void save_object(FILE *fp,object_freezer &freezer,object *op, int flag) { archetype *at; char *cp; object *tmp,*old; @@ -2055,7 +2068,7 @@ if (flag & 2 ) for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) - save_object(fp,tmp,flag); + save_object(fp,freezer,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 @@ -2067,7 +2080,7 @@ LOG(llevError," Recursive loop in inventory\n"); break; } - save_object(fp,tmp,flag); + save_object(fp,freezer,tmp,flag); old=tmp; } @@ -2077,6 +2090,7 @@ } fprintf(fp,"end\n"); + freezer.put (op); } void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions)