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

Open
SamuXarick opened this issue Jan 15, 2021 · 4 comments
Open

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

SamuXarick opened this issue Jan 15, 2021 · 4 comments
Labels
bug regression

Comments

@SamuXarick
Copy link
Contributor

@SamuXarick 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 LordAro commented Jan 15, 2021

Does it update if you move the window?

@SamuXarick
Copy link
Contributor Author

@SamuXarick SamuXarick commented Jan 15, 2021

Nope

@LordAro
Copy link
Member

@LordAro 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

@andythenorth andythenorth commented Feb 20, 2021

Introduced in 584df54

@andythenorth andythenorth added bug regression labels Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug regression
Projects
None yet
Development

No branches or pull requests

3 participants