changeset 17405:2e358832cb7f draft

(svn r22154) -Fix [FS#4529]: _current_company was modified when moving a client to spectators, causing issues in bankruptcy (Rubidium)
author terkhen <terkhen@openttd.org>
date Sun, 27 Feb 2011 11:38:28 +0000
parents 9800f410f409
children 107ec08fdc9b
files src/network/network_client.cpp
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -30,6 +30,7 @@
 #include "network.h"
 #include "network_base.h"
 #include "network_client.h"
+#include "../core/backup_type.hpp"
 
 #include "table/strings.h"
 
@@ -1155,6 +1156,7 @@
 
 void NetworkClientsToSpectators(CompanyID cid)
 {
+	Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
 	/* If our company is changing owner, go to spectators */
 	if (cid == _local_company) SetLocalCompany(COMPANY_SPECTATOR);
 
@@ -1164,6 +1166,8 @@
 		NetworkTextMessage(NETWORK_ACTION_COMPANY_SPECTATOR, CC_DEFAULT, false, ci->client_name);
 		ci->client_playas = COMPANY_SPECTATOR;
 	}
+
+	cur_company.Restore();
 }
 
 void NetworkUpdateClientName()