-
Notifications
You must be signed in to change notification settings - Fork 276
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
Port over salvage-by-weight from DDA #2142
Conversation
Co-Authored-By: Kevin Granade <860276+kevingranade@users.noreply.github.com>
Automated testing will be needed here for sure. I won't merge it without it, manual testing just doesn't cut it. |
Hmm, I'll try to look athow to port over the rest stuff. |
Committed the current work to port over the test for now, still having trouble sorting it out plus been distracted with offline stuff a lot lately. |
tests/iuse_actor_test.cpp
Outdated
const std::vector<material_id> &target_materials = cut_up_target.made_of(); | ||
units::mass smallest_yield_mass = units::mass_max; | ||
for( const material_id &mater : target_materials ) { | ||
if( const cata::optional<itype_id> item_id = mater->salvaged_into() ) { |
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.
Error: iuse_actor_test.cpp:83:59: error: member access into incomplete type 'const material_type'
if( const cata::optional<itype_id> item_id = mater->salvaged_into() ) {
^
../src/type_id.h:91:7: note: forward declaration of 'material_type'
class material_type;
^
Compiler needs to know full definition (internal layout) of the class to allow accessing its members and methods. Here, the compiler only has access to declaration (it knows it's a class and how it's called, and nothing else), hence it complains about incomplete type
.
You can fix it by finding which header has the definition (in Visual Studio and VSCode, go to that declaration and right-click -> "Go to definition") and then including that header at the top of iuse_actor_test.cpp
.
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.
Ah, thanks. I'll try to check this when I get home.
Okay, so now the test seems to work, I just gotta figure out what the implications are for it failing. I still don't even fully 100% understand what Kevin's test is expecting to actually determine.
This tells me it wants the smallest possible yield to be...anything BUT the maximum mass? Not
EDIT 2: Cause might be due to kevlar harnesses being a migrated item actually? Lemme look into this further. |
There we go, fixed the use of migrated dog armors. Also fixed the weird redundant use of two separate kevlar harnesses, I assume Kevin meant one of those to be the kevlar vest. This leaves what seems to be some signs of test failures indicating that some small items can salvage into more material than they have. |
Quickest fix would be to round their weights up to material weight. |
Ah, guess I can work on that. That said, I'm not even 100% sure what the item is testing for. It looks like the ones that're failing are for items that weigh less than the weight of a single patch item. What is even the intended behavior in that instance? If it's just meant to fail to yield a patch, I assume most items that weigh less than a patch should probably be shifted to using |
|
Ah, nice. I'll fix that in a bit then. |
Looks mostly good, but we'll still need a test case that goes over ALL items and checks if they are one of:
You can get all item types with |
I'll have to see if I can implement that when I get back home, hopefully works out. |
Didn't get the chance to work on it much yet, but did get to look into it a bit. The melee balance test seems to include a good example of grabbing all items using this method: https://github.com/cataclysmbnteam/Cataclysm-BN/blob/upload/tests/melee_balance_test.cpp#L24 Next step I assume would be only calling I assume then that the actual test would basically entail taking the current test from the source PR, and instead feeding it all the items that've been called up, checking that in all cases salvaged mass doesn't exceed the target item's mass. |
So I'd looked into it recently and main issue I found is that |
FFFF I accidentally wrecked your branch when pushing a tiny update (the "check all items" thing), I'll fix it. |
5fb7b88
to
4e4ad53
Compare
Alright, fixed. I implemented the whole "go over all items, check if they can be cut up properly or not at all" thing. Now it complains for some items. |
Oh nice, thank you. I'll check in a sec to see what items it complains about then tweak them, then. EDIT: Nice, the buildbot isn't showing them because it's only focused on complaining about the scenario whitelist in DSA, so guess I'll try to remember how to test manually again. EDIT: And having trouble getting any test results showing as failed for me to tell what items need updating. |
The "check all" test is disabled by default, you have to run the test executable and supply it with the test name, e.g. for VS build it's like this:
|
Co-authored-by: Olanti <olanti-p@yandex.ru>
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.
build worked, tests passed, gameplay worked. LGTM
Co-Authored-By: Kevin Granade 860276+kevingranade@users.noreply.github.com
Summary
SUMMARY: Bugfixes "Port over DDA PR changing salvaging to go by weight instead of volume"
Purpose of change
It was pointed out that salvaging items is still wacky because it goes by volume, and there's a DDA PR that changes it to by-weight that we could port over.
Describe the solution
minimal_volume_to_cut
in withvisit_salvage_products
andminimal_weight_to_cut
, updatingsalvage_actor::time_to_cut_up
with the added weight stuff, the change tosalvage_actor::valid_to_cut_up
, and the updates tosalvage_actor::try_to_cut_up
andsalvage_actor::cut_up
that actually gets yield from weight.NO_SALVAGE
to wetsuit gloves and burette per suggestion.Describe alternatives you've considered
Screaming.
Testing
So now things tend to lean closer to what they're supposed to be, just needing weight adjustments of problematic items in a follow-up PR, though it still performs poorly for multi-material items.
Additional context
Source PR, "Proportional part salvaging" by @kevingranade: CleverRaven/Cataclysm-DDA#45779
Stuff not ported over:
errors.txt
I tested in DDA build 2022-10-27-0335 and found that blankets still have the same weight as the ones in BN, they return 198 cotton patches (or 24.75 patchwork cotton sheets), and require 33 cotton sheets to craft, for an effective yield of 75% (not counting lost thread). This is better than the yield from the above test (14/35, or 40%), but still a sign that we should keep special-case uncrafts until the weight gives results actually closer to what you'd rationally expect of them.