FS#519 - Bridge building results in 'missing' pieces

Attached to Project: OpenTTD
Opened by Darkvater (Darkvater) - Saturday, 06 January 2007, 14:26 GMT
Last edited by Darkvater (Darkvater) - Saturday, 06 January 2007, 14:36 GMT
Type Bug
Category Core
Status Closed
Assigned To No-one
Operating System All
Severity High
Priority High
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


We have another problem with the town ratings. Its change is not atomic.
Basically a dry run of building a bridge succeeds because town penalty ratings are not accumulated.

When a bridge is actually built (see attached savegame) the penalty for removing the tree is deducted but the town will not allow removing its road, thus the command fails for the execution run (res != res2). Without assertions you will get the following picture, and broken savegame.

A solution would be to somehow get the town penalties from the deep underlying function and check that in the dry run as well...any clever ideas?

Thankfully to reproduce this bug you need very specific circumstances that won't happen too often, but this should be fixed. The only problem is how to return back the town penalties from a tile-independent CMD_LANDSCAPE_CLEAR and deal with the possible multiple town authorities the tiles along the way might belong to.
This task depends upon

Closed by  Remko Bijker (Rubidium)
Thursday, 31 May 2007, 20:59 GMT
Reason for closing:  Fixed
Additional comments about closing:  Already fixed in trunk.
Comment by Darkvater (Darkvater) - Saturday, 06 January 2007, 22:49 GMT
I would have an idea for solvage that could include something similar to the SET_EXPENSES_MACRO but with a function for town ratings. The only problem is it wouldn't check ratings for the multiple towns the bridge might pass through...

It would be something like:
do commands
modification = GetTownRatingModificationCount();

if (t->ratings[player] - modification < 0) cmd_error;
Comment by Darkvater (Darkvater) - Monday, 08 January 2007, 01:04 GMT
Bug does not happen in trunk/ after bridge-merge because even half-road pieces are not removed. Only other thing that could be removed are trees, but those are not checked for permission by town-authority.

So this bug might be obsolete. Still it would be nice to have some access to the town-rating affect numbers as then the CMD_AUTO hacks can be removed.