-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Item contents refactor (holster refactor 1 of 2) #36656
Item contents refactor (holster refactor 1 of 2) #36656
Conversation
6ff28b6
to
9d151de
Compare
5e2b4ab
to
e5050f6
Compare
return string_format( "%.2f %s", converted_weight, weight_units() ); | ||
} | ||
|
||
void item_pocket::general_info( std::vector<iteminfo> &info, int pocket_number, |
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.
Consider adding a new test to tests/iteminfo_test.cpp
for your new iteminfo
features.
0b22039
to
e47a2a1
Compare
Where in the code are you new classes actually used? I don't see a change to I also don't see any JSON definitions for the pocket data. In other words: this adds a bunch of dead code. |
#36660 |
But we can't really test this PR as the code added here is never run. I suggest you only add code that is actually used within a PR. For example the next PR (step 2 of 3) uses |
I see... I simply did not want to have a pr with 2k lines of change, but i suppose i can combine this one with that one? |
bf546d9
to
e898705
Compare
7278721
to
69e2641
Compare
note to self: do a sanity check on wherever i'm calling |
b9d9f80
to
4c6ed77
Compare
sanity check done |
5b0cb63
to
babd03a
Compare
note: there's some kind of quantum holster bug i need to fix still |
This PR is not a refactor: it's a sketch which adds loads of code for the sake of a minor part of the new feature. The idea behind pockets is interesting by itself, but it's an optional nice-to-have thing, not the essence of the unified nestable containers. I mean those can be made fully functional and smoothly playable with no pockets at first (or even at all). My concern is that the proposed implementation featuring pockets is somewhat cumbersome in terms that it would hinder the actually hard parts of the task instead of helping them. I'd suggest abandoning it for now and focusing on evolving the proper container-containee relationship, improving the existing code as you go. Then you could address the major tasks outlined by Kevin in #3671 (comment) to get the new system up and running, making it so that pockets could fit into it nicely. |
I don't really understand, but i guess i can close this pr until i have it all done i guess, like i did magiclysm? I have some specific plans and my own concerns now that this PR has been in the works for a long time, and I can outline them if it helps any:
|
I'd be advocating for the step-by-step approach. Even this PR (more than 2000 new lines of executable code) is well beyond being comfortably reviewable (Kevin once suggested 200 as a good upper limit).
This looks like an excellent first step.
I don't particularly see why. If you have, say,
Yes. It's one of the tricky parts I guess (especially considering proper stacking of items and different handling costs). The packing algorithm should be reasonably fast in case of vast amounts of items. At the same time, it should almost never make the player "fix" it (in other words, it must never yield unacceptable results).
That's the other tricky part, yes. I assume inventing convenient UI for this won't be trivial.
The container handling code in
I suppose there should be certain constraints, of course (like if a container contains liquid/powder, it can't contain anything else, and vice versa), but in the generic case, items should be able to nest indefinitely. |
all right, that makes me feel much better about what i decided to do when you posted the first time. I decided that i'm just going to need to hammer away at it in a branch and make a checklist for things i need to pr at a time to try to keep it as small as i can. i will continue to work with everyone on the discord and see how many prs i get out of it |
Summary
SUMMARY: Infrastructure "create item_pocket and item_contents class definitions"
Purpose of change
this is the first of two PRs to refactor holster to use the new item_pockets, which are part of the greater project "nested container system"
refer to #3671 for plenty-o-discussion
Describe the solution
My main idea behind the nested container system revolves around the idea of a "pocket", which is a small space that an item can have one or more of to contain items. A pocket has several pieces of metadata to define what kind of items are allowed to be placed in them:
an item's contents will be replaced by the item_contents class.
The data structure is such that an item_contents has a std::list<item_pocket> and an item_pocket has a std::list
in most applications, the item_pocket functions should never need to be accessed outside of item_contents functions, as this class is directly responsible for walking through the item_pocket.
Much of the functions as such are named the same, but the item_contents functions are usually a for loop.
Testing
tested together with the other PRs as a whole, for several days and via several helpful volunteers.