Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upFix another part of the rotting code (the code about rotting). #9353
Conversation
BevapDin
added some commits
Oct 1, 2014
This comment has been minimized.
This comment has been minimized.
|
I just filed PR #9352 that will recolor rotten items. I will see if I can pull your changes for testing along side of my changes to see that my code still works as intended. Edit: Verified to work perfectly fine alongside your changes - even better, in fact. I don't have to try and eat stuff to figure out it is rotten now. |
BevapDin
referenced this pull request
Oct 1, 2014
Merged
[WIP] Made items that are rotten show up in brown #9352
tivec
added a commit
to tivec/Cataclysm-DDA
that referenced
this pull request
Oct 1, 2014
This comment has been minimized.
This comment has been minimized.
|
Sorry for the confusion. I checked the save again and you are right, meat in top stack is already rotten. I must ate meat from wrong stack :( Thanks for fixing it. This bug is super annoying. |
KA101
added
the
(S2 - Confirmed)
label
Oct 1, 2014
This comment has been minimized.
This comment has been minimized.
|
I bet it also fixes #9297. |
KA101
self-assigned this
Oct 2, 2014
KA101
reviewed
Oct 2, 2014
| * The turn when this item has been put into a fridge. | ||
| * 0 if this item is not in a fridge. | ||
| */ | ||
| int fridge; |
This comment has been minimized.
This comment has been minimized.
KA101
reviewed
Oct 2, 2014
| // Rotting found *must* be active to trigger the rotting process, | ||
| // if it's already rotten, no need to do this. | ||
| active = true; | ||
| } |
This comment has been minimized.
This comment has been minimized.
KA101
Oct 2, 2014
Contributor
Was gonna ask if we needed a save handler for this. Looks like you've got it sorted.
BevapDin commentedOct 1, 2014
The save from #6414 (comment) contains that case. The first meat chunk in the fridge is actually rotten (try to eat it and you will see), but that is not displayed.
Found the failure: the meat chunks are rotten. The commits 946f873, 4468053 and 456da78 worked together in a very unfortunate way.
The first one makes food items active so they are processed to simulate the rot. The third commit stored the "is rotten" property in a separate member of the item class. That members was not stored in the save files! But the code that displays the "(rotten)" tag uses that member.
What happened is this: the meat starts as active, is processed (
item::calc_rotis called each turn), until it is rotten.calc_rotsetsitem::is_rottento true and makes the item inactive (4468053). Everything is fine now (rotten tag is displayed properly), until the game is saved and reloaded.The
is_rottenmember is not stored nor loaded, so it reverts to the default valuefalse, the item is not active either (that property is stored and was loaded, but was set to false incalc_rot). In the end, the item is rotten (item::rot * 600is bigger thanit_comest::spoils), but the tag was not displayed and the player though it is not rotten.There is an explicit call to
calc_rotinplayer::eatwhich would recalculate the rotting (increasesitem::rot, but that does not matter), it setsitem::is_rottento true again (because the comparison with the item type member says that the item should be rotten) and the following code ask the player to really eat the rotten item.Fixed all of this by moving the rotting related stuff into the item class, and making all loaded items that rot but are not yet rotten active again.
I also converted
it_comest::spoilsto be in turns (not hours) and be a signed int. It is compared to a signed int (the rot) anyway, and it is converted to turns all the time, so why not put that into the loading code.