summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/map/script.c b/src/map/script.c
index e7c5eba0c..355735740 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10894,10 +10894,30 @@ static BUILDIN(gettimestr)
static BUILDIN(openstorage)
{
struct map_session_data *sd = script->rid2sd(st);
- if (sd == NULL)
+ int storage_id = script_hasdata(st, 2) ? script_getnum(st, 2) : 1;
+ if (sd == NULL) {
+ script_pushint(st, 0);
+ ShowWarning("buildin_openstorage: Player not attached for Storage with ID %d!\n", storage_id);
+ return false;
+ }
+
+ int storage_access = script_hasdata(st, 3) ? script_getnum(st, 3) : STORAGE_ACCESS_ALL;
+ struct storage_data *stor = NULL;
+
+ if ((stor = storage->ensure(sd, storage_id)) == NULL) {
+ script_pushint(st, 0);
+ ShowError("buildin_openstorage: Error ensuring storage for player aid %d, storage id %d.\n", sd->bl.id, storage_id);
return false;
+ }
- if (sd->storage.received == false) {
+ const struct storage_settings *stst = NULL;
+ if ((stst = storage->get_settings(storage_id)) == NULL) {
+ script_pushint(st, 0);
+ ShowWarning("buildin_openstorage: Storage with ID %d was not found!\n", storage_id);
+ return false;
+ }
+
+ if (stor == NULL || !stor->received) {
script_pushint(st, 0);
ShowWarning("buildin_openstorage: Storage data for AID %d has not been loaded.\n", sd->bl.id);
return false;
@@ -10909,9 +10929,13 @@ static BUILDIN(openstorage)
return true;
}
- storage->open(sd);
+ sd->storage.access = storage_access; // Set storage access level. [Smokexyz/Hercules]
- script_pushint(st, 1); // success flag.
+ if (storage->open(sd, stor) == 0) {
+ script_pushint(st, 1); // success
+ } else {
+ script_pushint(st, 0);
+ }
return true;
}
@@ -26292,7 +26316,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(gettimetick,"i"),
BUILDIN_DEF(gettime,"i"),
BUILDIN_DEF(gettimestr, "si?"),
- BUILDIN_DEF(openstorage,""),
+ BUILDIN_DEF(openstorage,"??"),
BUILDIN_DEF(guildopenstorage,""),
BUILDIN_DEF(itemskill,"vi?"),
BUILDIN_DEF(produce,"i"),
@@ -27368,6 +27392,12 @@ static void script_hardcoded_constants(void)
script->set_constant("GUILDINFO_MASTER_NAME", GUILDINFO_MASTER_NAME, false, false);
script->set_constant("GUILDINFO_MASTER_CID", GUILDINFO_MASTER_CID, false, false);
+ script->constdb_comment("Storage Access Types");
+ script->set_constant("STORAGE_ACCESS_VIEW", STORAGE_ACCESS_VIEW, false, false);
+ script->set_constant("STORAGE_ACCESS_GET", STORAGE_ACCESS_GET, false, false);
+ script->set_constant("STORAGE_ACCESS_PUT", STORAGE_ACCESS_PUT, false, false);
+ script->set_constant("STORAGE_ACCESS_ALL", STORAGE_ACCESS_ALL, false, false);
+
script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);