Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Hercules Ultimate Storage System (HUSS) #3330

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift click to select a range
1ffe6ad
Implementation of the Hercules Ultimate Storage System
jasonch35 Nov 4, 2024
0a930b5
Add SQL files for main db and upgrades
jasonch35 Nov 4, 2024
d403047
Add data on message tables for the updated atcommands
jasonch35 Nov 4, 2024
520001b
Storage configuration
jasonch35 Nov 4, 2024
95d6f76
Update NPC scripts to comply with new command
jasonch35 Nov 4, 2024
98ad026
Update script and atcommand documentation
jasonch35 Nov 4, 2024
0cb567d
Update HPM Hooks
jasonch35 Nov 4, 2024
4aea3a4
Show warning if storage capacity is over MAX_STORAGE
jasonch35 Nov 5, 2024
c8947dc
Use cart function when storing from cart
jasonch35 Nov 21, 2024
c5e746a
Indexed storage_id column from storage sql table
jasonch35 Dec 1, 2024
41528de
Char-server to ignore storage sizes and hardcoded to MAX_STORAGE instead
jasonch35 Dec 1, 2024
6e485b3
Moved storage_settings struct from mmo to storage header
jasonch35 Dec 1, 2024
1dccefc
Added access modes argument for storage->open
jasonch35 Dec 1, 2024
8baf55b
Refactored atcommands logic
jasonch35 Dec 1, 2024
973f6f6
Missed name parameter in clif.c
jasonch35 Dec 1, 2024
dcdd63c
Fixed invalid storage(0) assertion
jasonch35 Dec 1, 2024
49997aa
Indentation/space fix
jasonch35 Dec 1, 2024
645b77a
PCCHECK_STORAGE check fix
jasonch35 Dec 1, 2024
d6adf1b
Initialization logic fix
jasonch35 Dec 1, 2024
007a858
Removed unnecessary cleaning of VECTOR
jasonch35 Dec 1, 2024
1c34316
Removed full storage checks for functions that calls storage->additem()
jasonch35 Dec 1, 2024
a919fd8
Set constant at the end of every iteration at config reading
jasonch35 Dec 1, 2024
53baf8b
Update HPM Hooks
jasonch35 Dec 1, 2024
e882183
Messagetable update
jasonch35 Dec 1, 2024
dc85a3e
Proper code styling for asterisks
jasonch35 Dec 1, 2024
3ec152b
Clif update storage amount window to capacity
jasonch35 Dec 1, 2024
8df6252
Corrected documentation
jasonch35 Dec 1, 2024
9f08c77
Storage config reading
jasonch35 Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions conf/messages.conf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 54,7 @@
24: Job level raised.
25: Job level lowered.
26: [%d] seconds left until you can use
27: Storage has been not loaded yet.
27: %s has not been loaded yet.
28: No player found.
29: 1 player found.
30: %d players found.
Expand Down Expand Up @@ -91,7 91,11 @@
62: Judgement has passed.
63: Mercy has been shown.
64: Mercy has been granted.
//65-69 FREE
65: Please specify a storage ID or name. (usage: @storeall <storage name/ID>).
66: Please specify a storage ID or name. (usage: @clearstorage <storage name/ID>).
67: Please specify a storage ID or name. (usage: @storage <storage name/ID>).
68: Please specify a storage ID or name. (usage: @storagelist <storage name/ID>).
69: Invalid storage name or ID
70: You have learned the skill.
71: You have forgotten the skill.
72: War of Emperium has been initiated.
Expand Down Expand Up @@ -779,7 783,7 @@
918: Please enter a speed value (usage: @speed <%d-%d>).

// @storage
919: Storage opened.
919: %s opened.

// @guildstorage
920: Guild storage opened.
Expand Down Expand Up @@ -1507,7 1511,7 @@
1393: You can't use commands while dead.

// @clearstorage
1394: Your storage was cleaned.
1394: Your %s has now been cleaned.
1395: Your guild storage was cleaned.

