Game Development Reference
In-Depth Information
void BaseGameLogic::VChangeState(BaseGameState newState)
{
if (newState==BGS_WaitingForPlayers)
{
// Get rid of the Main Menu
m_gameViews.pop_front();
// Note: Split screen support would require this to change!
m_ExpectedPlayers = 1;
m_ExpectedRemotePlayers = g_pApp->m_Options.m_expectedPlayers - 1;
m_ExpectedAI = g_pApp->m_Options.m_numAIs;
if (!g_pApp->m_Options.m_gameHost.empty())
{
VSetProxy();
m_ExpectedAI = 0; // the server will create these
m_ExpectedRemotePlayers = 0; // the server will create these
if (!g_pApp->AttachAsClient())
{
// Throw up a main menu
VChangeState(BGS_MainMenu);
return;
}
}
else if (m_ExpectedRemotePlayers > 0)
{
BaseSocketManager *pServer = GCC_NEW BaseSocketManager();
if (!pServer->Init())
{
// Throw up a main menu
VChangeState(BGS_MainMenu);
return;
}
pServer->AddSocket(
new GameServerListenSocket(g_pApp->m_Options.m_listenPort));
g_pApp->m_pBaseSocketManager = pServer;
}
}
m_State = newState;
}
VChangeState() is called whenever the game state needs to be changed. For Base-
GameLogic , all
it really cares about is detecting when the game begins waiting for
Search WWH ::




Custom Search