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

Fix cow milking from cows from old saves with old milk not raw milk. #37965

Merged
merged 10 commits into from Mar 2, 2020
Merged

Fix cow milking from cows from old saves with old milk not raw milk. #37965

merged 10 commits into from Mar 2, 2020

Conversation

ghost
Copy link

@ghost ghost commented Feb 12, 2020

Summary

SUMMARY: Bugfixes "Fix cow milking from cows from old saves with old milk not raw milk."

Purpose of change

Fixes #37899

Describe the solution

In the milking PR, I forgot that cows used to produce milk not raw_milk so the functions to find raw_milk in their ammo failed, producing debugmsgs.
Well theres no point crying over spilt milk, so heres a fix.

It looks for raw_milk, if that fails, it then looks for milk, and goes with that.

I coulda taken this opportunity to convert their udders to raw milk, but I guess some people prefer their old milk in their old saves, and once that cows been milked theres no point trying to squirt it back up the udders, so ill let them keep their milk.

Describe alternatives you've considered

N/A

Testing

Loaded attached save in linked issue, now no errors, and milking works nad produces milk, not raw milk

Additional context

N/A

@ghost ghost added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly. labels Feb 12, 2020
@BevapDin
Copy link
Contributor

Would be better to fix once while loading the monster. That way you only have one place to change, instead of changing three places.

It also seems the code will spawn "milk" (not "raw milk") when the old save is used (it takes the item id directly form the content of the ammo map, if that map still contains "milk", the spawned item will be milk).

@ghost
Copy link
Author

ghost commented Feb 12, 2020

Would be better to fix once while loading the monster. That way you only have one place to change, instead of changing three places.

It also seems the code will spawn "milk" (not "raw milk") when the old save is used (it takes the item id directly form the content of the ammo map, if that map still contains "milk", the spawned item will be milk).

Yep, I considered taking this opportunity to convert it to the new format of raw_milk, but thought people might not want that, but you think its preferable to convert ?

And yes Ill change to fix once when loading.

@BevapDin
Copy link
Contributor

Yep, I considered taking this opportunity to convert it to the new format of raw_milk, but thought people might not want that, but you think its preferable to convert ?

That would lead to inconsistency, which will be seen and reported as bugs:

In old saves, existing cows given "milk", but newly spawned cows give "raw milk".
With the same game version, cows in old saves given "milk", cows in new saves give "raw milk".

@ghost
Copy link
Author

ghost commented Feb 13, 2020

Theres some complications here, in the linked issues attached save, the sheep in that save must be very old, they have no starting ammo defined for their type at all, so they musta been spawned prior to 2018 when sheep milking went in.

And yet, they have the new milkable flag, but not the starting_ammo.

So I cannot give their udders milk_raw on load, when there is no starting ammo amount defined for how much to give them, only solution there I think, is just to exit early without a debugmsg, with a player message.

But I can still update old milk into milk_raw on load.

@ghost
Copy link
Author

ghost commented Feb 13, 2020

Fixed to update on load once.

src/monster.cpp Outdated Show resolved Hide resolved
src/monster.cpp Outdated Show resolved Hide resolved
@BevapDin
Copy link
Contributor

I suggest the following:

When the monsters are checked for consistency (monstergenerator::check_monster_definitions), check that milkable monsters have raw milk in their starting ammo list.

When milking a monster, check it's actually milkable (via the flag) - this is probably already done. Afterwards, if it does not have raw milk in the starting ammo list, just add it.

At this point it does not matter. It is milkable (according to the flag), so it should contain milk. Maybe add a debug message there in case it happens again and again on the same monster.

@ghost
Copy link
Author

ghost commented Feb 25, 2020

I suggest the following:

When the monsters are checked for consistency (monstergenerator::check_monster_definitions), check that milkable monsters have raw milk in their starting ammo list.

When milking a monster, check it's actually milkable (via the flag) - this is probably already done. Afterwards, if it does not have raw milk in the starting ammo list, just add it.

At this point it does not matter. It is milkable (according to the flag), so it should contain milk. Maybe add a debug message there in case it happens again and again on the same monster.

This is pretty much what ive ended up doing, added some checks to check_monster_definitions.
And just added its types ammo to its ammo when refilling udders.

Seemed silly to restrict it to milk_raw, when the JSOn allowed any item to be defined, so Ive just added a check if its a liquid item to the definition checker. and that there isnt more than one.

src/savegame_json.cpp Outdated Show resolved Hide resolved
@kevingranade kevingranade merged commit 0ccad5d into CleverRaven:master Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cows from older saves come with milk, not milk_raw, leading to errors
2 participants