OpenClonk
C4ControlReInitScenario Struct Referenceabstract

#include <C4Control.h>

Inheritance diagram for C4ControlReInitScenario:
[legend]
Collaboration diagram for C4ControlReInitScenario:
[legend]

Public Member Functions

 C4ControlReInitScenario ()
 
int32_t getByClient () const
 
bool LocalControl () const
 
bool HostControl () const
 
void SetByClient (int32_t iByClient)
 
virtual bool PreExecute () const
 
virtual void Execute () const =0
 
virtual void PreRec (C4Record *pRecord)
 
virtual bool Lobby () const
 
virtual bool Sync () const
 
void CompileFunc (StdCompiler *pComp) override
 
C4NetIOPacket pack (const C4NetIO::addr_t &addr=C4NetIO::addr_t()) const
 
C4NetIOPacket pack (uint8_t cStatus, const C4NetIO::addr_t &addr=C4NetIO::addr_t()) const
 
void unpack (const C4NetIOPacket &Pkt, char *pStatus=nullptr)
 

Protected Attributes

StdBuf data
 
int32_t iByClient
 

Detailed Description

Definition at line 604 of file C4Control.h.

Constructor & Destructor Documentation

◆ C4ControlReInitScenario()

C4ControlReInitScenario::C4ControlReInitScenario ( )

Definition at line 1881 of file C4Control.cpp.

References C4Group::Add(), C4Config::AtTempPath(), C4CFN_Map, C4CFN_MapBg, C4CFN_MapFg, C4CFN_ScenarioCore, C4CFN_ScenarioObjects, C4CFN_ScenarioObjectsScript, C4S_REINIT_SCENARIO, StdBuf::Clear(), C4ControlPacket::CompileFunc(), Config, Console, C4Game::CreateSectionFromTempFile(), C4ConsoleGUI::EditGraphControl(), EraseFile(), C4ControlPacket::Execute(), Game, C4Group::LoadEntry(), C4Game::LoadScenarioSection(), MakeTempFilename(), mkNamingAdapt(), C4Group::Open(), C4Group::Save(), C4Game::ScenarioFile, and StdCompiler::Value().

1882 {
1883  // Create a temp file with the scenario files to be loaded as a section
1884  char *tmp_fn = const_cast<char *>(Config.AtTempPath("ReinitSectionSave.ocs"));
1885  MakeTempFilename(tmp_fn);
1886  C4Group grp;
1887  grp.Open(tmp_fn, true);
1888  StdBuf buf;
1889  bool success = true;
1891  for (const char *section_component : section_components)
1892  {
1893  if (::Game.ScenarioFile.LoadEntry(section_component, &buf))
1894  {
1895  if (!grp.Add(section_component, buf, false, true)) success = false;
1896  }
1897  buf.Clear();
1898  }
1899  if (!grp.Save(false)) success = false;
1900  if (!success) return;
1901  // Move into buffer to be sent via queue
1902  success = data.LoadFromFile(tmp_fn);
1903  EraseFile(tmp_fn);
1904  if (!success) return;
1905 }
C4Config Config
Definition: C4Config.cpp:833
Definition: StdBuf.h:29
C4Game Game
Definition: C4Globals.cpp:52
#define C4CFN_MapFg
Definition: C4Components.h:58
#define C4CFN_Map
Definition: C4Components.h:57
void Clear()
Definition: StdBuf.h:190
bool LoadFromFile(const char *szFile)
Definition: StdBuf.cpp:32
bool LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSize=nullptr, int iAppendZeros=0)
Definition: C4Group.cpp:1893
bool Save(bool fReOpen)
Definition: C4Group.cpp:797
#define C4CFN_ScenarioObjectsScript
Definition: C4Components.h:74
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
C4Group ScenarioFile
Definition: C4Game.h:86
bool EraseFile(const char *szFileName)
#define C4CFN_MapBg
Definition: C4Components.h:59
#define C4CFN_ScenarioCore
Definition: C4Components.h:42
bool Add(const char *szFile, const char *szAddAs)
Definition: C4Group.cpp:1316
#define C4CFN_ScenarioObjects
Definition: C4Components.h:87
const char * AtTempPath(const char *szFilename)
Definition: C4Config.cpp:540
void MakeTempFilename(char *szFilename)
Definition: StdFile.cpp:323
Here is the call graph for this function:

Member Function Documentation

◆ CompileFunc()

void C4ControlPacket::CompileFunc ( StdCompiler pComp)
overridevirtualinherited

Implements C4PacketBase.

Definition at line 70 of file C4Control.cpp.

References C4Control::C4Control(), C4ControlPacket::iByClient, mkIntPackAdapt(), mkNamingAdapt(), and StdCompiler::Value().

Referenced by C4ControlEMDrawTool::C4ControlEMDrawTool(), C4ControlMenuCommand::C4ControlMenuCommand(), C4ControlPlayerSelect::C4ControlPlayerSelect(), C4ControlReInitScenario(), C4Control::CompileFunc(), C4ControlPlayerControl::ControlItem::CompileFunc(), C4ControlPlayerControl::ControlItem::ControlItem(), C4Control::Delete(), C4ControlPlayerMouse::DragDrop(), C4ControlSyncCheck::GetAllCrewPosX(), C4ControlVote::getDescWarning(), C4ControlPlayerAction::InitPlayerControl(), C4ControlJoinPlayer::PreRec(), C4ControlPacket::Sync(), and C4ControlEMMoveObject::~C4ControlEMMoveObject().

