Bug fixes:

-- Pin code issue after char_refac (bugreport:9027)
-- Delete date issue after char_refac (bugreport:9029)
-- Stuck when drag item from/to inventory/cart/storage if the item cannot be moved. (bugreport:8935)
Command:
-- Added @cloneequip to clone other's equipments.
-- Added @clonestat to clone other's statuses.
-- Thank Antares for the suggestion, http://rathena.org/board/topic/95076-new-atcommands-suggestion/
Permission:
-- Added 'bypass_stat_onclone' to make user who use @clonestat can bypass stat limit.
-- Change 'atcommand_enable_npc' to 'command_enable' permission to enable use command while talking with NPC. Suggested by @aleos long time ago.
Misc:
-- Correcting some checks for bAddEff bonuses.
-- Moved status point calculaiton formula to PC_STATUS_POINT_COST, removing redundancy in pc_need_status_point and pc_maxparameterincrease.
-- Added pc_is_same_equip_index function to move all item index checks, removing redundancy in some cases.
-- Some random in-source documentations.
-- Updated map_msg_idn.conf.

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
This commit is contained in:
Cydh Ramdh 2014-06-15 18:50:21 +07:00
parent 82467e14ed
commit 267d521c00
27 changed files with 837 additions and 538 deletions

View File

@ -60,6 +60,8 @@ aliases: {
itemreset: ["clearinventory"]
channel: ["main"]
autoloottype: ["aloottype"]
cloneequip: ["eqclone"]
clonestat: ["stclone"]
}
/* Commands help file */

View File

@ -31,6 +31,3 @@ ban_hack_trade: 5
// modifies @iteminfo to not display the minimum item drop rate (since it can't tell the mob level)
// modifies @whodrops to display the users' real drop rate as per renewal_drop formula
atcommand_mobinfo_type: 1
// Only group with level more than or equal this value can use atcommand while talking with NPC.
atcommand_enable_npc: 0

View File

@ -93,6 +93,7 @@ groups: (
trade or party */
can_trade: true
can_party: true
command_enable: true
}
},
{
@ -290,6 +291,7 @@ groups: (
channel_admin: true
can_trade_bounded: true
item_unconditional: false
bypass_stat_onclone: true
/* all_permission: true */
}
}

View File

@ -771,7 +771,14 @@
733: Item '%s' has not yet saved to your cart. Please re-log in order to correctly save your Vending information.
//734-899 free
// @cloneequip/@clonestat
734: Cannot clone your own %s.
735: Please enter char_id or \"char name\".
736: Cannot clone %s from this player.
737: '%s' (%d) cannot be cloned, limit (%d).
738: Clone '%s' is done.
//739-899 free
//------------------------------------
// More atcommands message

View File

@ -392,8 +392,8 @@
377: -- Pemain %s telah menolak permintaan duel --
//lain-lain
378: Eleanor sekarang dalam mode %s.
379: Penggunaan item gagal. [%s] sedang cooling down. Tunggu %.1f menit.
380: Penggunaan item gagal. [%s] sedang cooling down. Tunggu %d detik.
379: Dapat digunakan setelah %.1f menit.
380: Dapat digunakan setelah %d detik.
381: Penggunaan skill gagal. [%s] membutuhkan %dx %s.
382: Kamu terlalu dekat dengan batu atau emperium untuk menggunakan skill ini.
383: Kamu tidak dapat membuat save point di instance
@ -516,7 +516,10 @@
515: Intance kamu sudha dimuat ulang.
516: Database Instance sudah dimuat ulang.
//517~534: kosong
// @auction
517: Sistem Auction tidak tersedia.
//518~534: kosong
// Pesan yang berhubungan dengan deteksi Bot (Saat ini belum diimplementasikan)
535: Kemungkinan BOT (99%%) atau client yang digunakan sudah dimodifikasi '%s' (akun: %d, char_id: %d). Pemain ini bisa melihat nama kamu saat kamu sedang tidak terlihat.
@ -748,7 +751,16 @@
732: Item tidak dapat dibuka ketika inventory penuh.
//733-899 kosong
733: Item '%s' belum tersimpan di gerobak. Harap masuk kembali untuk dapat menyimpan informasi vending dengan benar.
// @cloneequip/@clonestat
734: Tidak dapat mengkloning %s diri sendiri.
735: Harap masukkan id_karakter atau \"nama karakter\".
736: Tidak dapat mengkloning %s dari player ini.
737: Status '%s' (%d) tidak dapat ditiru, batas status (%d).
738: Kloning '%s' selesai.
//739-899 kosong
//------------------------------------
// Pesan dalam perintah atcommand

View File

@ -1089,6 +1089,20 @@ Give or remove a cart to a player and also change the cart skin based on ID:
---------------------------------------
@cloneequip <char_id>
@cloneequip "<char name>"
'Clone' other player's equipments then equip them.
---------------------------------------
@clonestat <char_id>
@clonestat "<char name>"
'Clone' other player's stats.
---------------------------------------
==============================
| 5. Administrative Commands |
==============================

View File

@ -187,3 +187,15 @@ Allows player to use the client command /check (displays character status).
Allows player to use the client command /changemaptype.
---------------------------------------
*command_enable
Enable to use atcommand while talking with NPC.
---------------------------------------
*bypass_stat_onclone
Bypass max parameter limit while using @clonestat
---------------------------------------

View File

@ -68,15 +68,15 @@ struct Schema_Config {
};
extern struct Schema_Config schema_config;
// Pincode system
/// Pincode system
enum pincode_state {
PINCODE_OK = 0,
PINCODE_ASK,
PINCODE_NOTSET,
PINCODE_EXPIRED,
PINCODE_NEW,
PINCODE_PASSED,
PINCODE_WRONG,
PINCODE_OK = 0,
PINCODE_ASK = 1,
PINCODE_NOTSET = 2,
PINCODE_EXPIRED = 3,
PINCODE_NEW = 4,
PINCODE_PASSED = 7,
PINCODE_WRONG = 8,
PINCODE_MAXSTATE
};
struct Pincode_Config {

View File

@ -323,7 +323,7 @@ void chclif_char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_d
WFIFOW(fd,0) = 0x828;
WFIFOL(fd,2) = char_id;
WFIFOL(fd,6) = result;
WFIFOL(fd,10) = TOL(delete_date);
WFIFOL(fd,10) = TOL(delete_date-time(NULL));
WFIFOSET(fd,14);
}

View File

