OpenClonk
C4ControlPlayerAction Class Referenceabstract

#include <C4Control.h>

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

Public Types

enum  Action {
  CPA_NoAction = 0 , CPA_Surrender = 0x01 , CPA_ActivateGoal = 0x02 , CPA_ActivateGoalMenu = 0x03 ,
  CPA_Eliminate = 0x04 , CPA_SetHostility = 0x10 , CPA_SetTeam = 0x11 , CPA_InitScenarioPlayer = 0x20 ,
  CPA_InitPlayerControl = 0x21
}
 

Public Member Functions

 C4ControlPlayerAction (const C4Player *source=nullptr)
 
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)
 

Static Public Member Functions

static C4ControlPlayerActionSurrender (const C4Player *source)
 
static C4ControlPlayerActionEliminate (const C4Player *source)
 
static C4ControlPlayerActionActivateGoalMenu (const C4Player *source)
 
static C4ControlPlayerActionActivateGoal (const C4Player *source, const C4Object *target)
 
static C4ControlPlayerActionSetHostility (const C4Player *source, const C4Player *target, bool hostile)
 
static C4ControlPlayerActionSetTeam (const C4Player *source, int32_t team)
 
static C4ControlPlayerActionInitScenarioPlayer (const C4Player *source, int32_t team)
 
static C4ControlPlayerActionInitPlayerControl (const C4Player *source, const C4PlayerControlAssignmentSet *ctrl_set=nullptr)
 

Protected Attributes

int32_t iByClient
 

Detailed Description

Definition at line 270 of file C4Control.h.

Member Enumeration Documentation

◆ Action

Enumerator
CPA_NoAction 
CPA_Surrender 
CPA_ActivateGoal 
CPA_ActivateGoalMenu 
CPA_Eliminate 
CPA_SetHostility 
CPA_SetTeam 
CPA_InitScenarioPlayer 
CPA_InitPlayerControl 

Definition at line 273 of file C4Control.h.

274  {
275  CPA_NoAction = 0,
276 
277  CPA_Surrender = 0x01,
278  CPA_ActivateGoal = 0x02,
279  CPA_ActivateGoalMenu = 0x03,
280  CPA_Eliminate = 0x04,
281 
282  CPA_SetHostility = 0x10,
283  CPA_SetTeam = 0x11,
284 
285  CPA_InitScenarioPlayer = 0x20,
286  CPA_InitPlayerControl = 0x21
287  };

Constructor & Destructor Documentation

◆ C4ControlPlayerAction()

C4ControlPlayerAction::C4ControlPlayerAction ( const C4Player source = nullptr)

Definition at line 552 of file C4Control.cpp.

553  : source(source ? source->Number : NO_OWNER), target(NO_OWNER)
554 {
555 }
const int NO_OWNER
Definition: C4Constants.h:137
int32_t Number
Definition: C4Player.h:86

Referenced by ActivateGoal(), ActivateGoalMenu(), Eliminate(), InitPlayerControl(), InitScenarioPlayer(), SetHostility(), SetTeam(), and Surrender().

Here is the caller graph for this function:

Member Function Documentation

◆ ActivateGoal()

C4ControlPlayerAction * C4ControlPlayerAction::ActivateGoal ( const C4Player source,
const C4Object target 
)
static

Definition at line 571 of file C4Control.cpp.

572 {
573  assert(source);
574  assert(goal);
575  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
576  control->action = CPA_ActivateGoal;
577  control->target = goal->Number;
578  return control;
579 }
C4ControlPlayerAction(const C4Player *source=nullptr)
Definition: C4Control.cpp:552

References C4ControlPlayerAction(), CPA_ActivateGoal, and C4PropListNumbered::Number.

Referenced by C4MainMenu::MenuCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ActivateGoalMenu()

C4ControlPlayerAction * C4ControlPlayerAction::ActivateGoalMenu ( const C4Player source)
static

Definition at line 580 of file C4Control.cpp.

581 {
582  assert(source);
583  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
584  control->action = CPA_ActivateGoalMenu;
585  return control;
586 }

References C4ControlPlayerAction(), and CPA_ActivateGoalMenu.

Referenced by C4MainMenu::MenuCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompileFunc()

void C4ControlPacket::CompileFunc ( StdCompiler pComp)
overridevirtualinherited

Implements C4PacketBase.

Definition at line 70 of file C4Control.cpp.

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

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

Here is the call graph for this function:

◆ Eliminate()

C4ControlPlayerAction * C4ControlPlayerAction::Eliminate ( const C4Player source)
static

Definition at line 564 of file C4Control.cpp.

565 {
566  assert(source);
567  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
568  control->action = CPA_Eliminate;
569  return control;
570 }

References C4ControlPlayerAction(), and CPA_Eliminate.

Referenced by ConsoleDlgProc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Execute()

virtual void C4ControlPacket::Execute ( ) const
pure virtualinherited

Referenced by C4GameControl::DoSyncCheck(), C4GameControl::ExecControlPacket(), and C4Control::Execute().

