summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/pc.c18
-rw-r--r--src/map/pc.h1
-rw-r--r--src/map/script.c11
3 files changed, 30 insertions, 0 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index ad8cf2a94..94d8cd0c6 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -12338,6 +12338,23 @@ static bool pc_has_second_costume(struct map_session_data *sd)
return false;
}
+static bool pc_expandInventory(struct map_session_data *sd, int adjustSize)
+{
+ nullpo_retr(false, sd);
+ const int invSize = sd->status.inventorySize;
+ if (adjustSize > MAX_INVENTORY || invSize + adjustSize <= FIXED_INVENTORY_SIZE || invSize + adjustSize > MAX_INVENTORY) {
+ clif->inventoryExpandResult(sd, EXPAND_INVENTORY_RESULT_MAX_SIZE);
+ return false;
+ }
+ if (pc_isdead(sd) || sd->state.vending || sd->state.buyingstore || sd->chat_id != 0 || sd->state.trading || sd->state.storage_flag || sd->state.prevend) {
+ clif->inventoryExpandResult(sd, EXPAND_INVENTORY_RESULT_OTHER_WORK);
+ return false;
+ }
+ sd->status.inventorySize += adjustSize;
+ clif->inventoryExpansionInfo(sd);
+ return true;
+}
+
static void do_final_pc(void)
{
@@ -12740,4 +12757,5 @@ void pc_defaults(void)
pc->isDeathPenaltyJob = pc_isDeathPenaltyJob;
pc->has_second_costume = pc_has_second_costume;
+ pc->expandInventory = pc_expandInventory;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index cca15e829..bc2fd5a62 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -1185,6 +1185,7 @@ END_ZEROED_BLOCK; /* End */
bool (*check_basicskill) (struct map_session_data *sd, int level);
bool (*isDeathPenaltyJob) (uint16 job);
bool (*has_second_costume) (struct map_session_data *sd);
+ bool (*expandInventory) (struct map_session_data *sd, int adjustSize);
};
#ifdef HERCULES_CORE
diff --git a/src/map/script.c b/src/map/script.c
index 36b316320..8dadf6d57 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -24884,6 +24884,16 @@ static BUILDIN(expandInventoryResult)
return true;
}
+// adjust player inventory size to given value positive or negative
+static BUILDIN(expandInventory)
+{
+ struct map_session_data *sd = script_rid2sd(st);
+ if (sd == NULL)
+ return false;
+ script_pushint(st, pc->expandInventory(sd, script_getnum(st, 2)));
+ return true;
+}
+
/**
* Adds a built-in script function.
*
@@ -25626,6 +25636,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(enchantitem, "iii"),
BUILDIN_DEF(expandInventoryAck, "i?"),
BUILDIN_DEF(expandInventoryResult, "i"),
+ BUILDIN_DEF(expandInventory, "i"),
};
int i, len = ARRAYLENGTH(BUILDIN);
RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up