// @clearcart
Expand Down
53 changes: 53 additions & 0 deletions conf/storage.conf
Original file line number Diff line number Diff line change
@@ -0,0 1,53 @@
//================= Hercules Database ==========================================
//= _ _ _
//= | | | | | |
//= | |_| | ___ _ __ ___ _ _| | ___ ___
//= | _ |/ _ \ '__/ __| | | | |/ _ \/ __|
//= | | | | __/ | | (__| |_| | | __/\__ \
//= \_| |_/\___|_| \___|\__,_|_|\___||___/
//================= License ====================================================
//= This file is part of Hercules.
//= http://herc.ws - http://github.com/HerculesWS/Hercules
//=
//= Copyright (C) 2014-2024 Hercules Dev Team
//= Copyright (C) 2017 Smokexyz
//=
//= Hercules is free software: you can redistribute it and/or modify
//= it under the terms of the GNU General Public License as published by
//= the Free Software Foundation, either version 3 of the License, or
//= (at your option) any later version.
//=
//= This program is distributed in the hope that it will be useful,
//= but WITHOUT ANY WARRANTY; without even the implied warranty of
//= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//= GNU General Public License for more details.
//=
//= You should have received a copy of the GNU General Public License
//= along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================
//= Storage Configuration
//================= Description ================================================
//= There can be an unlimited amount of storages and limits.
//= All setting names are case-sensitive and must be keyed accurately.
//= Storage capacity will default to MAX_STORAGE in mmo.h if set higher
//= Storage ID 1 is the default (official) storage for accounts.
//==============================================================================

storage_conf: (
/******************************************************************************
***************************** Entry structure *********************************
*******************************************************************************
{
Id: (int) Unique Identifier
Name: (string) Name of the storage sent to the client.
Constant: (string) Constant to be used by scripts
Capacity: (int) Maximum capacity of the storage.
}
*******************************************************************************/
{
Id: 1
Name: "Main Storage"
Constant: "STORAGE_TYPE_MAIN"
Capacity: 600
},
)
17 changes: 11 additions & 6 deletions doc/atcommands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 560,9 @@ Using the command without a message will enable or disable main chat.

---------------------------------------

@storage
@storage <storage name/id>

Opens your Kafra storage.
Opens your specified Kafra storage.

---------------------------------------

Expand Down Expand Up @@ -731,9 731,9 @@ Valid item types:

---------------------------------------

@storeall
@storeall <storage name/id>

Places all inventory and equipped items directly into your Kafra Storage.
Places all inventory and equipped items directly into your specified storage.

---------------------------------------

Expand All @@ -743,10 743,15 @@ Deletes all inventory items (not equipped items).

---------------------------------------

@clearstorage
@clearstorage <storage name/id>

Deletes all items in specified storage.

---------------------------------------

@cleargstorage

Deletes all items in storage (or guild storage).
Deletes all items in guild storage.

---------------------------------------

Expand Down
29 changes: 21 additions & 8 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6217,19 6217,32 @@ has no gear, script will be terminated with an error.
//=====================================
---------------------------------------

*openstorage()
*openstorage(<storage_constant>{, <storage_mode>});

This will open character's Kafra storage window on the client connected to
the invoking character. It can be used from any kind of NPC or item
script, not just limited to Kafra Staff.
This command opens the specified <storage_constant> storage window on the client
connected to the invoking character. It can be used from any kind of NPC or
item script and is not limited to Kafra Staff interactions.

The storage window opens regardless of whether there are open NPC dialogs
or not, but it is preferred to close the dialog before displaying the
storage window, to avoid any disruption when both windows overlap.
The storage window will open regardless of whether there are open NPC dialogs,
but it is recommended to close any dialogs before displaying the storage window
to avoid overlapping interface elements, which could disrupt the user experience.

Parameters:
<storage_constant>: Specifies which storage to open (e.g., STORAGE_TYPE_MAIN).
Constants are declared in conf/storage.conf
<storage_mode> (optional): Defines the access permissions for the storage window.

