OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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
 
virtual void CompileFunc (StdCompiler *pComp)
 
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 276 of file C4Control.h.

Member Enumeration Documentation

Enumerator
CPA_NoAction 
CPA_Surrender 
CPA_ActivateGoal 
CPA_ActivateGoalMenu 
CPA_Eliminate 
CPA_SetHostility 
CPA_SetTeam 
CPA_InitScenarioPlayer 
CPA_InitPlayerControl 

Definition at line 279 of file C4Control.h.

Constructor & Destructor Documentation

C4ControlPlayerAction::C4ControlPlayerAction ( const C4Player source = nullptr)

Definition at line 562 of file C4Control.cpp.

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

563  : action(CPA_NoAction), source(source ? source->Number : NO_OWNER), target(NO_OWNER), param_int(0)
564 {
565 }
int32_t Number
Definition: C4Player.h:88
const int NO_OWNER
Definition: C4Constants.h:138

Here is the caller graph for this function:

Member Function Documentation

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

Definition at line 581 of file C4Control.cpp.

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

Referenced by C4MainMenu::MenuCommand().

582 {
583  assert(source);
584  assert(goal);
585  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
586  control->action = CPA_ActivateGoal;
587  control->target = goal->Number;
588  return control;
589 }
C4ControlPlayerAction(const C4Player *source=nullptr)
Definition: C4Control.cpp:562

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 590 of file C4Control.cpp.

References C4ControlPlayerAction(), and CPA_ActivateGoalMenu.

Referenced by C4MainMenu::MenuCommand().

591 {
592  assert(source);
593  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
594  control->action = CPA_ActivateGoalMenu;
595  return control;
596 }
C4ControlPlayerAction(const C4Player *source=nullptr)
Definition: C4Control.cpp:562

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ControlPacket::CompileFunc ( StdCompiler pComp)
virtualinherited

Implements C4PacketBase.

Definition at line 77 of file C4Control.cpp.

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

78 {
79  // Section must be set by caller
80  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iByClient), "ByClient", -1));
81 }
int32_t iByClient
Definition: C4Control.h:39
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
void Value(const T &rStruct)
Definition: StdCompiler.h:171
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:757

Here is the call graph for this function:

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

Definition at line 574 of file C4Control.cpp.

References C4ControlPlayerAction(), and CPA_Eliminate.

Referenced by ConsoleDlgProc().

575 {
576  assert(source);
577  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
578  control->action = CPA_Eliminate;
579  return control;
580 }
C4ControlPlayerAction(const C4Player *source=nullptr)
Definition: C4Control.cpp:562

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4ControlPacket::Execute ( ) const
pure virtualinherited

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

Here is the caller graph for this function:

int32_t C4ControlPacket::getByClient ( ) const
inlineinherited

Definition at line 42 of file C4Control.h.

References C4ControlPacket::iByClient.

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

42 { return iByClient; }
int32_t iByClient
Definition: C4Control.h:39

Here is the caller graph for this function:

bool C4ControlPacket::HostControl ( ) const
inlineinherited

Definition at line 44 of file C4Control.h.

References C4ClientIDHost.

44 { return iByClient == C4ClientIDHost; }
int32_t iByClient
Definition: C4Control.h:39
const int32_t C4ClientIDHost
Definition: C4Client.h:25
C4ControlPlayerAction * C4ControlPlayerAction::InitPlayerControl ( const C4Player source,
const C4PlayerControlAssignmentSet ctrl_set = nullptr 
)
static

Definition at line 623 of file C4Control.cpp.

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

Referenced by C4Player::InitControl().

624 {
625  assert(source);
626  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
627  control->action = CPA_InitPlayerControl;
628  if (ctrl_set)
629  {
630  control->param_str = ctrl_set->GetName();
631  if (ctrl_set->HasKeyboard())
632  control->param_int |= CPA_IPC_HasKeyboard;
633  if (ctrl_set->HasMouse())
634  control->param_int |= CPA_IPC_HasMouse;
635  if (ctrl_set->HasGamepad())
636  control->param_int |= CPA_IPC_HasGamepad;
637  }
638  return control;
639 }
const char * GetName() const
C4ControlPlayerAction(const C4Player *source=nullptr)
Definition: C4Control.cpp:562

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 615 of file C4Control.cpp.

