-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:
parent
7d46012f3d
commit
b43102152f
@ -331,7 +331,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
|
|||||||
return;
|
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
|
{// buyer does not have enough space for this item
|
||||||
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
|
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
|
||||||
return;
|
return;
|
||||||
|
@ -211,14 +211,14 @@ void cashshop_buylist( struct map_session_data* sd, uint32 kafrapoints, int n, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch( pc_checkadditem( sd, nameid, quantity ) ){
|
switch( pc_checkadditem( sd, nameid, quantity ) ){
|
||||||
case ADDITEM_EXIST:
|
case CHKADDITEM_EXIST:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADDITEM_NEW:
|
case CHKADDITEM_NEW:
|
||||||
new_++;
|
new_++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADDITEM_OVERAMOUNT:
|
case CHKADDITEM_OVERAMOUNT:
|
||||||
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_OVER_PRODUCT_TOTAL_CNT );
|
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_OVER_PRODUCT_TOTAL_CNT );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -254,16 +254,16 @@ void cashshop_buylist( struct map_session_data* sd, uint32 kafrapoints, int n, u
|
|||||||
item_tmp.identify = 1;
|
item_tmp.identify = 1;
|
||||||
|
|
||||||
switch( pc_additem( sd, &item_tmp, quantity, LOG_TYPE_CASH ) ){
|
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 );
|
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_INVENTORY_WEIGHT );
|
||||||
return;
|
return;
|
||||||
case 4:
|
case ADDITEM_OVERITEM:
|
||||||
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_INVENTORY_ITEMCNT );
|
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_INVENTORY_ITEMCNT );
|
||||||
return;
|
return;
|
||||||
case 5:
|
case ADDITEM_OVERAMOUNT:
|
||||||
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_OVER_PRODUCT_TOTAL_CNT );
|
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_OVER_PRODUCT_TOTAL_CNT );
|
||||||
return;
|
return;
|
||||||
case 7:
|
case ADDITEM_STACKLIMIT:
|
||||||
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_RUNE_OVERCOUNT );
|
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_RUNE_OVERCOUNT );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -14025,10 +14025,10 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) {
|
switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) {
|
||||||
case ADDITEM_NEW:
|
case CHKADDITEM_NEW:
|
||||||
fail = ( pc_inventoryblank(sd) == 0 );
|
fail = ( pc_inventoryblank(sd) == 0 );
|
||||||
break;
|
break;
|
||||||
case ADDITEM_OVERAMOUNT:
|
case CHKADDITEM_OVERAMOUNT:
|
||||||
fail = true;
|
fail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,13 +410,7 @@ int guild_created(int account_id,int guild_id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
guild = guild_search( guild_id );
|
|
||||||
if( !guild ){ //guild not found
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sd->status.guild_id = guild_id;
|
sd->status.guild_id = guild_id;
|
||||||
sd->guild = guild;
|
|
||||||
clif_guild_created(sd,0);
|
clif_guild_created(sd,0);
|
||||||
if(battle_config.guild_emperium_check)
|
if(battle_config.guild_emperium_check)
|
||||||
pc_delitem(sd,pc_search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption
|
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);
|
i = guild_getindex(g,sd->status.account_id,sd->status.char_id);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
|
sd->guild = NULL;
|
||||||
sd->status.guild_id=0;
|
sd->status.guild_id=0;
|
||||||
sd->guild_emblem_id=0;
|
sd->guild_emblem_id=0;
|
||||||
ShowWarning("guild: check_member %d[%s] is not member\n",sd->status.account_id,sd->status.name);
|
ShowWarning("guild: check_member %d[%s] is not member\n",sd->status.account_id,sd->status.name);
|
||||||
|
@ -1335,10 +1335,10 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
|
|||||||
|
|
||||||
switch( pc_checkadditem(sd,nameid,amount) )
|
switch( pc_checkadditem(sd,nameid,amount) )
|
||||||
{
|
{
|
||||||
case ADDITEM_NEW:
|
case CHKADDITEM_NEW:
|
||||||
new_++;
|
new_++;
|
||||||
break;
|
break;
|
||||||
case ADDITEM_OVERAMOUNT:
|
case CHKADDITEM_OVERAMOUNT:
|
||||||
return 3;
|
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) )
|
switch( pc_checkadditem(sd, nameid, amount) )
|
||||||
{
|
{
|
||||||
case ADDITEM_NEW:
|
case CHKADDITEM_NEW:
|
||||||
if( pc_inventoryblank(sd) == 0 )
|
if( pc_inventoryblank(sd) == 0 )
|
||||||
return 3;
|
return 3;
|
||||||
break;
|
break;
|
||||||
case ADDITEM_OVERAMOUNT:
|
case CHKADDITEM_OVERAMOUNT:
|
||||||
return 3;
|
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) )
|
switch( pc_checkadditem(sd,nameid,amount) )
|
||||||
{
|
{
|
||||||
case ADDITEM_EXIST:
|
case CHKADDITEM_EXIST:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADDITEM_NEW:
|
case CHKADDITEM_NEW:
|
||||||
new_++;
|
new_++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADDITEM_OVERAMOUNT:
|
case CHKADDITEM_OVERAMOUNT:
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
src/map/pc.c
24
src/map/pc.c
@ -3586,26 +3586,26 @@ int pc_checkadditem(struct map_session_data *sd,int nameid,int amount)
|
|||||||
nullpo_ret(sd);
|
nullpo_ret(sd);
|
||||||
|
|
||||||
if(amount > MAX_AMOUNT)
|
if(amount > MAX_AMOUNT)
|
||||||
return ADDITEM_OVERAMOUNT;
|
return CHKADDITEM_OVERAMOUNT;
|
||||||
|
|
||||||
data = itemdb_search(nameid);
|
data = itemdb_search(nameid);
|
||||||
|
|
||||||
if(!itemdb_isstackable2(data))
|
if(!itemdb_isstackable2(data))
|
||||||
return ADDITEM_NEW;
|
return CHKADDITEM_NEW;
|
||||||
|
|
||||||
if( data->stack.inventory && amount > data->stack.amount )
|
if( data->stack.inventory && amount > data->stack.amount )
|
||||||
return ADDITEM_OVERAMOUNT;
|
return CHKADDITEM_OVERAMOUNT;
|
||||||
|
|
||||||
for(i=0;i<MAX_INVENTORY;i++){
|
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.
|
// 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(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 ) )
|
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 CHKADDITEM_OVERAMOUNT;
|
||||||
return ADDITEM_EXIST;
|
return CHKADDITEM_EXIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ADDITEM_NEW;
|
return CHKADDITEM_NEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================
|
/*==========================================
|
||||||
@ -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);
|
nullpo_retr(1, item_data);
|
||||||
|
|
||||||
if( item_data->nameid <= 0 || amount <= 0 )
|
if( item_data->nameid <= 0 || amount <= 0 )
|
||||||
return 1;
|
return ADDITEM_INVALID;
|
||||||
if( amount > MAX_AMOUNT )
|
if( amount > MAX_AMOUNT )
|
||||||
return 5;
|
return ADDITEM_OVERAMOUNT;
|
||||||
|
|
||||||
data = itemdb_search(item_data->nameid);
|
data = itemdb_search(item_data->nameid);
|
||||||
|
|
||||||
if( data->stack.inventory && amount > data->stack.amount )
|
if( data->stack.inventory && amount > data->stack.amount )
|
||||||
{// item stack limitation
|
{// item stack limitation
|
||||||
return 7;
|
return ADDITEM_STACKLIMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = data->weight*amount;
|
w = data->weight*amount;
|
||||||
if(sd->weight + w > sd->max_weight)
|
if(sd->weight + w > sd->max_weight)
|
||||||
return 2;
|
return ADDITEM_OVERWEIGHT;
|
||||||
|
|
||||||
i = MAX_INVENTORY;
|
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);
|
i = pc_search_inventory(sd,0);
|
||||||
if( i < 0 )
|
if( i < 0 )
|
||||||
return 4;
|
return ADDITEM_OVERITEM;
|
||||||
|
|
||||||
memcpy(&sd->status.inventory[i], item_data, sizeof(sd->status.inventory[0]));
|
memcpy(&sd->status.inventory[i], item_data, sizeof(sd->status.inventory[0]));
|
||||||
// clear equips field first, just in case
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================
|
/*==========================================
|
||||||
|
10
src/map/pc.h
10
src/map/pc.h
@ -914,7 +914,15 @@ int pc_readdb(void);
|
|||||||
int do_init_pc(void);
|
int do_init_pc(void);
|
||||||
void do_final_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
|
// timer for night.day
|
||||||
extern int day_timer_tid;
|
extern int day_timer_tid;
|
||||||
|
@ -6162,10 +6162,10 @@ BUILDIN_FUNC(checkweight)
|
|||||||
|
|
||||||
switch( pc_checkadditem(sd, nameid, amount) )
|
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
|
// item is already in inventory, but there is still space for the requested amount
|
||||||
break;
|
break;
|
||||||
case ADDITEM_NEW:
|
case CHKADDITEM_NEW:
|
||||||
if( itemdb_isstackable(nameid) ) {// stackable
|
if( itemdb_isstackable(nameid) ) {// stackable
|
||||||
amount2++;
|
amount2++;
|
||||||
if( slots < amount2 ) {
|
if( slots < amount2 ) {
|
||||||
@ -6181,7 +6181,7 @@ BUILDIN_FUNC(checkweight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ADDITEM_OVERAMOUNT:
|
case CHKADDITEM_OVERAMOUNT:
|
||||||
script_pushint(st,0);
|
script_pushint(st,0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -6267,10 +6267,10 @@ BUILDIN_FUNC(checkweight2)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch( pc_checkadditem(sd, nameid, amount) ) {
|
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
|
// item is already in inventory, but there is still space for the requested amount
|
||||||
break;
|
break;
|
||||||
case ADDITEM_NEW:
|
case CHKADDITEM_NEW:
|
||||||
if( itemdb_isstackable(nameid) ){// stackable
|
if( itemdb_isstackable(nameid) ){// stackable
|
||||||
amount2++;
|
amount2++;
|
||||||
if( slots < amount2 )
|
if( slots < amount2 )
|
||||||
@ -6283,7 +6283,7 @@ BUILDIN_FUNC(checkweight2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ADDITEM_OVERAMOUNT:
|
case CHKADDITEM_OVERAMOUNT:
|
||||||
fail = 1;
|
fail = 1;
|
||||||
} //end switch
|
} //end switch
|
||||||
} //end loop DO NOT break it prematurly we need to depop all stack
|
} //end loop DO NOT break it prematurly we need to depop all stack
|
||||||
|
@ -16059,7 +16059,7 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger,
|
|||||||
if( i >= MAX_SKILL_PRODUCE_DB )
|
if( i >= MAX_SKILL_PRODUCE_DB )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if( pc_checkadditem(sd, nameid, qty) == ADDITEM_OVERAMOUNT )
|
if( pc_checkadditem(sd, nameid, qty) == CHKADDITEM_OVERAMOUNT )
|
||||||
{// cannot carry the produced stuff
|
{// cannot carry the produced stuff
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -156,14 +156,14 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
|
|||||||
vending[j].amount -= amount;
|
vending[j].amount -= amount;
|
||||||
|
|
||||||
switch( pc_checkadditem(sd, vsd->status.cart[idx].nameid, 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)
|
break; //We'd add this item to the existing one (in buyers inventory)
|
||||||
case ADDITEM_NEW:
|
case CHKADDITEM_NEW:
|
||||||
new_++;
|
new_++;
|
||||||
if (new_ > blank)
|
if (new_ > blank)
|
||||||
return; //Buyer has no space in his inventory
|
return; //Buyer has no space in his inventory
|
||||||
break;
|
break;
|
||||||
case ADDITEM_OVERAMOUNT:
|
case CHKADDITEM_OVERAMOUNT:
|
||||||
return; //too many items
|
return; //too many items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user