Storage Modes (bitmask):
STORAGE_ACCESS_VIEW: View storage only.
STORAGE_ACCESS_GET: Allow retrieving items from storage.
STORAGE_ACCESS_PUT: Allow depositing items into storage.
STORAGE_ACCESS_ALL: (Default mode) Full access for viewing, retrieving,
and depositing items.

Example Usage:
mes("I will now open your stash for you");
close2();
openstorage();
openstorage(STORAGE_TYPE_MAIN);
end;

The mapflag 'nostorage' when set to type '2' (or 3), will not open the
Expand Down
2 changes: 1 addition & 1 deletion npc/custom/etc/quest_warper.txt
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 474,7 @@ L_Storage:
}
mes "Close this window and I will open your storage.";
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;

L_StorageJBlow:
Expand Down
2 changes: 1 addition & 1 deletion npc/kafras/functions_kafras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 293,7 @@ function script F_KafStor {
}
callfunc("F_CheckKafCode"); //check your storage password, if set
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
cutin "", 255;
end;
}
Expand Down
2 changes: 1 addition & 1 deletion npc/kafras/kafras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 92,7 @@ aldeba_in,96,181,4 script Kafra Service 4_F_KAFRA5,{
mes "Thank you for your patronage.";
callfunc("F_CheckKafCode"); //check your storage password, if set
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
break;
case 3:
mes "[Kafra Leilah]";
Expand Down
2 changes: 1 addition & 1 deletion npc/other/CashShop_Functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 46,7 @@ function script F_CashStore {
mes "Welcome to the Kafra Corporation.";
mes "Here, let me open your Storage for you.";
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
cutin "",255;
return;
}
Expand Down
6 changes: 3 additions & 3 deletions npc/quests/quests_13_1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7686,7 7686,7 @@ function Catwarp;
mes "Your storage will";
mes "be opened shortly.";
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
}
else {
Expand Down Expand Up @@ -7733,7 7733,7 @@ function Catwarp;
mes "Your storage will";
mes "be opened shortly.";
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
}
else {
Expand Down Expand Up @@ -7855,7 7855,7 @@ function Catwarp;
mes "Your storage will";
mes "be opened shortly.";
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
}
else {
Expand Down
6 changes: 3 additions & 3 deletions npc/quests/quests_13_2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 109,7 @@ spl_fild02,25,211,4 script Cat Hand Agent#spl 4_M_BOSSCAT,{
mes "Thank you.";
mes "Your storage will be opened shortly.";
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
}
else {
Expand Down Expand Up @@ -156,7 156,7 @@ spl_fild02,25,211,4 script Cat Hand Agent#spl 4_M_BOSSCAT,{
mes "Thank you.";
mes "Your storage will be opened shortly.";
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
}
else {
Expand Down Expand Up @@ -277,7 277,7 @@ spl_fild02,25,211,4 script Cat Hand Agent#spl 4_M_BOSSCAT,{
mes "Thank you.";
mes "Your storage will be opened shortly.";
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
}
else {
Expand Down
2 changes: 1 addition & 1 deletion npc/re/cities/mora.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 1194,7 @@ mora,48,128,0 script Drawer#mora_warehouse HIDDEN_NPC,{
close;
}
Zeny -= 100;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
close;
case 2:
mes "- You gave up using the warehouse. -";
Expand Down
2 changes: 1 addition & 1 deletion npc/re/jobs/2e/rebellion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 987,7 @@ job_gun,216,138,4 script Butler Karlex 1_M_01,{
mes("Thank you for using the service.");
close2();
if (.@select == 2) {
openstorage();
openstorage(STORAGE_TYPE_MAIN);
}
end;
}
Expand Down
2 changes: 1 addition & 1 deletion npc/re/jobs/novice/academy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5422,7 5422,7 @@ iz_ac01,95,46,5 script Kafra Guide Trainer#ac 4_F_KAFRA1,{
mes("Thanks for using~!");
close2();
cutin("", 255);
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
} else {
mes("[Kafra Guide Trainer]");
Expand Down
2 changes: 1 addition & 1 deletion npc/re/other/dimensional_gap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 137,7 @@ dali,112,95,4 script Logistics Manager 4_M_MERCAT2,{
mes("You need at least 200 zeny to use the Storage.");
} else {
Zeny -= 200;
openstorage();
openstorage(STORAGE_TYPE_MAIN);
}
close();
}
Expand Down
2 changes: 1 addition & 1 deletion npc/re/quests/eden/eden_service.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 65,7 @@
}
Zeny -= 500;
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
}
mes "I don't have enough zeny.";
Expand Down
2 changes: 1 addition & 1 deletion npc/re/quests/quests_dicastes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 449,7 @@ dic_in01,254,119,0 script Item Storage#01 CLEAR_NPC,{
}
Zeny -= 500;
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
}

