News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

[patch] calculate Margin correctly

Started by blove, October 28, 2009, 04:49:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blove

Margin is currently calculated as:
Operational Profit / (Maintenance + Operation Costs)
It should be:
(Proceeds + Maintenance + Operation Costs) / Proceeds
or, more simply:
Operational Profit / Proceeds
The Finance window Help already says:
Margin - is the ratio of Operational Profit to Proceeds.

This is the same as Gross Profit Margin, according to Wikipedia.  If calculated, Net Profit Margin would include the cost of New Vehicles and Construction Costs as well.

Since Margin is a separate field in saved games, this patch will correctly convert an older saved game upon loading.  However, in order to do that, the correct current version must be supplied at the time the patch is applied.  It uses 0.102.3, since the patch was developed against r2830.

The patch also encapsulates the calculation into a function, since it is used multiple times.

Ben