Skip to content

Hercules Ultimate Storage System#2724

Closed
dastgirp wants to merge 14 commits into
HerculesWS:masterfrom
dastgirp:sStorage
Closed

Hercules Ultimate Storage System#2724
dastgirp wants to merge 14 commits into
HerculesWS:masterfrom
dastgirp:sStorage

Conversation

@dastgirp

@dastgirp dastgirp commented May 16, 2020

Copy link
Copy Markdown
Member

Pull Request Prelude

Changes Proposed

Design

Implementation of the Hercules Ultimate Storage System
Storages can now be created through a configuration file that describes their attributes.
Example storage configuration:

{
        Id: (int)                              (required|unique) Unique Identifier
        Name: (string)                         (required) Name of the storage sent to the client.
        Capacity: (int)                        (required) Maximum capacity of the storage.
}

Additional storages are handled with dynamic arrays that will save a tonne of memory when created, as opposed to a design in which they were implemented using fixed length arrays. In simple terms, a storage of 600 items would approximately cost the same amount of memory as 600 storages with 1 item each.
They are saved in the same storage database (SQL) as the original separating them by a storage identifier.
An infinite number of storages can be created, there are no limits.
The current design implementation only allow saving/loading of approximately 1600 items per storage due to packet size limits.

PS. Make sure you apply SQL upgrades for this patch!

Access Modes

Storage access modes can be set through the openstorage builtin command.

	STORAGE_ACCESS_VIEW     // View storage only
	STORAGE_ACCESS_GET      // Allow getting items from storage.
	STORAGE_ACCESS_PUT      // Allow putting items to storage.
	STORAGE_ACCESS_ALL      // Allow all actions.

Default storage mode : STORAGE_ACCESS_ALL

Script Commands

Changed: openstorage(<storage_id>{, <storage_mode>})

Issues addressed:

@dastgirp dastgirp requested review from 4144 and Kenpachi2k13 and removed request for Kenpachi2k13 May 16, 2020 18:02
@4144

4144 commented May 16, 2020

Copy link
Copy Markdown
Contributor

from ci, look like shadow variable i

@dastgirp dastgirp marked this pull request as draft May 16, 2020 19:29
@dastgirp

Copy link
Copy Markdown
Member Author

Windows compile fine for now, will be checking linux warnings and errors soon.

@4144 4144 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some checks probably already added in last commit, but i checked commit by commit from start

Comment thread conf/messages.conf Outdated
Comment thread conf/messages.conf Outdated
Comment thread src/map/clif.c
Comment thread src/map/clif.c
Comment thread src/map/clif.c
Comment thread src/map/intif.c Outdated
Comment thread src/map/intif.c Outdated
Comment thread src/map/script.c Outdated
Comment thread src/map/storage.c Outdated
Comment thread db/constants.conf Outdated
@Kenpachi2k13

Copy link
Copy Markdown
Member

In my opinion the Xcode upgrade should not be part of this PR since it's not required.

@dastgirp

Copy link
Copy Markdown
Member Author

In my opinion the Xcode upgrade should not be part of this PR since it's not required.

Ok, will remove it, I had just migrated it from old code to new code

@dastgirp dastgirp force-pushed the sStorage branch 3 times, most recently from ab0a8dc to 772ff5e Compare May 24, 2020 06:09
@dastgirp dastgirp requested a review from 4144 May 24, 2020 06:11
@dastgirp dastgirp force-pushed the sStorage branch 2 times, most recently from 14871b7 to 274ec5b Compare May 24, 2020 06:24
@dastgirp dastgirp marked this pull request as ready for review May 24, 2020 06:24
@dastgirp

Copy link
Copy Markdown
Member Author

@4144 @Kenpachi2k13 can you review again?

Comment thread src/map/atcommand.c Outdated
Comment thread src/map/clif.c Outdated
return;
}

