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

perf: make more items stackable #3489

Merged
merged 6 commits into from
Dec 25, 2023

Conversation

scarf005
Copy link
Member

@scarf005 scarf005 commented Oct 23, 2023

Purpose of change

Describe the solution

  1. wrote a script to migrate items to AMMO stackable
  2. converted items i could think of
  3. rags are heavily buffed, weighs only 10g/20ml (should be a separate balance PR)
  4. TOOLs are now GENERIC
  5. parts that were also used as vehicle parts had to be removed as they were the culprit for breaking vehicle tests. i suspect vehicle drag and efficiency calculate does not take account of count-by-charges

Describe alternatives you've considered

make everything stackable?

Testing

haven't tested disassembly and crafting, so weird stuff might happen.

rag.mp4

interestingly, use_action works as before.

Additional context

context: https://discord.com/channels/830879262763909202/830916329053487124/1166006575664738307

@github-actions github-actions bot added JSON related to game datas in JSON format. scripts related to game management scripts labels Oct 23, 2023
@olanti-p
Copy link
Contributor

AMMO is for gun and tool ammo. If you want generic items to be stackable, use stackable.

@scarf005
Copy link
Member Author

ah, will fix the script (tomorrow)

@chaosvolt
Copy link
Member

You'll definitely want to test the use action of rags to see whether they can get away with being ammo, or whether they should be comestibles instead.

@scarf005
Copy link
Member Author

i forgor other item types could be stackable, will try to preserve their types as before using stackable

@scarf005
Copy link
Member Author

 DEBUG    : warnings for type disinrag:
invalid stack_size 0 on type using charges


 FUNCTION : void Item_factory::check_definitions() const
 FILE     : /home/scarf/repo/cata/Cataclysm/src/item_factory.cpp
 LINE     : 1526
 VERSION  : BN 9fd976a84ee6

oww

@scarf005 scarf005 force-pushed the perf-more-stackables branch 2 times, most recently from cbe5535 to 302a7e3 Compare October 23, 2023 16:45
@olanti-p
Copy link
Contributor

Test failures seem to be related to the change, no other PR has them.

@scarf005
Copy link
Member Author

i've reduced rag weight and volume, so vehicle distance travelled test was failing.

@chaosvolt
Copy link
Member

chaosvolt commented Oct 24, 2023

Hmm, this is gonna run into the same issue as #3414 in opening up a lot of potential material duplication exploits. :/

That said, maybe a saner answer will end up being to just tweak recipes to fit instead of worrying about that since #3419 is kinda stalled by just how painfully slow it is to sanity-check every item in the game. XD

@scarf005
Copy link
Member Author

probably this indicates we need a saner recipe and uncrafts system, but anyways will rollback rag weights

@chaosvolt
Copy link
Member

Either way is fine I guess, the fix PR is kinda slow going since it's absolute hell to work with each item so do whichever works. XD

@scarf005
Copy link
Member Author

the fix PR is kinda slow going since it's absolute hell to work with each item

well that sounds painful, let's don't, you deserve better

@chaosvolt
Copy link
Member

Eh, items and recipes kinda need a big cleanup either way and have needed it ever since salvage-by-weight was merged, just still unsure which direction it should go in.

@github-actions github-actions bot added the src changes related to source code. label Oct 26, 2023
@scarf005
Copy link
Member Author

currently vehicle tests fail because apparently item weights are calculated differently for stacks.

@scarf005 scarf005 changed the title perf: make more items stackable perf(balance): make more items stackable Dec 2, 2023
scarf005 added a commit to scarf005/Cataclysm-BN that referenced this pull request Dec 2, 2023
@scarf005 scarf005 removed the balance label Dec 14, 2023
@scarf005 scarf005 force-pushed the perf-more-stackables branch from bac3526 to a0e8f2b Compare December 14, 2023 13:04
scarf005 added a commit to scarf005/Cataclysm-BN that referenced this pull request Dec 14, 2023
@chaosvolt
Copy link
Member

Side note: just in case, test if having rags be stackable affects them being usable for raw materials, both for sewing repairs and for modifying with clothing_mods (now that we have a vanilla clothing mod that uses rags). I recall in the past running in an issue where I tried to use a stacking item as the material for a tailor's kit mod (was either bones or rocks) and it always said it didn't have any available.

@scarf005
Copy link
Member Author

scarf005 commented Dec 25, 2023

found the curprit, it was glass_sheet.
for buffing rags, i guess followup PR could work.

@scarf005 scarf005 requested a review from chaosvolt December 25, 2023 04:07
@scarf005
Copy link
Member Author

scarf005 commented Dec 25, 2023

image

ah hecc, count by charges don't work with sewing kit
i'll make them check by their charges

