Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetServer.cpp
Show First 20 Lines • Show All 1,172 Lines • ▼ Show 20 Lines | bool CNetServerWorker::OnStartGame(void* context, CFsmEvent* event) | ||||
return true; | return true; | ||||
} | } | ||||
bool CNetServerWorker::OnLoadedGame(void* context, CFsmEvent* event) | bool CNetServerWorker::OnLoadedGame(void* context, CFsmEvent* event) | ||||
{ | { | ||||
ENSURE(event->GetType() == (uint)NMT_LOADED_GAME); | ENSURE(event->GetType() == (uint)NMT_LOADED_GAME); | ||||
CNetServerSession* session = (CNetServerSession*)context; | CNetServerSession* loadedSession = (CNetServerSession*)context; | ||||
CNetServerWorker& server = session->GetServer(); | CNetServerWorker& server = loadedSession->GetServer(); | ||||
// We're in the loading state, so wait until every player has loaded before | // We're in the loading state, so wait until every player has loaded before | ||||
elexis: player -> client | |||||
// starting the game | // starting the game | ||||
ENSURE(server.m_State == SERVER_STATE_LOADING); | ENSURE(server.m_State == SERVER_STATE_LOADING); | ||||
server.CheckGameLoadStatus(session); | if (server.CheckGameLoadStatus(loadedSession)) | ||||
return true; | |||||
Not Done Inline Actions2017-02-06-QuakeNet-#0ad-dev.log:17:59 < elexis> CheckGameLoadStatus could return true, so you dont send the message if its the last client that loaded elexis: `2017-02-06-QuakeNet-#0ad-dev.log:17:59 < elexis> CheckGameLoadStatus could return true, so you… | |||||
Done Inline Actions// Inform clients that another client has finished the loading screen and who's missing or something to that effect elexis: // Inform clients that another client has finished the loading screen and who's missing or… | |||||
CClientsLoadingMessage message; | |||||
for (CNetServerSession* session : server.m_Sessions) | |||||
Not Done Inline Actionsall GUIDs of clients in the loading state elexis: all GUIDs of clients in the loading state | |||||
if (session->GetCurrState() != NSS_INGAME && loadedSession->GetGUID() != session->GetGUID()) | |||||
{ | |||||
CClientsLoadingMessage::S_m_Clients client; | |||||
client.m_GUID = session->GetGUID(); | |||||
message.m_Clients.push_back(client); | |||||
} | |||||
// Send to the loaded player | |||||
Done Inline Actions// Send to the loaded client who is still in the NSS_PREGAME state? elexis: // Send to the loaded client who is still in the NSS_PREGAME state? | |||||
Not Done Inline Actionssure what else? Imarok: sure what else? | |||||
Not Done Inline ActionsAs in add that comment? elexis: As in add that comment? | |||||
Not Done Inline ActionsYeah, I did!? Imarok: Yeah, I did!? | |||||
loadedSession->SendMessage(&message); | |||||
Not Done Inline Actions// Send to the client who has loaded the game but did not reach the NSS_INGAME state yet? elexis: // Send to the client who has loaded the game but did not reach the NSS_INGAME state yet? | |||||
server.Broadcast(&message, { NSS_INGAME }); | |||||
return true; | return true; | ||||
} | } | ||||
bool CNetServerWorker::OnJoinSyncingLoadedGame(void* context, CFsmEvent* event) | bool CNetServerWorker::OnJoinSyncingLoadedGame(void* context, CFsmEvent* event) | ||||
{ | { | ||||
// A client rejoining an in-progress game has now finished loading the | // A client rejoining an in-progress game has now finished loading the | ||||
// map and deserialized the initial state. | // map and deserialized the initial state. | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | bool CNetServerWorker::OnClientPaused(void* context, CFsmEvent* event) | ||||
{ | { | ||||
if (session->GetCurrState() == NSS_INGAME && message->m_GUID != session->GetGUID()) | if (session->GetCurrState() == NSS_INGAME && message->m_GUID != session->GetGUID()) | ||||
session->SendMessage(message); | session->SendMessage(message); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
void CNetServerWorker::CheckGameLoadStatus(CNetServerSession* changedSession) | bool CNetServerWorker::CheckGameLoadStatus(CNetServerSession* changedSession) | ||||
{ | { | ||||
for (const CNetServerSession* session : m_Sessions) | for (const CNetServerSession* session : m_Sessions) | ||||
if (session != changedSession && session->GetCurrState() != NSS_INGAME) | if (session != changedSession && session->GetCurrState() != NSS_INGAME) | ||||
return; | return false; | ||||
// Inform clients that everyone has loaded the map and that the game can start | // Inform clients that everyone has loaded the map and that the game can start | ||||
CLoadedGameMessage loaded; | CLoadedGameMessage loaded; | ||||
loaded.m_CurrentTurn = 0; | loaded.m_CurrentTurn = 0; | ||||
// Notice the changedSession is still in the NSS_PREGAME state | // Notice the changedSession is still in the NSS_PREGAME state | ||||
Broadcast(&loaded, { NSS_PREGAME, NSS_INGAME }); | Broadcast(&loaded, { NSS_PREGAME, NSS_INGAME }); | ||||
m_State = SERVER_STATE_INGAME; | m_State = SERVER_STATE_INGAME; | ||||
return true; | |||||
} | } | ||||
void CNetServerWorker::StartGame() | void CNetServerWorker::StartGame() | ||||
{ | { | ||||
m_ServerTurnManager = new CNetServerTurnManager(*this); | m_ServerTurnManager = new CNetServerTurnManager(*this); | ||||
for (const CNetServerSession* session : m_Sessions) | for (const CNetServerSession* session : m_Sessions) | ||||
m_ServerTurnManager->InitialiseClient(session->GetHostID(), 0); // TODO: only for non-observers | m_ServerTurnManager->InitialiseClient(session->GetHostID(), 0); // TODO: only for non-observers | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
player -> client