Don't save ControlTick and SyncRate in network savegames (#1058).

issue1247
Sven Eberhardt 2014-10-03 23:12:43 +02:00
parent 15c2497311
commit 828eb7f82a
3 changed files with 17 additions and 13 deletions

View File

@ -191,7 +191,7 @@ bool C4GameSave::SaveRuntimeData()
{
// Game.txt data (general runtime data and objects)
C4ValueNumbers numbers;
if (!Game.SaveData(*pSaveGroup, false, IsExact(), &numbers))
if (!Game.SaveData(*pSaveGroup, false, IsExact(), IsSynced(), &numbers))
{ Log(LoadResStr("IDS_ERR_SAVE_RUNTIMEDATA")); return false; }
// scenario sections (exact only)
if (IsExact()) if (!SaveScenarioSections())

View File

@ -1584,8 +1584,11 @@ void C4Game::CompileFunc(StdCompiler *pComp, CompileSettings comp, C4ValueNumber
pComp->Name("Game");
pComp->Value(mkNamingAdapt(Time, "Time", 0));
pComp->Value(mkNamingAdapt(FrameCounter, "Frame", 0));
pComp->Value(mkNamingAdapt(Control.ControlTick, "ControlTick", 0));
pComp->Value(mkNamingAdapt(Control.SyncRate, "SyncRate", C4SyncCheckRate));
if (comp.fSync)
{
pComp->Value(mkNamingAdapt(Control.ControlTick, "ControlTick", 0));
pComp->Value(mkNamingAdapt(Control.SyncRate, "SyncRate", C4SyncCheckRate));
}
pComp->Value(mkNamingAdapt(iTick2, "Tick2", 0));
pComp->Value(mkNamingAdapt(iTick3, "Tick3", 0));
pComp->Value(mkNamingAdapt(iTick5, "Tick5", 0));
@ -1672,11 +1675,11 @@ void C4Game::CompileFunc(StdCompiler *pComp, CompileSettings comp, C4ValueNumber
pComp->NameEnd();
}
bool C4Game::CompileRuntimeData(C4Group &hGroup, bool fLoadSection, bool exact, C4ValueNumbers * numbers)
bool C4Game::CompileRuntimeData(C4Group &hGroup, bool fLoadSection, bool exact, bool sync, C4ValueNumbers * numbers)
{
::Objects.Clear(!fLoadSection);
GameText.Load(hGroup,C4CFN_Game);
CompileSettings Settings(fLoadSection, false, exact);
CompileSettings Settings(fLoadSection, false, exact, sync);
// C4Game is not defaulted on compilation.
// Loading of runtime data overrides only certain values.
// Doesn't compile players; those will be done later
@ -1696,13 +1699,13 @@ bool C4Game::CompileRuntimeData(C4Group &hGroup, bool fLoadSection, bool exact,
return true;
}
bool C4Game::SaveData(C4Group &hGroup, bool fSaveSection, bool fSaveExact, C4ValueNumbers * numbers)
bool C4Game::SaveData(C4Group &hGroup, bool fSaveSection, bool fSaveExact, bool fSaveSync, C4ValueNumbers * numbers)
{
if (fSaveExact)
{
StdStrBuf Buf;
// Decompile (without players for scenario sections)
DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(*this, CompileSettings(fSaveSection, !fSaveSection && fSaveExact, fSaveExact), numbers), &Buf, "Game");
DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(*this, CompileSettings(fSaveSection, !fSaveSection && fSaveExact, fSaveExact, fSaveSync), numbers), &Buf, "Game");
// Clear alternate saving method
hGroup.Delete(C4CFN_ScenarioObjectsScript);
@ -2153,7 +2156,7 @@ bool C4Game::InitGame(C4Group &hGroup, bool fLoadSection, bool fLoadSky, C4Value
if (!fLoadSection) InitValueOverloads();
// runtime data
if (!CompileRuntimeData(hGroup, fLoadSection, C4S.Head.SaveGame, numbers))
if (!CompileRuntimeData(hGroup, fLoadSection, C4S.Head.SaveGame, C4S.Head.NetworkGame, numbers))
{ LogFatal(LoadResStr("IDS_PRC_FAIL")); return false; }
SetInitProgress(93);
@ -3322,7 +3325,7 @@ bool C4Game::LoadScenarioSection(const char *szSection, DWORD dwFlags)
{
C4ValueNumbers numbers;
// objects: do not save info objects or inactive objects
if (!SaveData(*pGrp,true,false, &numbers))
if (!SaveData(*pGrp,true,false, false, &numbers))
{
DebugLog("LoadScenarioSection: Error saving objects");
return false;

View File

@ -35,9 +35,10 @@ private:
bool fScenarioSection;
bool fPlayers;
bool fExact;
bool fSync;
CompileSettings(bool fScenarioSection, bool fPlayers, bool fExact)
: fScenarioSection(fScenarioSection), fPlayers(fPlayers), fExact(fExact) { }
CompileSettings(bool fScenarioSection, bool fPlayers, bool fExact, bool fSync)
: fScenarioSection(fScenarioSection), fPlayers(fPlayers), fExact(fExact), fSync(fSync) { }
};
// struct of keyboard set and indexed control key
@ -264,9 +265,9 @@ protected:
bool PlaceInEarth(C4ID id);
public:
void CompileFunc(StdCompiler *pComp, CompileSettings comp, C4ValueNumbers *);
bool SaveData(C4Group &hGroup, bool fSaveSection, bool fSaveExact, C4ValueNumbers *);
bool SaveData(C4Group &hGroup, bool fSaveSection, bool fSaveExact, bool fSaveSync, C4ValueNumbers *);
protected:
bool CompileRuntimeData(C4Group &hGroup, bool fLoadSection, bool exact, C4ValueNumbers *);
bool CompileRuntimeData(C4Group &hGroup, bool fLoadSection, bool exact, bool sync, C4ValueNumbers *);
bool StoreParticipantPlayers();
bool RecreatePlayerFiles();