-
Notifications
You must be signed in to change notification settings - Fork 759
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
base: master
Are you sure you want to change the base?
Conversation
This commit includes: - HUSS main implementation - openstorage script command update - @storage atcommand update - @clearstorage atcommand update - @storeall atcommand update - @storagelist atcommand update
- There can be an unlimited amount of storages and limits. - All setting names are case-sensitive and must be keyed accurately. - The storage capacity will default to MAX_STORAGE in mmo.h if it is set higher - Storage ID 1 is the default (official) storage for accounts. - Integrated storage_constants (Constant) into the configuration so that it can be assigned dynamically
Thank you @jasonch35 hope this one will get implemented. |
Yes, Limit is capped by MAX_STORAGE which is 600 by default. |
Btw, I kept the "default" storage without warning/errors as it is set as default in original Herc's branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for putting the effort in fixing the previous PRs!
I did not try running it yet, but from the code review, I got those questions/points that may need to be addressed.
src/char/int_storage.c
Outdated
if (VECTOR_LENGTH(cp.item) > 0) { | ||
|
||
int *delete = aCalloc(cp_size, sizeof(int)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a VECTOR as well, removing the need to allocate it to an arbitrarily large size. It can be expanded as items to be deleted are found, with an appropriate growth step.
This would remove the need for a couple of confusing 'size' support vars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted to local variables since we hardcoded to a fixed MAX_STORAGE anyway.
I think it'll be much more efficient this way.
src/char/int_storage.c
Outdated
|
||
int cp_size = inter_storage->fromsql(account_id, storage_id, &cp, 0); | ||
|
||
bool* matched_p = aCalloc(VECTOR_LENGTH(p->item), sizeof(bool)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good candidate for a VECTOR, to avoid doing array subscript on a bare pointer and to make its length clear to the reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above:
Reverted to local variables since we hardcoded to a fixed MAX_STORAGE anyway.
I think it'll be much more efficient this way.
src/map/storage.c
Outdated
nullpo_retr(false, filename); | ||
|
||
if (!imported) | ||
VECTOR_INIT(storage->configuration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to VECTOR_CLEAR()
and move the init to storage_defaults()
so that there are no uninitialized variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking. I wanna drop this feature altogether. Since Nvm.storage.conf
will be as is almost forever officially similar to other configs. There is no point having additional fields and imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I transferred config read function below the initialization.
src/common/mmo.h
Outdated
/* Hercules Ultimate Storage System [Smokexyz/Hercules] */ | ||
struct storage_settings { | ||
int uid; ///< Storage Identifier. | ||
char name[NAME_LENGTH]; ///< Storage Name | ||
int capacity; ///< Item Capacity. | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This belongs to the map server and the char server has no business with it. Please move it to storage.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also regenerated HPM for this.
storage->config_read_additional_fields(t, &s_conf, filename); | ||
|
||
if (imported) { | ||
ARR_FIND(0, VECTOR_LENGTH(storage->configuration), i, VECTOR_INDEX(storage->configuration, i).uid == s_conf.uid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it stands, this seems an impossible condition (the duplicate check above was designed to only be executed if imported == false
perhaps?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above: Nvm.
I've been thinking. I wanna drop this feature altogether. Since storage.conf will be as is almost forever officially similar to other configs. There is no point having additional fields and imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added check on the first duplicate check.
Reverted to local variables since its not needed to allocate anymore.
Adjusted callers
-Direct initialization for struct instead to NULL -Removed `intval` variable: copy value directly to `storage_id` -Removed unnecessary message table comments -Moved stst NULL check outside of if condition
+ few cleanups
Also added handler for when storage capacity is invalid or set below 1
-Added @storagelist error message and rearranged -Matched MSGTBL_STORAGE_NOT_LOADED to its messages.conf text
- Check duplicate for non imported storage ID and overwrite when imported ID exist - Move vector initialization on do_init_storage and transferred config reading after it
Pull Request Prelude
Changes Proposed
MAX_STORAGE
at config readingStorage Configuration
Script Command
openstorage(<storage_constant>{, <storage_mode>});
Storage Modes
All atcommands utilizing storage has been updated as well:
@storage <storage name/id>
@storeall <storage name/id>
@clearstorage <storage name/id>
@storagelist <storage name/id>
Issues addressed:
Upon testing the following has been fixed as well:
Thank you @kyeme for pointing it out.
Credits to: @sagunkho and @dastgirp
Let's gooooo let's push this through!