The International Simutrans Forum

Simutrans Extended => Simutrans-Extended bug reports => Simutrans-Extended development => Simutrans-Extended closed bug reports => Topic started by: Tortain on April 13, 2018, 05:25:21 PM

Title: Bug: Incorrect operating profit at the end of the month.
Post by: Tortain on April 13, 2018, 05:25:21 PM
Save file:
https://www120.zippyshare.com/v/dxc4zs8n/file.html
(https://www120.zippyshare.com/v/dxc4zs8n/file.html)

(https://i.imgur.com/xYnq93A.png)

(https://i.imgur.com/mUDNnbR.png)


Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: ACarlotti on April 13, 2018, 10:57:29 PM
Vehicle maintenance is charged at the end of the month, but does not appear on the list of financial data (except as an unspecified part of operating profit). This is the real bug.

(P.S. I was only able to work this out by reading the relevant code and then inspecting the program with a debugger. The functionality is far from obvious.)
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: Tortain on April 13, 2018, 11:42:08 PM
After some testing i saw that only horses, post boy and post bicycle (biological vehicles) have both maintenance per km and per month.
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: jamespetts on April 13, 2018, 11:42:32 PM
I think that this behaves the same way in Standard - can anyone who knows the Standard codebase better than I confirm?
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: Tortain on April 13, 2018, 11:48:34 PM
Is posible to change biological vehicles cost per month to 0 like in others vehicles?
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: jamespetts on April 13, 2018, 11:53:13 PM
Quote from: Tortain on April 13, 2018, 11:48:34 PM
Is posible to change biological vehicles cost per month to 0 like in others vehicles?

It is possible to create vehicles with any cost, although removing the fixed cost will affect the balance.
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: ACarlotti on April 13, 2018, 11:57:07 PM
Quote from: Tortain on April 13, 2018, 11:48:34 PM
Is posible to change biological vehicles cost per month to 0 like in others vehicles?

Better to add monthy vehicle maintenance to the finance window, either separately, or merged into a renamed infrastructure maintenance or vehicle running costs.

From Standard:
ATV_VEHICLE_MAINTENANCE,        ///< Monthly vehicle maintenance. Unused.
Assuming the comment isn't a lie, then this isn't currently an issue in Standard. However, if our fix doesn't add any new rows to the table then it's probably worth adding to Standard as well, in case they start using monthly vehicle maintenance.
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: jamespetts on April 14, 2018, 01:56:22 PM
I have now added a graph in the finances window showing the monthly vehicle maintenance cost as separate to the per km cost, which should make this clearer.
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: Tortain on April 15, 2018, 04:08:11 PM
Is possible to have vehicles maintanence at begining of the month, and added to fixed month costs?
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: jamespetts on April 15, 2018, 04:32:40 PM
Quote from: Tortain on April 15, 2018, 04:08:11 PM
Is possible to have vehicles maintanence at begining of the month, and added to fixed month costs?

With enough work, most things are possible - but may I ask why you think that this would be worthwhile?
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: Tortain on April 15, 2018, 05:35:04 PM
Some vehicle maintenance per month is shown at begining of the month, rest is added at the end.
When someone in the middle of a month want to check operating profit, graph do not show real operating profit. Is needed to manually calculate the likely profit looking at the maintenance from the previous month.


(https://i.imgur.com/tedFHB9.png)
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: jamespetts on April 15, 2018, 08:58:15 PM
Quote from: Tortain on April 15, 2018, 05:35:04 PM
Some vehicle maintenance per month is shown at begining of the month, rest is added at the end.
(https://i.imgur.com/tedFHB9.png)

Are you sure that this is right? This does not seem correct. Can you upload a saved game in which this issue can reliably be reproduced?
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: Tortain on April 15, 2018, 11:19:19 PM
After some years I sold some horses and now maintenece per km is only added at the end of the month.

But on my picture you can find another bug.
Look at account balance. :P
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: ACarlotti on April 16, 2018, 03:12:26 AM
James: If I'm understanding finance.cc correctly, then all the changes you made there are modifying the definition of the old save format, used for compatibility for loading/saving old versions. Since you can't just redefine the legacy format, those changes should be reverted (as I have pushed).

I looked at the code for the finance gui, and I think I managed to fix the problems in the below image. I also think the way it is currently written is messy and difficult to maintain, although I will not attempt to refactor any of it now.

Fixes pushed to Github.
Title: Re: Bug: Incorrect operating profit at the end of the month.
Post by: jamespetts on April 16, 2018, 10:26:28 PM
Excellent - thank you for the fixes: now incorporated.