From 7b55511e79318e0b47b6a5dd3d6e309f9df2eb5e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 13 Sep 2015 14:44:19 +0300 Subject: Add missing checks into buyingstore.c --- src/map/buyingstore.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/map/buyingstore.c') diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index a1b6e9e65..e01b8a1d8 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -14,6 +14,7 @@ #include "map/pc.h" // struct map_session_data #include "common/cbasetypes.h" #include "common/db.h" // ARR_FIND +#include "common/nullpo.h" // nullpo_* #include "common/showmsg.h" // ShowWarning #include "common/socket.h" // RBUF* #include "common/strlib.h" // safestrncpy @@ -28,6 +29,7 @@ unsigned int buyingstore_getuid(void) { bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) { + nullpo_retr(false, sd); if( !battle_config.feature_buying_store || sd->state.vending || sd->state.buyingstore || sd->state.trading || slots == 0 ) { return false; @@ -62,11 +64,11 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) return true; } - void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const uint8* itemlist, unsigned int count) { unsigned int i, weight, listidx; + nullpo_retv(sd); if (!result || count == 0) { // canceled, or no items return; @@ -178,10 +180,10 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha clif->buyingstore_entry(sd); } - void buyingstore_close(struct map_session_data* sd) { - if( sd->state.buyingstore ) + nullpo_retv(sd); + if (sd->state.buyingstore) { // invalidate data sd->state.buyingstore = false; @@ -192,11 +194,11 @@ void buyingstore_close(struct map_session_data* sd) } } - void buyingstore_open(struct map_session_data* sd, int account_id) { struct map_session_data* pl_sd; + nullpo_retv(sd); if( !battle_config.feature_buying_store || pc_istrading(sd) ) {// not allowed to sell return; @@ -229,6 +231,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int unsigned int i, weight, listidx, k; struct map_session_data* pl_sd; + nullpo_retv(sd); if( count == 0 ) {// nothing to do return; @@ -402,7 +405,8 @@ bool buyingstore_search(struct map_session_data* sd, unsigned short nameid) { unsigned int i; - if( !sd->state.buyingstore ) + nullpo_retr(false, sd); + if (!sd->state.buyingstore) {// not buying return false; } @@ -424,6 +428,8 @@ bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_st unsigned int i, idx; struct s_buyingstore_item* it; + nullpo_retr(true, sd); + if( !sd->state.buyingstore ) {// not buying return true; -- cgit v1.2.3-60-g2f50