nullpo_retv(stor);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this nullpo probably need move into if block, because after if block, stor is non null

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/map/clif.c Outdated
struct storage_data *stor = storage->ensure(sd, sd->storage.current);
if (stor != NULL)
storage->get(sd, stor, item_index, item_amount);
} else if(sd->state.storage_flag == STORAGE_FLAG_GUILD) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be else if (sd->...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/map/intif.c Outdated
if ((stor = storage->ensure(sd, RFIFOW(fd, 8))) == NULL)
return;

Assert_retv(stor != NULL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here stor is not null

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/map/intif.c Outdated
if ((stor = storage->ensure(sd, storage_id)) == NULL)
return;

Assert_retv(stor != NULL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here stor is not null

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@bWolfie

bWolfie commented Jun 8, 2020

Copy link
Copy Markdown
Contributor

nice bro

@bWolfie

bWolfie commented Jun 9, 2020

Copy link
Copy Markdown
Contributor

Anyone currently using this on their server?

@4144

4144 commented Jul 26, 2020

Copy link
Copy Markdown
Contributor

@dastgirp you can complete this?

@Vaans

Vaans commented Oct 28, 2020

Copy link
Copy Markdown

dreams come true :D?

Comment thread src/map/unit.c Outdated
if( sd->sc_display_count ) {
int i;
for(i = 0; i < sd->sc_display_count; i++) {
for(int i = 0; i < sd->sc_display_count; i++) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after for and the curly brackets could be removed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/map/unit.c Outdated
}
VECTOR_CLEAR(sd->channels);
VECTOR_CLEAR(sd->script_queues);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this empty line?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, might be due to merge from old commit to here

Comment thread src/map/storage.c

/**
* Get a storage id by its name (through @commands etc...)
* @param[in] storage_name pointer to the storage name char array.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please separate the description and the parameter list with an empty comment line.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/map/storage.c

/**
* Get storage with a particular ID from a player.
* @param[in] sd pointer to map session data.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please separate the description and the parameter list with an empty comment line.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/map/storage.c Outdated
int i = 0;
struct storage_data *stor = NULL;

nullpo_retr(NULL, sd);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the NULL pointer check prior to declaring/initialising the variables.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/char/mapif.c Outdated
{
int payload_size = RFIFOW(fd, 2) - 8, account_id = RFIFOL(fd, 4);
int payload_size = RFIFOW(fd, 2) - 10, account_id = RFIFOL(fd, 4);
short storage_id = RFIFOW(fd, 8);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
short storage_id = RFIFOW(fd, 8);
int storage_id = RFIFOW(fd, 8);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is of 2 bytes, only, but as I see other are using int, changed it. done

Comment thread src/char/mapif.c
* @packet 0x3808 [out] <account_id>.L <storage_id>.W <save_flag>.B
* @param fd [in] File/Socket Descriptor.
* @param account_id [in] Account ID of the storage in question.
* @param flag [in] Save flag, true for success and false for failure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add parameter storage_id.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/char/int_storage.c Outdated
Comment on lines +47 to +50
bool *matched_p = NULL;
int *delete = NULL;
int total_deletes = 0, total_updates = 0, total_inserts = 0;
int total_changes = 0;
int cp_size = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix variable scopes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread sql-files/main.sql Outdated
CREATE TABLE IF NOT EXISTS `storage` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`account_id` INT UNSIGNED NOT NULL DEFAULT '0',
`storage_id` INT(11) UNSIGNED NOT NULL DEFAULT '1',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`storage_id` INT(11) UNSIGNED NOT NULL DEFAULT '1',
`storage_id` INT UNSIGNED NOT NULL DEFAULT '1',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

-- 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(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `account_id`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ALTER TABLE `storage` ADD `storage_id` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `account_id`;
ALTER TABLE `storage` ADD `storage_id` INT UNSIGNED NOT NULL DEFAULT '1' AFTER `account_id`;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@SombraRO

Copy link
Copy Markdown

@dastgirp something about that?

@dastgirp

Copy link
Copy Markdown
Member Author

@Kenpachi2k13 updated to latest commit and made all changes that were mentioned by you.

@4144

4144 commented Nov 28, 2020

Copy link
Copy Markdown
Contributor

look like compilation errors in all or most jobs

@dastgirp

Copy link
Copy Markdown
Member Author

look like compilation errors in all or most jobs

was problem with scope, fixed it.

@pazkero

pazkero commented Feb 15, 2021

Copy link
Copy Markdown
Contributor

@dastgirp Can you complete this? Seems to be having conflicts again... =(

@dastgirp

Copy link
Copy Markdown
Member Author

@dastgirp Can you complete this? Seems to be having conflicts again... =(

It was already completed but for some reason not merged,
If it is going to be merged in next cycle, I can fix the conflicts again, but without confirmation, it would just keep on conflicting with every new release, so, I won't be fixing conflict as of now until confirmation is received or some changes are requested.

@pazkero

pazkero commented Feb 16, 2021 via email

Copy link
Copy Markdown
Contributor

Comment thread src/map/script.c
{
struct map_session_data *sd = script->rid2sd(st);
if (sd == NULL)
int storage_id = script_getnum(st, 2);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not making this optional, as you need to have a storage 1 configured (SQL, for example) and considering it would improve compatibility?

Suggested change
int storage_id = script_getnum(st, 2);
int storage_id = script_hasdata(st, 2) ? script_getnum(st, 2) : 1;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this as optional is a way, but it won't tell others something is wrong.
Specifying storage id is better as it's clear that storage 1 will be used.
You can have any id you want, (even remove the Id 1), so having this optional would make it more confusing

@sgsilva

sgsilva commented Jul 1, 2021

Copy link
Copy Markdown

Does anyone have any news about?

@pazkero

pazkero commented Jul 1, 2021 via email

Copy link
Copy Markdown
Contributor

@waken22

waken22 commented Nov 5, 2021

Copy link
Copy Markdown

Any news about this?

@bWolfie

bWolfie commented Nov 12, 2021

Copy link
Copy Markdown
Contributor

One day it will become a reality. Lol.

@csnv

csnv commented Sep 19, 2023

Copy link
Copy Markdown
Contributor

@dastgirp @MishimaHaruna can we have a definitive merging window and finish this?

@Vaans

Vaans commented Feb 16, 2024

Copy link
Copy Markdown

Four years already :'(

@Samuel23 Samuel23 mentioned this pull request Jun 18, 2024
3 tasks
@MishimaHaruna

Copy link
Copy Markdown
Member

Closing this in favor of the updated versions #3302, #3330

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.