OpenClonk
C4Game Class Reference

#include <C4Game.h>

Collaboration diagram for C4Game:
[legend]

Public Types

enum  InitMode { IM_Normal = 0, IM_Section = 1, IM_ReInit = 2 }
 

Public Member Functions

 C4Game ()
 
 ~C4Game ()
 
void Clear ()
 
void Abort (bool fApproved=false)
 
void Evaluate ()
 
void ShowGameOverDlg ()
 
bool DoKeyboardInput (C4KeyCode vk_code, C4KeyEventType eEventType, bool fAlt, bool fCtrl, bool fShift, bool fRepeated, class C4GUI::Dialog *pForDialog=nullptr, bool fPlrCtrlOnly=false, int32_t iStrength=-1)
 
bool DoKeyboardInput (C4KeyCodeEx Key, C4KeyEventType eEventType, class C4GUI::Dialog *pForDialog=nullptr, bool fPlrCtrlOnly=false, int32_t iStrength=-1)
 
void DrawCrewOverheadText (C4TargetFacet &cgo, int32_t iPlayer)
 
void FixRandom (uint64_t iSeed)
 
bool Init ()
 
bool PreInit ()
 
void SetScenarioFilename (const char *)
 
bool HasScenario ()
 
bool Execute ()
 
C4PlayerJoinPlayer (const char *szFilename, int32_t iAtClient, const char *szAtClientName, C4PlayerInfo *pInfo)
 
void OnPlayerJoinFinished ()
 
bool DoGameOver ()
 
bool CanQuickSave ()
 
bool QuickSave (const char *strFilename, const char *strTitle, bool fForceSave=false)
 
void SetInitProgress (float fToProgress)
 
void OnResolutionChanged (unsigned int iXRes, unsigned int iYRes)
 
void OnKeyboardLayoutChanged ()
 
void InitFullscreenComponents (bool fRunning)
 
bool ToggleChat ()
 
bool TogglePause ()
 
bool Pause ()
 
bool Unpause ()
 
bool IsPaused ()
 
void Synchronize (bool fSavePlayerFiles)
 
void SyncClearance ()
 
bool DropFile (const char *szFilename, float iX, float iY)
 
bool DropDef (C4ID id, float iX, float iY)
 
bool ReloadFile (const char *szPath)
 
bool ReloadDef (C4ID id)
 
bool ReloadParticle (const char *szName)
 
void ClearPointers (C4Object *cobj)
 
C4ObjectCreateObject (C4PropList *type, C4Object *pCreator, int32_t owner=NO_OWNER, int32_t x=50, int32_t y=50, int32_t r=0, bool grow_from_center=false, C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t iController=NO_OWNER)
 
C4ObjectCreateObject (C4ID type, C4Object *pCreator, int32_t owner=NO_OWNER, int32_t x=50, int32_t y=50, int32_t r=0, bool grow_from_center=false, C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t iController=NO_OWNER)
 
C4ObjectCreateObjectConstruction (C4PropList *type, C4Object *pCreator, int32_t owner, int32_t ctx=0, int32_t bty=0, int32_t con=1, bool terrain=false)
 
C4ObjectCreateInfoObject (C4ObjectInfo *cinf, int32_t owner, int32_t tx=50, int32_t ty=50)
 
C4ObjectFindConstuctionSiteBlock (int32_t tx, int32_t ty, int32_t wdt, int32_t hgt)
 
C4ObjectFindObject (C4Def *pDef, int32_t iX=0, int32_t iY=0, int32_t iWdt=0, int32_t iHgt=0, DWORD ocf=OCF_All, C4Object *pFindNext=nullptr)
 
C4ObjectFindVisObject (float tx, float ty, int32_t iPlr, const C4Facet &fctViewportGame, const C4Facet &fctViewportGUI, float iX, float iY, DWORD category, float gui_x, float gui_y)
 
int32_t ObjectCount (C4ID id)
 
void CastObjects (C4ID id, C4Object *pCreator, int32_t num, int32_t level, int32_t tx, int32_t ty, int32_t iOwner=NO_OWNER, int32_t iController=NO_OWNER, C4ValueArray *out_objects=nullptr)
 
C4ObjectPlaceVegetation (C4PropList *def, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iGrowth, C4PropList *shape_proplist, C4PropList *out_pos_proplist)
 
C4ObjectPlaceAnimal (C4PropList *def)
 
C4Value GRBroadcast (const char *szFunction, C4AulParSet *pPars=nullptr, bool fPassError=false, bool fRejectTest=false)
 
bool LoadScenarioSection (const char *szSection, DWORD dwFlags)
 
bool CreateSectionFromTempFile (const char *section_name, const char *temp_filename)
 
bool DrawTextSpecImage (C4Facet &fctTarget, const char *szSpec, class C4DrawTransform *pTransform, uint32_t dwClr=0xff)
 
float GetTextSpecImageAspect (const char *szSpec)
 
bool DrawPropListSpecImage (C4Facet &fctTarget, C4PropList *pSpec)
 
bool SpeedUp ()
 
bool SlowDown ()
 
bool InitKeyboard ()
 
void UpdateLanguage ()
 
bool InitPlayerControlSettings ()
 
bool InitPlayerControlUserSettings ()
 
void SetDefaultGamma ()
 
bool LoadAdditionalSystemGroup (class C4Group &parent_group)
 
bool SaveGameTitle (C4Group &hGroup)
 
void CompileFunc (StdCompiler *pComp, CompileSettings comp, C4ValueNumbers *)
 
bool SaveData (C4Group &hGroup, bool fSaveSection, bool fSaveExact, bool fSaveSync, C4ValueNumbers *)
 
bool ToggleChart ()
 
void SetGlobalSoundModifier (C4PropList *modifier_props)
 
C4StringGetTranslatedString (const class C4Value &input_string, C4Value *selected_language, bool fail_silently) const
 
C4PropListAllocateTranslatedString ()
 

Public Attributes

C4GameParametersParameters
 
class C4ScenarioParametersStartupScenarioParameters
 
C4ClientListClients
 
C4TeamListTeams
 
C4PlayerInfoListPlayerInfos
 
C4PlayerInfoListRestorePlayerInfos
 
C4RoundResultsRoundResults
 
C4Scenario C4S
 
class C4ScenarioParameterDefsScenarioParameterDefs
 
C4ComponentHost Info
 
C4ComponentHost Title
 
C4ComponentHost Names
 
C4ComponentHost GameText
 
C4LangStringTable MainSysLangStringTable
 
C4LangStringTable ScenarioLangStringTable
 
StdStrBuf PlayerNames
 
C4ControlInput
 
C4PathFinder PathFinder
 
C4TransferZones TransferZones
 
C4Group ScenarioFile
 
C4GroupSet GroupSet
 
C4GrouppParentGroup
 
C4Extra Extra
 
class C4ScenarioObjectsScriptHostpScenarioObjectsScript
 
C4ScenarioSectionpScenarioSections
 
C4ScenarioSectionpCurrentScenarioSection
 
C4PlayerControlDefs PlayerControlDefs
 
C4PlayerControlAssignmentSets PlayerControlUserAssignmentSets
 
C4PlayerControlAssignmentSets PlayerControlDefaultAssignmentSets
 
C4Scoreboard Scoreboard
 
std::unique_ptr< C4Network2StatspNetworkStatistics
 
C4KeyboardInputKeyboardInput
 
std::unique_ptr< C4FileMonitorpFileMonitor
 
std::unique_ptr< C4GameSec1TimerpSec1Timer
 
C4ValueGlobalSoundModifier
 
char CurrentScenarioSection [C4MaxName+1]
 
char ScenarioFilename [_MAX_PATH+1]
 
StdCopyStrBuf ScenarioTitle
 
char PlayerFilenames [20 *_MAX_PATH+1]
 
char DefinitionFilenames [20 *_MAX_PATH+1]
 
char DirectJoinAddress [_MAX_PATH+1]
 
char DirectJoinTempFilename [_MAX_PATH+1]
 
std::unique_ptr< C4Network2ReferencepJoinReference
 
int32_t StartupPlayerCount
 
int32_t StartupTeamCount
 
int32_t FPS
 
int32_t cFPS
 
int32_t HaltCount
 
bool InitialPlayersJoined
 
bool GameOver
 
bool EvaluateOnAbort
 
bool Evaluated
 
bool GameOverDlgShown
 
bool fScriptCreatedObjects
 
bool fLobby
 
int32_t iLobbyTimeout
 
bool fObserve
 
bool fReferenceDefinitionOverride
 
bool NetworkActive
 
bool Record
 
StdStrBuf RecordDumpFile
 
StdStrBuf RecordStream
 
StdStrBuf TempScenarioFile
 
bool fPreinited {false}
 
int32_t FrameCounter
 
int32_t iTick2
 
int32_t iTick3
 
int32_t iTick5
 
int32_t iTick10
 
int32_t iTick35
 
int32_t iTick255
 
int32_t iTick1000
 
bool TimeGo
 
int32_t Time
 
int32_t StartTime
 
int32_t InitProgress
 
int32_t LastInitProgress
 
int32_t LastInitProgressShowTime
 
int32_t RandomSeed
 
bool GameGo
 
bool FullSpeed
 
int32_t FrameSkip
 
bool DoSkipFrame
 
bool fResortAnyObject
 
bool IsRunning
 
bool PointersDenumerated
 
size_t StartupLogPos {0}
 
size_t QuitLogPos {0}
 
bool fQuitWithError {false}
 
bool DebugMode
 
StdCopyStrBuf NextMission
 
StdCopyStrBuf NextMissionText
 
StdCopyStrBuf NextMissionDesc
 
uint16_t DebugPort
 
StdStrBuf DebugPassword
 
StdStrBuf DebugHost
 
int DebugWait
 
std::unique_ptr< C4ScriptGuiWindowScriptGuiRoot
 

Static Public Attributes

static constexpr const char * DirectJoinFilePrefix = "file:"
 

Protected Member Functions

void Default ()
 
void InitInEarth ()
 
void InitVegetation ()
 
void InitAnimals ()
 
void InitGoals ()
 
void InitRules ()
 
void InitValueOverloads ()
 
void InitEnvironment ()
 
void CloseScenario ()
 
void DeleteObjects (bool fDeleteInactive)
 
void ExecObjects ()
 
void Ticks ()
 
bool CheckObjectEnumeration ()
 
bool LoadScenarioComponents ()
 
bool InitGame (C4Group &hGroup, InitMode init_mode, bool fLoadSky, C4ValueNumbers *)
 
bool InitGameFinal (InitMode init_mode)
 
bool InitNetworkFromAddress (const char *szAddress)
 
bool InitNetworkFromReferenceFile (const char *temp_filename)
 
bool InitNetworkFromReference (const C4Network2Reference &Reference)
 
bool InitNetworkHost ()
 
bool InitControl ()
 
bool InitScriptEngine ()
 
bool LinkScriptEngine ()
 
bool ReLinkScriptEngine ()
 
bool InitPlayers (C4ValueNumbers *)
 
bool OpenScenario ()
 
bool InitDefs ()
 
bool InitMaterialTexture ()
 
bool GameOverCheck ()
 
bool PlaceInEarth (C4ID id)
 
bool CompileRuntimeData (C4Group &hGroup, InitMode init_mode, bool exact, bool sync, C4ValueNumbers *)
 
C4ObjectNewObject (C4PropList *ndef, C4Object *pCreator, int32_t owner, C4ObjectInfo *info, int32_t tx, int32_t ty, int32_t tr, C4Real xdir, C4Real ydir, C4Real rdir, int32_t con, int32_t iController, bool grow_from_center)
 
void ClearObjectPtrs (C4Object *tptr)
 
void ObjectRemovalCheck ()
 
bool ToggleDebugMode ()
 
bool ActivateMenu (const char *szCommand)
 

Detailed Description

Definition at line 32 of file C4Game.h.

Member Enumeration Documentation

◆ InitMode

Enumerator
IM_Normal 
IM_Section 
IM_ReInit 

Definition at line 36 of file C4Game.h.

37  {
38  IM_Normal = 0,
39  IM_Section = 1,
40  IM_ReInit = 2
41  };

Constructor & Destructor Documentation

◆ C4Game()

C4Game::C4Game ( )

Definition at line 97 of file C4Game.cpp.

References Default().

97  :
98  ScenarioParameterDefs(GameScenarioParameterDefs),
99  Parameters(GameParameters),
100  StartupScenarioParameters(GameStartupScenarioParameters),
105  RoundResults(GameRoundResults),
109  GlobalSoundModifier(GameGlobalSoundModifier)
110 {
111  Default();
112 }
C4PlayerInfoList & RestorePlayerInfos
Definition: C4Game.h:72
C4Value & GlobalSoundModifier
Definition: C4Game.h:99
C4ClientList Clients
class C4ScenarioParameterDefs & ScenarioParameterDefs
Definition: C4Game.h:75
C4GameParameters & Parameters
Definition: C4Game.h:67
C4TeamList & Teams
Definition: C4Game.h:70
C4GameControl Control
C4KeyboardInput & KeyboardInput
Definition: C4Game.h:96
C4Control Input
Definition: C4GameControl.h:66
void Default()
Definition: C4Game.cpp:1444
C4RoundResults & RoundResults
Definition: C4Game.h:73
C4PlayerInfoList RestorePlayerInfos
C4KeyboardInput & C4KeyboardInput_Init()
C4Control & Input
Definition: C4Game.h:82
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:71
class C4ScenarioParameters & StartupScenarioParameters
Definition: C4Game.h:68
C4PlayerInfoList PlayerInfos
C4ClientList & Clients
Definition: C4Game.h:69
std::unique_ptr< C4GameSec1Timer > pSec1Timer
Definition: C4Game.h:98
Here is the call graph for this function:

◆ ~C4Game()

C4Game::~C4Game ( )

Definition at line 114 of file C4Game.cpp.

References C4Startup::Unload().

115 {
116  // make sure no startup gfx remain loaded
118 }
static void Unload()
Definition: C4Startup.cpp:301
Here is the call graph for this function:

Member Function Documentation

◆ Abort()

void C4Game::Abort ( bool  fApproved = false)

Definition at line 3667 of file C4Game.cpp.

References Application, C4GameControl::ClientID(), Control, Evaluate(), EvaluateOnAbort, Game, GameOver, C4PlayerList::GetLocalByIndex(), C4GameControl::isCtrlHost(), C4Network2::isEnabled(), C4GameParameters::isLeague(), Network, Parameters, Players, C4Application::QuitGame(), C4PlayerList::RemoveAtRemoteClient(), C4PlayerList::RemoveLocal(), C4Network2::Vote(), VT_Cancel, and VT_Kick.

Referenced by C4VoteDialog::C4VoteDialog(), C4ControlVote::getDescWarning(), and C4AbortGameDialog::OnClosed().

3668 {
3669  // league needs approval
3670  if (Network.isEnabled() && Parameters.isLeague() && !fApproved)
3671  {
3672  if (Control.isCtrlHost() && !Game.GameOver)
3673  {
3675  return;
3676  }
3678  {
3679  Network.Vote(VT_Kick, true, Control.ClientID());
3680  return;
3681  }
3682  }
3683  if (EvaluateOnAbort)
3684  {
3685  // Scenario forces evaluation. This is intended for scenarios that
3686  // always save progress in the players, such as Tower of Despair.
3687  Evaluate();
3688  }
3689  // hard-abort: eval league and quit
3690  // manually evaluate league
3691  Players.RemoveLocal(true, true);
3692  Players.RemoveAtRemoteClient(true, true);
3693  // normal quit
3695 }
C4Player * GetLocalByIndex(int iIndex) const
C4Game Game
Definition: C4Globals.cpp:52
bool isCtrlHost() const
Definition: C4GameControl.h:99
bool RemoveAtRemoteClient(bool fDisonnected, bool fNoCalls)
bool isEnabled() const
Definition: C4Network2.h:203
bool EvaluateOnAbort
Definition: C4Game.h:115
void Vote(C4ControlVoteType eType, bool fApprove=true, int32_t iData=0)
bool RemoveLocal(bool fDisonnected, bool fNoCalls)
C4GameParameters & Parameters
Definition: C4Game.h:67
int32_t ClientID() const
C4Network2 Network
Definition: C4Globals.cpp:53
bool GameOver
Definition: C4Game.h:114
C4GameControl Control
bool isLeague() const
C4PlayerList Players
C4Application Application
Definition: C4Globals.cpp:44
void Evaluate()
Definition: C4Game.cpp:1504
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ActivateMenu()

bool C4Game::ActivateMenu ( const char *  szCommand)
protected

Definition at line 3650 of file C4Game.cpp.

References C4MainMenu::ActivateCommand(), C4PlayerList::GetLocalByIndex(), C4GameOverDlg::IsShown(), C4Player::Menu, C4Player::Number, and Players.

3651 {
3652  // no new menu during round evaluation
3653  if (C4GameOverDlg::IsShown()) return false;
3654  // forward to primary player
3656  if (!pPlr) return false;
3657  pPlr->Menu.ActivateCommand(pPlr->Number, szCommand);
3658  return true;
3659 }
C4Player * GetLocalByIndex(int iIndex) const
C4MainMenu Menu
Definition: C4Player.h:103
int32_t Number
Definition: C4Player.h:86
bool ActivateCommand(int32_t iPlayer, const char *szCommand)
Definition: C4MainMenu.cpp:865
static bool IsShown()
Definition: C4GameOverDlg.h:92
C4PlayerList Players
Here is the call graph for this function:

◆ AllocateTranslatedString()

C4PropList * C4Game::AllocateTranslatedString ( )

Definition at line 3970 of file C4Game.cpp.

References C4VString(), C4StringTable::P, P_Function, P_Translate, C4PropList::SetProperty(), and Strings.

3971 {
3972  C4PropListScript *value_proplist = new C4PropListScript();
3973  value_proplist->SetProperty(P_Function, C4VString(&::Strings.P[P_Translate]));
3974  return value_proplist;
3975 }
C4String P[P_LAST]
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:120
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246
Here is the call graph for this function:

◆ CanQuickSave()

bool C4Game::CanQuickSave ( )

Definition at line 1931 of file C4Game.cpp.

References C4Network2::isEnabled(), C4Network2::isHost(), LoadResStr(), Log(), and Network.

Referenced by C4MainMenu::ActivateSavegame(), HasScenario(), and QuickSave().

1932 {
1933  // Network hosts only
1934  if (Network.isEnabled() && !Network.isHost())
1935  { Log(LoadResStr("IDS_GAME_NOCLIENTSAVE")); return false; }
1936 
1937  return true;
1938 }
bool isEnabled() const
Definition: C4Network2.h:203
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
bool isHost() const
Definition: C4Network2.h:209
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CastObjects()

void C4Game::CastObjects ( C4ID  id,
C4Object pCreator,
int32_t  num,
int32_t  level,
int32_t  tx,
int32_t  ty,
int32_t  iOwner = NO_OWNER,
int32_t  iController = NO_OWNER,
C4ValueArray out_objects = nullptr 
)

Definition at line 1411 of file C4Game.cpp.

References C4REAL10(), C4VObj(), CreateObject(), C4ValueArray::GetSize(), itofix(), Random(), C4ValueArray::SetSize(), and C4PropList::Status.

Referenced by C4Landscape::P::BlastMaterial2Objects(), and HasScenario().

1412 {
1413  int32_t cnt, out_obj_size=0;
1414  if (out_objects)
1415  {
1416  out_obj_size = out_objects->GetSize();
1417  out_objects->SetSize(out_obj_size + num);
1418  }
1419  for (cnt=0; cnt<num; cnt++)
1420  {
1421  // Must do these calculation steps separately, because the order of
1422  // invokations of Random() is not defined if they're used as parameters
1423  int32_t angle = Random(360);
1424  C4Real xdir = C4REAL10(Random(2*level+1)-level);
1425  C4Real ydir = C4REAL10(Random(2*level+1)-level);
1426  C4Real rdir = itofix(Random(3)+1);
1427  C4Object *obj = CreateObject(id,pCreator,iOwner,
1428  tx,ty,angle,
1429  false,
1430  xdir,
1431  ydir,
1432  rdir, iController);
1433  if (obj && obj->Status && out_objects) (*out_objects)[out_obj_size+cnt] = C4VObj(obj);
1434  }
1435 }
uint32_t Random()
Definition: C4Random.cpp:43
C4Value C4VObj(C4Object *pObj)
Definition: C4Value.cpp:88
Definition: C4Real.h:58
C4Real C4REAL10(int x)
Definition: C4Real.h:269
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
void SetSize(int32_t inSize)
int32_t Status
Definition: C4PropList.h:168
int32_t GetSize() const
Definition: C4ValueArray.h:36
C4Object * CreateObject(C4PropList *type, C4Object *pCreator, int32_t owner=NO_OWNER, int32_t x=50, int32_t y=50, int32_t r=0, bool grow_from_center=false, C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t iController=NO_OWNER)
Definition: C4Game.cpp:1072
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckObjectEnumeration()

