diff options
Diffstat (limited to 'src/map/buyingstore.c')
-rw-r--r-- | src/map/buyingstore.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 85fef98aa..67018ec1f 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -4,21 +4,23 @@ #define HERCULES_CORE -#include "buyingstore.h" // struct s_buyingstore - -#include "atcommand.h" // msg_txt -#include "battle.h" // battle_config.* -#include "chrif.h" -#include "clif.h" // clif->buyingstore_* -#include "log.h" // log_pick_pc, log_zeny -#include "pc.h" // struct map_session_data -#include "../common/cbasetypes.h" -#include "../common/db.h" // ARR_FIND -#include "../common/showmsg.h" // ShowWarning -#include "../common/socket.h" // RBUF* -#include "../common/strlib.h" // safestrncpy +#include "buyingstore.h" // struct s_buyingstore + +#include "map/atcommand.h" // msg_txt +#include "map/battle.h" // battle_config.* +#include "map/chrif.h" +#include "map/clif.h" // clif-"buyingstore_* +#include "map/log.h" // log_pick_pc, log_zeny +#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 struct buyingstore_interface buyingstore_s; +struct buyingstore_interface *buyingstore; /// Returns unique buying store id unsigned int buyingstore_getuid(void) { @@ -27,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; @@ -43,7 +46,7 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) return false; } - if( map->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) { + if (map->getcell(sd->bl.m, &sd->bl, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING)) { // custom: no vending cells clif->message(sd->fd, msg_sd(sd,204)); // "You can't open a shop on this cell." return false; @@ -61,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; @@ -97,7 +100,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha return; } - if( map->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) { + if (map->getcell(sd->bl.m, &sd->bl, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING)) { // custom: no vending cells clif->message(sd->fd, msg_sd(sd,204)); // "You can't open a shop on this cell." return; @@ -177,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; @@ -191,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; @@ -228,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; @@ -353,7 +357,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int // move item pc->additem(pl_sd, &sd->status.inventory[index], amount, LOG_TYPE_BUYING_STORE); - pc->delitem(sd, index, amount, 1, 0, LOG_TYPE_BUYING_STORE); + pc->delitem(sd, index, amount, 1, DELITEM_NORMAL, LOG_TYPE_BUYING_STORE); pl_sd->buyingstore.items[listidx].amount-= amount; // pay up @@ -401,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; } @@ -423,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; |