@ -1198,7 +1198,8 @@ ACMD_FUNC(heal)
ACMD_FUNC(item)
{
char item_name[100];
int number = 0, flag = 0, bound = BOUND_NONE;
int number = 0, bound = BOUND_NONE;
char flag = 0;
struct item item_tmp;
struct item_data *item_data[10];
int get_count, i, j=0;
@ -1315,8 +1316,8 @@ ACMD_FUNC(item2)
item_id = item_data->nameid;
if (item_id > 500) {
int flag = 0;
int loop, get_count, i;
char flag = 0;
loop = 1;
get_count = number;
if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
@ -2192,12 +2193,9 @@ ACMD_FUNC(refine)
int i;
if ((i = sd->equip_index[j]) < 0)
continue;
if(j == EQI_AMMO) continue;
if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
if(j == EQI_AMMO)
continue;
if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
continue;
if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
continue;
if(position && !(sd->status.inventory[i].equip & position))
@ -2261,7 +2259,7 @@ ACMD_FUNC(produce)
item_id = item_data->nameid;
if (itemdb_isequip2(item_data)) {
int flag = 0;
char flag = 0;
if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
attribute = ATTRIBUTE_NORMAL;
if (star < MIN_STAR || star > MAX_STAR)
@ -5633,7 +5631,7 @@ ACMD_FUNC(skilltree)
// Hand a ring with partners name on it to this char
void getring (struct map_session_data* sd)
{
int flag;
char flag = 0;
unsigned short item_id;
struct item item_tmp;
item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
@ -9476,6 +9474,172 @@ ACMD_FUNC(costume) {
return 0;
}
/**
* Clone other player's equipments
* Usage: @cloneequip <char_id or "char name">
* http://rathena.org/board/topic/95076-new-atcommands-suggestion/
* @author [Cydh], [Antares]
*/
ACMD_FUNC(cloneequip) {
struct map_session_data *pl_sd;
int char_id = 0;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if( !message || !*message || (sscanf(message, "%d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
return -1;
}
if (char_id)
pl_sd = map_charid2sd(char_id);
else
pl_sd = map_nick2sd(atcmd_output);
if (!pl_sd) {
clif_displaymessage(fd, msg_txt(sd, 3));
return -1;
}
if (sd == pl_sd) {
memset(atcmd_output, '\0', sizeof(atcmd_output));
sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
clif_displaymessage(fd, atcmd_output);
return -1;
}
if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
memset(atcmd_output, '\0', sizeof(atcmd_output));
sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
clif_displaymessage(fd, atcmd_output);
return -1;
}
else {
int8 i;
for (i = 0; i < EQI_MAX; i++) {
int8 idx;
char flag = 0;
struct item tmp_item;
if ((idx = pl_sd->equip_index[i]) < 0)
continue;
if (i == EQI_AMMO)
continue;
if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
continue;
tmp_item = pl_sd->status.inventory[idx];
if (itemdb_isspecial(tmp_item.card[0]))
memset(tmp_item.card, 0, sizeof(tmp_item.card));
tmp_item.bound = 0;
tmp_item.expire_time = 0;
tmp_item.unique_id = 0;
tmp_item.favorite = 0;
tmp_item.amount = 1;
if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
clif_additem(sd, 0, 0, flag);
else
pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
}
}
memset(atcmd_output, '\0', sizeof(atcmd_output));
sprintf(atcmd_output, msg_txt(sd, 738), "status");
clif_displaymessage(fd, atcmd_output);
return 0;
}
/**
* Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
* Usage: @clonestat <char_id or "char name">
* http://rathena.org/board/topic/95076-new-atcommands-suggestion/
* @author [Cydh], [Antares]
*/
ACMD_FUNC(clonestat) {
struct map_session_data *pl_sd;
int char_id = 0;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if( !message || !*message || (sscanf(message, "%d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
return -1;
}
if (char_id)
pl_sd = map_charid2sd(char_id);
else
pl_sd = map_nick2sd(atcmd_output);
if (!pl_sd) {
clif_displaymessage(fd, msg_txt(sd, 3));
return -1;
}
if (sd == pl_sd) {
memset(atcmd_output, '\0', sizeof(atcmd_output));
sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
clif_displaymessage(fd, atcmd_output);
return -1;
}
if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
memset(atcmd_output, '\0', sizeof(atcmd_output));
sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
clif_displaymessage(fd, atcmd_output);
return -1;
}
else {
uint8 i;
short max_status[6];
pc_resetstate(sd);
if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
else {
max_status[0] = pc_maxparameter(sd, PARAM_STR);
max_status[1] = pc_maxparameter(sd, PARAM_AGI);
max_status[2] = pc_maxparameter(sd, PARAM_VIT);
max_status[3] = pc_maxparameter(sd, PARAM_INT);
max_status[4] = pc_maxparameter(sd, PARAM_DEX);
max_status[5] = pc_maxparameter(sd, PARAM_LUK);
}
#define clonestat_check(cmd,stat)\
{\
memset(atcmd_output, '\0', sizeof(atcmd_output));\
if (pl_sd->status.cmd > max_status[(stat)]) {\
sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
clif_displaymessage(fd, atcmd_output);\
sd->status.cmd = max_status[(stat)];\
}\
else\
sd->status.cmd = pl_sd->status.cmd;\
}
clonestat_check(str, PARAM_STR);
clonestat_check(agi, PARAM_AGI);
clonestat_check(vit, PARAM_VIT);
clonestat_check(int_, PARAM_INT);
clonestat_check(dex, PARAM_DEX);
clonestat_check(luk, PARAM_LUK);
for (i = 0; i < PARAM_MAX; i++) {
clif_updatestatus(sd, SP_STR + i);
clif_updatestatus(sd, SP_USTR + i);
}
status_calc_pc(sd, SCO_FORCE);
}
memset(atcmd_output, '\0', sizeof(atcmd_output));
sprintf(atcmd_output, msg_txt(sd, 738), "status");
clif_displaymessage(fd, atcmd_output);
#undef clonestat_check
return 0;
}
#include "../custom/atcommand.inc"
/**
@ -9764,6 +9928,8 @@ void atcommand_basecommands(void) {
#endif
ACMD_DEF(fullstrip),
ACMD_DEF(costume),
ACMD_DEF(cloneequip),
ACMD_DEF(clonestat),
};
AtCommandInfo* atcommand;
int i;

View File

@ -7822,7 +7822,6 @@ static const struct _battle_data {
{ "feature.autotrade_sit", &battle_config.feature_autotrade_sit, 1, 0, 1, },
{ "disp_serverbank_msg", &battle_config.disp_serverbank_msg, 0, 0, 1, },
{ "warg_can_falcon", &battle_config.warg_can_falcon, 0, 0, 1, },
{ "atcommand_enable_npc", &battle_config.atcommand_enable_npc, 0, 0, 100, },
{ "path_blown_halt", &battle_config.path_blown_halt, 1, 0, 1, },
{ "rental_mount_speed_boost", &battle_config.rental_mount_speed_boost, 25, 0, 100, },
{ "feature.warp_suggestions", &battle_config.warp_suggestions_enabled, 0, 0, 1, },

View File

@ -532,7 +532,6 @@ extern struct Battle_Config
int disp_serverbank_msg;
int warg_can_falcon;
int atcommand_enable_npc;
int path_blown_halt;
int rental_mount_speed_boost;
int warp_suggestions_enabled;

View File

@ -2186,7 +2186,7 @@ static void clif_addcards(unsigned char* buf, struct item* item)
/// 029a <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B <expire time>.L (ZC_ITEM_PICKUP_ACK2)
/// 02d4 <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B <expire time>.L <bindOnEquipType>.W (ZC_ITEM_PICKUP_ACK3)
/// 0990 <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.L <item type>.B <result>.B <expire time>.L <bindOnEquipType>.W (ZC_ITEM_PICKUP_ACK_V5)
void clif_additem(struct map_session_data *sd, int n, int amount, int fail)
void clif_additem(struct map_session_data *sd, int n, int amount, unsigned char fail)
{
int fd, header, offs=0;
#if PACKETVER < 20061218
@ -11094,10 +11094,7 @@ void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
return;
if (!pc_iscarton(sd))
return;
if ((flag = pc_putitemtocart(sd,RFIFOW(fd,info->pos[0])-2,RFIFOL(fd,info->pos[1])))) {
clif_dropitem(sd,RFIFOW(fd,info->pos[0])-2,0);
clif_cart_additem_ack(sd,(flag==1)?ADDITEM_TO_CART_FAIL_WEIGHT:ADDITEM_TO_CART_FAIL_COUNT);
}
pc_putitemtocart(sd,RFIFOW(fd,info->pos[0])-2,RFIFOL(fd,info->pos[1]));
}
@ -11108,8 +11105,7 @@ void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
if (!pc_iscarton(sd))
return;
pc_getitemfromcart(sd,RFIFOW(fd,info->pos[0])-2,
RFIFOL(fd,info->pos[1]));
pc_getitemfromcart(sd,RFIFOW(fd,info->pos[0])-2,RFIFOL(fd,info->pos[1]));
}

View File

@ -428,7 +428,7 @@ void clif_scriptinput(struct map_session_data *sd, int npcid); //self
void clif_scriptinputstr(struct map_session_data *sd, int npcid); // self
void clif_cutin(struct map_session_data* sd, const char* image, int type); //self
void clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color); //self
void clif_additem(struct map_session_data *sd, int n, int amount, int fail); // self
void clif_additem(struct map_session_data *sd, int n, int amount, unsigned char fail); // self
void clif_dropitem(struct map_session_data *sd,int n,int amount); //self
void clif_delitem(struct map_session_data *sd,int n,int amount, short reason); //self
void clif_updatestatus(struct map_session_data *sd,int type); //self

View File

@ -228,7 +228,7 @@ static void itemdb_pc_get_itemgroup_sub(struct map_session_data *sd, struct s_it
}
// Do loop for non-stackable item
for (i = 0; i < data->amount; i++) {
char flag;
char flag = 0;
if ((flag = pc_additem(sd, &tmp, tmp.amount, LOG_TYPE_SCRIPT)))
clif_additem(sd, 0, 0, flag);
else if (!flag && data->isAnnounced) { ///TODO: Move this broadcast to proper behavior (it should on at different packet)

View File

@ -127,7 +127,7 @@ enum MOBID {
//First Jobs
//Note the oddity of the novice:
//Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type, too...
enum {
enum e_mapid {
//Novice And 1-1 Jobs
MAPID_NOVICE = 0x0,
MAPID_SWORDMAN,

File diff suppressed because it is too large Load Diff

View File

@ -216,7 +216,7 @@ struct map_session_data {
unsigned int hold_recalc : 1;
unsigned int banking : 1; //1 when we using the banking system 0 when closed
unsigned int hpmeter_visible : 1;
bool disable_atcommand_on_npc; //Prevent to use atcommand while talking with NPC [Kichi]
unsigned disable_atcommand_on_npc : 1; //Prevent to use atcommand while talking with NPC [Kichi]
} state;
struct {
unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
@ -308,7 +308,7 @@ struct map_session_data {
int subclass[CLASS_MAX];
int subrace2[RC2_MAX];
int subsize[SZ_MAX];
int reseff[SC_COMMON_MAX-SC_COMMON_MIN+1];
short reseff[SC_COMMON_MAX-SC_COMMON_MIN+1]; //TODO: Make this for all SC?
int weapon_coma_ele[ELE_NONE];
int weapon_coma_race[RC_MAX];
int weapon_coma_class[CLASS_MAX];
@ -334,7 +334,7 @@ struct map_session_data {
short hp_gain_race_attack[RC_MAX];
// zeroed arrays end here.
// zeroed structures start here
struct s_autospell autospell[15], autospell2[15], autospell3[15];
struct s_autospell autospell[MAX_PC_BONUS], autospell2[MAX_PC_BONUS], autospell3[MAX_PC_BONUS];
struct s_addeffect addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS];
struct s_addeffectonskill addeff3[MAX_PC_BONUS];
@ -606,6 +606,8 @@ struct map_session_data {
/* Expiration Timer ID */
int expiration_tid;
time_t expiration_time;
short last_addeditem_index; /// Index of latest item added
};
struct eri *pc_sc_display_ers; /// Player's SC display table
@ -813,22 +815,22 @@ bool pc_can_use_command(struct map_session_data *sd, const char *command, AtComm
#define pc_has_permission(sd, permission) ( ((sd)->permissions&permission) != 0 )
bool pc_should_log_commands(struct map_session_data *sd);
int pc_setrestartvalue(struct map_session_data *sd,int type);
int pc_makesavestatus(struct map_session_data *);
void pc_setrestartvalue(struct map_session_data *sd, char type);
void pc_makesavestatus(struct map_session_data *sd);
void pc_respawn(struct map_session_data* sd, clr_type clrtype);
int pc_setnewpc(struct map_session_data*,int,int,int,unsigned int,int,int);
void pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int login_id1, unsigned int client_tick, int sex, int fd);
bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers);
void pc_authfail(struct map_session_data *);
int pc_reg_received(struct map_session_data *sd);
void pc_authfail(struct map_session_data *sd);
void pc_reg_received(struct map_session_data *sd);
void pc_close_npc(struct map_session_data *sd,int flag);
int pc_close_npc_timer(int tid, unsigned int tick, int id, intptr_t data);
int pc_isequip(struct map_session_data *sd,int n);
bool pc_isequip(struct map_session_data *sd,int n);
int pc_equippoint(struct map_session_data *sd,int n);
int pc_setinventorydata(struct map_session_data *sd);
void pc_setinventorydata(struct map_session_data *sd);
int pc_get_skillcooldown(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv);
int pc_checkskill(struct map_session_data *sd,uint16 skill_id);
uint8 pc_checkskill(struct map_session_data *sd,uint16 skill_id);
short pc_checkequip(struct map_session_data *sd,int pos);
bool pc_checkequip2(struct map_session_data *sd, unsigned short nameid, int min, int max);
@ -837,25 +839,25 @@ int pc_expiration_timer(int tid, unsigned int tick, int id, intptr_t data);
int pc_global_expiration_timer(int tid, unsigned tick, int id, intptr_t data);
void pc_expire_check(struct map_session_data *sd);
int pc_calc_skilltree(struct map_session_data *sd);
void pc_calc_skilltree(struct map_session_data *sd);
int pc_calc_skilltree_normalize_job(struct map_session_data *sd);
void pc_clean_skilltree(struct map_session_data *sd);
#define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp)
#define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp)
int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype);
char pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype);
void pc_setsavepoint(struct map_session_data *sd, short mapindex,int x,int y);
int pc_randomwarp(struct map_session_data *sd,clr_type type);
int pc_memo(struct map_session_data* sd, int pos);
char pc_randomwarp(struct map_session_data *sd,clr_type type);
bool pc_memo(struct map_session_data* sd, int pos);
int pc_checkadditem(struct map_session_data*, unsigned short, int);
int pc_inventoryblank(struct map_session_data*);
char pc_checkadditem(struct map_session_data *sd, unsigned short nameid, int amount);
uint8 pc_inventoryblank(struct map_session_data *sd);
short pc_search_inventory(struct map_session_data *sd, unsigned short nameid);
int pc_payzeny(struct map_session_data*,int, enum e_log_pick_type type, struct map_session_data*);
char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_pick_type log_type);
int pc_getzeny(struct map_session_data*,int, enum e_log_pick_type, struct map_session_data*);
int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type);
char pc_payzeny(struct map_session_data *sd, int zeny, enum e_log_pick_type type, struct map_session_data *tsd);
char pc_additem(struct map_session_data *sd, struct item *item, int amount, e_log_pick_type log_type);
char pc_getzeny(struct map_session_data *sd, int zeny, enum e_log_pick_type type, struct map_session_data *tsd);
char pc_delitem(struct map_session_data *sd, int n, int amount, int type, short reason, e_log_pick_type log_type);
//Bound items
int pc_bound_chk(TBL_PC *sd,enum bound_type type,int *idxlist);
@ -864,32 +866,32 @@ int pc_bound_chk(TBL_PC *sd,enum bound_type type,int *idxlist);
int pc_paycash( struct map_session_data *sd, int price, int points, e_log_pick_type type );
int pc_getcash( struct map_session_data *sd, int cash, int points, e_log_pick_type type );
int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type);
int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type);
int pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
unsigned char pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type);
void pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type);
void pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
void pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
int pc_takeitem(struct map_session_data*,struct flooritem_data*);
int pc_dropitem(struct map_session_data*,int,int);
bool pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem);
bool pc_dropitem(struct map_session_data *sd,int n,int amount);
bool pc_isequipped(struct map_session_data *sd, unsigned short nameid);
bool pc_can_Adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd );
bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
int pc_updateweightstatus(struct map_session_data *sd);
void pc_updateweightstatus(struct map_session_data *sd);
bool pc_addautobonus(struct s_autobonus *bonus,char max,const char *script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill);
void pc_exeautobonus(struct map_session_data* sd,struct s_autobonus *bonus);
int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data);
void pc_delautobonus(struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore);
int pc_bonus(struct map_session_data*,int,int);
int pc_bonus2(struct map_session_data *sd,int,int,int);
int pc_bonus3(struct map_session_data *sd,int,int,int,int);
int pc_bonus4(struct map_session_data *sd,int,int,int,int,int);
int pc_bonus5(struct map_session_data *sd,int,int,int,int,int,int);
int pc_skill(struct map_session_data* sd, int id, int level, int flag);
void pc_bonus(struct map_session_data *sd, int type, int val);
void pc_bonus2(struct map_session_data *sd, int type, int type2, int val);
void pc_bonus3(struct map_session_data *sd, int type, int type2, int type3, int val);
void pc_bonus4(struct map_session_data *sd, int type, int type2, int type3, int type4, int val);
void pc_bonus5(struct map_session_data *sd, int type, int type2, int type3, int type4, int type5, int val);
int pc_skill(struct map_session_data *sd, int id, int level, int flag);
int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip);
@ -923,7 +925,7 @@ int pc_resetstate(struct map_session_data*);
int pc_resetskill(struct map_session_data*, int);
int pc_resetfeel(struct map_session_data*);
int pc_resethate(struct map_session_data*);
bool pc_equipitem(struct map_session_data*,int,int);
bool pc_equipitem(struct map_session_data *sd, short n, int req_pos);
bool pc_unequipitem(struct map_session_data*,int,int);
void pc_checkitem(struct map_session_data*);
void pc_check_available_item(struct map_session_data *sd);
@ -1037,14 +1039,19 @@ void pc_readdb(void);
void do_init_pc(void);
void do_final_pc(void);
enum {CHKADDITEM_EXIST,CHKADDITEM_NEW,CHKADDITEM_OVERAMOUNT};
enum {
enum e_chkitem_result {
CHKADDITEM_EXIST,
CHKADDITEM_NEW,
CHKADDITEM_OVERAMOUNT
};
enum e_additem_result {
ADDITEM_SUCCESS,
ADDITEM_INVALID,
ADDITEM_OVERWEIGHT,
ADDITEM_OVERITEM=4,
ADDITEM_OVERITEM = 4,
ADDITEM_OVERAMOUNT,
ADDITEM_STACKLIMIT=7
ADDITEM_STACKLIMIT = 7
};
// timer for night.day
@ -1055,7 +1062,7 @@ int map_night_timer(int tid, unsigned int tick, int id, intptr_t data); // by [y
// Rental System
void pc_inventory_rentals(struct map_session_data *sd);
int pc_inventory_rental_clear(struct map_session_data *sd);
void pc_inventory_rental_clear(struct map_session_data *sd);
void pc_inventory_rental_add(struct map_session_data *sd, int seconds);
void pc_rental_expire(struct map_session_data *sd, int i);
@ -1071,8 +1078,8 @@ void pc_itemcd_do(struct map_session_data *sd, bool load);
int pc_load_combo(struct map_session_data *sd);
int pc_add_talisman(struct map_session_data *sd,int interval,int max,int type);
int pc_del_talisman(struct map_session_data *sd,int count,int type);
void pc_add_talisman(struct map_session_data *sd,int interval,int max,int type);
void pc_del_talisman(struct map_session_data *sd,int count,int type);
void pc_baselevelchanged(struct map_session_data *sd);
@ -1096,6 +1103,8 @@ void pc_itemgrouphealrate_clear(struct map_session_data *sd);
short pc_get_itemgroup_bonus(struct map_session_data* sd, unsigned short nameid);
short pc_get_itemgroup_bonus_group(struct map_session_data* sd, uint16 group_id);
bool pc_is_same_equip_index(enum equip_index eqi, int *equip_index, int8 index);
#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
int pc_level_penalty_mod(struct map_session_data *sd, int mob_level, uint32 mob_class, int type);
#endif

View File

@ -46,6 +46,8 @@ enum e_pc_permission {
PC_PERM_CHANNEL_ADMIN = 0x00200000,
PC_PERM_TRADE_BOUNDED = 0x00400000,
PC_PERM_ITEM_UNCONDITIONAL = 0x00800000,
PC_PERM_ENABLE_COMMAND = 0x01000000,
PC_PERM_BYPASS_STAT_ONCLONE = 0x02000000,
//.. add other here
PC_PERM_ALLPERMISSION = 0xFFFFFFFF,
};
@ -78,6 +80,8 @@ static const struct {
{ "channel_admin", PC_PERM_CHANNEL_ADMIN },
{ "can_trade_bounded", PC_PERM_TRADE_BOUNDED },
{ "item_unconditional", PC_PERM_ITEM_UNCONDITIONAL },
{ "command_enable",PC_PERM_ENABLE_COMMAND },
{ "bypass_stat_onclone",PC_PERM_BYPASS_STAT_ONCLONE },
{ "all_permission", PC_PERM_ALLPERMISSION },
};

View File

@ -293,7 +293,7 @@ static int pet_performance(struct map_session_data *sd, struct pet_data *pd)
static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
{
struct item tmp_item;
int flag;
unsigned char flag = 0;
pet_lootitem_drop(pd,sd);
memset(&tmp_item,0,sizeof(tmp_item));
@ -552,7 +552,8 @@ int pet_get_egg(int account_id,int pet_id,int flag)
{ //This function is invoked when a new pet has been created, and at no other time!
struct map_session_data *sd;
struct item tmp_item;
int i=0,ret=0;
int i=0;
unsigned char ret = 0;
if(flag)
return 0;
@ -706,7 +707,8 @@ int pet_equipitem(struct map_session_data *sd,int index)
static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd)
{
struct item tmp_item;
unsigned short nameid, flag;
unsigned short nameid;
unsigned char flag = 0;
if(pd->pet.equip == 0)
return 1;
@ -1003,7 +1005,7 @@ static int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data
int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
{
int i,flag=0;
int i;
struct item_drop_list *dlist;
struct item_drop *ditem;
struct item *it;
@ -1021,6 +1023,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
for(i=0;i<pd->loot->count;i++) {
it = &pd->loot->item[i];
if(sd){
unsigned char flag = 0;
if((flag = pc_additem(sd,it,it->amount,LOG_TYPE_PICKDROP_PLAYER))){
clif_additem(sd,0,0,flag);
ditem = ers_alloc(item_drop_ers, struct item_drop);

View File

@ -3136,7 +3136,6 @@ struct script_state* script_alloc_state(struct script_code* script, int pos, int
st->oid = oid;
st->sleep.timer = INVALID_TIMER;
st->npc_item_flag = battle_config.item_enabled_npc;
st->atcommand_enable_npc = battle_config.atcommand_enable_npc;
return st;
}
@ -3761,7 +3760,7 @@ static void script_attach_state(struct script_state* st)
sd->st = st;
sd->npc_id = st->oid;
sd->npc_item_flag = st->npc_item_flag; // load default.
sd->state.disable_atcommand_on_npc = (pc_get_group_level(sd) >= st->atcommand_enable_npc) ? false : true;
sd->state.disable_atcommand_on_npc = !pc_has_permission(sd, PC_PERM_ENABLE_COMMAND);
#ifdef SECURE_NPCTIMEOUT
if( sd->npc_idle_timer == INVALID_TIMER )
sd->npc_idle_timer = add_timer(gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
@ -6416,10 +6415,11 @@ BUILDIN_FUNC(checkweight2){
*------------------------------------------*/
BUILDIN_FUNC(getitem)
{
int nameid,amount,get_count,i,flag = 0;
int nameid,amount,get_count,i;
struct item it;
TBL_PC *sd;
struct script_data *data;
unsigned char flag = 0;
data=script_getdata(st,2);
get_val(st,data);
@ -6506,11 +6506,12 @@ BUILDIN_FUNC(getitem)
*------------------------------------------*/
BUILDIN_FUNC(getitem2)
{
int nameid, amount, get_count, i, flag = 0;
int nameid, amount, get_count, i;
int iden, ref, attr, c1, c2, c3, c4;
char bound = BOUND_NONE;
struct item_data *item_data;
struct item item_tmp;
unsigned char flag = 0;
TBL_PC *sd;
struct script_data *data;
@ -6555,7 +6556,7 @@ BUILDIN_FUNC(getitem2)
c3=(short)script_getnum(st,9);
c4=(short)script_getnum(st,10);
if(nameid<0) { // Invalide nameid
if(nameid < 0) { // Invalid nameid
nameid = -nameid;
flag = 1;
}
@ -6623,7 +6624,7 @@ BUILDIN_FUNC(rentitem) {
struct item it;
int seconds;
unsigned short nameid = 0;
int flag;
unsigned char flag = 0;
data = script_getdata(st,2);
get_val(st,data);
@ -6681,8 +6682,9 @@ BUILDIN_FUNC(rentitem2) {
struct script_data *data;
struct item it;
struct item_data *id;
int seconds, flag;
int seconds;
unsigned short nameid = 0;
unsigned char flag = 0;
int iden,ref,attr,c1,c2,c3,c4;
data = script_getdata(st,2);
@ -11913,7 +11915,7 @@ BUILDIN_FUNC(successremovecards) {
for( c = sd->inventory_data[i]->slot - 1; c >= 0; --c ) {
if( sd->status.inventory[i].card[c] && itemdb_type(sd->status.inventory[i].card[c]) == IT_CARD ) {// extract this card from the item
int flag;
unsigned char flag = 0;
struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
cardflag = 1;
@ -11928,7 +11930,7 @@ BUILDIN_FUNC(successremovecards) {
}
if(cardflag == 1) {//if card was remove remplace item with no card
int flag;
unsigned char flag = 0;
struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
@ -11980,7 +11982,7 @@ BUILDIN_FUNC(failedremovecards) {
cardflag = 1;
if(typefail == 2) {// add cards to inventory, clear
int flag;
unsigned char flag = 0;
struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
@ -12001,7 +12003,7 @@ BUILDIN_FUNC(failedremovecards) {
pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
}
if(typefail == 1){ // destroy the card
int flag;
unsigned char flag = 0;
struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
@ -13971,10 +13973,10 @@ BUILDIN_FUNC(isequippedcnt)
for (j=0; j<EQI_MAX; j++) {
int index;
index = sd->equip_index[j];
if(index < 0) continue;
if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index) continue;
if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index) continue;
if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index)) continue;
if(index < 0)
continue;
if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, index))
continue;
if(!sd->inventory_data[index])
continue;
@ -14028,10 +14030,10 @@ BUILDIN_FUNC(isequipped)
flag = 0;
for (j=0; j<EQI_MAX; j++) {
index = sd->equip_index[j];
if(index < 0) continue;
if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index) continue;
if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index) continue;
if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index)) continue;
if(index < 0)
continue;
if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index))
continue;
if(!sd->inventory_data[index])
continue;
@ -18000,7 +18002,7 @@ BUILDIN_FUNC(checkre)
/* getrandgroupitem <group_id>,<quantity>{,<sub_group>} */
BUILDIN_FUNC(getrandgroupitem) {
TBL_PC* sd;
int i, get_count = 0, flag;
int i, get_count = 0;
unsigned short nameid;
uint16 group = script_getnum(st,2), qty = script_getnum(st,3);
uint8 sub_group = script_getnum(st,4);
@ -18038,6 +18040,7 @@ BUILDIN_FUNC(getrandgroupitem) {
for (i = 0; i < get_count; i++) {
// if not pet egg
if (!pet_create_egg(sd, nameid)) {
unsigned char flag = 0;
if ((flag = pc_additem(sd,&item_tmp,item_tmp.amount,LOG_TYPE_SCRIPT))) {
clif_additem(sd,0,0,flag);
if (pc_candrop(sd,&item_tmp))
@ -18752,7 +18755,7 @@ BUILDIN_FUNC(enable_command) {
if (!sd)
return SCRIPT_CMD_FAILURE;
sd->state.disable_atcommand_on_npc = false;
sd->state.disable_atcommand_on_npc = 0;
return SCRIPT_CMD_SUCCESS;
}
@ -18763,7 +18766,7 @@ BUILDIN_FUNC(disable_command) {
if (!sd)
return SCRIPT_CMD_FAILURE;
sd->state.disable_atcommand_on_npc = true;
sd->state.disable_atcommand_on_npc = 1;
return SCRIPT_CMD_SUCCESS;
}

View File

@ -135,7 +135,6 @@ struct script_state {
unsigned npc_item_flag : 1;
unsigned mes_active : 1; // Store if invoking character has a NPC dialog box open.
unsigned char* funcname; // Stores the current running function name
uint8 atcommand_enable_npc;
};
struct script_reg {

View File

@ -6869,7 +6869,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case TF_PICKSTONE:
if(sd) {
int eflag;
unsigned char eflag;
struct item item_tmp;
struct block_list tbl;
clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
@ -18075,7 +18075,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, unsigned sh
tmp_item.nameid = compensation[i];
tmp_item.amount = qty;
tmp_item.identify = 1;
if( pc_additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE) ) {
if( (flag = pc_additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE)) ) {
clif_additem(sd,0,0,flag);
map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
@ -18101,7 +18101,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, unsigned sh
int skill_arrow_create (struct map_session_data *sd, unsigned short nameid)
{
int i,j,flag,index=-1;
int i, j, index =- 1;
struct item tmp_item;
nullpo_ret(sd);
@ -18120,6 +18120,7 @@ int skill_arrow_create (struct map_session_data *sd, unsigned short nameid)
pc_delitem(sd,j,1,0,0,LOG_TYPE_PRODUCE);
for(i=0;i<MAX_ARROW_RESOURCE;i++) {
unsigned char flag = 0;
memset(&tmp_item,0,sizeof(tmp_item));
tmp_item.identify = 1;
tmp_item.nameid = skill_arrow_db[index].cre_id[i];
@ -18383,7 +18384,7 @@ int skill_elementalanalysis(struct map_session_data* sd, int n, uint16 skill_lv,
tmp_item.identify = 1;
if( tmp_item.amount ) {
int flag = pc_additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_CONSUME);
unsigned char flag = pc_additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_CONSUME);
if( flag != 0 ) {
clif_additem(sd,0,0,flag);
map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);

View File

@ -2572,7 +2572,7 @@ static int status_get_hpbonus(struct block_list *bl, enum e_status_bonus type) {
//Only for BL_PC
if (bl->type == BL_PC) {
struct map_session_data *sd = map_id2sd(bl->id);
int8 i;
uint8 i;
bonus += sd->bonus.hp;
if ((i = pc_checkskill(sd,CR_TRUST)) > 0)
@ -2682,7 +2682,7 @@ static int status_get_spbonus(struct block_list *bl, enum e_status_bonus type) {
//Only for BL_PC
if (bl->type == BL_PC) {
struct map_session_data *sd = map_id2sd(bl->id);
int8 i;
uint8 i;
bonus += sd->bonus.sp;
if ((i = pc_checkskill(sd,SL_KAINA)) > 0)
@ -2706,14 +2706,14 @@ static int status_get_spbonus(struct block_list *bl, enum e_status_bonus type) {
//Only for BL_PC
if (bl->type == BL_PC) {
struct map_session_data *sd = map_id2sd(bl->id);
int8 i;
uint8 i;
bonus += sd->sprate;
bonus -= 100; //Default sprate is 100, so it should be add 0%
if((i=pc_checkskill(sd,HP_MEDITATIO)) > 0)
if((i = pc_checkskill(sd,HP_MEDITATIO)) > 0)
bonus += i;
if((i=pc_checkskill(sd,HW_SOULDRAIN)) > 0)
if((i = pc_checkskill(sd,HW_SOULDRAIN)) > 0)
bonus += 2 * i;
//+200% for top ranking Taekwons over level 90.
@ -2946,16 +2946,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
current_equip_item_index = index = sd->equip_index[i]; // We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
if(index < 0)
continue;
if(i == EQI_AMMO) continue;
if(i == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index)
if(i == EQI_AMMO)
continue;
if(i == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index)
continue;
if(i == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index))
continue;
if(i == EQI_COSTUME_MID && sd->equip_index[EQI_COSTUME_LOW] == index)
continue;
if(i == EQI_COSTUME_TOP && (sd->equip_index[EQI_COSTUME_MID] == index || sd->equip_index[EQI_COSTUME_LOW] == index))
if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index))
continue;
if(!sd->inventory_data[index])
continue;
@ -3091,12 +3084,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
current_equip_item_index = index = sd->equip_index[i]; // We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
if(index < 0)
continue;
if(i == EQI_AMMO) continue;
if(i == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index)
if(i == EQI_AMMO)
continue;
if(i == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index)
continue;
if(i == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index))
if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index))
continue;
if(sd->inventory_data[index]) {

View File

@ -245,30 +245,28 @@ int storage_delitem(struct map_session_data* sd, int n, int amount)
* @param amount : number of item to take
* @return 0:fail, 1:success
*/
int storage_storageadd(struct map_session_data* sd, int index, int amount)
void storage_storageadd(struct map_session_data* sd, int index, int amount)
{
nullpo_ret(sd);
nullpo_retv(sd);
if( sd->status.storage.storage_amount > sd->storage_size )
return 0; // storage full
return; // storage full
if( index < 0 || index >= MAX_INVENTORY )
return 0;
return;
if( sd->status.inventory[index].nameid <= 0 )
return 0; // No item on that spot
return; // No item on that spot
if( amount < 1 || amount > sd->status.inventory[index].amount )
return 0;
return;
if( storage_additem(sd,&sd->status.inventory[index],amount) == 0 )
pc_delitem(sd,index,amount,0,4,LOG_TYPE_STORAGE);
else {
clif_storageitemremoved(sd,index,0);
clif_dropitem(sd,index,0);
return 0;
}
return 1;
}
/**
@ -278,25 +276,25 @@ int storage_storageadd(struct map_session_data* sd, int index, int amount)
* @param amount : number of item to take
* @return 0:fail, 1:success
*/
int storage_storageget(struct map_session_data* sd, int index, int amount)
void storage_storageget(struct map_session_data* sd, int index, int amount)
{
int flag;
unsigned char flag = 0;
if( index < 0 || index >= sd->storage_size )
return 0;
return;
if( sd->status.storage.items[index].nameid <= 0 )
return 0; //Nothing there
return; //Nothing there
if( amount < 1 || amount > sd->status.storage.items[index].amount )
return 0;
return;
if( (flag = pc_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 )
storage_delitem(sd,index,amount);
else
else {
clif_storageitemremoved(sd,index,0);
clif_additem(sd,0,0,flag);
return 1;
}
}
/**
@ -306,26 +304,28 @@ int storage_storageget(struct map_session_data* sd, int index, int amount)
* @param amount : number of item to take
* @return 0:fail, 1:success
*/
int storage_storageaddfromcart(struct map_session_data* sd, int index, int amount)
void storage_storageaddfromcart(struct map_session_data* sd, int index, int amount)
{
nullpo_ret(sd);
nullpo_retv(sd);
if( sd->status.storage.storage_amount > sd->storage_size )
return 0; // storage full / storage closed
return; // storage full / storage closed
if( index < 0 || index >= MAX_CART )
return 0;
return;
if( sd->status.cart[index].nameid <= 0 )
return 0; //No item there.
return; //No item there.
if( amount < 1 || amount > sd->status.cart[index].amount )
return 0;
return;
if( storage_additem(sd,&sd->status.cart[index],amount) == 0 )
pc_cart_delitem(sd,index,amount,0,LOG_TYPE_STORAGE);
return 1;
else {
clif_storageitemremoved(sd,index,0);
clif_dropitem(sd,index,0);
}
}
/**
@ -335,28 +335,26 @@ int storage_storageaddfromcart(struct map_session_data* sd, int index, int amoun
* @param amount : number of item to take
* @return 0:fail, 1:success
*/
int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
void storage_storagegettocart(struct map_session_data* sd, int index, int amount)
{
short flag;
nullpo_ret(sd);
unsigned char flag;
nullpo_retv(sd);
if( index < 0 || index >= sd->storage_size )
return 0;
return;
if( sd->status.storage.items[index].nameid <= 0 )
return 0; //Nothing there.
return; //Nothing there.
if( amount < 1 || amount > sd->status.storage.items[index].amount )
return 0;
return;
if( (flag = pc_cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 )
storage_delitem(sd,index,amount);
else {
clif_dropitem(sd,index,0);
clif_storageitemremoved(sd,index,0);
clif_cart_additem_ack(sd,(flag==1)?ADDITEM_TO_CART_FAIL_WEIGHT:ADDITEM_TO_CART_FAIL_COUNT);
}
return 1;
}
@ -494,7 +492,7 @@ int storage_guild_storageopen(struct map_session_data* sd)
* @param amount : number of item to add
* @return 0 : success, 1 : fail
*/
int guild_storage_additem(struct map_session_data* sd, struct guild_storage* stor, struct item* item_data, int amount)
char guild_storage_additem(struct map_session_data* sd, struct guild_storage* stor, struct item* item_data, int amount)
{
struct item_data *data;
int i;
@ -584,38 +582,36 @@ int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* sto
* @param amount : number of item to delete
* @return 1:success, 0:fail
*/
int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
void storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
nullpo_ret(sd);
nullpo_ret(stor=guild2storage2(sd->status.guild_id));
nullpo_retv(sd);
nullpo_retv(stor=guild2storage2(sd->status.guild_id));
if( !stor->storage_status || stor->storage_amount > MAX_GUILD_STORAGE )
return 0;
return;
if( index<0 || index>=MAX_INVENTORY )
return 0;
if( index < 0 || index >= MAX_INVENTORY )
return;
if( sd->status.inventory[index].nameid == 0 )
return 0;
return;
if( amount < 1 || amount > sd->status.inventory[index].amount )
return 0;
return;
if( stor->lock ) {
storage_guild_storageclose(sd);
return 0;
return;
}
if(guild_storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
pc_delitem(sd,index,amount,0,4,LOG_TYPE_GSTORAGE);
else {
clif_storageitemremoved(sd,index,0);
clif_dropitem(sd,index,0);
return 0;
}
return 1;
}
/**
@ -625,40 +621,37 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
* @param amount : number of item to get
* @return 1:success, 0:fail
*/
int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
void storage_guild_storageget(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
int flag;
unsigned char flag = 0;
nullpo_ret(sd);
nullpo_ret(stor=guild2storage2(sd->status.guild_id));
nullpo_retv(sd);
nullpo_retv(stor=guild2storage2(sd->status.guild_id));
if(!stor->storage_status)
return 0;
return;
if(index<0 || index>=MAX_GUILD_STORAGE)
return 0;
if(index < 0 || index >= MAX_GUILD_STORAGE)
return;
if(stor->items[index].nameid == 0)
return 0;
return;
if(amount < 1 || amount > stor->items[index].amount)
return 0;
return;
if( stor->lock ) {
storage_guild_storageclose(sd);
return 0;
return;
}
if((flag = pc_additem(sd,&stor->items[index],amount,LOG_TYPE_GSTORAGE)) == 0)
guild_storage_delitem(sd,stor,index,amount);
else {//inform fail
clif_storageitemremoved(sd,index,0);
clif_additem(sd,0,0,flag);
return 0;
}
// log_fromstorage(sd, index, 1);
return 1;
}
/**
@ -668,29 +661,31 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
* @param amount : number of item to transfer
* @return 1:fail, 0:success
*/
int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int amount)
void storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
nullpo_ret(sd);
nullpo_ret(stor=guild2storage2(sd->status.guild_id));
nullpo_retv(sd);
nullpo_retv(stor=guild2storage2(sd->status.guild_id));
if( !stor->storage_status || stor->storage_amount > MAX_GUILD_STORAGE )
return 0;
return;
if( index < 0 || index >= MAX_CART )
return 0;
return;
if( sd->status.cart[index].nameid == 0 )
return 0;
return;
if( amount < 1 || amount > sd->status.cart[index].amount )
return 0;
return;
if(guild_storage_additem(sd,stor,&sd->status.cart[index],amount)==0)
pc_cart_delitem(sd,index,amount,0,LOG_TYPE_GSTORAGE);
return 1;
else {
clif_storageitemremoved(sd,index,0);
clif_dropitem(sd,index,0);
}
}
/**
@ -700,35 +695,32 @@ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int
* @param amount : number of item to transfert
* @return 1:fail, 0:success
*/
int storage_guild_storagegettocart(struct map_session_data* sd, int index, int amount)
void storage_guild_storagegettocart(struct map_session_data* sd, int index, int amount)
{
short flag;
struct guild_storage *stor;
nullpo_ret(sd);
nullpo_ret(stor=guild2storage2(sd->status.guild_id));
nullpo_retv(sd);
nullpo_retv(stor=guild2storage2(sd->status.guild_id));
if(!stor->storage_status)
return 0;
return;
if(index<0 || index>=MAX_GUILD_STORAGE)
return 0;
if(index < 0 || index >= MAX_GUILD_STORAGE)
return;
if(stor->items[index].nameid == 0)
return 0;
return;
if(amount < 1 || amount > stor->items[index].amount)
return 0;
return;
if((flag = pc_cart_additem(sd,&stor->items[index],amount,LOG_TYPE_GSTORAGE)) == 0)
guild_storage_delitem(sd,stor,index,amount);
else {
clif_dropitem(sd,index,0);
clif_cart_additem_ack(sd,(flag==1)?ADDITEM_TO_CART_FAIL_WEIGHT:ADDITEM_TO_CART_FAIL_COUNT);
return 0;
clif_storageitemremoved(sd,index,0);
clif_cart_additem_ack(sd,(flag == 1) ? ADDITEM_TO_CART_FAIL_WEIGHT:ADDITEM_TO_CART_FAIL_COUNT);
}
return 1;
}
/**

View File

@ -13,10 +13,10 @@ struct map_session_data;
int storage_delitem(struct map_session_data* sd, int n, int amount);
int storage_storageopen(struct map_session_data *sd);
int storage_storageadd(struct map_session_data *sd,int index,int amount);
int storage_storageget(struct map_session_data *sd,int index,int amount);
int storage_storageaddfromcart(struct map_session_data *sd,int index,int amount);
int storage_storagegettocart(struct map_session_data *sd,int index,int amount);
void storage_storageadd(struct map_session_data *sd,int index,int amount);
void storage_storageget(struct map_session_data *sd,int index,int amount);
void storage_storageaddfromcart(struct map_session_data *sd,int index,int amount);
void storage_storagegettocart(struct map_session_data *sd,int index,int amount);
void storage_storageclose(struct map_session_data *sd);
void storage_sortitem(struct item* items, unsigned int size);
void do_init_storage(void);
@ -28,12 +28,12 @@ struct guild_storage* guild2storage(int guild_id);
struct guild_storage *guild2storage2(int guild_id);
int guild_storage_delete(int guild_id);
int storage_guild_storageopen(struct map_session_data *sd);
int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor,struct item *item_data,int amount);
char guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor,struct item *item_data,int amount);
int guild_storage_delitem(struct map_session_data *sd,struct guild_storage *stor,int n,int amount);
int storage_guild_storageadd(struct map_session_data *sd,int index,int amount);
int storage_guild_storageget(struct map_session_data *sd,int index,int amount);
int storage_guild_storageaddfromcart(struct map_session_data *sd,int index,int amount);
int storage_guild_storagegettocart(struct map_session_data *sd,int index,int amount);
void storage_guild_storageadd(struct map_session_data *sd,int index,int amount);
void storage_guild_storageget(struct map_session_data *sd,int index,int amount);
void storage_guild_storageaddfromcart(struct map_session_data *sd,int index,int amount);
void storage_guild_storagegettocart(struct map_session_data *sd,int index,int amount);
int storage_guild_storageclose(struct map_session_data *sd);
int storage_guild_storage_quit(struct map_session_data *sd,int flag);
int storage_guild_storagesave(int account_id, int guild_id, int flag);

View File

@ -541,7 +541,6 @@ void trade_tradecommit(struct map_session_data *sd)
{
struct map_session_data *tsd;
int trade_i;
int flag;
if (!sd->state.trading || !sd->state.deal_locked) //Locked should be 1 (pressed ok) before you can press trade.
return;
@ -577,6 +576,7 @@ void trade_tradecommit(struct map_session_data *sd)
for( trade_i = 0; trade_i < 10; trade_i++ )
{
int n;
unsigned char flag = 0;
if (sd->deal.item[trade_i].amount)
{
n = sd->deal.item[trade_i].index;