-
Notifications
You must be signed in to change notification settings - Fork 471
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
[buildingplan] only consider building materials that can be accessed by citizens/residents #4897
Conversation
…by citizens/residents
|
||
// ensure that we update at most once per tick | ||
auto frame_counter = df::global::world->frame_counter; | ||
if (frame_counter == update_timestamp) |
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.
this will give incorrect results if a world is loaded, exited, and then a different world is loaded (since frame_counter
is reset to 0 on world load). It would be safer if the update_timestamp
were declared outside of this function, referenced as an extern
in buildingplan.h
(or buildingplan.cpp
) and reset in plugin_load_site_data
(where cycle_timestamp
is reset)
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.
You mean when you load a world, never unpause (or at least not long enough to reach a cycle), and then load a different world, you have one tick where there is stale data? Nice catch, I certainly didn't test that.
I noticed that |
I believe the rate limiting is coming from here: function ItemLine:reset()
self.desc = nil
self.available = nil
end
...
function ItemLine:get_item_line_text()
local idx = self.idx
local filter = get_cur_filters()[idx]
local quantity = get_quantity(filter, self.is_hollow_fn())
local buildingplan = require('plugins.buildingplan')
self.desc = self.desc or buildingplan.get_desc(filter)
self.available = self.available or buildingplan.countAvailableItems(
uibs.building_type, uibs.building_subtype, uibs.custom_type, idx - 1)
if self.available >= quantity then
self.note_pen = COLOR_GREEN
self.note = (' %d available now'):format(self.available)
elseif self.available >= 0 then
self.note_pen = COLOR_BROWN
self.note = (' Will link next (need to make %d)'):format(quantity - self.available)
else
self.note_pen = COLOR_BROWN
self.note = (' Will link later (need to make %d)'):format(-self.available + quantity)
end
self.note = string.char(192) .. self.note -- character 192 is "└"
return ('%d %s%s'):format(quantity, self.desc, quantity == 1 and '' or 's')
end so |
No description provided.