summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-13 18:53:59 +0000
committertruelight <truelight@openttd.org>2004-12-13 18:53:59 +0000
commit27fe361ddf7bffdd231d220cbaa58098a64be064 (patch)
treef2f52e09dcbfea587b2a9acea1a08990d08b0ea0
parent76b76c28c399b99741d5c95e7bda2fcf4150c375 (diff)
downloadopenttd-27fe361ddf7bffdd231d220cbaa58098a64be064.tar.xz
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
-rw-r--r--misc_gui.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/misc_gui.c b/misc_gui.c
index d7aae3b20..b805749e0 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -1014,7 +1014,14 @@ static void MakeSortedSaveGameList()
static void GenerateFileName(void)
{
- const Player *p = DEREF_PLAYER(_local_player);
+ const Player *p;
+ /* Check if we are not a specatator who wants to generate a name..
+ Let's use the name of player #0 for now. */
+ if (_local_player < MAX_PLAYERS)
+ p = DEREF_PLAYER(_local_player);
+ else
+ p = DEREF_PLAYER(0);
+
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
SetDParam(2, _date);