bool C4Game::CheckObjectEnumeration ( )
protected

Definition at line 3298 of file C4Game.cpp.

References FormatString(), C4PropList::GetName(), C4Object::GetX(), C4Object::id, LogFatal(), C4PropListNumbered::Number, Objects, C4PropListNumbered::SetEnumerationIndex(), and C4ID::ToString().

3299 {
3300 
3301  struct Check
3302  {
3303  int32_t maxNumber{0};
3304  Check() = default;
3305  // Check valid & maximum number & duplicate numbers
3306  bool that(C4Object* cObj)
3307  {
3308  // Invalid number
3309  if (cObj->Number<1)
3310  {
3311  LogFatal(FormatString("Invalid object enumeration number (%d) of object %s (x=%d)", cObj->Number, cObj->id.ToString(), cObj->GetX()).getData()); return false;
3312  }
3313  // Max
3314  if (cObj->Number>maxNumber) maxNumber=cObj->Number;
3315  // Duplicate
3316  for (C4Object *cObj2 : Objects)
3317  if (cObj2!=cObj)
3318  if (cObj->Number==cObj2->Number)
3319  { LogFatal(FormatString("Duplicate object enumeration number %d (%s and %s)",cObj2->Number,cObj->GetName(),cObj2->GetName()).getData()); return false; }
3320  for (C4Object *cObj2 : Objects.InactiveObjects)
3321  if (cObj2!=cObj)
3322  if (cObj->Number==cObj2->Number)
3323  { LogFatal(FormatString("Duplicate object enumeration number %d (%s and %s(i))",cObj2->Number,cObj->GetName(),cObj2->GetName()).getData()); return false; }
3324  return true;
3325  }
3326  };
3327 
3328  Check check;
3329  for (C4Object *cObj : Objects)
3330  {
3331  if (!check.that(cObj))
3332  return false;
3333  }
3334 
3335  for (C4Object *cObj : Objects.InactiveObjects)
3336  {
3337  if (!check.that(cObj))
3338  return false;
3339  }
3340 
3341  // Adjust enumeration index
3342  C4PropListNumbered::SetEnumerationIndex(check.maxNumber);
3343  // Done
3344  return true;
3345 }
int32_t GetX() const
Definition: C4Object.h:287
const char * ToString() const
Definition: C4Id.h:59
C4ID id
Definition: C4Object.h:108
static void SetEnumerationIndex(int32_t iMaxObjectNumber)
Definition: C4PropList.cpp:93
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:237
virtual const char * GetName() const
Definition: C4PropList.cpp:649
C4GameObjects Objects
Definition: C4Globals.cpp:48
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
Here is the call graph for this function:

◆ Clear()

void C4Game::Clear ( )

Definition at line 537 of file C4Game.cpp.

References C4AulProfiler::Abort(), Application, C4S, C4ST_SHOWSTAT, C4ComponentHost::Clear(), C4PlayerList::Clear(), C4Weather::Clear(), C4PathFinder::Clear(), C4DefList::Clear(), C4SoundSystem::Clear(), C4GraphicsSystem::Clear(), C4PXSSystem::Clear(), C4TransferZones::Clear(), C4Landscape::Clear(), C4FontLoader::Clear(), C4Scoreboard::Clear(), C4EditCursor::Clear(), C4ScenarioParameterDefs::Clear(), C4GroupSet::Clear(), C4TextureMap::Clear(), C4GameMessageList::Clear(), C4ScenarioParameters::Clear(), C4MessageInput::Clear(), C4PlayerControlDefs::Clear(), C4GameControl::Clear(), C4SoundModifierList::Clear(), C4MouseControl::Clear(), C4AulScriptEngine::Clear(), C4GameParameters::Clear(), C4RoundResults::Clear(), C4GameScriptHost::Clear(), C4MaterialMap::Clear(), C4Scenario::Clear(), C4Network2::Clear(), C4PlayerControlAssignmentSets::Clear(), C4MapScriptHost::Clear(), StdStrBuf::Clear(), C4ParticleSystem::Clear(), C4KeyboardInput::Clear(), StdMeshMatManager::Clear(), C4GUI::Screen::Clear(), C4MusicSystem::ClearGame(), C4PropListNumbered::ClearNumberedPropLists(), C4PropListScript::ClearScriptPropLists(), C4PropListNumbered::ClearShelve(), C4Console::CloseGame(), C4FullScreen::CloseMenu(), CloseScenario(), Console, Control, Default(), DefinitionFilenames, Definitions, DeleteObjects(), DirectJoinAddress, C4Console::EditCursor, Evaluate(), Evaluated, C4MusicSystem::FadeOut(), FontLoader, fPreinited, FullScreen, GameOver, GameScript, GameText, GetLogPos(), GraphicsSystem, GroupSet, C4Language::HasStringTable(), Info, IsRunning, KeyboardInput, Landscape, Languages, LoadResStr(), Log(), MainSysLangStringTable, MapScript, MaterialMap, MeshMaterialManager, MessageInput, Messages, C4SoundSystem::Modifiers, MouseControl, C4Application::MusicSystem, Names, Network, NextMission, NextMissionDesc, NextMissionText, Parameters, Particles, PathFinder, pFileMonitor, pGUI, pJoinReference, PlayerControlDefaultAssignmentSets, PlayerControlDefs, PlayerControlUserAssignmentSets, PlayerFilenames, Players, pNetworkStatistics, PointersDenumerated, pScenarioObjectsScript, PXS, QuitLogPos, RecordDumpFile, RecordStream, C4PropListNumbered::ResetEnumerationIndex(), RoundResults, ScenarioFilename, ScenarioLangStringTable, ScenarioParameterDefs, Scoreboard, ScriptEngine, ScriptGuiRoot, SetGlobalSoundModifier(), C4Application::SoundSystem, StartupScenarioParameters, TextureMap, Title, TransferZones, and Weather.

Referenced by C4Application::Clear(), and C4Application::GameTick().