Here is the caller graph for this function:

◆ getByClient()

int32_t C4ControlPacket::getByClient ( ) const
inlineinherited

Definition at line 42 of file C4Control.h.

42 { return iByClient; }

References C4ControlPacket::iByClient.

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

Here is the caller graph for this function:

◆ HostControl()

bool C4ControlPacket::HostControl ( ) const
inlineinherited

Definition at line 44 of file C4Control.h.

44 { return iByClient == C4ClientIDHost; }
const int32_t C4ClientIDHost
Definition: C4Client.h:25

References C4ClientIDHost, and C4ControlPacket::iByClient.

◆ InitPlayerControl()

C4ControlPlayerAction * C4ControlPlayerAction::InitPlayerControl ( const C4Player source,
const C4PlayerControlAssignmentSet ctrl_set = nullptr 
)
static

Definition at line 613 of file C4Control.cpp.

614 {
615  assert(source);
616  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
617  control->action = CPA_InitPlayerControl;
618  if (ctrl_set)
619  {
620  control->param_str = ctrl_set->GetName();
621  if (ctrl_set->HasKeyboard())
622  control->param_int |= CPA_IPC_HasKeyboard;
623  if (ctrl_set->HasMouse())
624  control->param_int |= CPA_IPC_HasMouse;
625  if (ctrl_set->HasGamepad())
626  control->param_int |= CPA_IPC_HasGamepad;
627  }
628  return control;
629 }
const char * GetName() const

References C4ControlPlayerAction(), CPA_InitPlayerControl, C4PlayerControlAssignmentSet::GetName(), C4PlayerControlAssignmentSet::HasGamepad(), C4PlayerControlAssignmentSet::HasKeyboard(), and C4PlayerControlAssignmentSet::HasMouse().

Referenced by C4Player::InitControl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitScenarioPlayer()

C4ControlPlayerAction * C4ControlPlayerAction::InitScenarioPlayer ( const C4Player source,
int32_t  team 
)
static

Definition at line 605 of file C4Control.cpp.

606 {
607  assert(source);
608  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
609  control->action = CPA_InitScenarioPlayer;
610  control->target = team;
611  return control;
612 }

References C4ControlPlayerAction(), and CPA_InitScenarioPlayer.

Referenced by C4Player::DoTeamSelection().

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.

53 { return false; }

Referenced by C4GameControl::DoInput().

Here is the caller graph for this function:

◆ LocalControl()

bool C4ControlPacket::LocalControl ( ) const
inherited

Definition at line 60 of file C4Control.cpp.

61 {
62  return iByClient == ::Control.ClientID();
63 }
C4GameControl Control
int32_t ClientID() const

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

Here is the call 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.

151 {
152  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
153 }

Referenced by MkC4NetIOPacket().

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.

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

References mkDecompileAdapt(), and mkInsertAdapt().

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.

48 { return true; }

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

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.

50 { }

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

Here is the caller graph for this function:

◆ SetByClient()

void C4ControlPacket::SetByClient ( int32_t  iByClient)
inherited

Definition at line 65 of file C4Control.cpp.

66 {
67  iByClient = inByClient;
68 }

References C4ControlPacket::iByClient.

◆ SetHostility()

C4ControlPlayerAction * C4ControlPlayerAction::SetHostility ( const C4Player source,
const C4Player target,
bool  hostile 
)
static

Definition at line 587 of file C4Control.cpp.

588 {
589  assert(source);
590  assert(target);
591  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
592  control->action = CPA_SetHostility;
593  control->target = target ? target->Number : NO_OWNER;
594  control->param_int = hostile;
595  return control;
596 }

References C4ControlPlayerAction(), CPA_SetHostility, NO_OWNER, and C4Player::Number.

Referenced by C4MainMenu::MenuCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetTeam()

C4ControlPlayerAction * C4ControlPlayerAction::SetTeam ( const C4Player source,
int32_t  team 
)
static

Definition at line 597 of file C4Control.cpp.

598 {
599  assert(source);
600  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
601  control->action = CPA_SetTeam;
602  control->target = team;
603  return control;
604 }

References C4ControlPlayerAction(), and CPA_SetTeam.

Referenced by C4MainMenu::MenuCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Surrender()

C4ControlPlayerAction * C4ControlPlayerAction::Surrender ( const C4Player source)
static

Definition at line 557 of file C4Control.cpp.

558 {
559  assert(source);
560  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
561  control->action = CPA_Surrender;
562  return control;
563 }

References C4ControlPlayerAction(), and CPA_Surrender.

Referenced by C4MainMenu::MenuCommand().

Here is the call graph for this function:
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.

55 { return true; }

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

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.

161 {
162  if (pStatus) *pStatus = Pkt.getStatus();
163  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
164 }
uint8_t getStatus() const
Definition: C4NetIO.h:319
StdBuf getPBuf() const
Definition: C4NetIO.h:322
C4NetIOPacket getRef() const
Definition: C4NetIO.h:325

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ iByClient


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