-add enum for return value of pc_additem

-revert r17142 sd.guild assignment

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@17248 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
glighta 2013-04-11 13:28:30 +00:00
parent 7d46012f3d
commit b43102152f
10 changed files with 67 additions and 64 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -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;i<MAX_INVENTORY;i++){
// FIXME: This does not consider the checked item's cards, thus could check a wrong slot for stackability.
if(sd->status.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;
}
/*==========================================

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -156,14 +156,14 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
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
}
}