538 {
539  pFileMonitor.reset();
540  // fade out music
542  // game no longer running
543  IsRunning = false;
544  PointersDenumerated = false;
545 
547  // C4ST_RESET
548 
549  // Evaluation
550  if (GameOver)
551  {
552  if (!Evaluated) Evaluate();
553  }
554 
555  // stop statistics
556  pNetworkStatistics.reset();
558 
559  // next mission (shoud have been transferred to C4Application now if next mission was desired)
561 
562  // Clear control
563  Network.Clear();
564  Control.Clear();
570 
571  // Clear game info
572  Scoreboard.Clear();
573  Players.Clear();
574  Parameters.Clear();
576  C4S.Clear();
579  Info.Clear();
580  Title.Clear();
581  Names.Clear();
582  GameText.Clear();
585 
586 #ifdef WITH_QT_EDITOR
587  // clear console pointers held into script engine
589  ::Console.ClearGamePointers();
590 #endif
591  // notify editor
592  Console.CloseGame();
593 
594  // Clear the particles before cleaning up the objects.
595  Particles.Clear();
596  DeleteObjects(true);
597 
598  // exit gui
599  pGUI->Clear();
600  ScriptGuiRoot.reset();
601 
602  // Clear landscape
603  Weather.Clear();
604  Landscape.Clear();
605  PXS.Clear();
607  TextureMap.Clear(); // texture map *MUST* be cleared after the materials, because of the patterns!
608  PathFinder.Clear();
610 
611  ::Messages.Clear();
613  SetGlobalSoundModifier(nullptr); // must be called before script engine clear
614  Application.SoundSystem.Modifiers.Clear(); // free some prop list pointers
615 
616  // Clear script engine
617  ::MapScript.Clear();
620  C4PropListNumbered::ClearShelve(); // may be nonempty if there was a fatal error during section load
622  pScenarioObjectsScript = nullptr;
623  // delete any remaining prop lists from circular chains
626 
627  // Clear translation tables
630 
631  // Cleanup remaining open scenario files
632  CloseScenario();
633  GroupSet.Clear();
635  Application.SoundSystem.Clear(); // will be re-inited by application pre-init if running from startup system
636 
637  // Clear remaining graphics
638 #ifndef USE_CONSOLE
640 #endif
643 
644  // global fullscreen class is not cleared, because it holds the carrier window
645  // but the menu must be cleared (maybe move Fullscreen.Menu somewhere else?)
647 
648  // Message
649  // avoid double message by not printing it if no restbl is loaded
650  // this would log an "[Undefined]" only, anyway
651  // (could abort the whole clear-procedure here, btw?)
652  if (::Languages.HasStringTable()) Log(LoadResStr("IDS_CNS_GAMECLOSED"));
653 
654  // clear game starting parameters
656 
657  // join reference
658  pJoinReference.reset();
659 
660  // okay, game cleared now. Remember log section
661  QuitLogPos = GetLogPos();
662 
663  fPreinited = false;
665 
666  // FIXME: remove this
667  Default();
668 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
C4EditCursor EditCursor
Definition: C4Console.h:90
bool IsRunning
Definition: C4Game.h:140
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:102
std::unique_ptr< C4Network2Reference > pJoinReference
Definition: C4Game.h:108
StdStrBuf RecordDumpFile
Definition: C4Game.h:125
StdCopyStrBuf NextMission
Definition: C4Game.h:147
C4Console Console
Definition: C4Globals.cpp:45
C4GameScriptHost GameScript
C4LangStringTable MainSysLangStringTable
Definition: C4Game.h:80
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4Scenario C4S
Definition: C4Game.h:74
C4GroupSet GroupSet
Definition: C4Game.h:87
void Clear()
Definition: StdBuf.h:466
C4ParticleSystem Particles
static void ResetEnumerationIndex()
Definition: C4PropList.cpp:99
void Clear()
Definition: C4Scenario.cpp:410
void Clear()
Definition: C4Texture.cpp:168
C4ComponentHost GameText
Definition: C4Game.h:79
static void ClearNumberedPropLists()
Definition: C4PropList.cpp:137
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
C4MessageInput MessageInput
class C4ScenarioObjectsScriptHost * pScenarioObjectsScript
Definition: C4Game.h:90
C4Scoreboard Scoreboard
Definition: C4Game.h:94
class C4ScenarioParameterDefs & ScenarioParameterDefs
Definition: C4Game.h:75
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
C4ComponentHost Names
Definition: C4Game.h:78
C4GameParameters & Parameters
Definition: C4Game.h:67
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
StdCopyStrBuf NextMissionDesc
Definition: C4Game.h:147
C4LangStringTable ScenarioLangStringTable
Definition: C4Game.h:80
C4MapScriptHost MapScript
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1191
std::unique_ptr< C4FileMonitor > pFileMonitor
Definition: C4Game.h:97
C4SoundModifierList Modifiers
Definition: C4SoundSystem.h:54
void Clear()
Definition: C4Gui.cpp:588
C4Network2 Network
Definition: C4Globals.cpp:53
void Clear()
Definition: C4PXS.cpp:163
bool fPreinited
Definition: C4Game.h:128
bool GameOver
Definition: C4Game.h:114
void Clear()
Definition: C4Weather.cpp:89
C4Language Languages
Definition: C4Language.cpp:42
static void ClearScriptPropLists()
Definition: C4PropList.cpp:207
C4GameControl Control
C4KeyboardInput & KeyboardInput
Definition: C4Game.h:96
C4Landscape Landscape
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
static void ClearShelve()
Definition: C4PropList.cpp:131
C4PlayerList Players
bool HasStringTable() const
Definition: C4Language.h:70
void Default()
Definition: C4Game.cpp:1444
C4TransferZones TransferZones
Definition: C4Game.h:85
StdCopyStrBuf NextMissionText
Definition: C4Game.h:147
void Clear()
Definition: C4Network2.cpp:711
void SetGlobalSoundModifier(C4PropList *modifier_props)
Definition: C4Game.cpp:3880
C4Weather Weather
Definition: C4Weather.cpp:206
C4PXSSystem PXS
Definition: C4PXS.cpp:423
void Clear()
Definition: C4Aul.cpp:85
void Clear()
C4PlayerControlDefs PlayerControlDefs
Definition: C4Game.h:92
size_t GetLogPos()
Definition: C4Log.cpp:296
C4RoundResults & RoundResults
Definition: C4Game.h:73
void FadeOut(int fadeout_ms)
void Clear()
Definition: C4GroupSet.cpp:50
size_t QuitLogPos
Definition: C4Game.h:142
bool PointersDenumerated
Definition: C4Game.h:141
char PlayerFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:104
bool Evaluated
Definition: C4Game.h:116
C4FontLoader FontLoader
class C4ScenarioParameters & StartupScenarioParameters
Definition: C4Game.h:68
C4PathFinder PathFinder
Definition: C4Game.h:84
#define C4ST_SHOWSTAT
Definition: C4Stat.h:154
void DeleteObjects(bool fDeleteInactive)
Definition: C4Game.cpp:1049
C4MaterialMap MaterialMap
Definition: C4Material.cpp:974
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
void Clear(bool fClearMapCreator=true, bool fClearSky=true, bool fClearRenderer=true)
StdStrBuf RecordStream
Definition: C4Game.h:126
char DefinitionFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:105
void CloseGame()
Definition: C4Console.cpp:609
C4ComponentHost Info
Definition: C4Game.h:76
C4DefList Definitions
Definition: C4Globals.cpp:49
C4GameMessageList Messages
std::unique_ptr< C4ScriptGuiWindow > ScriptGuiRoot
Definition: C4Game.h:234
char DirectJoinAddress[_MAX_PATH+1]
Definition: C4Game.h:106
std::unique_ptr< C4Network2Stats > pNetworkStatistics
Definition: C4Game.h:95
static void Abort()
Definition: C4AulExec.h:257
C4PlayerControlAssignmentSets PlayerControlDefaultAssignmentSets
Definition: C4Game.h:93
void CloseScenario()
Definition: C4Game.cpp:263
StdMeshMatManager MeshMaterialManager
C4PlayerControlAssignmentSets PlayerControlUserAssignmentSets
Definition: C4Game.h:93
C4Application Application
Definition: C4Globals.cpp:44
void Evaluate()
Definition: C4Game.cpp:1504
C4ComponentHost Title
Definition: C4Game.h:77
C4MusicSystem MusicSystem
Definition: C4Application.h:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearObjectPtrs()

void C4Game::ClearObjectPtrs ( C4Object tptr)
protected

Definition at line 905 of file C4Game.cpp.

References C4Object::ClearPointers(), and Objects.

Referenced by ClearPointers().

906 {
907  // May not call Objects.ClearPointers() because that would
908  // remove pObj from primary list and pObj is to be kept
909  // until CheckObjectRemoval().
910  for (C4Object *cObj : Objects)
911  {
912  cObj->ClearPointers(pObj);
913  }
914  // check in inactive objects as well
915  for (C4Object *cObj : Objects.InactiveObjects)
916  {
917  cObj->ClearPointers(pObj);
918  }
919 }
void ClearPointers(C4Object *ptr)
Definition: C4Object.cpp:1738
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearPointers()

void C4Game::ClearPointers ( C4Object cobj)

Definition at line 921 of file C4Game.cpp.

References Application, AulExec, ClearObjectPtrs(), C4PlayerList::ClearPointers(), C4SoundSystem::ClearPointers(), C4Console::ClearPointers(), C4TransferZones::ClearPointers(), C4AulExec::ClearPointers(), C4GameMessageList::ClearPointers(), C4Effect::ClearPointers(), C4MouseControl::ClearPointers(), C4ObjectList::ClearPointers(), C4MessageInput::ClearPointers(), C4ViewportList::ClearPointers(), C4Landscape::ClearPointers(), Console, C4GameObjects::ForeObjects, GameScript, Landscape, MessageInput, Messages, MouseControl, Objects, C4AulScriptEngine::pGlobalEffects, Players, C4GameScriptHost::pScenarioEffects, ScriptEngine, ScriptGuiRoot, C4Application::SoundSystem, TransferZones, and Viewports.

Referenced by C4Object::AssignRemoval(), C4ObjectList::DeleteObjects(), HasScenario(), LoadScenarioSection(), C4GameObjects::ResortUnsorted(), and C4Object::StatusDeactivate().

922 {
923  ::AulExec.ClearPointers(pObj);
926  ClearObjectPtrs(pObj);
928  ::Players.ClearPointers(pObj);
931  ::Console.ClearPointers(pObj);
933  ScriptGuiRoot->ClearPointers(pObj);
940 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
void ClearPointers(C4Object *pObj)
void ClearPointers(C4Object *pObj)
C4Console Console
Definition: C4Globals.cpp:45
C4GameScriptHost GameScript
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
void ClearPointers(C4Object *pObj)
C4MessageInput MessageInput
C4AulExec AulExec
Definition: C4AulExec.cpp:29
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
C4Landscape Landscape
C4PlayerList Players
C4TransferZones TransferZones
Definition: C4Game.h:85
void ClearPointers(C4Object *pObj)
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
C4ObjectList ForeObjects
Definition: C4GameObjects.h:44
void ClearPointers(C4Object *pObj)
Definition: C4Console.cpp:405
C4Effect * pScenarioEffects
Definition: C4ScriptHost.h:165
void ClearPointers(C4Object *pObj)
Definition: C4Viewport.cpp:956
int ClearPointers(C4Object *pObj)
void ClearPointers(C4Object *pObj)
void ClearPointers(C4Object *)
Definition: C4AulExec.cpp:136
C4GameMessageList Messages
std::unique_ptr< C4ScriptGuiWindow > ScriptGuiRoot
Definition: C4Game.h:234
void ClearObjectPtrs(C4Object *tptr)
Definition: C4Game.cpp:905
void ClearPointers(C4Object *pObj)
void ClearPointers(C4PropList *pObj)
Definition: C4Effect.cpp:191
void ClearPointers(C4Object *pObj)
C4Application Application
Definition: C4Globals.cpp:44
C4Effect * pGlobalEffects
Definition: C4Aul.h:144
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloseScenario()

void C4Game::CloseScenario ( )
protected

Definition at line 263 of file C4Game.cpp.

References StdStrBuf::Clear(), C4Group::Close(), C4GroupSet::CloseFolders(), EraseItem(), StdStrBuf::getData(), GroupSet, pCurrentScenarioSection, pParentGroup, pScenarioSections, ScenarioFile, and TempScenarioFile.

Referenced by Clear().

264 {
265  // close scenario
268  pParentGroup = nullptr;
269  // remove if temporary
270  if (TempScenarioFile)
271  {
274  }
275  // clear scenario section
276  // this removes any temp files, which may yet need to be used by any future features
277  // so better don't do this too early (like, in C4Game::Clear)
279 }
C4Group * pParentGroup
Definition: C4Game.h:88
StdStrBuf TempScenarioFile
Definition: C4Game.h:127
void Clear()
Definition: StdBuf.h:466
C4GroupSet GroupSet
Definition: C4Game.h:87
C4Group ScenarioFile
Definition: C4Game.h:86
C4ScenarioSection * pScenarioSections
Definition: C4Game.h:91
bool Close()
Definition: C4Group.cpp:755
const char * getData() const
Definition: StdBuf.h:442
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:809
bool CloseFolders()
Definition: C4GroupSet.cpp:235
C4ScenarioSection * pCurrentScenarioSection
Definition: C4Game.h:91
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompileFunc()

void C4Game::CompileFunc ( StdCompiler pComp,
CompileSettings  comp,
C4ValueNumbers numbers 
)

Definition at line 1661 of file C4Game.cpp.

References C4Value::_getInt(), Application, C4SyncCheckRate, C4V_Enum, C4VNull, Control, C4GameControl::ControlTick, CurrentScenarioSection, C4PropListNumbered::EnumerationIndex, C4PlayerList::First, FormatString(), FrameCounter, fResortAnyObject, StdStrBuf::getData(), C4Landscape::GetSky(), C4Value::GetType(), GlobalSoundModifier, IM_Normal, IM_Section, InitialPlayersJoined, StdCompiler::isDeserializer(), StdCompiler::isSerializer(), iTick10, iTick1000, iTick2, iTick255, iTick3, iTick35, iTick5, Landscape, mkNamingAdapt(), mkParAdapt(), mkStringAdaptMA, C4Application::MusicSystem, StdCompiler::Name(), StdCompiler::NameEnd(), C4Player::Next, NextMission, NextMissionDesc, NextMissionText, Objects, Players, Scoreboard, ScriptEngine, ScriptGuiRoot, C4PropListNumbered::ShelveNumberedPropLists(), StartupPlayerCount, StartupTeamCount, C4GameControl::SyncRate, Time, StdCompiler::Value(), and Weather.

1662 {
1663  if (comp.init_mode == IM_Normal && comp.fExact)
1664  {
1665  pComp->Name("Game");
1666  pComp->Value(mkNamingAdapt(Time, "Time", 0));
1667  pComp->Value(mkNamingAdapt(FrameCounter, "Frame", 0));
1668  if (comp.fSync)
1669  {
1670  pComp->Value(mkNamingAdapt(Control.ControlTick, "ControlTick", 0));
1671  pComp->Value(mkNamingAdapt(Control.SyncRate, "SyncRate", C4SyncCheckRate));
1672  }
1673  pComp->Value(mkNamingAdapt(iTick2, "Tick2", 0));
1674  pComp->Value(mkNamingAdapt(iTick3, "Tick3", 0));
1675  pComp->Value(mkNamingAdapt(iTick5, "Tick5", 0));
1676  pComp->Value(mkNamingAdapt(iTick10, "Tick10", 0));
1677  pComp->Value(mkNamingAdapt(iTick35, "Tick35", 0));
1678  pComp->Value(mkNamingAdapt(iTick255, "Tick255", 0));
1679  pComp->Value(mkNamingAdapt(iTick1000, "Tick1000", 0));
1680  pComp->Value(mkNamingAdapt(InitialPlayersJoined, "InitialPlayersJoined", false));
1681  pComp->Value(mkNamingAdapt(StartupPlayerCount, "StartupPlayerCount", 0));
1682  pComp->Value(mkNamingAdapt(StartupTeamCount, "StartupTeamCount", 0));
1683  pComp->Value(mkNamingAdapt(C4PropListNumbered::EnumerationIndex,"ObjectEnumerationIndex",0));
1684  pComp->Value(mkNamingAdapt(mkStringAdaptMA(CurrentScenarioSection), "CurrentScenarioSection", ""));
1685  pComp->Value(mkNamingAdapt(fResortAnyObject, "ResortAnyObj", false));
1686  pComp->Value(mkNamingAdapt(mkParAdapt(GlobalSoundModifier, numbers), "GlobalSoundModifier", C4Value()));
1687  pComp->Value(mkNamingAdapt(NextMission, "NextMission", StdCopyStrBuf()));
1688  pComp->Value(mkNamingAdapt(NextMissionText, "NextMissionText", StdCopyStrBuf()));
1689  pComp->Value(mkNamingAdapt(NextMissionDesc, "NextMissionDesc", StdCopyStrBuf()));
1690  pComp->NameEnd();
1691 
1692  // Music settings
1693  pComp->Value(mkNamingAdapt(::Application.MusicSystem, "Music"));
1694 
1695  // scoreboard compiles into main level [Scoreboard]
1696  pComp->Value(mkNamingAdapt(Scoreboard, "Scoreboard"));
1697  // Keyboard status of global keys synchronized for exact (runtime join) only; not for savegames,
1698  // as keys might be released between a savegame save and its resume
1699  }
1700 
1701  if (comp.fExact)
1702  {
1703  pComp->Value(mkNamingAdapt(Weather, "Weather"));
1704  pComp->Value(mkNamingAdapt(Landscape, "Landscape"));
1705  pComp->Value(mkNamingAdapt(Landscape.GetSky(), "Sky"));
1706 
1707  // save custom GUIs only if a real savegame and not for editor-scenario-saves or section changes
1708  if (comp.init_mode == IM_Normal)
1709  {
1710  pComp->Name("GUI");
1711  if (pComp->isDeserializer())
1712  {
1713  C4Value val;
1714  pComp->Value(mkNamingAdapt(mkParAdapt(val, numbers), "ScriptGUIs", C4VNull));
1715  // if loading, assume
1716  assert(ScriptGuiRoot->GetID() == 0); // ID of 0 means "had no subwindows ever" aka "is fresh" for root
1717  // we will need to denumerate and create the actual GUI post-loading
1718  // for now, just remember our enumerated ID
1719  if (val.GetType() == C4V_Enum)
1720  {
1721  int enumID = val._getInt();
1722  ScriptGuiRoot->SetEnumeratedID(enumID);
1723  }
1724  }
1725  else
1726  {
1727  C4Value *val = new C4Value(ScriptGuiRoot->ToC4Value());
1728  pComp->Value(mkNamingAdapt(mkParAdapt(*val, numbers), "ScriptGUIs", C4VNull));
1729  }
1730  pComp->NameEnd();
1731  }
1732  }
1733 
1734  if (comp.fPlayers)
1735  {
1736  assert(pComp->isSerializer());
1737  // player parsing: Parse all players
1738  // This doesn't create any players, but just parses existing by their ID
1739  // Primary player ininitialization (also setting ID) is done by player info list
1740  // Won't work this way for binary mode!
1741  for (C4Player *pPlr=Players.First; pPlr; pPlr=pPlr->Next)
1742  pComp->Value(mkNamingAdapt(mkParAdapt(*pPlr, numbers), FormatString("Player%d", pPlr->ID).getData()));
1743  }
1744 
1745  // Section load: Clear existing prop list numbering to make room for the new objects
1746  // Numbers will be re-acquired in C4GameObjects::PostLoad
1748 
1749  pComp->Value(mkParAdapt(Objects, !comp.fExact, numbers));
1750 
1751  pComp->Value(mkNamingAdapt(mkParAdapt(ScriptEngine, comp.init_mode == IM_Section, numbers), "Script"));
1752 }
int32_t iTick255
Definition: C4Game.h:130
int32_t ControlTick
Definition: C4GameControl.h:89
C4Value & GlobalSoundModifier
Definition: C4Game.h:99
StdCopyStrBuf NextMission
Definition: C4Game.h:147
int32_t iTick5
Definition: C4Game.h:130
int32_t iTick35
Definition: C4Game.h:130
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
const int32_t C4SyncCheckRate
Definition: C4GameControl.h:53
C4Player * First
Definition: C4PlayerList.h:31
virtual bool Name(const char *szName)
Definition: StdCompiler.h:77
C4Scoreboard Scoreboard
Definition: C4Game.h:94
C4V_Type GetType() const
Definition: C4Value.h:161
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
StdCopyStrBuf NextMissionDesc
Definition: C4Game.h:147
bool isSerializer()
Definition: StdCompiler.h:54
int32_t FrameCounter
Definition: C4Game.h:129
int32_t iTick1000
Definition: C4Game.h:130
C4GameControl Control
C4Landscape Landscape
C4PlayerList Players
bool InitialPlayersJoined
Definition: C4Game.h:113
int32_t Time
Definition: C4Game.h:132
class C4Sky & GetSky()
StdCopyStrBuf NextMissionText
Definition: C4Game.h:147
C4Weather Weather
Definition: C4Weather.cpp:206
int32_t iTick3
Definition: C4Game.h:130
void Value(const T &rStruct)
Definition: StdCompiler.h:161
static void ShelveNumberedPropLists()
Definition: C4PropList.cpp:105
int32_t _getInt() const
Definition: C4Value.h:122
int32_t iTick10
Definition: C4Game.h:130
const char * getData() const
Definition: StdBuf.h:442
virtual bool isDeserializer()
Definition: StdCompiler.h:53
bool fResortAnyObject
Definition: C4Game.h:139
const C4Value C4VNull
Definition: C4Value.cpp:30
int32_t StartupPlayerCount
Definition: C4Game.h:109
C4Player * Next
Definition: C4Player.h:142
#define mkStringAdaptMA(szString)
Definition: StdAdaptors.h:190
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:476
int32_t SyncRate
Definition: C4GameControl.h:90
int32_t StartupTeamCount
Definition: C4Game.h:110
std::unique_ptr< C4ScriptGuiWindow > ScriptGuiRoot
Definition: C4Game.h:234
static int32_t EnumerationIndex
Definition: C4PropList.h:238
char CurrentScenarioSection[C4MaxName+1]
Definition: C4Game.h:101
virtual void NameEnd(bool fBreak=false)
Definition: StdCompiler.h:78
C4Application Application
Definition: C4Globals.cpp:44
C4GameObjects Objects
Definition: C4Globals.cpp:48
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
int32_t iTick2
Definition: C4Game.h:130
C4MusicSystem MusicSystem
Definition: C4Application.h:41
Here is the call graph for this function:

◆ CompileRuntimeData()

bool C4Game::CompileRuntimeData ( C4Group hGroup,
InitMode  init_mode,
bool  exact,
bool  sync,
C4ValueNumbers numbers 
)
protected

Definition at line 1754 of file C4Game.cpp.

References C4CFN_Game, C4GameObjects::Clear(), GameText, C4ComponentHost::GetData(), C4ComponentHost::GetDataBuf(), IM_Section, C4ComponentHost::Load(), LoadResStr(), LogF(), mkParAdapt(), C4ObjectList::ObjectCount(), and Objects.

1755 {
1756  ::Objects.Clear(init_mode != IM_Section);
1757  GameText.Load(hGroup,C4CFN_Game);
1758  CompileSettings Settings(init_mode, false, exact, sync);
1759  // C4Game is not defaulted on compilation.
1760  // Loading of runtime data overrides only certain values.
1761  // Doesn't compile players; those will be done later
1762  if (GameText.GetData())
1763  {
1764  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(
1765  mkParAdapt(*this, Settings, numbers),
1767  return false;
1768  // Objects
1769  int32_t iObjects = Objects.ObjectCount();
1770  if (iObjects) { LogF(LoadResStr("IDS_PRC_OBJECTSLOADED"),iObjects); }
1771  }
1772  // Success
1773  return true;
1774 }
const char * GetData() const
bool Load(C4Group &hGroup, const char *szFilename, const char *szLanguage=nullptr)
C4ComponentHost GameText
Definition: C4Game.h:79
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
#define C4CFN_Game
Definition: C4Components.h:73
int ObjectCount(C4ID id=C4ID::None) const
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:476
const StdStrBuf & GetDataBuf() const
void Clear(bool fClearInactive)
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:260
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:

◆ CreateInfoObject()

C4Object * C4Game::CreateInfoObject ( C4ObjectInfo cinf,
int32_t  owner,
int32_t  tx = 50,
int32_t  ty = 50 
)

Definition at line 1086 of file C4Game.cpp.

References C4Id2Def(), Fix0, FullCon, C4ObjectInfoCore::id, NewObject(), and NO_OWNER.

Referenced by HasScenario(), and C4Player::PlaceReadyCrew().

1088 {
1089  C4Def *def;
1090  // Valid check
1091  if (!cinf) return nullptr;
1092  // Get def
1093  if (!(def=C4Id2Def(cinf->id))) return nullptr;
1094  // Create object
1095  return NewObject( def,nullptr,
1096  iOwner,cinf,
1097  tx,ty,0,
1098  Fix0,Fix0,Fix0,
1099  FullCon, NO_OWNER, false);
1100 }
C4Object * NewObject(C4PropList *ndef, C4Object *pCreator, int32_t owner, C4ObjectInfo *info, int32_t tx, int32_t ty, int32_t tr, C4Real xdir, C4Real ydir, C4Real rdir, int32_t con, int32_t iController, bool grow_from_center)
Definition: C4Game.cpp:1011
const int32_t FullCon
Definition: C4Constants.h:181
Definition: C4Def.h:98
const int NO_OWNER
Definition: C4Constants.h:137
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
const C4Real Fix0
Definition: C4Real.h:312
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateObject() [1/2]

C4Object * C4Game::CreateObject ( C4PropList type,
C4Object pCreator,
int32_t  owner = NO_OWNER,
int32_t  x = 50,
int32_t  y = 50,
int32_t  r = 0,
bool  grow_from_center = false,
C4Real  xdir = Fix0,
C4Real  ydir = Fix0,
C4Real  rdir = Fix0,
int32_t  iController = NO_OWNER 
)

Definition at line 1072 of file C4Game.cpp.

References FullCon, C4PropList::GetDef(), and NewObject().

Referenced by CastObjects(), C4Object::CreateContents(), C4Landscape::P::DigMaterial2Objects(), HasScenario(), InitEnvironment(), InitGoals(), InitRules(), C4EditCursor::PerformDuplicationLegacy(), PlaceAnimal(), PlaceInEarth(), C4Player::PlaceReadyMaterial(), C4Player::PlaceReadyVehic(), and C4ControlEMMoveObject::~C4ControlEMMoveObject().

1075 {
1076  // check Definition
1077  if (!PropList || !PropList->GetDef()) return nullptr;
1078  // Create object
1079  return NewObject(PropList,pCreator,
1080  iOwner,nullptr,
1081  x,y,r,
1082  xdir,ydir,rdir,
1083  FullCon, iController, grow_from_center);
1084 }
C4Object * NewObject(C4PropList *ndef, C4Object *pCreator, int32_t owner, C4ObjectInfo *info, int32_t tx, int32_t ty, int32_t tr, C4Real xdir, C4Real ydir, C4Real rdir, int32_t con, int32_t iController, bool grow_from_center)
Definition: C4Game.cpp:1011
const int32_t FullCon
Definition: C4Constants.h:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateObject() [2/2]

C4Object * C4Game::CreateObject ( C4ID  type,
C4Object pCreator,
int32_t  owner = NO_OWNER,
int32_t  x = 50,
int32_t  y = 50,
int32_t  r = 0,
bool  grow_from_center = false,
C4Real  xdir = Fix0,
C4Real  ydir = Fix0,
C4Real  rdir = Fix0,
int32_t  iController = NO_OWNER 
)

Definition at line 1057 of file C4Game.cpp.

References C4Id2Def(), FullCon, and NewObject().

1060 {
1061  C4Def *pDef;
1062  // Get pDef
1063  if (!(pDef=C4Id2Def(id))) return nullptr;
1064  // Create object
1065  return NewObject(pDef,pCreator,
1066  iOwner,nullptr,
1067  x,y,r,
1068  xdir,ydir,rdir,
1069  FullCon, iController, grow_from_center);
1070 }
C4Object * NewObject(C4PropList *ndef, C4Object *pCreator, int32_t owner, C4ObjectInfo *info, int32_t tx, int32_t ty, int32_t tr, C4Real xdir, C4Real ydir, C4Real rdir, int32_t con, int32_t iController, bool grow_from_center)
Definition: C4Game.cpp:1011
const int32_t FullCon
Definition: C4Constants.h:181
Definition: C4Def.h:98
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
Here is the call graph for this function:

◆ CreateObjectConstruction()

C4Object * C4Game::CreateObjectConstruction ( C4PropList type,
C4Object pCreator,
int32_t  owner,
int32_t  ctx = 0,
int32_t  bty = 0,
int32_t  con = 1,
bool  terrain = false 
)

Definition at line 1102 of file C4Game.cpp.

References C4Object::Controller, C4Landscape::DigFreeRect(), Fix0, C4PropList::GetDef(), C4Rect::Hgt, Landscape, NewObject(), NO_OWNER, C4Landscape::RaiseTerrain(), C4Def::Shape, and C4Rect::Wdt.

Referenced by HasScenario(), and C4Player::PlaceReadyBase().

1108 {
1109  C4Def *pDef;
1110  C4Object *pObj;
1111 
1112  // Get def
1113  if (!PropList) return nullptr;
1114  if (!(pDef=PropList->GetDef())) return nullptr;
1115 
1116  int32_t dx,dy,dwdt,dhgt;
1117  dwdt=pDef->Shape.Wdt; dhgt=pDef->Shape.Hgt;
1118  dx=iX-dwdt/2; dy=iBY-dhgt;
1119 
1120  // Terrain
1121  if (fTerrain)
1122  {
1123  // Clear site background (ignored for ultra-large structures)
1124  if (dwdt*dhgt<12000)
1125  Landscape.DigFreeRect(dx,dy,dwdt,dhgt);
1126  // Raise Terrain
1127  Landscape.RaiseTerrain(dx,dy+dhgt,dwdt);
1128  }
1129 
1130  // Create object
1131  if (!(pObj=NewObject(PropList,
1132  pCreator,
1133  iOwner,nullptr,
1134  iX,iBY,0,
1135  Fix0,Fix0,Fix0,
1136  iCon, pCreator ? pCreator->Controller : NO_OWNER, false))) return nullptr;
1137 
1138  return pObj;
1139 }
C4Object * NewObject(C4PropList *ndef, C4Object *pCreator, int32_t owner, C4ObjectInfo *info, int32_t tx, int32_t ty, int32_t tr, C4Real xdir, C4Real ydir, C4Real rdir, int32_t con, int32_t iController, bool grow_from_center)
Definition: C4Game.cpp:1011
void RaiseTerrain(int32_t tx, int32_t ty, int32_t wdt)
int32_t DigFreeRect(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, C4Object *by_object=nullptr, bool no_dig2objects=false, bool no_instability_check=false)
C4Def const * GetDef() const override
Definition: C4Def.h:214
int32_t Wdt
Definition: C4Rect.h:30
C4Shape Shape
Definition: C4Def.h:104
C4Landscape Landscape
Definition: C4Def.h:98
const int NO_OWNER
Definition: C4Constants.h:137
int32_t Hgt
Definition: C4Rect.h:30
int32_t Controller
Definition: C4Object.h:111
const C4Real Fix0
Definition: C4Real.h:312
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateSectionFromTempFile()

bool C4Game::CreateSectionFromTempFile ( const char *  section_name,
const char *  temp_filename 
)

Definition at line 3426 of file C4Game.cpp.

References StdStrBuf::getData(), C4ScenarioSection::name, pCurrentScenarioSection, C4ScenarioSection::pNext, C4ScenarioSection::pObjectScripts, pScenarioObjectsScript, pScenarioSections, ReLinkScriptEngine(), C4ScenarioSection::ScenarioLoad(), and SEqualNoCase().

Referenced by C4ControlReInitScenario::C4ControlReInitScenario(), and HasScenario().

3427 {
3428  // Remove existing (temp) section of same name
3429  C4ScenarioSection *existing_section = pScenarioSections, *prev = nullptr;
3430  while (existing_section) if (SEqualNoCase(existing_section->name.getData(), section_name)) break; else existing_section = (prev = existing_section)->pNext;
3431  bool deleted_current_section = false;
3432  if (existing_section)
3433  {
3434  deleted_current_section = (existing_section == pCurrentScenarioSection);
3435  if (deleted_current_section)
3436  {
3437  pCurrentScenarioSection = nullptr;
3438  pScenarioObjectsScript = nullptr;
3439  }
3440  if (existing_section->pObjectScripts)
3441  {
3442  delete existing_section->pObjectScripts;
3443  }
3444  if (prev) prev->pNext = existing_section->pNext; else pScenarioSections = existing_section->pNext;
3445  existing_section->pNext = nullptr;
3446  delete existing_section;
3447  }
3448  // Create new (temp) section
3449  C4ScenarioSection *new_section = new C4ScenarioSection(section_name);
3450  if (!new_section->ScenarioLoad(temp_filename, true))
3451  {
3452  pScenarioSections = new_section->pNext;
3453  new_section->pNext = nullptr;
3454  delete new_section;
3455  return false;
3456  }
3457  // Re-Link current section into newly created section
3458  if (deleted_current_section)
3459  {
3460  pCurrentScenarioSection = new_section;
3461  pScenarioObjectsScript = new_section->pObjectScripts;
3462  }
3463  // Link new Objects.c (or re-link because old Objects.c was removed)
3465  return !!new_section;
3466 }
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:207
class C4ScenarioObjectsScriptHost * pScenarioObjectsScript
Definition: C4Game.h:90
bool ReLinkScriptEngine()
Definition: C4Game.cpp:2438
C4ScenarioSection * pScenarioSections
Definition: C4Game.h:91
bool ScenarioLoad(const char *szFilename, bool is_temp_file)
const char * getData() const
Definition: StdBuf.h:442
StdCopyStrBuf name
Definition: C4Scenario.h:260
class C4ScenarioObjectsScriptHost * pObjectScripts
Definition: C4Scenario.h:264
C4ScenarioSection * pNext
Definition: C4Scenario.h:266
C4ScenarioSection * pCurrentScenarioSection
Definition: C4Game.h:91
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Default()

void C4Game::Default ( )
protected

Definition at line 1444 of file C4Game.cpp.

References Application, C4S, cFPS, StdStrBuf::Clear(), C4MusicSystem::ClearGame(), CurrentScenarioSection, DebugHost, DebugPassword, DebugPort, DebugWait, C4GameObjects::Default(), C4PlayerList::Default(), C4Weather::Default(), C4PathFinder::Default(), C4DefList::Default(), C4RankSystem::Default(), C4GraphicsSystem::Default(), C4PXSSystem::Default(), C4TransferZones::Default(), C4MassMoverSet::Default(), C4Landscape::Default(), C4GroupSet::Default(), C4GameMessageList::Default(), C4MessageInput::Default(), C4MouseControl::Default(), C4MaterialMap::Default(), C4Scenario::Default(), DefaultRanks, DefinitionFilenames, Definitions, DirectJoinAddress, DoSkipFrame, Evaluated, EvaluateOnAbort, fLobby, fObserve, FPS, FrameCounter, FrameSkip, fReferenceDefinitionOverride, fResortAnyObject, fScriptCreatedObjects, FullSpeed, GameOver, GameOverDlgShown, GraphicsSystem, GroupSet, HaltCount, iLobbyTimeout, InitialPlayersJoined, InitProgress, IsRunning, iTick10, iTick1000, iTick2, iTick255, iTick3, iTick35, iTick5, Landscape, LastInitProgress, MassMover, MaterialMap, MessageInput, Messages, MouseControl, C4Application::MusicSystem, Objects, PathFinder, pCurrentScenarioSection, pJoinReference, PlayerFilenames, Players, pNetworkStatistics, PointersDenumerated, pParentGroup, pScenarioSections, PXS, StdStrBuf::Ref(), ScenarioFilename, ScenarioTitle, ScriptGuiRoot, StartTime, StartupPlayerCount, StartupTeamCount, Time, TimeGo, TransferZones, and Weather.

Referenced by C4Game(), Clear(), and C4Scenario::Default().

1445 {
1446  PointersDenumerated = false;
1447  IsRunning = false;
1448  FrameCounter=0;
1450  ScenarioFilename[0]=0;
1451  PlayerFilenames[0]=0;
1452  DefinitionFilenames[0]=0;
1453  DirectJoinAddress[0]=0;
1454  pJoinReference=nullptr;
1456  StartupTeamCount = 0;
1457  ScenarioTitle.Ref("");
1458  HaltCount=0;
1460  Evaluated=false;
1461  EvaluateOnAbort=false;
1462  TimeGo=false;
1463  Time=0;
1464  StartTime=0;
1466  FPS=cFPS=0;
1467  fScriptCreatedObjects=false;
1468  fLobby=fObserve=false;
1469  iLobbyTimeout=0;
1471  FullSpeed=false;
1472  FrameSkip=1; DoSkipFrame=false;
1475  Objects.Default();
1476  Players.Default();
1477  Weather.Default();
1478  Landscape.Default();
1480  MassMover.Default();
1481  PXS.Default();
1483  C4S.Default();
1484  ::Messages.Default();
1487  PathFinder.Default();
1489  GroupSet.Default();
1490  pParentGroup=nullptr;
1493  fResortAnyObject=false;
1494  pNetworkStatistics.reset();
1496  DebugPort = 0;
1497  DebugPassword.Clear();
1498  DebugHost.Clear();
1499  DebugWait = false;
1500  assert(!ScriptGuiRoot);
1501  ScriptGuiRoot.reset();
1502 }
C4Group * pParentGroup
Definition: C4Game.h:88
bool IsRunning
Definition: C4Game.h:140
int32_t iLobbyTimeout
Definition: C4Game.h:120
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:102
void Default()
Definition: C4GroupSet.cpp:57
int32_t iTick255
Definition: C4Game.h:130
std::unique_ptr< C4Network2Reference > pJoinReference
Definition: C4Game.h:108
int32_t iTick5
Definition: C4Game.h:130
int32_t iTick35
Definition: C4Game.h:130
C4Scenario C4S
Definition: C4Game.h:74
void Clear()
Definition: StdBuf.h:466
C4GroupSet GroupSet
Definition: C4Game.h:87
StdCopyStrBuf ScenarioTitle
Definition: C4Game.h:103
bool GameOverDlgShown
Definition: C4Game.h:117
bool EvaluateOnAbort
Definition: C4Game.h:115
void Default()
Definition: C4PXS.cpp:158
StdStrBuf DebugHost
Definition: C4Game.h:149
C4RankSystem DefaultRanks
void Default() override
C4MessageInput MessageInput
int32_t LastInitProgress
Definition: C4Game.h:134
bool DoSkipFrame
Definition: C4Game.h:138
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
void Default()
Definition: C4Scenario.cpp:78
StdStrBuf DebugPassword
Definition: C4Game.h:149
int32_t InitProgress
Definition: C4Game.h:134
uint16_t DebugPort
Definition: C4Game.h:149
int32_t FrameCounter
Definition: C4Game.h:129
int32_t StartTime
Definition: C4Game.h:133
int32_t FrameSkip
Definition: C4Game.h:138
int32_t iTick1000
Definition: C4Game.h:130
bool GameOver
Definition: C4Game.h:114
int32_t FPS
Definition: C4Game.h:111
C4Landscape Landscape
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
C4PlayerList Players
bool InitialPlayersJoined
Definition: C4Game.h:113
int32_t Time
Definition: C4Game.h:132
C4ScenarioSection * pScenarioSections
Definition: C4Game.h:91
C4TransferZones TransferZones
Definition: C4Game.h:85
C4Weather Weather
Definition: C4Weather.cpp:206
C4PXSSystem PXS
Definition: C4PXS.cpp:423
int32_t iTick3
Definition: C4Game.h:130
int32_t iTick10
Definition: C4Game.h:130
bool fObserve
Definition: C4Game.h:121
void Default()
Definition: C4DefList.cpp:413
bool fResortAnyObject
Definition: C4Game.h:139
void Ref(const char *pnData)
Definition: StdBuf.h:455
C4MassMoverSet MassMover
int32_t StartupPlayerCount
Definition: C4Game.h:109
bool FullSpeed
Definition: C4Game.h:137
bool PointersDenumerated
Definition: C4Game.h:141
char PlayerFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:104
bool Evaluated
Definition: C4Game.h:116
C4PathFinder PathFinder
Definition: C4Game.h:84
C4MaterialMap MaterialMap
Definition: C4Material.cpp:974
char DefinitionFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:105
int32_t StartupTeamCount
Definition: C4Game.h:110
C4DefList Definitions
Definition: C4Globals.cpp:49
bool fReferenceDefinitionOverride
Definition: C4Game.h:122
int32_t HaltCount
Definition: C4Game.h:112
C4GameMessageList Messages
std::unique_ptr< C4ScriptGuiWindow > ScriptGuiRoot
Definition: C4Game.h:234
char DirectJoinAddress[_MAX_PATH+1]
Definition: C4Game.h:106
int32_t cFPS
Definition: C4Game.h:111
std::unique_ptr< C4Network2Stats > pNetworkStatistics
Definition: C4Game.h:95
bool fScriptCreatedObjects
Definition: C4Game.h:118
bool fLobby
Definition: C4Game.h:119
char CurrentScenarioSection[C4MaxName+1]
Definition: C4Game.h:101
C4Application Application
Definition: C4Globals.cpp:44
C4ScenarioSection * pCurrentScenarioSection
Definition: C4Game.h:91
bool TimeGo
Definition: C4Game.h:131
C4GameObjects Objects
Definition: C4Globals.cpp:48
void Default()
Definition: C4Weather.cpp:105
int DebugWait
Definition: C4Game.h:149
int32_t iTick2
Definition: C4Game.h:130
C4MusicSystem MusicSystem
Definition: C4Application.h:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteObjects()

void C4Game::DeleteObjects ( bool  fDeleteInactive)
protected

Definition at line 1049 of file C4Game.cpp.

References C4GameObjects::DeleteObjects(), fResortAnyObject, and Objects.

Referenced by Clear(), and LoadScenarioSection().

1050 {
1051  // del any objects
1052  ::Objects.DeleteObjects(fDeleteInactive);
1053  // reset resort flag
1054  fResortAnyObject = false;
1055 }
void DeleteObjects(bool fDeleteInactive)
bool fResortAnyObject
Definition: C4Game.h:139
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoGameOver()

bool C4Game::DoGameOver ( )

Definition at line 3098 of file C4Game.cpp.

References Config, C4PlayerList::First, GameOver, GRBroadcast(), LoadResStr(), Log(), C4Player::Next, Players, PSF_OnGameOver, and C4Config::Save().

Referenced by C4Playback::ExecuteControl(), GameOverCheck(), C4ControlSyncCheck::GetAllCrewPosX(), C4ControlVote::getDescWarning(), and HasScenario().

3099 {
3100  // Duplication safety
3101  if (GameOver) return false;
3102  // Flag, log, call
3103  GameOver=true;
3104  Log(LoadResStr("IDS_PRC_GAMEOVER"));
3106  // Flag all surviving players as winners
3107  for (C4Player *pPlayer = Players.First; pPlayer; pPlayer = pPlayer->Next)
3108  if (!pPlayer->Eliminated)
3109  pPlayer->EvaluateLeague(false, true);
3110  // Immediately save config so mission access gained by this round is stored if the game crashes during shutdown
3111  // or in a following round
3112  Config.Save();
3113  return true;
3114 }
C4Config Config
Definition: C4Config.cpp:833
C4Player * First
Definition: C4PlayerList.h:31
#define PSF_OnGameOver
Definition: C4GameScript.h:138
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool GameOver
Definition: C4Game.h:114
C4PlayerList Players
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars=nullptr, bool fPassError=false, bool fRejectTest=false)
Definition: C4Game.cpp:3853
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
C4Player * Next
Definition: C4Player.h:142
bool Save()
Definition: C4Config.cpp:400
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoKeyboardInput() [1/2]

bool C4Game::DoKeyboardInput ( C4KeyCode  vk_code,
C4KeyEventType  eEventType,
bool  fAlt,
bool  fCtrl,
bool  fShift,
bool  fRepeated,
class C4GUI::Dialog pForDialog = nullptr,
bool  fPlrCtrlOnly = false,
int32_t  iStrength = -1 
)

Definition at line 1866 of file C4Game.cpp.

References KEYS_Alt, KEYS_Control, and KEYS_Shift.

Referenced by ConsoleHandleWin32KeyboardMessage(), KeycodeToString(), C4StartupMainDlg::KeyEnterDown(), C4StartupMainDlg::KeyEnterUp(), C4ChatInputDialog::OnChatInput(), and C4AppDelegate::simulateKeyPressed:.

1867 {
1868  // compose key
1869  C4KeyCodeEx Key(vk_code, C4KeyShiftState(fAlt*KEYS_Alt + fCtrl*KEYS_Control + fShift*KEYS_Shift), fRepeated);
1870  return DoKeyboardInput(Key, eEventType, pForDialog, fPlrCtrlOnly, iStrength);
1871 }
C4KeyShiftState
bool DoKeyboardInput(C4KeyCode vk_code, C4KeyEventType eEventType, bool fAlt, bool fCtrl, bool fShift, bool fRepeated, class C4GUI::Dialog *pForDialog=nullptr, bool fPlrCtrlOnly=false, int32_t iStrength=-1)
Definition: C4Game.cpp:1866
Here is the caller graph for this function:

◆ DoKeyboardInput() [2/2]

bool C4Game::DoKeyboardInput ( C4KeyCodeEx  Key,
C4KeyEventType  eEventType,
class C4GUI::Dialog pForDialog = nullptr,
bool  fPlrCtrlOnly = false,
int32_t  iStrength = -1 
)

Definition at line 1874 of file C4Game.cpp.

References C4GUI::Screen::ActivateDialog(), C4Window::Active, Application, C4S, Console, C4KeyboardInput::DoInput(), C4SHead::Film, C4KeyCodeEx::FixShiftKeys(), FullScreen, Game, C4ViewportList::GetViewport(), C4GUI::Screen::HasKeyboardFocus(), C4Scenario::Head, C4Menu::IsActive(), C4Application::isEditor, IsRunning, C4GameOverDlg::IsShown(), C4GUI::Screen::KeyAny(), KeyboardInput, KEYSCOPE_Console, KEYSCOPE_Control, KEYSCOPE_FilmView, KEYSCOPE_FreeView, KEYSCOPE_Fullscreen, KEYSCOPE_FullSMenu, KEYSCOPE_FullSView, KEYSCOPE_Generic, KEYSCOPE_Gui, NO_OWNER, pGUI, C4FullScreen::pMenu, C4SHead::Replay, and Viewports.

1875 {
1876  Key.FixShiftKeys();
1877  // compose keyboard scope
1878  DWORD InScope = 0;
1879  if (fPlrCtrlOnly)
1880  InScope = KEYSCOPE_Control;
1881  else
1882  {
1883  if (IsRunning) InScope = KEYSCOPE_Generic;
1884  // if GUI has keyfocus, this overrides regular controls
1885  if (pGUI->HasKeyboardFocus() || pForDialog)
1886  {
1887  InScope |= KEYSCOPE_Gui;
1888  // control to console mode dialog: Make current keyboard target the active dlg,
1889  // so it can process input
1890  if (pForDialog) pGUI->ActivateDialog(pForDialog);
1891  // any keystroke in GUI resets tooltip times
1892  pGUI->KeyAny();
1893  }
1894  else
1895  {
1896  if (!Application.isEditor)
1897  {
1898  if (FullScreen.pMenu && FullScreen.pMenu->IsActive()) // fullscreen menu
1899  InScope |= KEYSCOPE_FullSMenu;
1900  else if (Game.C4S.Head.Replay && C4S.Head.Film) // film view only
1901  InScope |= KEYSCOPE_FilmView;
1902  else if (::Viewports.GetViewport(NO_OWNER)) // NO_OWNER-viewport-controls
1903  InScope |= KEYSCOPE_FreeView;
1904  else
1905  {
1906  // regular player viewport controls
1907  InScope |= KEYSCOPE_FullSView;
1908  // player controls disabled during round over dlg
1909  if (!C4GameOverDlg::IsShown()) InScope |= KEYSCOPE_Control;
1910  }
1911  }
1912  else
1913  // regular player viewport controls
1914  InScope |= KEYSCOPE_Control;
1915  }
1916  // fullscreen/console (in running game)
1917  if (IsRunning)
1918  {
1919  if (FullScreen.Active) InScope |= KEYSCOPE_Fullscreen;
1920  if (Console.Active) InScope |= KEYSCOPE_Console;
1921  }
1922  }
1923  // okay; do input
1924  if (KeyboardInput.DoInput(Key, eEventType, InScope, iStrength))
1925  return true;
1926 
1927  // unprocessed key
1928  return false;
1929 }
bool HasKeyboardFocus()
Definition: C4Gui.h:2668
bool IsRunning
Definition: C4Game.h:140
C4Console Console
Definition: C4Globals.cpp:45
C4MainMenu * pMenu
Definition: C4FullScreen.h:30
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:74
bool Replay
Definition: C4Scenario.h:72
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1191
C4KeyboardInput & KeyboardInput
Definition: C4Game.h:96
static bool IsShown()
Definition: C4GameOverDlg.h:92
const int NO_OWNER
Definition: C4Constants.h:137
bool IsActive()
Definition: C4Menu.cpp:480
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
bool DoInput(const C4KeyCodeEx &InKey, C4KeyEventType InEvent, DWORD InScope, int32_t iStrength)
bool Active
Definition: C4Window.h:274
C4SHead Head
Definition: C4Scenario.h:232
uint32_t DWORD
C4Application Application
Definition: C4Globals.cpp:44
int32_t Film
Definition: C4Scenario.h:73
void ActivateDialog(Dialog *pDlg)
Definition: C4Gui.cpp:647
bool KeyAny()
Definition: C4Gui.cpp:771
Here is the call graph for this function:

◆ DrawCrewOverheadText()

void C4Game::DrawCrewOverheadText ( C4TargetFacet cgo,
int32_t  iPlayer 
)

Definition at line 1533 of file C4Game.cpp.

References ACenter, C4GM_MaxText, Config, C4Object::Contained, C4Object::Def, C4GraphicsResource::fctMouseCursor, C4PlayerList::First, fixtof(), C4GraphicsResource::FontRegular, StdStrBuf::Format(), StdStrBuf::getData(), CStdFont::GetLineHeight(), C4PropList::GetName(), CStdFont::GetTextExtent(), C4Draw::GetZoom(), C4Config::Graphics, GraphicsResource, Hostile(), C4Object::Info, C4Object::IsVisible(), C4Player::Next, NO_OWNER, C4Object::OCF, OCF_CrewMember, pDraw, Players, C4ObjectInfoCore::Rank, SCopy(), C4Draw::SetZoom(), C4ConfigGraphics::ShowCrewCNames, C4ConfigGraphics::ShowCrewNames, sprintf, C4ObjectInfoCore::sRankName, C4PropList::Status, C4Facet::Surface, SWordWrap(), C4Draw::TextOut(), C4Facet::Wdt, C4Facet::X, C4Facet::Y, ZoomData::Zoom, and C4TargetFacet::Zoom.

Referenced by C4Viewport::Draw().

1534 {
1535 
1536  // All drawing in this function must not be affected by zoom; but remember zoom and reset later.
1537  ZoomData r;
1538  pDraw->GetZoom(&r);
1539  const float zoom = r.Zoom;
1540  r.Zoom = 1.0;
1541  pDraw->SetZoom(r);
1542  // Offset for all text/objects
1543  const float fixedOffsetX = -cgo.X * cgo.Zoom + cgo.X;
1544  const float fixedOffsetY = (-cgo.Y - 10.0f) * cgo.Zoom + cgo.Y;
1545  // Draw cursor mark arrow & cursor object name
1547  for (C4Player *pPlr = Players.First; pPlr; pPlr = pPlr->Next)
1548  {
1549  // Draw a small selector & name above the cursor? F.e. after switching crew.
1550  const bool drawCursorInfo = (pPlr->Number == iPlayer || iPlayer == NO_OWNER) // only for the viewport's player..
1551  && (pPlr->CursorFlash && pPlr->Cursor); // ..and if the player wants to show their cursor.
1552  // Otherwise, for allied players we might want to draw player & crew names.
1553  // Note that these two conditions are generally mutually-exclusive.
1554  const bool drawPlayerAndCursorNames = (pPlr->Number != iPlayer) // Never for own player..
1555  && (Config.Graphics.ShowCrewNames || Config.Graphics.ShowCrewCNames) // ..and if the settings allow it..
1556  && !Hostile(iPlayer, pPlr->Number) && !pPlr->IsInvisible(); // ..and of course only if applicable.
1557 
1558  if (!drawPlayerAndCursorNames && !drawCursorInfo) continue;
1559 
1560  // Lambda to calculate correct drawing position of object, (re-)adjusted by zoom.
1561  float drawX, drawY, drawZoom;
1562  auto calculateObjectTextPosition = [&](C4Object *obj)
1563  {
1564  obj->GetDrawPosition(cgo, fixtof(obj->fix_x), fixtof(obj->fix_y), 1.0, drawX, drawY, drawZoom);
1565  drawX = drawX * cgo.Zoom + fixedOffsetX;
1566  drawY = drawY * cgo.Zoom - static_cast<float>(obj->Def->Shape.Hgt) / 2.0 + fixedOffsetY;
1567  };
1568 
1569  // Actual text output!
1570  if (drawPlayerAndCursorNames)
1571  {
1572  // We need to show crew names for that player, we do so for every crew-member.
1573  for (C4Object * const & crew : pPlr->Crew)
1574  {
1575  if (!crew->Status || !crew->Def) continue;
1576  if (crew->Contained) continue;
1577  if ((crew->OCF & OCF_CrewMember) == 0) continue;
1578  if (!crew->IsVisible(iPlayer, false)) continue;
1579 
1580  calculateObjectTextPosition(crew);
1581  drawY -= 5.0f; // aesthetical offset
1582 
1583  // compose string
1584  char szText[C4GM_MaxText + 1];
1587  sprintf(szText, "%s (%s)", crew->GetName(), pPlr->GetName());
1588  else
1589  SCopy(pPlr->GetName(), szText);
1590  else
1591  SCopy(crew->GetName(), szText);
1592  // Word wrap to cgo width
1593  int32_t iCharWdt, dummy;
1594  ::GraphicsResource.FontRegular.GetTextExtent("m", iCharWdt, dummy, false);
1595  int32_t iMaxLine = std::max<int32_t>(cgo.Wdt / std::max<int32_t>(1, iCharWdt), 20);
1596  SWordWrap(szText, ' ', '|', iMaxLine);
1597  // Center text vertically, too
1598  int textWidth, textHeight;
1599  ::GraphicsResource.FontRegular.GetTextExtent(szText, textWidth, textHeight, true);
1600  // Draw
1601  pDraw->TextOut(szText, ::GraphicsResource.FontRegular, 1.0, cgo.Surface, drawX, drawY - static_cast<float>(textHeight) / 2.0,
1602  pPlr->ColorDw | 0x7f000000, ACenter);
1603  }
1604  }
1605  else if (drawCursorInfo)
1606  {
1607  C4Object * const cursor = pPlr->Cursor;
1608  calculateObjectTextPosition(cursor);
1609  // Draw a down-arrow above the Clonk's head
1610  drawY += -fctCursor.Hgt;
1611  fctCursor.Draw(cgo.Surface, drawX - static_cast<float>(fctCursor.Wdt) / 2.0, drawY, 4);
1612  // And possibly draw some info text, too
1613  if (cursor->Info)
1614  {
1615  int32_t texthgt = ::GraphicsResource.FontRegular.GetLineHeight();
1616  StdStrBuf str;
1617  if (cursor->Info->Rank > 0)
1618  {
1619  str.Format("%s|%s", cursor->Info->sRankName.getData(), cursor->GetName());
1620  texthgt += texthgt;
1621  }
1622  else str = cursor->GetName();
1623 
1625  drawX,
1626  drawY - static_cast<float>(texthgt) / 2.0,
1627  0xffff0000, ACenter);
1628 
1629  }
1630  }
1631  }
1632  // Reset zoom
1633  r.Zoom = zoom;
1634  pDraw->SetZoom(r);
1635 }
C4Config Config
Definition: C4Config.cpp:833
float Y
Definition: C4Facet.h:118
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
float Zoom
Definition: C4Facet.h:165
#define sprintf
Definition: Standard.h:164
bool TextOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
Definition: C4Draw.cpp:567
StdStrBuf sRankName
Definition: C4InfoCore.h:40
const uint32_t OCF_CrewMember
Definition: C4Constants.h:97
int32_t ShowCrewNames
Definition: C4Config.h:107
C4Player * First
Definition: C4PlayerList.h:31
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup=true)
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
C4GraphicsResource GraphicsResource
C4ObjectInfo * Info
Definition: C4Object.h:145
C4ConfigGraphics Graphics
Definition: C4Config.h:253
void SWordWrap(char *szText, char cSpace, char cSepa, int iMaxLine)
Definition: Standard.cpp:393
C4Def * Def
Definition: C4Object.h:143
int32_t ShowCrewCNames
Definition: C4Config.h:108
const int ACenter
Definition: C4Surface.h:41
C4PlayerList Players
const int NO_OWNER
Definition: C4Constants.h:137
int32_t Hostile(int32_t plr1, int32_t plr2)
C4Draw * pDraw
Definition: C4Draw.cpp:42
int32_t Status
Definition: C4PropList.h:168
const char * getData() const
Definition: StdBuf.h:442
bool IsVisible(int32_t iForPlr, bool fAsOverlay) const
Definition: C4Object.cpp:4053
virtual const char * GetName() const
Definition: C4PropList.cpp:649
void GetZoom(ZoomData *r)
Definition: C4Draw.h:197
int GetLineHeight() const
Definition: C4FontLoader.h:125
const int32_t C4GM_MaxText
Definition: C4GameMessage.h:26
C4Player * Next
Definition: C4Player.h:142
float fixtof(const C4Fixed &x)
Definition: C4Real.h:257
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Surface * Surface
Definition: C4Facet.h:117
uint32_t OCF
Definition: C4Object.h:134
float Wdt
Definition: C4Facet.h:118
void SetZoom(float X, float Y, float Zoom)
Definition: C4Draw.cpp:779
float X
Definition: C4Facet.h:118
float Zoom
Definition: C4Draw.h:70
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawPropListSpecImage()

