Rename some variables to point out that they are only used in visual replay. Add script function IsVisualReplay. Refs #9 #3355, patch by elexis
This was SVN commit r17017.
This commit is contained in:
parent
7ac0a4a3db
commit
9816e7c92d
@ -181,6 +181,11 @@ std::wstring SetCursor(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::wstr
|
||||
return old;
|
||||
}
|
||||
|
||||
bool IsVisualReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
||||
{
|
||||
return g_Game ? g_Game->IsVisualReplay() : false;
|
||||
}
|
||||
|
||||
int GetPlayerID(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
||||
{
|
||||
if (g_Game)
|
||||
@ -978,6 +983,7 @@ void GuiScriptingInit(ScriptInterface& scriptInterface)
|
||||
|
||||
// Misc functions
|
||||
scriptInterface.RegisterFunction<std::wstring, std::wstring, &SetCursor>("SetCursor");
|
||||
scriptInterface.RegisterFunction<bool, &IsVisualReplay>("IsVisualReplay");
|
||||
scriptInterface.RegisterFunction<int, &GetPlayerID>("GetPlayerID");
|
||||
scriptInterface.RegisterFunction<void, int, &SetPlayerID>("SetPlayerID");
|
||||
scriptInterface.RegisterFunction<void, std::string, &OpenURL>("OpenURL");
|
||||
|
@ -72,7 +72,7 @@ CGame::CGame(bool disableGraphics, bool replayLog):
|
||||
m_SimRate(1.0f),
|
||||
m_PlayerID(-1),
|
||||
m_IsSavedGame(false),
|
||||
m_IsReplay(false),
|
||||
m_IsVisualReplay(false),
|
||||
m_ReplayStream(NULL)
|
||||
{
|
||||
// TODO: should use CDummyReplayLogger unless activated by cmd-line arg, perhaps?
|
||||
@ -120,9 +120,9 @@ void CGame::SetTurnManager(CNetTurnManager* turnManager)
|
||||
m_TurnManager->SetPlayerID(m_PlayerID);
|
||||
}
|
||||
|
||||
int CGame::LoadReplayData()
|
||||
int CGame::LoadVisualReplayData()
|
||||
{
|
||||
ENSURE(m_IsReplay);
|
||||
ENSURE(m_IsVisualReplay);
|
||||
ENSURE(!m_ReplayPath.empty());
|
||||
ENSURE(m_ReplayStream);
|
||||
|
||||
@ -167,9 +167,9 @@ int CGame::LoadReplayData()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CGame::StartReplay(const std::string& replayPath)
|
||||
bool CGame::StartVisualReplay(const std::string& replayPath)
|
||||
{
|
||||
m_IsReplay = true;
|
||||
m_IsVisualReplay = true;
|
||||
ScriptInterface& scriptInterface = m_Simulation2->GetScriptInterface();
|
||||
|
||||
SetTurnManager(new CNetReplayTurnManager(*m_Simulation2, GetReplayLogger()));
|
||||
@ -250,8 +250,8 @@ void CGame::RegisterInit(const JS::HandleValue attribs, const std::string& saved
|
||||
if (m_IsSavedGame)
|
||||
RegMemFun(this, &CGame::LoadInitialState, L"Loading game", 1000);
|
||||
|
||||
if (m_IsReplay)
|
||||
RegMemFun(this, &CGame::LoadReplayData, L"Loading replay data", 1000);
|
||||
if (m_IsVisualReplay)
|
||||
RegMemFun(this, &CGame::LoadVisualReplayData, L"Loading visual replay data", 1000);
|
||||
|
||||
LDR_EndRegistering();
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
void StartGame(JS::MutableHandleValue attribs, const std::string& savedState);
|
||||
PSRETURN ReallyStartGame();
|
||||
|
||||
bool StartReplay(const std::string& replayPath);
|
||||
bool StartVisualReplay(const std::string& replayPath);
|
||||
|
||||
/**
|
||||
* Periodic heartbeat that controls the process. performs all per-frame updates.
|
||||
@ -115,6 +115,14 @@ public:
|
||||
return m_GameStarted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get m_IsVisualReplay.
|
||||
*
|
||||
* @return bool the value of m_IsVisualReplay.
|
||||
**/
|
||||
inline bool IsVisualReplay()
|
||||
{ return m_IsVisualReplay; }
|
||||
|
||||
/**
|
||||
* Get the pointer to the game world object.
|
||||
*
|
||||
@ -175,9 +183,9 @@ private:
|
||||
std::string m_InitialSavedState; // valid between RegisterInit and LoadInitialState
|
||||
bool m_IsSavedGame; // true if loading a saved game; false for a new game
|
||||
|
||||
int LoadReplayData();
|
||||
int LoadVisualReplayData();
|
||||
std::string m_ReplayPath;
|
||||
bool m_IsReplay;
|
||||
bool m_IsVisualReplay;
|
||||
std::istream* m_ReplayStream;
|
||||
u32 m_FinalReplayTurn;
|
||||
};
|
||||
|
@ -1478,13 +1478,12 @@ bool VisualReplay(const std::string replayFile)
|
||||
|
||||
g_Game = new CGame(false, false);
|
||||
g_Game->SetPlayerID(-1);
|
||||
g_Game->StartReplay(replayFile);
|
||||
g_Game->StartVisualReplay(replayFile);
|
||||
|
||||
// TODO: Non progressive load can fail - need a decent way to handle this
|
||||
LDR_NonprogressiveLoad();
|
||||
|
||||
PSRETURN ret = g_Game->ReallyStartGame();
|
||||
ENSURE(ret == PSRETURN_OK);
|
||||
PSRETURN ret = g_Game->ReallyStartGame(); ENSURE(ret == PSRETURN_OK);
|
||||
|
||||
ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user