Move Game.Control to ::Control

stable-5.2
Günther Brammer 2009-06-16 00:06:37 +02:00
parent 078a0ca9e4
commit c901530ee1
39 changed files with 226 additions and 190 deletions

View File

@ -30,7 +30,6 @@
#include <C4PlayerInfo.h>
#include <C4RoundResults.h>
#include <C4Scenario.h>
#include <C4GameControl.h>
#include <C4Control.h>
#include <C4PathFinder.h>
#include <C4Extra.h>
@ -80,7 +79,6 @@ class C4Game
C4GameScriptHost Script;
C4LangStringTable MainSysLangStringTable, ScenarioLangStringTable, ScenarioSysLangStringTable;
StdStrBuf PlayerNames;
C4GameControl Control;
C4Control &Input; // shortcut
C4PathFinder PathFinder;

View File

@ -166,5 +166,6 @@ protected:
void RemoveOldSyncChecks();
};
extern C4GameControl Control;
#endif // INC_C4GameControl

View File

@ -26,6 +26,7 @@
#include <C4Game.h>
#include <C4Log.h>
#include <C4PlayerList.h>
#include <C4GameControl.h>
#endif
#ifndef HAVE_WINSOCK
@ -321,7 +322,7 @@ void C4ClientList::CtrlRemove(const C4Client *pClient, const char *szReason)
if(pClient->getNetClient())
pClient->getNetClient()->SetStatus(NCS_Remove);
// add control
Game.Control.DoInput(CID_ClientRemove,
::Control.DoInput(CID_ClientRemove,
new C4ControlClientRemove(pClient->getID(), szReason),
CDT_Sync);
}

View File