71 {
72  // Section must be set by caller
73  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iByClient), "ByClient", -1));
74 }
int32_t iByClient
Definition: C4Control.h:39
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
void Value(const T &rStruct)
Definition: StdCompiler.h:161
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:777
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Execute()

◆ getByClient()

int32_t C4ControlPacket::getByClient ( ) const
inlineinherited

Definition at line 42 of file C4Control.h.

References C4ControlPacket::iByClient, and C4ControlPacket::LocalControl().

Referenced by C4Network2::GetVote(), and C4Network2::OpenVoteDialog().

42 { return iByClient; }
int32_t iByClient
Definition: C4Control.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HostControl()

bool C4ControlPacket::HostControl ( ) const
inlineinherited

Definition at line 44 of file C4Control.h.

References C4ClientIDHost, and C4ControlPacket::SetByClient().

Referenced by C4ControlEMDrawTool::C4ControlEMDrawTool(), C4Control::CompileFunc(), and C4ControlVote::getDescWarning().

44 { return iByClient == C4ClientIDHost; }
int32_t iByClient
Definition: C4Control.h:39
const int32_t C4ClientIDHost
Definition: C4Client.h:25
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lobby()

virtual bool C4ControlPacket::Lobby ( ) const
inlinevirtualinherited

Reimplemented in C4ControlMessage, C4ControlPlayerInfo, C4ControlClientRemove, C4ControlClientUpdate, C4ControlClientJoin, and C4ControlSet.

Definition at line 53 of file C4Control.h.

Referenced by C4GameControl::DoInput().

53 { return false; }
Here is the caller graph for this function:

◆ LocalControl()

bool C4ControlPacket::LocalControl ( ) const
inherited

Definition at line 60 of file C4Control.cpp.

References C4GameControl::ClientID(), Control, and C4ControlPacket::iByClient.

Referenced by C4ControlJoinPlayer::C4ControlJoinPlayer(), C4Control::CompileFunc(), C4ControlPacket::getByClient(), and C4ControlEMMoveObject::~C4ControlEMMoveObject().

61 {
62  return iByClient == ::Control.ClientID();
63 }
int32_t iByClient
Definition: C4Control.h:39
int32_t ClientID() const
C4GameControl Control
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack() [1/2]

C4NetIOPacket C4PacketBase::pack ( const C4NetIO::addr_t addr = C4NetIO::addr_t()) const
inherited

Definition at line 150 of file C4Packet2.cpp.

Referenced by MkC4NetIOPacket().

151 {
152  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
153 }
Here is the caller graph for this function:

◆ pack() [2/2]

C4NetIOPacket C4PacketBase::pack ( uint8_t  cStatus,
const C4NetIO::addr_t addr = C4NetIO::addr_t() 
) const
inherited

Definition at line 155 of file C4Packet2.cpp.

References mkDecompileAdapt(), and mkInsertAdapt().

156 {
157  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(mkInsertAdapt(mkDecompileAdapt(*this), cStatus)), addr);
158 }
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:153
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:455
Here is the call graph for this function:

◆ PreExecute()

virtual bool C4ControlPacket::PreExecute ( ) const
inlinevirtualinherited

Reimplemented in C4ControlJoinPlayer.

Definition at line 48 of file C4Control.h.

References C4ControlPacket::Execute().

Referenced by C4Control::Delete(), C4GameControl::ExecControlPacket(), and C4Control::PreExecute().

48 { return true; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PreRec()

virtual void C4ControlPacket::PreRec ( C4Record pRecord)
inlinevirtualinherited

Reimplemented in C4ControlJoinPlayer.

Definition at line 50 of file C4Control.h.

Referenced by C4Control::Delete(), C4Control::PreRec(), and C4Record::Rec().

50 { }
Here is the caller graph for this function:

◆ SetByClient()

void C4ControlPacket::SetByClient ( int32_t  iByClient)
inherited

Definition at line 65 of file C4Control.cpp.

References C4ControlPacket::iByClient.

Referenced by C4ControlPacket::HostControl(), and C4ControlEMMoveObject::~C4ControlEMMoveObject().

66 {
67  iByClient = inByClient;
68 }
int32_t iByClient
Definition: C4Control.h:39
Here is the caller graph for this function:

◆ Sync()

virtual bool C4ControlPacket::Sync ( ) const
inlinevirtualinherited

Reimplemented in C4ControlVoteEnd, C4ControlVote, C4ControlMessage, C4ControlPlayerInfo, C4ControlClientRemove, C4ControlClientUpdate, C4ControlClientJoin, and C4ControlSyncCheck.

Definition at line 55 of file C4Control.h.

References C4ControlPacket::CompileFunc().

Referenced by C4Playback::Check(), and C4GameControl::DoInput().

55 { return true; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack()

void C4PacketBase::unpack ( const C4NetIOPacket Pkt,
char *  pStatus = nullptr 
)
inherited

Definition at line 160 of file C4Packet2.cpp.

References C4PktBuf::C4PktBuf(), C4NetIOPacket::getPBuf(), C4NetIOPacket::getRef(), and C4NetIOPacket::getStatus().

Referenced by C4IDPacket::C4IDPacket(), and C4Network2IO::HandlePacket().

161 {
162  if (pStatus) *pStatus = Pkt.getStatus();
163  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
164 }
uint8_t getStatus() const
Definition: C4NetIO.h:318
StdBuf getPBuf() const
Definition: C4NetIO.h:321
C4NetIOPacket getRef() const
Definition: C4NetIO.h:324
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ data

StdBuf C4ControlReInitScenario::data
protected

Definition at line 609 of file C4Control.h.

◆ iByClient


The documentation for this struct was generated from the following files: