summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c33
-rw-r--r--src/common/mmo.h7
-rw-r--r--src/map/achievement.c3
-rw-r--r--src/map/atcommand.c24
-rw-r--r--src/map/chrif.c4
-rw-r--r--src/map/clif.c90
-rw-r--r--src/map/mail.c4
-rw-r--r--src/map/npc.c2
-rw-r--r--src/map/packets_struct.h2
-rw-r--r--src/map/pc.c82
-rw-r--r--src/map/pc.h1
-rw-r--r--src/map/pet.c14
-rw-r--r--src/map/quest.c2
-rw-r--r--src/map/rodex.c6
-rw-r--r--src/map/script.c72
-rw-r--r--src/map/skill.c20
-rw-r--r--src/map/status.c2
-rw-r--r--src/map/storage.c4
-rw-r--r--src/map/trade.c28
19 files changed, 208 insertions, 192 deletions
diff --git a/src/char/char.c b/src/char/char.c
index e08933f7b..0546e49df 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -479,11 +479,18 @@ static int char_mmo_char_tosql(int char_id, struct mmo_charstatus *p)
(p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) ||
(p->uniqueitem_counter != cp->uniqueitem_counter) || (p->hotkey_rowshift != cp->hotkey_rowshift) ||
(p->clan_id != cp->clan_id) || (p->last_login != cp->last_login) || (p->attendance_count != cp->attendance_count) ||
- (p->attendance_timer != cp->attendance_timer) || (p->title_id != cp->title_id)
+ (p->attendance_timer != cp->attendance_timer) || (p->title_id != cp->title_id) || (p->inventorySize != cp->inventorySize)
) {
//Save status
unsigned int opt = 0;
+ if (p->inventorySize <= 0 || p->inventorySize > MAX_INVENTORY) {
+ ShowError("Wrong inventorySize field: %d. Must be in range 1 to %d. Character %s (CID: %d, AID: %d)\n",
+ p->inventorySize, MAX_INVENTORY, p->name, p->char_id, p->account_id);
+ Assert_report(0);
+ p->inventorySize = FIXED_INVENTORY_SIZE;
+ }
+
if( p->allow_party )
opt |= OPT_ALLOW_PARTY;
if( p->show_equip )
@@ -498,7 +505,7 @@ static int char_mmo_char_tosql(int char_id, struct mmo_charstatus *p)
"`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `rename`='%d',"
"`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u', `font`='%u', `uniqueitem_counter` ='%u',"
"`hotkey_rowshift`='%d',`clan_id`='%d',`last_login`='%"PRId64"',`attendance_count`='%d',`attendance_timer`='%"PRId64"',"
- "`title_id`='%d'"
+ "`title_id`='%d', `inventory_size`='%d'"
" WHERE `account_id`='%d' AND `char_id` = '%d'",
char_db, p->base_level, p->job_level,
p->base_exp, p->job_exp, p->zeny,
@@ -511,7 +518,7 @@ static int char_mmo_char_tosql(int char_id, struct mmo_charstatus *p)
(unsigned long)p->delete_date, // FIXME: platform-dependent size
p->look.robe,p->slotchange,opt,p->font,p->uniqueitem_counter,
p->hotkey_rowshift,p->clan_id,p->last_login, p->attendance_count, p->attendance_timer,
- p->title_id,
+ p->title_id, p->inventorySize,
p->account_id, p->char_id) )
{
Sql_ShowDebug(inter->sql_handle);
@@ -1085,7 +1092,7 @@ static int char_mmo_chars_fromsql(struct char_session_data *sd, uint8 *buf, int
"`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`,"
"`status_point`,`skill_point`,`option`,`karma`,`manner`,`hair`,`hair_color`,"
"`clothes_color`,`body`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`rename`,`delete_date`,"
- "`robe`,`slotchange`,`unban_time`,`sex`,`title_id`"
+ "`robe`,`slotchange`,`unban_time`,`sex`,`title_id`,`inventory_size`"
" FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", char_db, sd->account_id, MAX_CHARS)
|| SQL_ERROR == SQL->StmtExecute(stmt)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p.char_id, sizeof p.char_id, NULL, NULL)
@@ -1129,6 +1136,7 @@ static int char_mmo_chars_fromsql(struct char_session_data *sd, uint8 *buf, int
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_TIME, &unban_time, sizeof unban_time, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_ENUM, &sex, sizeof sex, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 40, SQLDT_INT, &p.title_id, sizeof p.title_id, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 41, SQLDT_INT, &p.inventorySize, sizeof p.inventorySize, NULL, NULL)
) {
SqlStmt_ShowDebug(stmt);
SQL->StmtFree(stmt);
@@ -1139,6 +1147,12 @@ static int char_mmo_chars_fromsql(struct char_session_data *sd, uint8 *buf, int
for (i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->StmtNextRow(stmt); i++) {
if (p.slot >= MAX_CHARS)
continue;
+ if (p.inventorySize <= 0 || p.inventorySize > MAX_INVENTORY) {
+ ShowError("Wrong inventorySize field: %d. Must be in range 1 to %d. Character %s (CID: %d, AID: %d)\n",
+ p.inventorySize, MAX_INVENTORY, p.name, p.char_id, p.account_id);
+ Assert_report(0);
+ p.inventorySize = FIXED_INVENTORY_SIZE;
+ }
p.last_point.map = mapindex->name2id(last_map);
sd->found_char[p.slot] = p.char_id;
sd->unban_time[p.slot] = unban_time;
@@ -1179,6 +1193,7 @@ static int char_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool loa
nullpo_ret(p);
memset(p, 0, sizeof(struct mmo_charstatus));
+ p->inventorySize = FIXED_INVENTORY_SIZE;
if (chr->show_save_log)
ShowInfo("Char load request (%d)\n", char_id);
@@ -1198,7 +1213,7 @@ static int char_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool loa
"`hair_color`,`clothes_color`,`body`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`last_x`,`last_y`,"
"`save_map`,`save_x`,`save_y`,`partner_id`,`father`,`mother`,`child`,`fame`,`rename`,`delete_date`,`robe`,`slotchange`,"
"`char_opt`,`font`,`uniqueitem_counter`,`sex`,`hotkey_rowshift`,`clan_id`,`last_login`, `attendance_count`, `attendance_timer`,"
- "`title_id`"
+ "`title_id`, `inventory_size`"
" FROM `%s` WHERE `char_id`=? LIMIT 1", char_db)
|| SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, sizeof char_id)
|| SQL_ERROR == SQL->StmtExecute(stmt)
@@ -1266,6 +1281,7 @@ static int char_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool loa
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 61, SQLDT_SHORT, &p->attendance_count, sizeof p->attendance_count, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 62, SQLDT_INT64, &p->attendance_timer, sizeof p->attendance_timer, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 63, SQLDT_INT, &p->title_id, sizeof p->title_id, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 64, SQLDT_INT, &p->inventorySize, sizeof p->inventorySize, NULL, NULL)
) {
SqlStmt_ShowDebug(stmt);
SQL->StmtFree(stmt);
@@ -1297,6 +1313,13 @@ static int char_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool loa
p->save_point.y = mapindex->default_y;
}
+ if (p->inventorySize <= 0 || p->inventorySize > MAX_INVENTORY) {
+ ShowError("Wrong inventorySize field: %d. Must be in range 1 to %d. Character %s (CID: %d, AID: %d)\n",
+ p->inventorySize, MAX_INVENTORY, p->name, p->char_id, p->account_id);
+ Assert_report(0);
+ p->inventorySize = FIXED_INVENTORY_SIZE;
+ }
+
strcat(t_msg, " status");
if (!load_everything) // For quick selection of data when displaying the char menu
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 8b6bef431..4b8f49fa2 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -166,8 +166,12 @@
#define MAX_CARTS (MAX_BASE_CARTS + MAX_CARTDECORATION_CARTS)
#ifndef MAX_INVENTORY
+#if PACKETVER_ZERO_NUM >= 20181212
+#define MAX_INVENTORY 200
+#else
#define MAX_INVENTORY 100
-#endif
+#endif // PACKETVER_ZERO_NUM >= 20181212
+#endif // MAX_INVENTORY
#ifndef FIXED_INVENTORY_SIZE
#define FIXED_INVENTORY_SIZE 100
@@ -721,6 +725,7 @@ struct mmo_charstatus {
int64 last_login;
struct point last_point,save_point,memo_point[MAX_MEMOPOINTS];
+ int inventorySize;
struct item inventory[MAX_INVENTORY],cart[MAX_CART];
struct s_skill skill[MAX_SKILL_DB];
diff --git a/src/map/achievement.c b/src/map/achievement.c
index 7148acae8..057ea29c3 100644
--- a/src/map/achievement.c
+++ b/src/map/achievement.c
@@ -760,14 +760,13 @@ static void achievement_validate_refine(struct map_session_data *sd, unsigned in
struct item_data *id = NULL;
nullpo_retv(sd);
- Assert_retv(idx < MAX_INVENTORY);
+ Assert_retv(idx < sd->status.inventorySize);
id = itemdb->exists(sd->status.inventory[idx].nameid);
if (sd->achievements_received == false)
return;
- Assert_retv(idx < MAX_INVENTORY);
Assert_retv(id != NULL);
criteria.goal = sd->status.inventory[idx].refine;
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 6cfa86163..0a1fd6da3 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1359,9 +1359,7 @@ ACMD(item2)
*------------------------------------------*/
ACMD(itemreset)
{
- int i;
-
- for (i = 0; i < MAX_INVENTORY; i++) {
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_COMMAND);
}
@@ -4274,10 +4272,8 @@ ACMD(partyspy)
*------------------------------------------*/
ACMD(repairall)
{
- int count, i;
-
- count = 0;
- for (i = 0; i < MAX_INVENTORY; i++) {
+ int count = 0;
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].card[0] == CARD0_PET)
continue;
if (sd->status.inventory[i].nameid && (sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) {
@@ -5286,9 +5282,7 @@ ACMD(follow)
*------------------------------------------*/
ACMD(dropall)
{
- int i;
-
- for (i = 0; i < MAX_INVENTORY; i++) {
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].amount) {
if(sd->status.inventory[i].equip != 0)
pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
@@ -5304,8 +5298,6 @@ ACMD(dropall)
*------------------------------------------*/
ACMD(storeall)
{
- int i;
-
if (sd->state.storage_flag != STORAGE_FLAG_NORMAL) {
//Open storage.
if (storage->open(sd) == 1) {
@@ -5319,7 +5311,7 @@ ACMD(storeall)
return false;
}
- for (i = 0; i < MAX_INVENTORY; i++) {
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].amount) {
if(sd->status.inventory[i].equip != 0)
pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
@@ -6714,9 +6706,9 @@ ACMD(refreshall)
*------------------------------------------*/
ACMD(identify)
{
- int i,num;
+ int num = 0;
- for (i=num=0;i<MAX_INVENTORY;i++) {
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
num++;
}
@@ -8256,7 +8248,7 @@ ACMD(itemlist)
} else if( strcmpi(info->command, "itemlist") == 0 ) {
location = "inventory";
items = sd->status.inventory;
- size = MAX_INVENTORY;
+ size = sd->status.inventorySize;
} else
return false;
diff --git a/src/map/chrif.c b/src/map/chrif.c
index af3504ca2..a3277d4c2 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -975,14 +975,14 @@ static bool chrif_divorceack(int char_id, int partner_id)
if( ( sd = map->charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) {
sd->status.partner_id = 0;
- for(i = 0; i < MAX_INVENTORY; i++)
+ for (i = 0; i < sd->status.inventorySize; i++)
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_DIVORCE);
}
if( ( sd = map->charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) {
sd->status.partner_id = 0;
- for(i = 0; i < MAX_INVENTORY; i++)
+ for (i = 0; i < sd->status.inventorySize; i++)
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_DIVORCE);
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 659ff920e..123dd1a52 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -2162,14 +2162,14 @@ static void clif_buylist(struct map_session_data *sd, struct npc_data *nd)
/// 00c7 <packet len>.W { <index>.W <price>.L <overcharge price>.L }*
static void clif_selllist(struct map_session_data *sd)
{
- int fd,i,c=0,val;
+ int c = 0, val;
nullpo_retv(sd);
- fd=sd->fd;
- WFIFOHEAD(fd, MAX_INVENTORY * 10 + 4);
+ int fd = sd->fd;
+ WFIFOHEAD(fd, sd->status.inventorySize * 10 + 4);
WFIFOW(fd,0)=0xc7;
- for( i = 0; i < MAX_INVENTORY; i++ )
+ for (int i = 0; i < sd->status.inventorySize; i++)
{
if( sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] )
{
@@ -2584,7 +2584,7 @@ static void clif_additem(struct map_session_data *sd, int n, int amount, int fai
p.count = amount;
if( !fail ) {
- if( n < 0 || n >= MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL )
+ if (n < 0 || n >= sd->status.inventorySize || sd->status.inventory[n].nameid <= 0 || sd->inventory_data[n] == NULL)
return;
if (sd->inventory_data[n]->view_id > 0)
@@ -2806,7 +2806,7 @@ static void clif_inventoryItems(struct map_session_data *sd, enum inventory_type
int i, normal = 0, equip = 0;
nullpo_retv(sd);
- for( i = 0; i < MAX_INVENTORY; i++ ) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
if( sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL )
continue;
@@ -2840,7 +2840,7 @@ static void clif_inventoryItems(struct map_session_data *sd, enum inventory_type
}
/* on 20120925 onwards this is a field on clif_item_equip/normal */
#if PACKETVER >= 20111122 && PACKETVER < 20120925
- for( i = 0; i < MAX_INVENTORY; i++ ) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
if( sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL )
continue;
@@ -2868,7 +2868,7 @@ static void clif_equipItems(struct map_session_data *sd, enum inventory_type typ
int i, equip = 0;
nullpo_retv(sd);
- for( i = 0; i < MAX_INVENTORY; i++ ) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
if( sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL )
continue;
@@ -2888,7 +2888,7 @@ static void clif_equipItems(struct map_session_data *sd, enum inventory_type typ
/* on 20120925 onwards this is a field on clif_item_equip */
#if PACKETVER >= 20111122 && PACKETVER < 20120925
- for( i = 0; i < MAX_INVENTORY; i++ ) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
if( sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL )
continue;
@@ -3073,7 +3073,7 @@ static void clif_inventoryExpansionInfo(struct map_session_data *sd)
WFIFOHEAD(fd, sizeof(struct PACKET_ZC_INVENTORY_EXPANSION_INFO));
struct PACKET_ZC_INVENTORY_EXPANSION_INFO *p = WFIFOP(fd, 0);
p->packetType = HEADER_ZC_INVENTORY_EXPANSION_INFO;
- p->expansionSize = sd->inventorySize - FIXED_INVENTORY_SIZE;
+ p->expansionSize = sd->status.inventorySize - FIXED_INVENTORY_SIZE;
WFIFOSET(fd, sizeof(struct PACKET_ZC_INVENTORY_EXPANSION_INFO));
#endif
}
@@ -3917,7 +3917,7 @@ static void clif_equipitemack(struct map_session_data *sd, int n, int pos, enum
p.index = n+2;
p.wearLocation = pos;
#if PACKETVER >= 20100629
- Assert_retv(n >= 0 && n < MAX_INVENTORY);
+ Assert_retv(n >= 0 && n < sd->status.inventorySize);
if (result == EIA_SUCCESS && sd->inventory_data[n]->equip&EQP_VISIBLE)
p.wItemSpriteNumber = sd->inventory_data[n]->view_sprite;
else
@@ -4059,7 +4059,7 @@ static void clif_useitemack(struct map_session_data *sd, int index, int amount,
nullpo_retv(sd);
- if (index < 0 || index >= MAX_INVENTORY)
+ if (index < 0 || index >= sd->status.inventorySize)
return;
fd = sd->fd;
@@ -4408,7 +4408,7 @@ static void clif_tradeadditem(struct map_session_data *sd, struct map_session_da
if (index != 0)
{
index -= 2; //index fix
- Assert_retv(index >= 0 && index < MAX_INVENTORY);
+ Assert_retv(index >= 0 && index < sd->status.inventorySize);
if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
p.itemId = sd->inventory_data[index]->view_id;
else
@@ -6471,10 +6471,10 @@ static void clif_use_card(struct map_session_data *sd, int idx)
if (!pc->can_insert_card(sd, idx))
return;
- WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4);
+ WFIFOHEAD(fd, sd->status.inventorySize * 2 + 4);
WFIFOW(fd, 0) = 0x17b;
- for (i = c = 0; i < MAX_INVENTORY; i++) {
+ for (i = c = 0; i < sd->status.inventorySize; i++) {
if (!pc->can_insert_card_into(sd, idx, i))
continue;
WFIFOW(fd, 4 + c * 2) = i + 2;
@@ -6518,9 +6518,9 @@ static void clif_item_identify_list(struct map_session_data *sd)
fd=sd->fd;
- WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4);
+ WFIFOHEAD(fd, sd->status.inventorySize * 2 + 4);
WFIFOW(fd,0)=0x177;
- for(i=c=0;i<MAX_INVENTORY;i++){
+ for (i = c = 0; i < sd->status.inventorySize; i++) {
if(sd->status.inventory[i].nameid > 0 && !sd->status.inventory[i].identify){
WFIFOW(fd,c*2+4)=i+2;
c++;
@@ -6565,11 +6565,11 @@ static void clif_item_repair_list(struct map_session_data *sd, struct map_sessio
fd = sd->fd;
- len = MAX_INVENTORY * sizeof(struct PACKET_ZC_REPAIRITEMLIST_sub) + sizeof(struct PACKET_ZC_REPAIRITEMLIST);
+ len = dstsd->status.inventorySize * sizeof(struct PACKET_ZC_REPAIRITEMLIST_sub) + sizeof(struct PACKET_ZC_REPAIRITEMLIST);
WFIFOHEAD(fd, len);
p = WFIFOP(fd, 0);
p->packetType = 0x1fc;
- for (i = c = 0; i < MAX_INVENTORY; i++) {
+ for (i = c = 0; i < sd->status.inventorySize; i++) {
int nameid = dstsd->status.inventory[i].nameid;
if (nameid > 0 && (dstsd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { // && skill_can_repair(sd,nameid)) {
p->items[c].index = i;
@@ -6645,11 +6645,11 @@ static void clif_item_refine_list(struct map_session_data *sd)
skill_lv = pc->checkskill(sd, WS_WEAPONREFINE);
fd = sd->fd;
- len = MAX_INVENTORY * sizeof(struct PACKET_ZC_NOTIFY_WEAPONITEMLIST_sub) + sizeof(struct PACKET_ZC_NOTIFY_WEAPONITEMLIST);
+ len = sd->status.inventorySize * sizeof(struct PACKET_ZC_NOTIFY_WEAPONITEMLIST_sub) + sizeof(struct PACKET_ZC_NOTIFY_WEAPONITEMLIST);
WFIFOHEAD(fd, len);
p = WFIFOP(fd, 0);
p->packetType = 0x221;
- for (i = c = 0; i < MAX_INVENTORY; i++) {
+ for (i = c = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify
&& itemdb_wlv(sd->status.inventory[i].nameid) >= 1
&& !sd->inventory_data[i]->flag.no_refine
@@ -7479,9 +7479,9 @@ static void clif_sendegg(struct map_session_data *sd)
return;
}
- WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4);
+ WFIFOHEAD(fd, sd->status.inventorySize * 2 + 4);
WFIFOW(fd,0) = 0x1a6;
- for (i = n = 0; i < MAX_INVENTORY; i++) {
+ for (i = n = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL || sd->inventory_data[i]->type!=IT_PETEGG || sd->status.inventory[i].amount <= 0)
continue;
WFIFOW(fd, n * 2 + 4) = i + 2;
@@ -11394,7 +11394,7 @@ static void clif_parse_UseItem(int fd, struct map_session_data *sd)
pc->update_idle_time(sd, BCIDLE_USEITEM);
n = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0])-2;
- if (n < 0 || n >= MAX_INVENTORY)
+ if (n < 0 || n >= sd->status.inventorySize)
return;
if (!pc->useitem(sd,n))
clif->useitemack(sd,n,0,false); //Send an empty ack packet or the client gets stuck.
@@ -11415,7 +11415,7 @@ static void clif_parse_EquipItem(int fd, struct map_session_data *sd)
}
index = p->index - 2;
- if (index >= MAX_INVENTORY)
+ if (index >= sd->status.inventorySize)
return; //Out of bounds check.
if( sd->npc_id ) {
@@ -12606,7 +12606,7 @@ static void clif_parse_OneClick_ItemIdentify(int fd, struct map_session_data *sd
short idx = RFIFOW(fd, packet_db[cmd].pos[0]) - 2;
int n;
- if (idx < 0 || idx >= MAX_INVENTORY || sd->inventory_data[idx] == NULL || sd->status.inventory[idx].nameid <= 0)
+ if (idx < 0 || idx >= sd->status.inventorySize || sd->inventory_data[idx] == NULL || sd->status.inventory[idx].nameid <= 0)
return;
if ((n = pc->have_magnifier(sd) ) != INDEX_NOT_FOUND &&
@@ -12756,7 +12756,7 @@ static void clif_parse_MoveToKafra(int fd, struct map_session_data *sd)
item_index = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0])-2;
item_amount = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[1]);
- if (item_index < 0 || item_index >= MAX_INVENTORY || item_amount < 1)
+ if (item_index < 0 || item_index >= sd->status.inventorySize || item_amount < 1)
return;
if (sd->state.storage_flag == STORAGE_FLAG_NORMAL)
@@ -14407,10 +14407,10 @@ static void clif_parse_pet_evolution(int fd, struct map_session_data *sd)
return;
}
- ARR_FIND(0, MAX_INVENTORY, idx, sd->status.inventory[idx].card[0] == CARD0_PET &&
+ ARR_FIND(0, sd->status.inventorySize, idx, sd->status.inventory[idx].card[0] == CARD0_PET &&
sd->status.pet_id == MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
- if (idx == MAX_INVENTORY) {
+ if (idx == sd->status.inventorySize) {
clif->petEvolutionResult(fd, PET_EVOL_NO_PETEGG);
return;
}
@@ -16395,7 +16395,7 @@ static void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
if( sd->auction.amount > 0 )
sd->auction.amount = 0;
- if( idx < 0 || idx >= MAX_INVENTORY ) {
+ if (idx < 0 || idx >= sd->status.inventorySize) {
ShowWarning("Character %s trying to set invalid item index in auctions.\n", sd->status.name);
return;
}
@@ -16470,7 +16470,7 @@ static void clif_parse_Auction_register(int fd, struct map_session_data *sd)
if (!battle_config.feature_auction)
return;
- Assert_retv(sd->auction.index >= 0 && sd->auction.index < MAX_INVENTORY);
+ Assert_retv(sd->auction.index >= 0 && sd->auction.index < sd->status.inventorySize);
memset(&auction, 0, sizeof(auction));
auction.price = RFIFOL(fd,2);
@@ -17950,8 +17950,8 @@ static void clif_parse_ItemListWindowSelected(int fd, struct map_session_data *s
return; // Canceled by player.
}
- if (n > MAX_INVENTORY)
- n = MAX_INVENTORY; // It should be impossible to have more than that.
+ if (n > sd->status.inventorySize)
+ n = sd->status.inventorySize; // It should be impossible to have more than that.
if (sd->menuskill_id != SO_EL_ANALYSIS && sd->menuskill_id != GN_CHANGEMATERIAL) {
clif_menuskill_clear(sd);
@@ -18704,7 +18704,7 @@ static int clif_spellbook_list(struct map_session_data *sd)
WFIFOHEAD(fd, 8 * 8 + 8);
WFIFOW(fd,0) = 0x1ad;
- for( i = 0, c = 0; i < MAX_INVENTORY; i ++ )
+ for (i = 0, c = 0; i < sd->status.inventorySize; i ++ )
{
if( itemdb_is_spellbook(sd->status.inventory[i].nameid) )
{
@@ -18744,7 +18744,7 @@ static int clif_magicdecoy_list(struct map_session_data *sd, uint16 skill_lv, sh
WFIFOHEAD(fd, 8 * 8 + 8);
WFIFOW(fd,0) = 0x1ad; // This is the official packet. [pakpil]
- for( i = 0, c = 0; i < MAX_INVENTORY; i ++ ) {
+ for (i = 0, c = 0; i < sd->status.inventorySize; i ++) {
if( itemdb_is_element(sd->status.inventory[i].nameid) ) {
WFIFOW(fd, c * 2 + 4) = sd->status.inventory[i].nameid;
c ++;
@@ -18781,7 +18781,7 @@ static int clif_poison_list(struct map_session_data *sd, uint16 skill_lv)
WFIFOHEAD(fd, 8 * 8 + 8);
WFIFOW(fd,0) = 0x1ad; // This is the official packet. [pakpil]
- for( i = 0, c = 0; i < MAX_INVENTORY; i ++ ) {
+ for (i = 0, c = 0; i < sd->status.inventorySize; i ++) {
if( itemdb_is_poison(sd->status.inventory[i].nameid) ) {
WFIFOW(fd, c * 2 + 4) = sd->status.inventory[i].nameid;
c ++;
@@ -18922,7 +18922,7 @@ static void clif_parse_MoveItem(int fd, struct map_session_data *sd)
index = RFIFOW(fd,2)-2;
- if (index < 0 || index >= MAX_INVENTORY)
+ if (index < 0 || index >= sd->status.inventorySize)
return;
if ( sd->status.inventory[index].favorite && RFIFOB(fd, 4) == 1 )
@@ -19928,7 +19928,7 @@ static void clif_parse_NPCMarketPurchase(int fd, struct map_session_data *sd)
int count = (p->PacketLength - 4) / sizeof p->list[0];
struct itemlist item_list;
- Assert_retv(count >= 0 && count <= MAX_INVENTORY);
+ Assert_retv(count >= 0 && count <= sd->status.inventorySize);
VECTOR_INIT(item_list);
VECTOR_ENSURE(item_list, count, 1);
@@ -20266,7 +20266,7 @@ static void clif_openmergeitem(int fd, struct map_session_data *sd)
nullpo_retv(sd);
memset(&merge_items,'\0',sizeof(merge_items));
- for (i = 0; i < MAX_INVENTORY; i++) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
struct item *item_data = &sd->status.inventory[i];
if (item_data->nameid == 0 || !itemdb->isstackable(item_data->nameid) || item_data->bound != IBT_NONE)
@@ -20327,7 +20327,7 @@ static void clif_ackmergeitems(int fd, struct map_session_data *sd)
nullpo_retv(sd);
length = (RFIFOW(fd,2) - 4)/2;
- if (length >= MAX_INVENTORY || length < 2) {
+ if (length >= sd->status.inventorySize || length < 2) {
WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x96f;
WFIFOW(fd,2) = 0;
@@ -20341,7 +20341,7 @@ static void clif_ackmergeitems(int fd, struct map_session_data *sd)
int16 idx = RFIFOW(fd,i*2+4) - 2;
struct item *it = NULL;
- if (idx < 0 || idx >= MAX_INVENTORY)
+ if (idx < 0 || idx >= sd->status.inventorySize)
continue;
it = &sd->status.inventory[idx];
@@ -20391,7 +20391,7 @@ static void clif_ackmergeitems(int fd, struct map_session_data *sd)
item_data.unique_id = itemdb->unique_id(sd);
pc->additem(sd,&item_data,count,LOG_TYPE_NPC);
- ARR_FIND(0,MAX_INVENTORY,i,item_data.unique_id == sd->status.inventory[i].unique_id);
+ ARR_FIND(0, sd->status.inventorySize, i, item_data.unique_id == sd->status.inventory[i].unique_id);
WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x96f;
@@ -20950,7 +20950,7 @@ static void clif_rodex_add_item_result(struct map_session_data *sd, int16 idx, i
int fd, j;
nullpo_retv(sd);
- if (idx < 0 || idx >= MAX_INVENTORY)
+ if (idx < 0 || idx >= sd->status.inventorySize)
return;
fd = sd->fd;
@@ -21003,7 +21003,7 @@ static void clif_rodex_remove_item_result(struct map_session_data *sd, int16 idx
int fd;
nullpo_retv(sd);
- Assert_retv(idx >= 0 && idx < MAX_INVENTORY);
+ Assert_retv(idx >= 0 && idx < sd->status.inventorySize);
fd = sd->fd;
@@ -22128,7 +22128,7 @@ static void clif_item_preview(struct map_session_data *sd, int n)
{
#if PACKETVER_MAIN_NUM >= 20170726 || PACKETVER_RE_NUM >= 20170621 || defined(PACKETVER_ZERO)
nullpo_retv(sd);
- Assert_retv(n >= 0 && n < MAX_INVENTORY);
+ Assert_retv(n >= 0 && n < sd->status.inventorySize);
struct PACKET_ZC_ITEM_PREVIEW p;
p.packetType = HEADER_ZC_ITEM_PREVIEW;
diff --git a/src/map/mail.c b/src/map/mail.c
index d67e658fd..0a4b91e34 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -100,7 +100,7 @@ static unsigned char mail_setitem(struct map_session_data *sd, int idx, int amou
idx -= 2;
mail->removeitem(sd, 0);
- if( idx < 0 || idx >= MAX_INVENTORY )
+ if (idx < 0 || idx >= sd->status.inventorySize)
return 1;
if( amount <= 0 || amount > sd->status.inventory[idx].amount )
return 1;
@@ -128,7 +128,7 @@ static bool mail_setattachment(struct map_session_data *sd, struct mail_message
return false;
n = sd->mail.index;
- Assert_retr(false, n >= 0 && n < MAX_INVENTORY);
+ Assert_retr(false, n >= 0 && n < sd->status.inventorySize);
if( sd->mail.amount )
{
if( sd->status.inventory[n].nameid != sd->mail.nameid )
diff --git a/src/map/npc.c b/src/map/npc.c
index c59988c00..fd11b6c5f 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2235,7 +2235,7 @@ static int npc_selllist(struct map_session_data *sd, struct itemlist *item_list)
struct itemlist_entry *entry = &VECTOR_INDEX(*item_list, i);
int nameid, value, idx = entry->id;
- if (idx >= MAX_INVENTORY || idx < 0 || entry->amount < 0) {
+ if (idx >= sd->status.inventorySize || idx < 0 || entry->amount < 0) {
return 1;
}
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index c075d8674..1283f8494 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -1285,6 +1285,7 @@ struct packet_viewequip_ack {
int16 body2;
#endif
uint8 sex;
+ // [4144] need remove MAX_INVENTORY from here
struct EQUIPITEM_INFO list[MAX_INVENTORY];
} __attribute__((packed));
@@ -1386,6 +1387,7 @@ struct packet_npc_market_result_ack {
#endif
uint16 qty;
uint32 price;
+ // [4144] need remove MAX_INVENTORY from here
} list[MAX_INVENTORY];/* assuming MAX_INVENTORY is max since you can't hold more than MAX_INVENTORY items thus cant buy that many at once. */
} __attribute__((packed));
diff --git a/src/map/pc.c b/src/map/pc.c
index 39358adf4..ad8cf2a94 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -568,7 +568,7 @@ static void pc_rental_expire(struct map_session_data *sd, int i)
int nameid;
nullpo_retv(sd);
- Assert_retv(i >= 0 && i < MAX_INVENTORY);
+ Assert_retv(i >= 0 && i < sd->status.inventorySize);
nameid = sd->status.inventory[i].nameid;
/* Soon to be dropped, we got plans to integrate it with item db */
@@ -637,11 +637,11 @@ static void pc_rental_expire(struct map_session_data *sd, int i)
}
static void pc_inventory_rentals(struct map_session_data *sd)
{
- int i, c = 0;
+ int c = 0;
int64 expire_tick, next_tick = INT64_MAX;
nullpo_retv(sd);
- for( i = 0; i < MAX_INVENTORY; i++ )
+ for (int i = 0; i < sd->status.inventorySize; i++ )
{ // Check for Rentals on Inventory
if( sd->status.inventory[i].nameid == 0 )
continue; // Nothing here
@@ -773,7 +773,6 @@ static int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id,
sd->battle_status.speed = sd->base_status.speed = DEFAULT_WALK_SPEED;
sd->state.warp_clean = 1;
sd->catch_target_class = -1;
- sd->inventorySize = 100;
return 0;
}
@@ -783,7 +782,7 @@ static int pc_equippoint(struct map_session_data *sd, int n)
int ep = 0;
nullpo_ret(sd);
- Assert_ret(n >= 0 && n < MAX_INVENTORY);
+ Assert_ret(n >= 0 && n < sd->status.inventorySize);
if(!sd->inventory_data[n])
return 0;
@@ -839,11 +838,9 @@ static int pc_item_equippoint(struct map_session_data *sd, struct item_data *id)
static int pc_setinventorydata(struct map_session_data *sd)
{
- int i;
-
nullpo_ret(sd);
- for (i = 0; i < MAX_INVENTORY; i++) {
+ for (int i = 0; i < sd->status.inventorySize; i++) {
int id = sd->status.inventory[i].nameid;
sd->inventory_data[i] = id?itemdb->search(id):NULL;
}
@@ -903,7 +900,7 @@ static int pc_setequipindex(struct map_session_data *sd)
for(i=0;i<EQI_MAX;i++)
sd->equip_index[i] = -1;
- for(i=0;i<MAX_INVENTORY;i++) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
if(sd->status.inventory[i].nameid <= 0)
continue;
if(sd->status.inventory[i].equip) {
@@ -1074,7 +1071,7 @@ static int pc_isequip(struct map_session_data *sd, int n)
struct item_data *item;
nullpo_ret(sd);
- Assert_ret(n >= 0 && n < MAX_INVENTORY);
+ Assert_ret(n >= 0 && n < sd->status.inventorySize);
item = sd->inventory_data[n];
@@ -4311,7 +4308,7 @@ static bool pc_can_insert_card_into(struct map_session_data *sd, int idx_card, i
nullpo_ret(sd);
- if (idx_equip < 0 || idx_equip >= MAX_INVENTORY || sd->inventory_data[idx_equip] == NULL)
+ if (idx_equip < 0 || idx_equip >= sd->status.inventorySize || sd->inventory_data[idx_equip] == NULL)
return false; //Invalid item index.
if (sd->status.inventory[idx_equip].nameid <= 0 || sd->status.inventory[idx_equip].amount < 1)
return false; // target item missing
@@ -4345,7 +4342,7 @@ static bool pc_can_insert_card(struct map_session_data *sd, int idx_card)
{
nullpo_ret(sd);
- if (idx_card < 0 || idx_card >= MAX_INVENTORY || sd->inventory_data[idx_card] == NULL)
+ if (idx_card < 0 || idx_card >= sd->status.inventorySize || sd->inventory_data[idx_card] == NULL)
return false; //Invalid card index.
if (sd->status.inventory[idx_card].nameid <= 0 || sd->status.inventory[idx_card].amount < 1)
return false; // target card missing
@@ -4441,7 +4438,6 @@ static int pc_modifysellvalue(struct map_session_data *sd, int orig_value)
*------------------------------------------*/
static int pc_checkadditem(struct map_session_data *sd, int nameid, int amount)
{
- int i;
struct item_data* data;
nullpo_ret(sd);
@@ -4457,7 +4453,7 @@ static int pc_checkadditem(struct map_session_data *sd, int nameid, int amount)
if( data->stack.inventory && amount > data->stack.amount )
return ADDITEM_OVERAMOUNT;
- for(i=0;i<MAX_INVENTORY;i++){
+ for(int i = 0; i < sd->status.inventorySize; i++) {
// FIXME: This does not consider the checked item's cards, thus could check a wrong slot for stackability.
if(sd->status.inventory[i].nameid==nameid){
if( amount > MAX_AMOUNT - sd->status.inventory[i].amount || ( data->stack.inventory && amount > data->stack.amount - sd->status.inventory[i].amount ) )
@@ -4475,11 +4471,10 @@ static int pc_checkadditem(struct map_session_data *sd, int nameid, int amount)
*------------------------------------------*/
static int pc_inventoryblank(struct map_session_data *sd)
{
- int i,b;
-
nullpo_ret(sd);
+ int b = 0;
- for(i=0,b=0;i<MAX_INVENTORY;i++){
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if(sd->status.inventory[i].nameid==0)
b++;
}
@@ -4676,8 +4671,8 @@ static int pc_search_inventory(struct map_session_data *sd, int item_id)
int i;
nullpo_retr(INDEX_NOT_FOUND, sd);
- ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == item_id && (sd->status.inventory[i].amount > 0 || item_id == 0) );
- return ( i < MAX_INVENTORY ) ? i : INDEX_NOT_FOUND;
+ ARR_FIND(0, sd->status.inventorySize, i, sd->status.inventory[i].nameid == item_id && (sd->status.inventory[i].amount > 0 || item_id == 0));
+ return (i < sd->status.inventorySize) ? i : INDEX_NOT_FOUND;
}
/*==========================================
@@ -4739,11 +4734,11 @@ static int pc_additem(struct map_session_data *sd, const struct item *item_data,
}
}
- i = MAX_INVENTORY;
+ i = sd->status.inventorySize;
// Stackable | Non Rental
if( itemdb->isstackable2(data) && item_data->expire_time == 0 ) {
- for( i = 0; i < MAX_INVENTORY; i++ ) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
if( sd->status.inventory[i].nameid == item_data->nameid &&
sd->status.inventory[i].bound == item_data->bound &&
sd->status.inventory[i].expire_time == 0 &&
@@ -4758,7 +4753,7 @@ static int pc_additem(struct map_session_data *sd, const struct item *item_data,
}
}
- if ( i >= MAX_INVENTORY ) {
+ if (i >= sd->status.inventorySize) {
i = pc->search_inventory(sd,0);
if (i == INDEX_NOT_FOUND)
return 4;
@@ -4818,7 +4813,7 @@ static int pc_additem(struct map_session_data *sd, const struct item *item_data,
static int 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);
- Assert_retr(1, n >= 0 && n < MAX_INVENTORY);
+ Assert_retr(1, n >= 0 && n < sd->status.inventorySize);
if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
return 1;
@@ -4852,7 +4847,7 @@ static int pc_dropitem(struct map_session_data *sd, int n, int amount)
{
nullpo_retr(1, sd);
- if(n < 0 || n >= MAX_INVENTORY)
+ if(n < 0 || n >= sd->status.inventorySize)
return 0;
if(amount <= 0)
@@ -4963,7 +4958,7 @@ static int pc_isUseitem(struct map_session_data *sd, int n)
int nameid;
nullpo_ret(sd);
- Assert_ret(n >= 0 && n < MAX_INVENTORY);
+ Assert_ret(n >= 0 && n < sd->status.inventorySize);
item = sd->inventory_data[n];
nameid = sd->status.inventory[n].nameid;
@@ -5199,7 +5194,7 @@ static int pc_useitem(struct map_session_data *sd, int n)
bool removeItem = false;
nullpo_ret(sd);
- Assert_ret(n >= 0 && n < MAX_INVENTORY);
+ Assert_ret(n >= 0 && n < sd->status.inventorySize);
if (sd->npc_id || sd->state.workinprogress & 1) {
#if PACKETVER >= 20110308
@@ -5436,7 +5431,7 @@ static int pc_cart_delitem(struct map_session_data *sd, int n, int amount, int t
{
struct item_data * data;
nullpo_retr(1, sd);
- Assert_retr(1, n >= 0 && n < MAX_INVENTORY);
+ Assert_retr(1, n >= 0 && n < MAX_CART);
if( sd->status.cart[n].nameid == 0 || sd->status.cart[n].amount < amount || !(data = itemdb->exists(sd->status.cart[n].nameid)) )
return 1;
@@ -5470,7 +5465,7 @@ static int pc_putitemtocart(struct map_session_data *sd, int idx, int amount)
nullpo_ret(sd);
- if (idx < 0 || idx >= MAX_INVENTORY) //Invalid index check [Skotlex]
+ if (idx < 0 || idx >= sd->status.inventorySize) //Invalid index check [Skotlex]
return 1;
item_data = &sd->status.inventory[idx];
@@ -5540,7 +5535,7 @@ static void pc_bound_clear(struct map_session_data *sd, enum e_item_bound_type t
/* both restricted to inventory */
case IBT_PARTY:
case IBT_CHARACTER:
- for( i = 0; i < MAX_INVENTORY; i++ ){
+ for (i = 0; i < sd->status.inventorySize; i++ ) {
if( sd->status.inventory[i].bound == type ) {
pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_SKILLUSE, LOG_TYPE_OTHER); // FIXME: is this the correct reason flag?
}
@@ -5552,7 +5547,7 @@ static void pc_bound_clear(struct map_session_data *sd, enum e_item_bound_type t
case IBT_GUILD: {
struct guild_storage *gstor = idb_get(gstorage->db,sd->status.guild_id);
- for( i = 0; i < MAX_INVENTORY; i++ ){
+ for (i = 0; i < sd->status.inventorySize; i++ ) {
if(sd->status.inventory[i].bound == type) {
if( gstor )
gstorage->additem(sd,gstor,&sd->status.inventory[i],sd->status.inventory[i].amount);
@@ -8293,15 +8288,15 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src)
if(id == 0)
continue;
if(id == -1){
- int eq_num=0,eq_n[MAX_INVENTORY],k;
+ int eq_num = 0, eq_n[MAX_INVENTORY], k;
memset(eq_n,0,sizeof(eq_n));
- for(i=0;i<MAX_INVENTORY;i++){
+ for(i = 0; i < sd->status.inventorySize; i++) {
if( (type == 1 && !sd->status.inventory[i].equip)
|| (type == 2 && sd->status.inventory[i].equip)
|| type == 3)
{
- ARR_FIND( 0, MAX_INVENTORY, k, eq_n[k] <= 0 );
- if( k < MAX_INVENTORY )
+ ARR_FIND(0, sd->status.inventorySize, k, eq_n[k] <= 0);
+ if (k < sd->status.inventorySize)
eq_n[k] = i;
eq_num++;
@@ -8317,7 +8312,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src)
}
}
else if(id > 0){
- for(i=0;i<MAX_INVENTORY;i++){
+ for( i = 0; i < sd->status.inventorySize; i++) {
if(sd->status.inventory[i].nameid == id
&& rnd()%10000 < per
&& ((type == 1 && !sd->status.inventory[i].equip)
@@ -10148,7 +10143,7 @@ static int pc_equipitem(struct map_session_data *sd, int n, int req_pos)
nullpo_ret(sd);
- if( n < 0 || n >= MAX_INVENTORY ) {
+ if (n < 0 || n >= sd->status.inventorySize) {
clif->equipitemack(sd,0,0,EIA_FAIL);
return 0;
}
@@ -10356,7 +10351,7 @@ static int pc_unequipitem(struct map_session_data *sd, int n, int flag)
nullpo_ret(sd);
- if (n < 0 || n >= MAX_INVENTORY) {
+ if (n < 0 || n >= sd->status.inventorySize) {
clif->unequipitemack(sd, 0, 0, UIA_FAIL);
return 0;
}
@@ -10508,7 +10503,7 @@ static int pc_checkitem(struct map_session_data *sd)
int id = 0;
if (sd->itemcheck & PCCHECKITEM_INVENTORY) {
- for (i = 0; i < MAX_INVENTORY; i++) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
if ((id = sd->status.inventory[i].nameid) == 0)
continue;
@@ -10588,7 +10583,7 @@ static int pc_checkitem(struct map_session_data *sd)
}
}
- for (i = 0; i < MAX_INVENTORY; i++) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].nameid == 0)
continue;
@@ -10762,11 +10757,14 @@ static int pc_divorce(struct map_session_data *sd)
// Both players online, lets do the divorce manually
sd->status.partner_id = 0;
p_sd->status.partner_id = 0;
- for( i = 0; i < MAX_INVENTORY; i++ )
+ for (i = 0; i < sd->status.inventorySize; i++)
{
- if( sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F )
+ if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_DIVORCE);
- if( p_sd->status.inventory[i].nameid == WEDDING_RING_M || p_sd->status.inventory[i].nameid == WEDDING_RING_F )
+ }
+ for (i = 0; i < p_sd->status.inventorySize; i++)
+ {
+ if (p_sd->status.inventory[i].nameid == WEDDING_RING_M || p_sd->status.inventory[i].nameid == WEDDING_RING_F)
pc->delitem(p_sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_DIVORCE);
}
diff --git a/src/map/pc.h b/src/map/pc.h
index 20b995519..cca15e829 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -260,7 +260,6 @@ struct map_session_data {
struct mmo_charstatus status;
struct item_data *inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
- int inventorySize;
struct storage_data storage; ///< Account Storage
enum pc_checkitem_types itemcheck;
short equip_index[EQI_MAX];
diff --git a/src/map/pet.c b/src/map/pet.c
index c32a92b78..dd9f1ebbf 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -94,10 +94,10 @@ static void pet_set_intimate(struct pet_data *pd, int value)
if (value <= 0) {
int i;
- ARR_FIND(0, MAX_INVENTORY, i, sd->status.inventory[i].card[0] == CARD0_PET &&
+ ARR_FIND(0, sd->status.inventorySize, i, sd->status.inventory[i].card[0] == CARD0_PET &&
pd->pet.pet_id == MakeDWord(sd->status.inventory[i].card[1], sd->status.inventory[i].card[2]));
- if (i != MAX_INVENTORY) {
+ if (i != sd->status.inventorySize) {
pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_EGG);
}
}
@@ -342,10 +342,10 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
pet->lootitem_drop(pd,sd);
// Pet Evolution
- ARR_FIND(0, MAX_INVENTORY, i, sd->status.inventory[i].card[0] == CARD0_PET &&
+ ARR_FIND(0, sd->status.inventorySize, i, sd->status.inventory[i].card[0] == CARD0_PET &&
pd->pet.pet_id == MakeDWord(sd->status.inventory[i].card[1], sd->status.inventory[i].card[2]));
- if (i != MAX_INVENTORY) {
+ if (i != sd->status.inventorySize) {
sd->status.inventory[i].attribute &= ~ATTR_BROKEN;
sd->status.inventory[i].bound = IBT_NONE;
}
@@ -492,10 +492,10 @@ static int pet_recv_petdata(int account_id, struct s_pet *p, int flag)
if(p->incubate == 1) {
int i;
// Get Egg Index
- ARR_FIND(0, MAX_INVENTORY, i, sd->status.inventory[i].card[0] == CARD0_PET &&
+ ARR_FIND(0, sd->status.inventorySize, i, sd->status.inventory[i].card[0] == CARD0_PET &&
p->pet_id == MakeDWord(sd->status.inventory[i].card[1], sd->status.inventory[i].card[2]));
- if(i == MAX_INVENTORY) {
+ if(i == sd->status.inventorySize) {
ShowError("pet_recv_petdata: Hatching pet (%d:%s) aborted, couldn't find egg in inventory for removal!\n",p->pet_id, p->name);
sd->status.pet_id = 0;
return 1;
@@ -527,7 +527,7 @@ static int pet_select_egg(struct map_session_data *sd, int egg_index)
{
nullpo_ret(sd);
- if(egg_index < 0 || egg_index >= MAX_INVENTORY)
+ if (egg_index < 0 || egg_index >= sd->status.inventorySize)
return 0; //Forged packet!
if(sd->status.inventory[egg_index].card[0] == CARD0_PET)
diff --git a/src/map/quest.c b/src/map/quest.c
index f10d6847f..7a216095e 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -814,7 +814,7 @@ static bool quest_questinfo_validate_items(struct map_session_data *sd, struct q
for (int i = 0; i < VECTOR_LENGTH(qi->items); i++) {
struct questinfo_itemreq *item = &VECTOR_INDEX(qi->items, i);
int count = 0;
- for (int j = 0; j < MAX_INVENTORY; j++) {
+ for (int j = 0; j < sd->status.inventorySize; j++) {
if (sd->status.inventory[j].nameid == item->nameid)
count += sd->status.inventory[j].amount;
}
diff --git a/src/map/rodex.c b/src/map/rodex.c
index 602754d42..eea27b6d0 100644
--- a/src/map/rodex.c
+++ b/src/map/rodex.c
@@ -83,7 +83,7 @@ static void rodex_add_item(struct map_session_data *sd, int16 idx, int16 amount)
nullpo_retv(sd);
- if (idx < 0 || idx >= MAX_INVENTORY) {
+ if (idx < 0 || idx >= sd->status.inventorySize) {
clif->rodex_add_item_result(sd, idx, amount, RODEX_ADD_ITEM_FATAL_ERROR);
return;
}
@@ -160,7 +160,7 @@ static void rodex_remove_item(struct map_session_data *sd, int16 idx, int16 amou
struct item_data *itd;
nullpo_retv(sd);
- Assert_retv(idx >= 0 && idx < MAX_INVENTORY);
+ Assert_retv(idx >= 0 && idx < sd->status.inventorySize);
for (i = 0; i < RODEX_MAX_ITEM; ++i) {
if (sd->rodex.tmp.items[i].idx == idx)
@@ -504,7 +504,7 @@ static void rodex_get_items(struct map_session_data *sd, int8 opentype, int64 ma
}
required_slots = msg->items_count;
- for (i = 0; i < MAX_INVENTORY; ++i) {
+ for (i = 0; i < sd->status.inventorySize; ++i) {
if (sd->status.inventory[i].nameid == 0) {
empty_slots++;
} else if (itemdb->isstackable(sd->status.inventory[i].nameid) == 1) {
diff --git a/src/map/script.c b/src/map/script.c
index 52c0cf75c..8d3de56a5 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -7553,7 +7553,6 @@ static BUILDIN(viewpoint)
*------------------------------------------*/
static BUILDIN(countitem)
{
- int nameid, i;
int count = 0;
struct item_data* id = NULL;
@@ -7575,11 +7574,12 @@ static BUILDIN(countitem)
return false;
}
- nameid = id->nameid;
+ int nameid = id->nameid;
- for(i = 0; i < MAX_INVENTORY; i++)
- if(sd->status.inventory[i].nameid == nameid)
+ for (int i = 0; i < sd->status.inventorySize; i++) {
+ if (sd->status.inventory[i].nameid == nameid)
count += sd->status.inventory[i].amount;
+ }
script_pushint(st,count);
return true;
@@ -7593,7 +7593,6 @@ static BUILDIN(countitem2)
{
int nameid, iden, ref, attr, c1, c2, c3, c4;
int count = 0;
- int i;
struct item_data* id = NULL;
struct map_session_data *sd = script->rid2sd(st);
@@ -7623,7 +7622,7 @@ static BUILDIN(countitem2)
c3 = script_getnum(st,8);
c4 = script_getnum(st,9);
- for(i = 0; i < MAX_INVENTORY; i++)
+ for (int i = 0; i < sd->status.inventorySize; i++)
if (sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] != NULL &&
sd->status.inventory[i].amount > 0 && sd->status.inventory[i].nameid == nameid &&
sd->status.inventory[i].identify == iden && sd->status.inventory[i].refine == ref &&
@@ -9148,13 +9147,13 @@ static BUILDIN(getequipname)
*------------------------------------------*/
static BUILDIN(getbrokenid)
{
- int i,num,id=0,brokencounter=0;
+ int num,id=0,brokencounter=0;
struct map_session_data *sd = script->rid2sd(st);
if (sd == NULL)
return true;
num=script_getnum(st,2);
- for(i=0; i<MAX_INVENTORY; i++) {
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].card[0] == CARD0_PET)
continue;
if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) {
@@ -9181,7 +9180,7 @@ static BUILDIN(getbrokencount)
if (sd == NULL)
return true;
- for (i = 0; i < MAX_INVENTORY; i++) {
+ for (i = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].card[0] == CARD0_PET)
continue;
if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0)
@@ -9198,14 +9197,13 @@ static BUILDIN(getbrokencount)
*------------------------------------------*/
static BUILDIN(repair)
{
- int i,num;
int repaircounter=0;
struct map_session_data *sd = script->rid2sd(st);
if (sd == NULL)
return true;
- num=script_getnum(st,2);
- for(i=0; i<MAX_INVENTORY; i++) {
+ int num = script_getnum(st, 2);
+ for(int i = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].card[0] == CARD0_PET)
continue;
if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) {
@@ -9229,12 +9227,12 @@ static BUILDIN(repair)
*------------------------------------------*/
static BUILDIN(repairall)
{
- int i, repaircounter = 0;
+ int repaircounter = 0;
struct map_session_data *sd = script->rid2sd(st);
if (sd == NULL)
return true;
- for(i = 0; i < MAX_INVENTORY; i++)
+ for (int i = 0; i < sd->status.inventorySize; i++)
{
if (sd->status.inventory[i].card[0] == CARD0_PET)
continue;
@@ -14722,10 +14720,10 @@ static BUILDIN(getinventorylist)
struct map_session_data *sd = script->rid2sd(st);
char card_var[SCRIPT_VARNAME_LENGTH];
- int i,j=0,k;
+ int j=0,k;
if(!sd) return true;
- for(i=0;i<MAX_INVENTORY;i++) {
+ for (int i = 0;i < sd->status.inventorySize; i++) {
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount > 0) {
pc->setreg(sd,reference_uid(script->add_variable("@inventorylist_id"), j),sd->status.inventory[i].nameid);
pc->setreg(sd,reference_uid(script->add_variable("@inventorylist_amount"), j),sd->status.inventory[i].amount);
@@ -14816,10 +14814,9 @@ static BUILDIN(getskilllist)
static BUILDIN(clearitem)
{
struct map_session_data *sd = script->rid2sd(st);
- int i;
if (sd == NULL)
return true;
- for (i=0; i<MAX_INVENTORY; i++) {
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if (sd->status.inventory[i].amount) {
pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_SCRIPT);
}
@@ -15590,19 +15587,18 @@ static BUILDIN(getmercinfo)
*------------------------------------------*/
static BUILDIN(checkequipedcard)
{
- int n,i,c=0;
struct map_session_data *sd = script->rid2sd(st);
if (sd == NULL)
return true;
- c = script_getnum(st,2);
+ int c = script_getnum(st,2);
- for( i=0; i<MAX_INVENTORY; i++) {
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount && sd->inventory_data[i]) {
if (itemdb_isspecial(sd->status.inventory[i].card[0]))
continue;
- for(n=0;n<sd->inventory_data[i]->slot;n++) {
+ for (int n = 0; n < sd->inventory_data[i]->slot; n++) {
if(sd->status.inventory[i].card[n]==c) {
script_pushint(st,1);
return true;
@@ -16470,9 +16466,9 @@ static BUILDIN(equip)
ShowError("wrong item ID : equipitem(%d)\n",nameid);
return false;
}
- ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == nameid && sd->status.inventory[i].equip == 0 );
- if( i < MAX_INVENTORY )
- pc->equipitem(sd,i,item_data->equip);
+ ARR_FIND(0, sd->status.inventorySize, i, sd->status.inventory[i].nameid == nameid && sd->status.inventory[i].equip == 0);
+ if (i < sd->status.inventorySize)
+ pc->equipitem(sd, i, item_data->equip);
return true;
}
@@ -16530,21 +16526,21 @@ static BUILDIN(equip2)
c2 = script_getnum(st, 7);
c3 = script_getnum(st, 8);
- ARR_FIND( 0, MAX_INVENTORY, i,( sd->status.inventory[i].equip == 0 &&
+ ARR_FIND(0, sd->status.inventorySize, i, (sd->status.inventory[i].equip == 0 &&
sd->status.inventory[i].nameid == nameid &&
sd->status.inventory[i].refine == ref &&
sd->status.inventory[i].attribute == attr &&
sd->status.inventory[i].card[0] == c0 &&
sd->status.inventory[i].card[1] == c1 &&
sd->status.inventory[i].card[2] == c2 &&
- sd->status.inventory[i].card[3] == c3 ) );
+ sd->status.inventory[i].card[3] == c3));
- if( i < MAX_INVENTORY ) {
+ if (i < sd->status.inventorySize) {
script_pushint(st,1);
pc->equipitem(sd,i,item_data->equip);
- }
- else
+ } else {
script_pushint(st,0);
+ }
return true;
}
@@ -23658,7 +23654,7 @@ static BUILDIN(bg_join_team)
*------------------------------------------*/
static BUILDIN(countbound)
{
- int i, type, j=0, k=0;
+ int type, j=0, k=0;
struct map_session_data *sd = script->rid2sd(st);
if (sd == NULL)
@@ -23666,7 +23662,7 @@ static BUILDIN(countbound)
type = script_hasdata(st,2)?script_getnum(st,2):0;
- for(i=0;i<MAX_INVENTORY;i++) {
+ for (int i = 0; i < sd->status.inventorySize; i++) {
if(sd->status.inventory[i].nameid > 0 && (
(!type && sd->status.inventory[i].bound > 0) ||
(type && sd->status.inventory[i].bound == type)
@@ -23712,20 +23708,21 @@ static BUILDIN(checkbound)
ShowError("script_checkbound: Not a valid bind type! Type=%d\n", bound_type);
}
- ARR_FIND( 0, MAX_INVENTORY, i, (sd->status.inventory[i].nameid == nameid &&
+ ARR_FIND(0, sd->status.inventorySize, i, (sd->status.inventory[i].nameid == nameid &&
( sd->status.inventory[i].refine == (script_hasdata(st,4)? script_getnum(st,4) : sd->status.inventory[i].refine) ) &&
( sd->status.inventory[i].attribute == (script_hasdata(st,5)? script_getnum(st,5) : sd->status.inventory[i].attribute) ) &&
( sd->status.inventory[i].card[0] == (script_hasdata(st,6)? script_getnum(st,6) : sd->status.inventory[i].card[0]) ) &&
( sd->status.inventory[i].card[1] == (script_hasdata(st,7)? script_getnum(st,7) : sd->status.inventory[i].card[1]) ) &&
( sd->status.inventory[i].card[2] == (script_hasdata(st,8)? script_getnum(st,8) : sd->status.inventory[i].card[2]) ) &&
( sd->status.inventory[i].card[3] == (script_hasdata(st,9)? script_getnum(st,9) : sd->status.inventory[i].card[3]) ) &&
- ((sd->status.inventory[i].bound > 0 && !bound_type) || sd->status.inventory[i].bound == bound_type )) );
+ ((sd->status.inventory[i].bound > 0 && !bound_type) || sd->status.inventory[i].bound == bound_type)));
- if( i < MAX_INVENTORY ){
+ if (i < sd->status.inventorySize) {
script_pushint(st, sd->status.inventory[i].bound);
return true;
- } else
+ } else {
script_pushint(st,0);
+ }
return true;
}
@@ -25642,8 +25639,9 @@ static void script_hardcoded_constants(void)
script->set_constant("MAX_LEVEL",MAX_LEVEL,false, false);
script->set_constant("MAX_STORAGE",MAX_STORAGE,false, false);
script->set_constant("MAX_GUILD_STORAGE",MAX_GUILD_STORAGE,false, false);
- script->set_constant("MAX_CART",MAX_INVENTORY,false, false);
+ script->set_constant("MAX_CART", MAX_CART, false, false);
script->set_constant("MAX_INVENTORY",MAX_INVENTORY,false, false);
+ script->set_constant("FIXED_INVENTORY_SIZE", FIXED_INVENTORY_SIZE, false, false);
script->set_constant("MAX_ZENY",MAX_ZENY,false, false);
script->set_constant("MAX_BANK_ZENY", MAX_BANK_ZENY, false, false);
script->set_constant("MAX_BG_MEMBERS",MAX_BG_MEMBERS,false, false);
diff --git a/src/map/skill.c b/src/map/skill.c
index 8410a77d0..069db55df 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -14490,8 +14490,8 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s
**/
case AB_ANCILLA:
{
- int count = 0, i;
- for( i = 0; i < MAX_INVENTORY; i ++ )
+ int count = 0;
+ for (int i = 0; i < sd->status.inventorySize; i ++)
if (sd->status.inventory[i].nameid == ITEMID_ANSILA)
count += sd->status.inventory[i].amount;
if( count >= 3 ) {
@@ -16109,7 +16109,7 @@ static void skill_repairweapon(struct map_session_data *sd, int idx)
if (idx == 0xFFFF || idx == -1) // No item selected ('Cancel' clicked)
return;
- if( idx < 0 || idx >= MAX_INVENTORY )
+ if (idx < 0 || idx >= sd->status.inventorySize)
return; //Invalid index??
item = &target_sd->status.inventory[idx];
@@ -16157,7 +16157,7 @@ static void skill_identify(struct map_session_data *sd, int idx)
nullpo_retv(sd);
sd->state.workinprogress = 0;
- if(idx >= 0 && idx < MAX_INVENTORY) {
+ if (idx >= 0 && idx < sd->status.inventorySize) {
if(sd->status.inventory[idx].nameid > 0 && sd->status.inventory[idx].identify == 0 ){
flag=0;
sd->status.inventory[idx].identify=1;
@@ -16173,7 +16173,7 @@ static void skill_weaponrefine(struct map_session_data *sd, int idx)
{
nullpo_retv(sd);
- if (idx >= 0 && idx < MAX_INVENTORY) {
+ if (idx >= 0 && idx < sd->status.inventorySize) {
struct item *item;
struct item_data *ditem = sd->inventory_data[idx];
item = &sd->status.inventory[idx];
@@ -17992,8 +17992,8 @@ static int skill_can_produce_mix(struct map_session_data *sd, int nameid, int tr
if (pc->search_inventory(sd,id) == INDEX_NOT_FOUND)
return 0;
} else {
- int x, y;
- for(y=0,x=0;y<MAX_INVENTORY;y++)
+ int x = 0;
+ for (int y = 0; y < sd->status.inventorySize; y++)
if( sd->status.inventory[y].nameid == id )
x+=sd->status.inventory[y].amount;
if(x<qty*skill->dbs->produce_db[i].mat_amount[j])
@@ -18064,7 +18064,7 @@ static int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int n
else temp_qty = 1;
if (data->stack.inventory) {
- for( i = 0; i < MAX_INVENTORY; i++ ) {
+ for (i = 0; i < sd->status.inventorySize; i++ ) {
if( sd->status.inventory[i].nameid == nameid ) {
if( sd->status.inventory[i].amount >= data->stack.amount ) {
#if PACKETVER >= 20090729
@@ -18872,7 +18872,7 @@ static int skill_elementalanalysis(struct map_session_data *sd, uint16 skill_lv,
del_amount -= (del_amount % 10);
add_amount = (skill_lv == 1) ? del_amount * (5 + rnd()%5) : del_amount / 10 ;
- if (idx < 0 || idx >= MAX_INVENTORY
+ if (idx < 0 || idx >= sd->status.inventorySize
|| (nameid = sd->status.inventory[idx].nameid) <= 0
|| del_amount < 0 || del_amount > sd->status.inventory[idx].amount) {
clif->skill_fail(sd, SO_EL_ANALYSIS, USESKILL_FAIL_LEVEL, 0, 0);
@@ -18943,7 +18943,7 @@ static int skill_changematerial(struct map_session_data *sd, const struct itemli
for (k = 0; k < VECTOR_LENGTH(*item_list); k++) {
const struct itemlist_entry *entry = &VECTOR_INDEX(*item_list, k);
int idx = entry->id;
- Assert_ret(idx >= 0 && idx < MAX_INVENTORY);
+ Assert_ret(idx >= 0 && idx < sd->status.inventorySize);
amount = entry->amount;
nameid = sd->status.inventory[idx].nameid;
if (nameid > 0 && sd->status.inventory[idx].identify == 0) {
diff --git a/src/map/status.c b/src/map/status.c
index 75744c59b..65b52cbcf 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -2446,7 +2446,7 @@ static int status_calc_pc_(struct map_session_data *sd, enum e_status_calc_opt o
sd->regen.sregen = &sd->sregen;
sd->regen.ssregen = &sd->ssregen;
sd->weight=0;
- for(i=0;i<MAX_INVENTORY;i++){
+ for (i = 0; i < sd->status.inventorySize; i++) {
if(sd->status.inventory[i].nameid==0 || sd->inventory_data[i] == NULL)
continue;
sd->weight += sd->inventory_data[i]->weight*sd->status.inventory[i].amount;
diff --git a/src/map/storage.c b/src/map/storage.c
index a6f0715e7..90b620f63 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -285,7 +285,7 @@ static int storage_add_from_inventory(struct map_session_data *sd, int index, in
if (sd->storage.aggregate > MAX_STORAGE)
return 0; // storage full
- if (index < 0 || index >= MAX_INVENTORY)
+ if (index < 0 || index >= sd->status.inventorySize)
return 0;
if (sd->status.inventory[index].nameid <= 0)
@@ -623,7 +623,7 @@ static int storage_guild_storageadd(struct map_session_data *sd, int index, int
if( !stor->storage_status || stor->storage_amount > MAX_GUILD_STORAGE )
return 0;
- if( index<0 || index>=MAX_INVENTORY )
+ if (index < 0 || index >= sd->status.inventorySize)
return 0;
if( sd->status.inventory[index].nameid <= 0 )
diff --git a/src/map/trade.c b/src/map/trade.c
index d4f846d19..9c284ba23 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -209,7 +209,7 @@ static int impossible_trade_check(struct map_session_data *sd)
// remove this part: arrows can be trade and equipped
// re-added! [celest]
// remove equipped items (they can not be trade)
- for (i = 0; i < MAX_INVENTORY; i++)
+ for (i = 0; i < sd->status.inventorySize; i++)
if (inventory[i].nameid > 0 && inventory[i].equip && !(inventory[i].equip & EQP_AMMO))
memset(&inventory[i], 0, sizeof(struct item));
@@ -218,7 +218,7 @@ static int impossible_trade_check(struct map_session_data *sd)
if (!sd->deal.item[i].amount)
continue;
index = sd->deal.item[i].index;
- if (index < 0 || index >= MAX_INVENTORY)
+ if (index < 0 || index >= sd->status.inventorySize)
return 1;
if (inventory[index].amount < sd->deal.item[i].amount) {
// if more than the player have -> hack
@@ -281,9 +281,9 @@ static int trade_check(struct map_session_data *sd, struct map_session_data *tsd
return 0; //qty Exploit?
data = itemdb->search(inventory[n].nameid);
- i = MAX_INVENTORY;
+ i = tsd->status.inventorySize;
if (itemdb->isstackable2(data)) { //Stackable item.
- for(i = 0; i < MAX_INVENTORY; i++)
+ for(i = 0; i < tsd->status.inventorySize; i++)
if (inventory2[i].nameid == inventory[n].nameid &&
inventory2[i].card[0] == inventory[n].card[0] && inventory2[i].card[1] == inventory[n].card[1] &&
inventory2[i].card[2] == inventory[n].card[2] && inventory2[i].card[3] == inventory[n].card[3]) {
@@ -295,9 +295,9 @@ static int trade_check(struct map_session_data *sd, struct map_session_data *tsd
}
}
- if (i == MAX_INVENTORY) {// look for an empty slot.
- for(i = 0; i < MAX_INVENTORY && inventory2[i].nameid; i++);
- if (i == MAX_INVENTORY)
+ if (i == tsd->status.inventorySize) {// look for an empty slot.
+ for (i = 0; i < tsd->status.inventorySize && inventory2[i].nameid; i++);
+ if (i == tsd->status.inventorySize)
return 0;
memcpy(&inventory2[i], &inventory[n], sizeof(struct item));
inventory2[i].amount = amount;
@@ -308,15 +308,15 @@ static int trade_check(struct map_session_data *sd, struct map_session_data *tsd
if (!amount)
continue;
n = tsd->deal.item[trade_i].index;
- if (n < 0 || n >= MAX_INVENTORY)
+ if (n < 0 || n >= tsd->status.inventorySize)
return 0;
if (amount > inventory2[n].amount)
return 0;
// search if it's possible to add item (for full inventory)
data = itemdb->search(inventory2[n].nameid);
- i = MAX_INVENTORY;
+ i = sd->status.inventorySize;
if (itemdb->isstackable2(data)) {
- for(i = 0; i < MAX_INVENTORY; i++)
+ for(i = 0; i < sd->status.inventorySize; i++)
if (inventory[i].nameid == inventory2[n].nameid &&
inventory[i].card[0] == inventory2[n].card[0] && inventory[i].card[1] == inventory2[n].card[1] &&
inventory[i].card[2] == inventory2[n].card[2] && inventory[i].card[3] == inventory2[n].card[3]) {
@@ -327,9 +327,9 @@ static int trade_check(struct map_session_data *sd, struct map_session_data *tsd
break;
}
}
- if (i == MAX_INVENTORY) {
- for(i = 0; i < MAX_INVENTORY && inventory[i].nameid; i++);
- if (i == MAX_INVENTORY)
+ if (i == sd->status.inventorySize) {
+ for(i = 0; i < sd->status.inventorySize && inventory[i].nameid; i++);
+ if (i == sd->status.inventorySize)
return 0;
memcpy(&inventory[i], &inventory2[n], sizeof(struct item));
inventory[i].amount = amount;
@@ -369,7 +369,7 @@ static void trade_tradeadditem(struct map_session_data *sd, short index, short a
index -= 2; // 0 is for zeny, 1 is unknown. Gravity, go figure...
//Item checks...
- if( index < 0 || index >= MAX_INVENTORY )
+ if (index < 0 || index >= sd->status.inventorySize)
return;
if( amount < 0 || amount > sd->status.inventory[index].amount )
return;