diff --git a/conf/atcommand_athena.conf b/conf/atcommand_athena.conf index 7a996b84c0..180f8ea83f 100644 --- a/conf/atcommand_athena.conf +++ b/conf/atcommand_athena.conf @@ -60,6 +60,8 @@ aliases: { itemreset: ["clearinventory"] channel: ["main"] autoloottype: ["aloottype"] + cloneequip: ["eqclone"] + clonestat: ["stclone"] } /* Commands help file */ diff --git a/conf/battle/gm.conf b/conf/battle/gm.conf index a2f3c2bcc2..1821561036 100644 --- a/conf/battle/gm.conf +++ b/conf/battle/gm.conf @@ -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 diff --git a/conf/groups.conf b/conf/groups.conf index d1f788cfce..b4e65b1715 100644 --- a/conf/groups.conf +++ b/conf/groups.conf @@ -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 */ } } diff --git a/conf/msg_conf/map_msg.conf b/conf/msg_conf/map_msg.conf index d710aefd97..ed1ee69b3a 100644 --- a/conf/msg_conf/map_msg.conf +++ b/conf/msg_conf/map_msg.conf @@ -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 diff --git a/conf/msg_conf/map_msg_idn.conf b/conf/msg_conf/map_msg_idn.conf index adb4008814..0cc846325f 100644 --- a/conf/msg_conf/map_msg_idn.conf +++ b/conf/msg_conf/map_msg_idn.conf @@ -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 diff --git a/doc/atcommands.txt b/doc/atcommands.txt index 490b92cef9..4c43792a4a 100644 --- a/doc/atcommands.txt +++ b/doc/atcommands.txt @@ -1089,6 +1089,20 @@ Give or remove a cart to a player and also change the cart skin based on ID: --------------------------------------- +@cloneequip +@cloneequip "" + +'Clone' other player's equipments then equip them. + +--------------------------------------- + +@clonestat +@clonestat "" + +'Clone' other player's stats. + +--------------------------------------- + ============================== | 5. Administrative Commands | ============================== diff --git a/doc/permissions.txt b/doc/permissions.txt index db20767feb..4c76072e83 100644 --- a/doc/permissions.txt +++ b/doc/permissions.txt @@ -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 + +--------------------------------------- diff --git a/src/char/char.h b/src/char/char.h index 445df23f12..98c313b2b9 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -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 { diff --git a/src/char/char_clif.c b/src/char/char_clif.c index 775f716957..9f0934eb28 100644 --- a/src/char/char_clif.c +++ b/src/char/char_clif.c @@ -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); } diff --git a/src/map/atcommand.c b/src/map/atcommand.c index abe3ffddb8..1f2bd3d4b3 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -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 +* 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 +* 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; diff --git a/src/map/battle.c b/src/map/battle.c index 123fe96f72..d09cadb6f5 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -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, }, diff --git a/src/map/battle.h b/src/map/battle.h index ab6dcd3f9e..4015529e08 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -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; diff --git a/src/map/clif.c b/src/map/clif.c index f2f7932c16..84d1e28efb 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2186,7 +2186,7 @@ static void clif_addcards(unsigned char* buf, struct item* item) /// 029a .W .W .W .B .B .B .W .W .W .W .W .B .B .L (ZC_ITEM_PICKUP_ACK2) /// 02d4 .W .W .W .B .B .B .W .W .W .W .W .B .B .L .W (ZC_ITEM_PICKUP_ACK3) /// 0990 .W .W .W .B .B .B .W .W .W .W .L .B .B .L .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])); } diff --git a/src/map/clif.h b/src/map/clif.h index 98a220ade0..680a4ecf39 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -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 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index afe23d74af..b4578fbae3 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -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) diff --git a/src/map/map.h b/src/map/map.h index 3c46185fb5..cc6137f7e5 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -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, diff --git a/src/map/pc.c b/src/map/pc.c index 95d6c0899a..cf7f6a86f7 100755 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -97,19 +97,32 @@ struct item_cd { unsigned short nameid[MAX_ITEMDELAYS]; //item id }; -//Converts a class to its array index for CLASS_COUNT defined arrays. -//Note that it does not do a validity check for speed purposes, where parsing -//player input make sure to use a pcdb_checkid first! +/** +* Converts a class to its array index for CLASS_COUNT defined arrays. +* Note that it does not do a validity check for speed purposes, where parsing +* player input make sure to use a pcdb_checkid first! +* @param class_ +* @return Class Index +*/ int pc_class2idx(int class_) { if (class_ >= JOB_NOVICE_HIGH) return class_- JOB_NOVICE_HIGH+JOB_MAX_BASIC; return class_; } +/** +* Get player's group ID +* @param sd +* @return Group ID +*/ inline int pc_get_group_id(struct map_session_data *sd) { return sd->group_id; } +/** Get player's group Level +* @param sd +* @return Group Level +*/ inline int pc_get_group_level(struct map_session_data *sd) { return sd->group_level; } @@ -364,7 +377,11 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { return c; } -// Increases a player's fame points and displays a notice to him +/** +* Increases a player's fame points and displays a notice to him +* @param sd Player +* @param count Fame point +*/ void pc_addfame(struct map_session_data *sd,int count) { int ranktype=-1; @@ -383,7 +400,12 @@ void pc_addfame(struct map_session_data *sd,int count) chrif_updatefamelist(sd); } -// Check whether a player ID is in the fame rankers' list of its job, returns his/her position if so, 0 else +/** + * Check whether a player ID is in the fame rankers' list of its job, returns his/her position if so, 0 else + * @param sd + * @param job Job use enum e_mapid + * @return Rank + */ unsigned char pc_famerank(int char_id, int job) { uint8 i; @@ -412,9 +434,14 @@ unsigned char pc_famerank(int char_id, int job) return 0; } -int pc_setrestartvalue(struct map_session_data *sd,int type) { +/** +* Restart player's HP & SP value +* @param sd +* @param type Restart type: 1 - Normal Resurection +*/ +void pc_setrestartvalue(struct map_session_data *sd, char type) { struct status_data *status, *b_status; - nullpo_ret(sd); + nullpo_retv(sd); b_status = &sd->base_status; status = &sd->battle_status; @@ -428,12 +455,13 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { sd->status.hp = b_status->hp; sd->status.sp = (status->sp < b_status->sp)?b_status->sp:status->sp; } - return 0; } /*========================================== Rental System *------------------------------------------*/ + +/** Ends rental */ static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd = map_id2sd(id); @@ -449,17 +477,15 @@ static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t return 1; } -int pc_inventory_rental_clear(struct map_session_data *sd) +void pc_inventory_rental_clear(struct map_session_data *sd) { if( sd->rental_timer != INVALID_TIMER ) { delete_timer(sd->rental_timer, pc_inventory_rental_end); sd->rental_timer = INVALID_TIMER; } - - return 1; } -/* Assumes I is valid (from default areas where it is called, it is) */ +/** Assumes I is valid (from default areas where it is called, it is) */ void pc_rental_expire(struct map_session_data *sd, int i) { unsigned short nameid = sd->status.inventory[i].nameid; @@ -591,11 +617,12 @@ bool pc_can_give_bounded_items(struct map_session_data *sd) } /*========================================== - * prepares character for saving. + * Prepares character for saving. + * @param sd *------------------------------------------*/ -int pc_makesavestatus(struct map_session_data *sd) +void pc_makesavestatus(struct map_session_data *sd) { - nullpo_ret(sd); + nullpo_retv(sd); if(!battle_config.save_clothcolor) sd->status.clothes_color=0; @@ -617,7 +644,7 @@ int pc_makesavestatus(struct map_session_data *sd) sd->status.last_point.map = sd->mapindex; sd->status.last_point.x = sd->bl.x; sd->status.last_point.y = sd->bl.y; - return 0; + return; } if(pc_isdead(sd)){ @@ -638,16 +665,14 @@ int pc_makesavestatus(struct map_session_data *sd) else memcpy(&sd->status.last_point,&sd->status.save_point,sizeof(sd->status.last_point)); } - - return 0; } /*========================================== * Off init ? Connection? *------------------------------------------*/ -int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int login_id1, unsigned int client_tick, int sex, int fd) +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) { - nullpo_ret(sd); + nullpo_retv(sd); sd->bl.id = account_id; sd->status.account_id = account_id; @@ -661,9 +686,13 @@ int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int lo sd->canlog_tick = gettick(); //Required to prevent homunculus copuing a base speed of 0. sd->battle_status.speed = sd->base_status.speed = DEFAULT_WALK_SPEED; - return 0; } +/** +* Get equip point for an equip +* @param sd +* @param n Equip index in inventory +*/ int pc_equippoint(struct map_session_data *sd,int n){ int ep = 0; @@ -691,30 +720,33 @@ int pc_equippoint(struct map_session_data *sd,int n){ * @param sd : player session * @return 0 sucess, 1:invalid sd */ -int pc_setinventorydata(struct map_session_data *sd) +void pc_setinventorydata(struct map_session_data *sd) { uint8 i; - nullpo_retr(1,sd); + nullpo_retv(sd); - for(i=0;istatus.inventory[i].nameid; sd->inventory_data[i] = id?itemdb_search(id):NULL; } - return 0; } -int pc_calcweapontype(struct map_session_data *sd) +/** +* 'Calculates' weapon type +* @param sd +*/ +void pc_calcweapontype(struct map_session_data *sd) { - nullpo_ret(sd); + nullpo_retv(sd); // single-hand if(sd->weapontype2 == W_FIST) { sd->status.weapon = sd->weapontype1; - return 1; + return; } if(sd->weapontype1 == W_FIST) { sd->status.weapon = sd->weapontype2; - return 1; + return; } // dual-wield sd->status.weapon = 0; @@ -743,37 +775,38 @@ int pc_calcweapontype(struct map_session_data *sd) // unknown, default to right hand type if (!sd->status.weapon) sd->status.weapon = sd->weapontype1; - - return 2; } -int pc_setequipindex(struct map_session_data *sd) +/** +* Set equip index +* @param sd +*/ +void pc_setequipindex(struct map_session_data *sd) { - int i,j; + uint16 i; - nullpo_ret(sd); + nullpo_retv(sd); - for(i=0;iequip_index[i] = -1; - for(i=0;istatus.inventory[i].nameid <= 0) + for (i = 0; i < MAX_INVENTORY; i++) { + if (sd->status.inventory[i].nameid <= 0) continue; - if(sd->status.inventory[i].equip) { - for(j=0;jstatus.inventory[i].equip & equip_pos[j]) + if (sd->status.inventory[i].equip) { + uint8 j; + for (j = 0; j < EQI_MAX; j++) + if (sd->status.inventory[i].equip & equip_pos[j]) sd->equip_index[j] = i; - if(sd->status.inventory[i].equip & EQP_HAND_R) - { - if(sd->inventory_data[i]) + if (sd->status.inventory[i].equip & EQP_HAND_R) { + if (sd->inventory_data[i]) sd->weapontype1 = sd->inventory_data[i]->look; else sd->weapontype1 = 0; } - if( sd->status.inventory[i].equip & EQP_HAND_L ) - { + if( sd->status.inventory[i].equip & EQP_HAND_L ) { if( sd->inventory_data[i] && sd->inventory_data[i]->type == IT_WEAPON ) sd->weapontype2 = sd->inventory_data[i]->look; else @@ -782,8 +815,6 @@ int pc_setequipindex(struct map_session_data *sd) } } pc_calcweapontype(sd); - - return 0; } //static int pc_isAllowedCardOn(struct map_session_data *sd,int s,int eqindex,int flag) @@ -819,12 +850,10 @@ bool pc_isequipped(struct map_session_data *sd, unsigned short nameid) for( i = 0; i < EQI_MAX; i++ ) { int8 index = sd->equip_index[i], j; - if( index < 0 ) continue; - - if( i == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index ) 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( index < 0 ) + continue; + if( pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index) ) + continue; if( !sd->inventory_data[index] ) continue; if( sd->inventory_data[index]->nameid == nameid ) @@ -838,6 +867,12 @@ bool pc_isequipped(struct map_session_data *sd, unsigned short nameid) return false; } +/** Check adopt rule +* @param p1_sd Player 1 +* @param p2_sd Player 2 +* @param b_sd Player that will be adopted +* @return True - if can be adopted, False otherwise +*/ bool pc_can_Adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd ) { if( !p1_sd || !p2_sd || !b_sd ) @@ -977,9 +1012,11 @@ static bool pc_isItemClass (struct map_session_data *sd, struct item_data* item) /*================================================= * Checks if the player can equip the item at index n in inventory. - * Returns 0 (no) or 1 (yes). + * @param sd + * @param n Item index in inventory + * @return True - Can be equipped, False - failed *------------------------------------------------*/ -int pc_isequip(struct map_session_data *sd,int n) +bool pc_isequip(struct map_session_data *sd,int n) { struct item_data *item; @@ -988,38 +1025,38 @@ int pc_isequip(struct map_session_data *sd,int n) item = sd->inventory_data[n]; if(pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) - return 1; + return true; if(item == NULL) - return 0; + return false; if(item->elv && sd->status.base_level < (unsigned int)item->elv) - return 0; + return false; #ifdef RENEWAL if(item->elvmax && sd->status.base_level > (unsigned int)item->elvmax) - return 0; + return false; #endif if(item->sex != 2 && sd->status.sex != item->sex) - return 0; + return false; if (sd->sc.count) { if(item->equip & EQP_ARMS && item->type == IT_WEAPON && sd->sc.data[SC_STRIPWEAPON]) // Also works with left-hand weapons [DracoRPG] - return 0; + return false; if(item->equip & EQP_SHIELD && item->type == IT_ARMOR && sd->sc.data[SC_STRIPSHIELD]) - return 0; + return false; if(item->equip & EQP_ARMOR && sd->sc.data[SC_STRIPARMOR]) - return 0; + return false; if(item->equip & EQP_HEAD_TOP && sd->sc.data[SC_STRIPHELM]) - return 0; + return false; if(item->equip & EQP_ACC && sd->sc.data[SC__STRIPACCESSORY]) - return 0; + return false; if(item->equip && sd->sc.data[SC_KYOUGAKU]) - return 0; + return false; if (sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_SUPERNOVICE) { //Spirit of Super Novice equip bonuses. [Skotlex] if (sd->status.base_level > 90 && item->equip & EQP_HELM) - return 1; //Can equip all helms + return true; //Can equip all helms if (sd->status.base_level > 96 && item->equip & EQP_ARMS && item->type == IT_WEAPON) switch(item->look) { //In weapons, the look determines type of weapon. @@ -1028,23 +1065,23 @@ int pc_isequip(struct map_session_data *sd,int n) case W_1HAXE: //All 1H Axes case W_MACE: //All 1H Maces case W_STAFF: //All 1H Staves - return 1; + return true; } } } //fail to equip if item is restricted if (!battle_config.allow_equip_restricted_item && itemdb_isNoEquip(item, sd->bl.m)) - return 0; + return false; //Not equipable by class. [Skotlex] if (!(1<<(sd->class_&MAPID_BASEMASK)&item->class_base[(sd->class_&JOBL_2_1)?1:((sd->class_&JOBL_2_2)?2:0)])) - return 0; + return false; if (!pc_isItemClass(sd,item)) - return 0; + return false; - return 1; + return true; } /*========================================== @@ -1240,6 +1277,8 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim // Player has not yet received the CashShop list sd->status.cashshop_sent = false; + sd->last_addeditem_index = -1; + // Request all registries (auth is considered completed whence they arrive) intif_request_registry(sd,7); return true; @@ -1289,7 +1328,7 @@ bool pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl /*========================================== * Invoked once after the char/account/account2 registry variables are received. [Skotlex] *------------------------------------------*/ -int pc_reg_received(struct map_session_data *sd) +void pc_reg_received(struct map_session_data *sd) { uint8 i; @@ -1349,7 +1388,7 @@ int pc_reg_received(struct map_session_data *sd) } //Weird... maybe registries were reloaded? if (sd->state.active) - return 0; + return; sd->state.active = 1; if (sd->status.party_id) @@ -1414,8 +1453,6 @@ int pc_reg_received(struct map_session_data *sd) if( sd->state.autotrade ) clif_parse_LoadEndAck(sd->fd, sd); - - return 1; } static int pc_calc_skillpoint(struct map_session_data* sd) @@ -1446,19 +1483,20 @@ static int pc_calc_skillpoint(struct map_session_data* sd) /*========================================== * Calculation of skill level. + * @param sd *------------------------------------------*/ -int pc_calc_skilltree(struct map_session_data *sd) +void pc_calc_skilltree(struct map_session_data *sd) { int i,id=0,flag; int c=0; - nullpo_ret(sd); + nullpo_retv(sd); i = pc_calc_skilltree_normalize_job(sd); c = pc_mapid2jobid(i, sd->status.sex); if( c == -1 ) { //Unable to normalize job?? ShowError("pc_calc_skilltree: Unable to normalize job %d for character %s (%d:%d)\n", i, sd->status.name, sd->status.account_id, sd->status.char_id); - return 1; + return; } c = pc_class2idx(c); @@ -1552,7 +1590,7 @@ int pc_calc_skilltree(struct map_session_data *sd) if( skill_get_max(i) > 0 ) sd->status.skill[i].id = i; } - return 0; + return; } do { @@ -1634,8 +1672,6 @@ int pc_calc_skilltree(struct map_session_data *sd) sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_); } } - - return 0; } //Checks if you can learn a new skill after having leveled up a skill. @@ -1797,18 +1833,18 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) * 2: overweight 90% * It's assumed that SC_WEIGHT50 and SC_WEIGHT90 are only started/stopped here. */ -int pc_updateweightstatus(struct map_session_data *sd) +void pc_updateweightstatus(struct map_session_data *sd) { int old_overweight; int new_overweight; - nullpo_retr(1, sd); + nullpo_retv(sd); old_overweight = (sd->sc.data[SC_WEIGHT90]) ? 2 : (sd->sc.data[SC_WEIGHT50]) ? 1 : 0; new_overweight = (pc_is90overweight(sd)) ? 2 : (pc_is50overweight(sd)) ? 1 : 0; if( old_overweight == new_overweight ) - return 0; // no change + return; // no change // stop old status change if( old_overweight == 1 ) @@ -1824,8 +1860,6 @@ int pc_updateweightstatus(struct map_session_data *sd) // update overweight status sd->regen.state.overweight = new_overweight; - - return 0; } int pc_disguise(struct map_session_data *sd, int class_) @@ -1873,26 +1907,26 @@ int pc_disguise(struct map_session_data *sd, int class_) return 1; } -static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short flag, unsigned short card_id) +static void pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short flag, unsigned short card_id) { - int i; + uint8 i; if( !rate ) - return 0; + return; for( i = 0; i < max && spell[i].id; i++ ) { if( (spell[i].card_id == card_id || spell[i].rate < 0 || rate < 0) && spell[i].id == id && spell[i].lv == lv ) { if( !battle_config.autospell_stacking && spell[i].rate > 0 && rate > 0 ) - return 0; + return; rate += spell[i].rate; break; } } if (i == max) { ShowWarning("pc_bonus: Reached max (%d) number of autospells per character!\n", max); - return 0; + return; } spell[i].id = id; spell[i].lv = lv; @@ -1906,15 +1940,14 @@ static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, shor } spell[i].flag|= flag; spell[i].card_id = card_id; - return 1; } -static int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, unsigned short card_id) +static void pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, unsigned short card_id) { - int i; + uint8 i; if( !rate ) - return 0; + return; for( i = 0; i < max && spell[i].id; i++ ) { @@ -1924,7 +1957,7 @@ static int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short if( i == max ) { ShowWarning("pc_bonus: Reached max (%d) number of autospells per character!\n", max); - return 0; + return; } spell[i].flag = src_skill; @@ -1932,12 +1965,12 @@ static int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short spell[i].lv = lv; spell[i].rate = rate; spell[i].card_id = card_id; - return 1; + return; } -static int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, short rate, short arrow_rate, unsigned char flag) +static void pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, short rate, short arrow_rate, unsigned char flag) { - int i; + uint16 i; if (!(flag&(ATF_SHORT|ATF_LONG))) flag|=ATF_SHORT|ATF_LONG; //Default range: both if (!(flag&(ATF_TARGET|ATF_SELF))) @@ -1950,40 +1983,38 @@ static int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, { effect[i].rate += rate; effect[i].arrow_rate += arrow_rate; - return 1; + return; } } if (i == max) { ShowWarning("pc_bonus: Reached max (%d) number of add effects per character!\n", max); - return 0; + return; } effect[i].id = id; effect[i].rate = rate; effect[i].arrow_rate = arrow_rate; effect[i].flag = flag; - return 1; } -static int pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill, unsigned char target) +static void pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill, unsigned char target) { - int i; + uint8 i; for( i = 0; i < max && effect[i].skill; i++ ) { if( effect[i].id == id && effect[i].skill == skill && effect[i].target == target ) { effect[i].rate += rate; - return 1; + return; } } if( i == max ) { ShowWarning("pc_bonus: Reached max (%d) number of add effects on skill per character!\n", max); - return 0; + return; } effect[i].id = id; effect[i].rate = rate; effect[i].skill = skill; effect[i].target = target; - return 1; } /** Adjust/add drop rate modifier for player @@ -2152,9 +2183,9 @@ int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data) return 0; } -int pc_bonus_addele(struct map_session_data* sd, unsigned char ele, short rate, short flag) +static void pc_bonus_addele(struct map_session_data* sd, unsigned char ele, short rate, short flag) { - int i; + uint8 i; struct weapon_data* wd; wd = (sd->state.lr_flag ? &sd->left_weapon : &sd->right_weapon); @@ -2164,7 +2195,7 @@ int pc_bonus_addele(struct map_session_data* sd, unsigned char ele, short rate, if (i == MAX_PC_BONUS) { ShowWarning("pc_addele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS); - return 0; + return; } if (!(flag&BF_RANGEMASK)) @@ -2182,20 +2213,18 @@ int pc_bonus_addele(struct map_session_data* sd, unsigned char ele, short rate, wd->addele2[i].ele = ele; wd->addele2[i].rate = rate; wd->addele2[i].flag = flag; - - return 0; } -int pc_bonus_subele(struct map_session_data* sd, unsigned char ele, short rate, short flag) +static void pc_bonus_subele(struct map_session_data* sd, unsigned char ele, short rate, short flag) { - int i; + uint8 i; ARR_FIND(0, MAX_PC_BONUS, i, sd->subele2[i].rate == 0); if (i == MAX_PC_BONUS) { ShowWarning("pc_subele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS); - return 0; + return; } if (!(flag&BF_RANGEMASK)) @@ -2213,8 +2242,6 @@ int pc_bonus_subele(struct map_session_data* sd, unsigned char ele, short rate, sd->subele2[i].ele = ele; sd->subele2[i].rate = rate; sd->subele2[i].flag = flag; - - return 0; } /** Add item group heal rate bonus to player @@ -2269,12 +2296,16 @@ void pc_itemgrouphealrate_clear(struct map_session_data *sd) { /*========================================== * Add a bonus(type) to player sd + * format: bonus bBonusName,val; + * @param sd + * @param type Bonus type used by bBonusName + * @param val Value that usually for rate or fixed value *------------------------------------------*/ -int pc_bonus(struct map_session_data *sd,int type,int val) +void pc_bonus(struct map_session_data *sd,int type,int val) { struct status_data *status; int bonus; - nullpo_ret(sd); + nullpo_retv(sd); status = &sd->base_status; @@ -2883,17 +2914,21 @@ int pc_bonus(struct map_session_data *sd,int type,int val) ShowWarning("pc_bonus: unknown type %d %d !\n",type,val); break; } - return 0; } /*========================================== * Player bonus (type) with args type2 and val, called trough bonus2 (npc) + * format: bonus2 bBonusName,type2,val; + * @param sd + * @param type Bonus type used by bBonusName + * @param type2 + * @param val Value that usually for rate or fixed value *------------------------------------------*/ -int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) +void pc_bonus2(struct map_session_data *sd,int type,int type2,int val) { int i; - nullpo_ret(sd); + nullpo_retv(sd); switch(type){ case SP_ADDELE: @@ -2949,7 +2984,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) sd->subclass[type2]+=val; break; case SP_ADDEFF: - if (type2 > SC_MAX) { + if (type2 <= SC_NONE || type2 >= SC_MAX) { ShowWarning("pc_bonus2 (Add Effect): %d is not supported.\n", type2); break; } @@ -2957,7 +2992,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, 0); break; case SP_ADDEFF2: - if (type2 > SC_MAX) { + if (type2 <= SC_NONE || type2 >= SC_MAX) { ShowWarning("pc_bonus2 (Add Effect2): %d is not supported.\n", type2); break; } @@ -2971,8 +3006,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->state.lr_flag == 2) break; - i = sd->reseff[type2-SC_COMMON_MIN]+val; - sd->reseff[type2-SC_COMMON_MIN]= cap_value(i, 0, 10000); + i = sd->reseff[type2]+val; + sd->reseff[type2]= cap_value(i, -10000, 10000); break; case SP_MAGIC_ADDELE: if(type2 > ELE_ALL) { @@ -3183,7 +3218,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) sd->critaddrace[type2] += val*10; break; case SP_ADDEFF_WHENHIT: - if (type2 > SC_MAX) { + if (type2 <= SC_NONE || type2 >= SC_MAX) { ShowWarning("pc_bonus2 (Add Effect when hit): %d is not supported.\n", type2); break; } @@ -3537,12 +3572,18 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) ShowWarning("pc_bonus2: unknown type %d %d %d!\n",type,type2,val); break; } - return 0; } -int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) +/** +* Gives item bonus to player for format: bonus3 bBonusName,type2,val; +* @param sd +* @param type Bonus type used by bBonusName +* @param type2 +* @param val Value that usually for rate or fixed value +*/ +void pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) { - nullpo_ret(sd); + nullpo_retv(sd); switch(type){ case SP_ADD_MONSTER_DROP_ITEM: @@ -3604,7 +3645,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) break; case SP_ADDEFF: - if (type2 > SC_MAX) { + if (type2 <= SC_NONE || type2 >= SC_MAX) { ShowWarning("pc_bonus3 (Add Effect): %d is not supported.\n", type2); break; } @@ -3613,7 +3654,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) break; case SP_ADDEFF_WHENHIT: - if (type2 > SC_MAX) { + if (type2 <= SC_NONE || type2 >= SC_MAX) { ShowWarning("pc_bonus3 (Add Effect when hit): %d is not supported.\n", type2); break; } @@ -3622,7 +3663,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) break; case SP_ADDEFF_ONSKILL: - if( type3 > SC_MAX ) { + if (type3 <= SC_NONE || type3 >= SC_MAX) { ShowWarning("pc_bonus3 (Add Effect on skill): %d is not supported.\n", type3); break; } @@ -3652,13 +3693,19 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) ShowWarning("pc_bonus3: unknown type %d %d %d %d!\n",type,type2,type3,val); break; } - - return 0; } -int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4,int val) +/** +* Gives item bonus to player for format: bonus4 bBonusName,type2,type3,val; +* @param sd +* @param type Bonus type used by bBonusName +* @param type2 +* @param type3 +* @param val Value that usually for rate or fixed value +*/ +void pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4,int val) { - nullpo_ret(sd); + nullpo_retv(sd); switch(type){ case SP_AUTOSPELL: @@ -3682,7 +3729,7 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4 break; case SP_ADDEFF_ONSKILL: - if( type2 > SC_MAX ) { + if (type2 <= SC_NONE || type2 >= SC_MAX) { ShowWarning("pc_bonus4 (Add Effect on skill): %d is not supported.\n", type2); break; } @@ -3718,13 +3765,20 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4 ShowWarning("pc_bonus4: unknown type %d %d %d %d %d!\n",type,type2,type3,type4,val); break; } - - return 0; } -int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4,int type5,int val) +/** +* Gives item bonus to player for format: bonus5 bBonusName,type2,type3,type4,val; +* @param sd +* @param type Bonus type used by bBonusName +* @param type2 +* @param type3 +* @param type4 +* @param val Value that usually for rate or fixed value +*/ +void pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4,int type5,int val) { - nullpo_ret(sd); + nullpo_retv(sd); switch(type){ case SP_AUTOSPELL: @@ -3746,8 +3800,6 @@ int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4 ShowWarning("pc_bonus5: unknown type %d %d %d %d %d %d!\n",type,type2,type3,type4,type5,val); break; } - - return 0; } /*========================================== @@ -3923,8 +3975,12 @@ int pc_modifysellvalue(struct map_session_data *sd,int orig_value) /*========================================== * Checking if we have enough place on inventory for new item * Make sure to take 30k as limit (for client I guess) + * @param sd + * @param nameid + * @param amount + * @return e_chkitem_result *------------------------------------------*/ -int pc_checkadditem(struct map_session_data *sd, unsigned short nameid, int amount) +char pc_checkadditem(struct map_session_data *sd, unsigned short nameid, int amount) { int i; struct item_data* data; @@ -3957,14 +4013,16 @@ int pc_checkadditem(struct map_session_data *sd, unsigned short nameid, int amou /*========================================== * Return number of available place in inventory * Each non stackable item will reduce place by 1 + * @param sd + * @return Number of empty slots *------------------------------------------*/ -int pc_inventoryblank(struct map_session_data *sd) +uint8 pc_inventoryblank(struct map_session_data *sd) { - int i,b; + uint8 i, b; nullpo_ret(sd); - for(i=0,b=0;istatus.inventory[i].nameid==0) b++; } @@ -3974,10 +4032,15 @@ int pc_inventoryblank(struct map_session_data *sd) /*========================================== * attempts to remove zeny from player (sd) + * @param sd + * @param zeny Zeny removed + * @param type e_log_pick_type + * @param tsd (just for log?) + * @return 0 - Success, 1 - Failed *------------------------------------------*/ -int pc_payzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type, struct map_session_data *tsd) +char pc_payzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type, struct map_session_data *tsd) { - nullpo_retr(-1,sd); + nullpo_retr(2,sd); zeny = cap_value(zeny,-MAX_ZENY,MAX_ZENY); //prevent command UB if( zeny < 0 ) @@ -4117,7 +4180,7 @@ int pc_getcash( struct map_session_data *sd, int cash, int points, e_log_pick_ty * Attempts to give zeny to player (sd) * tsd (optional) from who for log (if null take sd) *------------------------------------------*/ -int pc_getzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type, struct map_session_data *tsd) +char pc_getzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type, struct map_session_data *tsd) { nullpo_retr(-1,sd); @@ -4152,7 +4215,7 @@ int pc_getzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type, * @return Stored index in inventory, or -1 if not found. **/ short pc_search_inventory(struct map_session_data *sd, unsigned short nameid) { - int16 i; + short i; nullpo_retr(-1, sd); ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == nameid && (sd->status.inventory[i].amount > 0 || nameid == 0) ); @@ -4231,6 +4294,7 @@ char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_p sd->status.inventory[i].amount = amount; sd->inventory_data[i] = id; + sd->last_addeditem_index = i; clif_additem(sd,i,amount,0); } #ifdef NSI_UNIQUE_ID @@ -4262,15 +4326,15 @@ char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_p /*========================================== * Remove an item at index n from inventory by amount. - * Parameters : - * @type - * 1 : don't notify deletion - * 2 : don't notify weight change - * Return: - * 0 = success - * 1 = invalid itemid or negative amount + * @param sd + * @param n Item index in inventory + * @param amount + * @param type &1: Don't notify deletion; &2 Don't notify weight change + * @param reason Delete reason + * @param log_type e_log_pick_type + * @return 1 - invalid itemid or negative amount; 0 - Success *------------------------------------------*/ -int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type) +char pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type) { nullpo_retr(1, sd); @@ -4297,19 +4361,20 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reas /*========================================== * Attempt to drop an item. - * Return: - * 0 = fail - * 1 = success + * @param sd + * @param n Item index in inventory + * @param amount Amount of item + * @return False = fail; True = success *------------------------------------------*/ -int pc_dropitem(struct map_session_data *sd,int n,int amount) +bool pc_dropitem(struct map_session_data *sd,int n,int amount) { nullpo_retr(1, sd); if(n < 0 || n >= MAX_INVENTORY) - return 0; + return false; if(amount <= 0) - return 0; + return false; if(sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount <= 0 || @@ -4317,48 +4382,48 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) sd->state.trading || sd->state.vending || !sd->inventory_data[n] //pc_delitem would fail on this case. ) - return 0; + return false; if( map[sd->bl.m].flag.nodrop ) { clif_displaymessage (sd->fd, msg_txt(sd,271)); - return 0; //Can't drop items in nodrop mapflag maps. + return false; //Can't drop items in nodrop mapflag maps. } if( !pc_candrop(sd,&sd->status.inventory[n]) ) { clif_displaymessage (sd->fd, msg_txt(sd,263)); - return 0; + return false; } if (!map_addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2)) - return 0; + return false; pc_delitem(sd, n, amount, 1, 0, LOG_TYPE_PICKDROP_PLAYER); clif_dropitem(sd, n, amount); - return 1; + return true; } /*========================================== * Attempt to pick up an item. - * Return: - * 0 = fail - * 1 = success + * @param sd + * @param fitem Item that will be picked + * @return False = fail; True = success *------------------------------------------*/ -int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) +bool pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) { int flag=0; unsigned int tick = gettick(); - struct party_data *p=NULL; + struct party_data *p = NULL; nullpo_ret(sd); nullpo_ret(fitem); if(!check_distance_bl(&fitem->bl, &sd->bl, 2) && sd->ud.skill_id!=BS_GREED) - return 0; // Distance is too far + return false; // Distance is too far if( sd->sc.cant.pickup ) - return 0; + return false; if (sd->status.party_id) p = party_search(sd->status.party_id); @@ -4369,7 +4434,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) if (!(p && p->party.item&1 && first_sd && first_sd->status.party_id == sd->status.party_id )) - return 0; + return false; } else if(fitem->second_get_charid > 0 && fitem->second_get_charid != sd->status.char_id) { struct map_session_data *second_sd = map_charid2sd(fitem->second_get_charid); @@ -4378,7 +4443,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) ((first_sd && first_sd->status.party_id == sd->status.party_id) || (second_sd && second_sd->status.party_id == sd->status.party_id)) )) - return 0; + return false; } else if(fitem->third_get_charid > 0 && fitem->third_get_charid != sd->status.char_id){ struct map_session_data *third_sd = map_charid2sd(fitem->third_get_charid); @@ -4388,7 +4453,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) (second_sd && second_sd->status.party_id == sd->status.party_id) || (third_sd && third_sd->status.party_id == sd->status.party_id)) )) - return 0; + return false; } } } @@ -4397,14 +4462,14 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) //This function takes care of giving the item to whoever should have it, considering party-share options. if ((flag = party_share_loot(p,sd,&fitem->item_data, fitem->first_get_charid))) { clif_additem(sd,0,0,flag); - return 1; + return true; } //Display pickup animation. pc_stop_attack(sd); clif_takeitem(&sd->bl,&fitem->bl); map_clearflooritem(&fitem->bl); - return 1; + return true; } /*========================================== @@ -4413,7 +4478,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) * 0 = no * 1 = yes *------------------------------------------*/ -int pc_isUseitem(struct map_session_data *sd,int n) +bool pc_isUseitem(struct map_session_data *sd,int n) { struct item_data *item; unsigned short nameid; @@ -4424,48 +4489,48 @@ int pc_isUseitem(struct map_session_data *sd,int n) nameid = sd->status.inventory[n].nameid; if( item == NULL ) - return 0; + return false; //Not consumable item if( item->type != IT_HEALING && item->type != IT_USABLE && item->type != IT_CASH ) - return 0; + return false; if( !item->script ) //if it has no script, you can't really consume it! - return 0; + return false; if (pc_has_permission(sd,PC_PERM_ITEM_UNCONDITIONAL)) - return 1; + return true; if(map[sd->bl.m].flag.noitemconsumption) //consumable but mapflag prevent it - return 0; + return false; //Prevent mass item usage. [Skotlex] if( DIFF_TICK(sd->canuseitem_tick,gettick()) > 0 || (itemdb_iscashfood(nameid) && DIFF_TICK(sd->canusecashfood_tick,gettick()) > 0) ) - return 0; + return false; if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) { clif_msgtable(sd->fd,ITEM_NOUSE_SITTING); - return 0; // You cannot use this item while sitting. + return false; // You cannot use this item while sitting. } if (sd->state.storage_flag && item->type != IT_CASH) { clif_colormes(sd, color_table[COLOR_RED], msg_txt(sd,388)); - return 0; // You cannot use this item while storage is open. + return false; // You cannot use this item while storage is open. } if (item->flag.dead_branch && (map[sd->bl.m].flag.nobranch || map_flag_gvg(sd->bl.m))) - return 0; + return false; switch( nameid ) { case ITEMID_ANODYNE: if( map_flag_gvg(sd->bl.m) ) - return 0; + return false; case ITEMID_ALOEBERA: if( pc_issit(sd) ) - return 0; + return false; break; case ITEMID_WING_OF_FLY: case ITEMID_GIANT_FLY_WING: if( map[sd->bl.m].flag.noteleport || map_flag_gvg(sd->bl.m) ) { clif_skill_teleportmessage(sd,0); - return 0; + return false; } case ITEMID_WING_OF_BUTTERFLY: case ITEMID_DUN_TELE_SCROLL1: @@ -4478,15 +4543,15 @@ int pc_isUseitem(struct map_session_data *sd,int n) case ITEMID_SIEGE_TELEPORT_SCROLL: if( sd->duel_group && !battle_config.duel_allow_teleport ) { clif_displaymessage(sd->fd, msg_txt(sd,663)); - return 0; + return false; } if( nameid != 601 && nameid != 12212 && map[sd->bl.m].flag.noreturn ) - return 0; + return false; break; case ITEMID_BUBBLE_GUM: case ITEMID_COMP_BUBBLE_GUM: if( sd->sc.data[SC_ITEMBOOST] ) - return 0; + return false; break; case ITEMID_BATTLE_MANUAL: case ITEMID_COMP_BATTLE_MANUAL: @@ -4496,11 +4561,11 @@ int pc_isUseitem(struct map_session_data *sd,int n) case ITEMID_BATTLE_MANUAL100: case ITEMID_BATTLE_MANUAL300: if( sd->sc.data[SC_EXPBOOST] ) - return 0; + return false; break; case ITEMID_JOB_MANUAL50: if( sd->sc.data[SC_JEXPBOOST] ) - return 0; + return false; break; case ITEMID_MERCENARY_RED_POTION: case ITEMID_MERCENARY_BLUE_POTION: @@ -4508,56 +4573,56 @@ int pc_isUseitem(struct map_session_data *sd,int n) case ITEMID_M_AWAKENING_POTION: case ITEMID_M_BERSERK_POTION: if( sd->md == NULL || sd->md->db == NULL ) - return 0; + return false; if( sd->md->sc.data[SC_BERSERK] ) - return 0; + return false; if( nameid == ITEMID_M_AWAKENING_POTION && sd->md->db->lv < 40 ) - return 0; + return false; if( nameid == ITEMID_M_BERSERK_POTION && sd->md->db->lv < 80 ) - return 0; + return false; break; case ITEMID_NEURALIZER: if( !map[sd->bl.m].flag.reset ) - return 0; + return false; break; } if( nameid >= ITEMID_BOW_MERCENARY_SCROLL1 && nameid <= ITEMID_SPEARMERCENARY_SCROLL10 && sd->md != NULL ) - return 0; // Mercenary Scrolls + return false; // Mercenary Scrolls /** * Only Rune Knights may use runes **/ if( itemdb_is_rune(nameid) && (sd->class_&MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT ) - return 0; + return false; /** * Only GCross may use poisons **/ else if( itemdb_is_poison(nameid) && (sd->class_&MAPID_THIRDMASK) != MAPID_GUILLOTINE_CROSS ) - return 0; + return false; if( item->flag.group ) { if( pc_is90overweight(sd) ) { clif_msgtable(sd->fd, ITEM_CANT_OBTAIN_WEIGHT); - return 0; + return false; } if( !pc_inventoryblank(sd) ) { clif_colormes(sd, color_table[COLOR_RED], msg_txt(sd, 1477)); //Item cannot be open when inventory is full - return 0; + return false; } } //Gender check if(item->sex != 2 && sd->status.sex != item->sex) - return 0; + return false; //Required level check if(item->elv && sd->status.base_level < (unsigned int)item->elv) - return 0; + return false; #ifdef RENEWAL if(item->elvmax && sd->status.base_level > (unsigned int)item->elvmax) - return 0; + return false; #endif //Not equipable by class. [Skotlex] @@ -4565,7 +4630,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) (1<<(sd->class_&MAPID_BASEMASK)) & (item->class_base[sd->class_&JOBL_2_1?1:(sd->class_&JOBL_2_2?2:0)]) )) - return 0; + return false; if (sd->sc.count && ( sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAYNIGHTFEVER] || @@ -4578,16 +4643,16 @@ int pc_isUseitem(struct map_session_data *sd,int n) sd->sc.data[SC_KAGEHUMI] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOITEM) || sd->sc.data[SC_HEAT_BARREL_AFTER])) - return 0; + return false; if (!pc_isItemClass(sd,item)) - return 0; + return false; //Dead Branch items if( item->flag.dead_branch ) log_branch(sd); - return 1; + return true; } /*========================================== @@ -4729,30 +4794,32 @@ int pc_useitem(struct map_session_data *sd,int n) return 1; } -/*========================================== +/** * Add item on cart for given index. - * Return: - * 0 = success - * 1 = fail - *------------------------------------------*/ -int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type) + * @param sd + * @param item + * @param amount + * @param log_type + * @return 0 = success; 1 = fail; 2 = no slot + */ +unsigned char pc_cart_additem(struct map_session_data *sd,struct item *item,int amount,e_log_pick_type log_type) { struct item_data *data; int i,w; nullpo_retr(1, sd); - nullpo_retr(1, item_data); + nullpo_retr(1, item); - if(item_data->nameid <= 0 || amount <= 0) + if(item->nameid <= 0 || amount <= 0) return 1; - data = itemdb_search(item_data->nameid); + data = itemdb_search(item->nameid); if( data->stack.cart && amount > data->stack.amount ) {// item stack limitation return 1; } - if( !itemdb_cancartstore(item_data, pc_get_group_level(sd)) || (item_data->bound > BOUND_ACCOUNT && !pc_can_give_bounded_items(sd))) + if( !itemdb_cancartstore(item, pc_get_group_level(sd)) || (item->bound > BOUND_ACCOUNT && !pc_can_give_bounded_items(sd))) { // Check item trade restrictions [Skotlex] clif_displaymessage (sd->fd, msg_txt(sd,264)); return 1; @@ -4762,15 +4829,15 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun return 1; // ID no longer points to inventory/kafra ID. While we get a new one we don't want to mess up vending creation. - item_data->id = 0; + item->id = 0; i = MAX_CART; - if( itemdb_isstackable2(data) && !item_data->expire_time ) + if( itemdb_isstackable2(data) && !item->expire_time ) { ARR_FIND( 0, MAX_CART, i, - sd->status.cart[i].nameid == item_data->nameid && sd->status.cart[i].bound == item_data->bound && - sd->status.cart[i].card[0] == item_data->card[0] && sd->status.cart[i].card[1] == item_data->card[1] && - sd->status.cart[i].card[2] == item_data->card[2] && sd->status.cart[i].card[3] == item_data->card[3] ); + sd->status.cart[i].nameid == item->nameid && sd->status.cart[i].bound == item->bound && + sd->status.cart[i].card[0] == item->card[0] && sd->status.cart[i].card[1] == item->card[1] && + sd->status.cart[i].card[2] == item->card[2] && sd->status.cart[i].card[3] == item->card[3] ); }; if( i < MAX_CART ) @@ -4787,7 +4854,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun if( i == MAX_CART ) return 2; // no slot - memcpy(&sd->status.cart[i],item_data,sizeof(sd->status.cart[0])); + memcpy(&sd->status.cart[i],item,sizeof(sd->status.cart[0])); sd->status.cart[i].amount=amount; sd->cart_num++; clif_cart_additem(sd,i,amount,0); @@ -4803,17 +4870,14 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun /*========================================== * Delete item on cart for given index. - * Return: - * 0 = success - * 1 = fail *------------------------------------------*/ -int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,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) { - nullpo_retr(1, sd); + nullpo_retv(sd); - if(sd->status.cart[n].nameid==0 || + if(sd->status.cart[n].nameid == 0 || sd->status.cart[n].amountstatus.cart[n]); @@ -4827,35 +4891,32 @@ int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_ clif_cart_delitem(sd,n,amount); clif_updatestatus(sd,SP_CARTINFO); } - - return 0; } /*========================================== * Transfer item from inventory to cart. - * Return: - * 0 = fail - * 1 = succes *------------------------------------------*/ -int pc_putitemtocart(struct map_session_data *sd,int idx,int amount) +void pc_putitemtocart(struct map_session_data *sd,int idx,int amount) { struct item *item_data; - short flag; + char flag; - nullpo_ret(sd); + nullpo_retv(sd); if (idx < 0 || idx >= MAX_INVENTORY) //Invalid index check [Skotlex] - return 1; + return; item_data = &sd->status.inventory[idx]; if( item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending ) - return 1; + return; if( (flag = pc_cart_additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0 ) - return pc_delitem(sd,idx,amount,0,5,LOG_TYPE_NONE); - - return flag; + pc_delitem(sd,idx,amount,0,5,LOG_TYPE_NONE); + else { + clif_dropitem(sd,idx,0); + clif_cart_additem_ack(sd,(flag==1)?ADDITEM_TO_CART_FAIL_WEIGHT:ADDITEM_TO_CART_FAIL_COUNT); + } } /*========================================== @@ -4879,29 +4940,26 @@ int pc_cartitem_amount(struct map_session_data* sd, int idx, int amount) /*========================================== * Retrieve an item at index idx from cart. - * Return: - * 0 = player not found or (FIXME) succes (from pc_cart_delitem) - * 1 = failure *------------------------------------------*/ -int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount) +void pc_getitemfromcart(struct map_session_data *sd,int idx,int amount) { struct item *item_data; - int flag; + unsigned char flag = 0; - nullpo_ret(sd); + nullpo_retv(sd); if (idx < 0 || idx >= MAX_CART) //Invalid index check [Skotlex] - return 1; + return; item_data=&sd->status.cart[idx]; if(item_data->nameid==0 || amount < 1 || item_data->amountstate.vending ) - return 1; + return; if((flag = pc_additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0) - return pc_cart_delitem(sd,idx,amount,0,LOG_TYPE_NONE); - + pc_cart_delitem(sd,idx,amount,0,LOG_TYPE_NONE); + else + clif_dropitem(sd,idx,0); clif_additem(sd,0,0,flag); - return 1; } /*========================================== @@ -4954,8 +5012,9 @@ int pc_show_steal(struct block_list *bl,va_list ap) *------------------------------------------*/ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skill_lv) { - int i,itemid,flag; + int i,itemid; double rate; + unsigned char flag = 0; struct status_data *sd_status, *md_status; struct mob_data *md; struct item tmp_item; @@ -5064,12 +5123,14 @@ int pc_steal_coin(struct map_session_data *sd,struct block_list *target) /*========================================== * Set's a player position. - * Return values: - * 0 - Success. - * 1 - Invalid map index. - * 2 - Map not in this map-server, and failed to locate alternate map-server. + * @param sd + * @param mapindex + * @param x + * @param y + * @param clrtype + * @return 0 - Success; 1 - Invalid map index; 2 - Map not in this map-server, and failed to locate alternate map-server. *------------------------------------------*/ -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) { int16 m; @@ -5232,10 +5293,10 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y * Warp player sd to random location on current map. * May fail if no walkable cell found (1000 attempts). * Return: - * 0 = fail or FIXME success (from pc_setpos) - * x(1|2) = fail + * 0 = Success + * 1,2,3 = Fail *------------------------------------------*/ -int pc_randomwarp(struct map_session_data *sd, clr_type type) +char pc_randomwarp(struct map_session_data *sd, clr_type type) { int x,y,i=0; int16 m; @@ -5245,7 +5306,7 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) m=sd->bl.m; if (map[sd->bl.m].flag.noteleport) //Teleport forbidden - return 0; + return 3; do { x = rnd()%(map[m].xs-2)+1; @@ -5255,14 +5316,14 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) if (i < 1000) return pc_setpos(sd,map[sd->bl.m].index,x,y,type); - return 0; + return 3; } /*========================================== * Records a memo point at sd's current position * pos - entry to replace, (-1: shift oldest entry out) *------------------------------------------*/ -int pc_memo(struct map_session_data* sd, int pos) +bool pc_memo(struct map_session_data* sd, int pos) { int skill; @@ -5271,27 +5332,27 @@ int pc_memo(struct map_session_data* sd, int pos) // check mapflags if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { clif_skill_teleportmessage(sd, 1); // "Saved point cannot be memorized." - return 0; + return false; } // check inputs if( pos < -1 || pos >= MAX_MEMOPOINTS ) - return 0; // invalid input + return false; // invalid input // check required skill level skill = pc_checkskill(sd, AL_WARP); if( skill < 1 ) { clif_skill_memomessage(sd,2); // "You haven't learned Warp." - return 0; + return false; } if( skill < 2 || skill - 2 < pos ) { clif_skill_memomessage(sd,1); // "Skill Level is not high enough." - return 0; + return false; } if( pos == -1 ) { - int i; + uint8 i; // prevent memo-ing the same map multiple times ARR_FIND( 0, MAX_MEMOPOINTS, i, sd->status.memo_point[i].map == map_id2index(sd->bl.m) ); memmove(&sd->status.memo_point[1], &sd->status.memo_point[0], (min(i,MAX_MEMOPOINTS-1))*sizeof(struct point)); @@ -5300,7 +5361,7 @@ int pc_memo(struct map_session_data* sd, int pos) if( map[sd->bl.m].instance_id ) { clif_displaymessage( sd->fd, msg_txt(sd,384) ); // You cannot create a memo in an instance. - return 0; + return false; } sd->status.memo_point[pos].map = map_id2index(sd->bl.m); @@ -5309,7 +5370,7 @@ int pc_memo(struct map_session_data* sd, int pos) clif_skill_memomessage(sd, 0); - return 1; + return true; } // @@ -5344,7 +5405,7 @@ int pc_get_skillcooldown(struct map_session_data *sd, uint16 skill_id, uint16 sk /*========================================== * Return player sd skill_lv learned for given skill *------------------------------------------*/ -int pc_checkskill(struct map_session_data *sd,uint16 skill_id) +uint8 pc_checkskill(struct map_session_data *sd,uint16 skill_id) { if(sd == NULL) return 0; if( skill_id >= GD_SKILLBASE && skill_id < GD_MAX ) { @@ -6363,6 +6424,14 @@ int pc_gets_status_point(int level) return ((level+15) / 5); } +#ifdef RENEWAL_STAT +/// Renewal status point cost formula +#define PC_STATUS_POINT_COST(low) (((low) < 100) ? (2 + ((low) - 1) / 10) : (16 + 4 * (((low) - 100) / 5))) +#else +/// Pre-Renewal status point cost formula +#define PC_STATUS_POINT_COST(low) (( 1 + ((low) + 9) / 10 )) +#endif + /// Returns the number of stat points needed to change the specified stat by val. /// If val is negative, returns the number of stat points that would be needed to /// raise the specified stat from (current value - val) to current value. @@ -6385,11 +6454,7 @@ int pc_need_status_point(struct map_session_data* sd, int type, int val) swap(low, high); for ( ; low < high; low++ ) -#ifdef RENEWAL_STAT // renewal status point cost formula - sp += (low < 100) ? (2 + (low - 1) / 10) : (16 + 4 * ((low - 100) / 5)); -#else - sp += ( 1 + (low + 9) / 10 ); -#endif + sp += PC_STATUS_POINT_COST(low); return sp; } @@ -6404,16 +6469,16 @@ int pc_need_status_point(struct map_session_data* sd, int type, int val) */ int pc_maxparameterincrease(struct map_session_data* sd, int type) { - int base, final_val, status_points = sd->status.status_point; + int base, final_val, status_points, max_param; + + nullpo_ret(sd); base = final_val = pc_getstat(sd, type); + status_points = sd->status.status_point; + max_param = pc_maxparameter(sd, (enum e_params)(type-SP_STR)); - while (final_val <= pc_maxparameter(sd, (enum e_params)(type-SP_STR)) && status_points >= 0) { -#ifdef RENEWAL_STAT // renewal status point cost formula - status_points -= (final_val < 100) ? (2 + (final_val - 1) / 10) : (16 + 4 * ((final_val - 100) / 5)); -#else - status_points -= ( 1 + (final_val + 9) / 10 ); -#endif + while (final_val <= max_param && status_points >= 0) { + status_points -= PC_STATUS_POINT_COST(final_val); final_val++; } final_val--; @@ -8793,16 +8858,15 @@ static int pc_checkcombo(struct map_session_data *sd, struct item_data *data) { for( k = 0; k < EQI_MAX; k++ ) { bool do_continue = false; //used to continue that specific loop with some check that also use some loop - int16 index; + int8 index; index = sd->equip_index[k]; - if( index < 0 ) continue; - if( k == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index ) continue; - if( k == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index ) continue; - if( k == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index) ) continue; - - if(!sd->inventory_data[index]) + if( index < 0 ) continue; - if(j>0){ + if( pc_is_same_equip_index((enum equip_index)k, sd->equip_index, index) ) + continue; + if (!sd->inventory_data[index] ) + continue; + if( j > 0 ) { uint8 z; for (z = 0; z < data->combos[i]->count; z++) if(combo_idx[z] == index) //we already have that index recorded @@ -8941,7 +9005,7 @@ int pc_load_combo(struct map_session_data *sd) { * Equip item on player sd at req_pos from inventory index n * return: false - fail; true - success *------------------------------------------*/ -bool pc_equipitem(struct map_session_data *sd,int n,int req_pos) +bool pc_equipitem(struct map_session_data *sd,short n,int req_pos) { int i,pos,flag=0,iflag; struct item_data *id; @@ -9865,11 +9929,11 @@ static int pc_talisman_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } -int pc_add_talisman(struct map_session_data *sd,int interval,int max,int type) +void pc_add_talisman(struct map_session_data *sd,int interval,int max,int type) { int tid, i; - nullpo_ret(sd); + nullpo_retv(sd); if(max > 10) max = 10; @@ -9894,22 +9958,21 @@ int pc_add_talisman(struct map_session_data *sd,int interval,int max,int type) sd->talisman[type]++; clif_talisman(sd, type); - return 0; } -int pc_del_talisman(struct map_session_data *sd,int count,int type) +void pc_del_talisman(struct map_session_data *sd,int count,int type) { int i; - nullpo_ret(sd); + nullpo_retv(sd); if( sd->talisman[type] <= 0 ) { sd->talisman[type] = 0; - return 0; + return; } if( count <= 0 ) - return 0; + return; if( count > sd->talisman[type] ) count = sd->talisman[type]; sd->talisman[type] -= count; @@ -9928,8 +9991,8 @@ int pc_del_talisman(struct map_session_data *sd,int count,int type) } clif_talisman(sd, type); - return 0; } + #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) /*========================================== * Renewal EXP/Itemdrop rate modifier base on level penalty @@ -9958,6 +10021,7 @@ int pc_level_penalty_mod(struct map_session_data *sd, int mob_level, uint32 mob_ return rate; } #endif + int pc_split_str(char *str,char **val,int num) { int i; @@ -10951,6 +11015,34 @@ short pc_get_itemgroup_bonus_group(struct map_session_data* sd, uint16 group_id) return bonus; } +/** +* Check if player's equip index in same specified position, like for 2-Handed weapon & Heagdear (inc. costume) +* @param eqi Item EQI of enum equip_index +* @param *equip_index Player's equip_index[] +* @param index Known index item in inventory from sd->equip_index[] to compare with specified EQI in *equip_index +* @return True if item in same inventory index, False if doesn't +*/ +bool pc_is_same_equip_index(enum equip_index eqi, int *equip_index, int8 index) { + if (index < 0 || index >= ARRAYLENGTH(equip_index)) + return false; + // Dual weapon checks + if (eqi == EQI_HAND_R && equip_index[EQI_HAND_L] == index) + return true; + // Headgear with Mid & Low location + else if (eqi == EQI_HEAD_MID && equip_index[EQI_HEAD_LOW] == index) + return true; + // Headgear with Top & Mid or Low location + else if (eqi == EQI_HEAD_TOP && (equip_index[EQI_HEAD_MID] == index || equip_index[EQI_HEAD_LOW] == index)) + return true; + // Headgear with Mid & Low location + else if (eqi == EQI_COSTUME_MID && equip_index[EQI_COSTUME_LOW] == index) + return true; + // Headgear with Top & Mid or Low location + else if (eqi == EQI_COSTUME_TOP && (equip_index[EQI_COSTUME_MID] == index || equip_index[EQI_COSTUME_LOW] == index)) + return true; + return false; +} + /*========================================== * pc Init/Terminate *------------------------------------------*/ diff --git a/src/map/pc.h b/src/map/pc.h index 050ca5c0c1..6512b46207 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -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 diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index a1e77cb813..7bcb7c1818 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -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 }, }; diff --git a/src/map/pet.c b/src/map/pet.c index 4f4cce806c..e13869886f 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -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;iloot->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); diff --git a/src/map/script.c b/src/map/script.c index 9b9c205d04..7c33cc1a75 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -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; jequip_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; jequip_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 ,{,} */ 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; } diff --git a/src/map/script.h b/src/map/script.h index 88fa7d63dd..0e74b85ed5 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -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 { diff --git a/src/map/skill.c b/src/map/skill.c index ff9b300908..c5c9086e81 100755 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -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;ibl.m,sd->bl.x,sd->bl.y,0,0,0,0); diff --git a/src/map/status.c b/src/map/status.c index 85332516c6..83cd638294 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -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]) { diff --git a/src/map/storage.c b/src/map/storage.c index 07ee6ce509..397c1ad780 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -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; } /** diff --git a/src/map/storage.h b/src/map/storage.h index b67dc327dd..5d08763905 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -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); diff --git a/src/map/trade.c b/src/map/trade.c index 4d08c584c3..0ae828fdbe 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -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;