Skip to content

Commit 01e364b

Browse files
authored
[GEN][ZH] Implement new user data ini files for multi instance clients (#905)
1 parent 23da9ba commit 01e364b

File tree

16 files changed

+188
-22
lines changed

16 files changed

+188
-22
lines changed

Generals/Code/GameEngine/Include/Common/SkirmishBattleHonors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class SkirmishBattleHonors : public UserPreferences
5252
SkirmishBattleHonors();
5353
virtual ~SkirmishBattleHonors();
5454

55+
Bool loadFromIniFile();
56+
5557
void setWins(Int val);
5658
Int getWins(void) const;
5759

Generals/Code/GameEngine/Include/Common/SkirmishPreferences.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class SkirmishPreferences : public UserPreferences
4646
public:
4747
SkirmishPreferences();
4848
virtual ~SkirmishPreferences();
49+
50+
Bool loadFromIniFile();
51+
4952
virtual Bool write(void);
5053
AsciiString getSlotList(void);
5154
void setSlotList(void);

Generals/Code/GameEngine/Include/Common/UserPreferences.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class UserPreferences : public PreferenceMap
5353
UserPreferences();
5454
virtual ~UserPreferences();
5555

56+
// Loads or creates a file with the given name in the user data directory.
5657
virtual Bool load(AsciiString fname);
5758
virtual Bool write(void);
5859

@@ -78,6 +79,9 @@ class OptionPreferences : public UserPreferences
7879
public:
7980
OptionPreferences( );
8081
virtual ~OptionPreferences();
82+
83+
Bool loadFromIniFile();
84+
8185
UnsignedInt getLANIPAddress(void); // convenience function
8286
UnsignedInt getOnlineIPAddress(void); // convenience function
8387
void setLANIPAddress(AsciiString IP); // convenience function
@@ -130,6 +134,9 @@ class LANPreferences : public UserPreferences
130134
public:
131135
LANPreferences();
132136
virtual ~LANPreferences();
137+
138+
Bool loadFromIniFile();
139+
133140
UnicodeString getUserName(void); // convenience function
134141
Int getPreferredFaction(void); // convenience function
135142
Int getPreferredColor(void); // convenience function

Generals/Code/GameEngine/Source/Common/SkirmishBattleHonors.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "Common/PlayerTemplate.h"
4343
#include "Common/QuotedPrintable.h"
4444
#include "Common/MultiplayerSettings.h"
45+
#include "GameClient/ClientInstance.h"
4546
#include "GameClient/MapUtil.h"
4647

4748
//-----------------------------------------------------------------------------
@@ -79,13 +80,25 @@
7980

8081
SkirmishBattleHonors::SkirmishBattleHonors()
8182
{
82-
load("SkirmishStats.ini");
83+
loadFromIniFile();
8384
}
8485

8586
SkirmishBattleHonors::~SkirmishBattleHonors()
8687
{
8788
}
8889

90+
Bool SkirmishBattleHonors::loadFromIniFile()
91+
{
92+
if (rts::ClientInstance::getInstanceId() > 1u)
93+
{
94+
AsciiString fname;
95+
fname.format("SkirmishStats_Instance%.2u.ini", rts::ClientInstance::getInstanceId());
96+
return load(fname);
97+
}
98+
99+
return load("SkirmishStats.ini");
100+
}
101+
89102
void SkirmishBattleHonors::setWins(Int val)
90103
{
91104
setInt("Wins", val);

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "Common/QuotedPrintable.h"
4343
#include "Common/UserPreferences.h"
4444
#include "GameClient/AnimateWindowManager.h"
45+
#include "GameClient/ClientInstance.h"
4546
#include "GameClient/GameText.h"
4647
#include "GameClient/MapUtil.h"
4748
#include "GameClient/Mouse.h"
@@ -73,14 +74,25 @@ static Bool justEntered = FALSE;
7374

7475
LANPreferences::LANPreferences( void )
7576
{
76-
// note, the superclass will put this in the right dir automatically, this is just a leaf name
77-
load("Network.ini");
77+
loadFromIniFile();
7878
}
7979

8080
LANPreferences::~LANPreferences()
8181
{
8282
}
8383

84+
Bool LANPreferences::loadFromIniFile()
85+
{
86+
if (rts::ClientInstance::getInstanceId() > 1u)
87+
{
88+
AsciiString fname;
89+
fname.format("Network_Instance%.2u.ini", rts::ClientInstance::getInstanceId());
90+
return load(fname);
91+
}
92+
93+
return load("Network.ini");
94+
}
95+
8496
UnicodeString LANPreferences::getUserName(void)
8597
{
8698
UnicodeString ret;

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "Common/Registry.h"
4242
#include "Common/version.h"
4343

44+
#include "GameClient/ClientInstance.h"
4445
#include "GameClient/GameClient.h"
4546
#include "GameClient/InGameUI.h"
4647
#include "GameClient/WindowLayout.h"
@@ -223,14 +224,24 @@ enum Detail CPP_11(: Int)
223224

224225
OptionPreferences::OptionPreferences( void )
225226
{
226-
// note, the superclass will put this in the right dir automatically, this is just a leaf name
227-
load("Options.ini");
227+
loadFromIniFile();
228228
}
229229

230230
OptionPreferences::~OptionPreferences()
231231
{
232232
}
233233

234+
Bool OptionPreferences::loadFromIniFile()
235+
{
236+
if (rts::ClientInstance::getInstanceId() > 1u)
237+
{
238+
AsciiString fname;
239+
fname.format("Options_Instance%.2u.ini", rts::ClientInstance::getInstanceId());
240+
return load(fname);
241+
}
242+
243+
return load("Options.ini");
244+
}
234245

235246
Int OptionPreferences::getCampaignDifficulty(void)
236247
{

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "Common/SkirmishPreferences.h"
4242
#include "GameLogic/GameLogic.h"
4343
#include "GameClient/AnimateWindowManager.h"
44+
#include "GameClient/ClientInstance.h"
4445
#include "GameClient/WindowLayout.h"
4546
#include "GameClient/Gadget.h"
4647
#include "GameClient/Shell.h"
@@ -172,14 +173,25 @@ static Int getNextSelectablePlayer(Int start)
172173

173174
SkirmishPreferences::SkirmishPreferences( void )
174175
{
175-
// note, the superclass will put this in the right dir automatically, this is just a leaf name
176-
load("Skirmish.ini");
176+
loadFromIniFile();
177177
}
178178

179179
SkirmishPreferences::~SkirmishPreferences()
180180
{
181181
}
182182

183+
Bool SkirmishPreferences::loadFromIniFile()
184+
{
185+
if (rts::ClientInstance::getInstanceId() > 1u)
186+
{
187+
AsciiString fname;
188+
fname.format("Skirmish_Instance%.2u.ini", rts::ClientInstance::getInstanceId());
189+
return load(fname);
190+
}
191+
192+
return load("Skirmish.ini");
193+
}
194+
183195
AsciiString SkirmishPreferences::getSlotList(void)
184196
{
185197
return getAsciiString("SlotList", AsciiString::TheEmptyString);

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "Common/Registry.h"
4242
#include "Common/UserPreferences.h"
4343
#include "GameClient/AnimateWindowManager.h"
44+
#include "GameClient/ClientInstance.h"
4445
#include "GameClient/WindowLayout.h"
4546
#include "GameClient/Gadget.h"
4647
#include "GameClient/GameText.h"
@@ -91,8 +92,10 @@ static UnsignedInt loginAttemptTime = 0;
9192
class GameSpyLoginPreferences : public UserPreferences
9293
{
9394
public:
94-
GameSpyLoginPreferences() { m_emailPasswordMap.clear(); m_emailNickMap.clear(); }
95-
virtual ~GameSpyLoginPreferences() { m_emailPasswordMap.clear(); m_emailNickMap.clear(); }
95+
GameSpyLoginPreferences();
96+
virtual ~GameSpyLoginPreferences();
97+
98+
Bool loadFromIniFile();
9699

97100
virtual Bool load(AsciiString fname);
98101
virtual Bool write(void);
@@ -134,6 +137,28 @@ static AsciiString obfuscate( AsciiString in )
134137
return out;
135138
}
136139

140+
GameSpyLoginPreferences::GameSpyLoginPreferences()
141+
{
142+
loadFromIniFile();
143+
}
144+
145+
GameSpyLoginPreferences::~GameSpyLoginPreferences()
146+
{
147+
}
148+
149+
Bool GameSpyLoginPreferences::loadFromIniFile()
150+
{
151+
if (rts::ClientInstance::getInstanceId() > 1u)
152+
{
153+
AsciiString fname;
154+
fname.format("GameSpyLogin_Instance%.2u.ini", rts::ClientInstance::getInstanceId());
155+
return load(fname);
156+
}
157+
158+
return load("GameSpyLogin.ini");
159+
}
160+
161+
137162
Bool GameSpyLoginPreferences::load( AsciiString fname )
138163
{
139164
if (!UserPreferences::load(fname))
@@ -288,7 +313,6 @@ AsciiStringList GameSpyLoginPreferences::getEmails( void )
288313
return theList;
289314
}
290315

291-
static const char *PREF_FILENAME = "GameSpyLogin.ini";
292316
static GameSpyLoginPreferences *loginPref = NULL;
293317

294318
static void startPings( void )
@@ -433,7 +457,6 @@ void WOLLoginMenuInit( WindowLayout *layout, void *userData )
433457
if (!loginPref)
434458
{
435459
loginPref = NEW GameSpyLoginPreferences;
436-
loginPref->load(PREF_FILENAME);
437460
}
438461

439462
// if the ESRB warning is blank (other country) hide the box

GeneralsMD/Code/GameEngine/Include/Common/SkirmishBattleHonors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class SkirmishBattleHonors : public UserPreferences
5252
SkirmishBattleHonors();
5353
virtual ~SkirmishBattleHonors();
5454

55+
Bool loadFromIniFile();
56+
5557
void setWins(Int val);
5658
Int getWins(void) const;
5759

GeneralsMD/Code/GameEngine/Include/Common/SkirmishPreferences.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class SkirmishPreferences : public UserPreferences
4646
public:
4747
SkirmishPreferences();
4848
virtual ~SkirmishPreferences();
49+
50+
Bool loadFromIniFile();
51+
4952
virtual Bool write(void);
5053
AsciiString getSlotList(void);
5154
void setSlotList(void);

0 commit comments

Comments
 (0)