summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-18 17:34:05 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-19 04:07:40 +0300
commit59da24bcf52a0aed89e63eb8593afe18b728d3f4 (patch)
tree75fd10c49764efa7f3acc64c683b086fc4bd7fc6 /src
parent287ba3febc950bb09298670209a40397b1e13666 (diff)
downloadhercules-59da24bcf52a0aed89e63eb8593afe18b728d3f4.tar.gz
hercules-59da24bcf52a0aed89e63eb8593afe18b728d3f4.tar.bz2
hercules-59da24bcf52a0aed89e63eb8593afe18b728d3f4.tar.xz
hercules-59da24bcf52a0aed89e63eb8593afe18b728d3f4.zip
Add missing checks into vending.c
Diffstat (limited to 'src')
-rw-r--r--src/map/vending.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/map/vending.c b/src/map/vending.c
index f92437cb8..80f57b9aa 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -44,14 +44,16 @@ struct vending_interface vending_s;
struct vending_interface *vending;
/// Returns an unique vending shop id.
-static inline unsigned int getid(void) {
+static inline unsigned int getid(void)
+{
return vending->next_id++;
}
/*==========================================
* Close shop
*------------------------------------------*/
-void vending_closevending(struct map_session_data* sd) {
+void vending_closevending(struct map_session_data* sd)
+{
nullpo_retv(sd);
if( sd->state.vending ) {
@@ -64,7 +66,8 @@ void vending_closevending(struct map_session_data* sd) {
/*==========================================
* Request a shop's item list
*------------------------------------------*/
-void vending_vendinglistreq(struct map_session_data* sd, unsigned int id) {
+void vending_vendinglistreq(struct map_session_data* sd, unsigned int id)
+{
struct map_session_data* vsd;
nullpo_retv(sd);
@@ -86,13 +89,15 @@ void vending_vendinglistreq(struct map_session_data* sd, unsigned int id) {
/*==========================================
* Purchase item(s) from a shop
*------------------------------------------*/
-void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, const uint8* data, int count) {
+void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, const uint8* data, int count)
+{
int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING];
int64 z;
struct s_vending vend[MAX_VENDING]; // against duplicate packets
struct map_session_data* vsd = map->id2sd(aid);
nullpo_retv(sd);
+ nullpo_retv(data);
if( vsd == NULL || !vsd->state.vending || vsd->bl.id == sd->bl.id )
return; // invalid shop
@@ -240,7 +245,8 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
* Open shop
* data := {<index>.w <amount>.w <value>.l}[count]
*------------------------------------------*/
-void vending_openvending(struct map_session_data* sd, const char* message, const uint8* data, int count) {
+void vending_openvending(struct map_session_data* sd, const char* message, const uint8* data, int count)
+{
int i, j;
int vending_skill_lvl;
nullpo_retv(sd);
@@ -309,9 +315,11 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
/// Checks if an item is being sold in given player's vending.
-bool vending_search(struct map_session_data* sd, unsigned short nameid) {
+bool vending_search(struct map_session_data* sd, unsigned short nameid)
+{
int i;
+ nullpo_retr(false, sd);
if( !sd->state.vending ) { // not vending
return false;
}
@@ -327,11 +335,14 @@ bool vending_search(struct map_session_data* sd, unsigned short nameid) {
/// Searches for all items in a vending, that match given ids, price and possible cards.
/// @return Whether or not the search should be continued.
-bool vending_searchall(struct map_session_data* sd, const struct s_search_store_search* s) {
+bool vending_searchall(struct map_session_data* sd, const struct s_search_store_search* s)
+{
int i, c, slot;
unsigned int idx, cidx;
struct item* it;
+ nullpo_retr(false, sd);
+ nullpo_retr(false, s);
if( !sd->state.vending ) // not vending
return true;
@@ -377,16 +388,20 @@ bool vending_searchall(struct map_session_data* sd, const struct s_search_store_
return true;
}
-void final(void) {
+
+void final(void)
+{
db_destroy(vending->db);
}
-void init(bool minimal) {
+void init(bool minimal)
+{
vending->db = idb_alloc(DB_OPT_BASE);
vending->next_id = 0;
}
-void vending_defaults(void) {
+void vending_defaults(void)
+{
vending = &vending_s;
vending->init = init;