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

Profit for each vehicle in vehicle lists aren't being updated regularly #8575

Closed
SamuXarick opened this issue Jan 15, 2021 · 5 comments
Closed
Labels
bug Something isn't working regression It used to work, and now it's broken.

Comments

@SamuXarick
Copy link
Contributor

SamuXarick commented Jan 15, 2021

Version of OpenTTD

OpenTTD 20210114-master-g4f5990fa26

Expected result

Profit this year for each vehicle in the list of vehicles should update at short intervals

Actual result

Profit this year isn't updated on its own, only when switching groups or filter criteria.

Steps to reproduce

Open list of vehicles, notice profit this year besides each vehicle.
Unnamed, 1950-04-18

@LordAro
Copy link
Member

LordAro commented Jan 15, 2021

Does it update if you move the window?

@SamuXarick
Copy link
Contributor Author

Nope

@LordAro
Copy link
Member

LordAro commented Jan 15, 2021

Yup, looks like vehicle group profit is calculated when the window is opened/initialised, rather than "live"

OpenTTD/src/vehicle_gui.cpp

Lines 1541 to 1543 in 0e62a39

SetDParam(0, vehgroup.display_profit_this_year);
SetDParam(1, vehgroup.display_profit_last_year);
DrawString(text_left, text_right, y + line_height - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM - 1, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);

OpenTTD/src/vehicle_gui.cpp

Lines 207 to 217 in 0e62a39

Money display_profit_this_year = 0;
Money display_profit_last_year = 0;
Date age = 0;
for (auto it = begin; it != end; ++it) {
const Vehicle * const v = (*it);
display_profit_this_year += v->GetDisplayProfitThisYear();
display_profit_last_year += v->GetDisplayProfitLastYear();
age = std::max<Date>(age, v->age);
}
this->vehgroups.emplace_back(begin, end, display_profit_this_year, display_profit_last_year, age);

@andythenorth
Copy link
Contributor

Introduced in 584df54

@andythenorth andythenorth added bug Something isn't working regression It used to work, and now it's broken. labels Feb 20, 2021
@2TallTyler
Copy link
Member

Closed by #8715 (but somehow not actually closed at that time).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression It used to work, and now it's broken.
Projects
None yet
Development

No branches or pull requests

4 participants