forked from Mirrors/openclonk
Move Game.Network to ::Network
parent
724f81724d
commit
fa05c07d5c
|
@ -90,7 +90,6 @@ class C4Game
|
|||
~C4Game();
|
||||
public:
|
||||
C4DefList Defs;
|
||||
C4Network2 Network;
|
||||
C4ClientList &Clients; // Shortcut
|
||||
C4GameParameters Parameters;
|
||||
C4TeamList &Teams; // Shortcut
|
||||
|
|
|
@ -366,6 +366,8 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
extern C4Network2 Network;
|
||||
|
||||
class C4VoteDialog : public C4GUI::MessageDialog
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
|
||||
void SetSourceIP(in_addr ip);
|
||||
|
||||
void InitLocal(C4Game *pGame);
|
||||
void InitLocal();
|
||||
|
||||
void SortNullIPsBack();
|
||||
|
||||
|
|
|
@ -751,7 +751,7 @@ bool C4Console::UpdateHaltCtrls(bool fHalt)
|
|||
BOOL C4Console::SaveGame(BOOL fSaveGame)
|
||||
{
|
||||
// Network hosts only
|
||||
if (Game.Network.isEnabled() && !Game.Network.isHost())
|
||||
if (::Network.isEnabled() && !::Network.isHost())
|
||||
{ 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_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_BUTTONPLAY,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(Game.Network.isLobbyActive() || fEnable ? hbmPlay : hbmPlay2));
|
||||
SendDlgItemMessage(hWindow,IDC_BUTTONHALT,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(Game.Network.isLobbyActive() || fEnable ? hbmHalt : hbmHalt2));
|
||||
SendDlgItemMessage(hWindow,IDC_BUTTONPLAY,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(::Network.isLobbyActive() || fEnable ? hbmPlay : hbmPlay2));
|
||||
SendDlgItemMessage(hWindow,IDC_BUTTONHALT,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)(::Network.isLobbyActive() || fEnable ? hbmHalt : hbmHalt2));
|
||||
|
||||
// OK
|
||||
EnableWindow( GetDlgItem(hWindow,IDOK), fEnable);
|
||||
|
||||
// Halt controls
|
||||
EnableWindow(GetDlgItem(hWindow,IDC_BUTTONPLAY), Game.Network.isLobbyActive() || fEnable);
|
||||
EnableWindow(GetDlgItem(hWindow,IDC_BUTTONHALT), Game.Network.isLobbyActive() || fEnable);
|
||||
EnableWindow(GetDlgItem(hWindow,IDC_BUTTONPLAY), ::Network.isLobbyActive() || fEnable);
|
||||
EnableWindow(GetDlgItem(hWindow,IDC_BUTTONHALT), ::Network.isLobbyActive() || fEnable);
|
||||
|
||||
// Edit modes
|
||||
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));
|
||||
#elif defined(WITH_DEVELOPER_MODE)
|
||||
// Halt controls
|
||||
gtk_widget_set_sensitive(btnPlay, Game.Network.isLobbyActive() || fEnable);
|
||||
gtk_widget_set_sensitive(btnHalt, Game.Network.isLobbyActive() || fEnable);
|
||||
gtk_widget_set_sensitive(btnPlay, ::Network.isLobbyActive() || fEnable);
|
||||
gtk_widget_set_sensitive(btnHalt, ::Network.isLobbyActive() || fEnable);
|
||||
|
||||
// Edit modes
|
||||
gtk_widget_set_sensitive(btnModePlay, Game.Network.isLobbyActive() || fEnable);
|
||||
gtk_widget_set_sensitive(btnModeEdit, Game.Network.isLobbyActive() || fEnable);
|
||||
gtk_widget_set_sensitive(btnModeDraw, Game.Network.isLobbyActive() || fEnable);
|
||||
gtk_widget_set_sensitive(btnModePlay, ::Network.isLobbyActive() || fEnable);
|
||||
gtk_widget_set_sensitive(btnModeEdit, ::Network.isLobbyActive() || fEnable);
|
||||
gtk_widget_set_sensitive(btnModeDraw, ::Network.isLobbyActive() || fEnable);
|
||||
|
||||
// Console input
|
||||
gtk_widget_set_sensitive(txtScript, Game.Network.isLobbyActive() || fEnable);
|
||||
gtk_widget_set_sensitive(txtScript, ::Network.isLobbyActive() || fEnable);
|
||||
|
||||
// File menu
|
||||
// C4Network2 will have to handle that cases somehow (TODO: test)
|
||||
|
@ -1331,20 +1331,20 @@ bool C4Console::UpdateModeCtrls(int iMode)
|
|||
|
||||
void C4Console::EditTitle()
|
||||
{
|
||||
if (Game.Network.isEnabled()) return;
|
||||
if (::Network.isEnabled()) return;
|
||||
Game.Title.Open();
|
||||
}
|
||||
|
||||
void C4Console::EditScript()
|
||||
{
|
||||
if (Game.Network.isEnabled()) return;
|
||||
if (::Network.isEnabled()) return;
|
||||
Game.Script.Open();
|
||||
Game.ScriptEngine.ReLink(&Game.Defs);
|
||||
}
|
||||
|
||||
void C4Console::EditInfo()
|
||||
{
|
||||
if (Game.Network.isEnabled()) return;
|
||||
if (::Network.isEnabled()) return;
|
||||
Game.Info.Open();
|
||||
}
|
||||
|
||||
|
@ -1418,12 +1418,12 @@ bool C4Console::UpdatePlayerMenu()
|
|||
for (C4Player *pPlr=Game.Players.First; pPlr; pPlr=pPlr->Next)
|
||||
{
|
||||
StdStrBuf sText;
|
||||
if (Game.Network.isEnabled())
|
||||
if (::Network.isEnabled())
|
||||
sText.Format(LoadResStr("IDS_CNS_PLRQUITNET"),pPlr->GetName(),pPlr->AtClientName);
|
||||
else
|
||||
sText.Format(LoadResStr("IDS_CNS_PLRQUIT"),pPlr->GetName());
|
||||
#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)
|
||||
// TODO: Implement AddMenuItem...
|
||||
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));
|
||||
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
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -1496,8 +1496,8 @@ void C4Console::PlayerJoin()
|
|||
char szPlayerFilename[_MAX_PATH+1];
|
||||
for (int iPar=0; SCopySegment(c4plist,iPar,szPlayerFilename,';',_MAX_PATH); iPar++)
|
||||
if (szPlayerFilename[0])
|
||||
if (Game.Network.isEnabled())
|
||||
Game.Network.Players.JoinLocalPlayer(szPlayerFilename, true);
|
||||
if (::Network.isEnabled())
|
||||
::Network.Players.JoinLocalPlayer(szPlayerFilename, true);
|
||||
else
|
||||
Game.Players.CtrlJoinLocalNoNetwork(szPlayerFilename, Game.Clients.getLocalID(), Game.Clients.getLocalName());
|
||||
|
||||
|
@ -1544,7 +1544,7 @@ void C4Console::UpdateNetMenu()
|
|||
{
|
||||
// Active & network hosting check
|
||||
if (!Active) return;
|
||||
if (!Game.Network.isHost() || !Game.Network.isEnabled()) return;
|
||||
if (!::Network.isHost() || !::Network.isEnabled()) return;
|
||||
// Clear old
|
||||
ClearNetMenu();
|
||||
// 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()));
|
||||
#endif
|
||||
// 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"),
|
||||
pClient->getName(), pClient->getID());
|
||||
|
|
|
@ -239,13 +239,13 @@ void C4ControlSet::Execute() const
|
|||
::GraphicsSystem.FlashMessage(LoadResStr("IDS_MSG_FAIRCREW_DEACTIVATED"));
|
||||
}
|
||||
// lobby updates
|
||||
if (Game.Network.isLobbyActive())
|
||||
if (::Network.isLobbyActive())
|
||||
{
|
||||
Game.Network.GetLobby()->UpdateFairCrew();
|
||||
::Network.GetLobby()->UpdateFairCrew();
|
||||
}
|
||||
// this setting is part of the reference
|
||||
if (Game.Network.isEnabled() && Game.Network.isHost())
|
||||
Game.Network.InvalidateReference();
|
||||
if (::Network.isEnabled() && ::Network.isHost())
|
||||
::Network.InvalidateReference();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -289,8 +289,8 @@ void C4ControlScript::Execute() const
|
|||
if(!LocalControl())
|
||||
{
|
||||
C4Network2Client *pClient = NULL;
|
||||
if(Game.Network.isEnabled())
|
||||
pClient = Game.Network.Clients.GetClientByID(iByClient);
|
||||
if(::Network.isEnabled())
|
||||
pClient = ::Network.Clients.GetClientByID(iByClient);
|
||||
if(pClient)
|
||||
LogF(" = %s (by %s)", rVal.GetDataString().getData(), pClient->getName());
|
||||
else
|
||||
|
@ -491,14 +491,14 @@ void C4ControlSyncCheck::Execute() const
|
|||
SaveGame.Save(Config.AtExePath("Desync.c4s"));
|
||||
#endif
|
||||
// league: Notify regular client disconnect within the game
|
||||
Game.Network.LeagueNotifyDisconnect(C4ClientIDHost, C4LDR_Desync);
|
||||
::Network.LeagueNotifyDisconnect(C4ClientIDHost, C4LDR_Desync);
|
||||
// Deactivate / end
|
||||
if(Game.Control.isReplay())
|
||||
Game.DoGameOver();
|
||||
else if(Game.Control.isNetwork())
|
||||
{
|
||||
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, "Network: Synchronization loss!");
|
||||
Game.Network.Clear();
|
||||
::Network.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,7 +546,7 @@ void C4ControlClientJoin::Execute() const
|
|||
// log
|
||||
LogF(LoadResStr("IDS_NET_CLIENT_JOIN"), Core.getName());
|
||||
// lobby callback
|
||||
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby();
|
||||
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
|
||||
if (pLobby) pLobby->OnClientJoin(pClient);
|
||||
// console callback
|
||||
if (Console.Active) Console.UpdateMenus();
|
||||
|
@ -641,13 +641,13 @@ void C4ControlClientRemove::Execute() const
|
|||
// remove all players
|
||||
Game.Players.RemoveAtClient(iID, true);
|
||||
// remove all resources
|
||||
if(Game.Network.isEnabled())
|
||||
Game.Network.ResList.RemoveAtClient(iID);
|
||||
if(::Network.isEnabled())
|
||||
::Network.ResList.RemoveAtClient(iID);
|
||||
// lobby callback
|
||||
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby();
|
||||
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
|
||||
if (pLobby && Game.pGUI) pLobby->OnClientPart(pClient);
|
||||
// player list callback
|
||||
Game.Network.Players.OnClientPart(pClient);
|
||||
::Network.Players.OnClientPart(pClient);
|
||||
// console callback
|
||||
if(Console.Active) Console.UpdateMenus();
|
||||
|
||||
|
@ -734,7 +734,7 @@ void C4ControlJoinPlayer::Execute() const
|
|||
else if(Game.Control.isNetwork())
|
||||
{
|
||||
// Find ressource
|
||||
C4Network2Res::Ref pRes = Game.Network.ResList.getRefRes(ResCore.getID());
|
||||
C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID());
|
||||
if(pRes && pRes->isComplete())
|
||||
Game.JoinPlayer(pRes->getFile(), iAtClient, pClient->getName(), pInfo);
|
||||
}
|
||||
|
@ -790,9 +790,9 @@ bool C4ControlJoinPlayer::PreExecute() const
|
|||
// network only
|
||||
if(!Game.Control.isNetwork()) return true;
|
||||
// search ressource
|
||||
C4Network2Res::Ref pRes = Game.Network.ResList.getRefRes(ResCore.getID());
|
||||
C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID());
|
||||
// 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;
|
||||
// is loading or removed?
|
||||
return !pRes->isLoading();
|
||||
|
@ -804,7 +804,7 @@ void C4ControlJoinPlayer::PreRec(C4Record *pRecord)
|
|||
if (fByRes)
|
||||
{
|
||||
// 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;
|
||||
// create a copy of the resource
|
||||
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!
|
||||
//if (pPlr) pPlr->CountControl(C4Player::PCID_Message, Message.GetHash());
|
||||
// get lobby to forward to
|
||||
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby();
|
||||
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
|
||||
StdStrBuf str;
|
||||
switch(eType)
|
||||
{
|
||||
|
@ -1169,7 +1169,7 @@ void C4ControlPlayerInfo::Execute() const
|
|||
}
|
||||
else
|
||||
// network:
|
||||
Game.Network.Players.HandlePlayerInfo(PlrInfo);
|
||||
::Network.Players.HandlePlayerInfo(PlrInfo);
|
||||
}
|
||||
|
||||
void C4ControlPlayerInfo::CompileFunc(StdCompiler *pComp)
|
||||
|
@ -1262,8 +1262,8 @@ void C4ControlVote::Execute() const
|
|||
else
|
||||
LogF(LoadResStr("IDS_VOTE_DOESNOTWANTTO"), pClient->getName(), getDesc().getData());
|
||||
// Save vote back
|
||||
if(Game.Network.isEnabled())
|
||||
Game.Network.AddVote(*this);
|
||||
if(::Network.isEnabled())
|
||||
::Network.AddVote(*this);
|
||||
// Vote done?
|
||||
if(Game.Control.isCtrlHost())
|
||||
{
|
||||
|
@ -1301,7 +1301,7 @@ void C4ControlVote::Execute() const
|
|||
iVotesTeam++;
|
||||
// Search vote of this client on the subject
|
||||
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->isApprove())
|
||||
iPositiveTeam++;
|
||||
|
@ -1347,8 +1347,8 @@ void C4ControlVoteEnd::Execute() const
|
|||
{
|
||||
// End the voting process
|
||||
if(!HostControl()) return;
|
||||
if(Game.Network.isEnabled())
|
||||
Game.Network.EndVote(getType(), isApprove(), getData());
|
||||
if(::Network.isEnabled())
|
||||
::Network.EndVote(getType(), isApprove(), getData());
|
||||
// Log
|
||||
StdStrBuf sMsg;
|
||||
if(isApprove())
|
||||
|
@ -1394,7 +1394,7 @@ void C4ControlVoteEnd::Execute() const
|
|||
// 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!
|
||||
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.DoGameOver();
|
||||
}
|
||||
|
|
|
@ -962,17 +962,17 @@ bool C4Game::Pause()
|
|||
// already paused?
|
||||
if (IsPaused()) return false;
|
||||
// pause by net?
|
||||
if(Game.Network.isEnabled())
|
||||
if(::Network.isEnabled())
|
||||
{
|
||||
// league? Vote...
|
||||
if(Parameters.isLeague() && !Game.Evaluated)
|
||||
{
|
||||
Game.Network.Vote(VT_Pause, true, true);
|
||||
::Network.Vote(VT_Pause, true, true);
|
||||
return false;
|
||||
}
|
||||
// host only
|
||||
if(!Game.Network.isHost()) return true;
|
||||
Game.Network.Pause();
|
||||
if(!::Network.isHost()) return true;
|
||||
::Network.Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -988,17 +988,17 @@ bool C4Game::Unpause()
|
|||
// already paused?
|
||||
if (!IsPaused()) return false;
|
||||
// pause by net?
|
||||
if(Game.Network.isEnabled())
|
||||
if(::Network.isEnabled())
|
||||
{
|
||||
// league? Vote...
|
||||
if(Parameters.isLeague() && !Game.Evaluated)
|
||||
{
|
||||
Game.Network.Vote(VT_Pause, true, false);
|
||||
::Network.Vote(VT_Pause, true, false);
|
||||
return false;
|
||||
}
|
||||
// host only
|
||||
if(!Game.Network.isHost()) return true;
|
||||
Game.Network.Start();
|
||||
if(!::Network.isHost()) return true;
|
||||
::Network.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1012,8 +1012,8 @@ bool C4Game::Unpause()
|
|||
bool C4Game::IsPaused()
|
||||
{
|
||||
// pause state defined either by network or by game halt count
|
||||
if (Game.Network.isEnabled())
|
||||
return !Game.Network.isRunning();
|
||||
if (::Network.isEnabled())
|
||||
return !::Network.isRunning();
|
||||
return !!HaltCount;
|
||||
}
|
||||
|
||||
|
@ -2133,7 +2133,7 @@ static void FileMonitorCallback(const char * file, const char * extrafile)
|
|||
BOOL C4Game::ReloadFile(const char *szFile)
|
||||
{
|
||||
// not in network
|
||||
if(Game.Network.isEnabled()) return FALSE;
|
||||
if(::Network.isEnabled()) return FALSE;
|
||||
const char *szRelativePath = Config.AtRelativePath(szFile);
|
||||
// a definition? or part of a definition?
|
||||
C4Def *pDef;
|
||||
|
@ -2151,7 +2151,7 @@ BOOL C4Game::ReloadDef(C4ID id)
|
|||
{
|
||||
bool fSucc;
|
||||
// not in network
|
||||
if(Game.Network.isEnabled()) return FALSE;
|
||||
if(::Network.isEnabled()) return FALSE;
|
||||
// syncronize (close menus with dead surfaces, etc.)
|
||||
// no need to sync back player files, though
|
||||
Synchronize(FALSE);
|
||||
|
@ -2197,7 +2197,7 @@ BOOL C4Game::ReloadDef(C4ID id)
|
|||
BOOL C4Game::ReloadParticle(const char *szName)
|
||||
{
|
||||
// not in network
|
||||
if(Game.Network.isEnabled()) return FALSE;
|
||||
if(::Network.isEnabled()) return FALSE;
|
||||
// safety
|
||||
if (!szName) return FALSE;
|
||||
// get particle def
|
||||
|
@ -2243,7 +2243,7 @@ BOOL C4Game::InitGame(C4Group &hGroup, bool fLoadSection, bool fLoadSky)
|
|||
// join local players for regular games
|
||||
// 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
|
||||
if (!Game.Network.isEnabled())
|
||||
if (!::Network.isEnabled())
|
||||
if (!PlayerInfos.InitLocal())
|
||||
{ LogFatal(LoadResStr("IDS_PRC_FAIL")); return FALSE; }
|
||||
|
||||
|
|
|
@ -107,8 +107,8 @@ void C4GameControl::ChangeToLocal()
|
|||
if(eMode == CM_Network)
|
||||
{
|
||||
Network.Clear();
|
||||
if(Game.Network.isEnabled())
|
||||
Game.Network.Clear();
|
||||
if(::Network.isEnabled())
|
||||
::Network.Clear();
|
||||
}
|
||||
// replay: close playback
|
||||
else if(eMode == CM_Replay)
|
||||
|
@ -152,7 +152,7 @@ bool C4GameControl::StartRecord(bool fInitial, bool fStreaming)
|
|||
if(fStreaming)
|
||||
{
|
||||
if(!pRecord->StartStreaming(fInitial) ||
|
||||
!Game.Network.StartStreaming(pRecord))
|
||||
!::Network.StartStreaming(pRecord))
|
||||
{
|
||||
delete pRecord; pRecord = NULL;
|
||||
return false;
|
||||
|
@ -169,7 +169,7 @@ void C4GameControl::StopRecord(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
|
|||
{
|
||||
if(pRecord)
|
||||
{
|
||||
Game.Network.FinishStreaming();
|
||||
::Network.FinishStreaming();
|
||||
pRecord->Stop(pRecordName, pRecordSHA1);
|
||||
// just delete
|
||||
delete pRecord; pRecord = NULL;
|
||||
|
@ -248,7 +248,7 @@ bool C4GameControl::Prepare()
|
|||
|
||||
// deactivated and got control: request activate
|
||||
if(Input.firstPkt() && !Game.Clients.getLocal()->isActivated())
|
||||
Game.Network.RequestActivate();
|
||||
::Network.RequestActivate();
|
||||
|
||||
// needs input?
|
||||
while(Network.CtrlNeeded(Game.FrameCounter))
|
||||
|
|
|
@ -200,28 +200,28 @@ void C4GameControlNetwork::DoInput(C4PacketType eCtrlType, C4ControlPacket *pCtr
|
|||
if(!fHost)
|
||||
{
|
||||
// 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; }
|
||||
delete pCtrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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
|
||||
if(Game.Network.isFrozen())
|
||||
if(::Network.isFrozen())
|
||||
{
|
||||
pParent->ExecControlPacket(eCtrlType, pCtrl);
|
||||
delete pCtrl;
|
||||
C4PacketExecSyncCtrl Pkt(pParent->ControlTick);
|
||||
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ExecSyncCtrl, Pkt));
|
||||
::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ExecSyncCtrl, Pkt));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Safe back otherwise
|
||||
SyncControl.Add(eCtrlType, pCtrl);
|
||||
// And sync
|
||||
Game.Network.Sync();
|
||||
::Network.Sync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ void C4GameControlNetwork::DoInput(C4PacketType eCtrlType, C4ControlPacket *pCtr
|
|||
case CDT_Private:
|
||||
{
|
||||
// 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; }
|
||||
// Exec at once
|
||||
pParent->ExecControlPacket(eCtrlType, pCtrl);
|
||||
|
@ -255,7 +255,7 @@ C4ControlDeliveryType C4GameControlNetwork::DecideControlDelivery() const
|
|||
return CDT_Queue;
|
||||
// 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.
|
||||
if(Game.Network.isFrozen())
|
||||
if(::Network.isFrozen())
|
||||
return CDT_Sync;
|
||||
if(!Game.Clients.getLocal()->isActivated())
|
||||
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.
|
||||
C4PacketExecSyncCtrl Pkt(pParent->ControlTick);
|
||||
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ExecSyncCtrl, Pkt));
|
||||
::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_ExecSyncCtrl, Pkt));
|
||||
|
||||
// Execute it
|
||||
ExecSyncControl(Pkt.getControlTick());
|
||||
|
@ -378,13 +378,13 @@ void C4GameControlNetwork::SetCtrlMode(C4GameControlNetworkMode enMode) // by ma
|
|||
{
|
||||
CStdLock CtrlLock(&CtrlCSec); C4GameControlPacket *pPkt;
|
||||
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)
|
||||
{
|
||||
CStdLock CtrlLock(&CtrlCSec); C4GameControlPacket *pPkt;
|
||||
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
|
||||
// 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())
|
||||
{
|
||||
C4Network2IOConnection *pConn = pNetClt->getMsgConn();
|
||||
|
@ -588,7 +588,7 @@ void C4GameControlNetwork::HandleControlPkt(C4PacketType eCtrlType, C4ControlPac
|
|||
ExecQueuedSyncCtrl();
|
||||
|
||||
// Execute at once, if possible
|
||||
if(Game.Network.isFrozen())
|
||||
if(::Network.isFrozen())
|
||||
{
|
||||
pParent->ExecControlPacket(eCtrlType, pCtrl);
|
||||
delete pCtrl;
|
||||
|
@ -743,9 +743,9 @@ void C4GameControlNetwork::CheckCompleteCtrl(bool fSetEvent) // by both
|
|||
C4NetIOPacket Pkt = MkC4NetIOPacket(PID_ControlReq, C4PacketControlReq(iControlReady + 1));
|
||||
// send control requests
|
||||
if(eMode == CNM_Central)
|
||||
Game.Network.Clients.SendMsgToHost(Pkt);
|
||||
::Network.Clients.SendMsgToHost(Pkt);
|
||||
else
|
||||
Game.Network.Clients.BroadcastMsgToConnClients(Pkt);
|
||||
::Network.Clients.BroadcastMsgToConnClients(Pkt);
|
||||
// set time for next request
|
||||
iNextControlReqeust = timeGetTime() + C4ControlRequestInterval;
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ C4GameControlPacket *C4GameControlNetwork::PackCompleteCtrl(int32_t iTick)
|
|||
|
||||
// host: send to clients (central and async mode)
|
||||
if(eMode != CNM_Decentral)
|
||||
Game.Network.Clients.BroadcastMsgToConnClients(MkC4NetIOPacket(PID_Control, *pComplete));
|
||||
::Network.Clients.BroadcastMsgToConnClients(MkC4NetIOPacket(PID_Control, *pComplete));
|
||||
|
||||
// advance control request time
|
||||
iNextControlReqeust = Max<uint32_t>(iNextControlReqeust, timeGetTime() + C4ControlRequestInterval);
|
||||
|
|
|
@ -54,7 +54,7 @@ C4AbortGameDialog::~C4AbortGameDialog()
|
|||
|
||||
void C4AbortGameDialog::OnShown()
|
||||
{
|
||||
if(!Game.Network.isEnabled())
|
||||
if(!::Network.isEnabled())
|
||||
{
|
||||
fGameHalted = true;
|
||||
Game.HaltCount++;
|
||||
|
|
|
@ -402,9 +402,9 @@ void MainDlg::OnClosed(bool fOK)
|
|||
void MainDlg::OnRunBtn(C4GUI::Control *btn)
|
||||
{
|
||||
// only for host
|
||||
if (!Game.Network.isHost()) return;
|
||||
if (!::Network.isHost()) return;
|
||||
// already started? then abort
|
||||
if (eCountdownState) { Game.Network.AbortLobbyCountdown(); return; }
|
||||
if (eCountdownState) { ::Network.AbortLobbyCountdown(); return; }
|
||||
// otherwise start, utilizing correct countdown time
|
||||
Start(Config.Lobby.CountdownTime);
|
||||
}
|
||||
|
@ -423,10 +423,10 @@ void MainDlg::Start(int32_t iCountdownTime)
|
|||
iCountdownTime = ValidatedCountdownTime(iCountdownTime);
|
||||
// either direct start...
|
||||
if (!iCountdownTime)
|
||||
Game.Network.Start();
|
||||
::Network.Start();
|
||||
else
|
||||
// ...or countdown
|
||||
Game.Network.StartLobbyCountdown(iCountdownTime);
|
||||
::Network.StartLobbyCountdown(iCountdownTime);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
else
|
||||
Game.Network.Players.JoinLocalPlayer(plrPath.getData(), true);
|
||||
::Network.Players.JoinLocalPlayer(plrPath.getData(), true);
|
||||
}
|
||||
// ------------------------------------------------------
|
||||
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);
|
||||
C4PlayerInfo *pNfo=NULL;
|
||||
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)
|
||||
{
|
||||
// a player name is given: Parse it
|
||||
|
@ -519,7 +519,7 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
|
|||
else
|
||||
{
|
||||
// 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"));
|
||||
}
|
||||
|
@ -543,7 +543,7 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
|
|||
if (pPlrInfo)
|
||||
{
|
||||
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?
|
||||
int32_t iTimeout = Config.Lobby.CountdownTime;
|
||||
if (!Game.Network.isHost())
|
||||
if (!::Network.isHost())
|
||||
LobbyError(LoadResStr("IDS_MSG_CMD_HOSTONLY"));
|
||||
else if (szPar && *szPar && (!sscanf(szPar, "%d", &iTimeout) || iTimeout<0))
|
||||
LobbyError(LoadResStr("IDS_MSG_CMD_START_USAGE"));
|
||||
else
|
||||
{
|
||||
// abort previous countdown
|
||||
if (eCountdownState) Game.Network.AbortLobbyCountdown();
|
||||
if (eCountdownState) ::Network.AbortLobbyCountdown();
|
||||
// start new countdown (aborts previous if necessary)
|
||||
Start(iTimeout);
|
||||
}
|
||||
|
@ -569,10 +569,10 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
|
|||
// ------------------------------------------------------
|
||||
else if (SEqualNoCase(Command, "/abort"))
|
||||
{
|
||||
if (!Game.Network.isHost())
|
||||
if (!::Network.isHost())
|
||||
LobbyError(LoadResStr("IDS_MSG_CMD_HOSTONLY"));
|
||||
else if (eCountdownState)
|
||||
Game.Network.AbortLobbyCountdown();
|
||||
::Network.AbortLobbyCountdown();
|
||||
else
|
||||
LobbyError(LoadResStr("IDS_MSG_CMD_ABORT_NOCOUNTDOWN"));
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ bool MainDlg::OnMessage(C4Client *pOfClient, const char *szMessage)
|
|||
// 2do: log with player colors?
|
||||
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();
|
||||
}
|
||||
// log it
|
||||
|
@ -748,7 +748,7 @@ void MainDlg::OnClientAddPlayer(const char *szFilename, int32_t idClient)
|
|||
return;
|
||||
}
|
||||
// join!
|
||||
Game.Network.Players.JoinLocalPlayer(Config.AtRelativePath(szFilename), true);
|
||||
::Network.Players.JoinLocalPlayer(Config.AtRelativePath(szFilename), true);
|
||||
}
|
||||
|
||||
void MainDlg::OnTabPlayers(C4GUI::Control *btn)
|
||||
|
@ -868,7 +868,7 @@ void MainDlg::ClearLog()
|
|||
void LobbyError(const char *szErrorMsg)
|
||||
{
|
||||
// get lobby
|
||||
MainDlg *pLobby = Game.Network.GetLobby();
|
||||
MainDlg *pLobby = ::Network.GetLobby();
|
||||
if (pLobby) pLobby->OnError(szErrorMsg);
|
||||
}
|
||||
|
||||
|
@ -878,12 +878,12 @@ void LobbyError(const char *szErrorMsg)
|
|||
Countdown::Countdown(int32_t iStartTimer) : iStartTimer(iStartTimer)
|
||||
{
|
||||
// only on network hosts
|
||||
assert(Game.Network.isHost());
|
||||
assert(::Network.isHost());
|
||||
// ctor: Init; sends initial countdown packet
|
||||
C4PacketCountdown pck(iStartTimer);
|
||||
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck));
|
||||
::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck));
|
||||
// also process on host
|
||||
MainDlg *pLobby = Game.Network.GetLobby();
|
||||
MainDlg *pLobby = ::Network.GetLobby();
|
||||
if (pLobby)
|
||||
{
|
||||
pLobby->OnCountdownPacket(pck);
|
||||
|
@ -914,9 +914,9 @@ void Countdown::OnSec1Timer()
|
|||
!(iStartTimer % 60)) // otherwise, minute interval
|
||||
{
|
||||
C4PacketCountdown pck(iStartTimer);
|
||||
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck));
|
||||
::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck));
|
||||
// also process on host
|
||||
MainDlg *pLobby = Game.Network.GetLobby();
|
||||
MainDlg *pLobby = ::Network.GetLobby();
|
||||
if (pLobby)
|
||||
pLobby->OnCountdownPacket(pck);
|
||||
else if (iStartTimer)
|
||||
|
@ -929,25 +929,25 @@ void Countdown::OnSec1Timer()
|
|||
if (!iStartTimer)
|
||||
{
|
||||
// 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...
|
||||
Application.Quit();
|
||||
}
|
||||
// Start the game
|
||||
else
|
||||
Game.Network.Start();
|
||||
::Network.Start();
|
||||
}
|
||||
}
|
||||
|
||||
void Countdown::Abort()
|
||||
{
|
||||
// host sends packets
|
||||
if (!Game.Network.isHost()) return;
|
||||
if (!::Network.isHost()) return;
|
||||
C4PacketCountdown pck(C4PacketCountdown::Abort);
|
||||
Game.Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck));
|
||||
::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_LobbyCountdown, pck));
|
||||
// also process on host
|
||||
MainDlg *pLobby = Game.Network.GetLobby();
|
||||
MainDlg *pLobby = ::Network.GetLobby();
|
||||
if (pLobby)
|
||||
{
|
||||
pLobby->OnCountdownPacket(pck);
|
||||
|
|
|
@ -100,7 +100,7 @@ void C4GameOptionsList::OptionControlMode::DoDropdownSelChange(int32_t idNewSele
|
|||
// change possible?
|
||||
if (!Game.Control.isNetwork() || !Game.Control.Network.IsEnabled() || !Game.Control.isCtrlHost()) return;
|
||||
// perform it
|
||||
Game.Network.SetCtrlMode(idNewSelection);
|
||||
::Network.SetCtrlMode(idNewSelection);
|
||||
// update done in parent call
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ void C4GameOptionsList::OptionControlRate::Update()
|
|||
// ----------- C4GameOptionsList::OptionRuntimeJoin ----------------------------------------------------------------
|
||||
|
||||
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"));
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ void C4GameOptionsList::OptionRuntimeJoin::DoDropdownSelChange(int32_t idNewSele
|
|||
// adjust mode
|
||||
bool fAllowed = !!idNewSelection;
|
||||
Config.Network.NoRuntimeJoin = !fAllowed;
|
||||
if (Game.IsRunning) Game.Network.AllowJoin(fAllowed);
|
||||
if (Game.IsRunning) ::Network.AllowJoin(fAllowed);
|
||||
}
|
||||
|
||||
void C4GameOptionsList::OptionRuntimeJoin::Update()
|
||||
|
@ -250,7 +250,7 @@ void C4GameOptionsList::InitOptions()
|
|||
// creates option selection components
|
||||
new OptionControlMode(this);
|
||||
new OptionControlRate(this);
|
||||
if (Game.Network.isHost()) new OptionRuntimeJoin(this);
|
||||
if (::Network.isHost()) new OptionRuntimeJoin(this);
|
||||
if (!IsRuntime())
|
||||
{
|
||||
if (Game.Teams.HasTeamDistOptions()) new OptionTeamDist(this);
|
||||
|
|
|
@ -252,7 +252,7 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
|
|||
Application.Add(this);
|
||||
Update();
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -268,10 +268,10 @@ void C4GameOverDlg::Update()
|
|||
for (int32_t i=0; i<iPlrListCount; ++i) ppPlayerLists[i]->Update();
|
||||
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
|
||||
bool fBtnsVisible = fIsNetDone || !Game.Network.isHost();
|
||||
bool fBtnsVisible = fIsNetDone || !::Network.isHost();
|
||||
if (fBtnsVisible != fIsQuitBtnVisible)
|
||||
{
|
||||
fIsQuitBtnVisible = fBtnsVisible;
|
||||
|
|
|
@ -290,7 +290,7 @@ bool C4GameResList::RetrieveFiles()
|
|||
{
|
||||
const C4Network2ResCore &Core = *pResList[i]->getResCore();
|
||||
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 true;
|
||||
|
|
|
@ -294,7 +294,7 @@ void C4GameSave::WriteDescDate(StdStrBuf &sBuf, bool fRecord)
|
|||
time_t tTime; time(&tTime);
|
||||
struct tm *pLocalTime;
|
||||
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_mon+1,
|
||||
pLocalTime->tm_year+1900,
|
||||
|
@ -361,7 +361,7 @@ void C4GameSave::WriteDescNetworkClients(StdStrBuf &sBuf)
|
|||
// Desc
|
||||
sBuf.Append(LoadResStr("IDS_DESC_CLIENTS"));
|
||||
// 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()); }
|
||||
// End of line
|
||||
WriteDescLineFeed(sBuf);
|
||||
|
@ -507,7 +507,7 @@ bool C4GameSaveSavegame::OnSaving()
|
|||
// this resets playing times and stores them in the players?
|
||||
// but doing so would be too late when the queue is executed!
|
||||
// TODO: remove it? (-> PeterW ;))
|
||||
if (Game.Network.isEnabled())
|
||||
if (::Network.isEnabled())
|
||||
Game.Input.Add(CID_Synchronize, new C4ControlSynchronize(TRUE));
|
||||
else
|
||||
Game.Players.SynchronizeLocalFiles();
|
||||
|
@ -542,7 +542,7 @@ bool C4GameSaveSavegame::WriteDesc(StdStrBuf &sBuf)
|
|||
WriteDescDate(sBuf);
|
||||
WriteDescGameTime(sBuf);
|
||||
WriteDescDefinitions(sBuf);
|
||||
if (Game.Network.isEnabled()) WriteDescNetworkClients(sBuf);
|
||||
if (::Network.isEnabled()) WriteDescNetworkClients(sBuf);
|
||||
WriteDescPlayers(sBuf);
|
||||
// done, success
|
||||
return true;
|
||||
|
@ -582,7 +582,7 @@ bool C4GameSaveRecord::WriteDesc(StdStrBuf &sBuf)
|
|||
WriteDescEngine(sBuf);
|
||||
WriteDescDefinitions(sBuf);
|
||||
WriteDescLeague(sBuf, fLeague, Game.Parameters.League.getData());
|
||||
if (Game.Network.isEnabled()) WriteDescNetworkClients(sBuf);
|
||||
if (::Network.isEnabled()) WriteDescNetworkClients(sBuf);
|
||||
WriteDescPlayers(sBuf);
|
||||
// done, success
|
||||
return true;
|
||||
|
|
|
@ -152,7 +152,7 @@ void C4GraphicsSystem::Execute()
|
|||
|
||||
// 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.Network.isLobbyActive() || !Game.IsRunning)
|
||||
if(::Network.isLobbyActive() || !Game.IsRunning)
|
||||
if (Application.isFullScreen)
|
||||
{
|
||||
// Message board
|
||||
|
|
|
@ -157,7 +157,7 @@ bool Log(const char *szMessage)
|
|||
// Pass on to console
|
||||
Console.Out(szMessage);
|
||||
// pass on to lobby
|
||||
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby();
|
||||
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
|
||||
if (pLobby && Game.pGUI) pLobby->OnLog(szMessage);
|
||||
|
||||
// Add message to log buffer
|
||||
|
|
|
@ -491,7 +491,7 @@ bool C4MainMenu::ActivateHost(int32_t iPlayer)
|
|||
SetAlignment(C4MN_Align_Left | C4MN_Align_Bottom);
|
||||
SetPermanent(true);
|
||||
// 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);
|
||||
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"));
|
||||
}
|
||||
// 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"));
|
||||
}
|
||||
// Options
|
||||
AddRefSym(LoadResStr("IDS_MNU_OPTIONS"), GfxR->fctOptions.GetPhase(0), "ActivateMenu:Options",C4MN_Item_NoCount, NULL, LoadResStr("IDS_MNU_OPTIONSINFO"));
|
||||
// Disconnect
|
||||
if (Game.Network.isEnabled())
|
||||
if (::Network.isEnabled())
|
||||
{
|
||||
// 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"));
|
||||
// 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"));
|
||||
}
|
||||
// Surrender (player menu only)
|
||||
|
@ -716,9 +716,9 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
|
|||
// not in league or replay mode
|
||||
if (Game.Parameters.isLeague() || Game.C4S.Head.Replay) return false;
|
||||
// join player
|
||||
if (Game.Network.isEnabled())
|
||||
if (::Network.isEnabled())
|
||||
// 2do: not for observers and such?
|
||||
Game.Network.Players.JoinLocalPlayer(szCommand+11, true);
|
||||
::Network.Players.JoinLocalPlayer(szCommand+11, true);
|
||||
else
|
||||
Game.Players.CtrlJoinLocalNoNetwork(szCommand+11, Game.Clients.getLocalID(), Game.Clients.getLocalName());
|
||||
return true;
|
||||
|
@ -760,9 +760,9 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
|
|||
if (SEqual2(szCommand,"Host:Kick:"))
|
||||
{
|
||||
int iClientID = atoi(szCommand+10);
|
||||
if(iClientID && Game.Network.isEnabled())
|
||||
if(iClientID && ::Network.isEnabled())
|
||||
if(Game.Parameters.isLeague() && Game.Players.GetAtClient(iClientID))
|
||||
Game.Network.Vote(VT_Kick, true, iClientID);
|
||||
::Network.Vote(VT_Kick, true, iClientID);
|
||||
else
|
||||
{
|
||||
C4Client *pClient = Game.Clients.getClientByID(iClientID);
|
||||
|
@ -774,13 +774,13 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
|
|||
// Part
|
||||
if (SEqual2(szCommand,"Part"))
|
||||
{
|
||||
if(Game.Network.isEnabled())
|
||||
if(::Network.isEnabled())
|
||||
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
|
||||
{
|
||||
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, LoadResStr("IDS_ERR_GAMELEFTVIAPLAYERMENU"));
|
||||
Game.Network.Clear();
|
||||
::Network.Clear();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -446,7 +446,7 @@ bool C4MessageInput::ProcessInput(const char *szText)
|
|||
|
||||
bool C4MessageInput::ProcessCommand(const char *szCommand)
|
||||
{
|
||||
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby();
|
||||
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
|
||||
// command
|
||||
char szCmdName[C4MaxName + 1];
|
||||
SCopyUntil(szCommand + 1, szCmdName, ' ', C4MaxName);
|
||||
|
@ -481,8 +481,8 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
{
|
||||
if (!Game.IsRunning) 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 (Game.Network.isEnabled() && !Game.Network.isHost()) return FALSE;
|
||||
if (!::Network.isEnabled() && !SEqual(Game.ScenarioFile.GetMaker(), Config.General.Name) && Game.ScenarioFile.GetStatus() != GRPF_Folder) return FALSE;
|
||||
if (::Network.isEnabled() && !::Network.isHost()) return FALSE;
|
||||
|
||||
Game.Control.DoInput(CID_Script, new C4ControlScript(pCmdPar, C4ControlScript::SCOPE_Console, false), CDT_Decide);
|
||||
return TRUE;
|
||||
|
@ -507,17 +507,17 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
}
|
||||
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
|
||||
Config.Network.Comment.CopyValidated(pCmdPar[7] ? (pCmdPar+8) : "");
|
||||
Game.Network.InvalidateReference();
|
||||
::Network.InvalidateReference();
|
||||
Log(LoadResStr("IDS_NET_COMMENTCHANGED"));
|
||||
return TRUE;
|
||||
}
|
||||
if(SEqual2(pCmdPar, "password ") || SEqual(pCmdPar, "password"))
|
||||
{
|
||||
if(!Game.Network.isEnabled() || !Game.Network.isHost()) return FALSE;
|
||||
Game.Network.SetPassword(pCmdPar[8] ? (pCmdPar+9) : NULL);
|
||||
if(!::Network.isEnabled() || !::Network.isHost()) return FALSE;
|
||||
::Network.SetPassword(pCmdPar[8] ? (pCmdPar+9) : NULL);
|
||||
if (pLobby) pLobby->UpdatePassword();
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -541,12 +541,12 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
// get szen from network folder - not in lobby; use res tab there
|
||||
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();
|
||||
if (pResCoreScen)
|
||||
{
|
||||
C4Network2Res::Ref pScenario = Game.Network.ResList.getRefRes(pResCoreScen->getID());
|
||||
C4Network2Res::Ref pScenario = ::Network.ResList.getRefRes(pResCoreScen->getID());
|
||||
if (pScenario)
|
||||
if (C4Group_CopyItem(pScenario->getFile(), Config.AtUserDataPath(GetFilename(Game.ScenarioFilename))))
|
||||
{
|
||||
|
@ -578,7 +578,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
// kick client
|
||||
if(SEqual(szCmdName, "kick"))
|
||||
{
|
||||
if (Game.Network.isEnabled() && Game.Network.isHost())
|
||||
if (::Network.isEnabled() && ::Network.isHost())
|
||||
{
|
||||
// find client
|
||||
C4Client *pClient = Game.Clients.getClientByName(pCmdPar);
|
||||
|
@ -589,7 +589,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
}
|
||||
// league: Kick needs voting
|
||||
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
|
||||
// add control
|
||||
Game.Clients.CtrlRemove(pClient, LoadResStr("IDS_MSG_KICKFROMMSGBOARD"));
|
||||
|
@ -645,7 +645,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
// kick/activate/deactivate/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; }
|
||||
// search for client
|
||||
C4Client *pClient = Game.Clients.getClientByName(pCmdPar);
|
||||
|
@ -673,9 +673,9 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
// control mode
|
||||
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; }
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -574,7 +574,7 @@ void C4Network2::Execute()
|
|||
{
|
||||
// create
|
||||
C4Network2Reference *pRef = new C4Network2Reference();
|
||||
pRef->InitLocal(&Game);
|
||||
pRef->InitLocal();
|
||||
// set
|
||||
NetIO.SetReference(pRef);
|
||||
iLastReferenceUpdate = time(NULL);
|
||||
|
@ -1948,7 +1948,7 @@ bool C4Network2::LeagueStart(bool *pCancel)
|
|||
|
||||
// Do update
|
||||
C4Network2Reference Ref;
|
||||
Ref.InitLocal(&Game);
|
||||
Ref.InitLocal();
|
||||
if(!pLeagueClient->Start(Ref))
|
||||
{
|
||||
// Log message
|
||||
|
@ -2093,7 +2093,7 @@ bool C4Network2::LeagueUpdate()
|
|||
|
||||
// Create reference
|
||||
C4Network2Reference Ref;
|
||||
Ref.InitLocal(&Game);
|
||||
Ref.InitLocal();
|
||||
|
||||
// Do update
|
||||
if(!pLeagueClient->Update(Ref))
|
||||
|
@ -2175,7 +2175,7 @@ bool C4Network2::LeagueEnd(const char *szRecordName, const BYTE *pRecordSHA)
|
|||
|
||||
// Do update
|
||||
C4Network2Reference Ref;
|
||||
Ref.InitLocal(&Game);
|
||||
Ref.InitLocal();
|
||||
if(!pLeagueClient->End(Ref, szRecordName, pRecordSHA))
|
||||
{
|
||||
// Log message
|
||||
|
@ -2674,7 +2674,7 @@ void C4VoteDialog::OnClosed(bool fOK)
|
|||
{
|
||||
bool fAbortGame = false;
|
||||
// notify that this object will be deleted shortly
|
||||
Game.Network.OnVoteDialogClosed();
|
||||
::Network.OnVoteDialogClosed();
|
||||
// Was league surrender dialog
|
||||
if (fSurrender)
|
||||
{
|
||||
|
@ -2684,8 +2684,8 @@ void C4VoteDialog::OnClosed(bool fOK)
|
|||
// set game leave reason, although round results dialog isn't showing it ATM
|
||||
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, LoadResStr("IDS_ERR_YOUSURRENDEREDTHELEAGUEGA"));
|
||||
// leave game
|
||||
Game.Network.LeagueSurrender();
|
||||
Game.Network.Clear();
|
||||
::Network.LeagueSurrender();
|
||||
::Network.Clear();
|
||||
// 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
|
||||
// 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
|
||||
{
|
||||
// Vote still active? Then vote.
|
||||
if (Game.Network.GetVote(C4ClientIDUnknown, eVoteType, iVoteData))
|
||||
Game.Network.Vote(eVoteType, fOK, iVoteData);
|
||||
if (::Network.GetVote(C4ClientIDUnknown, eVoteType, iVoteData))
|
||||
::Network.Vote(eVoteType, fOK, iVoteData);
|
||||
}
|
||||
// notify base class
|
||||
MessageDialog::OnClosed(fOK);
|
||||
|
@ -2905,3 +2905,5 @@ bool C4Network2::isStreaming() const
|
|||
// Streaming must be active and there must still be anything to stream
|
||||
return fStreaming;
|
||||
}
|
||||
|
||||
C4Network2 Network;
|
||||
|
|
|
@ -70,7 +70,7 @@ void C4Network2ClientDlg::UpdateText()
|
|||
AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_FORMAT"),
|
||||
strActivated.getData(), strLocal.getData(), strHost.getData(),
|
||||
pClient->getName(), iClientID,
|
||||
Game.Network.isHost() && pNetClient && !pNetClient->isReady() ? " (!ack)" : "");
|
||||
::Network.isHost() && pNetClient && !pNetClient->isReady() ? " (!ack)" : "");
|
||||
// show addresses
|
||||
int iCnt;
|
||||
if (iCnt=pNetClient->getAddrCnt())
|
||||
|
@ -94,13 +94,13 @@ void C4Network2ClientDlg::UpdateText()
|
|||
{
|
||||
AddLineFmt(LoadResStr("IDS_NET_CLIENT_INFO_CONNECTIONS"),
|
||||
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),
|
||||
htons(pNetClient->getMsgConn()->getPeerAddr().sin_port),
|
||||
pNetClient->getMsgConn()->getPingTime());
|
||||
if(pNetClient->getMsgConn() != pNetClient->getDataConn())
|
||||
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),
|
||||
htons(pNetClient->getDataConn()->getPeerAddr().sin_port),
|
||||
pNetClient->getDataConn()->getPingTime());
|
||||
|
@ -146,8 +146,8 @@ C4Network2ClientListBox::ClientListItem::ClientListItem(class C4Network2ClientLi
|
|||
}
|
||||
pName = new C4GUI::Label(sNameLabel.getData(), iIconSize + IconLabelSpacing,iVerticalIndent, ALeft);
|
||||
int iPingRightPos = GetBounds().Wdt - IconLabelSpacing;
|
||||
if (Game.Network.isHost()) iPingRightPos -= 48;
|
||||
if (Game.Network.isHost() && pClient && !pClient->isHost())
|
||||
if (::Network.isHost()) iPingRightPos -= 48;
|
||||
if (::Network.isHost() && pClient && !pClient->isHost())
|
||||
{
|
||||
// activate/deactivate and kick btns for clients at host
|
||||
if (!pForDlg->IsStartup())
|
||||
|
@ -265,7 +265,7 @@ void C4Network2ClientListBox::ClientListItem::OnButtonKick(C4GUI::Control *pButt
|
|||
// try kick
|
||||
// league: Kick needs voting
|
||||
if(Game.Parameters.isLeague() && Game.Players.GetAtClient(iClientID))
|
||||
Game.Network.Vote(VT_Kick, true, iClientID);
|
||||
::Network.Vote(VT_Kick, true, iClientID);
|
||||
else
|
||||
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
|
||||
{
|
||||
// get connection by connection ID
|
||||
C4Network2Client *pNetClient = Game.Network.Clients.GetClientByID(iClientID);
|
||||
C4Network2Client *pNetClient = ::Network.Clients.GetClientByID(iClientID);
|
||||
if (!pNetClient) return NULL;
|
||||
if (iConnID == 0) return pNetClient->getDataConn();
|
||||
if (iConnID == 1) return pNetClient->getMsgConn();
|
||||
|
@ -340,7 +340,7 @@ void C4Network2ClientListBox::ConnectionListItem::Update()
|
|||
// update description
|
||||
// get connection usage
|
||||
const char *szConnType;
|
||||
C4Network2Client *pNetClient = Game.Network.Clients.GetClientByID(iClientID);
|
||||
C4Network2Client *pNetClient = ::Network.Clients.GetClientByID(iClientID);
|
||||
if (pNetClient->getDataConn() == pNetClient->getMsgConn())
|
||||
szConnType = "Data/Msg";
|
||||
else if (iConnID)
|
||||
|
@ -350,7 +350,7 @@ void C4Network2ClientListBox::ConnectionListItem::Update()
|
|||
// display info
|
||||
pDesc->SetText(FormatString("%s: %s (%s:%d l%d)",
|
||||
szConnType,
|
||||
Game.Network.NetIO.getNetIOName(pConn->getNetClass()),
|
||||
::Network.NetIO.getNetIOName(pConn->getNetClass()),
|
||||
inet_ntoa(pConn->getPeerAddr().sin_addr),
|
||||
htons(pConn->getPeerAddr().sin_port),
|
||||
pConn->getPacketLoss()).getData());
|
||||
|
@ -577,7 +577,7 @@ C4GameOptionButtons::C4GameOptionButtons(const C4Rect &rcBounds, bool fNetwork,
|
|||
else btnLeague=NULL;
|
||||
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"));
|
||||
AddElement(btnPassword);
|
||||
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)
|
||||
{
|
||||
fCheck = Game.Network.LeagueSignupEnable();
|
||||
fCheck = ::Network.LeagueSignupEnable();
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.Network.LeagueSignupDisable();
|
||||
::Network.LeagueSignupDisable();
|
||||
}
|
||||
}
|
||||
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;
|
||||
// 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;
|
||||
OnPasswordSet(empty);
|
||||
|
@ -671,7 +671,7 @@ void C4GameOptionButtons::OnBtnPassword(C4GUI::Control *btn)
|
|||
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));
|
||||
pDlg->SetMaxText(CFG_MaxString);
|
||||
const char *szPassPreset = Game.Network.GetPassword();
|
||||
const char *szPassPreset = ::Network.GetPassword();
|
||||
if (!szPassPreset || !*szPassPreset) szPassPreset = Config.Network.LastPassword;
|
||||
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
|
||||
const char *szPass;
|
||||
Game.Network.SetPassword(szPass=rsNewPassword.getData());
|
||||
::Network.SetPassword(szPass=rsNewPassword.getData());
|
||||
// update icon to reflect if a password is set
|
||||
UpdatePasswordBtn();
|
||||
// remember password for next round
|
||||
|
@ -696,7 +696,7 @@ void C4GameOptionButtons::OnPasswordSet(const StdStrBuf &rsNewPassword)
|
|||
void C4GameOptionButtons::UpdatePasswordBtn()
|
||||
{
|
||||
// update icon to reflect if a password is set
|
||||
const char *szPass = Game.Network.GetPassword();
|
||||
const char *szPass = ::Network.GetPassword();
|
||||
bool fHasPassword = szPass && *szPass;
|
||||
//btnPassword->SetHighlight(fHasPassword);
|
||||
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;
|
||||
// Set in configuration, update reference
|
||||
Config.Network.Comment.CopyValidated(rsNewComment.getData());
|
||||
Game.Network.InvalidateReference();
|
||||
::Network.InvalidateReference();
|
||||
// message feedback
|
||||
Log(LoadResStr("IDS_NET_COMMENTCHANGED"));
|
||||
// acoustic feedback
|
||||
|
@ -926,7 +926,7 @@ C4ChartDialog::C4ChartDialog() : Dialog(DialogWidth, DialogHeight, LoadResStr("I
|
|||
AddChart(StdStrBuf("oc"));
|
||||
AddChart(StdStrBuf("FPS"));
|
||||
AddChart(StdStrBuf("NetIO"));
|
||||
if (Game.Network.isEnabled())
|
||||
if (::Network.isEnabled())
|
||||
AddChart(StdStrBuf("Pings"));
|
||||
AddChart(StdStrBuf("Control"));
|
||||
AddChart(StdStrBuf("APM"));
|
||||
|
|
|
@ -628,7 +628,7 @@ bool C4Network2IO::Execute(int iTimeout, pollfd *)
|
|||
}
|
||||
|
||||
// ressources
|
||||
Game.Network.ResList.OnTimer();
|
||||
::Network.ResList.OnTimer();
|
||||
|
||||
// ok
|
||||
return true;
|
||||
|
@ -647,7 +647,7 @@ void C4Network2IO::OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData
|
|||
{
|
||||
C4Network2IOConnection *pConn = reinterpret_cast<C4Network2IOConnection *>(pEventData);
|
||||
// do callback
|
||||
Game.Network.OnConn(pConn);
|
||||
::Network.OnConn(pConn);
|
||||
// remove reference
|
||||
pConn->DelRef();
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ void C4Network2IO::OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData
|
|||
C4Network2IOConnection *pConn = reinterpret_cast<C4Network2IOConnection *>(pEventData);
|
||||
assert(pConn->isClosed());
|
||||
// do callback
|
||||
Game.Network.OnDisconn(pConn);
|
||||
::Network.OnDisconn(pConn);
|
||||
// remove reference
|
||||
pConn->DelRef();
|
||||
}
|
||||
|
@ -902,31 +902,31 @@ void C4Network2IO::CallHandlers(int iHandlerID, const C4IDPacket *pPkt, C4Networ
|
|||
if(iHandlerID & PH_C4Network2)
|
||||
{
|
||||
assert(!fThread);
|
||||
Game.Network.HandlePacket(cStatus, pPacket, pConn);
|
||||
::Network.HandlePacket(cStatus, pPacket, pConn);
|
||||
}
|
||||
// fullscreen lobby
|
||||
if(iHandlerID & PH_C4GUIMainDlg)
|
||||
{
|
||||
assert(!fThread);
|
||||
Game.Network.HandleLobbyPacket(cStatus, pPacket, pConn);
|
||||
::Network.HandleLobbyPacket(cStatus, pPacket, pConn);
|
||||
}
|
||||
// client list class (main thread)
|
||||
if(iHandlerID & PH_C4Network2ClientList)
|
||||
{
|
||||
assert(!fThread);
|
||||
Game.Network.Clients.HandlePacket(cStatus, pPacket, pConn);
|
||||
::Network.Clients.HandlePacket(cStatus, pPacket, pConn);
|
||||
}
|
||||
// player list class (main thread)
|
||||
if(iHandlerID & PH_C4Network2Players)
|
||||
{
|
||||
assert(!fThread);
|
||||
Game.Network.Players.HandlePacket(cStatus, pPacket, pConn);
|
||||
::Network.Players.HandlePacket(cStatus, pPacket, pConn);
|
||||
}
|
||||
// ressource list class (network thread)
|
||||
if(iHandlerID & PH_C4Network2ResList)
|
||||
{
|
||||
assert(fThread);
|
||||
Game.Network.ResList.HandlePacket(cStatus, pPacket, pConn);
|
||||
::Network.ResList.HandlePacket(cStatus, pPacket, pConn);
|
||||
}
|
||||
// network control (mixed)
|
||||
if(iHandlerID & PH_C4GameControlNetwork)
|
||||
|
@ -1262,10 +1262,10 @@ void C4Network2IO::OnPunch(C4NetIO::addr_t addr)
|
|||
addr.sin_family = AF_INET;
|
||||
ZeroMem(addr.sin_zero, sizeof(addr.sin_zero));
|
||||
// Add for local client
|
||||
C4Network2Client *pLocal = Game.Network.Clients.GetLocal();
|
||||
C4Network2Client *pLocal = ::Network.Clients.GetLocal();
|
||||
if(pLocal)
|
||||
if(pLocal->AddAddr(C4Network2Address(addr, P_UDP), true))
|
||||
Game.Network.InvalidateReference();
|
||||
::Network.InvalidateReference();
|
||||
}
|
||||
|
||||
// *** C4Network2IOConnection
|
||||
|
|
|
@ -42,13 +42,13 @@ void C4Network2Players::Init()
|
|||
// not in replay
|
||||
if (Game.C4S.Head.Replay) return;
|
||||
// network only
|
||||
assert(Game.Network.isEnabled());
|
||||
assert(::Network.isEnabled());
|
||||
// must init before game is running
|
||||
assert(!Game.IsRunning);
|
||||
// join the local player(s)
|
||||
JoinLocalPlayer(Game.PlayerFilenames, false);
|
||||
// host: Rejoin script players from savegame
|
||||
if (Game.Network.isHost())
|
||||
if (::Network.isHost())
|
||||
Game.PlayerInfos.CreateRestoreInfosForJoinedScriptPlayers(Game.RestorePlayerInfos);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ bool C4Network2Players::JoinLocalPlayer(const char *szLocalPlayerFilename, bool
|
|||
// if observing: don't try
|
||||
if (Game.Clients.getLocal()->isObserver()) return false;
|
||||
// network only
|
||||
assert(Game.Network.isEnabled());
|
||||
assert(::Network.isEnabled());
|
||||
// create join info packet
|
||||
C4ClientPlayerInfos JoinInfo(szLocalPlayerFilename, fAdd);
|
||||
// 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++)
|
||||
{
|
||||
C4PlayerInfo *pInfo = JoinInfo.GetPlayerInfo(i);
|
||||
if(!Game.Network.LeaguePlrAuth(pInfo))
|
||||
if(!::Network.LeaguePlrAuth(pInfo))
|
||||
{
|
||||
JoinInfo.RemoveIndexedInfo(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
// host or client?
|
||||
if (Game.Network.isHost())
|
||||
if (::Network.isHost())
|
||||
{
|
||||
// error joining players? Zero players is OK for initial packet; marks host as observer
|
||||
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
|
||||
// with infos of all other clients
|
||||
if (fAdd && !JoinRequest.Info.GetPlayerCount()) return false;
|
||||
Game.Network.Clients.SendMsgToHost(MkC4NetIOPacket(PID_PlayerInfoUpdReq, JoinRequest));
|
||||
::Network.Clients.SendMsgToHost(MkC4NetIOPacket(PID_PlayerInfoUpdReq, JoinRequest));
|
||||
// request activation
|
||||
if(JoinRequest.Info.GetPlayerCount() && !Game.Clients.getLocal()->isActivated())
|
||||
Game.Network.RequestActivate();
|
||||
::Network.RequestActivate();
|
||||
}
|
||||
// done, success
|
||||
return true;
|
||||
|
@ -109,9 +109,9 @@ bool C4Network2Players::JoinLocalPlayer(const char *szLocalPlayerFilename, bool
|
|||
void C4Network2Players::RequestPlayerInfoUpdate(const class C4ClientPlayerInfos &rRequest)
|
||||
{
|
||||
// network only
|
||||
assert(Game.Network.isEnabled());
|
||||
assert(::Network.isEnabled());
|
||||
// host or client?
|
||||
if (Game.Network.isHost())
|
||||
if (::Network.isHost())
|
||||
{
|
||||
// host processes directly
|
||||
HandlePlayerInfoUpdRequest(&rRequest, true);
|
||||
|
@ -120,15 +120,15 @@ void C4Network2Players::RequestPlayerInfoUpdate(const class C4ClientPlayerInfos
|
|||
{
|
||||
// client sends request to host
|
||||
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)
|
||||
{
|
||||
// network host only
|
||||
assert(Game.Network.isEnabled());
|
||||
assert(Game.Network.isHost());
|
||||
assert(::Network.isEnabled());
|
||||
assert(::Network.isHost());
|
||||
// copy client infos (need to be adjusted)
|
||||
C4ClientPlayerInfos OwnInfoPacket(*pInfoPacket);
|
||||
// safety: check any duplicate, unjoined players first
|
||||
|
@ -182,7 +182,7 @@ void C4Network2Players::HandlePlayerInfoUpdRequest(const class C4ClientPlayerInf
|
|||
if (Game.Parameters.isLeague())
|
||||
{
|
||||
// lobby only
|
||||
if(!Game.Network.isLobbyActive())
|
||||
if(!::Network.isLobbyActive())
|
||||
return;
|
||||
// check league authentication for new players
|
||||
for(int i = 0; i < OwnInfoPacket.GetPlayerCount(); i++)
|
||||
|
@ -190,7 +190,7 @@ void C4Network2Players::HandlePlayerInfoUpdRequest(const class C4ClientPlayerInf
|
|||
{
|
||||
C4PlayerInfo *pInfo = OwnInfoPacket.GetPlayerInfo(i);
|
||||
// remove player infos without authentication
|
||||
if(!Game.Network.LeaguePlrAuthCheck(pInfo))
|
||||
if(!::Network.LeaguePlrAuthCheck(pInfo))
|
||||
{
|
||||
OwnInfoPacket.RemoveIndexedInfo(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
|
||||
Game.Control.DoInput(CID_PlrInfo, new C4ControlPlayerInfo(OwnInfoPacket), CDT_Direct);
|
||||
// notify lobby of updates
|
||||
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby();
|
||||
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
|
||||
if (pLobby) pLobby->OnPlayersChange();
|
||||
}
|
||||
|
||||
void C4Network2Players::HandlePlayerInfo(const class C4ClientPlayerInfos &rInfoPacket)
|
||||
{
|
||||
// network only
|
||||
assert(Game.Network.isEnabled());
|
||||
assert(::Network.isEnabled());
|
||||
// copy client player infos out of packet to be used in local list
|
||||
C4ClientPlayerInfos *pClientInfo = new C4ClientPlayerInfos(rInfoPacket);
|
||||
// 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());
|
||||
// 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
|
||||
JoinUnjoinedPlayersInControlQueue(pClientInfo);
|
||||
}
|
||||
}
|
||||
// lobby: update players
|
||||
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby();
|
||||
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
|
||||
if (pLobby) pLobby->OnPlayersChange();
|
||||
// invalidate reference
|
||||
Game.Network.InvalidateReference();
|
||||
::Network.InvalidateReference();
|
||||
}
|
||||
|
||||
void C4Network2Players::SendUpdatedPlayers()
|
||||
|
@ -320,7 +320,7 @@ void C4Network2Players::ResetUpdatedPlayers()
|
|||
void C4Network2Players::JoinUnjoinedPlayersInControlQueue(C4ClientPlayerInfos *pNewPacket)
|
||||
{
|
||||
// only host may join any players to the queue
|
||||
assert(Game.Network.isHost());
|
||||
assert(::Network.isHost());
|
||||
// check all players
|
||||
int i=0; C4PlayerInfo *pInfo;
|
||||
while (pInfo = pNewPacket->GetPlayerInfo(i++))
|
||||
|
@ -332,7 +332,7 @@ void C4Network2Players::JoinUnjoinedPlayersInControlQueue(C4ClientPlayerInfos *p
|
|||
pInfo->SetJoinIssued();
|
||||
// do so!
|
||||
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 (pInfo->GetType() != C4PT_Script)
|
||||
{
|
||||
|
@ -361,8 +361,8 @@ void C4Network2Players::HandlePacket(char cStatus, const C4PacketBase *pPacket,
|
|||
if(!pConn) return;
|
||||
|
||||
// find associated client
|
||||
C4Network2Client *pClient = Game.Network.Clients.GetClient(pConn);
|
||||
if(!pClient) pClient = Game.Network.Clients.GetClientByID(pConn->getClientID());
|
||||
C4Network2Client *pClient = ::Network.Clients.GetClient(pConn);
|
||||
if(!pClient) pClient = ::Network.Clients.GetClientByID(pConn->getClientID());
|
||||
|
||||
#define GETPKT(type, name) \
|
||||
assert(pPacket); const type &name = \
|
||||
|
@ -373,7 +373,7 @@ void C4Network2Players::HandlePacket(char cStatus, const C4PacketBase *pPacket,
|
|||
{
|
||||
GETPKT(C4PacketPlayerInfoUpdRequest, pkPlrInfo);
|
||||
// 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
|
||||
HandlePlayerInfoUpdRequest(&pkPlrInfo.Info, false);
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ void C4Network2Players::OnClientPart(C4Client *pPartClient)
|
|||
// update team association to left player
|
||||
Game.Teams.RecheckPlayers();
|
||||
// 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
|
||||
rInfoList.UpdatePlayerAttributes();
|
||||
|
@ -425,14 +425,14 @@ void C4Network2Players::OnClientPart(C4Client *pPartClient)
|
|||
SendUpdatedPlayers();
|
||||
}
|
||||
// invalidate reference
|
||||
if(Game.Network.isHost())
|
||||
Game.Network.InvalidateReference();
|
||||
if(::Network.isHost())
|
||||
::Network.InvalidateReference();
|
||||
}
|
||||
|
||||
void C4Network2Players::OnStatusGoReached()
|
||||
{
|
||||
// host only
|
||||
if (!Game.Network.isHost()) return;
|
||||
if (!::Network.isHost()) return;
|
||||
// check all player lists
|
||||
int i=0; C4ClientPlayerInfos *pkInfo;
|
||||
while (pkInfo = rInfoList.GetIndexedInfo(i++))
|
||||
|
|
|
@ -50,10 +50,10 @@ void C4Network2Reference::SetSourceIP(in_addr ip)
|
|||
}
|
||||
|
||||
#ifdef C4ENGINE
|
||||
void C4Network2Reference::InitLocal(C4Game *pGame)
|
||||
void C4Network2Reference::InitLocal()
|
||||
{
|
||||
// Copy all game parameters
|
||||
Parameters = pGame->Parameters;
|
||||
Parameters = ::Game.Parameters;
|
||||
|
||||
// Discard player resources (we don't want these infos in the reference)
|
||||
C4ClientPlayerInfos *pClientInfos; C4PlayerInfo *pPlayerInfo;
|
||||
|
@ -63,22 +63,22 @@ void C4Network2Reference::InitLocal(C4Game *pGame)
|
|||
pPlayerInfo->DiscardResource();
|
||||
|
||||
// Special additional information in reference
|
||||
Icon = pGame->C4S.Head.Icon;
|
||||
Title.CopyValidated(pGame->ScenarioTitle);
|
||||
GameStatus = pGame->Network.Status;
|
||||
Time = pGame->Time;
|
||||
Frame = pGame->FrameCounter;
|
||||
StartTime = pGame->StartTime;
|
||||
LeaguePerformance = pGame->RoundResults.GetLeaguePerformance();
|
||||
Icon = ::Game.C4S.Head.Icon;
|
||||
Title.CopyValidated(::Game.ScenarioTitle);
|
||||
GameStatus = ::Network.Status;
|
||||
Time = ::Game.Time;
|
||||
Frame = ::Game.FrameCounter;
|
||||
StartTime = ::Game.StartTime;
|
||||
LeaguePerformance = ::Game.RoundResults.GetLeaguePerformance();
|
||||
Comment = Config.Network.Comment;
|
||||
JoinAllowed = pGame->Network.isJoinAllowed();
|
||||
ObservingAllowed = pGame->Network.isObservingAllowed();
|
||||
PasswordNeeded = pGame->Network.isPassworded();
|
||||
RegJoinOnly = pGame->RegJoinOnly;
|
||||
JoinAllowed = ::Network.isJoinAllowed();
|
||||
ObservingAllowed = ::Network.isObservingAllowed();
|
||||
PasswordNeeded = ::Network.isPassworded();
|
||||
RegJoinOnly = ::Game.RegJoinOnly;
|
||||
Game.Set();
|
||||
|
||||
// Addresses
|
||||
C4Network2Client *pLocalNetClient = pGame->Clients.getLocal()->getNetClient();
|
||||
C4Network2Client *pLocalNetClient = ::Game.Clients.getLocal()->getNetClient();
|
||||
iAddrCnt = pLocalNetClient->getAddrCnt();
|
||||
for(i = 0; i < iAddrCnt; i++)
|
||||
Addrs[i] = pLocalNetClient->getAddr(i);
|
||||
|
|
|
@ -136,7 +136,7 @@ void C4Network2ResDlg::ListItem::LocalSaveResource(bool fDoOverwrite)
|
|||
C4Network2Res::Ref C4Network2ResDlg::ListItem::GetRefRes()
|
||||
{
|
||||
// forward to network reslist
|
||||
return Game.Network.ResList.getRefRes(iResID);
|
||||
return ::Network.ResList.getRefRes(iResID);
|
||||
}
|
||||
|
||||
bool C4Network2ResDlg::ListItem::IsSavePossible()
|
||||
|
@ -189,7 +189,7 @@ void C4Network2ResDlg::Update()
|
|||
// check through own resources and current res list
|
||||
ListItem *pItem = static_cast<ListItem *>(pClientWindow->GetFirst()), *pNext;
|
||||
C4Network2Res *pRes; int iResID=-1;
|
||||
while (pRes = Game.Network.ResList.getRefNextRes(++iResID))
|
||||
while (pRes = ::Network.ResList.getRefNextRes(++iResID))
|
||||
{
|
||||
iResID = pRes->getResID();
|
||||
// resource checking: deleted ressource(s) present?
|
||||
|
|
|
@ -324,14 +324,14 @@ C4Network2Stats::C4Network2Stats()
|
|||
statActions.SetAverageTime(100);
|
||||
for (C4Player *pPlr = Game.Players.First; pPlr; pPlr = pPlr->Next) pPlr->CreateGraphs();
|
||||
C4Network2Client *pClient = NULL;
|
||||
while (pClient = Game.Network.Clients.GetNextClient(pClient)) pClient->CreateGraphs();
|
||||
while (pClient = ::Network.Clients.GetNextClient(pClient)) pClient->CreateGraphs();
|
||||
}
|
||||
|
||||
C4Network2Stats::~C4Network2Stats()
|
||||
{
|
||||
for (C4Player *pPlr = Game.Players.First; pPlr; pPlr = pPlr->Next) pPlr->ClearGraphs();
|
||||
C4Network2Client *pClient = NULL;
|
||||
while (pClient = Game.Network.Clients.GetNextClient(pClient)) pClient->ClearGraphs();
|
||||
while (pClient = ::Network.Clients.GetNextClient(pClient)) pClient->ClearGraphs();
|
||||
Application.Remove(this);
|
||||
}
|
||||
|
||||
|
@ -343,11 +343,11 @@ void C4Network2Stats::ExecuteFrame()
|
|||
void C4Network2Stats::ExecuteSecond()
|
||||
{
|
||||
statFPS.RecordValue(C4Graph::ValueType(Game.FPS));
|
||||
statNetI.RecordValue(C4Graph::ValueType(Game.Network.NetIO.getProtIRate(P_TCP) + Game.Network.NetIO.getProtIRate(P_UDP)));
|
||||
statNetO.RecordValue(C4Graph::ValueType(Game.Network.NetIO.getProtORate(P_TCP) + Game.Network.NetIO.getProtORate(P_UDP)));
|
||||
statNetI.RecordValue(C4Graph::ValueType(::Network.NetIO.getProtIRate(P_TCP) + ::Network.NetIO.getProtIRate(P_UDP)));
|
||||
statNetO.RecordValue(C4Graph::ValueType(::Network.NetIO.getProtORate(P_TCP) + ::Network.NetIO.getProtORate(P_UDP)));
|
||||
// pings for all clients
|
||||
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;
|
||||
C4Network2IOConnection *pConn = pClient->getMsgConn();
|
||||
|
|
|
@ -435,7 +435,7 @@ BOOL C4Player::Save()
|
|||
// Close group
|
||||
if (!hGroup.Close()) return FALSE;
|
||||
// resource
|
||||
C4Network2Res::Ref pRes = Game.Network.ResList.getRefRes(Filename),
|
||||
C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(Filename),
|
||||
pDRes = NULL;
|
||||
bool fOfficial = pRes && Game.Control.isCtrlHost();
|
||||
if(pRes) pDRes = pRes->Derive();
|
||||
|
|
|
@ -93,14 +93,14 @@ bool C4PlayerInfo::LoadFromLocalFile(const char *szFilename)
|
|||
dwColor = dwOriginalColor = C4P.PrefColorDw & 0xffffff; // ignore alpha
|
||||
dwAlternateColor = C4P.PrefColor2Dw & 0xffffff; // ignore alpha
|
||||
// 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
|
||||
// 2do: rejoining players need to update their ressource version when saving the player
|
||||
// otherwise, player file versions may differ
|
||||
pRes = Game.Network.ResList.getRefRes(szFilename, true);
|
||||
pRes = ::Network.ResList.getRefRes(szFilename, true);
|
||||
// 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;
|
||||
// set core and flag
|
||||
ResCore = pRes->getCore();
|
||||
|
@ -300,7 +300,7 @@ void C4PlayerInfo::LoadResource()
|
|||
dwFlags &= ~PIF_HasRes;
|
||||
else
|
||||
// create resource (will check if resource already exists)
|
||||
if (!(pRes = Game.Network.ResList.AddByCore(ResCore)))
|
||||
if (!(pRes = ::Network.ResList.AddByCore(ResCore)))
|
||||
{
|
||||
dwFlags &= ~PIF_HasRes;
|
||||
// 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
|
||||
bool fSucc = true;
|
||||
if (Game.Control.isNetwork())
|
||||
Game.Network.Players.RequestPlayerInfoUpdate(*pUpdate);
|
||||
::Network.Players.RequestPlayerInfoUpdate(*pUpdate);
|
||||
else
|
||||
fSucc = DoLocalNonNetworkPlayerInfoUpdate(pUpdate);
|
||||
return fSucc;
|
||||
|
@ -880,7 +880,7 @@ C4ClientPlayerInfos *C4PlayerInfoList::AddInfo(C4ClientPlayerInfos *pNewClientIn
|
|||
// caution: also called for RestorePlayerInfos-list
|
||||
// host: reserve new IDs for all players
|
||||
// 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())
|
||||
{
|
||||
|
@ -1317,7 +1317,7 @@ bool C4PlayerInfoList::InitLocal()
|
|||
// no double init
|
||||
assert(!GetInfoCount());
|
||||
// no network
|
||||
assert(!Game.Network.isEnabled());
|
||||
assert(!::Network.isEnabled());
|
||||
// create player info for local player joins
|
||||
C4ClientPlayerInfos *pLocalInfo = new C4ClientPlayerInfos(Game.PlayerFilenames);
|
||||
// register local info immediately
|
||||
|
@ -1334,7 +1334,7 @@ bool C4PlayerInfoList::InitLocal()
|
|||
bool C4PlayerInfoList::LocalJoinUnjoinedPlayersInQueue()
|
||||
{
|
||||
// local call only - in network, C4Network2Players joins players!
|
||||
assert(!Game.Network.isEnabled());
|
||||
assert(!::Network.isEnabled());
|
||||
// get local players
|
||||
C4ClientPlayerInfos **ppkLocal = GetInfoPtrByClientID(Game.Control.ClientID()), *pkLocal;
|
||||
if (!ppkLocal) return false;
|
||||
|
@ -1410,7 +1410,7 @@ bool C4PlayerInfoList::RestoreSavegameInfos(C4PlayerInfoList &rSavegamePlayers)
|
|||
// do savegame player association of real players
|
||||
// for non-lobby games do automatic association first
|
||||
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
|
||||
for (int eMatchingLevel = 0; eMatchingLevel <= PML_Any; ++eMatchingLevel)
|
||||
|
@ -1582,7 +1582,7 @@ bool C4PlayerInfoList::RecreatePlayers()
|
|||
szAtClientName = "Replay";
|
||||
else
|
||||
// local non-network non-replay games set local name
|
||||
if (!Game.Network.isEnabled())
|
||||
if (!::Network.isEnabled())
|
||||
{
|
||||
assert(idAtClient == Game.Control.ClientID());
|
||||
szAtClientName = "Local";
|
||||
|
@ -1613,7 +1613,7 @@ bool C4PlayerInfoList::RecreatePlayers()
|
|||
if (szFilename && pJoinRes && pJoinRes->isLoading())
|
||||
{
|
||||
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()))
|
||||
szFilename=NULL;
|
||||
}
|
||||
|
@ -1701,7 +1701,7 @@ bool C4PlayerInfoList::SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fS
|
|||
{
|
||||
// in the game: Set filename for inside savegame file
|
||||
StdStrBuf sNewName;
|
||||
if (Game.Network.isEnabled())
|
||||
if (::Network.isEnabled())
|
||||
{
|
||||
C4Client *pGameClient = Game.Clients.getClientByID(pClient->GetClientID());
|
||||
const char *szName = pGameClient ? pGameClient->getName() : "Unknown";
|
||||
|
|
|
@ -38,7 +38,7 @@ DWORD GenerateRandomPlayerColor(int32_t iTry); // in C4PlayerInfoConflicts.cpp
|
|||
// helper
|
||||
C4GameLobby::MainDlg *C4PlayerInfoListBox::ListItem::GetLobby() const
|
||||
{
|
||||
return Game.Network.GetLobby();
|
||||
return ::Network.GetLobby();
|
||||
}
|
||||
|
||||
bool C4PlayerInfoListBox::ListItem::CanLocalChooseTeams(int32_t idPlayer) const
|
||||
|
@ -258,7 +258,7 @@ void C4PlayerInfoListBox::PlayerListItem::UpdateIcon(C4PlayerInfo *pInfo, C4Play
|
|||
fResPresent = pRes->isComplete();
|
||||
C4RoundResultsPlayer *pEvaluationPlayer = NULL;
|
||||
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
|
||||
bool fHasJoinedInfo = !!pJoinedInfo;
|
||||
DWORD dwJoinedInfoClr = pJoinedInfo ? pJoinedInfo->GetLobbyColor() : 0;
|
||||
|
@ -506,7 +506,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::PlayerListItem::OnContext(C4GUI::Elemen
|
|||
else
|
||||
{
|
||||
// owned players or host can manipulate players
|
||||
if (Game.Network.isHost() || IsLocalClientPlayer())
|
||||
if (::Network.isHost() || IsLocalClientPlayer())
|
||||
{
|
||||
// player removal (except for joined script players)
|
||||
if (pInfo->GetType() != C4PT_Script || !pInfo->GetAssociatedSavegamePlayerID())
|
||||
|
@ -535,7 +535,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::PlayerListItem::OnContextTakeOver(C4GUI
|
|||
// create context menu
|
||||
C4GUI::ContextMenu *pMenu = new C4GUI::ContextMenu();
|
||||
// add options for all own, unassigned players
|
||||
C4ClientPlayerInfos *pkInfo = Game.Network.Players.GetLocalPlayerInfoPacket();
|
||||
C4ClientPlayerInfos *pkInfo = ::Network.Players.GetLocalPlayerInfoPacket();
|
||||
if (pkInfo)
|
||||
{
|
||||
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
|
||||
// this must be processed as a request by the host
|
||||
// some safety first...
|
||||
C4ClientPlayerInfos *pLocalInfo = Game.Network.Players.GetLocalPlayerInfoPacket();
|
||||
C4ClientPlayerInfos *pLocalInfo = ::Network.Players.GetLocalPlayerInfoPacket();
|
||||
if (!fFreeSavegamePlayer || !idPlayer || !pLocalInfo) return;
|
||||
C4ClientPlayerInfos LocalInfoRequest(*pLocalInfo);
|
||||
C4PlayerInfo *pGrabbingInfo = LocalInfoRequest.GetPlayerInfoByID(idPlayer);
|
||||
|
@ -569,13 +569,13 @@ void C4PlayerInfoListBox::PlayerListItem::OnCtxTakeOver(C4GUI::Element *pListIte
|
|||
// now adjust info packet
|
||||
pGrabbingInfo->SetAssociatedSavegamePlayer(this->idPlayer);
|
||||
// and request this update (host processes it directly)
|
||||
Game.Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
|
||||
::Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
|
||||
}
|
||||
|
||||
void C4PlayerInfoListBox::PlayerListItem::OnCtxRemove(C4GUI::Element *pListItem)
|
||||
{
|
||||
// only host or own player
|
||||
if (!Game.Network.isEnabled() || (!Game.Network.isHost() && !IsLocalClientPlayer())) return;
|
||||
if (!::Network.isEnabled() || (!::Network.isHost() && !IsLocalClientPlayer())) return;
|
||||
// remove the player
|
||||
// this must be processed as a request by the host
|
||||
// now change it in its own request packet
|
||||
|
@ -585,13 +585,13 @@ void C4PlayerInfoListBox::PlayerListItem::OnCtxRemove(C4GUI::Element *pListItem)
|
|||
if (!LocalInfoRequest.GetPlayerInfoByID(idPlayer)) return;
|
||||
LocalInfoRequest.RemoveInfo(idPlayer);
|
||||
// and request this update (host processes it directly)
|
||||
Game.Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
|
||||
::Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
|
||||
}
|
||||
|
||||
void C4PlayerInfoListBox::PlayerListItem::OnCtxNewColor(C4GUI::Element *pListItem)
|
||||
{
|
||||
// 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
|
||||
// the host will deny this and decide on a new color
|
||||
C4ClientPlayerInfos *pChangeInfo = Game.PlayerInfos.GetInfoByClientID(idClient);
|
||||
|
@ -601,7 +601,7 @@ void C4PlayerInfoListBox::PlayerListItem::OnCtxNewColor(C4GUI::Element *pListIte
|
|||
if (!pPlrInfo) return;
|
||||
pPlrInfo->SetColor(pPlrInfo->GetOriginalColor());
|
||||
// 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)
|
||||
|
@ -629,7 +629,7 @@ bool C4PlayerInfoListBox::PlayerListItem::OnTeamComboSelChange(C4GUI::ComboBox *
|
|||
if (!pChangedInfo) return true;
|
||||
pChangedInfo->SetTeam(pNewTeam->GetID());
|
||||
// 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
|
||||
return true;
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ bool C4PlayerInfoListBox::PlayerListItem::CanLocalChooseTeam() const
|
|||
// never on savegame players
|
||||
if (fFreeSavegamePlayer || GetJoinedInfo()) return false;
|
||||
// only host or own player
|
||||
if (!Game.Network.isHost() && !IsLocalClientPlayer()) return false;
|
||||
if (!::Network.isHost() && !IsLocalClientPlayer()) return false;
|
||||
// finally, only if team settings permit
|
||||
return CanLocalChooseTeams(idPlayer);
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ bool C4PlayerInfoListBox::PlayerListItem::IsLocalClientPlayer() 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()
|
||||
{
|
||||
// update color (always, because it can change silently)
|
||||
SetColor(Game.Network.Players.GetClientChatColor(idClient, true));
|
||||
SetColor(::Network.Players.GetClientChatColor(idClient, true));
|
||||
// update activation status
|
||||
fIsShownActive = GetClient() && GetClient()->isActivated();
|
||||
// update status icon
|
||||
|
@ -820,7 +820,7 @@ bool C4PlayerInfoListBox::ClientListItem::IsLocalClientPlayer() const
|
|||
|
||||
C4Network2Client *C4PlayerInfoListBox::ClientListItem::GetNetClient() const
|
||||
{
|
||||
return Game.Network.Clients.GetClientByID(idClient);
|
||||
return ::Network.Clients.GetClientByID(idClient);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// safety
|
||||
if (!Game.Network.isEnabled()) return NULL;
|
||||
if (!::Network.isEnabled()) return NULL;
|
||||
// get associated client
|
||||
C4Client *pClient = GetClient();
|
||||
// create context menu
|
||||
C4GUI::ContextMenu *pMenu = new C4GUI::ContextMenu();
|
||||
// host options
|
||||
if (Game.Network.isHost() && GetNetClient())
|
||||
if (::Network.isHost() && GetNetClient())
|
||||
{
|
||||
StdCopyStrBuf strKickDesc(LoadResStr("IDS_NET_KICKCLIENT_DESC"));
|
||||
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)
|
||||
{
|
||||
// host only
|
||||
if (!Game.Network.isEnabled() || !Game.Network.isHost()) return;
|
||||
if (!::Network.isEnabled() || !::Network.isHost()) return;
|
||||
// add control
|
||||
Game.Clients.CtrlRemove(GetClient(), LoadResStr("IDS_MSG_KICKFROMLOBBY"));
|
||||
}
|
||||
|
@ -931,7 +931,7 @@ void C4PlayerInfoListBox::ClientListItem::OnCtxActivate(C4GUI::Element *pListIte
|
|||
{
|
||||
// host only
|
||||
C4Client *pClient = GetClient();
|
||||
if (!Game.Network.isEnabled() || !Game.Network.isHost() || !pClient) return;
|
||||
if (!::Network.isEnabled() || !::Network.isHost() || !pClient) return;
|
||||
// add control
|
||||
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;
|
||||
// and request this update (host processes it directly)
|
||||
Game.Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
|
||||
::Network.Players.RequestPlayerInfoUpdate(LocalInfoRequest);
|
||||
// next update will move the player labels
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
assert(!Game.Network.isEnabled());
|
||||
assert(!::Network.isEnabled());
|
||||
// Create temp copy of player file without portraits
|
||||
// Why? This is local join!
|
||||
/*
|
||||
|
@ -485,7 +485,7 @@ BOOL C4PlayerList::FileInUse(const char *szFilename) const
|
|||
if (ItemIdentical(cPlr->Filename,szFilename))
|
||||
return TRUE;
|
||||
// Compare to any network path player files with prefix (hack)
|
||||
if (Game.Network.isEnabled())
|
||||
if (::Network.isEnabled())
|
||||
{
|
||||
char szWithPrefix[_MAX_PATH+1];
|
||||
SCopy(GetFilename(szFilename),szWithPrefix);
|
||||
|
|
|
@ -1479,7 +1479,7 @@ void C4StartupScenSelDlg::OnClosed(bool fOK)
|
|||
if (!fOK)
|
||||
{
|
||||
// clear settings: Password
|
||||
Game.Network.SetPassword(NULL);
|
||||
::Network.SetPassword(NULL);
|
||||
C4Startup::Get()->SwitchDialog(C4Startup::SDID_Back);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -451,7 +451,7 @@ bool C4TeamList::IsTeamVisible() const
|
|||
{
|
||||
// teams invisible during lobby time if random surprise teams
|
||||
if (eTeamDist == TEAMDIST_RandomInv)
|
||||
if (Game.Network.isLobbyActive())
|
||||
if (::Network.isLobbyActive())
|
||||
return false;
|
||||
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
|
||||
// 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
|
||||
bool fWillHaveLobby = Game.Network.isEnabled() && !Game.Network.Status.isPastLobby() && Game.fLobby;
|
||||
bool fHasOrWillHaveLobby = Game.Network.isLobbyActive() || fWillHaveLobby;
|
||||
bool fWillHaveLobby = ::Network.isEnabled() && !::Network.Status.isPastLobby() && Game.fLobby;
|
||||
bool fHasOrWillHaveLobby = ::Network.isLobbyActive() || fWillHaveLobby;
|
||||
bool fCanPickTeamAtRuntime = !IsRandomTeam() && (rNewJoin.GetType() == C4PT_User) && IsRuntimeJoinTeamChoice();
|
||||
bool fIsTeamNeeded = IsRuntimeJoinTeamChoice() || GetTeamCount();
|
||||
if (!fHasOrWillHaveLobby && (!fIsTeamNeeded || fCanPickTeamAtRuntime)) return false;
|
||||
|
@ -798,9 +798,9 @@ void C4TeamList::SetTeamDistribution(TeamDist eToVal)
|
|||
RecheckTeams();
|
||||
}
|
||||
// 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;
|
||||
// go through all player infos; reset color in them
|
||||
Game.PlayerInfos.UpdatePlayerAttributes(); // sets team and savegame colors
|
||||
if (Game.Network.isEnabled())
|
||||
if (::Network.isEnabled())
|
||||
{
|
||||
// sends color updates to all clients
|
||||
Game.Network.Players.SendUpdatedPlayers();
|
||||
::Network.Players.SendUpdatedPlayers();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1122,7 +1122,7 @@ void C4Viewport::Draw(C4TargetFacet &cgo, bool fDrawOverlay)
|
|||
|
||||
// Netstats
|
||||
if (::GraphicsSystem.ShowNetstatus)
|
||||
Game.Network.DrawStatus(cgo);
|
||||
::Network.DrawStatus(cgo);
|
||||
|
||||
C4ST_STOP(OvrStat)
|
||||
|
||||
|
|
Loading…
Reference in New Issue