-
Notifications
You must be signed in to change notification settings - Fork 761
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.
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
I know its Holidays but please give us this, we've been waiting for years. (officially) |
|
||
VECTOR_ENSURE(p->item, num_rows > MAX_STORAGE ? MAX_STORAGE : num_rows, 1); | ||
if (SQL->NumRows(inter->sql_handle) > 0) { | ||
VECTOR_ENSURE(p->item, MAX_STORAGE, 1); |
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 would be allocating more memory than needed if the storage is not full with MAX_STORAGE items. I think it would be better to keep the original logic of only allocating the needed space, never exceeding the MAX_STORAGE value.
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 Haru stated above #3330 (comment), number of items showing in the storage should retrieve actual (or more) amount even if its higher than storage capacity and should be hard limited only by MAX_STORAGE. Instead, we let map server to handle the limits. Which I agree in case owners reduce the capacity of a specific storage.
if (sd->storage.received == false) { | ||
clif->message(sd->fd, msg_sd(sd, MSGTBL_STORAGE_NOT_LOADED)); // Storage has not been loaded yet. | ||
return 1; | ||
} |
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.
is removing the received check intended? from Haru message, he asked whether turning the message into assertion was intended (as an assertion doesn't inform the user why this happened).
But now, we would allow a not received storage to be "open".
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.
Yes, I rewritten it as an assertion error but as Haru pointed out, it is no longer needed as the script and atcommands already errors out when called if storage is not loaded yet in intif_parse_account_storage
src/map/unit.c
Outdated
|
||
for (int i = 0; i < VECTOR_LENGTH(sd->storage.list); i++) { // Storages | ||
VECTOR_CLEAR(VECTOR_INDEX(sd->storage.list, i).item); | ||
VECTOR_INDEX(sd->storage.list, i).received = false; |
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.
(adding here since the line is gone from the final diff)
the vector still needs to be cleared up, because its internal data is dynamically allocated. you just don't have to set received
to false, as this data will be cleared up at VECTOR_CLEAR(sd->storage.list);
ShowError("intif_parse_account_storage: Multiple calls from the inter-server received.\n"); | ||
return; | ||
} | ||
|
||
storage_count = (payload_size/sizeof(struct item)); | ||
|
||
VECTOR_ENSURE(sd->storage.item, storage_count, 1); | ||
VECTOR_ENSURE(stor->item, storage_count, 1); |
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.
Memory manager reported a leak from this, I didn't check what is causing it (not sure if related to the missing VECTOR_CLEAR in unit.c
0001 : storage.c line 298 size 352 address 0x0x55976f3717e4
0002 : intif.c line 363 size 440 address 0x0x55977473f1fc
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 #3330 (comment), error now gone for me (I used builtin). Thank you!
VECTOR_PUSH(sd->storage.item, *item_data); | ||
it = &VECTOR_LAST(sd->storage.item); | ||
if (i == VECTOR_LENGTH(stor->item)) { | ||
VECTOR_ENSURE(stor->item, 1, 1); |
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.
Memory manager reported a leak from this, I didn't check what is causing it (not sure if related to the missing VECTOR_CLEAR in unit.c
0001 : storage.c line 298 size 352 address 0x0x55976f3717e4
0002 : intif.c line 363 size 440 address 0x0x55977473f1fc
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
src/map/script.c
Outdated
@@ -12035,7 +12035,7 @@ static BUILDIN(openstorage) | |||
|
|||
sd->storage.access = storage_access; // Set storage access level. [Smokexyz/Hercules] |
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 now redundant since it's done by storage->open()
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.
Removed. thank you. please rereview.
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!