OpenTTD

Tasklist

FS#5297 - Returning negative values from the refit_cost callback

Attached to Project: OpenTTD
Opened by Supercheese (Supercheese) - Thursday, 13 September 2012, 23:33 GMT
Last edited by Jose Soler (Terkhen) - Saturday, 22 September 2012, 16:21 GMT
Type Bug
Category Interface
Status Closed
Assigned To No-one
Operating System Windows
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

When returning negative values from the refit_cost callback in OTTD (tested with r24517), the functionality is as intended - namely, the player is refunded money. However, the refit window displays: "Cost of refit: {RED}-$XX,XXX", as shown in the attached screenshot. That seems rather silly IMO, and should probably be changed to {GREEN} text along with some indication of a refund.

For a .grf that exhibits this behavior, see the Fake Subways .grf: http://www.tt-forums.net/viewtopic.php?f=26&t=62672
(That .grf is attached to this report.)

The source and compilation instructions are attached to the second post of that thread, but I've also attached the resultant .nml file to this report, for quick viewing of the code. You'll of course need the remaining sources from the thread to compile the functional .grf. (Search for "refit_cost_switch" to quickly arrive at the relevant switch block.)


Anyway, steps to reproduce:

1) Load Fake Subways .grf in a new game
2) Build road depot
3) Purchase a subway
4) Refit to more carriages
5) Refit again down to fewer carriages

That's about it.

This task depends upon

Closed by  Jose Soler (Terkhen)
Saturday, 22 September 2012, 16:21 GMT
Reason for closing:  Fixed
Additional comments about closing:  In r24544, with option 4).
Comment by Supercheese (Supercheese) - Thursday, 13 September 2012, 23:34 GMT
Forgot .grf, here it is.
Comment by Jose Soler (Terkhen) - Friday, 21 September 2012, 14:26 GMT
Thanks for the report.

I'm sorry for the lateness in my answer. Last weekend I had a working patch to solve this issue, but I did not commit it because I was concerned with a not so trivial detail: aesthetics. I am not sure about which colour scheme would be better for this. The options I'm currently considering are:

1) Gold for refit cost, gold for refit income
2) Red for refit cost, gold for refit income
3) Gold for refit cost, green for refit income
4) Red for refit cost, green for refit income

Option 2) feels more readable for me, therefore I'm somewhat inclined to use it.

I'm attaching two screenshots that show option 1) and option 4) for comparison.
Comment by Supercheese (Supercheese) - Friday, 21 September 2012, 22:14 GMT
Well, immediately after the user selects a refit and confirms that selection, either a Red "Cost" or a Green "Income" will appear above the depot. If one wishes to be maximally consistent with this, the refit costs should be displayed in red and green as well (and gold for zero cost, I suppose). I personally lean towards this, but I am quite open to other arguments.


As a side note, you seem to have found a bug in the .grf related to rounding errors with negative numbers. Interesting how a silly thing such as a negative sign inside or outside the parentheses can result in rounding errors!

Loading...