@chaosvolt
Copy link
Member

RIP. Did it only affect using them as reagents to add clothing_mods or did it also affect using them for item repair?

@scarf005
Copy link
Member Author

Cataclysm-BN/src/visitable.cpp

Lines 1109 to 1115 in 7143dfd

template <typename T>
int visitable<T>::amount_of( const itype_id &what, bool pseudo, int limit,
const std::function<bool( const item & )> &filter ) const
{
return amount_of_internal( *this, what, pseudo, limit, filter );
}

haven't tested but probably both as visitable<T>::amount_of doesn't seem to take charges into account

@scarf005 scarf005 force-pushed the perf-more-stackables branch from 1b9a92b to 2365747 Compare December 25, 2023 04:28
@github-actions github-actions bot added the src changes related to source code. label Dec 25, 2023
@scarf005 scarf005 changed the title perf(balance): make more items stackable perf: make more items stackable Dec 25, 2023
Copy link
Member

@chaosvolt chaosvolt left a comment

Choose a reason for hiding this comment

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

  1. Compiled and load-tested.

  2. Took down some curtains and disassembled the sheet, got 20 rags as expected.

  3. Cut up the other rags, message is a lil weird (see below) but yield was as expected, and amount spawned matches what it said spawned.

  4. Uncrafted the long string into short strings then thread, correctly got 300 thread out of it.

  5. Repeated on another curtain and hauled the two piles of items together, items stack up correctly.

  6. Made a french maid dress, it correctly used the 30 rags it said it should.

  7. Reinforced some items, it consumes rags as expected.

  8. Checked via yeeting remaining rags away that a sheet says it takes 2 rags per repair operation, destroyed another sheet and confirmed it takes the stated number of rags when sewing.

  9. Enlarge-ified my shirt, it correctly consumed 2 rags.

  10. Constructed and deconstructed a wire fence, it correctly takes 2, and yields 2 wires.

  11. Bolt-cut the wire fence too, yields 2 wires as expected.
    image

  12. And the bad bit: Bloodied myself up and used a rag, it generates a blood-stained rag but doesn't consume the rag.
    image

The "wash hard items" action seems to work as expected tho.

Copy link
Member

@chaosvolt chaosvolt left a comment

Choose a reason for hiding this comment

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

Bonus WTF: splintered woods seem to not work right for fuel in a firewood source.
image
Except sometimes they do? what in the goddamn
image

@scarf005
Copy link
Member Author

scarf005 commented Dec 25, 2023

image

Bonus WTF: splintered woods seem to not work right for fuel in a firewood source.

strange, i cannot reproduce this one. spawned brazier, 1000 splintered wood on a firewood zone, was able to keep the fire going until all woods were exhausted.

@scarf005 scarf005 requested a review from chaosvolt December 25, 2023 06:30
@chaosvolt
Copy link
Member

chaosvolt commented Dec 25, 2023

Tested it again and I still don't understand the firewood source behavior. What I did, in order:

  1. Created new world.
  2. Took down a curtain.
  3. Used the stick to smash a bunch of benches and some lockers.
  4. Made a brazier, piled all the wood in a spot next to it.
  5. Defined a firewood source from the construction menu, on the pile I made.
  6. Examined the brazier and lit a fire, it immediately worked first time.
  7. Moved the planks off the pile, removed the firewood source, and re-added it again to the pile that now has just splintered woods on a freshly-constructed firewood source.

I have a save from right after this moment of it having not worked:
Offerman.zip

After I saved I try the brazier, it works. I quit without saving, load save, try again and this time it doesn't work. So whatever the hell this is, it's literally random if it works or not. I figured maybe it was a wind effect because my earlier test was outside and it was just being a shit and not printing a message about wind causing fires to not work or something, but this save's test is purely indoors.

Loading that save and having it work the turn after loading:
image

Loading that save and having it NOT work the turn after loading:
image

@scarf005
Copy link
Member Author

Cataclysm-BN/src/item.cpp

Lines 8300 to 8305 in 7143dfd

int stack_burnt = rng( type->stack_size / 2, type->stack_size );
time_added *= stack_burnt;
smoke_added *= stack_burnt;
burn_added *= stack_burnt;
}

I'm suspecting that this line is making random failure.

@scarf005
Copy link
Member Author

now it should work.

@scarf005 scarf005 force-pushed the perf-more-stackables branch from eb9cf15 to b8b408d Compare December 25, 2023 08:35
Copy link
Member

@chaosvolt chaosvolt left a comment

Choose a reason for hiding this comment

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

Yep, that seems to have done it. :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSON related to game datas in JSON format. scripts related to game management scripts src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

☂️ make rags lag less
4 participants