References C4ControlPlayerAction(), and CPA_InitScenarioPlayer.

Referenced by C4Player::DoTeamSelection().

616 {
617  assert(source);
618  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
619  control->action = CPA_InitScenarioPlayer;
620  control->target = team;
621  return control;
622 }
C4ControlPlayerAction(const C4Player *source=nullptr)
Definition: C4Control.cpp:562

Here is the call graph for this function:

Here is the caller graph for this function:

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:

bool C4ControlPacket::LocalControl ( ) const
inherited

Definition at line 67 of file C4Control.cpp.

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

68 {
69  return iByClient == ::Control.ClientID();
70 }
int32_t iByClient
Definition: C4Control.h:39
C4GameControl Control
int32_t ClientID() const

Here is the call graph for this function:

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

Definition at line 156 of file C4Packet2.cpp.

Referenced by MkC4NetIOPacket().

157 {
158  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
159 }

Here is the caller graph for this function:

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

Definition at line 161 of file C4Packet2.cpp.

References mkDecompileAdapt(), and mkInsertAdapt().

162 {
163  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(mkInsertAdapt(mkDecompileAdapt(*this), cStatus)), addr);
164 }
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:154
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:435

Here is the call graph for this function:

virtual bool C4ControlPacket::PreExecute ( ) const
inlinevirtualinherited

Reimplemented in C4ControlJoinPlayer.

Definition at line 48 of file C4Control.h.

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

48 { return true; }

Here is the caller graph for this function:

virtual void C4ControlPacket::PreRec ( C4Record pRecord)
inlinevirtualinherited

Reimplemented in C4ControlJoinPlayer.

Definition at line 50 of file C4Control.h.

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

50 { }

Here is the caller graph for this function:

void C4ControlPacket::SetByClient ( int32_t  iByClient)
inherited

Definition at line 72 of file C4Control.cpp.

References C4ControlPacket::iByClient.

73 {
74  iByClient = inByClient;
75 }
int32_t iByClient
Definition: C4Control.h:39
C4ControlPlayerAction * C4ControlPlayerAction::SetHostility ( const C4Player source,
const C4Player target,
bool  hostile 
)
static

Definition at line 597 of file C4Control.cpp.

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

Referenced by C4MainMenu::MenuCommand().

598 {
599  assert(source);
600  assert(target);
601  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
602  control->action = CPA_SetHostility;
603  control->target = target ? target->Number : NO_OWNER;
604  control->param_int = hostile;
605  return control;
606 }
int32_t Number
Definition: C4Player.h:88
C4ControlPlayerAction(const C4Player *source=nullptr)
Definition: C4Control.cpp:562
const int NO_OWNER
Definition: C4Constants.h:138

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 607 of file C4Control.cpp.

References C4ControlPlayerAction(), and CPA_SetTeam.

Referenced by C4MainMenu::MenuCommand().

608 {
609  assert(source);
610  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
611  control->action = CPA_SetTeam;
612  control->target = team;
613  return control;
614 }
C4ControlPlayerAction(const C4Player *source=nullptr)
Definition: C4Control.cpp:562

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 567 of file C4Control.cpp.

References C4ControlPlayerAction(), and CPA_Surrender.

Referenced by C4MainMenu::MenuCommand().

568 {
569  assert(source);
570  C4ControlPlayerAction *control = new C4ControlPlayerAction(source);
571  control->action = CPA_Surrender;
572  return control;
573 }
C4ControlPlayerAction(const C4Player *source=nullptr)
Definition: C4Control.cpp:562

Here is the call graph for this function:

Here is the caller graph for this function:

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.

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

55 { return true; }

Here is the caller graph for this function:

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

Definition at line 166 of file C4Packet2.cpp.

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

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

167 {
168  if (pStatus) *pStatus = Pkt.getStatus();
169  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
170 }
StdBuf getPBuf() const
Definition: C4NetIO.h:321
C4NetIOPacket getRef() const
Definition: C4NetIO.h:324
uint8_t getStatus() const
Definition: C4NetIO.h:318

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

int32_t C4ControlPacket::iByClient
protectedinherited

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