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 upFood rot calculation since start of the apocalypse is wrong #22308
Comments
This comment has been minimized.
This comment has been minimized.
|
Well I thought about it closely. I encountered this for long time ago. Probably it just as it is supposed to work. Technical limitation. So just close issue if it is so. |
This comment has been minimized.
This comment has been minimized.
|
Was the milk spawned in mapgen or from a creature? Creatures drop fresh items. |
This comment has been minimized.
This comment has been minimized.
Definitely not from creature. It was found in house. Actually I never saw 1 gallon milk bottle spawned from creature. Also from my save you can find pancakes under my character that was found in something called Sugar House (or so). So it is definitely not milk or container only related. |
This comment has been minimized.
This comment has been minimized.
Weyrling
commented
Oct 30, 2017
|
This behavior probably comes from temperature/weather, at the beginning of Spring it's still cold. If you look into weather.cpp you'll find get_rot_since which I've pasted below for convenience. int get_rot_since( const int startturn, const int endturn, const tripoint &location ) |
This comment has been minimized.
This comment has been minimized.
|
I still wouldn't expect milk to last well into summer. |
This comment has been minimized.
This comment has been minimized.
|
valgrind does show a lot of use of uninitialized values in rot related functions. removed most of the repeated stuff. a full log here
|
This comment has been minimized.
This comment has been minimized.
|
turn on build in debug msg on will show rotting related info in item info which might help debug this. |
This comment has been minimized.
This comment has been minimized.
|
my guess is that the item is generated with bday set to the time when player first enter the map. |
This comment has been minimized.
This comment has been minimized.
|
I've got some interesting results. Some of the items have birthday on current turn while others on 0 turn - see tin of corn. Put code to function CheckItem(item, x, y, z, item_searchmask)
local item_display_name = item:display_name()
local item_weight = item.type.weight
local item_volume = item.type.volume:value()
local item_birthday = item:birthday()
local item_age = item:age()
if (string.match(item_display_name, item_searchmask) ~= nil) then
--local message_text = string.format("Item: %s [W:<color_white>%d</color>, V:<color_white>%d</color>] at [X:<color_white>%d</color>, Y:<color_white>%d</color>, Z:<color_white>%d</color>]", item_display_name, item_weight, item_volume, x, y, z)
local message_text = string.format("Item: %s [B:<color_green>%d</color>, A:<color_cyan>%d</color>] at [<color_red>%d</color>,<color_red>%d</color>,<color_red>%d</color>]", item_display_name, item_birthday, item_age, x, y, z)
game.add_msg(message_text)
print(message_text)
end
end
function CheckMapItems(item_searchmask)
local REALITY_BUBBLE_WIDTH = 24
local ScanRadius = REALITY_BUBBLE_WIDTH * 5
local center = player:pos()
for x = -ScanRadius, ScanRadius do
for y = -ScanRadius, ScanRadius do
local z = 0 --only current Z-level
local point = tripoint (center.x + x, center.y + y, center.z + z)
local distance = game.trig_dist(point.x, point.y, center.x, center.y)
if (distance <= ScanRadius) then
if map:i_at(point):size() > 0 then
local item_stack_iterator = map:i_at(point):cppbegin()
for _ = 1, map:i_at(point):size() do
CheckItem(item_stack_iterator:elem(), point.x, point.y, point.z, item_searchmask)
item_stack_iterator:inc()
end
end
end
end
end
end
CheckMapItems("fresh")
CheckMapItems("rotten")
local calendar = game.get_calendar_turn()
local calendar_turn = calendar:get_turn()
local message_text = string.format("Calendar turn: <color_yellow>%d</color>", calendar_turn)
print (message_text)
game.add_msg (message_text) |
ituluwituluwzev
added
<Bug>
Spawn
labels
Oct 31, 2017
This comment has been minimized.
This comment has been minimized.
|
Debug setting the season to autumn from spring: items are randomly fresh when spawned by mapgen. |
ZhilkinSerg
referenced this issue
May 28, 2018
Closed
Attributes are not accessible in Lua in VisualStudio builds #23258
This comment has been minimized.
This comment has been minimized.
This guessing is true. Some food indeed has non zero bday in scenarion "Next summer". |
This comment has been minimized.
This comment has been minimized.
|
Ok. How about that:
|
This comment has been minimized.
This comment has been minimized.
|
Some mapgen code uses Note that the default for new items is the current turn, but the default for items created via |
This comment has been minimized.
This comment has been minimized.
Well. I guess that is it. No surprise that smoe items spawned fresh then. |
This comment has been minimized.
This comment has been minimized.
|
That is also mean that most likely rot calculation is ok. It is wrong date for birthday itself. |
Firestorm01X2
referenced this issue
May 28, 2018
Merged
Fixed spawning fresh food instead of spoiled after passing long time #23881
This comment has been minimized.
This comment has been minimized.
|
Could someone confirm that bug have been fixed? |
nexusmrsep
added this to In progress
in Mapgen and overmapgen improvements
Sep 3, 2018
nexusmrsep
moved this from In progress
to To do
in Mapgen and overmapgen improvements
Sep 3, 2018
nexusmrsep
removed this from To do
in Mapgen and overmapgen improvements
Sep 3, 2018
This comment has been minimized.
This comment has been minimized.
|
Inactive for many months, if you run across fresh food at a late date, please open a new issue and list what the food was and where you found it. |

Firestorm01X2 commentedOct 30, 2017
•
edited
Clermont.zip
Game version:
6899
Operating system:
Win 7 X64
Tiles or curses:
Tiles
Mods active:
Default mods.
Expected behavior
Food starting to rot from beginning of the apocalypse i.e from Spring day 1. So it shouldn't be possible to find, for example non rotten milk on Summer 7.
Actual behavior
I am constantly finding food that supposed to be rotten already. For now I have non rotten milk on Summer 7 that was found in house. I even have non pershed fruits founded in houses.
Steps to reproduce the behavior
I've looked in code at item.cpp. Looks like food rot calculation should use start date of the apocalypse. There is calendar calculation. Probaly something just wrong.
I've attached save with my character on Summer 7 with bottle of milk in hands. Milk is not rotten. But it should be possible. Whole season passed. This is not attached to milk only of course. Other perishable food affected too.
But if food was generated already then it starts to perish correctly.
I suppose by design it should be generated rotten or set rotten on next check if too much time passed. But for some reason it was bugged. Or maybe discarded?