(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
authortruelight
Mon, 13 Dec 2004 18:53:59 +0000
changeset 635 5a595bc1653f
parent 634 88d9420048db
child 636 799b9e2c7eae
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
misc_gui.c
--- a/misc_gui.c	Mon Dec 13 18:51:08 2004 +0000
+++ b/misc_gui.c	Mon Dec 13 18:53:59 2004 +0000
@@ -1014,7 +1014,14 @@
 
 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);