bool C4Game::DrawPropListSpecImage ( C4Facet fctTarget,
C4PropList pSpec 
)

Definition at line 3798 of file C4Game.cpp.

References C4DefGraphics::Draw(), C4Def::Draw(), C4DefGraphics::Get(), C4String::GetCStr(), C4PropList::GetDef(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyPropList(), C4PropList::GetPropertyStr(), C4Def::Graphics, P_Color, P_Name, and P_Source.

Referenced by C4GameMessage::Draw(), and HasScenario().

3799 {
3800  // safety
3801  assert(pSpec);
3802  if (!pSpec) return false;
3803 
3804  // get source definition
3805  C4PropList *source_def_proplist = pSpec->GetPropertyPropList(P_Source);
3806  if (!source_def_proplist) return false;
3807  C4Def *source_def = source_def_proplist->GetDef();
3808  if (!source_def) return false;
3809 
3810  // get custom color
3811  uint32_t color = (uint32_t)pSpec->GetPropertyInt(P_Color);
3812 
3813  C4String *source_name = pSpec->GetPropertyStr(P_Name);
3814  if (!source_name)
3815  {
3816  // Base graphics
3817  source_def->Draw(fctTarget, false, color);
3818  }
3819  else
3820  {
3821  // Alternative named graphics
3822  C4DefGraphics *source_graphics = source_def->Graphics.Get(source_name->GetCStr());
3823  if (!source_graphics) return false;
3824  source_graphics->Draw(fctTarget, color, nullptr, 0,0, nullptr);
3825  }
3826  return true;
3827 }
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:775
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
C4DefGraphics * Get(const char *szGrpName)
const char * GetCStr() const
Definition: C4StringTable.h:49
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:597
Definition: C4Def.h:98
void Draw(C4Facet &cgo, DWORD iColor, C4Object *pObj, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *trans)
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:685
C4PropList * GetPropertyPropList(C4PropertyName k) const
Definition: C4PropList.cpp:900
C4DefGraphics Graphics
Definition: C4Def.h:191
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawTextSpecImage()

bool C4Game::DrawTextSpecImage ( C4Facet fctTarget,
const char *  szSpec,
class C4DrawTransform pTransform,
uint32_t  dwClr = 0xff 
)

Definition at line 3744 of file C4Game.cpp.

References C4Id2Def(), C4Def::Draw(), C4Facet::DrawXT(), GetTextSpecFacet(), C4Facet::Hgt, C4Facet::Surface, C4Facet::Wdt, C4Facet::X, and C4Facet::Y.

Referenced by C4MainMenu::DoRefillInternal(), HasScenario(), and C4DefList::Reload().

3745 {
3746  // safety
3747  assert(szSpec && *szSpec);
3748  if (!szSpec) return false;
3749 
3750  C4Facet fctSource;
3751  if(GetTextSpecFacet(szSpec, fctSource))
3752  {
3753  fctSource.DrawXT(fctTarget.Surface, fctTarget.X, fctTarget.Y, fctTarget.Wdt, fctTarget.Hgt, 0, 0, pTransform);
3754  return true;
3755  }
3756  else
3757  {
3758  C4Def *pDef = C4Id2Def(C4ID(szSpec));
3759  if (!pDef) return false;
3760 
3761  pDef->Draw(fctTarget, false, dwClr, nullptr, 0, 0, pTransform);
3762  return true;
3763  }
3764 }
float Y
Definition: C4Facet.h:118
bool GetTextSpecFacet(const char *szSpec, C4Facet &fct)
Definition: C4Game.cpp:3724
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:597
Definition: C4Def.h:98
Definition: C4Id.h:25
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
float Hgt
Definition: C4Facet.h:118
void DrawXT(C4Surface *sfcTarget, float iX, float iY, int32_t iWdt, int32_t iHgt, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform)
Definition: C4Facet.cpp:392
C4Surface * Surface
Definition: C4Facet.h:117
float Wdt
Definition: C4Facet.h:118
float X
Definition: C4Facet.h:118
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DropDef()

bool C4Game::DropDef ( C4ID  id,
float  iX,
float  iY 
)

Definition at line 1394 of file C4Game.cpp.

References C4Id2Def(), CDT_Decide, CID_EMMoveObj, Console, Control, C4ControlEMMoveObject::CreateObject(), C4GameControl::DoInput(), FormatString(), ftofix(), LoadResStr(), and C4ConsoleGUI::Out().

Referenced by DropFile(), and HasScenario().

1395 {
1396  // Get def
1397  C4Def *pDef;
1398  if ((pDef=C4Id2Def(id)))
1399  {
1401  return true;
1402  }
1403  else
1404  {
1405  // Failure
1406  Console.Out(FormatString(LoadResStr("IDS_CNS_DROPNODEF"),id.ToString()).getData());
1407  }
1408  return false;
1409 }
C4Console Console
Definition: C4Globals.cpp:45
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4GameControl Control
void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery)
Definition: C4Def.h:98
void Out(const char *message)
Definition: C4Console.cpp:684
C4Fixed ftofix(float x)
Definition: C4Real.h:258
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
static C4ControlEMMoveObject * CreateObject(const C4ID &id, C4Real x, C4Real y, C4Object *container)
Definition: C4Control.cpp:1214
#define X(sdl, oc)
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DropFile()

