Move Game.Network to ::Network

stable-5.2
Günther Brammer 2009-06-05 17:19:46 +02:00
parent 724f81724d
commit fa05c07d5c
32 changed files with 282 additions and 279 deletions

View File

@ -90,7 +90,6 @@ class C4Game
~C4Game(); ~C4Game();
public: public:
C4DefList Defs; C4DefList Defs;
C4Network2 Network;
C4ClientList &Clients; // Shortcut C4ClientList &Clients; // Shortcut
C4GameParameters Parameters; C4GameParameters Parameters;
C4TeamList &Teams; // Shortcut C4TeamList &Teams; // Shortcut

View File

@ -366,6 +366,8 @@ protected:
}; };
extern C4Network2 Network;
class C4VoteDialog : public C4GUI::MessageDialog class C4VoteDialog : public C4GUI::MessageDialog
{ {
public: public:

View File

@ -83,7 +83,7 @@ public:
void SetSourceIP(in_addr ip); void SetSourceIP(in_addr ip);
void InitLocal(C4Game *pGame); void InitLocal();
void SortNullIPsBack(); void SortNullIPsBack();

View File

@ -751,7 +751,7 @@ bool C4Console::UpdateHaltCtrls(bool fHalt)
BOOL C4Console::SaveGame(BOOL fSaveGame) BOOL C4Console::SaveGame(BOOL fSaveGame)
{ {
// Network hosts only // Network hosts only
if (Game.Network.isEnabled() && !Game.Network.isHost()) if (::Network.isEnabled() && !::Network.isHost())
{ Message(LoadResStr("IDS_GAME_NOCLIENTSAVE")); return FALSE; } { Message(LoadResStr("IDS_GAME_NOCLIENTSAVE")); return FALSE; }
@ -879,15 +879,15 @@ void C4Console::EnableControls(bool fEnable)
SendDlgItemMessage(hWindow,IDC_BUTTONMODEPLAY,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(fEnable ? hbmMouse : hbmMouse2)); SendDlgItemMessage(hWindow,IDC_BUTTONMODEPLAY,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(fEnable ? hbmMouse : hbmMouse2));
SendDlgItemMessage(hWindow,IDC_BUTTONMODEEDIT,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)((fEnable && Editing) ? hbmCursor : hbmCursor2)); SendDlgItemMessage(hWindow,IDC_BUTTONMODEEDIT,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)((fEnable && Editing) ? hbmCursor : hbmCursor2));
SendDlgItemMessage(hWindow,IDC_BUTTONMODEDRAW,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)((fEnable && Editing) ? hbmBrush : hbmBrush2)); SendDlgItemMessage(hWindow,IDC_BUTTONMODEDRAW,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)((fEnable && Editing) ? hbmBrush : hbmBrush2));
SendDlgItemMessage(hWindow,IDC_BUTTONPLAY,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(Game.Network.isLobbyActive() || fEnable ? hbmPlay : hbmPlay2)); SendDlgItemMessage(hWindow,IDC_BUTTONPLAY,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(::Network.isLobbyActive() || fEnable ? hbmPlay : hbmPlay2));
SendDlgItemMessage(hWindow,IDC_BUTTONHALT,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(Game.Network.isLobbyActive() || fEnable ? hbmHalt : hbmHalt2)); SendDlgItemMessage(hWindow,IDC_BUTTONHALT,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(::Network.isLobbyActive() || fEnable ? hbmHalt : hbmHalt2));
// OK // OK
EnableWindow( GetDlgItem(hWindow,IDOK), fEnable); EnableWindow( GetDlgItem(hWindow,IDOK), fEnable);
// Halt controls // Halt controls
EnableWindow(GetDlgItem(hWindow,IDC_BUTTONPLAY), Game.Network.isLobbyActive() || fEnable); EnableWindow(GetDlgItem(hWindow,IDC_BUTTONPLAY), ::Network.isLobbyActive() || fEnable);
EnableWindow(GetDlgItem(hWindow,IDC_BUTTONHALT), Game.Network.isLobbyActive() || fEnable); EnableWindow(GetDlgItem(hWindow,IDC_BUTTONHALT), ::Network.isLobbyActive() || fEnable);
// Edit modes // Edit modes
EnableWindow(GetDlgItem(hWindow,IDC_BUTTONMODEPLAY),(fEnable)); EnableWindow(GetDlgItem(hWindow,IDC_BUTTONMODEPLAY),(fEnable));
@ -918,16 +918,16 @@ void C4Console::EnableControls(bool fEnable)
EnableMenuItem(GetMenu(hWindow),IDM_VIEWPORT_NEW, MF_BYCOMMAND | (fEnable ? MF_ENABLED : MF_GRAYED)); EnableMenuItem(GetMenu(hWindow),IDM_VIEWPORT_NEW, MF_BYCOMMAND | (fEnable ? MF_ENABLED : MF_GRAYED));
#elif defined(WITH_DEVELOPER_MODE) #elif defined(WITH_DEVELOPER_MODE)
// Halt controls // Halt controls
gtk_widget_set_sensitive(btnPlay, Game.Network.isLobbyActive() || fEnable); gtk_widget_set_sensitive(btnPlay, ::Network.isLobbyActive() || fEnable);
gtk_widget_set_sensitive(btnHalt, Game.Network.isLobbyActive() || fEnable); gtk_widget_set_sensitive(btnHalt, ::Network.isLobbyActive() || fEnable);
// Edit modes // Edit modes
gtk_widget_set_sensitive(btnModePlay, Game.Network.isLobbyActive() || fEnable); gtk_widget_set_sensitive(btnModePlay, ::Network.isLobbyActive() || fEnable);
gtk_widget_set_sensitive(btnModeEdit, Game.Network.isLobbyActive() || fEnable); gtk_widget_set_sensitive(btnModeEdit, ::Network.isLobbyActive() || fEnable);
gtk_widget_set_sensitive(btnModeDraw, Game.Network.isLobbyActive() || fEnable); gtk_widget_set_sensitive(btnModeDraw, ::Network.isLobbyActive() || fEnable);
// Console input // Console input
gtk_widget_set_sensitive(txtScript, Game.Network.isLobbyActive() || fEnable); gtk_widget_set_sensitive(txtScript, ::Network.isLobbyActive() || fEnable);
// File menu // File menu
// C4Network2 will have to handle that cases somehow (TODO: test) // C4Network2 will have to handle that cases somehow (TODO: test)
@ -1331,20 +1331,20 @@ bool C4Console::UpdateModeCtrls(int iMode)
void C4Console::EditTitle() void C4Console::EditTitle()
{ {
if (Game.Network.isEnabled()) return; if (::Network.isEnabled()) return;
Game.Title.Open(); Game.Title.Open();
} }
void C4Console::EditScript() void C4Console::EditScript()
{ {
if (Game.Network.isEnabled()) return; if (::Network.isEnabled()) return;
Game.Script.Open(); Game.Script.Open();
Game.ScriptEngine.ReLink(&Game.Defs); Game.ScriptEngine.ReLink(&Game.Defs);
} }
void C4Console::EditInfo() void C4Console::EditInfo()
{ {
if (Game.Network.isEnabled()) return; if (::Network.isEnabled()) return;
Game.Info.Open(); Game.Info.Open();
} }
@ -1418,12 +1418,12 @@ bool C4Console::UpdatePlayerMenu()
for (C4Player *pPlr=Game.Players.First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=Game.Players.First; pPlr; pPlr=pPlr->Next)
{ {
StdStrBuf sText; StdStrBuf sText;
if (Game.Network.isEnabled()) if (::Network.isEnabled())
sText.Format(LoadResStr("IDS_CNS_PLRQUITNET"),pPlr->GetName(),pPlr->AtClientName); sText.Format(LoadResStr("IDS_CNS_PLRQUITNET"),pPlr->GetName(),pPlr->AtClientName);
else else
sText.Format(LoadResStr("IDS_CNS_PLRQUIT"),pPlr->GetName()); sText.Format(LoadResStr("IDS_CNS_PLRQUIT"),pPlr->GetName());
#ifdef _WIN32 #ifdef _WIN32
AddMenuItem(hMenu,IDM_PLAYER_QUIT1+pPlr->Number,sText.getData(),(!Game.Network.isEnabled() || Game.Network.isHost()) && Editing); AddMenuItem(hMenu,IDM_PLAYER_QUIT1+pPlr->Number,sText.getData(),(!::Network.isEnabled() || ::Network.isHost()) && Editing);
#elif defined(WITH_DEVELOPER_MODE) #elif defined(WITH_DEVELOPER_MODE)
// TODO: Implement AddMenuItem... // TODO: Implement AddMenuItem...
GtkWidget* menuItem = gtk_menu_item_new_with_label(Languages.IconvUtf8(sText.getData()).getData()); GtkWidget* menuItem = gtk_menu_item_new_with_label(Languages.IconvUtf8(sText.getData()).getData());
@ -1431,7 +1431,7 @@ bool C4Console::UpdatePlayerMenu()
g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(OnPlrQuit), GINT_TO_POINTER(pPlr->Number)); g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(OnPlrQuit), GINT_TO_POINTER(pPlr->Number));
gtk_widget_show(menuItem); gtk_widget_show(menuItem);
gtk_widget_set_sensitive(menuItem, (!Game.Network.isEnabled() || Game.Network.isHost()) && Editing); gtk_widget_set_sensitive(menuItem, (!::Network.isEnabled() || ::Network.isHost()) && Editing);
#endif // WITH_DEVELOPER_MODE / _WIN32 #endif // WITH_DEVELOPER_MODE / _WIN32
} }
return TRUE; return TRUE;
@ -1496,8 +1496,8 @@ void C4Console::PlayerJoin()
char szPlayerFilename[_MAX_PATH+1]; char szPlayerFilename[_MAX_PATH+1];
for (int iPar=0; SCopySegment(c4plist,iPar,szPlayerFilename,';',_MAX_PATH); iPar++) for (int iPar=0; SCopySegment(c4plist,iPar,szPlayerFilename,';',_MAX_PATH); iPar++)
if (szPlayerFilename[0]) if (szPlayerFilename[0])
if (Game.Network.isEnabled()) if (::Network.isEnabled())
Game.Network.Players.JoinLocalPlayer(szPlayerFilename, true); ::Network.Players.JoinLocalPlayer(szPlayerFilename, true);
else else
Game.Players.CtrlJoinLocalNoNetwork(szPlayerFilename, Game.Clients.getLocalID(), Game.Clients.getLocalName()); Game.Players.CtrlJoinLocalNoNetwork(szPlayerFilename, Game.Clients.getLocalID(), Game.Clients.getLocalName());
@ -1544,7 +1544,7 @@ void C4Console::UpdateNetMenu()
{ {
// Active & network hosting check // Active & network hosting check
if (!Active) return; if (!Active) return;
if (!Game.Network.isHost() || !Game.Network.isEnabled()) return; if (!::Network.isHost() || !::Network.isEnabled()) return;
// Clear old // Clear old
ClearNetMenu(); ClearNetMenu();
// Insert menu // Insert menu
@ -1576,7 +1576,7 @@ void C4Console::UpdateNetMenu()
g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(OnNetClient), GINT_TO_POINTER(Game.Clients.getLocalID())); g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(OnNetClient), GINT_TO_POINTER(Game.Clients.getLocalID()));
#endif #endif
// Clients // Clients
for (C4Network2Client *pClient=Game.Network.Clients.GetNextClient(NULL); pClient; pClient=Game.Network.Clients.GetNextClient(pClient)) for (C4Network2Client *pClient=::Network.Clients.GetNextClient(NULL); pClient; pClient=::Network.Clients.GetNextClient(pClient))
{ {
str.Format(LoadResStr(pClient->isActivated() ? "IDS_MNU_NETCLIENT" : "IDS_MNU_NETCLIENTDE"), str.Format(LoadResStr(pClient->isActivated() ? "IDS_MNU_NETCLIENT" : "IDS_MNU_NETCLIENTDE"),
pClient->getName(), pClient->getID()); pClient->getName(), pClient->getID());

View File

@ -239,13 +239,13 @@ void C4ControlSet::Execute() const
::GraphicsSystem.FlashMessage(LoadResStr("IDS_MSG_FAIRCREW_DEACTIVATED")); ::GraphicsSystem.FlashMessage(LoadResStr("IDS_MSG_FAIRCREW_DEACTIVATED"));
} }
// lobby updates // lobby updates
if (Game.Network.isLobbyActive()) if (::Network.isLobbyActive())
{ {
Game.Network.GetLobby()->UpdateFairCrew(); ::Network.GetLobby()->UpdateFairCrew();
} }
// this setting is part of the reference // this setting is part of the reference
if (Game.Network.isEnabled() && Game.Network.isHost()) if (::Network.isEnabled() && ::Network.isHost())
Game.Network.InvalidateReference(); ::Network.InvalidateReference();
break; break;
} }
} }
@ -289,8 +289,8 @@ void C4ControlScript::Execute() const
if(!LocalControl()) if(!LocalControl())
{ {
C4Network2Client *pClient = NULL; C4Network2Client *pClient = NULL;
if(Game.Network.isEnabled()) if(::Network.isEnabled())
pClient = Game.Network.Clients.GetClientByID(iByClient); pClient = ::Network.Clients.GetClientByID(iByClient);
if(pClient) if(pClient)
LogF(" = %s (by %s)", rVal.GetDataString().getData(), pClient->getName()); LogF(" = %s (by %s)", rVal.GetDataString().getData(), pClient->getName());
else else
@ -491,14 +491,14 @@ void C4ControlSyncCheck::Execute() const
SaveGame.Save(Config.AtExePath("Desync.c4s")); SaveGame.Save(Config.AtExePath("Desync.c4s"));
#endif #endif
// league: Notify regular client disconnect within the game // league: Notify regular client disconnect within the game
Game.Network.LeagueNotifyDisconnect(C4ClientIDHost, C4LDR_Desync); ::Network.LeagueNotifyDisconnect(C4ClientIDHost, C4LDR_Desync);
// Deactivate / end // Deactivate / end
if(Game.Control.isReplay()) if(Game.Control.isReplay())
Game.DoGameOver(); Game.DoGameOver();
else if(Game.Control.isNetwork()) else if(Game.Control.isNetwork())
{ {
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, "Network: Synchronization loss!"); Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, "Network: Synchronization loss!");
Game.Network.Clear(); ::Network.Clear();
} }
} }
@ -546,7 +546,7 @@ void C4ControlClientJoin::Execute() const
// log // log
LogF(LoadResStr("IDS_NET_CLIENT_JOIN"), Core.getName()); LogF(LoadResStr("IDS_NET_CLIENT_JOIN"), Core.getName());
// lobby callback // lobby callback
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby(); C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
if (pLobby) pLobby->OnClientJoin(pClient); if (pLobby) pLobby->OnClientJoin(pClient);
// console callback // console callback
if (Console.Active) Console.UpdateMenus(); if (Console.Active) Console.UpdateMenus();
@ -641,13 +641,13 @@ void C4ControlClientRemove::Execute() const
// remove all players // remove all players
Game.Players.RemoveAtClient(iID, true); Game.Players.RemoveAtClient(iID, true);
// remove all resources // remove all resources
if(Game.Network.isEnabled()) if(::Network.isEnabled())
Game.Network.ResList.RemoveAtClient(iID); ::Network.ResList.RemoveAtClient(iID);
// lobby callback // lobby callback
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby(); C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
if (pLobby && Game.pGUI) pLobby->OnClientPart(pClient); if (pLobby && Game.pGUI) pLobby->OnClientPart(pClient);
// player list callback // player list callback
Game.Network.Players.OnClientPart(pClient); ::Network.Players.OnClientPart(pClient);
// console callback // console callback
if(Console.Active) Console.UpdateMenus(); if(Console.Active) Console.UpdateMenus();
@ -734,7 +734,7 @@ void C4ControlJoinPlayer::Execute() const
else if(Game.Control.isNetwork()) else if(Game.Control.isNetwork())
{ {
// Find ressource // Find ressource
C4Network2Res::Ref pRes = Game.Network.ResList.getRefRes(ResCore.getID()); C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID());
if(pRes && pRes->isComplete()) if(pRes && pRes->isComplete())
Game.JoinPlayer(pRes->getFile(), iAtClient, pClient->getName(), pInfo); Game.JoinPlayer(pRes->getFile(), iAtClient, pClient->getName(), pInfo);
} }
@ -790,9 +790,9 @@ bool C4ControlJoinPlayer::PreExecute() const
// network only // network only
if(!Game.Control.isNetwork()) return true; if(!Game.Control.isNetwork()) return true;
// search ressource // search ressource
C4Network2Res::Ref pRes = Game.Network.ResList.getRefRes(ResCore.getID()); C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID());
// doesn't exist? start loading // doesn't exist? start loading
if(!pRes) { pRes = Game.Network.ResList.AddByCore(ResCore, true); } if(!pRes) { pRes = ::Network.ResList.AddByCore(ResCore, true); }
if(!pRes) return true; if(!pRes) return true;
// is loading or removed? // is loading or removed?
return !pRes->isLoading(); return !pRes->isLoading();
@ -804,7 +804,7 @@ void C4ControlJoinPlayer::PreRec(C4Record *pRecord)
if (fByRes) if (fByRes)
{ {
// get local file by id // get local file by id
C4Network2Res::Ref pRes = Game.Network.ResList.getRefRes(ResCore.getID()); C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID());
if(!pRes || pRes->isRemoved()) return; if(!pRes || pRes->isRemoved()) return;
// create a copy of the resource // create a copy of the resource
StdStrBuf szTemp; szTemp.Copy(pRes->getFile()); StdStrBuf szTemp; szTemp.Copy(pRes->getFile());
@ -1035,7 +1035,7 @@ void C4ControlMessage::Execute() const
// do not record message as control, because it is not synced! // do not record message as control, because it is not synced!
//if (pPlr) pPlr->CountControl(C4Player::PCID_Message, Message.GetHash()); //if (pPlr) pPlr->CountControl(C4Player::PCID_Message, Message.GetHash());
// get lobby to forward to // get lobby to forward to
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby(); C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
StdStrBuf str; StdStrBuf str;
switch(eType) switch(eType)
{ {
@ -1169,7 +1169,7 @@ void C4ControlPlayerInfo::Execute() const
} }
else else
// network: // network:
Game.Network.Players.HandlePlayerInfo(PlrInfo); ::Network.Players.HandlePlayerInfo(PlrInfo);
} }
void C4ControlPlayerInfo::CompileFunc(StdCompiler *pComp) void C4ControlPlayerInfo::CompileFunc(StdCompiler *pComp)
@ -1262,8 +1262,8 @@ void C4ControlVote::Execute() const
else else
LogF(LoadResStr("IDS_VOTE_DOESNOTWANTTO"), pClient->getName(), getDesc().getData()); LogF(LoadResStr("IDS_VOTE_DOESNOTWANTTO"), pClient->getName(), getDesc().getData());
// Save vote back // Save vote back
if(Game.Network.isEnabled()) if(::Network.isEnabled())
Game.Network.AddVote(*this); ::Network.AddVote(*this);
// Vote done? // Vote done?
if(Game.Control.isCtrlHost()) if(Game.Control.isCtrlHost())
{ {
@ -1301,7 +1301,7 @@ void C4ControlVote::Execute() const
iVotesTeam++; iVotesTeam++;
// Search vote of this client on the subject // Search vote of this client on the subject
C4IDPacket *pPkt; C4ControlVote *pVote; C4IDPacket *pPkt; C4ControlVote *pVote;
if(pPkt = Game.Network.GetVote(iClientID, eType, iData)) if(pPkt = ::Network.GetVote(iClientID, eType, iData))
if(pVote = static_cast<C4ControlVote *>(pPkt->getPkt())) if(pVote = static_cast<C4ControlVote *>(pPkt->getPkt()))
if(pVote->isApprove()) if(pVote->isApprove())
iPositiveTeam++; iPositiveTeam++;
@ -1347,8 +1347,8 @@ void C4ControlVoteEnd::Execute() const
{ {
// End the voting process // End the voting process
if(!HostControl()) return; if(!HostControl()) return;
if(Game.Network.isEnabled()) if(::Network.isEnabled())
Game.Network.EndVote(getType(), isApprove(), getData()); ::Network.EndVote(getType(), isApprove(), getData());
// Log // Log
StdStrBuf sMsg; StdStrBuf sMsg;
if(isApprove()) if(isApprove())
@ -1394,7 +1394,7 @@ void C4ControlVoteEnd::Execute() const
// otherwise, we have been kicked by the host. // otherwise, we have been kicked by the host.
// Do a regular disconnect and display reason in game over dialog, so the client knows what has happened! // Do a regular disconnect and display reason in game over dialog, so the client knows what has happened!
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, FormatString(LoadResStr("IDS_ERR_YOUHAVEBEENREMOVEDBYVOTIN"), sMsg.getData()).getData()); Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, FormatString(LoadResStr("IDS_ERR_YOUHAVEBEENREMOVEDBYVOTIN"), sMsg.getData()).getData());
Game.Network.Clear(); ::Network.Clear();
// Game over immediately, so poor player won't continue game alone // Game over immediately, so poor player won't continue game alone
Game.DoGameOver(); Game.DoGameOver();
} }

