From e4666b4fb5100b2be3f7758cbf0d724b046a7178 Mon Sep 17 00:00:00 2001 From: Lance Date: Tue, 23 May 2006 08:35:22 +0000 Subject: * Added 'setd' support for local NPC scope (') variables. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6704 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 4 ++-- src/map/npc.c | 4 ++-- src/map/script.c | 60 ++++++++++++++++++++++++++++---------------------------- src/map/script.h | 3 ++- 4 files changed, 36 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/map/clif.c b/src/map/clif.c index bfd3d0779..1adff1ad9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9384,8 +9384,8 @@ void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd) if((nd = ((struct npc_data *)map_id2bl(sd->npc_shopid))->master_nd)){ sprintf(npc_ev, "%s::OnBuyItem", nd->exname); for(i=0;istatus.inventory[idx]); if(nd) { - setd_sub(sd, "@sold_nameid", i, (void *)(int)sd->status.inventory[idx].nameid); - setd_sub(sd, "@sold_quantity", i, (void *)(int)qty); + setd_sub(NULL,sd, "@sold_nameid", i, (void *)(int)sd->status.inventory[idx].nameid); + setd_sub(NULL,sd, "@sold_quantity", i, (void *)(int)qty); } itemamount+=qty; pc_delitem(sd,idx,qty,0); diff --git a/src/map/script.c b/src/map/script.c index f45e722fc..5e2080080 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9902,9 +9902,9 @@ int buildin_distance(struct script_state *st){ // <--- [zBuffer] List of mathematics commands // [zBuffer] List of dynamic var commands ---> -void setd_sub(struct map_session_data *sd, char *varname, int elem, void *value) +void setd_sub(struct script_state *st, struct map_session_data *sd, char *varname, int elem, void *value) { - set_reg(NULL, sd, add_str((unsigned char *) varname)+(elem<<24), varname, value, NULL); + set_reg(st, sd, add_str((unsigned char *) varname)+(elem<<24), varname, value,NULL); return; } @@ -9924,9 +9924,9 @@ int buildin_setd(struct script_state *st) sd = script_rid2sd(st); if(varname[strlen(varname)-1] != '$') { - setd_sub(sd, varname, elem, (void *)atoi(value)); + setd_sub(st,sd, varname, elem, (void *)atoi(value)); } else { - setd_sub(sd, varname, elem, (void *)value); + setd_sub(st,sd, varname, elem, (void *)value); } return 0; @@ -9955,12 +9955,12 @@ int buildin_query_sql(struct script_state *st) { if((sql_res = mysql_store_result(&mmysql_handle))){ if(name[strlen(name)-1] != '$') { while(i<128 && (sql_row = mysql_fetch_row(sql_res))){ - setd_sub(sd, name, i, (void *)atoi(sql_row[0])); + setd_sub(st,sd, name, i, (void *)atoi(sql_row[0])); i++; } } else { while(i<128 && (sql_row = mysql_fetch_row(sql_res))){ - setd_sub(sd, name, i, (void *)sql_row[0]); + setd_sub(st,sd, name, i, (void *)sql_row[0]); i++; } } @@ -10495,30 +10495,30 @@ int buildin_getmobdata(struct script_state *st) { } else { num=st->stack->stack_data[st->start+2].u.num; name=(char *)(str_buf+str_data[num&0x00ffffff].str); - setd_sub(map_id2sd(st->rid),name,0,(void *)(int)md->class_); - setd_sub(map_id2sd(st->rid),name,1,(void *)(int)md->level); - setd_sub(map_id2sd(st->rid),name,2,(void *)(int)md->hp); - setd_sub(map_id2sd(st->rid),name,3,(void *)(int)md->max_hp); - setd_sub(map_id2sd(st->rid),name,4,(void *)(int)md->master_id); - setd_sub(map_id2sd(st->rid),name,5,(void *)(int)md->bl.m); - setd_sub(map_id2sd(st->rid),name,6,(void *)(int)md->bl.x); - setd_sub(map_id2sd(st->rid),name,7,(void *)(int)md->bl.y); - setd_sub(map_id2sd(st->rid),name,8,(void *)(int)md->speed); - setd_sub(map_id2sd(st->rid),name,9,(void *)(int)md->mode); - setd_sub(map_id2sd(st->rid),name,10,(void *)(int)md->special_state.ai); - setd_sub(map_id2sd(st->rid),name,11,(void *)(int)md->db->option); - setd_sub(map_id2sd(st->rid),name,12,(void *)(int)md->vd->sex); - setd_sub(map_id2sd(st->rid),name,13,(void *)(int)md->vd->class_); - setd_sub(map_id2sd(st->rid),name,14,(void *)(int)md->vd->hair_style); - setd_sub(map_id2sd(st->rid),name,15,(void *)(int)md->vd->hair_color); - setd_sub(map_id2sd(st->rid),name,16,(void *)(int)md->vd->head_bottom); - setd_sub(map_id2sd(st->rid),name,17,(void *)(int)md->vd->head_mid); - setd_sub(map_id2sd(st->rid),name,18,(void *)(int)md->vd->head_top); - setd_sub(map_id2sd(st->rid),name,19,(void *)(int)md->vd->cloth_color); - setd_sub(map_id2sd(st->rid),name,20,(void *)(int)md->vd->shield); - setd_sub(map_id2sd(st->rid),name,21,(void *)(int)md->vd->weapon); - setd_sub(map_id2sd(st->rid),name,22,(void *)(int)md->vd->shield); - setd_sub(map_id2sd(st->rid),name,23,(void *)(int)md->ud.dir); + setd_sub(st,map_id2sd(st->rid),name,0,(void *)(int)md->class_); + setd_sub(st,map_id2sd(st->rid),name,1,(void *)(int)md->level); + setd_sub(st,map_id2sd(st->rid),name,2,(void *)(int)md->hp); + setd_sub(st,map_id2sd(st->rid),name,3,(void *)(int)md->max_hp); + setd_sub(st,map_id2sd(st->rid),name,4,(void *)(int)md->master_id); + setd_sub(st,map_id2sd(st->rid),name,5,(void *)(int)md->bl.m); + setd_sub(st,map_id2sd(st->rid),name,6,(void *)(int)md->bl.x); + setd_sub(st,map_id2sd(st->rid),name,7,(void *)(int)md->bl.y); + setd_sub(st,map_id2sd(st->rid),name,8,(void *)(int)md->speed); + setd_sub(st,map_id2sd(st->rid),name,9,(void *)(int)md->mode); + setd_sub(st,map_id2sd(st->rid),name,10,(void *)(int)md->special_state.ai); + setd_sub(st,map_id2sd(st->rid),name,11,(void *)(int)md->db->option); + setd_sub(st,map_id2sd(st->rid),name,12,(void *)(int)md->vd->sex); + setd_sub(st,map_id2sd(st->rid),name,13,(void *)(int)md->vd->class_); + setd_sub(st,map_id2sd(st->rid),name,14,(void *)(int)md->vd->hair_style); + setd_sub(st,map_id2sd(st->rid),name,15,(void *)(int)md->vd->hair_color); + setd_sub(st,map_id2sd(st->rid),name,16,(void *)(int)md->vd->head_bottom); + setd_sub(st,map_id2sd(st->rid),name,17,(void *)(int)md->vd->head_mid); + setd_sub(st,map_id2sd(st->rid),name,18,(void *)(int)md->vd->head_top); + setd_sub(st,map_id2sd(st->rid),name,19,(void *)(int)md->vd->cloth_color); + setd_sub(st,map_id2sd(st->rid),name,20,(void *)(int)md->vd->shield); + setd_sub(st,map_id2sd(st->rid),name,21,(void *)(int)md->vd->weapon); + setd_sub(st,map_id2sd(st->rid),name,22,(void *)(int)md->vd->shield); + setd_sub(st,map_id2sd(st->rid),name,23,(void *)(int)md->ud.dir); } return 0; } diff --git a/src/map/script.h b/src/map/script.h index 109ab7690..87b03a5af 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -69,9 +69,10 @@ int run_script(struct script_code *rootscript,int pos,int rid,int oid); int set_var(struct map_session_data *sd, char *name, void *val); int conv_num(struct script_state *st,struct script_data *data); char* conv_str(struct script_state *st,struct script_data *data); -void setd_sub(struct map_session_data *sd, char *varname, int elem, void *value); +void setd_sub(struct script_state *st, struct map_session_data *sd, char *varname, int elem, void *value); int run_script_timer(int tid, unsigned int tick, int id, int data); int run_script_main(struct script_state *st); + struct linkdb_node* script_erase_sleepdb(struct linkdb_node *n); void script_free_code(struct script_code* code); -- cgit v1.2.3-70-g09d2