diff options
author | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-03-27 18:43:31 +0000 |
---|---|---|
committer | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-03-27 18:43:31 +0000 |
commit | fd625485b8ab08aa9df7115d630076cb2ca6d9af (patch) | |
tree | 48bbfa255756163d6943a21968726bf309d354a7 /src/map/vending.c | |
parent | bf8bae03ea42ffb8684beb999ca1101e5f11fb48 (diff) | |
download | hercules-fd625485b8ab08aa9df7115d630076cb2ca6d9af.tar.gz hercules-fd625485b8ab08aa9df7115d630076cb2ca6d9af.tar.bz2 hercules-fd625485b8ab08aa9df7115d630076cb2ca6d9af.tar.xz hercules-fd625485b8ab08aa9df7115d630076cb2ca6d9af.zip |
* Added separate character state for vending (like for buyingstore), instead of vender_id != 0 (follow up to r14682, related r14713).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14762 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/vending.c')
-rw-r--r-- | src/map/vending.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/map/vending.c b/src/map/vending.c index 08e15d733..c5ead6513 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -19,16 +19,11 @@ #include <stdio.h> #include <string.h> -static int vending_nextid = 1; +static int vending_nextid = 0; /// Returns an unique vending shop id. static int vending_getuid(void) { - if(!vending_nextid) - {// wrapped around, 0 is reserved for "not vending" state on eathena - vending_nextid = 1; - } - return vending_nextid++; } @@ -39,8 +34,11 @@ void vending_closevending(struct map_session_data* sd) { nullpo_retv(sd); - sd->vender_id = 0; - clif_closevendingboard(&sd->bl,0); + if( sd->state.vending ) + { + sd->state.vending = false; + clif_closevendingboard(&sd->bl, 0); + } } /*========================================== @@ -53,7 +51,7 @@ void vending_vendinglistreq(struct map_session_data* sd, int id) if( (vsd = map_id2sd(id)) == NULL ) return; - if( vsd->vender_id == 0 ) + if( !vsd->state.vending ) return; // not vending if ( !pc_can_give_items(pc_isGM(sd)) || !pc_can_give_items(pc_isGM(vsd)) ) //check if both GMs are allowed to trade @@ -78,7 +76,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui struct map_session_data* vsd = map_id2sd(aid); nullpo_retv(sd); - if( vsd == NULL || vsd->vender_id == 0 || vsd->bl.id == sd->bl.id ) + if( vsd == NULL || !vsd->state.vending || vsd->bl.id == sd->bl.id ) return; // invalid shop if( vsd->vender_id != uid ) @@ -309,6 +307,7 @@ void vending_openvending(struct map_session_data* sd, const char* message, bool return; } + sd->state.vending = true; sd->vender_id = vending_getuid(); sd->vend_num = i; safestrncpy(sd->message, message, MESSAGE_SIZE); @@ -324,7 +323,7 @@ bool vending_search(struct map_session_data* sd, unsigned short nameid) { int i; - if( !sd->vender_id ) + if( !sd->state.vending ) {// not vending return false; } @@ -347,7 +346,7 @@ bool vending_searchall(struct map_session_data* sd, const struct s_search_store_ unsigned int idx, cidx; struct item* it; - if( !sd->vender_id ) + if( !sd->state.vending ) {// not vending return true; } |