@ -37,6 +37,7 @@
#include <C4Landscape.h>
#include <C4GraphicsSystem.h>
#include <C4PlayerList.h>
#include <C4GameControl.h>
#include <StdFile.h>
#include <StdRegistry.h>
@ -267,14 +268,14 @@ BOOL CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
// Remove player
if (Inside((int) LOWORD(wParam),IDM_PLAYER_QUIT1,IDM_PLAYER_QUIT2))
{
Game.Control.Input.Add(CID_Script, new C4ControlScript(
::Control.Input.Add(CID_Script, new C4ControlScript(
FormatString("EliminatePlayer(%d)", LOWORD(wParam)-IDM_PLAYER_QUIT1).getData()));
return TRUE;
}
// Remove client
if (Inside((int) LOWORD(wParam),IDM_NET_CLIENT1,IDM_NET_CLIENT2))
{
if(!Game.Control.isCtrlHost()) return FALSE;
if(!::Control.isCtrlHost()) return FALSE;
Game.Clients.CtrlRemove(Game.Clients.getClientByID(LOWORD(wParam)-IDM_NET_CLIENT1), LoadResStr("IDS_MSG_KICKBYMENU"));
return TRUE;
}
@ -612,7 +613,7 @@ bool C4Console::In(const char *szText)
// editing enabled?
if (!EditCursor.EditingOK()) return FALSE;
// pass through network queue
Game.Control.DoInput(CID_Script, new C4ControlScript(szText, C4ControlScript::SCOPE_Console, false), CDT_Decide);
::Control.DoInput(CID_Script, new C4ControlScript(szText, C4ControlScript::SCOPE_Console, false), CDT_Decide);
return TRUE;
}
@ -877,7 +878,7 @@ void C4Console::EnableControls(bool fEnable)
{
if (!Active) return;
// disable Editing if no input allowed
Editing &= !Game.Control.NoInput();
Editing &= !::Control.NoInput();
#ifdef _WIN32
// Set button images (edit modes & halt controls)
@ -906,7 +907,7 @@ void C4Console::EnableControls(bool fEnable)
// C4Network2 will have to handle that cases somehow (TODO: test)
EnableMenuItem(GetMenu(hWindow),IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED );
EnableMenuItem(GetMenu(hWindow),IDM_FILE_OPENWPLRS, MF_BYCOMMAND | MF_ENABLED );
EnableMenuItem(GetMenu(hWindow),IDM_FILE_RECORD, MF_BYCOMMAND | ((Game.IsRunning && Game.Control.IsRuntimeRecordPossible()) ? MF_ENABLED : MF_GRAYED));
EnableMenuItem(GetMenu(hWindow),IDM_FILE_RECORD, MF_BYCOMMAND | ((Game.IsRunning && ::Control.IsRuntimeRecordPossible()) ? MF_ENABLED : MF_GRAYED));
EnableMenuItem(GetMenu(hWindow),IDM_FILE_SAVEGAME, MF_BYCOMMAND | ((fEnable && ::Players.GetCount()) ? MF_ENABLED : MF_GRAYED));
EnableMenuItem(GetMenu(hWindow),IDM_FILE_SAVEGAMEAS, MF_BYCOMMAND | ((fEnable && ::Players.GetCount()) ? MF_ENABLED : MF_GRAYED));
EnableMenuItem(GetMenu(hWindow),IDM_FILE_SAVE, MF_BYCOMMAND | (fEnable ? MF_ENABLED : MF_GRAYED));
@ -936,7 +937,7 @@ void C4Console::EnableControls(bool fEnable)
// File menu
// C4Network2 will have to handle that cases somehow (TODO: test)
gtk_widget_set_sensitive(fileRecord, Game.IsRunning && Game.Control.IsRuntimeRecordPossible());
gtk_widget_set_sensitive(fileRecord, Game.IsRunning && ::Control.IsRuntimeRecordPossible());
gtk_widget_set_sensitive(fileSaveGame, fEnable && ::Players.GetCount());
gtk_widget_set_sensitive(fileSaveGameAs, fEnable && ::Players.GetCount());
gtk_widget_set_sensitive(fileSave, fEnable);
@ -1162,9 +1163,9 @@ BOOL C4Console::FileSelect(char *sFilename, int iSize, const char * szFilter, DW
BOOL C4Console::FileRecord()
{
// only in running mode
if (!Game.IsRunning || !Game.Control.IsRuntimeRecordPossible()) return FALSE;
if (!Game.IsRunning || !::Control.IsRuntimeRecordPossible()) return FALSE;
// start record!
Game.Control.RequestRuntimeRecord();
::Control.RequestRuntimeRecord();
// disable menuitem
#ifdef _WIN32
EnableMenuItem(GetMenu(hWindow),IDM_FILE_RECORD, MF_BYCOMMAND | MF_GRAYED);
@ -1806,7 +1807,7 @@ void C4Console::OnPlrJoin(GtkWidget* item, gpointer data)
void C4Console::OnPlrQuit(GtkWidget* item, gpointer data)
{
Game.Control.Input.Add(CID_Script, new C4ControlScript(FormatString("EliminatePlayer(%d)", GPOINTER_TO_INT(data)).getData()));
::Control.Input.Add(CID_Script, new C4ControlScript(FormatString("EliminatePlayer(%d)", GPOINTER_TO_INT(data)).getData()));
}
void C4Console::OnViewNew(GtkWidget* item, gpointer data)
@ -1826,7 +1827,7 @@ void C4Console::OnHelpAbout(GtkWidget* item, gpointer data)
void C4Console::OnNetClient(GtkWidget* item, gpointer data)
{
if(!Game.Control.isCtrlHost()) return;
if(!::Control.isCtrlHost()) return;
Game.Clients.CtrlRemove(Game.Clients.getClientByID(GPOINTER_TO_INT(data)), LoadResStr("IDS_MSG_KICKBYMENU"));
}
#endif // WITH_DEVELOPER_MODE

View File

@ -44,11 +44,12 @@
#include <C4Game.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4GameControl.h>
#endif
// *** C4ControlPacket
C4ControlPacket::C4ControlPacket()
: iByClient(Game.Control.ClientID())
: iByClient(::Control.ClientID())
{
}
@ -60,7 +61,7 @@ C4ControlPacket::~C4ControlPacket()
bool C4ControlPacket::LocalControl() const
{
return iByClient == Game.Control.ClientID();
return iByClient == ::Control.ClientID();
}
void C4ControlPacket::SetByClient(int32_t inByClient)
@ -155,14 +156,14 @@ void C4ControlSet::Execute() const
// host only
if(iByClient != C4ClientIDHost) break;
// adjust control rate
Game.Control.ControlRate += iData;
Game.Control.ControlRate = BoundBy<int32_t>(Game.Control.ControlRate, 1, C4MaxControlRate);
Game.Parameters.ControlRate = Game.Control.ControlRate;
::Control.ControlRate += iData;
::Control.ControlRate = BoundBy<int32_t>(::Control.ControlRate, 1, C4MaxControlRate);
Game.Parameters.ControlRate = ::Control.ControlRate;
// write back adjusted control rate to network settings
if (Game.Control.isCtrlHost() && !Game.Control.isReplay() && Game.Control.isNetwork())
Config.Network.ControlRate = Game.Control.ControlRate;
if (::Control.isCtrlHost() && !::Control.isReplay() && ::Control.isNetwork())
Config.Network.ControlRate = ::Control.ControlRate;
// always show msg
::GraphicsSystem.FlashMessage(FormatString(LoadResStr("IDS_NET_CONTROLRATE"),Game.Control.ControlRate,Game.FrameCounter).getData());
::GraphicsSystem.FlashMessage(FormatString(LoadResStr("IDS_NET_CONTROLRATE"),::Control.ControlRate,Game.FrameCounter).getData());
break;
case C4CVT_AllowDebug: // allow debug mode?
@ -216,7 +217,7 @@ void C4ControlSet::Execute() const
// deny setting if it's fixed by scenario
if (Game.Parameters.FairCrewForced)
{
if (Game.Control.isCtrlHost()) Log(LoadResStr("IDS_MSG_NOMODIFYFAIRCREW"));
if (::Control.isCtrlHost()) Log(LoadResStr("IDS_MSG_NOMODIFYFAIRCREW"));
break;
}
// set new value
@ -440,7 +441,7 @@ void C4ControlSyncCheck::Set()
{
extern int32_t FRndPtr3;
Frame = Game.FrameCounter;
ControlTick = Game.Control.ControlTick;
ControlTick = ::Control.ControlTick;
Random3 = FRndPtr3;
RandomCount = ::RandomCount;
AllCrewPosX = GetAllCrewPosX();
@ -463,19 +464,19 @@ int32_t C4ControlSyncCheck::GetAllCrewPosX()
void C4ControlSyncCheck::Execute() const
{
// control host?
if(Game.Control.isCtrlHost()) return;
if(::Control.isCtrlHost()) return;
// get the saved sync check data
C4ControlSyncCheck* pSyncCheck = Game.Control.GetSyncCheck(Frame), &SyncCheck = *pSyncCheck;
C4ControlSyncCheck* pSyncCheck = ::Control.GetSyncCheck(Frame), &SyncCheck = *pSyncCheck;
if(!pSyncCheck)
{
Game.Control.SyncChecks.Add(CID_SyncCheck, new C4ControlSyncCheck(*this));
::Control.SyncChecks.Add(CID_SyncCheck, new C4ControlSyncCheck(*this));
return;
}
// Not equal
if ( Frame != pSyncCheck->Frame
||(ControlTick != pSyncCheck->ControlTick && !Game.Control.isReplay())
||(ControlTick != pSyncCheck->ControlTick && !::Control.isReplay())
|| Random3 != pSyncCheck->Random3
|| RandomCount != pSyncCheck->RandomCount
|| AllCrewPosX != pSyncCheck->AllCrewPosX
@ -485,8 +486,8 @@ void C4ControlSyncCheck::Execute() const
|| ObjectEnumerationIndex != pSyncCheck->ObjectEnumerationIndex
|| SectShapeSum != pSyncCheck->SectShapeSum)
{
const char *szThis = "Client", *szOther = Game.Control.isReplay() ? "Rec ":"Host";
if(iByClient != Game.Control.ClientID())
const char *szThis = "Client", *szOther = ::Control.isReplay() ? "Rec ":"Host";
if(iByClient != ::Control.ClientID())
{ const char *szTemp = szThis; szThis = szOther; szOther = szTemp; }
// Message
LogFatal("Network: Synchronization loss!");
@ -501,9 +502,9 @@ void C4ControlSyncCheck::Execute() const
// league: Notify regular client disconnect within the game
::Network.LeagueNotifyDisconnect(C4ClientIDHost, C4LDR_Desync);
// Deactivate / end
if(Game.Control.isReplay())
if(::Control.isReplay())
Game.DoGameOver();
else if(Game.Control.isNetwork())
else if(::Control.isNetwork())
{
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, "Network: Synchronization loss!");
::Network.Clear();
@ -588,7 +589,7 @@ void C4ControlClientUpdate::Execute() const
pClient->SetActivated(!!iData);
// local?
if(pClient->isLocal())
Game.Control.SetActivated(!!iData);
::Control.SetActivated(!!iData);
break;
case CUT_SetObserver:
// nothing to do?
@ -599,7 +600,7 @@ void C4ControlClientUpdate::Execute() const
pClient->SetObserver();
// local?
if(pClient->isLocal())
Game.Control.SetActivated(false);
::Control.SetActivated(false);
// remove all players ("soft kick")
::Players.RemoveAtClient(iID, true);
break;
@ -628,7 +629,7 @@ void C4ControlClientRemove::Execute() const
{
// TODO: in replays, client list is not yet synchronized
// remove players anyway
if (Game.Control.isReplay()) ::Players.RemoveAtClient(iID, true);
if (::Control.isReplay()) ::Players.RemoveAtClient(iID, true);
return;
}
StdCopyStrBuf strClient(LoadResStr(pClient->isLocal() ? "IDS_NET_LOCAL_CLIENT" : "IDS_NET_CLIENT"));
@ -639,7 +640,7 @@ void C4ControlClientRemove::Execute() const
sMsg.Format(LoadResStr("IDS_NET_CLIENT_REMOVED"), strClient.getData(), pClient->getName(), strReason.getData());
Log(sMsg.getData());
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, sMsg.getData());
Game.Control.ChangeToLocal();
::Control.ChangeToLocal();
return;
}
// remove client
@ -739,14 +740,14 @@ void C4ControlJoinPlayer::Execute() const
return;
}
}
else if(Game.Control.isNetwork())
else if(::Control.isNetwork())
{
// Find ressource
C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID());
if(pRes && pRes->isComplete())
Game.JoinPlayer(pRes->getFile(), iAtClient, pClient->getName(), pInfo);
}
else if(Game.Control.isReplay())
else if(::Control.isReplay())
{
// Expect player in scenario file
StdStrBuf PlayerFilename; PlayerFilename.Format("%s" DirSep "%d-%s", Game.ScenarioFilename, ResCore.getID(), GetFilename(ResCore.getFileName()));
@ -796,7 +797,7 @@ bool C4ControlJoinPlayer::PreExecute() const
// client lost?
if(!Game.Clients.getClientByID(iAtClient)) return true;
// network only
if(!Game.Control.isNetwork()) return true;
if(!::Control.isNetwork()) return true;
// search ressource
C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID());
// doesn't exist? start loading
@ -1164,7 +1165,7 @@ void C4ControlPlayerInfo::Execute() const
{
// join to player info list
// replay and local control: direct join
if (Game.Control.isReplay() || !Game.Control.isNetwork())
if (::Control.isReplay() || !::Control.isNetwork())
{
// add info directly
Game.PlayerInfos.AddInfo(new C4ClientPlayerInfos(PlrInfo));
@ -1172,7 +1173,7 @@ void C4ControlPlayerInfo::Execute() const
Game.Teams.RecheckPlayers();
// replay: actual player join packet will follow
// offline game: Issue the join
if (Game.Control.isLocal())
if (::Control.isLocal())
Game.PlayerInfos.LocalJoinUnjoinedPlayersInQueue();
}
else
@ -1273,7 +1274,7 @@ void C4ControlVote::Execute() const
if(::Network.isEnabled())
::Network.AddVote(*this);
// Vote done?
if(Game.Control.isCtrlHost())
if(::Control.isCtrlHost())
{
// Count votes
int32_t iPositive = 0, iNegative = 0, iVotes = 0;
@ -1330,12 +1331,12 @@ void C4ControlVote::Execute() const
}
// Approval? More then 50% needed
if(iPositive * 2 > iVotes)
Game.Control.DoInput(CID_VoteEnd,
::Control.DoInput(CID_VoteEnd,
new C4ControlVoteEnd(eType, true, iData),
CDT_Sync);
// Disapproval?
else if(iNegative * 2 >= iVotes)
Game.Control.DoInput(CID_VoteEnd,
::Control.DoInput(CID_VoteEnd,
new C4ControlVoteEnd(eType, false, iData),
CDT_Sync);
}
@ -1390,7 +1391,7 @@ void C4ControlVoteEnd::Execute() const
if(!pInfo->IsRemoved())
pInfo->SetVotedOut();
// Remove the client
if(Game.Control.isCtrlHost())
if(::Control.isCtrlHost())
{
C4Client *pClient = Game.Clients.getClientByID(getData());
if(pClient)

View File

@ -37,6 +37,7 @@
#include <C4GraphicsResource.h>
#include <C4Game.h>
#include <C4GameObjects.h>
#include <C4GameControl.h>
#endif
#ifdef WITH_DEVELOPER_MODE
@ -365,7 +366,7 @@ bool C4EditCursor::Delete()
{
if (!EditingOK()) return FALSE;
EMMoveObject(EMMO_Remove, 0, 0, NULL, &Selection);
if(Game.Control.isCtrlHost())
if(::Control.isCtrlHost())
{
OnSelectionChanged();
}
@ -763,7 +764,7 @@ void C4EditCursor::EMMoveObject(C4ControlEMObjectAction eAction, int32_t tx, int
void C4EditCursor::EMControl(C4PacketType eCtrlType, C4ControlPacket *pCtrl)
{
Game.Control.DoInput(eCtrlType, pCtrl, CDT_Decide);
::Control.DoInput(eCtrlType, pCtrl, CDT_Decide);
}
#ifdef WITH_DEVELOPER_MODE

View File

@ -816,11 +816,8 @@ void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj)
int32_t GetSmokeLevel()
{
// Network active: enforce fixed smoke level
if(Game.Control.SyncMode())
return 150;
// User-defined smoke level
return Config.Graphics.SmokeLevel;
// just use fixed smoke level, smoke uses particles anyway
return 150;
}
void BubbleOut(int32_t tx, int32_t ty)

View File

@ -71,6 +71,7 @@
#include <C4Landscape.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4GameControl.h>
#endif
#include <StdFile.h>
@ -1594,7 +1595,7 @@ BOOL C4Game::DropDef(C4ID id, float X, float Y)
str.Format("CreateConstruction(%s,%d,%d,-1,%d,true)", C4IdText(id), int(X), int(Y), FullCon);
else
str.Format("CreateObject(%s,%d,%d,-1)", C4IdText(id), int(X), int(Y));
Game.Control.DoInput(CID_Script, new C4ControlScript(str.getData()), CDT_Decide);
::Control.DoInput(CID_Script, new C4ControlScript(str.getData()), CDT_Decide);
return TRUE;
}
else

View File

@ -183,7 +183,7 @@ void C4GameControl::RequestRuntimeRecord()
// request through a synchronize-call
// currnetly do not request, but start record with next gamesync, so network runtime join can be debugged
#ifndef DEBUGREC
Game.Control.DoInput(CID_Synchronize, new C4ControlSynchronize(false, true), CDT_Queue);
::Control.DoInput(CID_Synchronize, new C4ControlSynchronize(false, true), CDT_Queue);
#endif
}
@ -366,7 +366,7 @@ void C4GameControl::AdjustControlRate(int32_t iBy)
{
// control host only
if(isCtrlHost())
Game.Control.DoInput(CID_Set, new C4ControlSet(C4CVT_ControlRate, iBy), CDT_Decide);
::Control.DoInput(CID_Set, new C4ControlSet(C4CVT_ControlRate, iBy), CDT_Decide);
}
void C4GameControl::SetActivated(bool fnActivated)
@ -515,3 +515,5 @@ void C4GameControl::RemoveOldSyncChecks()
SyncChecks.Delete(pPkt);
}
}
C4GameControl Control;

View File

@ -54,8 +54,8 @@ bool C4GameControlNetwork::Init(int32_t inClientID, bool fnHost, int32_t iStartT
if(IsEnabled()) Clear();
// init
iClientID = inClientID; fHost = fnHost;
Game.Control.ControlTick = iStartTick;
iControlSent = iControlReady = Game.Control.getNextControlTick() - 1;
::Control.ControlTick = iStartTick;
iControlSent = iControlReady = ::Control.getNextControlTick() - 1;
fActivated = fnActivated;
pNetwork = pnNetwork;
// check
@ -86,7 +86,7 @@ void C4GameControlNetwork::Clear() // by main thread
void C4GameControlNetwork::Execute() // by main thread
{
// Control ticks only
if(Game.FrameCounter % Game.Control.ControlRate)
if(Game.FrameCounter % ::Control.ControlRate)
return;
// Save time the control tick was reached
@ -314,7 +314,7 @@ void C4GameControlNetwork::AddClient(int32_t iClientID, const char *szName) // b
// create new
C4GameControlClient *pClient = new C4GameControlClient();
pClient->Set(iClientID, szName);
pClient->SetNextControl(Game.Control.ControlTick);
pClient->SetNextControl(::Control.ControlTick);
// add client
AddClient(pClient);
}
@ -364,7 +364,7 @@ void C4GameControlNetwork::SetActivated(bool fnActivated) // by main thread
fActivated = fnActivated;
// Activated? Start to send control at next tick
if(fActivated)
iControlSent = Game.Control.getNextControlTick() - 1;
iControlSent = ::Control.getNextControlTick() - 1;
}
void C4GameControlNetwork::SetCtrlMode(C4GameControlNetworkMode enMode) // by main thread
@ -378,13 +378,13 @@ void C4GameControlNetwork::SetCtrlMode(C4GameControlNetworkMode enMode) // by ma
if(enMode == CNM_Decentral)
{
CStdLock CtrlLock(&CtrlCSec); C4GameControlPacket *pPkt;
for(int32_t iCtrlTick = Game.Control.ControlTick; pPkt = getCtrl(iClientID, iCtrlTick); iCtrlTick++)
for(int32_t iCtrlTick = ::Control.ControlTick; pPkt = getCtrl(iClientID, iCtrlTick); iCtrlTick++)
::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++)
for(int32_t iCtrlTick = ::Control.ControlTick; pPkt = getCtrl(C4ClientIDAll, iCtrlTick); iCtrlTick++)
::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_Control, *pPkt));
}
}
@ -713,7 +713,7 @@ void C4GameControlNetwork::CheckCompleteCtrl(bool fSetEvent) // by both
// own control not ready?
if(fActivated && iControlSent <= iControlReady) break;
// no clients? no need to pack more than one tick into the future
if(!pClients && Game.Control.ControlTick <= iControlReady) break;
if(!pClients && ::Control.ControlTick <= iControlReady) break;
// stop packing?
if(iStopTick >= 0 && iControlReady + 1 >= iStopTick) break;
// central mode and not host?
@ -728,12 +728,12 @@ void C4GameControlNetwork::CheckCompleteCtrl(bool fSetEvent) // by both
// ok, control for this tick is ready
iControlReady++;
// tell the main thread to move on
if(fSetEvent && Game.GameGo && iControlReady >= Game.Control.ControlTick)
if(fSetEvent && Game.GameGo && iControlReady >= ::Control.ControlTick)
Application.NextTick();
}
// clear old ctrl
if(Game.Control.ControlTick >= C4ControlBacklog)
ClearCtrl(Game.Control.ControlTick - C4ControlBacklog);
if(::Control.ControlTick >= C4ControlBacklog)
ClearCtrl(::Control.ControlTick - C4ControlBacklog);
// target ctrl tick to reach?
if(iControlReady < iTargetTick &&
(!fActivated || iControlSent > iControlReady) &&

View File

@ -28,6 +28,7 @@
#include <C4Network2Dialogs.h>
#include <C4Game.h>
#include <C4Player.h>
#include <C4Network2.h>
#endif
bool C4AbortGameDialog::is_shown = false;

View File

@ -34,6 +34,7 @@
#include "C4PlayerInfoListBox.h"
#include <C4MessageInput.h>
#include <C4Game.h>
#include <C4Network2.h>
#endif
namespace C4GameLobby {

View File

@ -32,6 +32,7 @@
#include <C4Game.h>
#include <C4Log.h>
#include <C4PlayerList.h>
#include <C4Record.h>
#endif
C4GameObjects::C4GameObjects()

View File

@ -22,6 +22,7 @@
#include "C4Include.h"
#include "C4GameOptions.h"
#include <C4Game.h>
#include <C4GameControl.h>
// ----------- C4GameOptionsList::Option ----------------------------------------------------------------
@ -81,7 +82,7 @@ C4GameOptionsList::OptionDropdown::OptionDropdown(class C4GameOptionsList *pForD
// Unfortunately, the control mode cannot be changed in the lobby
C4GameOptionsList::OptionControlMode::OptionControlMode(class C4GameOptionsList *pForDlg)
: C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_TEXT_CONTROLMODE"), !Game.Control.isCtrlHost() || !Game.Control.isNetwork() || !Game.Control.Network.IsEnabled() || !pForDlg->IsRuntime())
: C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_TEXT_CONTROLMODE"), !::Control.isCtrlHost() || !::Control.isNetwork() || !::Control.Network.IsEnabled() || !pForDlg->IsRuntime())
{
SetToolTip(LoadResStr("IDS_DESC_CHANGESTHEWAYCONTROLDATAI"));
}
@ -89,7 +90,7 @@ C4GameOptionsList::OptionControlMode::OptionControlMode(class C4GameOptionsList
void C4GameOptionsList::OptionControlMode::DoDropdownFill(C4GUI::ComboBox_FillCB *pFiller)
{
// change possible?
if (!Game.Control.isNetwork() || !Game.Control.Network.IsEnabled() || !Game.Control.isCtrlHost()) return;
if (!::Control.isNetwork() || !::Control.Network.IsEnabled() || !::Control.isCtrlHost()) return;
// add possible modes
pFiller->AddEntry(LoadResStr("IDS_NET_CTRLMODE_CENTRAL"), CNM_Central);
pFiller->AddEntry(LoadResStr("IDS_NET_CTRLMODE_DECENTRAL"), CNM_Decentral);
@ -98,7 +99,7 @@ void C4GameOptionsList::OptionControlMode::DoDropdownFill(C4GUI::ComboBox_FillCB
void C4GameOptionsList::OptionControlMode::DoDropdownSelChange(int32_t idNewSelection)
{
// change possible?
if (!Game.Control.isNetwork() || !Game.Control.Network.IsEnabled() || !Game.Control.isCtrlHost()) return;
if (!::Control.isNetwork() || !::Control.Network.IsEnabled() || !::Control.isCtrlHost()) return;
// perform it
::Network.SetCtrlMode(idNewSelection);
// update done in parent call
@ -107,11 +108,11 @@ void C4GameOptionsList::OptionControlMode::DoDropdownSelChange(int32_t idNewSele
void C4GameOptionsList::OptionControlMode::Update()
{
const char *szControlMode;
if (!Game.Control.isNetwork() || !Game.Control.Network.IsEnabled())
if (!::Control.isNetwork() || !::Control.Network.IsEnabled())
szControlMode = LoadResStr("IDS_NET_NONET");
else
{
switch (Game.Control.Network.GetCtrlMode())
switch (::Control.Network.GetCtrlMode())
{
case CNM_Central: szControlMode = LoadResStr("IDS_NET_CTRLMODE_CENTRAL"); break;
case CNM_Decentral: szControlMode = LoadResStr("IDS_NET_CTRLMODE_DECENTRAL"); break;
@ -125,7 +126,7 @@ void C4GameOptionsList::OptionControlMode::Update()
// ----------- C4GameOptionsList::OptionControlRate ----------------------------------------------------------------
C4GameOptionsList::OptionControlRate::OptionControlRate(class C4GameOptionsList *pForDlg)
: C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_CTL_CONTROLRATE"), !Game.Control.isCtrlHost())
: C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_CTL_CONTROLRATE"), !::Control.isCtrlHost())
{
SetToolTip(LoadResStr("IDS_CTL_CONTROLRATE_DESC"));
}
@ -140,14 +141,14 @@ void C4GameOptionsList::OptionControlRate::DoDropdownSelChange(int32_t idNewSele
{
// adjust rate
int32_t iNewRate = idNewSelection;
if (!iNewRate || iNewRate == Game.Control.ControlRate) return;
Game.Control.AdjustControlRate(iNewRate - Game.Control.ControlRate);
if (!iNewRate || iNewRate == ::Control.ControlRate) return;
::Control.AdjustControlRate(iNewRate - ::Control.ControlRate);
}
void C4GameOptionsList::OptionControlRate::Update()
{
if (atoi(pDropdownList->GetText().getData()) == Game.Control.ControlRate) return;
pDropdownList->SetText(FormatString("%d", Game.Control.ControlRate).getData());
if (atoi(pDropdownList->GetText().getData()) == ::Control.ControlRate) return;
pDropdownList->SetText(FormatString("%d", ::Control.ControlRate).getData());
}
@ -187,7 +188,7 @@ void C4GameOptionsList::OptionRuntimeJoin::Update()
// ----------- C4GameOptionsList::OptionTeamDist ----------------------------------------------------------------
C4GameOptionsList::OptionTeamDist::OptionTeamDist(class C4GameOptionsList *pForDlg)
: C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_MSG_TEAMDIST"), !Game.Control.isCtrlHost())
: C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_MSG_TEAMDIST"), !::Control.isCtrlHost())
{
SetToolTip(LoadResStr("IDS_MSG_TEAMDIST_DESC"));
}
@ -213,7 +214,7 @@ void C4GameOptionsList::OptionTeamDist::Update()
// ----------- C4GameOptionsList::OptionTeamColors ----------------------------------------------------------------
C4GameOptionsList::OptionTeamColors::OptionTeamColors(class C4GameOptionsList *pForDlg)
: C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_MSG_TEAMCOLORS"), !Game.Control.isCtrlHost())
: C4GameOptionsList::OptionDropdown(pForDlg, LoadResStr("IDS_MSG_TEAMCOLORS"), !::Control.isCtrlHost())
{
SetToolTip(LoadResStr("IDS_MSG_TEAMCOLORS_DESC"));
}

View File

@ -32,6 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <C4PlayerInfoListBox.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4GameControl.h>
#endif
@ -243,7 +244,7 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
{
// not available for regular replay and network clients, obviously
// it is available for films though, so you can create cinematics for adventures
if (Game.Control.isCtrlHost() || (Game.C4S.Head.Film == 2))
if (::Control.isCtrlHost() || (Game.C4S.Head.Film == 2))
{
fHasNextMissionButton = true;
btnContinue->SetText(Game.NextMissionText.getData());

View File

@ -26,6 +26,7 @@
#include "C4Components.h"
#include <C4Game.h>
#include <C4GameObjects.h>
#include <C4Network2.h>
#endif
// *** C4GameRes

View File

@ -37,6 +37,7 @@
#include <C4MassMover.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4Record.h>
#endif
// *** C4GameSave main class

View File

@ -49,6 +49,7 @@
#include <C4GraphicsResource.h>
#include <C4GraphicsSystem.h>
#include <C4Texture.h>
#include <C4Record.h>
#endif
#include <StdPNG.h>

View File

@ -33,6 +33,8 @@
#include <C4Game.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4Network2.h>
#include <C4GameControl.h>
#endif
// -----------------------------------------------------------
@ -701,7 +703,7 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
if (SEqual(szCommand+13,"NewPlayer")) return ActivateNewPlayer(Player);
if (SEqual(szCommand+13,"Goals"))
{
Game.Control.DoInput(CID_Script, new C4ControlScript(FormatString("ActivateGameGoalMenu(%d)", Player).getData()), CDT_Queue);
::Control.DoInput(CID_Script, new C4ControlScript(FormatString("ActivateGameGoalMenu(%d)", Player).getData()), CDT_Queue);
return true;
}
if (SEqual(szCommand+13,"Rules")) return ActivateRules(Player);
@ -748,7 +750,7 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
// Surrender
if (SEqual2(szCommand,"Surrender"))
{
Game.Control.DoInput(CID_Script, new C4ControlScript(FormatString("SurrenderPlayer(%d)", Player).getData()), CDT_Queue);
::Control.DoInput(CID_Script, new C4ControlScript(FormatString("SurrenderPlayer(%d)", Player).getData()), CDT_Queue);
return true;
}
// Save game
@ -780,7 +782,7 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
{
if(::Network.isEnabled())
if(Game.Parameters.isLeague() && ::Players.GetLocalByIndex(0))
::Network.Vote(VT_Kick, true, Game.Control.ClientID());
::Network.Vote(VT_Kick, true, ::Control.ClientID());
else
{
Game.RoundResults.EvaluateNetwork(C4RoundResults::NR_NetError, LoadResStr("IDS_ERR_GAMELEFTVIAPLAYERMENU"));
@ -854,7 +856,7 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
// TODO!
C4Object *pObj; C4ID idItem = C4Id(szCommand+12);
if (pObj = ::Objects.FindInternal(idItem))
Game.Control.DoInput(CID_Script, new C4ControlScript(FormatString("Activate(%d)", Player).getData(), pObj->Number), CDT_Queue);
::Control.DoInput(CID_Script, new C4ControlScript(FormatString("Activate(%d)", Player).getData(), pObj->Number), CDT_Queue);
else
return false;
return true;
@ -878,7 +880,7 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
// check if it's still allowed
if (!Game.Teams.IsTeamSwitchAllowed()) return false;
// OK, join this team
Game.Control.DoInput(CID_Script, new C4ControlScript(FormatString("SetPlayerTeam(%d,%d)", (int)Player, (int)idTeam).getData()), CDT_Queue);
::Control.DoInput(CID_Script, new C4ControlScript(FormatString("SetPlayerTeam(%d,%d)", (int)Player, (int)idTeam).getData()), CDT_Queue);
return true;
}
// Observe

View File

@ -35,6 +35,7 @@
#include <C4Game.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4GameControl.h>
#endif
const int32_t C4MN_DefInfoWdt = 270, // default width of info windows
@ -836,7 +837,7 @@ void C4Menu::Draw(C4TargetFacet &cgo)
if (!fTextProgressing) ++TimeOnSelection;
if (TimeOnSelection >= C4MN_InfoCaption_Delay)
if (Style != C4MN_Style_Info) // No tooltips in info menus - doesn't make any sense...
if (!Game.Control.isReplay() && ::pGUI)
if (!::Control.isReplay() && ::pGUI)
if (!::pGUI->Mouse.IsActiveInput())
{
C4MenuItem *pSel = GetSelectedItem();

View File

@ -37,6 +37,7 @@
#include <C4GameLobby.h>
#include <C4GraphicsSystem.h>
#include <C4PlayerList.h>
#include <C4GameControl.h>v
#endif
#include <cctype>
@ -104,7 +105,7 @@ void C4ChatInputDialog::OnChatCancel()
{
// there was an associated query - it must be removed on all clients synchronized via queue
// do this by calling OnMessageBoardAnswer without an answer
Game.Control.DoInput(CID_Script, new C4ControlScript(FormatString("OnMessageBoardAnswer(Object(%d), %d, 0)", pTarget ? pTarget->Number : 0, iPlr).getData()), CDT_Decide);
::Control.DoInput(CID_Script, new C4ControlScript(FormatString("OnMessageBoardAnswer(Object(%d), %d, 0)", pTarget ? pTarget->Number : 0, iPlr).getData()), CDT_Decide);
}
}
}
@ -152,7 +153,7 @@ C4GUI::Edit::InputResult C4ChatInputDialog::OnChatInput(C4GUI::Edit *edt, bool f
StdStrBuf sInput;
sInput.Copy(szInputText);
sInput.EscapeString();
Game.Control.DoInput(CID_Script, new C4ControlScript(FormatString("OnMessageBoardAnswer(Object(%d), %d, \"%s\")", pTarget ? pTarget->Number : 0, iPlr, sInput.getData()).getData()), CDT_Decide);
::Control.DoInput(CID_Script, new C4ControlScript(FormatString("OnMessageBoardAnswer(Object(%d), %d, \"%s\")", pTarget ? pTarget->Number : 0, iPlr, sInput.getData()).getData()), CDT_Decide);
return C4GUI::Edit::IR_CloseDlg;
}
else
@ -438,7 +439,7 @@ bool C4MessageInput::ProcessInput(const char *szText)
// get sending player (if any)
C4Player *pPlr = Game.IsRunning ? ::Players.GetLocalByIndex(0) : NULL;
// send
Game.Control.DoInput(CID_Message,
::Control.DoInput(CID_Message,
new C4ControlMessage(eMsgType, szMessage, pPlr ? pPlr->Number : -1, iToPlayer),
CDT_Private);
}
@ -486,7 +487,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
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);
::Control.DoInput(CID_Script, new C4ControlScript(pCmdPar, C4ControlScript::SCOPE_Console, false), CDT_Decide);
return TRUE;
}
// set runtimte properties
@ -494,14 +495,14 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
{
if(SEqual2(pCmdPar, "maxplayer "))
{
if (Game.Control.isCtrlHost())
if (::Control.isCtrlHost())
{
if(atoi(pCmdPar+10) == 0 && !SEqual(pCmdPar+10, "0"))
{
Log("Syntax: /set maxplayer count");
return FALSE;
}
Game.Control.DoInput(CID_Set,
::Control.DoInput(CID_Set,
new C4ControlSet(C4CVT_MaxPlayer, atoi(pCmdPar+10)),
CDT_Decide);
return TRUE;
@ -534,7 +535,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
pSet = new C4ControlSet(C4CVT_FairCrew, atoi(pCmdPar + 9));
else
return FALSE;
Game.Control.DoInput(CID_Set, pSet, CDT_Decide);
::Control.DoInput(CID_Set, pSet, CDT_Decide);
return TRUE;
}
// unknown property
@ -623,7 +624,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
if (SEqual(szCmdName, "nodebug"))
{
if (!Game.IsRunning) return FALSE;
Game.Control.DoInput(CID_Set, new C4ControlSet(C4CVT_AllowDebug, false), CDT_Decide);
::Control.DoInput(CID_Set, new C4ControlSet(C4CVT_AllowDebug, false), CDT_Decide);
return TRUE;
}
@ -666,7 +667,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
pCtrl = new C4ControlClientUpdate(pClient->getID(), CUT_SetObserver);
// perform it
if (pCtrl)
Game.Control.DoInput(CID_ClientUpdate, pCtrl, CDT_Sync);
::Control.DoInput(CID_ClientUpdate, pCtrl, CDT_Sync);
else
Log(LoadResStr("IDS_LOG_COMMANDNOTALLOWEDINLEAGUE"));
return TRUE;
@ -733,7 +734,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
else
Script = pCmd->Script;
// add script
Game.Control.DoInput(CID_Script, new C4ControlScript(Script.getData()), CDT_Decide);
::Control.DoInput(CID_Script, new C4ControlScript(Script.getData()), CDT_Decide);
// ok
return TRUE;
}

View File

@ -40,6 +40,7 @@
#include <C4GraphicsSystem.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4GameControl.h>
#endif
const int32_t C4MC_Drag_None = 0,
@ -1379,7 +1380,7 @@ C4Object *C4MouseControl::GetTargetObject(float iX, float iY, DWORD &dwOCF, C4Ob
BOOL C4MouseControl::IsPassive()
{
return Game.Control.isReplay() || Player<=NO_OWNER;
return ::Control.isReplay() || Player<=NO_OWNER;
}
void C4MouseControl::ScrollView(int32_t iX, int32_t iY, int32_t ViewWdt, int32_t ViewHgt)

View File

@ -33,6 +33,7 @@
#include <C4Game.h>
#include <C4GraphicsSystem.h>
#include <C4GraphicsResource.h>
#include <C4GameControl.h>
// lobby
#include <C4Gui.h>
@ -166,7 +167,7 @@ bool C4Network2::InitHost(bool fLobby)
{
if(isEnabled()) Clear();
// initialize everything
Status.Set(fLobby ? GS_Lobby : GS_Go, Game.Control.ControlTick);
Status.Set(fLobby ? GS_Lobby : GS_Go, ::Control.ControlTick);
Status.SetCtrlMode(Config.Network.ControlMode);
fHost = true;
fStatusAck = fStatusReached = true;
@ -187,8 +188,8 @@ bool C4Network2::InitHost(bool fLobby)
if(!InitNetIO(false, true))
{ Clear(); return false; }
// init network control
pControl = &Game.Control.Network;
pControl->Init(C4ClientIDHost, true, Game.Control.getNextControlTick(), true, this);
pControl = &::Control.Network;
pControl->Init(C4ClientIDHost, true, ::Control.getNextControlTick(), true, this);
// init league
bool fCancel = true;
if(!InitLeague(&fCancel) || !LeagueStart(&fCancel))
@ -282,7 +283,7 @@ C4Network2::InitResult C4Network2::InitClient(const class C4Network2Address *pAd
if(!InitNetIO(true, false))
{ Clear(); return IR_Fatal; }
// set network control
pControl = &Game.Control.Network;
pControl = &::Control.Network;
// set exclusive connection mode
NetIO.SetExclusiveConnMode(true);
// try to connect host
@ -413,7 +414,7 @@ bool C4Network2::Start()
{
if(!isEnabled() || !isHost()) return false;
// change mode: go
ChangeGameStatus(GS_Go, Game.Control.ControlTick);
ChangeGameStatus(GS_Go, ::Control.ControlTick);
return true;
}
@ -421,7 +422,7 @@ bool C4Network2::Pause()
{
if(!isEnabled() || !isHost()) return false;
// change mode: pause
return ChangeGameStatus(GS_Pause, Game.Control.getNextControlTick());
return ChangeGameStatus(GS_Pause, ::Control.getNextControlTick());
}
bool C4Network2::Sync()
@ -438,7 +439,7 @@ bool C4Network2::Sync()
// already sync?
if(isFrozen()) return true;
// ok, so let's do a sync: change in the same state we are already in
return ChangeGameStatus(Status.getState(), Game.Control.getNextControlTick());
return ChangeGameStatus(Status.getState(), ::Control.getNextControlTick());
}
bool C4Network2::FinalInit()
@ -565,7 +566,7 @@ void C4Network2::Execute()
if(isHost())
{
// remove dynamic
if(!ResDynamic.isNull() && Game.Control.ControlTick > iDynamicTick)
if(!ResDynamic.isNull() && ::Control.ControlTick > iDynamicTick)
RemoveDynamic();
// Set chase target
UpdateChaseTarget();
@ -596,7 +597,7 @@ void C4Network2::Execute()
if(Votes.firstPkt() && time(NULL) > (time_t) (iVoteStartTime + C4NetVotingTimeout))
{
C4ControlVote *pVote = static_cast<C4ControlVote *>(Votes.firstPkt()->getPkt());
Game.Control.DoInput(
::Control.DoInput(
CID_VoteEnd,
new C4ControlVoteEnd(pVote->getType(), false, pVote->getData()),
CDT_Sync);
@ -637,8 +638,8 @@ void C4Network2::Clear()
Status.Clear();
fStatusAck = fStatusReached = true;
// if control mode is network: change to local
if(Game.Control.isNetwork())
Game.Control.ChangeToLocal();
if(::Control.isNetwork())
::Control.ChangeToLocal();
// clear all player infos
Players.Clear();
// remove all clients
@ -726,7 +727,7 @@ void C4Network2::SetCtrlMode(int32_t iCtrlMode)
// no change?
if(iCtrlMode == Status.getCtrlMode()) return;
// change game status
ChangeGameStatus(Status.getState(), Game.Control.ControlTick, iCtrlMode);
ChangeGameStatus(Status.getState(), ::Control.ControlTick, iCtrlMode);
}
void C4Network2::OnConn(C4Network2IOConnection *pConn)
@ -943,8 +944,8 @@ void C4Network2::DrawStatus(C4TargetFacet &cgo)
// some control statistics
Stat.AppendFormat( "|Control: %s, Tick %d, Behind %d, Rate %d, PreSend %d, ACT: %d",
Status.getCtrlMode() == CNM_Decentral ? "Decentral" : Status.getCtrlMode() == CNM_Central ? "Central" : "Async",
Game.Control.ControlTick, pControl->GetBehind(Game.Control.ControlTick),
Game.Control.ControlRate, pControl->getControlPreSend(), pControl->getAvgControlSendTime());
::Control.ControlTick, pControl->GetBehind(::Control.ControlTick),
::Control.ControlRate, pControl->getControlPreSend(), pControl->getAvgControlSendTime());
// Streaming statistics
if(fStreaming)
@ -974,9 +975,9 @@ void C4Network2::DrawStatus(C4TargetFacet &cgo)
Core.isObserver() ? "Observing" : Core.isActivated() ? "Active" : "Inactive", Core.isHost() ? "host" : "client",
Core.getName(), Core.getID(),
pControl->ClientPerfStat(pClient->getID()),
Game.Control.ControlTick - pControl->ClientNextControl(pClient->getID()),
::Control.ControlTick - pControl->ClientNextControl(pClient->getID()),
szClientStatus,
pClient->isActivated() && !pControl->ClientReady(pClient->getID(), Game.Control.ControlTick) ? " (!ctrl)" : "");
pClient->isActivated() && !pControl->ClientReady(pClient->getID(), ::Control.ControlTick) ? " (!ctrl)" : "");
// connections
if(pClient->isConnected())
{
@ -1195,7 +1196,7 @@ bool C4Network2::Join(C4ClientCore &CCore, C4Network2IOConnection *pConn, const
CCore.SetName(szNewName);
}
// join client
Game.Control.DoInput(CID_ClientJoin, new C4ControlClientJoin(CCore), CDT_Direct);
::Control.DoInput(CID_ClientJoin, new C4ControlClientJoin(CCore), CDT_Direct);
// get client, set status
C4Network2Client *pClient = Clients.GetClient(CCore);
if(pClient) pClient->SetStatus(NCS_Joining);
@ -1330,7 +1331,7 @@ void C4Network2::HandleActivateReq(int32_t iTick, C4Network2Client *pByClient)
return;
}
// activate him
Game.Control.DoInput(CID_ClientUpdate,
::Control.DoInput(CID_ClientUpdate,
new C4ControlClientUpdate(pByClient->getID(), CUT_Activate, TRUE),
CDT_Sync);
}
@ -1360,7 +1361,7 @@ void C4Network2::HandleJoinData(const C4PacketJoinData &rPkt)
ResDynamic = rPkt.getDynamicCore();
iDynamicTick = rPkt.getStartCtrlTick();
// initialize control
Game.Control.ControlRate = rPkt.Parameters.ControlRate;
::Control.ControlRate = rPkt.Parameters.ControlRate;
pControl->Init(rPkt.getClientID(), false, rPkt.getStartCtrlTick(), pLocalClient->isActivated(), this);
pControl->CopyClientList(Game.Parameters.Clients);
// set local core
@ -1447,7 +1448,7 @@ void C4Network2::OnClientDisconnect(C4Network2Client *pClient)
// (client might be the only one claiming to have the given control)
if(!fStatusReached)
if(Status.getState() == GS_Go || Status.getState() == GS_Pause)
ChangeGameStatus(Status.getState(), Game.Control.ControlTick);
ChangeGameStatus(Status.getState(), ::Control.ControlTick);
}
// host disconnected? Clear up
if(!isHost() && pClient->isHost())
@ -1466,11 +1467,11 @@ void C4Network2::SendJoinData(C4Network2Client *pClient)
// host only, scenario must be available
assert(isHost());
// dynamic available?
if(ResDynamic.isNull() || iDynamicTick < Game.Control.ControlTick)
if(ResDynamic.isNull() || iDynamicTick < ::Control.ControlTick)
{
fDynamicNeeded = true;
// add synchronization control (will callback, see C4Game::Synchronize)
Game.Control.DoInput(CID_Synchronize, new C4ControlSynchronize(false, true), CDT_Sync);
::Control.DoInput(CID_Synchronize, new C4ControlSynchronize(false, true), CDT_Sync);
return;
}
// save his client ID
@ -1604,7 +1605,7 @@ bool C4Network2::CreateDynamic(bool fInit)
if(!pRes) { Log(LoadResStr("IDS_NET_SAVE_ERR_ADDDYNDATARES")); return false; }
// save
ResDynamic = pRes->getCore();
iDynamicTick = Game.Control.getNextControlTick();
iDynamicTick = ::Control.getNextControlTick();
fDynamicNeeded = false;
// ok
return true;
@ -1665,8 +1666,8 @@ void C4Network2::CheckStatusReached(bool fFromFinalInit)
if(Game.IsRunning || fFromFinalInit)
{
// Make sure we have reached the tick and the control queue is empty (except for chasing)
if(Game.Control.CtrlTickReached(Status.getTargetCtrlTick()) &&
(fChasing || !pControl->CtrlReady(Game.Control.ControlTick)))
if(::Control.CtrlTickReached(Status.getTargetCtrlTick()) &&
(fChasing || !pControl->CtrlReady(::Control.ControlTick)))
fStatusReached = true;
else
{
@ -1686,7 +1687,7 @@ void C4Network2::CheckStatusReached(bool fFromFinalInit)
CheckStatusAck();
else
{
Status.SetTargetTick(Game.Control.ControlTick);
Status.SetTargetTick(::Control.ControlTick);
// send response to host
Clients.SendMsgToHost(MkC4NetIOPacket(PID_StatusAck, Status));
// do delayed activation request
@ -1764,7 +1765,7 @@ void C4Network2::RequestActivate()
if(fHost)
{
// activate him
Game.Control.DoInput(CID_ClientUpdate,
::Control.DoInput(CID_ClientUpdate,
new C4ControlClientUpdate(C4ClientIDHost, CUT_Activate, TRUE),
CDT_Sync);
return;
@ -1794,7 +1795,7 @@ void C4Network2::DeactivateInactiveClients()
for(C4Network2Client *pClient = Clients.GetNextClient(NULL); pClient; pClient = Clients.GetNextClient(pClient))
if(!pClient->isLocal() && pClient->isActivated())
if(pClient->getLastActivity() + C4NetDeactivationDelay < Game.FrameCounter)
Game.Control.DoInput(CID_ClientUpdate, new C4ControlClientUpdate(pClient->getID(), CUT_Activate, false), CDT_Sync);
::Control.DoInput(CID_ClientUpdate, new C4ControlClientUpdate(pClient->getID(), CUT_Activate, false), CDT_Sync);
}
void C4Network2::UpdateChaseTarget()
@ -1814,7 +1815,7 @@ void C4Network2::UpdateChaseTarget()
return;
// copy status, set current tick
C4Network2Status ChaseTarget = Status;
ChaseTarget.SetTargetTick(Game.Control.ControlTick);
ChaseTarget.SetTargetTick(::Control.ControlTick);
// send to everyone involved
for(pClient = Clients.GetNextClient(NULL); pClient; pClient = Clients.GetNextClient(pClient))
if(pClient->isChasing())
@ -2530,7 +2531,7 @@ void C4Network2::Vote(C4ControlVoteType eType, bool fApprove, int32_t iData)
iLastOwnVoting = time(NULL);
}
// Already voted? Ignore
if(GetVote(Game.Control.ClientID(), eType, iData))
if(GetVote(::Control.ClientID(), eType, iData))
return;
// Set pause mode if this is the host
if(isHost() && isRunning())
@ -2539,7 +2540,7 @@ void C4Network2::Vote(C4ControlVoteType eType, bool fApprove, int32_t iData)
fPausedForVote = true;
}
// send vote control
Game.Control.DoInput(CID_Vote, new C4ControlVote(eType, fApprove, iData), CDT_Direct);
::Control.DoInput(CID_Vote, new C4ControlVote(eType, fApprove, iData), CDT_Direct);
}
void C4Network2::AddVote(const C4ControlVote &Vote)
@ -2628,7 +2629,7 @@ void C4Network2::OpenVoteDialog()
{
// Already voted on this matter?
C4ControlVote *pVote = static_cast<C4ControlVote *>(pPkt->getPkt());
if(!GetVote(Game.Control.ClientID(), pVote->getType(), pVote->getData()))
if(!GetVote(::Control.ClientID(), pVote->getType(), pVote->getData()))
{
// Compose message
C4Client *pSrcClient = Game.Clients.getClientByID(pVote->getByClient());

View File

@ -32,6 +32,7 @@
#include "C4GameOptions.h"
#include <C4Game.h>
#include <C4PlayerList.h>
#include <C4GameControl.h>
#endif
#ifndef HAVE_WINSOCK
@ -182,7 +183,7 @@ void C4Network2ClientListBox::ClientListItem::Update()
// update wait label
if (pPing)
{
int iWait = Game.Control.Network.ClientPerfStat(iClientID);
int iWait = ::Control.Network.ClientPerfStat(iClientID);
pPing->SetText(FormatString("%d ms", iWait).getData());
pPing->SetColor(RGB(
BoundBy(255-Abs(iWait)*5, 0, 255),
@ -235,7 +236,7 @@ void C4Network2ClientListBox::ClientListItem::Update()
// network OK - control ready?
if (!pForDlg->IsStartup() && (icoStatus == C4GUI::Ico_Ready))
{
if (!Game.Control.Network.ClientReady(iClientID, Game.Control.ControlTick))
if (!::Control.Network.ClientReady(iClientID, ::Control.ControlTick))
{
// control not ready
icoStatus = C4GUI::Ico_NetWait;
@ -259,7 +260,7 @@ void C4Network2ClientListBox::ClientListItem::OnButtonActivate(C4GUI::Control *p
return;
}
// change to status that is not currently shown
Game.Control.DoInput(CID_ClientUpdate, new C4ControlClientUpdate(iClientID, CUT_Activate, !fShownActive), CDT_Sync);
::Control.DoInput(CID_ClientUpdate, new C4ControlClientUpdate(iClientID, CUT_Activate, !fShownActive), CDT_Sync);
}
void C4Network2ClientListBox::ClientListItem::OnButtonKick(C4GUI::Control *pButton)
@ -487,9 +488,9 @@ void C4Network2ClientListDlg::Update()
// Compose status text
StdStrBuf sStatusText;
sStatusText.Format("Tick %d, Behind %d, Rate %d, PreSend %d, ACT: %d",
(int)Game.Control.ControlTick, (int)Game.Control.Network.GetBehind(Game.Control.ControlTick),
(int)Game.Control.ControlRate, (int)Game.Control.Network.getControlPreSend(),
(int)Game.Control.Network.getAvgControlSendTime());
(int)::Control.ControlTick, (int)::Control.Network.GetBehind(::Control.ControlTick),
(int)::Control.ControlRate, (int)::Control.Network.getControlPreSend(),
(int)::Control.Network.getAvgControlSendTime());
// Update status label
pStatusLabel->SetText(sStatusText.getData());
}
@ -641,7 +642,7 @@ void C4GameOptionButtons::OnBtnFairCrew(C4GUI::Control *btn)
{
// altering button in lobby: Must be distributed as a control to all clients
if (Game.Parameters.FairCrewForced) return;
Game.Control.DoInput(CID_Set, new C4ControlSet(C4CVT_FairCrew, Game.Parameters.UseFairCrew ? -1 : Config.General.FairCrewStrength), CDT_Sync);
::Control.DoInput(CID_Set, new C4ControlSet(C4CVT_FairCrew, Game.Parameters.UseFairCrew ? -1 : Config.General.FairCrewStrength), CDT_Sync);
// button will be updated through control
}
else

View File

@ -28,6 +28,7 @@
#include <C4UserMessages.h>
#include <C4Log.h>
#include <C4Game.h>
#include <C4GameControl.h>
#endif
#ifndef HAVE_WINSOCK
@ -931,7 +932,7 @@ void C4Network2IO::CallHandlers(int iHandlerID, const C4IDPacket *pPkt, C4Networ
// network control (mixed)
if(iHandlerID & PH_C4GameControlNetwork)
{
Game.Control.Network.HandlePacket(cStatus, pPacket, pConn);
::Control.Network.HandlePacket(cStatus, pPacket, pConn);
}
}

View File

@ -26,6 +26,8 @@
#include "C4PlayerInfo.h"
#include "C4GameLobby.h"
#include <C4Game.h>
#include <C4Network2.h>
#include <C4GameControl.h>
#include "C4Control.h"
@ -208,7 +210,7 @@ void C4Network2Players::HandlePlayerInfoUpdRequest(const class C4ClientPlayerInf
// so future player join request will take the other joined clients into consideration
// when assigning player colors, etc.; it will also start resource loading
// 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);
::Control.DoInput(CID_PlrInfo, new C4ControlPlayerInfo(OwnInfoPacket), CDT_Direct);
// notify lobby of updates
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
if (pLobby) pLobby->OnPlayersChange();
@ -255,7 +257,7 @@ void C4Network2Players::SendUpdatedPlayers()
{
C4ControlPlayerInfo *pkSend = new C4ControlPlayerInfo(*pUpdInfo);
// send info to all
Game.Control.DoInput(CID_PlrInfo, pkSend, CDT_Direct);
::Control.DoInput(CID_PlrInfo, pkSend, CDT_Direct);
}
ResetUpdatedPlayers();
}
@ -334,7 +336,7 @@ void C4Network2Players::JoinUnjoinedPlayersInControlQueue(C4ClientPlayerInfos *p
// do so!
C4Network2Res *pPlrRes = pInfo->GetRes();
C4Network2Client *pClient = ::Network.Clients.GetClientByID(pNewPacket->GetClientID());
if (!pPlrRes || (!pClient && pNewPacket->GetClientID() != Game.Control.ClientID()))
if (!pPlrRes || (!pClient && pNewPacket->GetClientID() != ::Control.ClientID()))
if (pInfo->GetType() != C4PT_Script)
{
// failure: Non-script players must have a res to join from!

View File

@ -29,6 +29,7 @@
#include <C4Group.h>
#include <C4Components.h>
#include <C4Game.h>
#include <C4GameControl.h>
#endif
#include <fcntl.h>
@ -1691,7 +1692,7 @@ void C4Network2ResList::OnResComplete(C4Network2Res *pRes)
// log (network thread -> ThreadLog)
Application.InteractiveThread.ThreadLogS("Network: %s received.", pRes->getCore().getFileName());
// call handler (ctrl might wait for this ressource)
Game.Control.Network.OnResComplete(pRes);
::Control.Network.OnResComplete(pRes);
}
bool C4Network2ResList::CreateNetworkFolder()

View File

@ -27,6 +27,8 @@
#include <C4Player.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4Network2.h>
#include <C4GameControl.h>
#endif
C4Graph::C4Graph()
@ -362,8 +364,8 @@ void C4Network2Stats::ExecuteSecond()
void C4Network2Stats::ExecuteControlFrame()
{
// control rate may have updated: always convert values to actions per minute
statControls.SetMultiplier((C4Graph::ValueType) 1000 / 38 / Game.Control.ControlRate);
statActions.SetMultiplier((C4Graph::ValueType) 1000 / 38 * 60 / Game.Control.ControlRate);
statControls.SetMultiplier((C4Graph::ValueType) 1000 / 38 / ::Control.ControlRate);
statActions.SetMultiplier((C4Graph::ValueType) 1000 / 38 * 60 / ::Control.ControlRate);
// register and reset control counts for all players
for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next)
{

View File

@ -53,6 +53,7 @@
#include <C4Game.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4Record.h>
#endif
void DrawVertex(C4Facet &cgo, int32_t tx, int32_t ty, int32_t col, int32_t contact)

View File

@ -48,6 +48,7 @@
#include <C4Game.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4GameControl.h>
#endif
#define C4FOW_Def_View_RangeX 500
@ -179,7 +180,7 @@ void C4Player::Execute()
{
// There's only one team left to join? Join there immediately.
if (Menu.IsActive() && Menu.GetIdentification() == C4MN_TeamSelection) Menu.TryClose(false, false);
if (LocalControl && !Game.Control.isReplay())
if (LocalControl && !::Control.isReplay())
{
// team selection done through queue because TeamSelection-status may not be in sync (may be TeamSelectionPending!)
DoTeamSelection(idSelectedTeam);
@ -444,7 +445,7 @@ BOOL C4Player::Save()
// resource
C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(Filename),
pDRes = NULL;
bool fOfficial = pRes && Game.Control.isCtrlHost();
bool fOfficial = pRes && ::Control.isCtrlHost();
if(pRes) pDRes = pRes->Derive();
// move back
if (ItemExists(Filename)) EraseItem(Filename);
@ -1738,7 +1739,7 @@ void C4Player::DoTeamSelection(int32_t idTeam)
// stop team selection. This might close the menu forever if the control gets lost
// let's hope it doesn't!
Status = PS_TeamSelectionPending;
Game.Control.DoInput(CID_Script, new C4ControlScript(FormatString("InitScenarioPlayer(%d,%d)", (int)Number, (int)idTeam).getData()), CDT_Queue);
::Control.DoInput(CID_Script, new C4ControlScript(FormatString("InitScenarioPlayer(%d,%d)", (int)Number, (int)idTeam).getData()), CDT_Queue);
}
void C4Player::EnumeratePointers()
@ -1845,7 +1846,7 @@ void C4Player::InitControl()
{
// Check local control
LocalControl = FALSE;
if (AtClient == Game.Control.ClientID())
if (AtClient == ::Control.ClientID())
if (!GetInfo() || GetInfo()->GetType() == C4PT_User)
LocalControl=TRUE;
// Set control
@ -1877,7 +1878,7 @@ void C4Player::InitControl()
pGamepad = new C4GamePadOpener(Control - C4P_Control_GamePad1);
}
// Mouse
if (PrefMouse && !Game.Control.isReplay())
if (PrefMouse && !::Control.isReplay())
if (!Game.C4S.Head.DisableMouse)
if (Inside<int32_t>(Control, C4P_Control_Keyboard1, C4P_Control_GamePadMax))
if (!::Players.MouseControlTaken())
@ -2012,7 +2013,7 @@ void C4Player::Eliminate()
Log(FormatString(LoadResStr("IDS_PRC_PLRELIMINATED"),GetName()).getData());
// Early client deactivation check
if(Game.Control.isCtrlHost() && AtClient > C4ClientIDHost)
if(::Control.isCtrlHost() && AtClient > C4ClientIDHost)
{
// Check: Any player left at this client?
C4Player *pPlr = NULL;
@ -2021,7 +2022,7 @@ void C4Player::Eliminate()
break;
// If not, deactivate the client
if(!pPlr)
Game.Control.DoInput(CID_ClientUpdate,
::Control.DoInput(CID_ClientUpdate,
new C4ControlClientUpdate(AtClient, CUT_Activate, false),
CDT_Sync);
}

View File

@ -34,6 +34,7 @@
#include <C4Player.h>
#include <C4FullScreen.h>
#include <C4PlayerList.h>
#include <C4GameControl.h>
#endif
// *** C4PlayerInfo
@ -381,9 +382,9 @@ C4ClientPlayerInfos::C4ClientPlayerInfos(const char *szJoinFilenames, bool fAdd,
if (SSearch(Config.GetRegistrationData("Type"), "Developer"))
dwFlags |= CIF_Developer;
// set local ID
iClientID = Game.Control.ClientID();
iClientID = ::Control.ClientID();
// maybe control is not preinitialized
if (!Game.Control.isNetwork() && iClientID < 0) iClientID = 0;
if (!::Control.isNetwork() && iClientID < 0) iClientID = 0;
// join packet or initial packet?
if (fAdd)
// packet is to be added to other players
@ -748,10 +749,10 @@ bool C4PlayerInfoList::DoLocalNonNetworkPlayerJoin(const char *szPlayerFile)
bool C4PlayerInfoList::DoPlayerInfoUpdate(C4ClientPlayerInfos *pUpdate)
{
// never done by clients or in replay - update will be handled via queue
if (!Game.Control.isCtrlHost()) return false;
if (!::Control.isCtrlHost()) return false;
// in network game, process by host. In offline game, just create control
bool fSucc = true;
if (Game.Control.isNetwork())
if (::Control.isNetwork())
::Network.Players.RequestPlayerInfoUpdate(*pUpdate);
else
fSucc = DoLocalNonNetworkPlayerInfoUpdate(pUpdate);
@ -771,7 +772,7 @@ bool C4PlayerInfoList::DoLocalNonNetworkPlayerInfoUpdate(C4ClientPlayerInfos *pU
UpdatePlayerAttributes(pUpdate, true);
// add through queue: This will add directly, do the record and put player joins into the queue
// in running mode, this call will also put the actual player joins into the queue
Game.Control.DoInput(CID_PlrInfo, new C4ControlPlayerInfo(*pUpdate), Game.IsRunning ? CDT_Queue : CDT_Direct);
::Control.DoInput(CID_PlrInfo, new C4ControlPlayerInfo(*pUpdate), Game.IsRunning ? CDT_Queue : CDT_Direct);
// done, success
return true;
}
@ -1336,7 +1337,7 @@ bool C4PlayerInfoList::LocalJoinUnjoinedPlayersInQueue()
// local call only - in network, C4Network2Players joins players!
assert(!::Network.isEnabled());
// get local players
C4ClientPlayerInfos **ppkLocal = GetInfoPtrByClientID(Game.Control.ClientID()), *pkLocal;
C4ClientPlayerInfos **ppkLocal = GetInfoPtrByClientID(::Control.ClientID()), *pkLocal;
if (!ppkLocal) return false;
pkLocal = *ppkLocal;
// check all players
@ -1358,7 +1359,7 @@ bool C4PlayerInfoList::LocalJoinUnjoinedPlayersInQueue()
continue;
}
Game.Input.Add(CID_JoinPlr,
new C4ControlJoinPlayer(szFilename, Game.Control.ClientID(), pInfo->GetID()));
new C4ControlJoinPlayer(szFilename, ::Control.ClientID(), pInfo->GetID()));
}
// done, success
return true;
@ -1468,7 +1469,7 @@ bool C4PlayerInfoList::RestoreSavegameInfos(C4PlayerInfoList &rSavegamePlayers)
// in replay mode, if there are no regular player joins, it must have been a runtime record
// i.e., a record that was started during the game
// in this case, the savegame player infos equal the real player infos to be used
if (Game.Control.isReplay() && !GetInfoCount())
if (::Control.isReplay() && !GetInfoCount())
{
*this = rSavegamePlayers;
}
@ -1584,7 +1585,7 @@ bool C4PlayerInfoList::RecreatePlayers()
// local non-network non-replay games set local name
if (!::Network.isEnabled())
{
assert(idAtClient == Game.Control.ClientID());
assert(idAtClient == ::Control.ClientID());
szAtClientName = "Local";
}
else
@ -1634,11 +1635,11 @@ bool C4PlayerInfoList::RecreatePlayers()
}
}
// record file handling: Save to the record file in the manner it's expected by C4PlayerInfoList::RecreatePlayers
if (Game.Control.isRecord() && szFilename)
if (::Control.isRecord() && szFilename)
{
StdStrBuf sFilenameInRecord;
sFilenameInRecord.Format("Recreate-%d.c4p", pInfo->GetID());
Game.Control.RecAddFile(szFilename, sFilenameInRecord.getData());
::Control.RecAddFile(szFilename, sFilenameInRecord.getData());
}
// recreate join directly
::Players.Join(szFilename, FALSE, idAtClient, szAtClientName, pInfo);

View File

@ -31,6 +31,8 @@
#include <C4FileSelDlg.h>
#include <C4GraphicsResource.h>
#include <C4MouseControl.h>
#include <C4Network2.h>
#include <C4GameControl.h>
#endif
DWORD GenerateRandomPlayerColor(int32_t iTry); // in C4PlayerInfoConflicts.cpp
@ -935,7 +937,7 @@ void C4PlayerInfoListBox::ClientListItem::OnCtxActivate(C4GUI::Element *pListIte
C4Client *pClient = GetClient();
if (!::Network.isEnabled() || !::Network.isHost() || !pClient) return;
// add control
Game.Control.DoInput(CID_ClientUpdate, new C4ControlClientUpdate(idClient, CUT_Activate, !pClient->isActivated()), CDT_Sync);
::Control.DoInput(CID_ClientUpdate, new C4ControlClientUpdate(idClient, CUT_Activate, !pClient->isActivated()), CDT_Sync);
}
void C4PlayerInfoListBox::ClientListItem::OnCtxInfo(C4GUI::Element *pListItem)
@ -1127,7 +1129,7 @@ C4PlayerInfoListBox::ScriptPlayersListItem::ScriptPlayersListItem(C4PlayerInfoLi
pIcon = new C4GUI::Icon(C4Rect(0, 0, iIconSize, iIconSize), C4GUI::Ico_Record);
pNameLabel = new C4GUI::Label(LoadResStr("IDS_CTL_SCRIPTPLAYERS"), iIconSize + IconLabelSpacing,0, ALeft);
btnAddPlayer = NULL;
if (Game.Control.isCtrlHost())
if (::Control.isCtrlHost())
{
btnAddPlayer = new C4GUI::CallbackButton<ScriptPlayersListItem, C4GUI::IconButton>(C4GUI::Ico_AddPlr, C4Rect(0, 0, iIconSize, iIconSize), 'A' /* 2do TODO */, &ScriptPlayersListItem::OnBtnAddPlr, this);
}
@ -1170,7 +1172,7 @@ void C4PlayerInfoListBox::ScriptPlayersListItem::OnBtnAddPlr(C4GUI::Control *btn
int32_t iCurrScriptPlrCount = Game.PlayerInfos.GetActiveScriptPlayerCount(true, true);
bool fCanJoinScriptPlayers = (Game.Teams.GetMaxScriptPlayers() - iCurrScriptPlrCount > 0);
if (!fCanJoinScriptPlayers) return;
if (!Game.Control.isCtrlHost()) return;
if (!::Control.isCtrlHost()) return;
// request a script player join
C4PlayerInfo *pScriptPlrInfo = new C4PlayerInfo();
pScriptPlrInfo->SetAsScriptPlayer(Game.Teams.GetScriptPlayerName().getData(), GenerateRandomPlayerColor(iCurrScriptPlrCount), 0, C4ID_None);

View File

@ -35,6 +35,7 @@
#include <C4Game.h>
#include <C4GraphicsSystem.h>
#include <C4GameObjects.h>
#include <C4GameControl.h>
#endif
C4PlayerList::C4PlayerList()
@ -452,7 +453,7 @@ BOOL C4PlayerList::Retire(C4Player *pPlr)
if (!pPlr->Evaluated)
{
pPlr->Evaluate();
if (!Game.Control.isReplay() && pPlr->GetType() != C4PT_Script) pPlr->Save();
if (!::Control.isReplay() && pPlr->GetType() != C4PT_Script) pPlr->Save();
}
Remove(pPlr, false, false);
@ -610,7 +611,7 @@ C4Player* C4PlayerList::GetAtRemoteClient(int iIndex) const
{
int cindex=0;
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->AtClient != Game.Control.ClientID())
if (pPlr->AtClient != ::Control.ClientID())
{
if (cindex==iIndex) return pPlr;
cindex++;

View File

@ -30,6 +30,7 @@
#include <C4Log.h>
#include <C4Player.h>
#include <C4Game.h>
#include <C4GameControl.h>
#endif
#include <StdFile.h>
@ -47,7 +48,7 @@ int DoNoDebugRec=0; // debugrec disable counter
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
{
Game.Control.DbgRec(eType, (const uint8_t *) pData, iSize);
::Control.DbgRec(eType, (const uint8_t *) pData, iSize);
}
#else
bool DoDebugRec=false;
@ -911,7 +912,7 @@ void C4Playback::Finish()
Game.DoGameOver();
}
// finish playback: enable controls
Game.Control.ChangeToLocal();
::Control.ChangeToLocal();
}
void C4Playback::Clear()
@ -1043,7 +1044,7 @@ void C4Playback::Check(C4RecordChunkType eType, const uint8_t *pData, int iSize)
C4IDPacket Packet(*currChunk->pPkt);
C4ControlPacket *pCtrlPck = static_cast<C4ControlPacket *>(Packet.getPkt());
assert(!pCtrlPck->Sync());
Game.Control.ExecControlPacket(Packet.getPktType(), pCtrlPck);
::Control.ExecControlPacket(Packet.getPktType(), pCtrlPck);
NextChunk();
}
// record end?

View File

@ -52,6 +52,7 @@
#include <C4PlayerList.h>
#include <C4Game.h>
#include <C4GameObjects.h>
#include <C4GameControl.h>
#endif
//========================== Some Support Functions =======================================
@ -2440,7 +2441,7 @@ static long FnSetPlayList(C4AulContext *cth, C4String *szPlayList)
long iFilesInPlayList = Application.MusicSystem.SetPlayList(FnStringPar(szPlayList));
Game.PlayList.Copy(FnStringPar(szPlayList));
// network/record/replay: return 0
if(Game.Control.SyncMode()) return 0;
if(::Control.SyncMode()) return 0;
return iFilesInPlayList;
}
@ -2676,7 +2677,7 @@ static C4String *FnGetPlrControlName(C4AulContext *cthr, long iPlr, long iCon, b
static long FnGetPlrViewMode(C4AulContext *cthr, long iPlr)
{
if (!ValidPlr(iPlr)) return -1;
if (Game.Control.SyncMode()) return -1;
if (::Control.SyncMode()) return -1;
return ::Players.Get(iPlr)->ViewMode;
}
@ -2982,7 +2983,7 @@ static bool FnCreateScriptPlayer(C4AulContext *cthr, C4String *szName, long dwCo
// this script command puts a new script player info into the list
// the actual join will be delayed and synchronized via queue
// processed by control host only - clients/replay/etc. will perform the join via queue
if (!Game.Control.isCtrlHost()) return true;
if (!::Control.isCtrlHost()) return true;
C4PlayerInfo *pScriptPlrInfo = new C4PlayerInfo();
uint32_t dwInfoFlags = 0u;
if (dwFlags & CSPF_FixedAttributes ) dwInfoFlags |= C4PlayerInfo::PIF_AttributesFixed;
@ -3655,7 +3656,7 @@ static C4Value FnPrivateCall_C4V(C4AulContext *cthr,
static C4Value FnEditCursor(C4AulContext *cth, C4Value *pPars)
{
if (Game.Control.SyncMode()) return C4VNull;
if (::Control.SyncMode()) return C4VNull;
return C4VObj(Console.EditCursor.GetTarget());
}
@ -4037,7 +4038,7 @@ static bool FnGetMissionAccess(C4AulContext *cthr, C4String *strMissionAccess)
if (!strMissionAccess) return FALSE;
// non-sync mode: warn
if(Game.Control.SyncMode())
if(::Control.SyncMode())
Log("Warning: using GetMissionAccess may cause desyncs when playing records!");
if (!Config.General.MissionAccess) return FALSE;
@ -4804,7 +4805,7 @@ static long FnNoContainer(C4AulContext*) { return NO_CONTAINER; }
static long FnGetTime(C4AulContext *)
{
// check network, record, etc
if (Game.Control.SyncMode()) return 0;
if (::Control.SyncMode()) return 0;
return timeGetTime();
}
@ -4812,7 +4813,7 @@ static long FnGetSystemTime(C4AulContext *cthr, long iWhat)
{
#ifdef _WIN32
// check network, record, etc
if (Game.Control.SyncMode()) return 0;
if (::Control.SyncMode()) return 0;
// check bounds
if (!Inside<long>(iWhat, 0, 7)) return 0;
SYSTEMTIME time;
@ -5387,7 +5388,7 @@ static bool FnSetFilmView(C4AulContext *ctx, long iToPlr)
// check player
if (!ValidPlr(iToPlr) && iToPlr != NO_OWNER) return FALSE;
// real switch in replays only
if (!Game.Control.isReplay()) return TRUE;
if (!::Control.isReplay()) return TRUE;
// set new target plr
if (C4Viewport *vp = ::GraphicsSystem.GetFirstViewport()) vp->Init(iToPlr, true);
// done, always success (sync)
@ -5962,12 +5963,12 @@ static bool FnSetViewOffset(C4AulContext *ctx, long iPlayer, long iX, long iY)
static bool FnSetPreSend(C4AulContext *cthr, long iToVal, C4String *pNewName)
{
if (!Game.Control.isNetwork()) return TRUE;
if (!::Control.isNetwork()) return TRUE;
// dbg: manual presend
const char *szClient = FnStringPar(pNewName);
if (!szClient || !*szClient || WildcardMatch(szClient, Game.Clients.getLocalName()))
{
Game.Control.Network.setTargetFPS(iToVal);
::Control.Network.setTargetFPS(iToVal);
::GraphicsSystem.FlashMessage(FormatString("TargetFPS: %ld", iToVal).getData());
}
return TRUE;
@ -6205,7 +6206,7 @@ static long FnActivateGameGoalMenu(C4AulContext *ctx, long iPlayer)
C4Player *pPlr = ::Players.Get(iPlayer);
if (!pPlr) return FALSE;
// open menu
return pPlr->Menu.ActivateGoals(pPlr->Number, pPlr->LocalControl && !Game.Control.isReplay());
return pPlr->Menu.ActivateGoals(pPlr->Number, pPlr->LocalControl && !::Control.isReplay());
}
static bool FnFatalError(C4AulContext *ctx, C4String *pErrorMsg)
@ -6301,7 +6302,7 @@ static bool FnCustomMessage(C4AulContext *ctx, C4String *pMsg, C4Object *pObj, l
static bool FnPauseGame(C4AulContext *ctx, bool fToggle)
{
// not in replay (film)
if (Game.Control.isReplay()) return true;
if (::Control.isReplay()) return true;
// script method for halting game (for films)
if (fToggle)
Console.TogglePause();

View File

@ -32,6 +32,7 @@
#include <C4Game.h>
#include <C4Log.h>
#include <C4GraphicsResource.h>
#include <C4Network2.h>
#endif
#include <StdGL.h>

View File

@ -29,6 +29,7 @@
#include <C4Components.h>
#include <C4Player.h>
#include <C4PlayerList.h>
#include <C4GameControl.h>
#endif
// ---------------------------------------------------------------
@ -304,7 +305,7 @@ bool C4TeamList::CanLocalChooseTeam() const
switch (eTeamDist)
{
case TEAMDIST_Free: return true;
case TEAMDIST_Host: return Game.Control.isCtrlHost();
case TEAMDIST_Host: return ::Control.isCtrlHost();
case TEAMDIST_Random:
case TEAMDIST_RandomInv:
return false;
@ -462,7 +463,7 @@ bool C4TeamList::RecheckPlayerInfoTeams(C4PlayerInfo &rNewJoin, bool fByHost)
assert(IsMultiTeams());
if (!IsMultiTeams()) return false;
// local/single call only
//assert(Game.Control.isCtrlHost()); -- bla, control is not initialized at this point.
//assert(::Control.isCtrlHost()); -- bla, control is not initialized at this point.
// check whether a new team is to be assigned first
C4Team *pCurrentTeam = GetTeamByPlayerID(rNewJoin.GetID());
int32_t idCurrentTeam = pCurrentTeam ? pCurrentTeam->GetID() : 0;
@ -674,7 +675,7 @@ void C4TeamList::RecheckTeams()
// automatic team distributions only
if (eTeamDist != TEAMDIST_Random && eTeamDist != TEAMDIST_RandomInv) return;
// host decides random teams
if (!Game.Control.isCtrlHost()) return;
if (!::Control.isCtrlHost()) return;
// redistribute players of largest team that has relocatable players left towards smaller teams
for(;;)
{
@ -709,8 +710,8 @@ void C4TeamList::RecheckTeams()
void C4TeamList::ReassignAllTeams()
{
assert(Game.Control.isCtrlHost());
if (!Game.Control.isCtrlHost()) return;
assert(::Control.isCtrlHost());
if (!::Control.isCtrlHost()) return;
// go through all player infos; reset team in them
int32_t idStart = -1; C4PlayerInfo *pNfo;
while (pNfo = Game.PlayerInfos.GetNextPlayerInfoByID(idStart))
@ -765,9 +766,9 @@ void C4TeamList::FillTeamDistOptions(C4GUI::ComboBox_FillCB *pFiller) const
void C4TeamList::SendSetTeamDist(TeamDist eNewTeamDist)
{
assert(Game.Control.isCtrlHost());
assert(::Control.isCtrlHost());
// set it for all clients
Game.Control.DoInput(CID_Set, new C4ControlSet(C4CVT_TeamDistribution, eNewTeamDist), CDT_Sync);
::Control.DoInput(CID_Set, new C4ControlSet(C4CVT_TeamDistribution, eNewTeamDist), CDT_Sync);
}
StdStrBuf C4TeamList::GetTeamDistString() const
@ -787,7 +788,7 @@ void C4TeamList::SetTeamDistribution(TeamDist eToVal)
if (!Inside(eToVal, TEAMDIST_First, TEAMDIST_Last)) { assert(false); return; }
eTeamDist = eToVal;
// team distribution mode changed: Host may beed to redistribute
if (Game.Control.isCtrlHost())
if (::Control.isCtrlHost())
{
// if a random team mode was set, reassign all teams so it's really random
if (eTeamDist == TEAMDIST_Random || eTeamDist == TEAMDIST_RandomInv)
@ -808,7 +809,7 @@ void C4TeamList::SetTeamDistribution(TeamDist eToVal)
void C4TeamList::SendSetTeamColors(bool fEnabled)
{
// set it for all clients
Game.Control.DoInput(CID_Set, new C4ControlSet(C4CVT_TeamColors, fEnabled), CDT_Sync);
::Control.DoInput(CID_Set, new C4ControlSet(C4CVT_TeamColors, fEnabled), CDT_Sync);
}
void C4TeamList::SetTeamColors(bool fEnabled)
@ -818,7 +819,7 @@ void C4TeamList::SetTeamColors(bool fEnabled)
// reflect change
fTeamColors = fEnabled;
// update colors of all players
if (!Game.Control.isCtrlHost()) return;
if (!::Control.isCtrlHost()) return;
// go through all player infos; reset color in them
Game.PlayerInfos.UpdatePlayerAttributes(); // sets team and savegame colors
if (::Network.isEnabled())

View File

@ -30,6 +30,7 @@
#include <C4Texture.h>
#include <C4Landscape.h>
#include <C4Game.h>
#include <C4GameControl.h>
#include <StdRegistry.h>
#include <StdD3D.h>
#ifdef USE_GL
@ -893,7 +894,7 @@ BOOL C4ToolsDlg::SetLandscapeMode(int32_t iMode, bool fThroughControl)
// send as control
if (!fThroughControl)
{
Game.Control.DoInput(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_SetMode, iMode), CDT_Decide);
::Control.DoInput(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_SetMode, iMode), CDT_Decide);
return TRUE;
}
// Set landscape mode

View File

@ -49,6 +49,7 @@
#include <C4Game.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4Network2.h>
#endif
#include <StdGL.h>