View File

@ -962,17 +962,17 @@ bool C4Game::Pause()
// already paused? // already paused?
if (IsPaused()) return false; if (IsPaused()) return false;
// pause by net? // pause by net?
if(Game.Network.isEnabled()) if(::Network.isEnabled())
{ {
// league? Vote... // league? Vote...
if(Parameters.isLeague() && !Game.Evaluated) if(Parameters.isLeague() && !Game.Evaluated)
{ {
Game.Network.Vote(VT_Pause, true, true); ::Network.Vote(VT_Pause, true, true);
return false; return false;
} }
// host only // host only
if(!Game.Network.isHost()) return true; if(!::Network.isHost()) return true;
Game.Network.Pause(); ::Network.Pause();
} }
else else
{ {
@ -988,17 +988,17 @@ bool C4Game::Unpause()
// already paused? // already paused?
if (!IsPaused()) return false; if (!IsPaused()) return false;
// pause by net? // pause by net?
if(Game.Network.isEnabled()) if(::Network.isEnabled())
{ {
// league? Vote... // league? Vote...
if(Parameters.isLeague() && !Game.Evaluated) if(Parameters.isLeague() && !Game.Evaluated)
{ {
Game.Network.Vote(VT_Pause, true, false); ::Network.Vote(VT_Pause, true, false);
return false; return false;
} }
// host only // host only
if(!Game.Network.isHost()) return true; if(!::Network.isHost()) return true;
Game.Network.Start(); ::Network.Start();
} }
else else
{ {
@ -1012,8 +1012,8 @@ bool C4Game::Unpause()
bool C4Game::IsPaused() bool C4Game::IsPaused()
{ {
// pause state defined either by network or by game halt count // pause state defined either by network or by game halt count
if (Game.Network.isEnabled()) if (::Network.isEnabled())
return !Game.Network.isRunning(); return !::Network.isRunning();
return !!HaltCount; return !!HaltCount;
} }
@ -2133,7 +2133,7 @@ static void FileMonitorCallback(const char * file, const char * extrafile)
BOOL C4Game::ReloadFile(const char *szFile) BOOL C4Game::ReloadFile(const char *szFile)
{ {
// not in network // not in network
if(Game.Network.isEnabled()) return FALSE; if(::Network.isEnabled()) return FALSE;
const char *szRelativePath = Config.AtRelativePath(szFile); const char *szRelativePath = Config.AtRelativePath(szFile);
// a definition? or part of a definition? // a definition? or part of a definition?
C4Def *pDef; C4Def *pDef;
@ -2151,7 +2151,7 @@ BOOL C4Game::ReloadDef(C4ID id)
{ {
bool fSucc; bool fSucc;
// not in network // not in network
if(Game.Network.isEnabled()) return FALSE; if(::Network.isEnabled()) return FALSE;
// syncronize (close menus with dead surfaces, etc.) // syncronize (close menus with dead surfaces, etc.)
// no need to sync back player files, though // no need to sync back player files, though
Synchronize(FALSE); Synchronize(FALSE);
@ -2197,7 +2197,7 @@ BOOL C4Game::ReloadDef(C4ID id)
BOOL C4Game::ReloadParticle(const char *szName) BOOL C4Game::ReloadParticle(const char *szName)
{ {
// not in network // not in network
if(Game.Network.isEnabled()) return FALSE; if(::Network.isEnabled()) return FALSE;
// safety // safety
if (!szName) return FALSE; if (!szName) return FALSE;
// get particle def // get particle def
@ -2243,7 +2243,7 @@ BOOL C4Game::InitGame(C4Group &hGroup, bool fLoadSection, bool fLoadSky)
// join local players for regular games // join local players for regular games
// should be done before record/replay is initialized, so the players are stored in PlayerInfos.txt // should be done before record/replay is initialized, so the players are stored in PlayerInfos.txt
// for local savegame resumes, players are joined into PlayerInfos and later associated in InitPlayers // for local savegame resumes, players are joined into PlayerInfos and later associated in InitPlayers
if (!Game.Network.isEnabled()) if (!::Network.isEnabled())
if (!PlayerInfos.InitLocal()) if (!PlayerInfos.InitLocal())
{ LogFatal(LoadResStr("IDS_PRC_FAIL")); return FALSE; } { LogFatal(LoadResStr("IDS_PRC_FAIL")); return FALSE; }

View File

@ -107,8 +107,8 @@ void C4GameControl::ChangeToLocal()
if(eMode == CM_Network) if(eMode == CM_Network)
{ {
Network.Clear(); Network.Clear();
if(Game.Network.isEnabled()) if(::Network.isEnabled())
Game.Network.Clear(); ::Network.Clear();
} }
// replay: close playback // replay: close playback
else if(eMode == CM_Replay) else if(eMode == CM_Replay)
@ -152,7 +152,7 @@ bool C4GameControl::StartRecord(bool fInitial, bool fStreaming)
if(fStreaming) if(fStreaming)
{ {
if(!pRecord->StartStreaming(fInitial) || if(!pRecord->StartStreaming(fInitial) ||
!Game.Network.StartStreaming(pRecord)) !::Network.StartStreaming(pRecord))
{ {
delete pRecord; pRecord = NULL; delete pRecord; pRecord = NULL;
return false; return false;
@ -169,7 +169,7 @@ void C4GameControl::StopRecord(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
{ {
if(pRecord) if(pRecord)
{ {
Game.Network.FinishStreaming(); ::Network.FinishStreaming();
pRecord->Stop(pRecordName, pRecordSHA1); pRecord->Stop(pRecordName, pRecordSHA1);
// just delete // just delete
delete pRecord; pRecord = NULL; delete pRecord; pRecord = NULL;
@ -248,7 +248,7 @@ bool C4GameControl::Prepare()
// deactivated and got control: request activate // deactivated and got control: request activate
if(Input.firstPkt() && !Game.Clients.getLocal()->isActivated()) if(Input.firstPkt() && !Game.Clients.getLocal()->isActivated())
Game.Network.RequestActivate(); ::Network.RequestActivate();
// needs input? // needs input?
while(Network.CtrlNeeded(Game.FrameCounter)) while(Network.CtrlNeeded(Game.FrameCounter))

View File

@ -200,28 +200,28 @@ void C4GameControlNetwork::DoInput(C4PacketType eCtrlType, C4ControlPacket *pCtr
if(!fHost) if(!fHost)
{ {
// Client: send to host // Client: send to host
if(!Game.Network.Clients.SendMsgToHost(MkC4NetIOPacket(PID_ControlPkt, CtrlPkt))) if(!::Network.Clients.SendMsgToHost(MkC4NetIOPacket(PID_ControlPkt, CtrlPkt)))
{ LogFatal("Network: could not send direct control packet!"); break; } { LogFatal("Network: could not send direct control packet!"); break; }
delete pCtrl; delete pCtrl;
} }
else else
{ {
// Host: send to all clients // Host: send to all clients
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ControlPkt, CtrlPkt)); ::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ControlPkt, CtrlPkt));
// Execute at once, if possible // Execute at once, if possible
if(Game.Network.isFrozen()) if(::Network.isFrozen())
{ {
pParent->ExecControlPacket(eCtrlType, pCtrl); pParent->ExecControlPacket(eCtrlType, pCtrl);
delete pCtrl; delete pCtrl;
C4PacketExecSyncCtrl Pkt(pParent->ControlTick); C4PacketExecSyncCtrl Pkt(pParent->ControlTick);
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ExecSyncCtrl, Pkt)); ::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ExecSyncCtrl, Pkt));
} }
else else
{ {
// Safe back otherwise // Safe back otherwise
SyncControl.Add(eCtrlType, pCtrl); SyncControl.Add(eCtrlType, pCtrl);
// And sync // And sync
Game.Network.Sync(); ::Network.Sync();
} }
} }
} }
@ -232,7 +232,7 @@ void C4GameControlNetwork::DoInput(C4PacketType eCtrlType, C4ControlPacket *pCtr
case CDT_Private: case CDT_Private:
{ {
// Send to all clients // Send to all clients
if(!Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ControlPkt, CtrlPkt))) if(!::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ControlPkt, CtrlPkt)))
{ LogFatal("Network: could not send direct control packet!"); break; } { LogFatal("Network: could not send direct control packet!"); break; }
// Exec at once // Exec at once
pParent->ExecControlPacket(eCtrlType, pCtrl); pParent->ExecControlPacket(eCtrlType, pCtrl);
@ -255,7 +255,7 @@ C4ControlDeliveryType C4GameControlNetwork::DecideControlDelivery() const
return CDT_Queue; return CDT_Queue;
// Decide the fastest control delivery type atm. Note this is a guess. // Decide the fastest control delivery type atm. Note this is a guess.
// Control sent with the returned delivery type may in theory be delayed infinitely. // Control sent with the returned delivery type may in theory be delayed infinitely.
if(Game.Network.isFrozen()) if(::Network.isFrozen())
return CDT_Sync; return CDT_Sync;
if(!Game.Clients.getLocal()->isActivated()) if(!Game.Clients.getLocal()->isActivated())
return CDT_Sync; return CDT_Sync;
@ -275,7 +275,7 @@ void C4GameControlNetwork::ExecSyncControl() // by main thread
// So let's spread the word, so clients will call ExecSyncControl, too. // So let's spread the word, so clients will call ExecSyncControl, too.
C4PacketExecSyncCtrl Pkt(pParent->ControlTick); C4PacketExecSyncCtrl Pkt(pParent->ControlTick);
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ExecSyncCtrl, Pkt)); ::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ExecSyncCtrl, Pkt));
// Execute it // Execute it
ExecSyncControl(Pkt.getControlTick()); ExecSyncControl(Pkt.getControlTick());
@ -378,13 +378,13 @@ void C4GameControlNetwork::SetCtrlMode(C4GameControlNetworkMode enMode) // by ma
{ {
CStdLock CtrlLock(&CtrlCSec); C4GameControlPacket *pPkt; CStdLock CtrlLock(&CtrlCSec); C4GameControlPacket *pPkt;
for(int32_t iCtrlTick = Game.Control.ControlTick; pPkt = getCtrl(iClientID, iCtrlTick); iCtrlTick++) for(int32_t iCtrlTick = Game.Control.ControlTick; pPkt = getCtrl(iClientID, iCtrlTick); iCtrlTick++)
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_Control, *pPkt)); ::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_Control, *pPkt));
} }
else if(enMode == CNM_Central && fHost) else if(enMode == CNM_Central && fHost)
{ {
CStdLock CtrlLock(&CtrlCSec); C4GameControlPacket *pPkt; CStdLock CtrlLock(&CtrlCSec); C4GameControlPacket *pPkt;
for(int32_t iCtrlTick = Game.Control.ControlTick; pPkt = getCtrl(C4ClientIDAll, iCtrlTick); iCtrlTick++) for(int32_t iCtrlTick = Game.Control.ControlTick; pPkt = getCtrl(C4ClientIDAll, iCtrlTick); iCtrlTick++)
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_Control, *pPkt)); ::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_Control, *pPkt));
} }
} }
@ -400,7 +400,7 @@ void C4GameControlNetwork::CalcPerformance(int32_t iCtrlTick)
{ {
// Some rudimentary PreSend-calculation // Some rudimentary PreSend-calculation
// get associated connection - NULL for self // get associated connection - NULL for self
C4Network2Client *pNetClt = Game.Network.Clients.GetClientByID(pClient->getClientID()); C4Network2Client *pNetClt = ::Network.Clients.GetClientByID(pClient->getClientID());
if (pNetClt && !pNetClt->isLocal()) if (pNetClt && !pNetClt->isLocal())
{ {
C4Network2IOConnection *pConn = pNetClt->getMsgConn(); C4Network2IOConnection *pConn = pNetClt->getMsgConn();
@ -588,7 +588,7 @@ void C4GameControlNetwork::HandleControlPkt(C4PacketType eCtrlType, C4ControlPac
ExecQueuedSyncCtrl(); ExecQueuedSyncCtrl();
// Execute at once, if possible // Execute at once, if possible
if(Game.Network.isFrozen()) if(::Network.isFrozen())
{ {
pParent->ExecControlPacket(eCtrlType, pCtrl); pParent->ExecControlPacket(eCtrlType, pCtrl);
delete pCtrl; delete pCtrl;
@ -743,9 +743,9 @@ void C4GameControlNetwork::CheckCompleteCtrl(bool fSetEvent) // by both
C4NetIOPacket Pkt = MkC4NetIOPacket(PID_ControlReq, C4PacketControlReq(iControlReady + 1)); C4NetIOPacket Pkt = MkC4NetIOPacket(PID_ControlReq, C4PacketControlReq(iControlReady + 1));
// send control requests // send control requests
if(eMode == CNM_Central) if(eMode == CNM_Central)
Game.Network.Clients.SendMsgToHost(Pkt); ::Network.Clients.SendMsgToHost(Pkt);
else else
Game.Network.Clients.BroadcastMsgToConnClients(Pkt); ::Network.Clients.BroadcastMsgToConnClients(Pkt);
// set time for next request // set time for next request
iNextControlReqeust = timeGetTime() + C4ControlRequestInterval; iNextControlReqeust = timeGetTime() + C4ControlRequestInterval;
} }
@ -793,7 +793,7 @@ C4GameControlPacket *C4GameControlNetwork::PackCompleteCtrl(int32_t iTick)
// host: send to clients (central and async mode) // host: send to clients (central and async mode)
if(eMode != CNM_Decentral) if(eMode != CNM_Decentral)
Game.Network.Clients.BroadcastMsgToConnClients(MkC4NetIOPacket(PID_Control, *pComplete)); ::Network.Clients.BroadcastMsgToConnClients(MkC4NetIOPacket(PID_Control, *pComplete));
// advance control request time // advance control request time
iNextControlReqeust = Max<uint32_t>(iNextControlReqeust, timeGetTime() + C4ControlRequestInterval); iNextControlReqeust = Max<uint32_t>(iNextControlReqeust, timeGetTime() + C4ControlRequestInterval);

View File

@ -54,7 +54,7 @@ C4AbortGameDialog::~C4AbortGameDialog()
void C4AbortGameDialog::OnShown() void C4AbortGameDialog::OnShown()
{ {
if(!Game.Network.isEnabled()) if(!::Network.isEnabled())
{ {
fGameHalted = true; fGameHalted = true;
Game.HaltCount++; Game.HaltCount++;

View File

@ -402,9 +402,9 @@ void MainDlg::OnClosed(bool fOK)
void MainDlg::OnRunBtn(C4GUI::Control *btn) void MainDlg::OnRunBtn(C4GUI::Control *btn)
{ {
// only for host // only for host
if (!Game.Network.isHost()) return; if (!::Network.isHost()) return;
// already started? then abort // already started? then abort
if (eCountdownState) { Game.Network.AbortLobbyCountdown(); return; } if (eCountdownState) { ::Network.AbortLobbyCountdown(); return; }
// otherwise start, utilizing correct countdown time // otherwise start, utilizing correct countdown time
Start(Config.Lobby.CountdownTime); Start(Config.Lobby.CountdownTime);
} }
@ -423,10 +423,10 @@ void MainDlg::Start(int32_t iCountdownTime)
iCountdownTime = ValidatedCountdownTime(iCountdownTime); iCountdownTime = ValidatedCountdownTime(iCountdownTime);
// either direct start... // either direct start...
if (!iCountdownTime) if (!iCountdownTime)
Game.Network.Start(); ::Network.Start();
else else
// ...or countdown // ...or countdown
Game.Network.StartLobbyCountdown(iCountdownTime); ::Network.StartLobbyCountdown(iCountdownTime);
} }
C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, bool fPastingMore) C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, bool fPastingMore)
@ -485,7 +485,7 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
LobbyError(FormatString(LoadResStr("IDS_MSG_CMD_JOINPLR_NOFILE"), plrPath.getData()).getData()); LobbyError(FormatString(LoadResStr("IDS_MSG_CMD_JOINPLR_NOFILE"), plrPath.getData()).getData());
} }
else else
Game.Network.Players.JoinLocalPlayer(plrPath.getData(), true); ::Network.Players.JoinLocalPlayer(plrPath.getData(), true);
} }
// ------------------------------------------------------ // ------------------------------------------------------
else if (SEqualNoCase(Command, "/plrclr")) else if (SEqualNoCase(Command, "/plrclr"))
@ -494,7 +494,7 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
int iSepPos = SCharPos(' ', szPar, 0); int iSepPos = SCharPos(' ', szPar, 0);
C4PlayerInfo *pNfo=NULL; C4PlayerInfo *pNfo=NULL;
int32_t idLocalClient = -1; int32_t idLocalClient = -1;
if (Game.Network.Clients.GetLocal()) idLocalClient = Game.Network.Clients.GetLocal()->getID(); if (::Network.Clients.GetLocal()) idLocalClient = ::Network.Clients.GetLocal()->getID();
if (iSepPos>0) if (iSepPos>0)
{ {
// a player name is given: Parse it // a player name is given: Parse it
@ -519,7 +519,7 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
else else
{ {
// may color of this client be set? // may color of this client be set?
if (pCltNfo->GetClientID() != idLocalClient && !Game.Network.isHost()) if (pCltNfo->GetClientID() != idLocalClient && !::Network.isHost())
{ {
LobbyError(LoadResStr("IDS_MSG_CMD_PLRCLR_NOACCESS")); LobbyError(LoadResStr("IDS_MSG_CMD_PLRCLR_NOACCESS"));
} }
@ -543,7 +543,7 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
if (pPlrInfo) if (pPlrInfo)
{ {
pPlrInfo->SetOriginalColor(dwNewClr); // set this as a new color wish pPlrInfo->SetOriginalColor(dwNewClr); // set this as a new color wish
Game.Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest); ::Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
} }
} }
} }
@ -554,14 +554,14 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
{ {
// timeout given? // timeout given?
int32_t iTimeout = Config.Lobby.CountdownTime; int32_t iTimeout = Config.Lobby.CountdownTime;
if (!Game.Network.isHost()) if (!::Network.isHost())
LobbyError(LoadResStr("IDS_MSG_CMD_HOSTONLY")); LobbyError(LoadResStr("IDS_MSG_CMD_HOSTONLY"));
else if (szPar && *szPar && (!sscanf(szPar, "%d", &iTimeout) || iTimeout<0)) else if (szPar && *szPar && (!sscanf(szPar, "%d", &iTimeout) || iTimeout<0))
LobbyError(LoadResStr("IDS_MSG_CMD_START_USAGE")); LobbyError(LoadResStr("IDS_MSG_CMD_START_USAGE"));
else else
{ {
// abort previous countdown // abort previous countdown
if (eCountdownState) Game.Network.AbortLobbyCountdown(); if (eCountdownState) ::Network.AbortLobbyCountdown();
// start new countdown (aborts previous if necessary) // start new countdown (aborts previous if necessary)
Start(iTimeout); Start(iTimeout);
} }
@ -569,10 +569,10 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
// ------------------------------------------------------ // ------------------------------------------------------
else if (SEqualNoCase(Command, "/abort")) else if (SEqualNoCase(Command, "/abort"))
{ {
if (!Game.Network.isHost()) if (!::Network.isHost())
LobbyError(LoadResStr("IDS_MSG_CMD_HOSTONLY")); LobbyError(LoadResStr("IDS_MSG_CMD_HOSTONLY"));
else if (eCountdownState) else if (eCountdownState)
Game.Network.AbortLobbyCountdown(); ::Network.AbortLobbyCountdown();
else else
LobbyError(LoadResStr("IDS_MSG_CMD_ABORT_NOCOUNTDOWN")); LobbyError(LoadResStr("IDS_MSG_CMD_ABORT_NOCOUNTDOWN"));
} }
@ -661,7 +661,7 @@ bool MainDlg::OnMessage(C4Client *pOfClient, const char *szMessage)
// 2do: log with player colors? // 2do: log with player colors?
if (pChatBox && C4GUI::GetRes()) if (pChatBox && C4GUI::GetRes())
{ {
pChatBox->AddTextLine(szMsgBuf, &C4GUI::GetRes()->TextFont, Game.Network.Players.GetClientChatColor(pOfClient ? pOfClient->getID() : Game.Clients.getLocalID(), true) | C4GUI_MessageFontAlpha, true, true); pChatBox->AddTextLine(szMsgBuf, &C4GUI::GetRes()->TextFont, ::Network.Players.GetClientChatColor(pOfClient ? pOfClient->getID() : Game.Clients.getLocalID(), true) | C4GUI_MessageFontAlpha, true, true);
pChatBox->ScrollToBottom(); pChatBox->ScrollToBottom();
} }
// log it // log it
@ -748,7 +748,7 @@ void MainDlg::OnClientAddPlayer(const char *szFilename, int32_t idClient)
return; return;
} }
// join! // join!
Game.Network.Players.JoinLocalPlayer(Config.AtRelativePath(szFilename), true); ::Network.Players.JoinLocalPlayer(Config.AtRelativePath(szFilename), true);
} }
void MainDlg::OnTabPlayers(C4GUI::Control *btn) void MainDlg::OnTabPlayers(C4GUI::Control *btn)
@ -868,7 +868,7 @@ void MainDlg::ClearLog()
void LobbyError(const char *szErrorMsg) void LobbyError(const char *szErrorMsg)
{ {
// get lobby // get lobby
MainDlg *pLobby = Game.Network.GetLobby(); MainDlg *pLobby = ::Network.GetLobby();
if (pLobby) pLobby->OnError(szErrorMsg); if (pLobby) pLobby->OnError(szErrorMsg);
} }
@ -878,12 +878,12 @@ void LobbyError(const char *szErrorMsg)
Countdown::Countdown(int32_t iStartTimer) : iStartTimer(iStartTimer) Countdown::Countdown(int32_t iStartTimer) : iStartTimer(iStartTimer)
{ {
// only on network hosts // only on network hosts
assert(Game.Network.isHost()); assert(::Network.isHost());
// ctor: Init; sends initial countdown packet // ctor: Init; sends initial countdown packet
C4PacketCountdown pck(iStartTimer); C4PacketCountdown pck(iStartTimer);
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck)); ::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck));
// also process on host // also process on host
MainDlg *pLobby = Game.Network.GetLobby(); MainDlg *pLobby = ::Network.GetLobby();
if (pLobby) if (pLobby)
{ {
pLobby->OnCountdownPacket(pck); pLobby->OnCountdownPacket(pck);
@ -914,9 +914,9 @@ void Countdown::OnSec1Timer()
!(iStartTimer % 60)) // otherwise, minute interval !(iStartTimer % 60)) // otherwise, minute interval
{ {
C4PacketCountdown pck(iStartTimer); C4PacketCountdown pck(iStartTimer);
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck)); ::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck));
// also process on host // also process on host
MainDlg *pLobby = Game.Network.GetLobby(); MainDlg *pLobby = ::Network.GetLobby();
if (pLobby) if (pLobby)
pLobby->OnCountdownPacket(pck); pLobby->OnCountdownPacket(pck);
else if (iStartTimer) else if (iStartTimer)
@ -929,25 +929,25 @@ void Countdown::OnSec1Timer()
if (!iStartTimer) if (!iStartTimer)
{ {
// Dedicated server: if there are not enough players for this game, abort and quit the application // Dedicated server: if there are not enough players for this game, abort and quit the application
if (!Game.Network.GetLobby() && (Game.PlayerInfos.GetPlayerCount() < Game.C4S.GetMinPlayer())) if (!::Network.GetLobby() && (Game.PlayerInfos.GetPlayerCount() < Game.C4S.GetMinPlayer()))
{ {
Log(LoadResStr("IDS_MSG_NOTENOUGHPLAYERSFORTHISRO")); // it would also be nice to send this message to all clients... Log(LoadResStr("IDS_MSG_NOTENOUGHPLAYERSFORTHISRO")); // it would also be nice to send this message to all clients...
Application.Quit(); Application.Quit();
} }
// Start the game // Start the game
else else
Game.Network.Start(); ::Network.Start();
} }
} }
void Countdown::Abort() void Countdown::Abort()
{ {
// host sends packets // host sends packets
if (!Game.Network.isHost()) return; if (!::Network.isHost()) return;
C4PacketCountdown pck(C4PacketCountdown::Abort); C4PacketCountdown pck(C4PacketCountdown::Abort);
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck)); ::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck));
// also process on host // also process on host
MainDlg *pLobby = Game.Network.GetLobby(); MainDlg *pLobby = ::Network.GetLobby();
if (pLobby) if (pLobby)
{ {
pLobby->OnCountdownPacket(pck); pLobby->OnCountdownPacket(pck);

View File

@ -100,7 +100,7 @@ void C4GameOptionsList::OptionControlMode::DoDropdownSelChange(int32_t idNewSele
// change possible? // change possible?
if (!Game.Control.isNetwork() || !Game.Control.Network.IsEnabled() || !Game.Control.isCtrlHost()) return; if (!Game.Control.isNetwork() || !Game.Control.Network.IsEnabled() || !Game.Control.isCtrlHost()) return;
// perform it // perform it
Game.Network.SetCtrlMode(idNewSelection); ::Network.SetCtrlMode(idNewSelection);
// update done in parent call // update done in parent call
} }
@ -154,7 +154,7 @@ void C4GameOptionsList::OptionControlRate::Update()
// ----------- C4GameOptionsList::OptionRuntimeJoin ---------------------------------------------------------------- // ----------- C4GameOptionsList::OptionRuntimeJoin ----------------------------------------------------------------
C4GameOptionsList::OptionRuntimeJoin::OptionRuntimeJoin(class C4GameOptionsList *pForDlg) C4GameOptionsList::OptionRuntimeJoin::OptionRuntimeJoin(class C4GameOptionsList *pForDlg)
: C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_NET_RUNTIMEJOIN"), !Game.Network.isHost()) : C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_NET_RUNTIMEJOIN"), !::Network.isHost())
{ {
SetToolTip(LoadResStr("IDS_NET_RUNTIMEJOIN_DESC")); SetToolTip(LoadResStr("IDS_NET_RUNTIMEJOIN_DESC"));
} }
@ -170,7 +170,7 @@ void C4GameOptionsList::OptionRuntimeJoin::DoDropdownSelChange(int32_t idNewSele
// adjust mode // adjust mode
bool fAllowed = !!idNewSelection; bool fAllowed = !!idNewSelection;
Config.Network.NoRuntimeJoin = !fAllowed; Config.Network.NoRuntimeJoin = !fAllowed;
if (Game.IsRunning) Game.Network.AllowJoin(fAllowed); if (Game.IsRunning) ::Network.AllowJoin(fAllowed);
} }
void C4GameOptionsList::OptionRuntimeJoin::Update() void C4GameOptionsList::OptionRuntimeJoin::Update()
@ -250,7 +250,7 @@ void C4GameOptionsList::InitOptions()
// creates option selection components // creates option selection components
new OptionControlMode(this); new OptionControlMode(this);
new OptionControlRate(this); new OptionControlRate(this);
if (Game.Network.isHost()) new OptionRuntimeJoin(this); if (::Network.isHost()) new OptionRuntimeJoin(this);
if (!IsRuntime()) if (!IsRuntime())
{ {
if (Game.Teams.HasTeamDistOptions()) new OptionTeamDist(this); if (Game.Teams.HasTeamDistOptions()) new OptionTeamDist(this);

View File

@ -252,7 +252,7 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
Application.Add(this); Application.Add(this);
Update(); Update();
// initial focus on quit button if visible, so space/enter/low gamepad buttons quit // initial focus on quit button if visible, so space/enter/low gamepad buttons quit
fIsQuitBtnVisible = fIsNetDone || !Game.Network.isHost(); fIsQuitBtnVisible = fIsNetDone || !::Network.isHost();
if (fIsQuitBtnVisible) SetFocus(btnExit, false); if (fIsQuitBtnVisible) SetFocus(btnExit, false);
} }
@ -268,10 +268,10 @@ void C4GameOverDlg::Update()
for (int32_t i=0; i<iPlrListCount; ++i) ppPlayerLists[i]->Update(); for (int32_t i=0; i<iPlrListCount; ++i) ppPlayerLists[i]->Update();
if (pNetResultLabel) if (pNetResultLabel)
{ {
SetNetResult(Game.RoundResults.GetNetResultString(), Game.RoundResults.GetNetResult(), Game.Network.getPendingStreamData(), Game.Network.isStreaming()); SetNetResult(Game.RoundResults.GetNetResultString(), Game.RoundResults.GetNetResult(), ::Network.getPendingStreamData(), ::Network.isStreaming());
} }
// exit/continue button only visible for host if league streaming finished // exit/continue button only visible for host if league streaming finished
bool fBtnsVisible = fIsNetDone || !Game.Network.isHost(); bool fBtnsVisible = fIsNetDone || !::Network.isHost();
if (fBtnsVisible != fIsQuitBtnVisible) if (fBtnsVisible != fIsQuitBtnVisible)
{ {
fIsQuitBtnVisible = fBtnsVisible; fIsQuitBtnVisible = fBtnsVisible;

View File

@ -290,7 +290,7 @@ bool C4GameResList::RetrieveFiles()
{ {
const C4Network2ResCore &Core = *pResList[i]->getResCore(); const C4Network2ResCore &Core = *pResList[i]->getResCore();
StdStrBuf ResNameBuf = FormatString("%s: %s", LoadResStr("IDS_DLG_DEFINITION"), GetFilename(Core.getFileName())); StdStrBuf ResNameBuf = FormatString("%s: %s", LoadResStr("IDS_DLG_DEFINITION"), GetFilename(Core.getFileName()));
if (!Game.Network.RetrieveRes(Core, C4NetResRetrieveTimeout, ResNameBuf.getData())) if (!::Network.RetrieveRes(Core, C4NetResRetrieveTimeout, ResNameBuf.getData()))
return false; return false;
} }
return true; return true;

View File

@ -294,7 +294,7 @@ void C4GameSave::WriteDescDate(StdStrBuf &sBuf, bool fRecord)
time_t tTime; time(&tTime); time_t tTime; time(&tTime);
struct tm *pLocalTime; struct tm *pLocalTime;
pLocalTime=localtime(&tTime); pLocalTime=localtime(&tTime);
sBuf.AppendFormat(LoadResStr(fRecord ? "IDS_DESC_DATEREC" : (Game.Network.isEnabled() ? "IDS_DESC_DATENET" : "IDS_DESC_DATE")), sBuf.AppendFormat(LoadResStr(fRecord ? "IDS_DESC_DATEREC" : (::Network.isEnabled() ? "IDS_DESC_DATENET" : "IDS_DESC_DATE")),
pLocalTime->tm_mday, pLocalTime->tm_mday,
pLocalTime->tm_mon+1, pLocalTime->tm_mon+1,
pLocalTime->tm_year+1900, pLocalTime->tm_year+1900,
@ -361,7 +361,7 @@ void C4GameSave::WriteDescNetworkClients(StdStrBuf &sBuf)
// Desc // Desc
sBuf.Append(LoadResStr("IDS_DESC_CLIENTS")); sBuf.Append(LoadResStr("IDS_DESC_CLIENTS"));
// Client names // Client names
for (C4Network2Client *pClient=Game.Network.Clients.GetNextClient(NULL); pClient; pClient=Game.Network.Clients.GetNextClient(pClient)) for (C4Network2Client *pClient=::Network.Clients.GetNextClient(NULL); pClient; pClient=::Network.Clients.GetNextClient(pClient))
{ sBuf.Append(", "); sBuf.Append(pClient->getName()); } { sBuf.Append(", "); sBuf.Append(pClient->getName()); }
// End of line // End of line
WriteDescLineFeed(sBuf); WriteDescLineFeed(sBuf);
@ -507,7 +507,7 @@ bool C4GameSaveSavegame::OnSaving()
// this resets playing times and stores them in the players? // this resets playing times and stores them in the players?
// but doing so would be too late when the queue is executed! // but doing so would be too late when the queue is executed!
// TODO: remove it? (-> PeterW ;)) // TODO: remove it? (-> PeterW ;))
if (Game.Network.isEnabled()) if (::Network.isEnabled())
Game.Input.Add(CID_Synchronize, new C4ControlSynchronize(TRUE)); Game.Input.Add(CID_Synchronize, new C4ControlSynchronize(TRUE));
else else
Game.Players.SynchronizeLocalFiles(); Game.Players.SynchronizeLocalFiles();
@ -542,7 +542,7 @@ bool C4GameSaveSavegame::WriteDesc(StdStrBuf &sBuf)
WriteDescDate(sBuf); WriteDescDate(sBuf);
WriteDescGameTime(sBuf); WriteDescGameTime(sBuf);
WriteDescDefinitions(sBuf); WriteDescDefinitions(sBuf);
if (Game.Network.isEnabled()) WriteDescNetworkClients(sBuf); if (::Network.isEnabled()) WriteDescNetworkClients(sBuf);
WriteDescPlayers(sBuf); WriteDescPlayers(sBuf);
// done, success // done, success
return true; return true;
@ -582,7 +582,7 @@ bool C4GameSaveRecord::WriteDesc(StdStrBuf &sBuf)
WriteDescEngine(sBuf); WriteDescEngine(sBuf);
WriteDescDefinitions(sBuf); WriteDescDefinitions(sBuf);
WriteDescLeague(sBuf, fLeague, Game.Parameters.League.getData()); WriteDescLeague(sBuf, fLeague, Game.Parameters.League.getData());
if (Game.Network.isEnabled()) WriteDescNetworkClients(sBuf); if (::Network.isEnabled()) WriteDescNetworkClients(sBuf);
WriteDescPlayers(sBuf); WriteDescPlayers(sBuf);
// done, success // done, success
return true; return true;

View File

@ -152,7 +152,7 @@ void C4GraphicsSystem::Execute()
// If lobby running, message board only (page flip done by startup message board) // If lobby running, message board only (page flip done by startup message board)
if (!Game.pGUI || !Game.pGUI->HasFullscreenDialog(true)) // allow for message board behind GUI if (!Game.pGUI || !Game.pGUI->HasFullscreenDialog(true)) // allow for message board behind GUI
if(Game.Network.isLobbyActive() || !Game.IsRunning) if(::Network.isLobbyActive() || !Game.IsRunning)
if (Application.isFullScreen) if (Application.isFullScreen)
{ {
// Message board // Message board

View File

@ -157,7 +157,7 @@ bool Log(const char *szMessage)
// Pass on to console // Pass on to console
Console.Out(szMessage); Console.Out(szMessage);
// pass on to lobby // pass on to lobby
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby(); C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
if (pLobby && Game.pGUI) pLobby->OnLog(szMessage); if (pLobby && Game.pGUI) pLobby->OnLog(szMessage);
// Add message to log buffer // Add message to log buffer

View File

@ -491,7 +491,7 @@ bool C4MainMenu::ActivateHost(int32_t iPlayer)
SetAlignment(C4MN_Align_Left | C4MN_Align_Bottom); SetAlignment(C4MN_Align_Left | C4MN_Align_Bottom);
SetPermanent(true); SetPermanent(true);
// Clients // Clients
for (C4Network2Client *pClient=Game.Network.Clients.GetNextClient(NULL); pClient; pClient=Game.Network.Clients.GetNextClient(pClient)) for (C4Network2Client *pClient=::Network.Clients.GetNextClient(NULL); pClient; pClient=::Network.Clients.GetNextClient(pClient))
{ {
bool fHost = (pClient->getID() == 0); bool fHost = (pClient->getID() == 0);
StdStrBuf strText, strCommand; StdStrBuf strText, strCommand;
@ -641,20 +641,20 @@ bool C4MainMenu::ActivateMain(int32_t iPlayer)
AddRefSym(LoadResStr("IDS_MENU_CPNEWPLAYER"),GfxR->fctPlayerClr.GetPhase(),"ActivateMenu:NewPlayer",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MENU_CPNEWPLAYERINFO")); AddRefSym(LoadResStr("IDS_MENU_CPNEWPLAYER"),GfxR->fctPlayerClr.GetPhase(),"ActivateMenu:NewPlayer",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MENU_CPNEWPLAYERINFO"));
} }
// Save game (player menu only - should we allow saving games with no players in it?) // Save game (player menu only - should we allow saving games with no players in it?)
if (pPlr && (!Game.Network.isEnabled() || Game.Network.isHost())) if (pPlr && (!::Network.isEnabled() || ::Network.isHost()))
{ {
AddRefSym(LoadResStr("IDS_MENU_CPSAVEGAME"),GfxR->fctMenu.GetPhase(0),"ActivateMenu:Save:Game",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MENU_CPSAVEGAMEINFO")); AddRefSym(LoadResStr("IDS_MENU_CPSAVEGAME"),GfxR->fctMenu.GetPhase(0),"ActivateMenu:Save:Game",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MENU_CPSAVEGAMEINFO"));
} }
// Options // Options
AddRefSym(LoadResStr("IDS_MNU_OPTIONS"), GfxR->fctOptions.GetPhase(0), "ActivateMenu:Options",C4MN_Item_NoCount, NULL, LoadResStr("IDS_MNU_OPTIONSINFO")); AddRefSym(LoadResStr("IDS_MNU_OPTIONS"), GfxR->fctOptions.GetPhase(0), "ActivateMenu:Options",C4MN_Item_NoCount, NULL, LoadResStr("IDS_MNU_OPTIONSINFO"));
// Disconnect // Disconnect
if (Game.Network.isEnabled()) if (::Network.isEnabled())
{ {
// Host // Host
if(Game.Network.isHost() && Game.Clients.getClient(NULL)) if(::Network.isHost() && Game.Clients.getClient(NULL))
AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Host", C4MN_Item_NoCount, NULL, LoadResStr("IDS_TEXT_KICKCERTAINCLIENTSFROMTHE")); AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Host", C4MN_Item_NoCount, NULL, LoadResStr("IDS_TEXT_KICKCERTAINCLIENTSFROMTHE"));
// Client // Client
if (!Game.Network.isHost()) if (!::Network.isHost())
AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Client", C4MN_Item_NoCount, NULL, LoadResStr("IDS_TEXT_DISCONNECTTHEGAMEFROMTHES")); AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Client", C4MN_Item_NoCount, NULL, LoadResStr("IDS_TEXT_DISCONNECTTHEGAMEFROMTHES"));
} }
// Surrender (player menu only) // Surrender (player menu only)
@ -716,9 +716,9 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
// not in league or replay mode // not in league or replay mode
if (Game.Parameters.isLeague() || Game.C4S.Head.Replay) return false; if (Game.Parameters.isLeague() || Game.C4S.Head.Replay) return false;
// join player // join player
if (Game.Network.isEnabled()) if (::Network.isEnabled())
// 2do: not for observers and such? // 2do: not for observers and such?
Game.Network.Players.JoinLocalPlayer(szCommand+11, true); ::Network.Players.JoinLocalPlayer(szCommand+11, true);
else else
Game.Players.CtrlJoinLocalNoNetwork(szCommand+11, Game.Clients.getLocalID(), Game.Clients.getLocalName()); Game.Players.CtrlJoinLocalNoNetwork(szCommand+11, Game.Clients.getLocalID(), Game.Clients.getLocalName());
return true; return true;
@ -760,9 +760,9 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
if (SEqual2(szCommand,"Host:Kick:")) if (SEqual2(szCommand,"Host:Kick:"))
{ {
int iClientID = atoi(szCommand+10); int iClientID = atoi(szCommand+10);
if(iClientID && Game.Network.isEnabled()) if(iClientID && ::Network.isEnabled())
if(Game.Parameters.isLeague() && Game.Players.GetAtClient(iClientID)) if(Game.Parameters.isLeague() && Game.Players.GetAtClient(iClientID))
Game.Network.Vote(VT_Kick, true, iClientID); ::Network.Vote(VT_Kick, true, iClientID);
else else
{ {
C4Client *pClient = Game.Clients.getClientByID(iClientID); C4Client *pClient = Game.Clients.getClientByID(iClientID);
@ -774,13 +774,13 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
// Part // Part
if (SEqual2(szCommand,"Part")) if (SEqual2(szCommand,"Part"))
{ {
if(Game.Network.isEnabled()) if(::Network.isEnabled())
if(Game.Parameters.isLeague() && Game.Players.GetLocalByIndex(0)) if(Game.Parameters.isLeague() && Game.Players.GetLocalByIndex(0))
Game.Network.Vote(VT_Kick, true, Game.Control.ClientID()); ::Network.Vote(VT_Kick, true, Game.Control.ClientID());
else else
{ {
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, LoadResStr("IDS_ERR_GAMELEFTVIAPLAYERMENU")); Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, LoadResStr("IDS_ERR_GAMELEFTVIAPLAYERMENU"));
Game.Network.Clear(); ::Network.Clear();
} }
return true; return true;
} }

View File

@ -446,7 +446,7 @@ bool C4MessageInput::ProcessInput(const char *szText)
bool C4MessageInput::ProcessCommand(const char *szCommand) bool C4MessageInput::ProcessCommand(const char *szCommand)
{ {
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby(); C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
// command // command
char szCmdName[C4MaxName + 1]; char szCmdName[C4MaxName + 1];
SCopyUntil(szCommand + 1, szCmdName, ' ', C4MaxName); SCopyUntil(szCommand + 1, szCmdName, ' ', C4MaxName);
@ -481,8 +481,8 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
{ {
if (!Game.IsRunning) return FALSE; if (!Game.IsRunning) return FALSE;
if (!Game.DebugMode) return FALSE; if (!Game.DebugMode) return FALSE;
if (!Game.Network.isEnabled() && !SEqual(Game.ScenarioFile.GetMaker(), Config.General.Name) && Game.ScenarioFile.GetStatus() != GRPF_Folder) return FALSE; if (!::Network.isEnabled() && !SEqual(Game.ScenarioFile.GetMaker(), Config.General.Name) && Game.ScenarioFile.GetStatus() != GRPF_Folder) return FALSE;
if (Game.Network.isEnabled() && !Game.Network.isHost()) return FALSE; if (::Network.isEnabled() && !::Network.isHost()) return FALSE;
Game.Control.DoInput(CID_Script, new C4ControlScript(pCmdPar, C4ControlScript::SCOPE_Console, false), CDT_Decide); Game.Control.DoInput(CID_Script, new C4ControlScript(pCmdPar, C4ControlScript::SCOPE_Console, false), CDT_Decide);
return TRUE; return TRUE;
@ -507,17 +507,17 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
} }
if(SEqual2(pCmdPar, "comment ") || SEqual(pCmdPar, "comment")) if(SEqual2(pCmdPar, "comment ") || SEqual(pCmdPar, "comment"))
{ {
if(!Game.Network.isEnabled() || !Game.Network.isHost()) return FALSE; if(!::Network.isEnabled() || !::Network.isHost()) return FALSE;
// Set in configuration, update reference // Set in configuration, update reference
Config.Network.Comment.CopyValidated(pCmdPar[7] ? (pCmdPar+8) : ""); Config.Network.Comment.CopyValidated(pCmdPar[7] ? (pCmdPar+8) : "");
Game.Network.InvalidateReference(); ::Network.InvalidateReference();
Log(LoadResStr("IDS_NET_COMMENTCHANGED")); Log(LoadResStr("IDS_NET_COMMENTCHANGED"));
return TRUE; return TRUE;
} }
if(SEqual2(pCmdPar, "password ") || SEqual(pCmdPar, "password")) if(SEqual2(pCmdPar, "password ") || SEqual(pCmdPar, "password"))
{ {
if(!Game.Network.isEnabled() || !Game.Network.isHost()) return FALSE; if(!::Network.isEnabled() || !::Network.isHost()) return FALSE;
Game.Network.SetPassword(pCmdPar[8] ? (pCmdPar+9) : NULL); ::Network.SetPassword(pCmdPar[8] ? (pCmdPar+9) : NULL);
if (pLobby) pLobby->UpdatePassword(); if (pLobby) pLobby->UpdatePassword();
return TRUE; return TRUE;
} }
@ -541,12 +541,12 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
// get szen from network folder - not in lobby; use res tab there // get szen from network folder - not in lobby; use res tab there
if(SEqual(szCmdName, "netgetscen")) if(SEqual(szCmdName, "netgetscen"))
{ {
if (Game.Network.isEnabled() && !Game.Network.isHost() && !pLobby) if (::Network.isEnabled() && !::Network.isHost() && !pLobby)
{ {
const C4Network2ResCore *pResCoreScen = Game.Parameters.Scenario.getResCore(); const C4Network2ResCore *pResCoreScen = Game.Parameters.Scenario.getResCore();
if (pResCoreScen) if (pResCoreScen)
{ {
C4Network2Res::Ref pScenario = Game.Network.ResList.getRefRes(pResCoreScen->getID()); C4Network2Res::Ref pScenario = ::Network.ResList.getRefRes(pResCoreScen->getID());
if (pScenario) if (pScenario)
if (C4Group_CopyItem(pScenario->getFile(), Config.AtUserDataPath(GetFilename(Game.ScenarioFilename)))) if (C4Group_CopyItem(pScenario->getFile(), Config.AtUserDataPath(GetFilename(Game.ScenarioFilename))))
{ {
@ -578,7 +578,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
// kick client // kick client
if(SEqual(szCmdName, "kick")) if(SEqual(szCmdName, "kick"))
{ {
if (Game.Network.isEnabled() && Game.Network.isHost()) if (::Network.isEnabled() && ::Network.isHost())
{ {
// find client // find client
C4Client *pClient = Game.Clients.getClientByName(pCmdPar); C4Client *pClient = Game.Clients.getClientByName(pCmdPar);
@ -589,7 +589,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
} }
// league: Kick needs voting // league: Kick needs voting
if(Game.Parameters.isLeague() && Game.Players.GetAtClient(pClient->getID())) if(Game.Parameters.isLeague() && Game.Players.GetAtClient(pClient->getID()))
Game.Network.Vote(VT_Kick, true, pClient->getID()); ::Network.Vote(VT_Kick, true, pClient->getID());
else else
// add control // add control
Game.Clients.CtrlRemove(pClient, LoadResStr("IDS_MSG_KICKFROMMSGBOARD")); Game.Clients.CtrlRemove(pClient, LoadResStr("IDS_MSG_KICKFROMMSGBOARD"));
@ -645,7 +645,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
// kick/activate/deactivate/observer // kick/activate/deactivate/observer
if(SEqual(szCmdName, "activate") || SEqual(szCmdName, "deactivate") || SEqual(szCmdName, "observer")) if(SEqual(szCmdName, "activate") || SEqual(szCmdName, "deactivate") || SEqual(szCmdName, "observer"))
{ {
if (!Game.Network.isEnabled() || !Game.Network.isHost()) if (!::Network.isEnabled() || !::Network.isHost())
{ Log(LoadResStr("IDS_MSG_CMD_HOSTONLY")); return FALSE; } { Log(LoadResStr("IDS_MSG_CMD_HOSTONLY")); return FALSE; }
// search for client // search for client
C4Client *pClient = Game.Clients.getClientByName(pCmdPar); C4Client *pClient = Game.Clients.getClientByName(pCmdPar);
@ -673,9 +673,9 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
// control mode // control mode
if(SEqual(szCmdName, "centralctrl") || SEqual(szCmdName, "decentralctrl") || SEqual(szCmdName, "asyncctrl")) if(SEqual(szCmdName, "centralctrl") || SEqual(szCmdName, "decentralctrl") || SEqual(szCmdName, "asyncctrl"))
{ {
if (!Game.Network.isEnabled() || !Game.Network.isHost()) if (!::Network.isEnabled() || !::Network.isHost())
{ Log(LoadResStr("IDS_MSG_CMD_HOSTONLY")); return FALSE; } { Log(LoadResStr("IDS_MSG_CMD_HOSTONLY")); return FALSE; }
Game.Network.SetCtrlMode(*szCmdName == 'c' ? CNM_Central : *szCmdName == 'd' ? CNM_Decentral : CNM_Async); ::Network.SetCtrlMode(*szCmdName == 'c' ? CNM_Central : *szCmdName == 'd' ? CNM_Decentral : CNM_Async);
return TRUE; return TRUE;
} }

View File

@ -574,7 +574,7 @@ void C4Network2::Execute()
{ {
// create // create
C4Network2Reference *pRef = new C4Network2Reference(); C4Network2Reference *pRef = new C4Network2Reference();
pRef->InitLocal(&Game); pRef->InitLocal();
// set // set
NetIO.SetReference(pRef); NetIO.SetReference(pRef);
iLastReferenceUpdate = time(NULL); iLastReferenceUpdate = time(NULL);
@ -1948,7 +1948,7 @@ bool C4Network2::LeagueStart(bool *pCancel)
// Do update // Do update
C4Network2Reference Ref; C4Network2Reference Ref;
Ref.InitLocal(&Game); Ref.InitLocal();
if(!pLeagueClient->Start(Ref)) if(!pLeagueClient->Start(Ref))
{ {
// Log message // Log message
@ -2093,7 +2093,7 @@ bool C4Network2::LeagueUpdate()
// Create reference // Create reference
C4Network2Reference Ref; C4Network2Reference Ref;
Ref.InitLocal(&Game); Ref.InitLocal();
// Do update // Do update
if(!pLeagueClient->Update(Ref)) if(!pLeagueClient->Update(Ref))
@ -2175,7 +2175,7 @@ bool C4Network2::LeagueEnd(const char *szRecordName, const BYTE *pRecordSHA)
// Do update // Do update
C4Network2Reference Ref; C4Network2Reference Ref;
Ref.InitLocal(&Game); Ref.InitLocal();
if(!pLeagueClient->End(Ref, szRecordName, pRecordSHA)) if(!pLeagueClient->End(Ref, szRecordName, pRecordSHA))
{ {
// Log message // Log message
@ -2674,7 +2674,7 @@ void C4VoteDialog::OnClosed(bool fOK)
{ {
bool fAbortGame = false; bool fAbortGame = false;
// notify that this object will be deleted shortly // notify that this object will be deleted shortly
Game.Network.OnVoteDialogClosed(); ::Network.OnVoteDialogClosed();
// Was league surrender dialog // Was league surrender dialog
if (fSurrender) if (fSurrender)
{ {
@ -2684,8 +2684,8 @@ void C4VoteDialog::OnClosed(bool fOK)
// set game leave reason, although round results dialog isn't showing it ATM // set game leave reason, although round results dialog isn't showing it ATM
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, LoadResStr("IDS_ERR_YOUSURRENDEREDTHELEAGUEGA")); Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, LoadResStr("IDS_ERR_YOUSURRENDEREDTHELEAGUEGA"));
// leave game // leave game
Game.Network.LeagueSurrender(); ::Network.LeagueSurrender();
Game.Network.Clear(); ::Network.Clear();
// We have just league-surrendered. Abort the game - that is what we originally wanted. // We have just league-surrendered. Abort the game - that is what we originally wanted.
// Note: as we are losing league points and this is a relevant game, it would actually be // Note: as we are losing league points and this is a relevant game, it would actually be
// nice to show an evaluation dialog which tells us that we have lost and how many league // nice to show an evaluation dialog which tells us that we have lost and how many league
@ -2700,8 +2700,8 @@ void C4VoteDialog::OnClosed(bool fOK)
else else
{ {
// Vote still active? Then vote. // Vote still active? Then vote.
if (Game.Network.GetVote(C4ClientIDUnknown, eVoteType, iVoteData)) if (::Network.GetVote(C4ClientIDUnknown, eVoteType, iVoteData))
Game.Network.Vote(eVoteType, fOK, iVoteData); ::Network.Vote(eVoteType, fOK, iVoteData);
} }
// notify base class // notify base class
MessageDialog::OnClosed(fOK); MessageDialog::OnClosed(fOK);
@ -2905,3 +2905,5 @@ bool C4Network2::isStreaming() const
// Streaming must be active and there must still be anything to stream // Streaming must be active and there must still be anything to stream
return fStreaming; return fStreaming;
} }
C4Network2 Network;

View File

@ -70,7 +70,7 @@ void C4Network2ClientDlg::UpdateText()
AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_FORMAT"), AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_FORMAT"),
strActivated.getData(), strLocal.getData(), strHost.getData(), strActivated.getData(), strLocal.getData(), strHost.getData(),
pClient->getName(), iClientID, pClient->getName(), iClientID,
Game.Network.isHost() && pNetClient && !pNetClient->isReady() ? " (!ack)" : ""); ::Network.isHost() && pNetClient && !pNetClient->isReady() ? " (!ack)" : "");
// show addresses // show addresses
int iCnt; int iCnt;
if (iCnt=pNetClient->getAddrCnt()) if (iCnt=pNetClient->getAddrCnt())
@ -94,13 +94,13 @@ void C4Network2ClientDlg::UpdateText()
{ {
AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_CONNECTIONS"), AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_CONNECTIONS"),
pNetClient->getMsgConn() == pNetClient->getDataConn() ? "Msg/Data" : "Msg", pNetClient->getMsgConn() == pNetClient->getDataConn() ? "Msg/Data" : "Msg",
Game.Network.NetIO.getNetIOName(pNetClient->getMsgConn()->getNetClass()), ::Network.NetIO.getNetIOName(pNetClient->getMsgConn()->getNetClass()),
inet_ntoa(pNetClient->getMsgConn()->getPeerAddr().sin_addr), inet_ntoa(pNetClient->getMsgConn()->getPeerAddr().sin_addr),
htons(pNetClient->getMsgConn()->getPeerAddr().sin_port), htons(pNetClient->getMsgConn()->getPeerAddr().sin_port),
pNetClient->getMsgConn()->getPingTime()); pNetClient->getMsgConn()->getPingTime());
if(pNetClient->getMsgConn() != pNetClient->getDataConn()) if(pNetClient->getMsgConn() != pNetClient->getDataConn())
AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_CONNDATA"), AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_CONNDATA"),
Game.Network.NetIO.getNetIOName(pNetClient->getDataConn()->getNetClass()), ::Network.NetIO.getNetIOName(pNetClient->getDataConn()->getNetClass()),
inet_ntoa(pNetClient->getDataConn()->getPeerAddr().sin_addr), inet_ntoa(pNetClient->getDataConn()->getPeerAddr().sin_addr),
htons(pNetClient->getDataConn()->getPeerAddr().sin_port), htons(pNetClient->getDataConn()->getPeerAddr().sin_port),
pNetClient->getDataConn()->getPingTime()); pNetClient->getDataConn()->getPingTime());
@ -146,8 +146,8 @@ C4Network2ClientListBox::ClientListItem::ClientListItem(class C4Network2ClientLi
} }
pName = new C4GUI::Label(sNameLabel.getData(), iIconSize + IconLabelSpacing,iVerticalIndent, ALeft); pName = new C4GUI::Label(sNameLabel.getData(), iIconSize + IconLabelSpacing,iVerticalIndent, ALeft);
int iPingRightPos = GetBounds().Wdt - IconLabelSpacing; int iPingRightPos = GetBounds().Wdt - IconLabelSpacing;
if (Game.Network.isHost()) iPingRightPos -= 48; if (::Network.isHost()) iPingRightPos -= 48;
if (Game.Network.isHost() && pClient && !pClient->isHost()) if (::Network.isHost() && pClient && !pClient->isHost())
{ {
// activate/deactivate and kick btns for clients at host // activate/deactivate and kick btns for clients at host
if (!pForDlg->IsStartup()) if (!pForDlg->IsStartup())
@ -265,7 +265,7 @@ void C4Network2ClientListBox::ClientListItem::OnButtonKick(C4GUI::Control *pButt
// try kick // try kick
// league: Kick needs voting // league: Kick needs voting
if(Game.Parameters.isLeague() && Game.Players.GetAtClient(iClientID)) if(Game.Parameters.isLeague() && Game.Players.GetAtClient(iClientID))
Game.Network.Vote(VT_Kick, true, iClientID); ::Network.Vote(VT_Kick, true, iClientID);
else else
Game.Clients.CtrlRemove(GetClient(), LoadResStr(pForDlg->IsStartup() ? "IDS_MSG_KICKFROMSTARTUPDLG" : "IDS_MSG_KICKFROMCLIENTLIST")); Game.Clients.CtrlRemove(GetClient(), LoadResStr(pForDlg->IsStartup() ? "IDS_MSG_KICKFROMSTARTUPDLG" : "IDS_MSG_KICKFROMCLIENTLIST"));
} }
@ -317,7 +317,7 @@ C4Network2ClientListBox::ConnectionListItem::ConnectionListItem(class C4Network2
C4Network2IOConnection *C4Network2ClientListBox::ConnectionListItem::GetConnection() const C4Network2IOConnection *C4Network2ClientListBox::ConnectionListItem::GetConnection() const
{ {
// get connection by connection ID // get connection by connection ID
C4Network2Client *pNetClient = Game.Network.Clients.GetClientByID(iClientID); C4Network2Client *pNetClient = ::Network.Clients.GetClientByID(iClientID);
if (!pNetClient) return NULL; if (!pNetClient) return NULL;
if (iConnID == 0) return pNetClient->getDataConn(); if (iConnID == 0) return pNetClient->getDataConn();
if (iConnID == 1) return pNetClient->getMsgConn(); if (iConnID == 1) return pNetClient->getMsgConn();
@ -340,7 +340,7 @@ void C4Network2ClientListBox::ConnectionListItem::Update()
// update description // update description
// get connection usage // get connection usage
const char *szConnType; const char *szConnType;
C4Network2Client *pNetClient = Game.Network.Clients.GetClientByID(iClientID); C4Network2Client *pNetClient = ::Network.Clients.GetClientByID(iClientID);
if (pNetClient->getDataConn() == pNetClient->getMsgConn()) if (pNetClient->getDataConn() == pNetClient->getMsgConn())
szConnType = "Data/Msg"; szConnType = "Data/Msg";
else if (iConnID) else if (iConnID)
@ -350,7 +350,7 @@ void C4Network2ClientListBox::ConnectionListItem::Update()
// display info // display info
pDesc->SetText(FormatString("%s: %s (%s:%d l%d)", pDesc->SetText(FormatString("%s: %s (%s:%d l%d)",
szConnType, szConnType,
Game.Network.NetIO.getNetIOName(pConn->getNetClass()), ::Network.NetIO.getNetIOName(pConn->getNetClass()),
inet_ntoa(pConn->getPeerAddr().sin_addr), inet_ntoa(pConn->getPeerAddr().sin_addr),
htons(pConn->getPeerAddr().sin_port), htons(pConn->getPeerAddr().sin_port),
pConn->getPacketLoss()).getData()); pConn->getPacketLoss()).getData());
@ -577,7 +577,7 @@ C4GameOptionButtons::C4GameOptionButtons(const C4Rect &rcBounds, bool fNetwork,
else btnLeague=NULL; else btnLeague=NULL;
if (fNetwork && fHost) if (fNetwork && fHost)
{ {
btnPassword = new C4GUI::CallbackButton<C4GameOptionButtons, C4GUI::IconButton>(Game.Network.isPassworded() ? C4GUI::Ico_Ex_Locked : C4GUI::Ico_Ex_Unlocked, caButtons.GetFromLeft(iIconSize, iIconSize), 'P' /* 2do */, &C4GameOptionButtons::OnBtnPassword, this); btnPassword = new C4GUI::CallbackButton<C4GameOptionButtons, C4GUI::IconButton>(::Network.isPassworded() ? C4GUI::Ico_Ex_Locked : C4GUI::Ico_Ex_Unlocked, caButtons.GetFromLeft(iIconSize, iIconSize), 'P' /* 2do */, &C4GameOptionButtons::OnBtnPassword, this);
btnPassword->SetToolTip(LoadResStr("IDS_NET_PASSWORD_DESC")); btnPassword->SetToolTip(LoadResStr("IDS_NET_PASSWORD_DESC"));
AddElement(btnPassword); AddElement(btnPassword);
btnComment = new C4GUI::CallbackButton<C4GameOptionButtons, C4GUI::IconButton>(C4GUI::Ico_Ex_Comment, caButtons.GetFromLeft(iIconSize, iIconSize), 'M' /* 2do */, &C4GameOptionButtons::OnBtnComment, this); btnComment = new C4GUI::CallbackButton<C4GameOptionButtons, C4GUI::IconButton>(C4GUI::Ico_Ex_Comment, caButtons.GetFromLeft(iIconSize, iIconSize), 'M' /* 2do */, &C4GameOptionButtons::OnBtnComment, this);
@ -603,11 +603,11 @@ void C4GameOptionButtons::OnBtnInternet(C4GUI::Control *btn)
{ {
if (fCheck) if (fCheck)
{ {
fCheck = Game.Network.LeagueSignupEnable(); fCheck = ::Network.LeagueSignupEnable();
} }
else else
{ {
Game.Network.LeagueSignupDisable(); ::Network.LeagueSignupDisable();
} }
} }
btnInternet->SetIcon(fCheck ? C4GUI::Ico_Ex_InternetOn : C4GUI::Ico_Ex_InternetOff); btnInternet->SetIcon(fCheck ? C4GUI::Ico_Ex_InternetOn : C4GUI::Ico_Ex_InternetOff);
@ -661,7 +661,7 @@ void C4GameOptionButtons::OnBtnPassword(C4GUI::Control *btn)
{ {
if (!fNetwork || !fHost) return; if (!fNetwork || !fHost) return;
// password is currently set - a single click only clears the password // password is currently set - a single click only clears the password
if (Game.Network.GetPassword() && *Game.Network.GetPassword()) if (::Network.GetPassword() && *::Network.GetPassword())
{ {
StdStrBuf empty; StdStrBuf empty;
OnPasswordSet(empty); OnPasswordSet(empty);
@ -671,7 +671,7 @@ void C4GameOptionButtons::OnBtnPassword(C4GUI::Control *btn)
C4GUI::InputDialog *pDlg; C4GUI::InputDialog *pDlg;
GetScreen()->ShowRemoveDlg(pDlg=new C4GUI::InputDialog(LoadResStr("IDS_MSG_ENTERPASSWORD"), LoadResStr("IDS_DLG_PASSWORD"), C4GUI::Ico_Ex_LockedFrontal, new C4GUI::InputCallback<C4GameOptionButtons>(this, &C4GameOptionButtons::OnPasswordSet), false)); GetScreen()->ShowRemoveDlg(pDlg=new C4GUI::InputDialog(LoadResStr("IDS_MSG_ENTERPASSWORD"), LoadResStr("IDS_DLG_PASSWORD"), C4GUI::Ico_Ex_LockedFrontal, new C4GUI::InputCallback<C4GameOptionButtons>(this, &C4GameOptionButtons::OnPasswordSet), false));
pDlg->SetMaxText(CFG_MaxString); pDlg->SetMaxText(CFG_MaxString);
const char *szPassPreset = Game.Network.GetPassword(); const char *szPassPreset = ::Network.GetPassword();
if (!szPassPreset || !*szPassPreset) szPassPreset = Config.Network.LastPassword; if (!szPassPreset || !*szPassPreset) szPassPreset = Config.Network.LastPassword;
if (*szPassPreset) pDlg->SetInputText(szPassPreset); if (*szPassPreset) pDlg->SetInputText(szPassPreset);
} }
@ -680,7 +680,7 @@ void C4GameOptionButtons::OnPasswordSet(const StdStrBuf &rsNewPassword)
{ {
// password input dialog answered with OK: Set/clear network password // password input dialog answered with OK: Set/clear network password
const char *szPass; const char *szPass;
Game.Network.SetPassword(szPass=rsNewPassword.getData()); ::Network.SetPassword(szPass=rsNewPassword.getData());
// update icon to reflect if a password is set // update icon to reflect if a password is set
UpdatePasswordBtn(); UpdatePasswordBtn();
// remember password for next round // remember password for next round
@ -696,7 +696,7 @@ void C4GameOptionButtons::OnPasswordSet(const StdStrBuf &rsNewPassword)
void C4GameOptionButtons::UpdatePasswordBtn() void C4GameOptionButtons::UpdatePasswordBtn()
{ {
// update icon to reflect if a password is set // update icon to reflect if a password is set
const char *szPass = Game.Network.GetPassword(); const char *szPass = ::Network.GetPassword();
bool fHasPassword = szPass && *szPass; bool fHasPassword = szPass && *szPass;
//btnPassword->SetHighlight(fHasPassword); //btnPassword->SetHighlight(fHasPassword);
btnPassword->SetIcon(fHasPassword ? C4GUI::Ico_Ex_Locked : C4GUI::Ico_Ex_Unlocked); btnPassword->SetIcon(fHasPassword ? C4GUI::Ico_Ex_Locked : C4GUI::Ico_Ex_Unlocked);
@ -717,7 +717,7 @@ void C4GameOptionButtons::OnCommentSet(const StdStrBuf &rsNewComment)
if (rsNewComment == Config.Network.Comment) return; if (rsNewComment == Config.Network.Comment) return;
// Set in configuration, update reference // Set in configuration, update reference
Config.Network.Comment.CopyValidated(rsNewComment.getData()); Config.Network.Comment.CopyValidated(rsNewComment.getData());
Game.Network.InvalidateReference(); ::Network.InvalidateReference();
// message feedback // message feedback
Log(LoadResStr("IDS_NET_COMMENTCHANGED")); Log(LoadResStr("IDS_NET_COMMENTCHANGED"));
// acoustic feedback // acoustic feedback
@ -926,7 +926,7 @@ C4ChartDialog::C4ChartDialog() : Dialog(DialogWidth, DialogHeight, LoadResStr("I
AddChart(StdStrBuf("oc")); AddChart(StdStrBuf("oc"));
AddChart(StdStrBuf("FPS")); AddChart(StdStrBuf("FPS"));
AddChart(StdStrBuf("NetIO")); AddChart(StdStrBuf("NetIO"));
if (Game.Network.isEnabled()) if (::Network.isEnabled())
AddChart(StdStrBuf("Pings")); AddChart(StdStrBuf("Pings"));
AddChart(StdStrBuf("Control")); AddChart(StdStrBuf("Control"));
AddChart(StdStrBuf("APM")); AddChart(StdStrBuf("APM"));

View File

@ -628,7 +628,7 @@ bool C4Network2IO::Execute(int iTimeout, pollfd *)
} }
// ressources // ressources
Game.Network.ResList.OnTimer(); ::Network.ResList.OnTimer();
// ok // ok
return true; return true;
@ -647,7 +647,7 @@ void C4Network2IO::OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData
{ {
C4Network2IOConnection *pConn = reinterpret_cast<C4Network2IOConnection *>(pEventData); C4Network2IOConnection *pConn = reinterpret_cast<C4Network2IOConnection *>(pEventData);
// do callback // do callback
Game.Network.OnConn(pConn); ::Network.OnConn(pConn);
// remove reference // remove reference
pConn->DelRef(); pConn->DelRef();
} }
@ -658,7 +658,7 @@ void C4Network2IO::OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData
C4Network2IOConnection *pConn = reinterpret_cast<C4Network2IOConnection *>(pEventData); C4Network2IOConnection *pConn = reinterpret_cast<C4Network2IOConnection *>(pEventData);
assert(pConn->isClosed()); assert(pConn->isClosed());
// do callback // do callback
Game.Network.OnDisconn(pConn); ::Network.OnDisconn(pConn);
// remove reference // remove reference
pConn->DelRef(); pConn->DelRef();
} }
@ -902,31 +902,31 @@ void C4Network2IO::CallHandlers(int iHandlerID, const C4IDPacket *pPkt, C4Networ
if(iHandlerID & PH_C4Network2) if(iHandlerID & PH_C4Network2)
{ {
assert(!fThread); assert(!fThread);
Game.Network.HandlePacket(cStatus, pPacket, pConn); ::Network.HandlePacket(cStatus, pPacket, pConn);
} }
// fullscreen lobby // fullscreen lobby
if(iHandlerID & PH_C4GUIMainDlg) if(iHandlerID & PH_C4GUIMainDlg)
{ {
assert(!fThread); assert(!fThread);
Game.Network.HandleLobbyPacket(cStatus, pPacket, pConn); ::Network.HandleLobbyPacket(cStatus, pPacket, pConn);
} }
// client list class (main thread) // client list class (main thread)
if(iHandlerID & PH_C4Network2ClientList) if(iHandlerID & PH_C4Network2ClientList)
{ {
assert(!fThread); assert(!fThread);
Game.Network.Clients.HandlePacket(cStatus, pPacket, pConn); ::Network.Clients.HandlePacket(cStatus, pPacket, pConn);
} }
// player list class (main thread) // player list class (main thread)
if(iHandlerID & PH_C4Network2Players) if(iHandlerID & PH_C4Network2Players)
{ {
assert(!fThread); assert(!fThread);
Game.Network.Players.HandlePacket(cStatus, pPacket, pConn); ::Network.Players.HandlePacket(cStatus, pPacket, pConn);
} }
// ressource list class (network thread) // ressource list class (network thread)
if(iHandlerID & PH_C4Network2ResList) if(iHandlerID & PH_C4Network2ResList)
{ {
assert(fThread); assert(fThread);
Game.Network.ResList.HandlePacket(cStatus, pPacket, pConn); ::Network.ResList.HandlePacket(cStatus, pPacket, pConn);
} }
// network control (mixed) // network control (mixed)
if(iHandlerID & PH_C4GameControlNetwork) if(iHandlerID & PH_C4GameControlNetwork)
@ -1262,10 +1262,10 @@ void C4Network2IO::OnPunch(C4NetIO::addr_t addr)
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
ZeroMem(addr.sin_zero, sizeof(addr.sin_zero)); ZeroMem(addr.sin_zero, sizeof(addr.sin_zero));
// Add for local client // Add for local client
C4Network2Client *pLocal = Game.Network.Clients.GetLocal(); C4Network2Client *pLocal = ::Network.Clients.GetLocal();
if(pLocal) if(pLocal)
if(pLocal->AddAddr(C4Network2Address(addr, P_UDP), true)) if(pLocal->AddAddr(C4Network2Address(addr, P_UDP), true))
Game.Network.InvalidateReference(); ::Network.InvalidateReference();
} }
// *** C4Network2IOConnection // *** C4Network2IOConnection

View File

@ -42,13 +42,13 @@ void C4Network2Players::Init()
// not in replay // not in replay
if (Game.C4S.Head.Replay) return; if (Game.C4S.Head.Replay) return;
// network only // network only
assert(Game.Network.isEnabled()); assert(::Network.isEnabled());
// must init before game is running // must init before game is running
assert(!Game.IsRunning); assert(!Game.IsRunning);
// join the local player(s) // join the local player(s)
JoinLocalPlayer(Game.PlayerFilenames, false); JoinLocalPlayer(Game.PlayerFilenames, false);
// host: Rejoin script players from savegame // host: Rejoin script players from savegame
if (Game.Network.isHost()) if (::Network.isHost())
Game.PlayerInfos.CreateRestoreInfosForJoinedScriptPlayers(Game.RestorePlayerInfos); Game.PlayerInfos.CreateRestoreInfosForJoinedScriptPlayers(Game.RestorePlayerInfos);
} }
@ -66,7 +66,7 @@ bool C4Network2Players::JoinLocalPlayer(const char *szLocalPlayerFilename, bool
// if observing: don't try // if observing: don't try
if (Game.Clients.getLocal()->isObserver()) return false; if (Game.Clients.getLocal()->isObserver()) return false;
// network only // network only
assert(Game.Network.isEnabled()); assert(::Network.isEnabled());
// create join info packet // create join info packet
C4ClientPlayerInfos JoinInfo(szLocalPlayerFilename, fAdd); C4ClientPlayerInfos JoinInfo(szLocalPlayerFilename, fAdd);
// league game: get authentication for players // league game: get authentication for players
@ -74,14 +74,14 @@ bool C4Network2Players::JoinLocalPlayer(const char *szLocalPlayerFilename, bool
for(int i = 0; i < JoinInfo.GetPlayerCount(); i++) for(int i = 0; i < JoinInfo.GetPlayerCount(); i++)
{ {
C4PlayerInfo *pInfo = JoinInfo.GetPlayerInfo(i); C4PlayerInfo *pInfo = JoinInfo.GetPlayerInfo(i);
if(!Game.Network.LeaguePlrAuth(pInfo)) if(!::Network.LeaguePlrAuth(pInfo))
{ {
JoinInfo.RemoveIndexedInfo(i); JoinInfo.RemoveIndexedInfo(i);
i--; i--;
} }
} }
// host or client? // host or client?
if (Game.Network.isHost()) if (::Network.isHost())
{ {
// error joining players? Zero players is OK for initial packet; marks host as observer // error joining players? Zero players is OK for initial packet; marks host as observer
if (fAdd && !JoinInfo.GetPlayerCount()) return false; if (fAdd && !JoinInfo.GetPlayerCount()) return false;
@ -97,10 +97,10 @@ bool C4Network2Players::JoinLocalPlayer(const char *szLocalPlayerFilename, bool
// it's also necessary to send the empty player info packet, so the host will answer // it's also necessary to send the empty player info packet, so the host will answer
// with infos of all other clients // with infos of all other clients
if (fAdd && !JoinRequest.Info.GetPlayerCount()) return false; if (fAdd && !JoinRequest.Info.GetPlayerCount()) return false;
Game.Network.Clients.SendMsgToHost(MkC4NetIOPacket(PID_PlayerInfoUpdReq, JoinRequest)); ::Network.Clients.SendMsgToHost(MkC4NetIOPacket(PID_PlayerInfoUpdReq, JoinRequest));
// request activation // request activation
if(JoinRequest.Info.GetPlayerCount() && !Game.Clients.getLocal()->isActivated()) if(JoinRequest.Info.GetPlayerCount() && !Game.Clients.getLocal()->isActivated())
Game.Network.RequestActivate(); ::Network.RequestActivate();
} }
// done, success // done, success
return true; return true;
@ -109,9 +109,9 @@ bool C4Network2Players::JoinLocalPlayer(const char *szLocalPlayerFilename, bool
void C4Network2Players::RequestPlayerInfoUpdate(const class C4ClientPlayerInfos &rRequest) void C4Network2Players::RequestPlayerInfoUpdate(const class C4ClientPlayerInfos &rRequest)
{ {
// network only // network only
assert(Game.Network.isEnabled()); assert(::Network.isEnabled());
// host or client? // host or client?
if (Game.Network.isHost()) if (::Network.isHost())
{ {
// host processes directly // host processes directly
HandlePlayerInfoUpdRequest(&rRequest, true); HandlePlayerInfoUpdRequest(&rRequest, true);
@ -120,15 +120,15 @@ void C4Network2Players::RequestPlayerInfoUpdate(const class C4ClientPlayerInfos
{ {
// client sends request to host // client sends request to host
C4PacketPlayerInfoUpdRequest UpdateRequest(rRequest); C4PacketPlayerInfoUpdRequest UpdateRequest(rRequest);
Game.Network.Clients.SendMsgToHost(MkC4NetIOPacket(PID_PlayerInfoUpdReq, UpdateRequest)); ::Network.Clients.SendMsgToHost(MkC4NetIOPacket(PID_PlayerInfoUpdReq, UpdateRequest));
} }
} }
void C4Network2Players::HandlePlayerInfoUpdRequest(const class C4ClientPlayerInfos *pInfoPacket, bool fByHost) void C4Network2Players::HandlePlayerInfoUpdRequest(const class C4ClientPlayerInfos *pInfoPacket, bool fByHost)
{ {
// network host only // network host only
assert(Game.Network.isEnabled()); assert(::Network.isEnabled());
assert(Game.Network.isHost()); assert(::Network.isHost());
// copy client infos (need to be adjusted) // copy client infos (need to be adjusted)
C4ClientPlayerInfos OwnInfoPacket(*pInfoPacket); C4ClientPlayerInfos OwnInfoPacket(*pInfoPacket);
// safety: check any duplicate, unjoined players first // safety: check any duplicate, unjoined players first
@ -182,7 +182,7 @@ void C4Network2Players::HandlePlayerInfoUpdRequest(const class C4ClientPlayerInf
if (Game.Parameters.isLeague()) if (Game.Parameters.isLeague())
{ {
// lobby only // lobby only
if(!Game.Network.isLobbyActive()) if(!::Network.isLobbyActive())
return; return;
// check league authentication for new players // check league authentication for new players
for(int i = 0; i < OwnInfoPacket.GetPlayerCount(); i++) for(int i = 0; i < OwnInfoPacket.GetPlayerCount(); i++)
@ -190,7 +190,7 @@ void C4Network2Players::HandlePlayerInfoUpdRequest(const class C4ClientPlayerInf
{ {
C4PlayerInfo *pInfo = OwnInfoPacket.GetPlayerInfo(i); C4PlayerInfo *pInfo = OwnInfoPacket.GetPlayerInfo(i);
// remove player infos without authentication // remove player infos without authentication
if(!Game.Network.LeaguePlrAuthCheck(pInfo)) if(!::Network.LeaguePlrAuthCheck(pInfo))
{ {
OwnInfoPacket.RemoveIndexedInfo(i); OwnInfoPacket.RemoveIndexedInfo(i);
i--; i--;
@ -209,14 +209,14 @@ void C4Network2Players::HandlePlayerInfoUpdRequest(const class C4ClientPlayerInf
// in running mode, this call will also put the actual player joins into the queue // in running mode, this call will also put the actual player joins into the queue
Game.Control.DoInput(CID_PlrInfo, new C4ControlPlayerInfo(OwnInfoPacket), CDT_Direct); Game.Control.DoInput(CID_PlrInfo, new C4ControlPlayerInfo(OwnInfoPacket), CDT_Direct);
// notify lobby of updates // notify lobby of updates
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby(); C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
if (pLobby) pLobby->OnPlayersChange(); if (pLobby) pLobby->OnPlayersChange();
} }
void C4Network2Players::HandlePlayerInfo(const class C4ClientPlayerInfos &rInfoPacket) void C4Network2Players::HandlePlayerInfo(const class C4ClientPlayerInfos &rInfoPacket)
{ {
// network only // network only
assert(Game.Network.isEnabled()); assert(::Network.isEnabled());
// copy client player infos out of packet to be used in local list // copy client player infos out of packet to be used in local list
C4ClientPlayerInfos *pClientInfo = new C4ClientPlayerInfos(rInfoPacket); C4ClientPlayerInfos *pClientInfo = new C4ClientPlayerInfos(rInfoPacket);
// add client info to local player info list - eventually deleting pClientInfo and // add client info to local player info list - eventually deleting pClientInfo and
@ -232,17 +232,17 @@ void C4Network2Players::HandlePlayerInfo(const class C4ClientPlayerInfos &rInfoP
{ {
const C4Client *pClient = Game.Clients.getClientByID(pClientInfo->GetClientID()); const C4Client *pClient = Game.Clients.getClientByID(pClientInfo->GetClientID());
// host, game running and client active already? // host, game running and client active already?
if (Game.Network.isHost() && Game.Network.isRunning() && pClient && pClient->isActivated()) if (::Network.isHost() && ::Network.isRunning() && pClient && pClient->isActivated())
{ {
// then join the players immediately // then join the players immediately
JoinUnjoinedPlayersInControlQueue(pClientInfo); JoinUnjoinedPlayersInControlQueue(pClientInfo);
} }
} }
// lobby: update players // lobby: update players
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby(); C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
if (pLobby) pLobby->OnPlayersChange(); if (pLobby) pLobby->OnPlayersChange();
// invalidate reference // invalidate reference
Game.Network.InvalidateReference(); ::Network.InvalidateReference();
} }
void C4Network2Players::SendUpdatedPlayers() void C4Network2Players::SendUpdatedPlayers()
@ -320,7 +320,7 @@ void C4Network2Players::ResetUpdatedPlayers()
void C4Network2Players::JoinUnjoinedPlayersInControlQueue(C4ClientPlayerInfos *pNewPacket) void C4Network2Players::JoinUnjoinedPlayersInControlQueue(C4ClientPlayerInfos *pNewPacket)
{ {
// only host may join any players to the queue // only host may join any players to the queue
assert(Game.Network.isHost()); assert(::Network.isHost());
// check all players // check all players
int i=0; C4PlayerInfo *pInfo; int i=0; C4PlayerInfo *pInfo;
while (pInfo = pNewPacket->GetPlayerInfo(i++)) while (pInfo = pNewPacket->GetPlayerInfo(i++))
@ -332,7 +332,7 @@ void C4Network2Players::JoinUnjoinedPlayersInControlQueue(C4ClientPlayerInfos *p
pInfo->SetJoinIssued(); pInfo->SetJoinIssued();
// do so! // do so!
C4Network2Res *pPlrRes = pInfo->GetRes(); C4Network2Res *pPlrRes = pInfo->GetRes();
C4Network2Client *pClient = Game.Network.Clients.GetClientByID(pNewPacket->GetClientID()); C4Network2Client *pClient = ::Network.Clients.GetClientByID(pNewPacket->GetClientID());
if (!pPlrRes || (!pClient && pNewPacket->GetClientID() != Game.Control.ClientID())) if (!pPlrRes || (!pClient && pNewPacket->GetClientID() != Game.Control.ClientID()))
if (pInfo->GetType() != C4PT_Script) if (pInfo->GetType() != C4PT_Script)
{ {
@ -361,8 +361,8 @@ void C4Network2Players::HandlePacket(char cStatus, const C4PacketBase *pPacket,
if(!pConn) return; if(!pConn) return;
// find associated client // find associated client
C4Network2Client *pClient = Game.Network.Clients.GetClient(pConn); C4Network2Client *pClient = ::Network.Clients.GetClient(pConn);
if(!pClient) pClient = Game.Network.Clients.GetClientByID(pConn->getClientID()); if(!pClient) pClient = ::Network.Clients.GetClientByID(pConn->getClientID());
#define GETPKT(type, name) \ #define GETPKT(type, name) \
assert(pPacket); const type &name = \ assert(pPacket); const type &name = \
@ -373,7 +373,7 @@ void C4Network2Players::HandlePacket(char cStatus, const C4PacketBase *pPacket,
{ {
GETPKT(C4PacketPlayerInfoUpdRequest, pkPlrInfo); GETPKT(C4PacketPlayerInfoUpdRequest, pkPlrInfo);
// this packet is sent to the host only, and thus cannot have been sent from the host // this packet is sent to the host only, and thus cannot have been sent from the host
if(!Game.Network.isHost()) return; if(!::Network.isHost()) return;
// handle this packet // handle this packet
HandlePlayerInfoUpdRequest(&pkPlrInfo.Info, false); HandlePlayerInfoUpdRequest(&pkPlrInfo.Info, false);
} }
@ -413,7 +413,7 @@ void C4Network2Players::OnClientPart(C4Client *pPartClient)
// update team association to left player // update team association to left player
Game.Teams.RecheckPlayers(); Game.Teams.RecheckPlayers();
// host: update player data according to leaver // host: update player data according to leaver
if (Game.Network.isHost() && Game.Network.isEnabled()) if (::Network.isHost() && ::Network.isEnabled())
{ {
// host: update any player colors and names // host: update any player colors and names
rInfoList.UpdatePlayerAttributes(); rInfoList.UpdatePlayerAttributes();
@ -425,14 +425,14 @@ void C4Network2Players::OnClientPart(C4Client *pPartClient)
SendUpdatedPlayers(); SendUpdatedPlayers();
} }
// invalidate reference // invalidate reference
if(Game.Network.isHost()) if(::Network.isHost())
Game.Network.InvalidateReference(); ::Network.InvalidateReference();
} }
void C4Network2Players::OnStatusGoReached() void C4Network2Players::OnStatusGoReached()
{ {
// host only // host only
if (!Game.Network.isHost()) return; if (!::Network.isHost()) return;
// check all player lists // check all player lists
int i=0; C4ClientPlayerInfos *pkInfo; int i=0; C4ClientPlayerInfos *pkInfo;
while (pkInfo = rInfoList.GetIndexedInfo(i++)) while (pkInfo = rInfoList.GetIndexedInfo(i++))

View File

@ -50,10 +50,10 @@ void C4Network2Reference::SetSourceIP(in_addr ip)
} }
#ifdef C4ENGINE #ifdef C4ENGINE
void C4Network2Reference::InitLocal(C4Game *pGame) void C4Network2Reference::InitLocal()
{ {
// Copy all game parameters // Copy all game parameters
Parameters = pGame->Parameters; Parameters = ::Game.Parameters;
// Discard player resources (we don't want these infos in the reference) // Discard player resources (we don't want these infos in the reference)
C4ClientPlayerInfos *pClientInfos; C4PlayerInfo *pPlayerInfo; C4ClientPlayerInfos *pClientInfos; C4PlayerInfo *pPlayerInfo;
@ -63,22 +63,22 @@ void C4Network2Reference::InitLocal(C4Game *pGame)
pPlayerInfo->DiscardResource(); pPlayerInfo->DiscardResource();
// Special additional information in reference // Special additional information in reference
Icon = pGame->C4S.Head.Icon; Icon = ::Game.C4S.Head.Icon;
Title.CopyValidated(pGame->ScenarioTitle); Title.CopyValidated(::Game.ScenarioTitle);
GameStatus = pGame->Network.Status; GameStatus = ::Network.Status;
Time = pGame->Time; Time = ::Game.Time;
Frame = pGame->FrameCounter; Frame = ::Game.FrameCounter;
StartTime = pGame->StartTime; StartTime = ::Game.StartTime;
LeaguePerformance = pGame->RoundResults.GetLeaguePerformance(); LeaguePerformance = ::Game.RoundResults.GetLeaguePerformance();
Comment = Config.Network.Comment; Comment = Config.Network.Comment;
JoinAllowed = pGame->Network.isJoinAllowed(); JoinAllowed = ::Network.isJoinAllowed();
ObservingAllowed = pGame->Network.isObservingAllowed(); ObservingAllowed = ::Network.isObservingAllowed();
PasswordNeeded = pGame->Network.isPassworded(); PasswordNeeded = ::Network.isPassworded();
RegJoinOnly = pGame->RegJoinOnly; RegJoinOnly = ::Game.RegJoinOnly;
Game.Set(); Game.Set();
// Addresses // Addresses
C4Network2Client *pLocalNetClient = pGame->Clients.getLocal()->getNetClient(); C4Network2Client *pLocalNetClient = ::Game.Clients.getLocal()->getNetClient();
iAddrCnt = pLocalNetClient->getAddrCnt(); iAddrCnt = pLocalNetClient->getAddrCnt();
for(i = 0; i < iAddrCnt; i++) for(i = 0; i < iAddrCnt; i++)
Addrs[i] = pLocalNetClient->getAddr(i); Addrs[i] = pLocalNetClient->getAddr(i);

View File

@ -136,7 +136,7 @@ void C4Network2ResDlg::ListItem::LocalSaveResource(bool fDoOverwrite)
C4Network2Res::Ref C4Network2ResDlg::ListItem::GetRefRes() C4Network2Res::Ref C4Network2ResDlg::ListItem::GetRefRes()
{ {
// forward to network reslist // forward to network reslist
return Game.Network.ResList.getRefRes(iResID); return ::Network.ResList.getRefRes(iResID);
} }
bool C4Network2ResDlg::ListItem::IsSavePossible() bool C4Network2ResDlg::ListItem::IsSavePossible()
@ -189,7 +189,7 @@ void C4Network2ResDlg::Update()
// check through own resources and current res list // check through own resources and current res list
ListItem *pItem = static_cast<ListItem *>(pClientWindow->GetFirst()), *pNext; ListItem *pItem = static_cast<ListItem *>(pClientWindow->GetFirst()), *pNext;
C4Network2Res *pRes; int iResID=-1; C4Network2Res *pRes; int iResID=-1;
while (pRes = Game.Network.ResList.getRefNextRes(++iResID)) while (pRes = ::Network.ResList.getRefNextRes(++iResID))
{ {
iResID = pRes->getResID(); iResID = pRes->getResID();
// resource checking: deleted ressource(s) present? // resource checking: deleted ressource(s) present?

View File

@ -324,14 +324,14 @@ C4Network2Stats::C4Network2Stats()
statActions.SetAverageTime(100); statActions.SetAverageTime(100);
for (C4Player *pPlr = Game.Players.First; pPlr; pPlr = pPlr->Next) pPlr->CreateGraphs(); for (C4Player *pPlr = Game.Players.First; pPlr; pPlr = pPlr->Next) pPlr->CreateGraphs();
C4Network2Client *pClient = NULL; C4Network2Client *pClient = NULL;
while (pClient = Game.Network.Clients.GetNextClient(pClient)) pClient->CreateGraphs(); while (pClient = ::Network.Clients.GetNextClient(pClient)) pClient->CreateGraphs();
} }
C4Network2Stats::~C4Network2Stats() C4Network2Stats::~C4Network2Stats()
{ {
for (C4Player *pPlr = Game.Players.First; pPlr; pPlr = pPlr->Next) pPlr->ClearGraphs(); for (C4Player *pPlr = Game.Players.First; pPlr; pPlr = pPlr->Next) pPlr->ClearGraphs();
C4Network2Client *pClient = NULL; C4Network2Client *pClient = NULL;
while (pClient = Game.Network.Clients.GetNextClient(pClient)) pClient->ClearGraphs(); while (pClient = ::Network.Clients.GetNextClient(pClient)) pClient->ClearGraphs();
Application.Remove(this); Application.Remove(this);
} }
@ -343,11 +343,11 @@ void C4Network2Stats::ExecuteFrame()
void C4Network2Stats::ExecuteSecond() void C4Network2Stats::ExecuteSecond()
{ {
statFPS.RecordValue(C4Graph::ValueType(Game.FPS)); statFPS.RecordValue(C4Graph::ValueType(Game.FPS));
statNetI.RecordValue(C4Graph::ValueType(Game.Network.NetIO.getProtIRate(P_TCP) + Game.Network.NetIO.getProtIRate(P_UDP))); statNetI.RecordValue(C4Graph::ValueType(::Network.NetIO.getProtIRate(P_TCP) + ::Network.NetIO.getProtIRate(P_UDP)));
statNetO.RecordValue(C4Graph::ValueType(Game.Network.NetIO.getProtORate(P_TCP) + Game.Network.NetIO.getProtORate(P_UDP))); statNetO.RecordValue(C4Graph::ValueType(::Network.NetIO.getProtORate(P_TCP) + ::Network.NetIO.getProtORate(P_UDP)));
// pings for all clients // pings for all clients
C4Network2Client *pClient = NULL; C4Network2Client *pClient = NULL;
while (pClient = Game.Network.Clients.GetNextClient(pClient)) if (pClient->getStatPing()) while (pClient = ::Network.Clients.GetNextClient(pClient)) if (pClient->getStatPing())
{ {
int iPing=0; int iPing=0;
C4Network2IOConnection *pConn = pClient->getMsgConn(); C4Network2IOConnection *pConn = pClient->getMsgConn();

View File

@ -435,7 +435,7 @@ BOOL C4Player::Save()
// Close group // Close group
if (!hGroup.Close()) return FALSE; if (!hGroup.Close()) return FALSE;
// resource // resource
C4Network2Res::Ref pRes = Game.Network.ResList.getRefRes(Filename), C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(Filename),
pDRes = NULL; pDRes = NULL;
bool fOfficial = pRes && Game.Control.isCtrlHost(); bool fOfficial = pRes && Game.Control.isCtrlHost();
if(pRes) pDRes = pRes->Derive(); if(pRes) pDRes = pRes->Derive();

View File

@ -93,14 +93,14 @@ bool C4PlayerInfo::LoadFromLocalFile(const char *szFilename)
dwColor = dwOriginalColor = C4P.PrefColorDw & 0xffffff; // ignore alpha dwColor = dwOriginalColor = C4P.PrefColorDw & 0xffffff; // ignore alpha
dwAlternateColor = C4P.PrefColor2Dw & 0xffffff; // ignore alpha dwAlternateColor = C4P.PrefColor2Dw & 0xffffff; // ignore alpha
// network: ressource (not for replays, because everyone has the player files there...) // network: ressource (not for replays, because everyone has the player files there...)
if (Game.Network.isEnabled() && !Game.C4S.Head.Replay) if (::Network.isEnabled() && !Game.C4S.Head.Replay)
{ {
// add ressource // add ressource
// 2do: rejoining players need to update their ressource version when saving the player // 2do: rejoining players need to update their ressource version when saving the player
// otherwise, player file versions may differ // otherwise, player file versions may differ
pRes = Game.Network.ResList.getRefRes(szFilename, true); pRes = ::Network.ResList.getRefRes(szFilename, true);
// not found? add // not found? add
if(!pRes) pRes = Game.Network.ResList.AddByGroup(&Grp, false, NRT_Player, -1, szFilename); if(!pRes) pRes = ::Network.ResList.AddByGroup(&Grp, false, NRT_Player, -1, szFilename);
if(!pRes) return false; if(!pRes) return false;
// set core and flag // set core and flag
ResCore = pRes->getCore(); ResCore = pRes->getCore();
@ -300,7 +300,7 @@ void C4PlayerInfo::LoadResource()
dwFlags &= ~PIF_HasRes; dwFlags &= ~PIF_HasRes;
else else
// create resource (will check if resource already exists) // create resource (will check if resource already exists)
if (!(pRes = Game.Network.ResList.AddByCore(ResCore))) if (!(pRes = ::Network.ResList.AddByCore(ResCore)))
{ {
dwFlags &= ~PIF_HasRes; dwFlags &= ~PIF_HasRes;
// add failed? invalid ressource??! -- TODO: may be too large to load // add failed? invalid ressource??! -- TODO: may be too large to load
@ -752,7 +752,7 @@ bool C4PlayerInfoList::DoPlayerInfoUpdate(C4ClientPlayerInfos *pUpdate)
// in network game, process by host. In offline game, just create control // in network game, process by host. In offline game, just create control
bool fSucc = true; bool fSucc = true;
if (Game.Control.isNetwork()) if (Game.Control.isNetwork())
Game.Network.Players.RequestPlayerInfoUpdate(*pUpdate); ::Network.Players.RequestPlayerInfoUpdate(*pUpdate);
else else
fSucc = DoLocalNonNetworkPlayerInfoUpdate(pUpdate); fSucc = DoLocalNonNetworkPlayerInfoUpdate(pUpdate);
return fSucc; return fSucc;
@ -880,7 +880,7 @@ C4ClientPlayerInfos *C4PlayerInfoList::AddInfo(C4ClientPlayerInfos *pNewClientIn
// caution: also called for RestorePlayerInfos-list // caution: also called for RestorePlayerInfos-list
// host: reserve new IDs for all players // host: reserve new IDs for all players
// client: all IDs should be assigned already by host // client: all IDs should be assigned already by host
if (Game.Network.isHost() || !Game.Network.isEnabled()) if (::Network.isHost() || !::Network.isEnabled())
{ {
if (!AssignPlayerIDs(pNewClientInfo) && pNewClientInfo->IsAddPacket()) if (!AssignPlayerIDs(pNewClientInfo) && pNewClientInfo->IsAddPacket())
{ {
@ -1317,7 +1317,7 @@ bool C4PlayerInfoList::InitLocal()
// no double init // no double init
assert(!GetInfoCount()); assert(!GetInfoCount());
// no network // no network
assert(!Game.Network.isEnabled()); assert(!::Network.isEnabled());
// create player info for local player joins // create player info for local player joins
C4ClientPlayerInfos *pLocalInfo = new C4ClientPlayerInfos(Game.PlayerFilenames); C4ClientPlayerInfos *pLocalInfo = new C4ClientPlayerInfos(Game.PlayerFilenames);
// register local info immediately // register local info immediately
@ -1334,7 +1334,7 @@ bool C4PlayerInfoList::InitLocal()
bool C4PlayerInfoList::LocalJoinUnjoinedPlayersInQueue() bool C4PlayerInfoList::LocalJoinUnjoinedPlayersInQueue()
{ {
// local call only - in network, C4Network2Players joins players! // local call only - in network, C4Network2Players joins players!
assert(!Game.Network.isEnabled()); assert(!::Network.isEnabled());
// get local players // get local players
C4ClientPlayerInfos **ppkLocal = GetInfoPtrByClientID(Game.Control.ClientID()), *pkLocal; C4ClientPlayerInfos **ppkLocal = GetInfoPtrByClientID(Game.Control.ClientID()), *pkLocal;
if (!ppkLocal) return false; if (!ppkLocal) return false;
@ -1410,7 +1410,7 @@ bool C4PlayerInfoList::RestoreSavegameInfos(C4PlayerInfoList &rSavegamePlayers)
// do savegame player association of real players // do savegame player association of real players
// for non-lobby games do automatic association first // for non-lobby games do automatic association first
int32_t iNumGrabbed = 0, i; int32_t iNumGrabbed = 0, i;
if (!Game.Network.isEnabled() && Game.C4S.Head.SaveGame) if (!::Network.isEnabled() && Game.C4S.Head.SaveGame)
{ {
// do several passes: First passes using regular player matching; following passes matching anything but with a warning message // do several passes: First passes using regular player matching; following passes matching anything but with a warning message
for (int eMatchingLevel = 0; eMatchingLevel <= PML_Any; ++eMatchingLevel) for (int eMatchingLevel = 0; eMatchingLevel <= PML_Any; ++eMatchingLevel)
@ -1582,7 +1582,7 @@ bool C4PlayerInfoList::RecreatePlayers()
szAtClientName = "Replay"; szAtClientName = "Replay";
else else
// local non-network non-replay games set local name // local non-network non-replay games set local name
if (!Game.Network.isEnabled()) if (!::Network.isEnabled())
{ {
assert(idAtClient == Game.Control.ClientID()); assert(idAtClient == Game.Control.ClientID());
szAtClientName = "Local"; szAtClientName = "Local";
@ -1613,7 +1613,7 @@ bool C4PlayerInfoList::RecreatePlayers()
if (szFilename && pJoinRes && pJoinRes->isLoading()) if (szFilename && pJoinRes && pJoinRes->isLoading())
{ {
const char *szName = pInfo->GetName(); const char *szName = pInfo->GetName();
if (!Game.Network.RetrieveRes(pJoinRes->getCore(), C4NetResRetrieveTimeout, if (!::Network.RetrieveRes(pJoinRes->getCore(), C4NetResRetrieveTimeout,
FormatString(LoadResStr("IDS_NET_RES_PLRFILE"), szName).getData())) FormatString(LoadResStr("IDS_NET_RES_PLRFILE"), szName).getData()))
szFilename=NULL; szFilename=NULL;
} }
@ -1701,7 +1701,7 @@ bool C4PlayerInfoList::SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fS
{ {
// in the game: Set filename for inside savegame file // in the game: Set filename for inside savegame file
StdStrBuf sNewName; StdStrBuf sNewName;
if (Game.Network.isEnabled()) if (::Network.isEnabled())
{ {
C4Client *pGameClient = Game.Clients.getClientByID(pClient->GetClientID()); C4Client *pGameClient = Game.Clients.getClientByID(pClient->GetClientID());
const char *szName = pGameClient ? pGameClient->getName() : "Unknown"; const char *szName = pGameClient ? pGameClient->getName() : "Unknown";

View File

@ -38,7 +38,7 @@ DWORD GenerateRandomPlayerColor(int32_t iTry); // in C4PlayerInfoConflicts.cpp
// helper // helper
C4GameLobby::MainDlg *C4PlayerInfoListBox::ListItem::GetLobby() const C4GameLobby::MainDlg *C4PlayerInfoListBox::ListItem::GetLobby() const
{ {
return Game.Network.GetLobby(); return ::Network.GetLobby();
} }
bool C4PlayerInfoListBox::ListItem::CanLocalChooseTeams(int32_t idPlayer) const bool C4PlayerInfoListBox::ListItem::CanLocalChooseTeams(int32_t idPlayer) const
@ -258,7 +258,7 @@ void C4PlayerInfoListBox::PlayerListItem::UpdateIcon(C4PlayerInfo *pInfo, C4Play
fResPresent = pRes->isComplete(); fResPresent = pRes->isComplete();
C4RoundResultsPlayer *pEvaluationPlayer = NULL; C4RoundResultsPlayer *pEvaluationPlayer = NULL;
if (pList->IsEvaluation()) pEvaluationPlayer = Game.RoundResults.GetPlayers().GetByID(idPlayer); if (pList->IsEvaluation()) pEvaluationPlayer = Game.RoundResults.GetPlayers().GetByID(idPlayer);
bool fHasIcon = fResPresent || pEvaluationPlayer || (!Game.Network.isEnabled() && pInfo); bool fHasIcon = fResPresent || pEvaluationPlayer || (!::Network.isEnabled() && pInfo);
// check whether joined info is present // check whether joined info is present
bool fHasJoinedInfo = !!pJoinedInfo; bool fHasJoinedInfo = !!pJoinedInfo;
DWORD dwJoinedInfoClr = pJoinedInfo ? pJoinedInfo->GetLobbyColor() : 0; DWORD dwJoinedInfoClr = pJoinedInfo ? pJoinedInfo->GetLobbyColor() : 0;
@ -506,7 +506,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::PlayerListItem::OnContext(C4GUI::Elemen
else else
{ {
// owned players or host can manipulate players // owned players or host can manipulate players
if (Game.Network.isHost() || IsLocalClientPlayer()) if (::Network.isHost() || IsLocalClientPlayer())
{ {
// player removal (except for joined script players) // player removal (except for joined script players)
if (pInfo->GetType() != C4PT_Script || !pInfo->GetAssociatedSavegamePlayerID()) if (pInfo->GetType() != C4PT_Script || !pInfo->GetAssociatedSavegamePlayerID())
@ -535,7 +535,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::PlayerListItem::OnContextTakeOver(C4GUI
// create context menu // create context menu
C4GUI::ContextMenu *pMenu = new C4GUI::ContextMenu(); C4GUI::ContextMenu *pMenu = new C4GUI::ContextMenu();
// add options for all own, unassigned players // add options for all own, unassigned players
C4ClientPlayerInfos *pkInfo = Game.Network.Players.GetLocalPlayerInfoPacket(); C4ClientPlayerInfos *pkInfo = ::Network.Players.GetLocalPlayerInfoPacket();
if (pkInfo) if (pkInfo)
{ {
int32_t i=0; C4PlayerInfo *pInfo; int32_t i=0; C4PlayerInfo *pInfo;
@ -561,7 +561,7 @@ void C4PlayerInfoListBox::PlayerListItem::OnCtxTakeOver(C4GUI::Element *pListIte
// use player idPlayer to take over this one // use player idPlayer to take over this one
// this must be processed as a request by the host // this must be processed as a request by the host
// some safety first... // some safety first...
C4ClientPlayerInfos *pLocalInfo = Game.Network.Players.GetLocalPlayerInfoPacket(); C4ClientPlayerInfos *pLocalInfo = ::Network.Players.GetLocalPlayerInfoPacket();
if (!fFreeSavegamePlayer || !idPlayer || !pLocalInfo) return; if (!fFreeSavegamePlayer || !idPlayer || !pLocalInfo) return;
C4ClientPlayerInfos LocalInfoRequest(*pLocalInfo); C4ClientPlayerInfos LocalInfoRequest(*pLocalInfo);
C4PlayerInfo *pGrabbingInfo = LocalInfoRequest.GetPlayerInfoByID(idPlayer); C4PlayerInfo *pGrabbingInfo = LocalInfoRequest.GetPlayerInfoByID(idPlayer);
@ -569,13 +569,13 @@ void C4PlayerInfoListBox::PlayerListItem::OnCtxTakeOver(C4GUI::Element *pListIte
// now adjust info packet // now adjust info packet
pGrabbingInfo->SetAssociatedSavegamePlayer(this->idPlayer); pGrabbingInfo->SetAssociatedSavegamePlayer(this->idPlayer);
// and request this update (host processes it directly) // and request this update (host processes it directly)
Game.Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest); ::Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
} }
void C4PlayerInfoListBox::PlayerListItem::OnCtxRemove(C4GUI::Element *pListItem) void C4PlayerInfoListBox::PlayerListItem::OnCtxRemove(C4GUI::Element *pListItem)
{ {
// only host or own player // only host or own player
if (!Game.Network.isEnabled() || (!Game.Network.isHost() && !IsLocalClientPlayer())) return; if (!::Network.isEnabled() || (!::Network.isHost() && !IsLocalClientPlayer())) return;
// remove the player // remove the player
// this must be processed as a request by the host // this must be processed as a request by the host
// now change it in its own request packet // now change it in its own request packet
@ -585,13 +585,13 @@ void C4PlayerInfoListBox::PlayerListItem::OnCtxRemove(C4GUI::Element *pListItem)
if (!LocalInfoRequest.GetPlayerInfoByID(idPlayer)) return; if (!LocalInfoRequest.GetPlayerInfoByID(idPlayer)) return;
LocalInfoRequest.RemoveInfo(idPlayer); LocalInfoRequest.RemoveInfo(idPlayer);
// and request this update (host processes it directly) // and request this update (host processes it directly)
Game.Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest); ::Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
} }
void C4PlayerInfoListBox::PlayerListItem::OnCtxNewColor(C4GUI::Element *pListItem) void C4PlayerInfoListBox::PlayerListItem::OnCtxNewColor(C4GUI::Element *pListItem)
{ {
// only host or own player // only host or own player
if (!Game.Network.isEnabled() || (!Game.Network.isHost() && !IsLocalClientPlayer())) return; if (!::Network.isEnabled() || (!::Network.isHost() && !IsLocalClientPlayer())) return;
// just send a request to reclaim the original color to the host // just send a request to reclaim the original color to the host
// the host will deny this and decide on a new color // the host will deny this and decide on a new color
C4ClientPlayerInfos *pChangeInfo = Game.PlayerInfos.GetInfoByClientID(idClient); C4ClientPlayerInfos *pChangeInfo = Game.PlayerInfos.GetInfoByClientID(idClient);
@ -601,7 +601,7 @@ void C4PlayerInfoListBox::PlayerListItem::OnCtxNewColor(C4GUI::Element *pListIte
if (!pPlrInfo) return; if (!pPlrInfo) return;
pPlrInfo->SetColor(pPlrInfo->GetOriginalColor()); pPlrInfo->SetColor(pPlrInfo->GetOriginalColor());
// and request this update (host processes it directly) // and request this update (host processes it directly)
Game.Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest); ::Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
} }
void C4PlayerInfoListBox::PlayerListItem::OnTeamComboFill(C4GUI::ComboBox_FillCB *pFiller) void C4PlayerInfoListBox::PlayerListItem::OnTeamComboFill(C4GUI::ComboBox_FillCB *pFiller)
@ -629,7 +629,7 @@ bool C4PlayerInfoListBox::PlayerListItem::OnTeamComboSelChange(C4GUI::ComboBox *
if (!pChangedInfo) return true; if (!pChangedInfo) return true;
pChangedInfo->SetTeam(pNewTeam->GetID()); pChangedInfo->SetTeam(pNewTeam->GetID());
// and request this update (host processes it directly) // and request this update (host processes it directly)
Game.Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest); ::Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
// next update will change the combo box text // next update will change the combo box text
return true; return true;
} }
@ -703,7 +703,7 @@ bool C4PlayerInfoListBox::PlayerListItem::CanLocalChooseTeam() const
// never on savegame players // never on savegame players
if (fFreeSavegamePlayer || GetJoinedInfo()) return false; if (fFreeSavegamePlayer || GetJoinedInfo()) return false;
// only host or own player // only host or own player
if (!Game.Network.isHost() && !IsLocalClientPlayer()) return false; if (!::Network.isHost() && !IsLocalClientPlayer()) return false;
// finally, only if team settings permit // finally, only if team settings permit
return CanLocalChooseTeams(idPlayer); return CanLocalChooseTeams(idPlayer);
} }
@ -718,7 +718,7 @@ bool C4PlayerInfoListBox::PlayerListItem::IsLocalClientPlayer() const
C4Network2Client *C4PlayerInfoListBox::PlayerListItem::GetNetClient() const C4Network2Client *C4PlayerInfoListBox::PlayerListItem::GetNetClient() const
{ {
return Game.Network.Clients.GetClientByID(idClient); return ::Network.Clients.GetClientByID(idClient);
} }
@ -796,7 +796,7 @@ void C4PlayerInfoListBox::ClientListItem::SetPing(int32_t iToPing)
void C4PlayerInfoListBox::ClientListItem::UpdateInfo() void C4PlayerInfoListBox::ClientListItem::UpdateInfo()
{ {
// update color (always, because it can change silently) // update color (always, because it can change silently)
SetColor(Game.Network.Players.GetClientChatColor(idClient, true)); SetColor(::Network.Players.GetClientChatColor(idClient, true));
// update activation status // update activation status
fIsShownActive = GetClient() && GetClient()->isActivated(); fIsShownActive = GetClient() && GetClient()->isActivated();
// update status icon // update status icon
@ -820,7 +820,7 @@ bool C4PlayerInfoListBox::ClientListItem::IsLocalClientPlayer() const
C4Network2Client *C4PlayerInfoListBox::ClientListItem::GetNetClient() const C4Network2Client *C4PlayerInfoListBox::ClientListItem::GetNetClient() const
{ {
return Game.Network.Clients.GetClientByID(idClient); return ::Network.Clients.GetClientByID(idClient);
} }
bool C4PlayerInfoListBox::ClientListItem::IsLocal() const bool C4PlayerInfoListBox::ClientListItem::IsLocal() const
@ -895,13 +895,13 @@ void C4PlayerInfoListBox::ClientListItem::SetSoundIcon()
C4GUI::ContextMenu *C4PlayerInfoListBox::ClientListItem::OnContext(C4GUI::Element *pListItem, int32_t iX, int32_t iY) C4GUI::ContextMenu *C4PlayerInfoListBox::ClientListItem::OnContext(C4GUI::Element *pListItem, int32_t iX, int32_t iY)
{ {
// safety // safety
if (!Game.Network.isEnabled()) return NULL; if (!::Network.isEnabled()) return NULL;
// get associated client // get associated client
C4Client *pClient = GetClient(); C4Client *pClient = GetClient();
// create context menu // create context menu
C4GUI::ContextMenu *pMenu = new C4GUI::ContextMenu(); C4GUI::ContextMenu *pMenu = new C4GUI::ContextMenu();
// host options // host options
if (Game.Network.isHost() && GetNetClient()) if (::Network.isHost() && GetNetClient())
{ {
StdCopyStrBuf strKickDesc(LoadResStr("IDS_NET_KICKCLIENT_DESC")); StdCopyStrBuf strKickDesc(LoadResStr("IDS_NET_KICKCLIENT_DESC"));
pMenu->AddItem(LoadResStr("IDS_NET_KICKCLIENT"), strKickDesc.getData(), C4GUI::Ico_None, pMenu->AddItem(LoadResStr("IDS_NET_KICKCLIENT"), strKickDesc.getData(), C4GUI::Ico_None,
@ -922,7 +922,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::ClientListItem::OnContext(C4GUI::Elemen
void C4PlayerInfoListBox::ClientListItem::OnCtxKick(C4GUI::Element *pListItem) void C4PlayerInfoListBox::ClientListItem::OnCtxKick(C4GUI::Element *pListItem)
{ {
// host only // host only
if (!Game.Network.isEnabled() || !Game.Network.isHost()) return; if (!::Network.isEnabled() || !::Network.isHost()) return;
// add control // add control
Game.Clients.CtrlRemove(GetClient(), LoadResStr("IDS_MSG_KICKFROMLOBBY")); Game.Clients.CtrlRemove(GetClient(), LoadResStr("IDS_MSG_KICKFROMLOBBY"));
} }
@ -931,7 +931,7 @@ void C4PlayerInfoListBox::ClientListItem::OnCtxActivate(C4GUI::Element *pListIte
{ {
// host only // host only
C4Client *pClient = GetClient(); C4Client *pClient = GetClient();
if (!Game.Network.isEnabled() || !Game.Network.isHost() || !pClient) return; if (!::Network.isEnabled() || !::Network.isHost() || !pClient) return;
// add control // add control
Game.Control.DoInput(CID_ClientUpdate, new C4ControlClientUpdate(idClient, CUT_Activate, !pClient->isActivated()), CDT_Sync); Game.Control.DoInput(CID_ClientUpdate, new C4ControlClientUpdate(idClient, CUT_Activate, !pClient->isActivated()), CDT_Sync);
} }
@ -1051,7 +1051,7 @@ void C4PlayerInfoListBox::TeamListItem::MoveLocalPlayersIntoTeam()
} }
if (!fAnyChange) return; if (!fAnyChange) return;
// and request this update (host processes it directly) // and request this update (host processes it directly)
Game.Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest); ::Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
// next update will move the player labels // next update will move the player labels
} }

View File

@ -343,7 +343,7 @@ C4Player* C4PlayerList::Join(const char *szFilename, BOOL fScenarioInit, int iAt
BOOL C4PlayerList::CtrlJoinLocalNoNetwork(const char *szFilename, int iAtClient, const char *szAtClientName) BOOL C4PlayerList::CtrlJoinLocalNoNetwork(const char *szFilename, int iAtClient, const char *szAtClientName)
{ {
assert(!Game.Network.isEnabled()); assert(!::Network.isEnabled());
// Create temp copy of player file without portraits // Create temp copy of player file without portraits
// Why? This is local join! // Why? This is local join!
/* /*
@ -485,7 +485,7 @@ BOOL C4PlayerList::FileInUse(const char *szFilename) const
if (ItemIdentical(cPlr->Filename,szFilename)) if (ItemIdentical(cPlr->Filename,szFilename))
return TRUE; return TRUE;
// Compare to any network path player files with prefix (hack) // Compare to any network path player files with prefix (hack)
if (Game.Network.isEnabled()) if (::Network.isEnabled())
{ {
char szWithPrefix[_MAX_PATH+1]; char szWithPrefix[_MAX_PATH+1];
SCopy(GetFilename(szFilename),szWithPrefix); SCopy(GetFilename(szFilename),szWithPrefix);

View File

@ -1479,7 +1479,7 @@ void C4StartupScenSelDlg::OnClosed(bool fOK)
if (!fOK) if (!fOK)
{ {
// clear settings: Password // clear settings: Password
Game.Network.SetPassword(NULL); ::Network.SetPassword(NULL);
C4Startup::Get()->SwitchDialog(C4Startup::SDID_Back); C4Startup::Get()->SwitchDialog(C4Startup::SDID_Back);
} }
} }

View File

@ -451,7 +451,7 @@ bool C4TeamList::IsTeamVisible() const
{ {
// teams invisible during lobby time if random surprise teams // teams invisible during lobby time if random surprise teams
if (eTeamDist == TEAMDIST_RandomInv) if (eTeamDist == TEAMDIST_RandomInv)
if (Game.Network.isLobbyActive()) if (::Network.isLobbyActive())
return false; return false;
return true; return true;
} }
@ -487,8 +487,8 @@ bool C4TeamList::RecheckPlayerInfoTeams(C4PlayerInfo &rNewJoin, bool fByHost)
// teams are always needed in the lobby, so there's a team preset to change // teams are always needed in the lobby, so there's a team preset to change
// for runtime joins, teams are needed if specified by teams.txt or if any teams have been created before (to avoid mixed team-noteam-scenarios) // for runtime joins, teams are needed if specified by teams.txt or if any teams have been created before (to avoid mixed team-noteam-scenarios)
// but only assign teams in runtime join if the player won't pick it himself // but only assign teams in runtime join if the player won't pick it himself
bool fWillHaveLobby = Game.Network.isEnabled() && !Game.Network.Status.isPastLobby() && Game.fLobby; bool fWillHaveLobby = ::Network.isEnabled() && !::Network.Status.isPastLobby() && Game.fLobby;
bool fHasOrWillHaveLobby = Game.Network.isLobbyActive() || fWillHaveLobby; bool fHasOrWillHaveLobby = ::Network.isLobbyActive() || fWillHaveLobby;
bool fCanPickTeamAtRuntime = !IsRandomTeam() && (rNewJoin.GetType() == C4PT_User) && IsRuntimeJoinTeamChoice(); bool fCanPickTeamAtRuntime = !IsRandomTeam() && (rNewJoin.GetType() == C4PT_User) && IsRuntimeJoinTeamChoice();
bool fIsTeamNeeded = IsRuntimeJoinTeamChoice() || GetTeamCount(); bool fIsTeamNeeded = IsRuntimeJoinTeamChoice() || GetTeamCount();
if (!fHasOrWillHaveLobby && (!fIsTeamNeeded || fCanPickTeamAtRuntime)) return false; if (!fHasOrWillHaveLobby && (!fIsTeamNeeded || fCanPickTeamAtRuntime)) return false;
@ -798,9 +798,9 @@ void C4TeamList::SetTeamDistribution(TeamDist eToVal)
RecheckTeams(); RecheckTeams();
} }
// send updates to other clients and reset flags // send updates to other clients and reset flags
if (Game.Network.isEnabled()) if (::Network.isEnabled())
{ {
Game.Network.Players.SendUpdatedPlayers(); ::Network.Players.SendUpdatedPlayers();
} }
} }
} }
@ -821,10 +821,10 @@ void C4TeamList::SetTeamColors(bool fEnabled)
if (!Game.Control.isCtrlHost()) return; if (!Game.Control.isCtrlHost()) return;
// go through all player infos; reset color in them // go through all player infos; reset color in them
Game.PlayerInfos.UpdatePlayerAttributes(); // sets team and savegame colors Game.PlayerInfos.UpdatePlayerAttributes(); // sets team and savegame colors
if (Game.Network.isEnabled()) if (::Network.isEnabled())
{ {
// sends color updates to all clients // sends color updates to all clients
Game.Network.Players.SendUpdatedPlayers(); ::Network.Players.SendUpdatedPlayers();
} }
} }

View File

@ -1122,7 +1122,7 @@ void C4Viewport::Draw(C4TargetFacet &cgo, bool fDrawOverlay)
// Netstats // Netstats
if (::GraphicsSystem.ShowNetstatus) if (::GraphicsSystem.ShowNetstatus)
Game.Network.DrawStatus(cgo); ::Network.DrawStatus(cgo);
C4ST_STOP(OvrStat) C4ST_STOP(OvrStat)