FS#504 - Crash at building airports in Toyland in Multiplayer game

Attached to Project: OpenTTD
Opened by Leif Linse (Zuu) - Tuesday, 02 January 2007, 21:33 GMT
Type Bug
Category Core
Status Closed
Assigned To No-one
Operating System All
Severity High
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


== OTTD Version ==
0.5 RC2, compiled from source on 32bit Debian Linux

== How to reproduce? ==
* Open attached savegame (a multiplayer-game)
* Build any airport except helicopter airports.
=> Crash with the folowing output in the shell:
openttd: station_cmd.c:3187: StationRect_BeforeAddTile: Assertion `mode != RECT_MODE_TRY' failed.

I've tried to start a new singleplayer and then the game does not crash.
I've loaded the provided savegame in singelplayer and tried => resulting in crashes.

== The Game ==
512x512 map of Toyland.

== What to do? ==
See if this is just this multiplayer-game or if this bug hapens for any multiplayer game in Toyland.
This task depends upon

Closed by  KUDr (KUDr)
Wednesday, 03 January 2007, 23:16 GMT
Reason for closing:  Fixed
Additional comments about closing:  r7810 /trunk/src/station_cmd.c: -Fix:  FS#504  Building airport whose size exceeds max station spread-out caused assert. (Zuu)
Comment by Leif Linse (Zuu) - Tuesday, 02 January 2007, 23:37 GMT
The openttd.cfg comes here.
Comment by Leif Linse (Zuu) - Wednesday, 03 January 2007, 01:23 GMT
[skip down to end of post, I found the true orgin of the bug]

Sorry for not beeing clear. The .cfg-file is for the server, not my client.


I've tried to host a game with that cfg (except for server ID, player name, server name, client ID).
Building Small airport works, but when I build a comuters airport, the server crashes this time (earlier when I found the bug it was my client that crashed). The client gets disconnected as the server crashes. The output from the server is:
openttd: station_cmd.c:3187: StationRect_BeforeAddTile: Assertion `mode != RECT_MODE_TRY' failed.

Exit code is 134, if that helps.

I've also tried with a windows-version of OTTD as client and it also crashes the server. (with the same assertion).
And lastly I've tried with windows as server with above attached .cfg and a Linux client. That resulted on a crash on the Linux Client.

== Summary ==
Crash ocours on Linux Client or Server, if both are Linux it oucours on the Server. If both are Windows nothing happens.

== Found the true orgin of bug! ==
When station_spread is set to < size of airport OpenTTD crashes on Linux. Why it does not on Windows I don't know. Maybe because the assert have been disabled in the windows build?

Yay! :)
Comment by Leif Linse (Zuu) - Wednesday, 03 January 2007, 02:24 GMT
== Soulution ==
I've studied the code and I have found out why this bug ocours and I have a soulution. However, since it is over 3 AM, here, I'll post a patch later.

Comment by Leif Linse (Zuu) - Wednesday, 03 January 2007, 11:54 GMT
== Patch ==
This patch fixes the "crashes". When one is placing airpots as new station, it does not make sure that it is smaller than station_spread. This is the simple way. The other way would be to reject airports larger than station_spread. But that would need changes in the gui, perhaps dissable airports in the build menu larger than station_spread.