mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Reduce duplicate code
Make a method for setting the host state.
This commit is contained in:
parent
fe5099eb04
commit
0eddec2473
@ -390,6 +390,24 @@ void CHostState::LoadConfig(void) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: set state machine
|
||||||
|
// Input : newState -
|
||||||
|
// clearNext -
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CHostState::SetState(const HostStates_t newState)
|
||||||
|
{
|
||||||
|
m_iCurrentState = newState;
|
||||||
|
|
||||||
|
// If our next state isn't a shutdown, or its a forced shutdown then set
|
||||||
|
// next state to run.
|
||||||
|
if (m_iNextState != HostStates_t::HS_SHUTDOWN ||
|
||||||
|
!host_hasIrreversibleShutdown->GetBool())
|
||||||
|
{
|
||||||
|
m_iNextState = newState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: shutdown active game
|
// Purpose: shutdown active game
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -415,7 +433,7 @@ void CHostState::State_NewGame(void)
|
|||||||
LARGE_INTEGER time{};
|
LARGE_INTEGER time{};
|
||||||
|
|
||||||
#ifndef CLIENT_DLL
|
#ifndef CLIENT_DLL
|
||||||
bool bSplitScreenConnect = m_bSplitScreenConnect;
|
const bool bSplitScreenConnect = m_bSplitScreenConnect;
|
||||||
m_bSplitScreenConnect = 0;
|
m_bSplitScreenConnect = 0;
|
||||||
|
|
||||||
if (!g_pServerGameClients) // Init Game if it ain't valid.
|
if (!g_pServerGameClients) // Init Game if it ain't valid.
|
||||||
@ -436,13 +454,7 @@ void CHostState::State_NewGame(void)
|
|||||||
}
|
}
|
||||||
#endif // !CLIENT_DLL
|
#endif // !CLIENT_DLL
|
||||||
|
|
||||||
m_iCurrentState = HostStates_t::HS_RUN; // Set current state to run.
|
SetState(HostStates_t::HS_RUN);
|
||||||
|
|
||||||
// If our next state isn't a shutdown or its a forced shutdown then set next state to run.
|
|
||||||
if (m_iNextState != HostStates_t::HS_SHUTDOWN || !host_hasIrreversibleShutdown->GetBool())
|
|
||||||
{
|
|
||||||
m_iNextState = HostStates_t::HS_RUN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -462,13 +474,8 @@ void CHostState::State_ChangeLevelSP(void)
|
|||||||
Error(eDLL_T::ENGINE, NO_ERROR, "%s: Unable to find level: '%s'\n", __FUNCTION__, m_levelName);
|
Error(eDLL_T::ENGINE, NO_ERROR, "%s: Unable to find level: '%s'\n", __FUNCTION__, m_levelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iCurrentState = HostStates_t::HS_RUN; // Set current state to run.
|
// Set current state to run.
|
||||||
|
SetState(HostStates_t::HS_RUN);
|
||||||
// If our next state isn't a shutdown or its a forced shutdown then set next state to run.
|
|
||||||
if (m_iNextState != HostStates_t::HS_SHUTDOWN || !host_hasIrreversibleShutdown->GetBool())
|
|
||||||
{
|
|
||||||
m_iNextState = HostStates_t::HS_RUN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -494,13 +501,8 @@ void CHostState::State_ChangeLevelMP(void)
|
|||||||
Error(eDLL_T::ENGINE, NO_ERROR, "%s: Unable to find level: '%s'\n", __FUNCTION__, m_levelName);
|
Error(eDLL_T::ENGINE, NO_ERROR, "%s: Unable to find level: '%s'\n", __FUNCTION__, m_levelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iCurrentState = HostStates_t::HS_RUN; // Set current state to run.
|
// Set current state to run.
|
||||||
|
SetState(HostStates_t::HS_RUN);
|
||||||
// If our next state isn't a shutdown or its a forced shutdown then set next state to run.
|
|
||||||
if (m_iNextState != HostStates_t::HS_SHUTDOWN || !host_hasIrreversibleShutdown->GetBool())
|
|
||||||
{
|
|
||||||
m_iNextState = HostStates_t::HS_RUN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -23,9 +23,10 @@ public:
|
|||||||
void Setup(void);
|
void Setup(void);
|
||||||
void Think(void) const;
|
void Think(void) const;
|
||||||
|
|
||||||
|
void SetState(const HostStates_t newState);
|
||||||
void GameShutDown(void);
|
void GameShutDown(void);
|
||||||
void State_NewGame(void);
|
|
||||||
|
|
||||||
|
void State_NewGame(void);
|
||||||
void State_ChangeLevelSP(void);
|
void State_ChangeLevelSP(void);
|
||||||
void State_ChangeLevelMP(void);
|
void State_ChangeLevelMP(void);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user