diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 8e3c21bd42..c59458035b 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -331,7 +331,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int return; } - if( pc_checkadditem(pl_sd, nameid, amount) == ADDITEM_OVERAMOUNT ) + if( pc_checkadditem(pl_sd, nameid, amount) == CHKADDITEM_OVERAMOUNT ) {// buyer does not have enough space for this item clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid); return; diff --git a/src/map/cashshop.c b/src/map/cashshop.c index a916ae3929..4d63299dab 100644 --- a/src/map/cashshop.c +++ b/src/map/cashshop.c @@ -78,7 +78,7 @@ static void cashshop_read_db_txt( void ){ if( !cashshop_parse_dbrow( str, path, lines ) ) continue; - + count++; } @@ -91,7 +91,7 @@ static void cashshop_read_db_txt( void ){ static int cashshop_read_db_sql( void ){ const char* cash_db_name[] = { item_cash_db_db, item_cash_db2_db }; int fi; - + for( fi = 0; fi < ARRAYLENGTH( cash_db_name ); ++fi ){ uint32 lines = 0, count = 0; @@ -211,14 +211,14 @@ void cashshop_buylist( struct map_session_data* sd, uint32 kafrapoints, int n, u } switch( pc_checkadditem( sd, nameid, quantity ) ){ - case ADDITEM_EXIST: + case CHKADDITEM_EXIST: break; - case ADDITEM_NEW: + case CHKADDITEM_NEW: new_++; break; - case ADDITEM_OVERAMOUNT: + case CHKADDITEM_OVERAMOUNT: clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_OVER_PRODUCT_TOTAL_CNT ); return; } @@ -254,16 +254,16 @@ void cashshop_buylist( struct map_session_data* sd, uint32 kafrapoints, int n, u item_tmp.identify = 1; switch( pc_additem( sd, &item_tmp, quantity, LOG_TYPE_CASH ) ){ - case 2: + case ADDITEM_OVERWEIGHT: clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_INVENTORY_WEIGHT ); return; - case 4: + case ADDITEM_OVERITEM: clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_INVENTORY_ITEMCNT ); return; - case 5: + case ADDITEM_OVERAMOUNT: clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_OVER_PRODUCT_TOTAL_CNT ); return; - case 7: + case ADDITEM_STACKLIMIT: clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_RUNE_OVERCOUNT ); return; } diff --git a/src/map/clif.c b/src/map/clif.c index da77028dae..f1ef2a4b2c 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -14025,10 +14025,10 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) return; switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) { - case ADDITEM_NEW: + case CHKADDITEM_NEW: fail = ( pc_inventoryblank(sd) == 0 ); break; - case ADDITEM_OVERAMOUNT: + case CHKADDITEM_OVERAMOUNT: fail = true; } @@ -16584,7 +16584,7 @@ void clif_cashshop_result( struct map_session_data *sd, uint16 item_id, uint16 r WFIFOW( sd->fd, 6 ) = result; WFIFOL( sd->fd, 8 ) = sd->cashPoints; WFIFOL( sd->fd, 12 ) = sd->kafraPoints; - WFIFOSET( sd->fd, 16 ); + WFIFOSET( sd->fd, 16 ); } /*========================================== diff --git a/src/map/guild.c b/src/map/guild.c index 1b15411c8a..a45d036a22 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -406,17 +406,11 @@ int guild_created(int account_id,int guild_id) if(sd==NULL) return 0; if(!guild_id) { - clif_guild_created(sd, 2); // Creation failure (presence of the same name Guild) + clif_guild_created(sd, 2); // Creation failure (presence of the same name Guild) return 0; } - guild = guild_search( guild_id ); - if( !guild ){ //guild not found - return -1; - } - sd->status.guild_id = guild_id; - sd->guild = guild; clif_guild_created(sd,0); if(battle_config.guild_emperium_check) pc_delitem(sd,pc_search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption @@ -471,6 +465,7 @@ int guild_check_member(struct guild *g) i = guild_getindex(g,sd->status.account_id,sd->status.char_id); if (i < 0) { + sd->guild = NULL; sd->status.guild_id=0; sd->guild_emblem_id=0; ShowWarning("guild: check_member %d[%s] is not member\n",sd->status.account_id,sd->status.name); @@ -611,7 +606,7 @@ int guild_recv_info(struct guild *sg) } } - //Occurrence of an event + //Occurrence of an event if (guild_infoevent_db->remove(guild_infoevent_db, db_i2key(sg->guild_id), &data)) { struct eventlist *ev = db_data2ptr(&data), *ev2; while(ev) { diff --git a/src/map/npc.c b/src/map/npc.c index 893a48e973..2590d2ef79 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1335,10 +1335,10 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns switch( pc_checkadditem(sd,nameid,amount) ) { - case ADDITEM_NEW: + case CHKADDITEM_NEW: new_++; break; - case ADDITEM_OVERAMOUNT: + case CHKADDITEM_OVERAMOUNT: return 3; } @@ -1443,11 +1443,11 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po switch( pc_checkadditem(sd, nameid, amount) ) { - case ADDITEM_NEW: + case CHKADDITEM_NEW: if( pc_inventoryblank(sd) == 0 ) return 3; break; - case ADDITEM_OVERAMOUNT: + case CHKADDITEM_OVERAMOUNT: return 3; } @@ -1542,14 +1542,14 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) switch( pc_checkadditem(sd,nameid,amount) ) { - case ADDITEM_EXIST: + case CHKADDITEM_EXIST: break; - case ADDITEM_NEW: + case CHKADDITEM_NEW: new_++; break; - case ADDITEM_OVERAMOUNT: + case CHKADDITEM_OVERAMOUNT: return 2; } diff --git a/src/map/pc.c b/src/map/pc.c index 1515c2a6be..d9c04a9a1c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3586,26 +3586,26 @@ int pc_checkadditem(struct map_session_data *sd,int nameid,int amount) nullpo_ret(sd); if(amount > MAX_AMOUNT) - return ADDITEM_OVERAMOUNT; + return CHKADDITEM_OVERAMOUNT; data = itemdb_search(nameid); if(!itemdb_isstackable2(data)) - return ADDITEM_NEW; + return CHKADDITEM_NEW; if( data->stack.inventory && amount > data->stack.amount ) - return ADDITEM_OVERAMOUNT; + return CHKADDITEM_OVERAMOUNT; for(i=0;istatus.inventory[i].nameid==nameid){ if( amount > MAX_AMOUNT - sd->status.inventory[i].amount || ( data->stack.inventory && amount > data->stack.amount - sd->status.inventory[i].amount ) ) - return ADDITEM_OVERAMOUNT; - return ADDITEM_EXIST; + return CHKADDITEM_OVERAMOUNT; + return CHKADDITEM_EXIST; } } - return ADDITEM_NEW; + return CHKADDITEM_NEW; } /*========================================== @@ -3810,14 +3810,14 @@ int pc_search_inventory(struct map_session_data *sd,int item_id) /*========================================== * Attempt to add a new item to inventory. * Return: - 0 = success - 1 = invalid itemid not found or negative amount - 2 = overweight - 3 = ? - 4 = no free place found - 5 = max amount reached - 6 = ? - 7 = stack limitation + 0 = success + 1 = invalid itemid not found or negative amount + 2 = overweight + 3 = ? + 4 = no free place found + 5 = max amount reached + 6 = ? + 7 = stack limitation *------------------------------------------*/ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type) { @@ -3829,20 +3829,20 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l nullpo_retr(1, item_data); if( item_data->nameid <= 0 || amount <= 0 ) - return 1; + return ADDITEM_INVALID; if( amount > MAX_AMOUNT ) - return 5; + return ADDITEM_OVERAMOUNT; data = itemdb_search(item_data->nameid); if( data->stack.inventory && amount > data->stack.amount ) {// item stack limitation - return 7; + return ADDITEM_STACKLIMIT; } w = data->weight*amount; if(sd->weight + w > sd->max_weight) - return 2; + return ADDITEM_OVERWEIGHT; i = MAX_INVENTORY; @@ -3865,7 +3865,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l { i = pc_search_inventory(sd,0); if( i < 0 ) - return 4; + return ADDITEM_OVERITEM; memcpy(&sd->status.inventory[i], item_data, sizeof(sd->status.inventory[0])); // clear equips field first, just in case @@ -3900,7 +3900,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l } } - return 0; + return ADDITEM_SUCCESS; } /*========================================== diff --git a/src/map/pc.h b/src/map/pc.h index ed187645f8..c3931b66e1 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -914,7 +914,15 @@ int pc_readdb(void); int do_init_pc(void); void do_final_pc(void); -enum {ADDITEM_EXIST,ADDITEM_NEW,ADDITEM_OVERAMOUNT}; +enum {CHKADDITEM_EXIST,CHKADDITEM_NEW,CHKADDITEM_OVERAMOUNT}; +enum { + ADDITEM_SUCCESS, + ADDITEM_INVALID, + ADDITEM_OVERWEIGHT, + ADDITEM_OVERITEM=4, + ADDITEM_OVERAMOUNT, + ADDITEM_STACKLIMIT=7 +}; // timer for night.day extern int day_timer_tid; diff --git a/src/map/script.c b/src/map/script.c index 63aea9368e..b98d797683 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6162,10 +6162,10 @@ BUILDIN_FUNC(checkweight) switch( pc_checkadditem(sd, nameid, amount) ) { - case ADDITEM_EXIST: + case CHKADDITEM_EXIST: // item is already in inventory, but there is still space for the requested amount break; - case ADDITEM_NEW: + case CHKADDITEM_NEW: if( itemdb_isstackable(nameid) ) {// stackable amount2++; if( slots < amount2 ) { @@ -6181,7 +6181,7 @@ BUILDIN_FUNC(checkweight) } } break; - case ADDITEM_OVERAMOUNT: + case CHKADDITEM_OVERAMOUNT: script_pushint(st,0); return 0; } @@ -6267,10 +6267,10 @@ BUILDIN_FUNC(checkweight2) continue; } switch( pc_checkadditem(sd, nameid, amount) ) { - case ADDITEM_EXIST: + case CHKADDITEM_EXIST: // item is already in inventory, but there is still space for the requested amount break; - case ADDITEM_NEW: + case CHKADDITEM_NEW: if( itemdb_isstackable(nameid) ){// stackable amount2++; if( slots < amount2 ) @@ -6283,7 +6283,7 @@ BUILDIN_FUNC(checkweight2) } } break; - case ADDITEM_OVERAMOUNT: + case CHKADDITEM_OVERAMOUNT: fail = 1; } //end switch } //end loop DO NOT break it prematurly we need to depop all stack diff --git a/src/map/skill.c b/src/map/skill.c index 4a823d8b60..9bc272adde 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -16059,7 +16059,7 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, if( i >= MAX_SKILL_PRODUCE_DB ) return 0; - if( pc_checkadditem(sd, nameid, qty) == ADDITEM_OVERAMOUNT ) + if( pc_checkadditem(sd, nameid, qty) == CHKADDITEM_OVERAMOUNT ) {// cannot carry the produced stuff return 0; } diff --git a/src/map/vending.c b/src/map/vending.c index 6c0c332970..47307631bd 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -59,7 +59,7 @@ void vending_vendinglistreq(struct map_session_data* sd, int id) { // GM is not allowed to trade clif_displaymessage(sd->fd, msg_txt(246)); return; - } + } sd->vended_id = vsd->vender_id; // register vending uid @@ -139,11 +139,11 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui clif_buyvending(sd, idx, amount, 2); // you can not buy, because overweight return; } - + //Check to see if cart/vend info is in sync. if( vending[j].amount > vsd->status.cart[idx].amount ) vending[j].amount = vsd->status.cart[idx].amount; - + // if they try to add packets (example: get twice or more 2 apples if marchand has only 3 apples). // here, we check cumulative amounts if( vending[j].amount < amount ) @@ -152,18 +152,18 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // not enough quantity return; } - + vending[j].amount -= amount; switch( pc_checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) { - case ADDITEM_EXIST: + case CHKADDITEM_EXIST: break; //We'd add this item to the existing one (in buyers inventory) - case ADDITEM_NEW: + case CHKADDITEM_NEW: new_++; if (new_ > blank) return; //Buyer has no space in his inventory break; - case ADDITEM_OVERAMOUNT: + case CHKADDITEM_OVERAMOUNT: return; //too many items } } @@ -199,7 +199,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui { if( vsd->vending[i].amount == 0 ) continue; - + if( cursor != i ) // speedup { vsd->vending[cursor].index = vsd->vending[i].index;