bool C4Game::DropFile ( const char *  szFilename,
float  iX,
float  iY 
)

Definition at line 1373 of file C4Game.cpp.

References Application, C4D_Load_RX, C4Id2Def(), Config, Console, DefFileGetID(), Definitions, DropDef(), FormatString(), C4Config::General, GetExtension(), GetFilename(), C4ConfigGeneral::LanguageEx, C4DefList::Load(), LoadResStr(), C4ConsoleGUI::Out(), SEqualNoCase(), and C4Application::SoundSystem.

Referenced by C4Viewport::DropFile(), and HasScenario().

1374 {
1375  C4ID c_id; C4Def *cdef;
1376  // Drop def to create object
1377  if (SEqualNoCase(GetExtension(szFilename),"ocd"))
1378  {
1379  // Get id from file
1380  if ((c_id=DefFileGetID(szFilename)))
1381  // Get loaded def or try to load def from file
1382  if ( (cdef=C4Id2Def(c_id))
1383  || (::Definitions.Load(szFilename,C4D_Load_RX,Config.General.LanguageEx,&Application.SoundSystem) && (cdef=C4Id2Def(c_id))) )
1384  {
1385  return DropDef(c_id, iX, iY);
1386  }
1387  // Failure
1388  Console.Out(FormatString(LoadResStr("IDS_CNS_DROPNODEF"),GetFilename(szFilename)).getData());
1389  return false;
1390  }
1391  return false;
1392 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:45
C4SoundSystem SoundSystem
Definition: C4Application.h:42
C4Config Config
Definition: C4Config.cpp:833
C4Console Console
Definition: C4Globals.cpp:45
C4ConfigGeneral General
Definition: C4Config.h:251
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:207
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
const DWORD C4D_Load_RX
Definition: C4Def.h:91
Definition: C4Def.h:98
void Out(const char *message)
Definition: C4Console.cpp:684
bool DropDef(C4ID id, float iX, float iY)
Definition: C4Game.cpp:1394
char * GetExtension(char *szFilename)
Definition: StdFile.cpp:121
char LanguageEx[CFG_MaxString+1]
Definition: C4Config.h:37
Definition: C4Id.h:25
int32_t Load(C4Group &hGroup, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem=nullptr, bool fOverload=false, bool fSearchMessage=false, int32_t iMinProgress=0, int32_t iMaxProgress=0, bool fLoadSysGroups=true)
Definition: C4DefList.cpp:71
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
C4DefList Definitions
Definition: C4Globals.cpp:49
C4Application Application
Definition: C4Globals.cpp:44
C4ID DefFileGetID(const char *szFilename)
Definition: C4Game.cpp:1363
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Evaluate()

void C4Game::Evaluate ( )

Definition at line 1504 of file C4Game.cpp.

References Control, C4PlayerList::Evaluate(), Evaluated, C4RoundResults::EvaluateGame(), StdStrBuf::getData(), C4Network2::isEnabled(), C4Network2::isHost(), C4GameParameters::isLeague(), C4GameControl::isRecord(), C4Network2::LeagueGameEvaluate(), LoadResStr(), Log(), Network, Parameters, Players, RoundResults, C4PlayerList::Save(), SHA_DIGEST_LENGTH, and C4GameControl::StopRecord().

Referenced by Abort(), Clear(), and Execute().

1505 {
1506 
1507  // League game?
1508  bool fLeague = Network.isEnabled() && Network.isHost() && Parameters.isLeague();
1509 
1510  // Stop record
1511  StdStrBuf RecordName; BYTE RecordSHA[SHA_DIGEST_LENGTH];
1512  if (Control.isRecord())
1513  Control.StopRecord(&RecordName, fLeague ? RecordSHA : nullptr);
1514 
1515  // Send league result
1516  if (fLeague)
1517  Network.LeagueGameEvaluate(RecordName.getData(), RecordSHA);
1518 
1519  // Players
1520  // saving local players only, because remote players will probably not rejoin after evaluation anyway)
1521  Players.Evaluate();
1522  Players.Save(true);
1523 
1524  // Round results
1526 
1527  // Set game flag
1528  Log(LoadResStr("IDS_PRC_EVALUATED"));
1529  Evaluated=true;
1530 
1531 }
#define SHA_DIGEST_LENGTH
Definition: SHA1.h:42
void StopRecord(StdStrBuf *pRecordName=nullptr, BYTE *pRecordSHA1=nullptr)
bool isEnabled() const
Definition: C4Network2.h:203
uint8_t BYTE
C4GameParameters & Parameters
Definition: C4Game.h:67
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
C4GameControl Control
bool isLeague() const
C4PlayerList Players
bool isRecord() const
C4RoundResults & RoundResults
Definition: C4Game.h:73
const char * getData() const
Definition: StdBuf.h:442
bool isHost() const
Definition: C4Network2.h:209
bool Evaluated
Definition: C4Game.h:116
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
void LeagueGameEvaluate(const char *szRecordName=nullptr, const BYTE *pRecordSHA=nullptr)
bool Save(bool fSaveLocalOnly)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExecObjects()

void C4Game::ExecObjects ( )
protected

Definition at line 1321 of file C4Game.cpp.

References AddDbgRec(), Config, C4GameObjects::CrossCheck(), C4ConfigGeneral::DebugRec, fResortAnyObject, Game, C4Config::General, iTick255, ObjectRemovalCheck(), Objects, RCT_Block, C4GameObjects::ResortUnsorted(), and C4ObjectList::reverse().

Referenced by Execute().

1322 {
1323  if (Config.General.DebugRec)
1324  AddDbgRec(RCT_Block, "ObjEx", 6);
1325 
1326  // Execute objects - reverse order to ensure
1327  for (C4Object *cObj : Objects.reverse())
1328  {
1329  if (cObj)
1330  {
1331  if (cObj->Status)
1332  // Execute object
1333  cObj->Execute();
1334  else
1335  // Status reset: process removal delay
1336  if (cObj->RemovalDelay>0) cObj->RemovalDelay--;
1337  }
1338  }
1339 
1340  if (Config.General.DebugRec)
1341  AddDbgRec(RCT_Block, "ObjCC", 6);
1342 
1343  // Cross check objects
1344  Objects.CrossCheck();
1345 
1346  if (Config.General.DebugRec)
1347  AddDbgRec(RCT_Block, "ObjRs", 6);
1348 
1349  // Resort
1350  if (fResortAnyObject)
1351  {
1352  fResortAnyObject = false;
1354  }
1355 
1356  if (Config.General.DebugRec)
1357  AddDbgRec(RCT_Block, "ObjRm", 6);
1358 
1359  // Removal
1360  if (!::Game.iTick255) ObjectRemovalCheck();
1361 }
C4Config Config
Definition: C4Config.cpp:833
int32_t iTick255
Definition: C4Game.h:130
C4Game Game
Definition: C4Globals.cpp:52
C4ConfigGeneral General
Definition: C4Config.h:251
const ReverseView reverse() const
Definition: C4ObjectList.h:104
void ObjectRemovalCheck()
Definition: C4Game.cpp:1309
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:32
bool fResortAnyObject
Definition: C4Game.h:139
int32_t DebugRec
Definition: C4Config.h:60
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Execute()

bool C4Game::Execute ( )

Definition at line 709 of file C4Game.cpp.

References AddDbgRec(), C4ST_RESETPART, C4ST_SHOWPARTSTAT, C4ParticleSystem::CalculateNextStep(), Config, Control, C4ConfigGeneral::DebugRec, C4Landscape::DoRelights(), C4GameControl::DoSyncCheck(), Evaluate(), Evaluated, EXEC_DR, EXEC_S, EXEC_S_DR, ExecObjects(), C4PlayerList::Execute(), C4Weather::Execute(), C4PXSSystem::Execute(), C4MassMoverSet::Execute(), C4Landscape::Execute(), C4GameMessageList::Execute(), C4Effect::Execute(), C4MouseControl::Execute(), C4GameControl::Execute(), C4Network2::Execute(), FrameCounter, GameGo, GameOver, GameOverCheck(), GameOverDlgShown, GameScript, C4Config::General, HaltCount, IsRunning, Landscape, MassMover, Messages, MouseControl, Network, Particles, C4AulScriptEngine::pGlobalEffects, Players, C4GameControl::Prepare(), C4GameScriptHost::pScenarioEffects, PXS, RCT_Block, RCT_DbgFrame, ScriptEngine, ShowGameOverDlg(), Ticks(), and Weather.

Referenced by C4Application::GameTick(), C4CustomKey::GetPriority(), and HasScenario().

710 {
711 
712  // Let's go
713  GameGo = true;
714 
715  // Network
716  Network.Execute();
717 
718  // Prepare control
719  bool fControl;
720  EXEC_S( fControl = Control.Prepare(); , ControlStat )
721  if (!fControl) return false; // not ready yet: wait
722 
723  // Halt
724  if (HaltCount) return false;
725 
726  if (Config.General.DebugRec)
728 
729  // Execute the control
730  Control.Execute();
731  if (!IsRunning) return false;
732 
733  // Ticks
734  EXEC_DR( Ticks(); , "Ticks")
735 
736  if (Config.General.DebugRec)
737  // debugrec
738  AddDbgRec(RCT_DbgFrame, &FrameCounter, sizeof(int32_t));
739 
740  // allow the particle system to execute the next frame BEFORE the other game stuff is calculated since it will run in parallel to the main thread
741  Particles.CalculateNextStep();
742 
743  // Game
744 
745  EXEC_S( ExecObjects(); , ExecObjectsStat )
746  EXEC_S_DR( C4Effect::Execute(&ScriptEngine.pGlobalEffects);
747  C4Effect::Execute(&GameScript.pScenarioEffects);
748  , GEStats , "GEEx\0");
749  EXEC_S_DR( PXS.Execute(); , PXSStat , "PXSEx")
750  EXEC_S_DR( MassMover.Execute(); , MassMoverStat , "MMvEx")
751  EXEC_S_DR( Weather.Execute(); , WeatherStat , "WtrEx")
752  EXEC_S_DR( Landscape.Execute(); , LandscapeStat , "LdsEx")
753  EXEC_S_DR( Players.Execute(); , PlayersStat , "PlrEx")
754  EXEC_S_DR( ::Messages.Execute(); , MessagesStat , "MsgEx")
755 
756  EXEC_DR( MouseControl.Execute(); , "Input")
757 
758  EXEC_DR( GameOverCheck(); , "Misc\0")
759 
760  Control.DoSyncCheck();
761 
762  // Evaluation; Game over dlg
763  if (GameOver)
764  {
765  if (!Evaluated) Evaluate();
767  }
768 
769  // show stat each 1000 ticks
770  if (!(FrameCounter % 1000))
771  {
772  C4ST_SHOWPARTSTAT(FrameCounter)
774  }
775 
776  if (Config.General.DebugRec)
777  {
778  AddDbgRec(RCT_Block, "eGame", 6);
780  }
781 
782  return true;
783 }
bool IsRunning
Definition: C4Game.h:140
C4Config Config
Definition: C4Config.cpp:833
C4GameScriptHost GameScript
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4ConfigGeneral General
Definition: C4Config.h:251
C4ParticleSystem Particles
#define C4ST_RESETPART
Definition: C4Stat.h:157
bool GameOverDlgShown
Definition: C4Game.h:117
bool Execute()
Definition: C4Game.cpp:709
void Execute()
Definition: C4Network2.cpp:648
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
void ShowGameOverDlg()
Definition: C4Game.cpp:3116
int32_t FrameCounter
Definition: C4Game.h:129
#define EXEC_S_DR(Expressions, Stat, DebugRecName)
Definition: C4Game.cpp:706
void Ticks()
Definition: C4Game.cpp:1637
C4Network2 Network
Definition: C4Globals.cpp:53
bool GameOverCheck()
Definition: C4Game.cpp:670
bool GameOver
Definition: C4Game.h:114
C4GameControl Control
C4Landscape Landscape
C4PlayerList Players
#define EXEC_S(Expressions, Stat)
Definition: C4Game.cpp:703
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:32
#define EXEC_DR(Expressions, DebugRecName)
Definition: C4Game.cpp:707
C4Weather Weather
Definition: C4Weather.cpp:206
C4PXSSystem PXS
Definition: C4PXS.cpp:423
C4Control & Input
Definition: C4Game.h:82
C4MassMoverSet MassMover
#define C4ST_SHOWPARTSTAT(FrameCounter)
Definition: C4Stat.h:155
bool Evaluated
Definition: C4Game.h:116
void ExecObjects()
Definition: C4Game.cpp:1321
bool GameGo
Definition: C4Game.h:136
int32_t DebugRec
Definition: C4Config.h:60
bool DoRelights()
int32_t HaltCount
Definition: C4Game.h:112
C4GameMessageList Messages
void Evaluate()
Definition: C4Game.cpp:1504
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindConstuctionSiteBlock()

C4Object * C4Game::FindConstuctionSiteBlock ( int32_t  tx,
int32_t  ty,
int32_t  wdt,
int32_t  hgt 
)

Definition at line 1142 of file C4Game.cpp.

References C4LArea::FirstObjectShapes(), C4Rect::Hgt, C4LArea::NextObjectShapes(), Objects, OCF_Exclusive, C4Rect::Overlap(), C4GameObjects::Sectors, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by ConstructionCheck(), FindConSiteSpot(), and HasScenario().

1143 {
1144  C4Rect rect1,rect2;
1145  rect1.x=tx; rect1.y=ty; rect1.Wdt=wdt; rect1.Hgt=hgt;
1146  C4LArea Area(&::Objects.Sectors, tx, ty, wdt, hgt); C4LSector *pSector;
1147  for (C4ObjectList *pObjs = Area.FirstObjectShapes(&pSector); pSector; pObjs = Area.NextObjectShapes(pObjs, &pSector))
1148  for (C4Object *cObj : *pObjs)
1149  if (cObj->Status && !cObj->Contained)
1150  if (cObj->OCF & OCF_Exclusive)
1151  {
1152  rect2=cObj->Shape; rect2.x+=cObj->GetX(); rect2.y+=cObj->GetY();
1153  if (rect1.Overlap(rect2)) return cObj;
1154  }
1155  return nullptr;
1156 }
Definition: C4Rect.h:27
int32_t Wdt
Definition: C4Rect.h:30
int32_t y
Definition: C4Rect.h:30
const uint32_t OCF_Exclusive
Definition: C4Constants.h:89
C4LSectors Sectors
Definition: C4GameObjects.h:42
int32_t x
Definition: C4Rect.h:30
bool Overlap(C4Rect &rTarget)
Definition: C4Rect.cpp:91
int32_t Hgt
Definition: C4Rect.h:30
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindObject()

C4Object * C4Game::FindObject ( C4Def pDef,
int32_t  iX = 0,
int32_t  iY = 0,
int32_t  iWdt = 0,
int32_t  iHgt = 0,
DWORD  ocf = OCF_All,
C4Object pFindNext = nullptr 
)

Definition at line 1158 of file C4Game.cpp.

References C4Def::Count, C4Object::GetX(), C4Object::GetY(), and Objects.

Referenced by C4Command::Acquire(), HasScenario(), and C4EditCursor::Move().

1162 {
1163 
1164  C4Object *pClosest=nullptr;
1165  int32_t iClosest = 0,iDistance,iFartherThan=-1;
1166  C4Object *pFindNextCpy=pFindNext;
1167 
1168  // check the easy case first: no instances at all?
1169  if (pDef && !pDef->Count) return nullptr;
1170 
1171  // Finding next closest: find closest but further away than last closest
1172  if (pFindNext && (iWdt==-1) && (iHgt==-1))
1173  {
1174  iFartherThan = (pFindNext->GetX()-iX)*(pFindNext->GetX()-iX)+(pFindNext->GetY()-iY)*(pFindNext->GetY()-iY);
1175  pFindNext = nullptr;
1176  }
1177 
1178  // Scan all objects
1179  for (C4Object *cObj : Objects)
1180  {
1181  // Not skipping to find next
1182  if (!pFindNext)
1183  // Status
1184  if (cObj->Status)
1185  // ID
1186  if (!pDef || (cObj->Def == pDef))
1187  // OCF (match any specified)
1188  if (cObj->OCF & ocf)
1189  // Area
1190  {
1191  // Point
1192  if ((iWdt==0) && (iHgt==0))
1193  {
1194  if (Inside<int32_t>(iX-(cObj->GetX()+cObj->Shape.x),0,cObj->Shape.Wdt-1))
1195  if (Inside<int32_t>(iY-(cObj->GetY()+cObj->Shape.y),0,cObj->Shape.Hgt-1))
1196  return cObj;
1197  continue;
1198  }
1199  // Closest
1200  if ((iWdt==-1) && (iHgt==-1))
1201  {
1202  iDistance = (cObj->GetX()-iX)*(cObj->GetX()-iX)+(cObj->GetY()-iY)*(cObj->GetY()-iY);
1203  // same distance?
1204  if ((iDistance == iFartherThan) && !pFindNextCpy)
1205  return cObj;
1206  // nearer than/first closest?
1207  if (!pClosest || (iDistance < iClosest))
1208  if (iDistance > iFartherThan)
1209  { pClosest=cObj; iClosest=iDistance; }
1210  }
1211  // Range
1212  else if (Inside<int32_t>(cObj->GetX()-iX,0,iWdt-1) && Inside<int32_t>(cObj->GetY()-iY,0,iHgt-1))
1213  return cObj;
1214  }
1215 
1216  // Find next mark reached
1217  if (cObj == pFindNextCpy) pFindNext = pFindNextCpy = nullptr;
1218 
1219  }
1220 
1221  return pClosest;
1222 
1223 }
int32_t GetX() const
Definition: C4Object.h:287
int32_t Count
Definition: C4Def.h:179
int32_t GetY() const
Definition: C4Object.h:288
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindVisObject()

C4Object * C4Game::FindVisObject ( float  tx,
float  ty,
int32_t  iPlr,
const C4Facet fctViewportGame,
const C4Facet fctViewportGUI,
float  iX,
float  iY,
DWORD  category,
float  gui_x,
float  gui_y 
)

Definition at line 1225 of file C4Game.cpp.

References C4D_Foreground, C4D_MouseIgnore, C4OS_NORMAL, C4Player::Cursor, C4GameObjects::ForeObjects, C4PlayerList::Get(), C4Object::Layer, Objects, Players, C4Facet::X, and C4Facet::Y.

Referenced by C4MouseControl::GetTargetObject(), and HasScenario().

1227 {
1228  // FIXME: Use C4FindObject here for optimization
1229  // -- can't really do that, since sectors ignore parallaxity, etc.
1230  // determine layer to search in
1231  C4Object *layer_object = nullptr;
1232  C4Player *plr = ::Players.Get(iPlr);
1233  if (plr && plr->Cursor) layer_object = plr->Cursor->Layer;
1234  // scan all object lists separately
1236  while (pLst)
1237  {
1238  // Scan all objects in list
1239  for (C4Object *cObj : *pLst)
1240  {
1241  // Status
1242  if (cObj->Status == C4OS_NORMAL)
1243  // exclude fore-objects from main list
1244  if ((pLst != &Objects) || (~cObj->Category & C4D_Foreground))
1245  // exclude MouseIgnore-objects
1246  if (~cObj->Category & C4D_MouseIgnore)
1247  // Category (match any specified)
1248  if (cObj->Category & category)
1249  // Container
1250  if (!cObj->Contained)
1251  // Visibility
1252  if (cObj->IsVisible(iPlr, false))
1253  // Layer check: Layered objects are invisible to players whose cursor is in another layer
1254  // except for GUI: GUI always visible
1255  {
1256  if (cObj->Layer != layer_object)
1257  if (pLst != &::Objects.ForeObjects)
1258  continue;
1259  // Area
1260  // get object position
1261  float iObjX, iObjY, check_x, check_y;
1262  if (pLst == &::Objects.ForeObjects)
1263  {
1264  // object position for HUD object
1265  check_x = gui_x; check_y = gui_y;
1266  cObj->GetViewPos(iObjX, iObjY, -fctViewportGUI.X, -fctViewportGUI.Y, fctViewportGUI);
1267  }
1268  else
1269  {
1270  // object position for game object
1271  check_x = game_x; check_y = game_y;
1272  cObj->GetViewPos(iObjX, iObjY, tx, ty, fctViewportGame);
1273  }
1274  // Point search
1275  if (Inside<float>(check_x-(iObjX+cObj->Shape.x),0,float(cObj->Shape.Wdt)-1))
1276  if (Inside<float>(check_y-(iObjY+cObj->Shape.y-cObj->addtop()),0,float(cObj->Shape.Hgt+cObj->addtop()-1)))
1277  return cObj;
1278  }
1279  }
1280  // next list
1281  if (pLst == &::Objects.ForeObjects) pLst = &Objects;
1282  else pLst = nullptr;
1283  }
1284 
1285  // none found
1286  return nullptr;
1287 }
float Y
Definition: C4Facet.h:118
C4ObjectPtr Cursor
Definition: C4Player.h:130
#define C4OS_NORMAL
Definition: C4Object.h:35
C4ObjectPtr Layer
Definition: C4Object.h:136
C4Player * Get(int iPlayer) const
C4PlayerList Players
const int32_t C4D_MouseIgnore
Definition: C4Def.h:54
C4ObjectList ForeObjects
Definition: C4GameObjects.h:44
float X
Definition: C4Facet.h:118
const int32_t C4D_Foreground
Definition: C4Def.h:53
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FixRandom()

void C4Game::FixRandom ( uint64_t  iSeed)

Definition at line 3093 of file C4Game.cpp.

References FixedRandom().

Referenced by C4Landscape::Init(), InitControl(), LoadScenarioSection(), PreInit(), and Synchronize().

3094 {
3095  FixedRandom(iSeed);
3096 }
void FixedRandom(uint64_t seed)
Definition: C4Random.cpp:37
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GameOverCheck()

bool C4Game::GameOverCheck ( )
protected

Definition at line 670 of file C4Game.cpp.

References C4ST_NEW, Control, DoGameOver(), Game, GameOver, C4PlayerList::GetCountNotEliminated(), C4GameControl::isReplay(), iTick35, and Players.

Referenced by Execute().

671 {
672  bool fDoGameOver = false;
673 
674  // Only every 35 ticks
675  if (::Game.iTick35) return false;
676 
677  // do not GameOver in replay
678  if (Control.isReplay()) return false;
679 
680  // All players eliminated: game over
682  fDoGameOver=true;
683 
684  // Message
685  if (fDoGameOver) DoGameOver();
686 
687  return GameOver;
688 }
bool DoGameOver()
Definition: C4Game.cpp:3098
bool isReplay() const
Definition: C4GameControl.h:98
C4Game Game
Definition: C4Globals.cpp:52
int32_t iTick35
Definition: C4Game.h:130
int GetCountNotEliminated() const
bool GameOver
Definition: C4Game.h:114
C4GameControl Control
C4PlayerList Players
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTextSpecImageAspect()

float C4Game::GetTextSpecImageAspect ( const char *  szSpec)

Definition at line 3766 of file C4Game.cpp.

References C4Id2Def(), StdMesh::GetBoundingBox(), GetTextSpecFacet(), C4Def::Graphics, C4Rect::Hgt, C4Facet::Hgt, C4Def::PictureRect, C4DefGraphics::Type, C4DefGraphics::TYPE_Bitmap, C4DefGraphics::TYPE_Mesh, C4Rect::Wdt, C4Facet::Wdt, StdMeshBox::x1, StdMeshBox::x2, StdMeshBox::y1, and StdMeshBox::y2.

Referenced by HasScenario(), and C4DefList::Reload().

3767 {
3768  // safety
3769  assert(szSpec && *szSpec);
3770  if (!szSpec) return -1.0f;
3771 
3772  C4Facet fctSource;
3773  if(GetTextSpecFacet(szSpec, fctSource))
3774  {
3775  return static_cast<float>(fctSource.Wdt) / static_cast<float>(fctSource.Hgt);
3776  }
3777  else
3778  {
3779  C4Def *pDef = C4Id2Def(C4ID(szSpec));
3780  if (!pDef) return -1.0f;
3781 
3782  C4DefGraphics* pGfx = &pDef->Graphics;
3783  if(pGfx->Type == C4DefGraphics::TYPE_Bitmap)
3784  {
3785  return static_cast<float>(pDef->PictureRect.Wdt) / static_cast<float>(pDef->PictureRect.Hgt);
3786  }
3787  else if (pGfx->Type == C4DefGraphics::TYPE_Mesh)
3788  {
3789  const StdMesh& mesh = *pGfx->Mesh;
3790  const StdMeshBox& box = mesh.GetBoundingBox();
3791  return (box.x2 - box.x1) / (box.y2 - box.y1);
3792  }
3793 
3794  return -1.0f;
3795  }
3796 }
float y2
Definition: StdMesh.h:147
C4Rect PictureRect
Definition: C4Def.h:107
float x2
Definition: StdMesh.h:147
const StdMeshBox & GetBoundingBox() const
Definition: StdMesh.h:206
bool GetTextSpecFacet(const char *szSpec, C4Facet &fct)
Definition: C4Game.cpp:3724
int32_t Wdt
Definition: C4Rect.h:30
float y1
Definition: StdMesh.h:146
Definition: C4Def.h:98
Definition: C4Id.h:25
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
float Hgt
Definition: C4Facet.h:118
GraphicsType Type
Definition: C4DefGraphics.h:48
float x1
Definition: StdMesh.h:146
int32_t Hgt
Definition: C4Rect.h:30
float Wdt
Definition: C4Facet.h:118
C4DefGraphics Graphics
Definition: C4Def.h:191
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTranslatedString()

C4String * C4Game::GetTranslatedString ( const class C4Value input_string,
C4Value selected_language,
bool  fail_silently 
) const

Definition at line 3897 of file C4Game.cpp.

References C4Value::_getPropList(), C4Value::_getStr(), C4V_Nil, C4V_String, Config, C4StringTable::FindString(), FormatString(), C4Config::General, StdStrBuf::getData(), C4Value::GetDataString(), C4PropList::GetPropertyByS(), C4PropList::GetPropertyStr(), C4PropList::GetSortedLocalProperties(), C4Value::getStr(), C4Value::GetType(), C4ConfigGeneral::LanguageEx, C4StringTable::P, P_Function, P_Translate, SCopySegment(), C4Value::SetString(), and Strings.

3898 {
3899  // Resolve a localized string
3900  // If a string is passed, just return it
3901  // If a proplist like { DE="Hallo, Welt!", US="Hello, world!" } is passed, return the string matching the selected language
3902  // Nothing?
3903  if (input_string.GetType() == C4V_Nil)
3904  {
3905  return nullptr;
3906  }
3907  // Non-localized string?
3908  if (input_string.GetType() == C4V_String)
3909  {
3910  return input_string._getStr();
3911  }
3912  // Invalid type for this function?
3913  C4PropList *p = input_string._getPropList();
3914  if (!p || p->GetPropertyStr(P_Function) != &::Strings.P[P_Translate])
3915  {
3916  if (fail_silently)
3917  {
3918  return nullptr;
3919  }
3920  else
3921  {
3922  throw C4AulExecError(FormatString("Invalid value for translation: %s", input_string.GetDataString().getData()).getData());
3923  }
3924  }
3925  // This is a proplist. Resolve the language as the key.
3926  char lang_code[3] = "";
3927  for (int32_t lang_index = 0; SCopySegment(Config.General.LanguageEx, lang_index, lang_code, ',', 2); ++lang_index)
3928  {
3929  C4String *lang_string = ::Strings.FindString(lang_code);
3930  if (lang_string) // If the string is not found, it cannot be the key in a prop list
3931  {
3932  C4Value localized_string_val;
3933  if (p->GetPropertyByS(lang_string, &localized_string_val))
3934  {
3935  C4String *localized_string = localized_string_val.getStr();
3936  if (localized_string)
3937  {
3938  // Found it!
3939  if (selected_language)
3940  {
3941  selected_language->SetString(lang_string);
3942  }
3943  return localized_string;
3944  }
3945  }
3946  }
3947  }
3948  // No language matched. Just use any property and assume it's a language key.
3949  for (C4String *lang_string : p->GetSortedLocalProperties(false))
3950  {
3951  C4Value localized_string_val;
3952  if (p->GetPropertyByS(lang_string, &localized_string_val))
3953  {
3954  C4String *localized_string = localized_string_val.getStr();
3955  if (localized_string)
3956  {
3957  // Found it!
3958  if (selected_language)
3959  {
3960  selected_language->SetString(lang_string);
3961  }
3962  return localized_string;
3963  }
3964  }
3965  }
3966  // No string properties. There's no localized information to be found.
3967  return nullptr;
3968 }
C4String P[P_LAST]
C4Config Config
Definition: C4Config.cpp:833
C4String * getStr() const
Definition: C4Value.h:117
C4ConfigGeneral General
Definition: C4Config.h:251
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:775
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:273
void SetString(C4String *Str)
Definition: C4Value.h:138
C4StringTable Strings
Definition: C4Globals.cpp:42
char LanguageEx[CFG_MaxString+1]
Definition: C4Config.h:37
std::vector< C4String *> GetSortedLocalProperties(bool add_prototype=true) const
Definition: C4PropList.cpp:576
C4String * FindString(const char *strString) const
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:757
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
Here is the call graph for this function:

◆ GRBroadcast()

C4Value C4Game::GRBroadcast ( const char *  szFunction,
C4AulParSet pPars = nullptr,
bool  fPassError = false,
bool  fRejectTest = false 
)

Definition at line 3853 of file C4Game.cpp.

References C4GameScriptHost::Call(), GameScript, C4GameObjects::GRBroadcast(), and Objects.

Referenced by C4Object::AssignDeath(), DoGameOver(), HasScenario(), C4Player::Init(), LoadScenarioSection(), OnPlayerJoinFinished(), C4PlayerList::Remove(), C4Player::ScenarioInit(), and C4Player::SetWealth().

3854 {
3855  std::string func{ szFunction };
3856  if (func[0] != '~')
3857  func.insert(0, 1, '~');
3858 
3859  // call objects first - scenario script might overwrite hostility, etc...
3860  C4Value vResult = ::Objects.GRBroadcast(func.c_str(), pPars, fPassError, fRejectTest);
3861  // rejection tests abort on first nonzero result
3862  if (fRejectTest) if (!!vResult) return vResult;
3863  // scenario script call
3864  return ::GameScript.Call(func.c_str(), pPars, fPassError);
3865 }
C4GameScriptHost GameScript
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars, bool fPassError, bool fRejectTest)
C4Value Call(const char *szFunction, C4AulParSet *pPars=nullptr, bool fPassError=false)
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasScenario()

