OpenClonk
C4ControlVoteEnd Class Referenceabstract

#include <C4Control.h>

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

Public Member Functions

 C4ControlVoteEnd (C4ControlVoteType eType=VT_None, bool fApprove=true, int iData=0)
 
bool Sync () const override
 
C4ControlVoteType getType () const
 
bool isApprove () const
 
int32_t getData () const
 
StdStrBuf getDesc () const
 
StdStrBuf getDescWarning () const
 
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
 
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

int32_t iByClient
 

Detailed Description

Definition at line 592 of file C4Control.h.

Constructor & Destructor Documentation

◆ C4ControlVoteEnd()

C4ControlVoteEnd::C4ControlVoteEnd ( C4ControlVoteType  eType = VT_None,
bool  fApprove = true,
int  iData = 0 
)
inline

Definition at line 595 of file C4Control.h.

596  : C4ControlVote(eType, fApprove, iData)
597  { }
C4ControlVote(C4ControlVoteType eType=VT_None, bool fApprove=true, int iData=0)
Definition: C4Control.h:570

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::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:

◆ getData()

int32_t C4ControlVote::getData ( ) const
inlineinherited

Definition at line 582 of file C4Control.h.

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

582 { return iData; }
Here is the caller graph for this function:

◆ getDesc()

StdStrBuf C4ControlVote::getDesc ( ) const
inherited

Definition at line 1675 of file C4Control.cpp.

References C4Game::Clients, StdStrBuf::Format(), Game, C4ClientList::getClientByID(), C4Client::getName(), C4ControlPacket::iByClient, LoadResStr(), VT_Cancel, VT_Kick, and VT_Pause.

Referenced by C4Network2::OpenVoteDialog().

1676 {
1677  // Describe action
1678  StdStrBuf Action;
1679  switch (eType)
1680  {
1681  case VT_Cancel:
1682  Action = LoadResStr("IDS_VOTE_CANCELTHEROUND"); break;
1683  case VT_Kick:
1684  if (iData == iByClient)
1685  Action = LoadResStr("IDS_VOTE_LEAVETHEGAME");
1686  else
1687  {
1688  C4Client *pTargetClient = Game.Clients.getClientByID(iData);
1689  Action.Format(LoadResStr("IDS_VOTE_KICKCLIENT"), pTargetClient ? pTargetClient->getName() : "???");
1690  }
1691  break;
1692  case VT_Pause:
1693  if (iData)
1694  Action = LoadResStr("IDS_TEXT_PAUSETHEGAME");
1695  else
1696  Action = LoadResStr("IDS_TEXT_UNPAUSETHEGAME");
1697  break;
1698  default:
1699  Action = "perform some mysterious action"; break;
1700  }
1701  return Action;
1702 }
C4Game Game
Definition: C4Globals.cpp:52
int32_t iByClient
Definition: C4Control.h:39
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Client * getClientByID(int32_t iID) const
Definition: C4Client.cpp:200
const char * getName() const
Definition: C4Client.h:107
C4ClientList & Clients
Definition: C4Game.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDescWarning()

StdStrBuf C4ControlVote::getDescWarning ( ) const
inherited

Definition at line 1704 of file C4Control.cpp.

References C4Game::Abort(), C4Network2::AddVote(), C4ClientIDUnknown, CDT_Sync, CID_VoteEnd, C4Network2::Clear(), C4Game::Clients, C4ControlPacket::CompileFunc(), Control, C4ClientList::CtrlRemove(), C4Game::DoGameOver(), C4GameControl::DoInput(), C4Network2::EndVote(), C4RoundResults::EvaluateNetwork(), C4ControlPacket::Execute(), StdStrBuf::Format(), FormatString(), Game, C4Game::GameOver, C4ClientList::getClientByID(), C4PlayerInfoList::GetClientInfoByPlayerID(), StdStrBuf::getData(), C4PlayerInfo::GetID(), C4PlayerInfoList::GetIndexedInfo(), C4Team::GetIndexedPlayer(), C4PlayerInfoList::GetInfoByClientID(), C4ClientList::getLocalID(), C4Client::getName(), C4IDPacket::getPkt(), C4Team::GetPlayerCount(), C4PlayerInfoList::GetPlayerCount(), C4ClientPlayerInfos::GetPlayerInfo(), C4PlayerInfoList::GetPlayerInfoByID(), C4PlayerInfoList::GetPlayerInfoByIndex(), C4TeamList::GetTeamByIndex(), C4TeamList::GetTeamCount(), C4Network2::GetVote(), C4ControlPacket::HostControl(), C4ControlPacket::iByClient, C4ControlVote::isApprove(), C4GameControl::isCtrlHost(), C4Network2::isEnabled(), C4PlayerInfo::IsJoined(), C4PlayerInfo::IsRemoved(), LoadResStr(), Log(), LogF(), mkNamingAdapt(), Network, C4RoundResults::NR_NetError, C4Game::PlayerInfos, C4Game::RoundResults, C4PlayerInfo::SetVotedOut(), C4Game::Teams, StdCompiler::Value(), VT_Cancel, VT_Kick, and VT_None.

Referenced by C4Network2::OpenVoteDialog().

1705 {
1706  StdStrBuf Warning;
1707  switch (eType)
1708  {
1709  case VT_Cancel:
1710  Warning = LoadResStr("IDS_TEXT_WARNINGIFTHEGAMEISCANCELL"); break;
1711  case VT_Kick:
1712  Warning = LoadResStr("IDS_TEXT_WARNINGNOLEAGUEPOINTSWILL"); break;
1713  default:
1714  Warning = ""; break;
1715  }
1716  return Warning;
1717 }
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getType()

C4ControlVoteType C4ControlVote::getType ( ) const
inlineinherited

Definition at line 580 of file C4Control.h.

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

580 { return eType; }
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:

◆ isApprove()

bool C4ControlVote::isApprove ( ) const
inlineinherited

Definition at line 581 of file C4Control.h.

Referenced by C4ControlVote::getDescWarning().

581 { return fApprove; }
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()

bool C4ControlVoteEnd::Sync ( ) const
inlineoverridevirtual

Reimplemented from C4ControlVote.

Definition at line 599 of file C4Control.h.

References DECLARE_C4CONTROL_VIRTUALS.

599 { return true; }

◆ 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

◆ iByClient


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