From dc1c0ca6d41a3cb15a98cda7a324a948f40c90f7 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 14 Mar 2009 17:17:06 -0600 Subject: Fix some storage-related code You can't end NPC scripts with openstorage, which will now wait for the user. --- src/map/clif.c | 11 +++++++---- src/map/map.h | 3 +++ src/map/script.c | 15 ++++++++++++--- src/map/storage.c | 2 -- 4 files changed, 22 insertions(+), 9 deletions(-) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index b555231..a309111 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7611,7 +7611,7 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) { item_index = RFIFOW(fd,2) - 2; item_amount = RFIFOL(fd,4); - if (sd->npc_id != 0) + if (sd->npc_id != 0 && !sd->npc_flags.storage) return; if (sd->state.storage_flag) @@ -7632,7 +7632,7 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) { item_index = RFIFOW(fd,2) - 1; item_amount = RFIFOL(fd,4); - if (sd->npc_id != 0) + if (sd->npc_id != 0 && !sd->npc_flags.storage) return; if (sd->state.storage_flag) @@ -7648,7 +7648,7 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) { void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd) { nullpo_retv(sd); - if (sd->npc_id != 0) + if (sd->npc_id != 0 && !sd->npc_flags.storage) return; if (sd->state.storage_flag) storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4)); @@ -7683,7 +7683,10 @@ void clif_parse_CloseKafra(int fd, struct map_session_data *sd) { else storage_storageclose(sd); - map_scriptcont(sd, sd->npc_id); + if (sd->npc_flags.storage) { + sd->npc_flags.storage = 0; + map_scriptcont(sd, sd->npc_id); + } } /*========================================== diff --git a/src/map/map.h b/src/map/map.h index b3ff052..a81d15d 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -206,6 +206,9 @@ struct map_session_data { char *npc_script,*npc_scriptroot; char *npc_stackbuf; char npc_str[256]; + struct { + unsigned storage : 1; + } npc_flags; unsigned int chatID; int attacktimer; diff --git a/src/map/script.c b/src/map/script.c index a51f65f..c5bcae1 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -376,7 +376,7 @@ struct { {buildin_gettimetick,"gettimetick","i"}, {buildin_gettime,"gettime","i"}, {buildin_gettimestr,"gettimestr","si"}, - {buildin_openstorage,"openstorage",""}, + {buildin_openstorage,"openstorage","*"}, {buildin_guildopenstorage,"guildopenstorage","*"}, {buildin_itemskill,"itemskill","iis"}, {buildin_monster,"monster","siisii*"}, @@ -3522,8 +3522,16 @@ int buildin_gettimestr(struct script_state *st) */ int buildin_openstorage(struct script_state *st) { - st->state=STOP; - storage_storageopen(script_rid2sd(st)); +// int sync = 0; +// if (st->end >= 3) sync = conv_num(st,& (st->stack->stack_data[st->start+2])); + struct map_session_data *sd=script_rid2sd(st); + +// if (sync) { + st->state=STOP; + sd->npc_flags.storage = 1; +// } else st->state = END; + + storage_storageopen(sd); return 0; } @@ -3531,6 +3539,7 @@ int buildin_guildopenstorage(struct script_state *st) { struct map_session_data *sd=script_rid2sd(st); int ret; + st->state=STOP; ret = storage_guild_storageopen(sd); push_val(st->stack,C_INT,ret); return 0; diff --git a/src/map/storage.c b/src/map/storage.c index 0158f38..ca7fa8b 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -228,8 +228,6 @@ int storage_storageget(struct map_session_data *sd,int index,int amount) nullpo_retr(0, sd); nullpo_retr(0, stor=account2storage(sd->status.account_id)); - printf("A!\n"); - if(stor->storage_status == 1) { // storage open if(index>=0 && indexstorage[index].amount) && (amount > 0) ) { //valid amount -- cgit v1.2.3-70-g09d2