bool C4Game::HasScenario ( )
inline

Definition at line 163 of file C4Game.h.

References CanQuickSave(), CastObjects(), ClearPointers(), CreateInfoObject(), CreateObject(), CreateObjectConstruction(), CreateSectionFromTempFile(), DoGameOver(), DrawPropListSpecImage(), DrawTextSpecImage(), DropDef(), DropFile(), Execute(), FindConstuctionSiteBlock(), FindObject(), FindVisObject(), Fix0, StdStrBuf::getSize(), GetTextSpecImageAspect(), GRBroadcast(), InitFullscreenComponents(), InitKeyboard(), InitPlayerControlSettings(), InitPlayerControlUserSettings(), IsPaused(), JoinPlayer(), LoadScenarioSection(), NO_OWNER, ObjectCount(), OCF_All, OnKeyboardLayoutChanged(), OnPlayerJoinFinished(), OnResolutionChanged(), Pause(), PlaceAnimal(), PlaceVegetation(), QuickSave(), ReloadDef(), ReloadFile(), ReloadParticle(), SetDefaultGamma(), SetInitProgress(), SlowDown(), SpeedUp(), SyncClearance(), Synchronize(), ToggleChat(), TogglePause(), Unpause(), and UpdateLanguage().

Referenced by C4Application::ParseCommandLine(), and C4Application::PreInit().

