From fd625485b8ab08aa9df7115d630076cb2ca6d9af Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sun, 27 Mar 2011 18:43:31 +0000 Subject: * 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 --- src/map/vending.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/map/vending.c') 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 #include -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; } -- cgit v1.2.3-60-g2f50