Expand Down
2 changes: 1 addition & 1 deletion npc/re/quests/quests_malangdo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 371,7 @@ malangdo,184,139,4 script Storekeeper#mal 4_CAT_ADV2,{
mes "[Storekeeper]";
mes "Thank you.";
close2;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
}

Expand Down
2 changes: 1 addition & 1 deletion npc/woe-fe/agit_main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 367,7 @@ OnRecvCastle:
mes "the Kafra Service.";
close2;
cutin "",255;
openstorage;
openstorage(STORAGE_TYPE_MAIN);
end;
case 2:
mes "[Kafra Employee]";
Expand Down
2 changes: 1 addition & 1 deletion npc/woe-se/agit_main_se.txt
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 869,7 @@ OnInit:
mes("have at least Novice Skill");
mes("Lv.6 to use the Storage.");
}
else openstorage;
else openstorage(STORAGE_TYPE_MAIN);
break;
case 2:
mes("[Kafra Employee]");
Expand Down
5 changes: 4 additions & 1 deletion sql-files/main.sql
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 967,7 @@ INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1599908598); -- 2020-09-1
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1613840320); -- 2021-02-20--19-57.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1618058468); -- 2021-04-10--15-36.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1653155461); -- 2022-05-21--29-49.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1730631632); -- 2024-11-03--07-00.sql

--
-- Table structure for table `storage`
Expand All @@ -975,6 976,7 @@ INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1653155461); -- 2022-05-2
CREATE TABLE IF NOT EXISTS `storage` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`account_id` INT UNSIGNED NOT NULL DEFAULT '0',
`storage_id` INT UNSIGNED NOT NULL DEFAULT '1',
jasonch35 marked this conversation as resolved.
Show resolved Hide resolved
`nameid` INT UNSIGNED NOT NULL DEFAULT '0',
`amount` SMALLINT UNSIGNED NOT NULL DEFAULT '0',
`equip` INT UNSIGNED NOT NULL DEFAULT '0',
Expand All @@ -1000,7 1002,8 @@ CREATE TABLE IF NOT EXISTS `storage` (
`bound` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`unique_id` BIGINT UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `account_id` (`account_id`)
KEY `account_id` (`account_id`),
KEY `storage_id` (`storage_id`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `rodex_items` (
Expand Down
24 changes: 24 additions & 0 deletions sql-files/upgrades/2024-11-03--07-00.sql
Original file line number Diff line number Diff line change
@@ -0,0 1,24 @@
#1730631632

-- This file is part of Hercules.
-- http://herc.ws - http://github.com/HerculesWS/Hercules
--
-- Copyright (C) 2013-2024 Hercules Dev Team
--
-- Hercules is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.

ALTER TABLE `storage` ADD `storage_id` INT UNSIGNED NOT NULL DEFAULT '1' AFTER `account_id`,
ADD INDEX `storage_id` (`storage_id`);

INSERT INTO `sql_updates` (`timestamp`) VALUES (1730631632);
Loading
Loading