char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:102
size_t getSize() const
Definition: StdBuf.h:444
StdStrBuf RecordStream
Definition: C4Game.h:126
char DirectJoinAddress[_MAX_PATH+1]
Definition: C4Game.h:106
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

bool C4Game::Init ( )

Definition at line 328 of file C4Game.cpp.

References C4Value::_getPropList(), _MAX_PATH, C4GameParameters::AllowDebug, C4ConfigGeneral::AlwaysDebug, Application, C4S, C4FullScreen::CloseMenu(), Config, Console, StdStrBuf::Copy(), DebugMode, DirectJoinAddress, DirectJoinFilePrefix, C4Scoreboard::DoDlgShow(), C4Network2::DoLobby(), Extra, C4Network2::FinalInit(), fQuitWithError, FullScreen, C4GameParameters::GameRes, C4Config::General, GetLogPos(), GlobalSoundModifier, GraphicsSystem, C4Scenario::Head, IM_Normal, C4Extra::Init(), InitFullscreenComponents(), C4Console::InitGame(), InitGame(), InitGameFinal(), InitKeyboard(), C4GraphicsSystem::InitLoaderScreen(), InitNetworkFromAddress(), InitNetworkFromReference(), InitNetworkFromReferenceFile(), InitNetworkHost(), InitPlayers(), InitProgress, C4GraphicsSystem::InvalidateBg(), C4Application::isEditor, C4Network2::isEnabled(), C4Network2::isLobbyActive(), IsRunning, LastInitProgress, C4SHead::Loader, LoadResStr(), Log(), LogFatal(), Network, C4SHead::NetworkGame, OpenScenario(), Parameters, C4ConfigGeneral::Participants, pGUI, pJoinReference, PlayerFilenames, C4GraphicsSystem::pLoaderScreen, pNetworkStatistics, C4GameResList::RetrieveFiles(), C4Network2::RetrieveScenario(), C4SHead::SaveGame, ScenarioFile, ScenarioFilename, SCopy(), Scoreboard, SEqual2(), C4GUI::Screen::SetExclusive(), SetGlobalSoundModifier(), SetInitProgress(), StartTime, StartupLogPos, SyncClearance(), Synchronize(), TempScenarioFile, C4Startup::Unload(), and C4GameLobby::UserAbort.

Referenced by C4Application::GameTick().

329 {
330  C4ValueNumbers numbers;
331  IsRunning = false;
332 
334  SetInitProgress(0);
335 
336  // reinit keyboard to reflect any config changes that might have been done
337  // this is a good time to do it, because no GUI dialogs are opened
338  if (!InitKeyboard()) LogFatal(LoadResStr("IDS_ERR_NOKEYBOARD"));
339 
340  // start log pos (used by startup)
342  fQuitWithError = false;
343  C4GameLobby::UserAbort = false;
344 
345  // Store a start time that identifies this game on this host
346  StartTime = time(nullptr);
347 
348  // Get PlayerFilenames from Config, if ParseCommandLine did not fill some in
349  // Must be done here, because InitGame calls PlayerInfos.InitLocal
350  if (!*PlayerFilenames)
351  {
353  }
354 
355  // Join a game?
357  {
358 
360  {
361  // init extra; needed for loader screen
362  Log(LoadResStr("IDS_PRC_INITEXTRA"));
363  if (!Extra.Init())
364  { LogFatal(LoadResStr("IDS_PRC_ERREXTRA")); return false; }
365 
366  // init loader
368  { LogFatal(LoadResStr("IDS_PRC_ERRLOADER")); return false; }
369  }
370 
371  SetInitProgress(5);
372 
373  // Initialize network
374  if (pJoinReference)
375  {
376  // By reference
377  bool fSuccess = InitNetworkFromReference(*pJoinReference);
378  pJoinReference.reset();
379  if (!fSuccess)
380  return false;
381  }
383  {
384  // By reference serialized to temp file
386  return false;
387  }
388  else
389  {
390  // By address
392  return false;
393  }
394 
395  // check wether console mode is allowed
397  { LogFatal(LoadResStr("IDS_TEXT_JOININCONSOLEMODENOTALLOW")); return false; }
398 
399  // do lobby (if desired)
400  if (Network.isLobbyActive())
401  if (!Network.DoLobby())
402  return false;
403 
404  // get scenario
405  char szScenario[_MAX_PATH+1];
406  SetInitProgress(6);
407  if (!Network.RetrieveScenario(szScenario)) return false;
408 
409  // open new scenario
410  SCopy(szScenario, ScenarioFilename, _MAX_PATH);
411  if (!OpenScenario()) return false;
413 
414  // get everything else
415  if (!Parameters.GameRes.RetrieveFiles()) return false;
416 
417  // Check network game data scenario type (safety)
418  if (!C4S.Head.NetworkGame)
419  { LogFatal(LoadResStr("IDS_NET_NONETGAME")); return false; }
420 
421  SetInitProgress(7);
422 
423  }
424 
425  // Local game or host?
426  else
427  {
428 
429  // Open scenario
430  if (!OpenScenario())
431  { LogFatal(LoadResStr("IDS_PRC_FAIL")); return false; }
432 
433  // init extra; needed for loader screen
434  Log(LoadResStr("IDS_PRC_INITEXTRA"));
435  if (!Extra.Init())
436  { LogFatal(LoadResStr("IDS_PRC_ERREXTRA")); return false; }
437 
438  // init loader
440  { LogFatal(LoadResStr("IDS_PRC_ERRLOADER")); return false; }
441 
442  // Init network
443  if (!InitNetworkHost()) return false;
444  SetInitProgress(7);
445 
446  }
447 
448  // now free all startup gfx to make room for game gfx
450 
451  // Init debugmode
454  DebugMode = true;
455  if (!Parameters.AllowDebug)
456  DebugMode = false;
457 
458  // Init game
459  if (!InitGame(ScenarioFile, IM_Normal, true, &numbers)) return false;
460 
461  // Network final init
462  if (Network.isEnabled())
463  {
464  if (!Network.FinalInit()) return false;
465  }
466  // non-net may have to synchronize now to keep in sync with replays
467  // also needs to synchronize to update transfer zones
468  else
469  {
470  // - would kill DebugRec-sync for runtime debugrec starts
471  C4DebugRecOff DBGRECOFF(!!C4S.Head.SaveGame);
472  SyncClearance();
473  Synchronize(false);
474  }
475 
476  // Init players
477  if (!InitPlayers(&numbers)) return false;
478  SetInitProgress(98);
479 
480  // Final init
481  if (!InitGameFinal(IM_Normal)) return false;
482  SetInitProgress(99);
483 
484  // Sound modifier from savegames
486 
487  // Message board and upper board
488  if (!Application.isEditor)
489  {
491  }
492 
493  // Default fullscreen menu, in case any old surfaces are left (extra safety)
495 
496  // start statistics (always for now. Make this a config?)
497  pNetworkStatistics = std::make_unique<C4Network2Stats>();
498 
499  // clear loader screen
501  {
504  }
505 
506  // game running now!
507  IsRunning = true;
508 
509  // Start message
510  Log(LoadResStr(C4S.Head.NetworkGame ? "IDS_PRC_JOIN" : C4S.Head.SaveGame ? "IDS_PRC_RESUME" : "IDS_PRC_START"));
511 
512  // set non-exclusive GUI
513  pGUI->SetExclusive(false);
514 
515  // after GUI is made non-exclusive, recheck the scoreboard
516  Scoreboard.DoDlgShow(0, false);
517  SetInitProgress(100);
518 
519  // and redraw background
521 
522  // Notify editor
523  Console.InitGame();
524 
525  return true;
526 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3386
bool IsRunning
Definition: C4Game.h:140
bool InitGame(C4Group &hGroup, InitMode init_mode, bool fLoadSky, C4ValueNumbers *)
Definition: C4Game.cpp:2101
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:102
StdStrBuf TempScenarioFile
Definition: C4Game.h:127
C4Config Config
Definition: C4Config.cpp:833
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
std::unique_ptr< C4Network2Reference > pJoinReference
Definition: C4Game.h:108
C4Value & GlobalSoundModifier
Definition: C4Game.h:99
C4Console Console
Definition: C4Globals.cpp:45
void SyncClearance()
Definition: C4Game.cpp:3132
std::string Loader
Definition: C4Scenario.h:65
C4Scenario C4S
Definition: C4Game.h:74
bool FinalInit()
Definition: C4Network2.cpp:537
C4ConfigGeneral General
Definition: C4Config.h:251
static constexpr const char * DirectJoinFilePrefix
Definition: C4Game.h:296
bool isEnabled() const
Definition: C4Network2.h:203
void DoDlgShow(int32_t iChange, bool fUserToggle)
static void Unload()
Definition: C4Startup.cpp:301
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
int32_t LastInitProgress
Definition: C4Game.h:134
C4Scoreboard Scoreboard
Definition: C4Game.h:94
#define _MAX_PATH
bool InitPlayers(C4ValueNumbers *)
Definition: C4Game.cpp:2451
C4GameParameters & Parameters
Definition: C4Game.h:67
bool InitNetworkFromReferenceFile(const char *temp_filename)
Definition: C4Game.cpp:3214
bool OpenScenario()
Definition: C4Game.cpp:165
bool InitNetworkHost()
Definition: C4Game.cpp:3257
C4PropList * _getPropList() const
Definition: C4Value.h:129
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
size_t StartupLogPos
Definition: C4Game.h:142
int32_t InitProgress
Definition: C4Game.h:134
bool SaveGame
Definition: C4Scenario.h:71
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1191
C4Network2 Network
Definition: C4Globals.cpp:53
int32_t StartTime
Definition: C4Game.h:133
bool InitLoaderScreen(const char *szLoaderSpec)
char Participants[CFG_MaxString+1]
Definition: C4Config.h:38
bool Init()
Definition: C4Extra.cpp:41
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
C4GameResList GameRes
C4Group ScenarioFile
Definition: C4Game.h:86
bool NetworkGame
Definition: C4Scenario.h:78
void SetExclusive(bool fToState)
Definition: C4Gui.h:2666
bool fQuitWithError
Definition: C4Game.h:143
void SetGlobalSoundModifier(C4PropList *modifier_props)
Definition: C4Game.cpp:3880
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:237
bool InitNetworkFromReference(const C4Network2Reference &Reference)
Definition: C4Game.cpp:3232
C4LoaderScreen * pLoaderScreen
size_t GetLogPos()
Definition: C4Log.cpp:296
bool InitNetworkFromAddress(const char *szAddress)
Definition: C4Game.cpp:3161
void InitFullscreenComponents(bool fRunning)
Definition: C4Game.cpp:785
char PlayerFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:104
void InitGame()
Definition: C4Console.cpp:590
bool InitKeyboard()
Definition: C4Game.cpp:2933
int32_t AlwaysDebug
Definition: C4Config.h:39
bool RetrieveScenario(char *szScenario)
Definition: C4Network2.cpp:589
void Synchronize(bool fSavePlayerFiles)
Definition: C4Game.cpp:3137
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
bool DoLobby()
Definition: C4Network2.cpp:432
bool SEqual2(const char *szStr1, const char *szStr2)
Definition: Standard.cpp:198
C4SHead Head
Definition: C4Scenario.h:232
bool InitGameFinal(InitMode init_mode)
Definition: C4Game.cpp:2330
char DirectJoinAddress[_MAX_PATH+1]
Definition: C4Game.h:106
C4Extra Extra
Definition: C4Game.h:89
std::unique_ptr< C4Network2Stats > pNetworkStatistics
Definition: C4Game.h:95
void Copy()
Definition: StdBuf.h:467
C4Application Application
Definition: C4Globals.cpp:44
bool isLobbyActive() const
Definition: C4Network2.h:204
bool DebugMode
Definition: C4Game.h:145
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitAnimals()

void C4Game::InitAnimals ( )
protected

Definition at line 2841 of file C4Game.cpp.

References C4Scenario::Animals, C4Id2Def(), C4S, C4SAnimals::EarthNest, C4SAnimals::FreeLife, C4IDList::GetID(), PlaceAnimal(), and PlaceInEarth().

2842 {
2843  int32_t cnt,cnt2;
2844  C4ID idAnimal; int32_t iCount;
2845  // Place animals
2846  for (cnt=0; (idAnimal=C4S.Animals.FreeLife.GetID(cnt,&iCount)); cnt++)
2847  for (cnt2=0; cnt2<iCount; cnt2++)
2848  PlaceAnimal(C4Id2Def(idAnimal));
2849  // Place nests
2850  for (cnt=0; (idAnimal=C4S.Animals.EarthNest.GetID(cnt,&iCount)); cnt++)
2851  for (cnt2=0; cnt2<iCount; cnt2++)
2852  PlaceInEarth(idAnimal);
2853 }
C4Scenario C4S
Definition: C4Game.h:74
bool PlaceInEarth(C4ID id)
Definition: C4Game.cpp:2605
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
C4Object * PlaceAnimal(C4PropList *def)
Definition: C4Game.cpp:2775
Definition: C4Id.h:25
C4SAnimals Animals
Definition: C4Scenario.h:237
C4IDList EarthNest
Definition: C4Scenario.h:212
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
C4IDList FreeLife
Definition: C4Scenario.h:211
Here is the call graph for this function:

◆ InitControl()

bool C4Game::InitControl ( )
protected

Definition at line 2536 of file C4Game.cpp.

References C4S, Clients, Control, C4GameParameters::doStreaming(), FixRandom(), C4ClientList::getLocal(), C4Scenario::Head, C4GameControl::InitLocal(), C4GameControl::InitNetwork(), C4GameControl::InitReplay(), C4Network2::isEnabled(), C4Network2::isHost(), C4GameParameters::isLeague(), LoadResStr(), Log(), LogFatal(), Network, C4SHead::NetworkGame, Parameters, PlayerFilenames, C4SHead::RandomSeed, RandomSeed, Record, C4SHead::Replay, ScenarioFile, and C4GameControl::StartRecord().

2537 {
2538  // update random seed
2539  if (C4S.Head.NetworkGame || C4S.Head.Replay)
2540  {
2542  }
2543  // Randomize
2545 
2546  // Replay?
2547  if (C4S.Head.Replay)
2548  {
2549  // no joins
2550  PlayerFilenames[0]=0;
2551  // start playback
2553  return false;
2554  // no record!
2555  Record = false;
2556  }
2557  else if (Network.isEnabled())
2558  {
2559  // initialize
2561  return false;
2562  // league? always record
2563  if (Parameters.isLeague())
2564  Record = true;
2565  }
2566  // Otherwise: local game
2567  else
2568  {
2569  // init
2571  return false;
2572  }
2573 
2574  // record?
2575  if (Record)
2576  if (!Control.StartRecord(true, Parameters.doStreaming()))
2577  {
2578  // Special: If this happens for a league host, the game must not start.
2580  {
2581  LogFatal(LoadResStr("IDS_ERR_NORECORD"));
2582  return false;
2583  }
2584  else
2585  {
2586  Log(LoadResStr("IDS_ERR_NORECORD"));
2587  }
2588  }
2589 
2590  return true;
2591 }
int32_t RandomSeed
Definition: C4Game.h:135
C4Scenario C4S
Definition: C4Game.h:74
bool Replay
Definition: C4Scenario.h:72
bool isEnabled() const
Definition: C4Network2.h:203
bool InitNetwork(C4Client *pLocal)
C4Client * getLocal() const
Definition: C4Client.h:161
bool InitLocal(C4Client *pLocal)
bool InitReplay(C4Group &rGroup)
C4GameParameters & Parameters
Definition: C4Game.h:67
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void FixRandom(uint64_t iSeed)
Definition: C4Game.cpp:3093
C4Network2 Network
Definition: C4Globals.cpp:53
C4GameControl Control
bool isLeague() const
C4Group ScenarioFile
Definition: C4Game.h:86
bool NetworkGame
Definition: C4Scenario.h:78
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:237
bool doStreaming() const
bool isHost() const
Definition: C4Network2.h:209
char PlayerFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:104
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
C4ClientList & Clients
Definition: C4Game.h:69
bool Record
Definition: C4Game.h:124
bool StartRecord(bool fInitial, bool fStreaming)
C4SHead Head
Definition: C4Scenario.h:232
int32_t RandomSeed
Definition: C4Scenario.h:74
Here is the call graph for this function:

◆ InitDefs()

bool C4Game::InitDefs ( )
protected

Definition at line 120 of file C4Game.cpp.

References C4DefList::AppendAndIncludeSkeletons(), Application, C4DefList::BuildTable(), C4D_Load_RX, C4DefList::CheckEngineVersion(), C4DefList::CheckRequireDef(), Config, Definitions, C4GameParameters::GameRes, C4Config::General, C4GameRes::getFile(), C4GameResList::iterRes(), C4ConfigGeneral::LanguageEx, C4DefList::Load(), C4DefList::LoadFailure, LoadResStr(), Log(), LogF(), LogFatal(), NRT_Definitions, Parameters, ScenarioFile, and C4Application::SoundSystem.

121 {
122  int32_t iDefs=0;
123  Log(LoadResStr("IDS_PRC_INITDEFS"));
124  int iDefResCount = 0;
125  C4GameRes *pDef;
126  for (pDef = Parameters.GameRes.iterRes(nullptr, NRT_Definitions); pDef; pDef = Parameters.GameRes.iterRes(pDef, NRT_Definitions))
127  ++iDefResCount;
128  int i = 0;
129  // Load specified defs
130  for (pDef = Parameters.GameRes.iterRes(nullptr, NRT_Definitions); pDef; pDef = Parameters.GameRes.iterRes(pDef, NRT_Definitions))
131  {
132  int iMinProgress = 25 + (25 * i) / iDefResCount;
133  int iMaxProgress = 25 + (25 * (i + 1)) / iDefResCount;
134  ++i;
135  iDefs+=::Definitions.Load(pDef->getFile(),C4D_Load_RX,Config.General.LanguageEx,&Application.SoundSystem,true,iMinProgress,iMaxProgress);
136 
137  // Def load failure
138  if (::Definitions.LoadFailure) return false;
139  }
140 
141  // Load for scenario file - ignore sys group here, because it has been loaded already
143 
144  // Absolutely no defs: we don't like that
145  if (!iDefs) { LogFatal(LoadResStr("IDS_PRC_NODEFS")); return false; }
146 
147  // Check def engine version (should be done immediately on def load)
148  iDefs=::Definitions.CheckEngineVersion(C4XVER1,C4XVER2);
149  if (iDefs>0) { LogF(LoadResStr("IDS_PRC_DEFSINVC4X"),iDefs); }
150 
151  // Check for unmet requirements
153 
154  // build quick access table
156 
157  // handle skeleton appends and includes
159 
160  // Done
161  return true;
162 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
C4Config Config
Definition: C4Config.cpp:833
C4GameRes * iterRes(C4GameRes *pLast, C4Network2ResType eType=NRT_Null)
C4ConfigGeneral General
Definition: C4Config.h:251
void BuildTable()
Definition: C4DefList.cpp:514
C4GameParameters & Parameters
Definition: C4Game.h:67
const char * getFile() const
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
const DWORD C4D_Load_RX
Definition: C4Def.h:91
void AppendAndIncludeSkeletons()
Definition: C4DefList.cpp:521
int32_t CheckRequireDef()
Definition: C4DefList.cpp:384
C4GameResList GameRes
C4Group ScenarioFile
Definition: C4Game.h:86
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:237
char LanguageEx[CFG_MaxString+1]
Definition: C4Config.h:37
int32_t Load(C4Group &hGroup, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem=nullptr, bool fOverload=false, bool fSearchMessage=false, int32_t iMinProgress=0, int32_t iMaxProgress=0, bool fLoadSysGroups=true)
Definition: C4DefList.cpp:71
bool LoadFailure
Definition: C4DefList.h:31
int32_t CheckEngineVersion(int32_t ver1, int32_t ver2)
Definition: C4DefList.cpp:365
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
C4DefList Definitions
Definition: C4Globals.cpp:49
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:260
C4Application Application
Definition: C4Globals.cpp:44
Here is the call graph for this function:

◆ InitEnvironment()

void C4Game::InitEnvironment ( )
protected

Definition at line 3356 of file C4Game.cpp.

References C4S, CreateObject(), C4Scenario::Environment, C4IDList::GetID(), and C4SEnvironment::Objects.

3357 {
3358  // Place environment objects
3359  int32_t cnt,cnt2;
3360  C4ID idType; int32_t iCount;
3361  for (cnt=0; (idType=C4S.Environment.Objects.GetID(cnt,&iCount)); cnt++)
3362  for (cnt2=0; cnt2<iCount; cnt2++)
3363  CreateObject(idType,nullptr);
3364 }
C4IDList Objects
Definition: C4Scenario.h:221
C4SEnvironment Environment
Definition: C4Scenario.h:239
C4Scenario C4S
Definition: C4Game.h:74
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
Definition: C4Id.h:25
C4Object * CreateObject(C4PropList *type, C4Object *pCreator, int32_t owner=NO_OWNER, int32_t x=50, int32_t y=50, int32_t r=0, bool grow_from_center=false, C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t iController=NO_OWNER)
Definition: C4Game.cpp:1072
Here is the call graph for this function:

◆ InitFullscreenComponents()

void C4Game::InitFullscreenComponents ( bool  fRunning)

Definition at line 785 of file C4Game.cpp.

References C4UpperBoardHeight, FullScreen, C4GUI::GetScreenHgt(), C4GUI::GetScreenWdt(), GraphicsResource, GraphicsSystem, C4UpperBoard::Init(), C4GraphicsResource::IsInitialized(), C4GraphicsSystem::MessageBoard, C4Window::pSurface, C4ViewportList::RecalculateViewports(), C4Facet::Set(), C4GraphicsSystem::UpperBoard, and Viewports.

Referenced by HasScenario(), Init(), and OnResolutionChanged().

786 {
787  // It can happen that this is called before graphics are loaded due to
788  // an early OnResolutionChanged() call. Ignore it, the message board,
789  // upper board and viewports will be initialized within the regular
790  // startup sequence then.
791  if(!GraphicsResource.IsInitialized()) return;
792 
793  // fullscreen message board
794  C4Facet cgo;
796  GraphicsSystem.MessageBoard->Init(cgo, !fRunning);
797  if (fRunning)
798  {
799  // running game: Message board upper board and viewports
800  C4Facet cgo2;
804  }
805 }
void RecalculateViewports()
Definition: C4Viewport.cpp:989
C4Surface * pSurface
Definition: C4Window.h:275
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
int32_t GetScreenWdt()
Definition: C4Gui.h:2821
const int C4UpperBoardHeight
Definition: C4Constants.h:59
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
C4GraphicsResource GraphicsResource
C4UpperBoard UpperBoard
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
int32_t GetScreenHgt()
Definition: C4Gui.h:2822
void Init(C4Facet &cgo)
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
std::unique_ptr< C4MessageBoard > MessageBoard
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitGame()

bool C4Game::InitGame ( C4Group hGroup,
InitMode  init_mode,
bool  fLoadSky,
C4ValueNumbers numbers 
)
protected

Definition at line 2101 of file C4Game.cpp.

References Application, C4ConfigDeveloper::AutoFileReload, Config, DebugHost, DebugPassword, DebugPort, C4Config::Developer, StdStrBuf::getData(), IM_Normal, C4AulDebug::InitDebug(), C4Application::isEditor, C4GameParameters::isLeague(), Log(), Parameters, and pFileMonitor.

Referenced by Init(), and LoadScenarioSection().

2102 {
2103  // Activate debugger if requested
2104  // needs to happen before any scripts are compiled to bytecode so AB_DEBUG chunks will be inserted
2105  if (DebugPort)
2106  {
2107  if (Parameters.isLeague())
2108  Log("Debugger disabled. Not allowed in league.");
2109  else
2111  return false;
2112  }
2113 
2114  if (init_mode == IM_Normal)
2115  {
2116 
2117  // file monitor
2119  pFileMonitor = std::make_unique<C4FileMonitor>(FileMonitorCallback);
2120 
2121  // system scripts
2122  if (!InitScriptEngine())
2123  { LogFatal(LoadResStr("IDS_PRC_FAIL")); return false; }
2124  SetInitProgress(8);
2125 
2126  // Scenario components
2127  if (!LoadScenarioComponents())
2128  { LogFatal(LoadResStr("IDS_PRC_FAIL")); return false; }
2129  SetInitProgress(9);
2130 
2131  // join local players for regular games
2132  // should be done before record/replay is initialized, so the players are stored in PlayerInfos.txt
2133  // for local savegame resumes, players are joined into PlayerInfos and later associated in InitPlayers
2134  if (!::Network.isEnabled())
2135  if (!PlayerInfos.InitLocal())
2136  { LogFatal(LoadResStr("IDS_PRC_FAIL")); return false; }
2137 
2138  // for replays, make sure teams are assigned correctly
2139  if (C4S.Head.Replay)
2140  {
2141  PlayerInfos.RecheckAutoGeneratedTeams(); // checks that all teams used in playerinfos exist
2142  Teams.RecheckPlayers(); // syncs player list of teams with teams set in PlayerInfos
2143  }
2144 
2145  // set up control (inits Record/Replay)
2146  if (!InitControl()) return false;
2147 
2148  // Graphics and fonts (may reinit main font, too)
2149  // redundant call in NETWORK2; but it may do scenario local overloads
2150  Log(LoadResStr("IDS_PRC_GFXRES"));
2151  if (!GraphicsResource.Init())
2152  { LogFatal(LoadResStr("IDS_PRC_FAIL")); return false; }
2153  SetInitProgress(25);
2154 
2155  // Definitions
2156  if (!InitDefs()) return false;
2157  SetInitProgress(55);
2158 
2159  // Scenario scripts (and local system.ocg)
2161  // Map scripts
2163  // Scenario objects
2165  // After defs to get overloading priority
2167  { LogFatal(LoadResStr("IDS_PRC_FAIL")); return false; }
2168  SetInitProgress(57);
2169 
2170  // Final init for loaded player commands. Before linking scripts, so CON_* constants are registered
2172 
2173  // Register constants for scenario options
2175 
2176  // Now that all controls and assignments are known, resolve user overloads on control assignments
2177  if (!InitPlayerControlUserSettings()) return false;
2178  // Sort assignments by priority. Should be done last, because the user should not see this order in the control config dialog
2180  // (Theoretically, PlayerControlDefaultAssignmentSets could be cleared now. However, the amount of memory used is negligible)
2181 
2182  // Link scripts
2183  if (!LinkScriptEngine()) return false;
2184  SetInitProgress(58);
2185 
2186  // Materials
2187  if (!InitMaterialTexture())
2188  { LogFatal(LoadResStr("IDS_PRC_MATERROR")); return false; }
2189  SetInitProgress(60);
2190 
2191  // prepare script menus
2192  assert(!ScriptGuiRoot);
2193  ScriptGuiRoot = std::make_unique<C4ScriptGuiWindow>();
2194  }
2195  else if (fLoadSky)
2196  {
2197  // Sky needs graphics loaded, for shaders
2198  if (!GraphicsResource.Init())
2199  { LogFatal(LoadResStr("IDS_PRC_FAIL")); return false; }
2200  }
2201 
2202  // Load section sounds
2203  Application.SoundSystem.LoadEffects(hGroup, nullptr, true);
2204 
2205  // determine startup player and team count, which may be used for initial map generation
2206  if (!FrameCounter)
2207  {
2210  }
2211 
2212  // The Landscape is the last long chunk of loading time, so it's a good place to start the music fadeout
2213  if (init_mode == IM_Normal) Application.MusicSystem.FadeOut(2000);
2214  // Landscape
2215  Log(LoadResStr("IDS_PRC_LANDSCAPE"));
2216  bool fLandscapeLoaded = false;
2217  if (!Landscape.Init(hGroup, init_mode != IM_Normal, fLoadSky, fLandscapeLoaded, !!C4S.Head.SaveGame))
2218  { LogFatal(LoadResStr("IDS_ERR_GBACK")); return false; }
2219  SetInitProgress(88);
2220  // the savegame flag is set if runtime data is present, in which case this is to be used
2221  // except for scenario sections
2222  if (fLandscapeLoaded && (!C4S.Head.SaveGame || init_mode == IM_Section))
2224  // clear old landscape data
2225  if (init_mode != IM_Normal && fLandscapeLoaded) { PXS.Clear(); MassMover.Clear(); }
2226  SetInitProgress(89);
2227  // Init main object list
2229 
2230  // Pathfinder
2231  if (init_mode == IM_Normal) PathFinder.Init( &LandscapeFree, &TransferZones );
2232  SetInitProgress(90);
2233 
2234  // PXS
2235  if (hGroup.FindEntry(C4CFN_PXS))
2236  if (!PXS.Load(hGroup))
2237  { LogFatal(LoadResStr("IDS_ERR_PXS")); return false; }
2238  SetInitProgress(91);
2239 
2240  // MassMover
2241  if (hGroup.FindEntry(C4CFN_MassMover))
2242  if (!MassMover.Load(hGroup))
2243  { LogFatal(LoadResStr("IDS_ERR_MOVER")); return false; }
2244  SetInitProgress(92);
2245 
2246  // definition value overloads
2247  // TODO: Remove this function? We could move value to script and allow it through regular overloads
2248  if (init_mode == IM_Normal) InitValueOverloads();
2249 
2250  // runtime data
2251  if (!CompileRuntimeData(hGroup, init_mode, C4S.Head.SaveGame, C4S.Head.NetworkGame, numbers))
2252  { LogFatal(LoadResStr("IDS_PRC_FAIL")); return false; }
2253 
2254  SetInitProgress(93);
2255 
2256  // Load round results
2257  if (init_mode == IM_Normal)
2258  {
2259  if (hGroup.FindEntry(C4CFN_RoundResults))
2260  {
2261  if (!RoundResults.Load(hGroup, C4CFN_RoundResults))
2262  { LogFatal(LoadResStr("IDS_ERR_ERRORLOADINGROUNDRESULTS")); return false; }
2263  }
2264  else
2265  {
2266  RoundResults.Init();
2267  }
2268  // Per-scenario flag, ignored in sections.
2270  }
2271 
2272  // Denumerate game data pointers
2273  if (init_mode == IM_Normal) ScriptEngine.Denumerate(numbers);
2274  if (init_mode == IM_Normal) GlobalSoundModifier.Denumerate(numbers);
2275  numbers->Denumerate();
2276  if (init_mode == IM_Normal) ScriptGuiRoot->Denumerate(numbers);
2277  // Object.PostLoad must happen after number->Denumerate(), becuase UpdateFace() will access Action proplist,
2278  // which might have a non-denumerated prototype otherwise
2279  Objects.PostLoad(init_mode == IM_Section, numbers);
2280 
2281  // Check object enumeration
2282  if (!CheckObjectEnumeration()) return false;
2283 
2284  // Okay; everything in denumerated state from now on
2285  PointersDenumerated = true;
2286 
2287  // scenario objects script
2290 
2291  // Environment
2292  if (!C4S.Head.NoInitialize && fLandscapeLoaded)
2293  {
2294  Log(LoadResStr("IDS_PRC_ENVIRONMENT"));
2295  InitVegetation();
2296  InitInEarth();
2297  InitAnimals();
2298  InitEnvironment();
2299  InitRules();
2300  InitGoals();
2302  }
2303  SetInitProgress(94);
2304 
2305  // Weather
2306  if (fLandscapeLoaded) Weather.Init(!C4S.Head.SaveGame);
2307  SetInitProgress(96);
2308 
2309  // close any gfx groups, because they are no longer needed (after sky is initialized)
2311 
2312  if (init_mode == IM_Normal) // reload doesn't affect the music (takes too long)
2313  {
2314  // Music
2317  if (::Config.Sound.RXMusic)
2318  {
2319  // Play something that is not Frontend.mid
2321  }
2322  else
2324  SetInitProgress(97);
2325  }
2326 
2327  return true;
2328 }
#define C4CFN_MassMover
Definition: C4Components.h:76
C4SoundSystem SoundSystem
Definition: C4Application.h:42
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3386
void InitValueOverloads()
Definition: C4Game.cpp:3347
bool FindEntry(const char *szWildCard, StdStrBuf *sFileName=nullptr, size_t *iSize=nullptr)
Definition: C4Group.cpp:1774
void RecheckPlayers()
Definition: C4Teams.cpp:663
const char * GetData() const
void Denumerate()
Definition: C4Value.cpp:281
bool InitMaterialTexture()
Definition: C4Game.cpp:807
C4Config Config
Definition: C4Config.cpp:833
bool Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bool &rfLoaded, bool fSavegame)
void InitEnvironment()
Definition: C4Game.cpp:3356
C4Value & GlobalSoundModifier
Definition: C4Game.h:99
C4GameScriptHost GameScript
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4Scenario C4S
Definition: C4Game.h:74
C4ConfigGeneral General
Definition: C4Config.h:251
#define C4CFN_Script
Definition: C4Components.h:66
void InitGoals()
Definition: C4Game.cpp:3376
bool Replay
Definition: C4Scenario.h:72
C4ComponentHost GameText
Definition: C4Game.h:79
int32_t LoadEffects(C4Group &hGroup, const char *namespace_prefix, bool group_is_root)
#define C4CFN_RoundResults
Definition: C4Components.h:129
bool isEnabled() const
Definition: C4Network2.h:203
bool PostInitMap()
bool EvaluateOnAbort
Definition: C4Game.h:115
void RecheckAutoGeneratedTeams()
StdStrBuf DebugHost
Definition: C4Game.h:149
void Init(PointFreeFn fnPointFree, C4TransferZones *pTransferZones=nullptr)
class C4ScenarioObjectsScriptHost * pScenarioObjectsScript
Definition: C4Game.h:90
bool Load(C4Group &hGroup, const char *szFilename=C4CFN_RoundResults)
bool LandscapeFree(int32_t x, int32_t y)
Definition: C4Game.cpp:1988
class C4ScenarioParameterDefs & ScenarioParameterDefs
Definition: C4Game.h:75
void ScenarioInit()
C4GraphicsResource GraphicsResource
StdStrBuf DebugPassword
Definition: C4Game.h:149
C4GameParameters & Parameters
Definition: C4Game.h:67
C4TeamList & Teams
Definition: C4Game.h:70
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4LangStringTable ScenarioLangStringTable
Definition: C4Game.h:80
bool InitControl()
Definition: C4Game.cpp:2536
bool Load(C4Group &, const char *, const char *, C4LangStringTable *) override
C4MapScriptHost MapScript
uint16_t DebugPort
Definition: C4Game.h:149
bool SaveGame
Definition: C4Scenario.h:71
int32_t FrameCounter
Definition: C4Game.h:129
bool LoadScenarioComponents()
Definition: C4Game.cpp:2856
void Denumerate(C4ValueNumbers *)
Definition: C4Value.cpp:251
std::unique_ptr< C4FileMonitor > pFileMonitor
Definition: C4Game.h:97
C4Network2 Network
Definition: C4Globals.cpp:53
#define C4CFN_ScenarioObjectsScript
Definition: C4Components.h:74
void Clear()
Definition: C4PXS.cpp:163
bool CheckObjectEnumeration()
Definition: C4Game.cpp:3298
bool Load(C4Group &, const char *, const char *, C4LangStringTable *) override
C4ScenarioParameters ScenarioParameters
void Denumerate(C4ValueNumbers *) override
Definition: C4Aul.cpp:145
bool Load(C4Group &hGroup)
Definition: C4PXS.cpp:358
bool CompileRuntimeData(C4Group &hGroup, InitMode init_mode, bool exact, bool sync, C4ValueNumbers *)
Definition: C4Game.cpp:1754
C4Landscape Landscape
bool isLeague() const
int32_t AutoFileReload
Definition: C4Config.h:83
C4Group ScenarioFile
Definition: C4Game.h:86
bool NetworkGame
Definition: C4Scenario.h:78
C4ConfigDeveloper Developer
Definition: C4Config.h:252
C4TransferZones TransferZones
Definition: C4Game.h:85
bool InitDefs()
Definition: C4Game.cpp:120
void Init(bool fScenario)
Definition: C4Weather.cpp:39
C4Weather Weather
Definition: C4Weather.cpp:206
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:237
C4PXSSystem PXS
Definition: C4PXS.cpp:423
void InitInEarth()
Definition: C4Game.cpp:2810
static bool InitDebug(const char *szPassword, const char *szHost)
Definition: C4AulDebug.cpp:43
C4PlayerControlDefs PlayerControlDefs
Definition: C4Game.h:92
char LanguageEx[CFG_MaxString+1]
Definition: C4Config.h:37
C4RoundResults & RoundResults
Definition: C4Game.h:73
const char * getData() const
Definition: StdBuf.h:442
bool InitForScenario(C4Group &hGroup)
#define C4CFN_MapScript
Definition: C4Components.h:67
void FadeOut(int fadeout_ms)
int32_t GetStartupCount()
C4MassMoverSet MassMover
int32_t GetHeight() const
int32_t StartupPlayerCount
Definition: C4Game.h:109
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:71
bool PointersDenumerated
Definition: C4Game.h:141
bool LinkScriptEngine()
Definition: C4Game.cpp:2417
void InitRules()
Definition: C4Game.cpp:3366
C4PathFinder PathFinder
Definition: C4Game.h:84
bool InitPlayerControlUserSettings()
Definition: C4Game.cpp:3049
C4PropListStatic * GetPropList() override
int32_t GetWidth() const
C4SGame Game
Definition: C4Scenario.h:234
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
void InitAnimals()
Definition: C4Game.cpp:2841
void InitVegetation()
Definition: C4Game.cpp:2826
#define C4CFN_PXS
Definition: C4Components.h:75
int32_t StartupTeamCount
Definition: C4Game.h:110
bool EvaluateOnAbort
Definition: C4Scenario.h:129
bool LoadAdditionalSystemGroup(class C4Group &parent_group)
Definition: C4Game.cpp:2887
bool InitScriptEngine()
Definition: C4Game.cpp:2376
C4SHead Head
Definition: C4Scenario.h:232
void Init(int32_t iWidth, int32_t iHeight)
std::unique_ptr< C4ScriptGuiWindow > ScriptGuiRoot
Definition: C4Game.h:234
void RegisterScriptConstants(const class C4ScenarioParameters &values)
int PostLoad(bool fKeepInactive, C4ValueNumbers *)
bool Load(C4Group &hGroup)
C4ConfigSound Sound
Definition: C4Config.h:254
virtual bool Load(C4Group &hGroup, const char *szFilename, const char *szLanguage, C4LangStringTable *pLocalTable)
bool NoInitialize
Definition: C4Scenario.h:69
int32_t GetStartupTeamCount(int32_t startup_player_count)
Definition: C4Teams.cpp:900
C4PlayerControlAssignmentSets PlayerControlUserAssignmentSets
Definition: C4Game.h:93
C4Application Application
Definition: C4Globals.cpp:44
C4GameObjects Objects
Definition: C4Globals.cpp:48
#define PSF_InitializeObjects
Definition: C4GameScript.h:45
int32_t RXMusic
Definition: C4Config.h:127
bool Play(const char *szSongname=nullptr, bool fLoop=false, int fadetime_ms=0, double max_resume_time=0.0, bool allow_break=false)
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110
C4MusicSystem MusicSystem
Definition: C4Application.h:41
Here is the call graph for this function: