OpenClonk
C4Player Class Reference

#include <C4Player.h>

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

Public Types

enum  ControlType {
  PCID_None , PCID_Message , PCID_Special , PCID_Command ,
  PCID_DirectCom
}
 
enum  StatusTypes { PS_None =0 , PS_Normal =1 , PS_TeamSelection = 2 , PS_TeamSelectionPending = 3 }
 

Public Member Functions

 C4Player ()
 
 ~C4Player ()
 
const char * GetName () const
 
C4PlayerType GetType () const
 
void Eliminate ()
 
void ClearPointers (C4Object *tptr, bool fDeath)
 
void Execute ()
 
void ExecuteControl ()
 
void SetViewMode (int32_t iMode, C4Object *pTarget=nullptr, bool immediate_position=false)
 
void ResetCursorView (bool immediate_position=false)
 
void Evaluate ()
 
void Surrender ()
 
void ScrollView (float iX, float iY, float ViewWdt, float ViewHgt)
 
void SetCursor (C4Object *pObj, bool fSelectArrow)
 
void RemoveCrewObjects ()
 
int32_t FindNewOwner () const
 
void NotifyOwnedObjects ()
 
void DefaultRuntimeData ()
 
void DrawHostility (C4Facet &cgo, int32_t iIndex)
 
void AdjustCursorCommand ()
 
bool DoScore (int32_t iChange)
 
bool Init (int32_t iNumber, int32_t iAtClient, const char *szAtClientName, const char *szFilename, bool fScenarioInit, class C4PlayerInfo *pInfo, C4ValueNumbers *)
 
bool ScenarioAndTeamInit (int32_t idTeam)
 
bool ScenarioInit ()
 
bool FinalInit (bool fInitialScore)
 
bool Save ()
 
bool Save (C4Group &hGroup, bool fSavegame, bool fStoreTiny)
 
bool MakeCrewMember (C4Object *pObj, bool fForceInfo=true, bool fDoCalls=true)
 
bool Load (const char *szFilename, bool fSavegame)
 
bool Message (const char *szMsg)
 
bool ObjectInCrew (C4Object *tobj)
 
bool DoWealth (int32_t change)
 
bool SetWealth (int32_t val)
 
bool SetKnowledge (C4ID id, bool fRemove)
 
bool SetHostility (int32_t iOpponent, int32_t iHostility, bool fSilent=false)
 
bool IsHostileTowards (const C4Player *opponent) const
 
void CompileFunc (StdCompiler *pComp, C4ValueNumbers *)
 
void DenumeratePointers ()
 
bool LoadRuntimeData (C4Group &hGroup, C4ValueNumbers *)
 
bool ActivateMenuMain ()
 
bool ActivateMenuTeamSelection (bool fFromMain)
 
void DoTeamSelection (int32_t idTeam)
 
C4ObjectGetHiExpActiveCrew ()
 
C4ObjectGetHiRankActiveCrew ()
 
void SetFoW (bool fEnable)
 
int32_t ActiveCrewCount ()
 
int32_t GetSelectedCrewCount ()
 
bool LocalSync ()
 
bool SetObjectCrewStatus (C4Object *pCrew, bool fNewStatus)
 
bool IsChosingTeam () const
 
bool IsInvisible () const
 
bool IsViewLocked () const
 
void SetViewLocked (bool to_val)
 
void SetSoundModifier (C4PropList *new_modifier)
 
void SetTeamHostility ()
 
void CloseMenu ()
 
void EvaluateLeague (bool fDisconnected, bool fWon)
 
void CreateGraphs ()
 
void ClearGraphs ()
 
void CountControl (ControlType eType, int32_t iID, int32_t iCntAdd=1)
 
class C4PlayerInfoGetInfo ()
 
void ToggleMouseControl ()
 
void CallMessageBoard (C4Object *pForObj, const StdStrBuf &sQueryString, bool fUppercase)
 
bool RemoveMessageBoardQuery (C4Object *pForObj)
 
bool MarkMessageBoardQueryAnswered (C4Object *pForObj)
 
bool HasMessageBoardQuery ()
 
void OnTeamSelectionFailed ()
 
void SetPlayerColor (uint32_t dwNewClr)
 
void SetZoomByViewRange (int32_t range_wdt, int32_t range_hgt, bool direct, bool no_increase, bool no_decrease)
 
void SetMinZoomByViewRange (int32_t range_wdt, int32_t range_hgt, bool no_increase, bool no_decrease)
 
void SetMaxZoomByViewRange (int32_t range_wdt, int32_t range_hgt, bool no_increase, bool no_decrease)
 
void SetZoom (C4Real zoom, bool direct, bool no_increase, bool no_decrease)
 
void SetMinZoom (C4Real zoom, bool no_increase, bool no_decrease)
 
void SetMaxZoom (C4Real zoom, bool no_increase, bool no_decrease)
 
void ZoomToViewports (bool direct, bool no_increase=false, bool no_decrease=false)
 
void ZoomToViewport (C4Viewport *vp, bool direct, bool no_increase=false, bool no_decrease=false)
 
void ZoomLimitsToViewports ()
 
void ZoomLimitsToViewport (C4Viewport *vp)
 
bool GainScenarioAchievement (const char *achievement_id, int32_t value, const char *scen_name_override=nullptr)
 
void Default (C4RankSystem *pRanks=nullptr)
 
void Promote (int32_t iRank, C4RankSystem &rRanks)
 
bool Load (C4Group &hGroup)
 
bool Save (C4Group &hGroup)
 
bool CheckPromotion (C4RankSystem &rRanks)
 
void CompileFunc (StdCompiler *pComp)
 

Static Public Member Functions

static bool Strip (const char *szFilename, bool fAggressive)
 
static DWORD GetPrefColorValue (int32_t iPrefColor)
 

Public Attributes

char Filename [_MAX_PATH_LEN]
 
StdStrBuf Name
 
int32_t Status
 
int32_t Eliminated
 
int32_t Surrendered
 
bool Evaluated
 
int32_t Number
 
int32_t ID
 
int32_t Team
 
uint32_t ColorDw
 
class C4PlayerControlAssignmentSetControlSet
 
StdCopyStrBuf ControlSetName
 
int32_t MouseControl
 
int32_t Position
 
int32_t PlrStartIndex
 
int32_t RetireDelay
 
int32_t GameJoinTime
 
int32_t AtClient
 
char AtClientName [C4MaxTitle+1]
 
bool LocalControl
 
bool LeagueEvaluated
 
bool NoEliminationCheck
 
C4MainMenu Menu
 
int32_t ViewMode
 
C4Real ViewX
 
C4Real ViewY
 
bool ViewLock
 
C4ObjectViewTarget
 
bool ShowStartup
 
int32_t FlashCom
 
bool fFogOfWar
 
int32_t ZoomLimitMinWdt
 
int32_t ZoomLimitMinHgt
 
int32_t ZoomLimitMaxWdt
 
int32_t ZoomLimitMaxHgt
 
int32_t ZoomWdt
 
int32_t ZoomHgt
 
C4Real ZoomLimitMinVal
 
C4Real ZoomLimitMaxVal
 
C4Real ZoomVal
 
int32_t Wealth
 
int32_t CurrentScore
 
int32_t InitialScore
 
int32_t ObjectsOwned
 
HostilitySet Hostility
 
C4IDList BaseMaterial
 
C4IDList BaseProduction
 
int32_t ProductionDelay
 
int32_t ProductionUnit
 
C4ObjectInfoList CrewInfoList
 
C4ObjectList Crew
 
C4IDList Knowledge
 
C4PlayerControl Control
 
C4ObjectPtr Cursor
 
C4ObjectPtr ViewCursor
 
int32_t CursorFlash
 
std::shared_ptr< class C4GamePadOpenerpGamepad
 
int32_t MessageStatus
 
char MessageBuf [256+1]
 
class C4MessageBoardQuerypMsgBoardQuery
 
C4FacetSurface BigIcon
 
C4Value SoundModifier
 
C4PlayerNext
 
class C4TableGraphpstatControls
 
class C4TableGraphpstatActions
 
int32_t ControlCount
 
int32_t ActionCount
 
ControlType LastControlType
 
int32_t LastControlID
 
char PrefName [C4MaxName+1]
 
char Comment [C4MaxComment+1]
 
int32_t Rank
 
char RankName [C4MaxName+1]
 
int32_t TotalScore
 
int32_t Rounds
 
int32_t RoundsWon
 
int32_t RoundsLost
 
int32_t TotalPlayingTime
 
C4RoundResult LastRound
 
C4ValueMapData ExtraData
 
char LeagueName [C4MaxName+1]
 
StdCopyStrBuf PrefControl
 
int32_t PrefMouse
 
int32_t PrefColor
 
uint32_t PrefColorDw
 
uint32_t PrefColor2Dw
 
int32_t PrefClonkSkin
 
int32_t OldPrefControl
 
int32_t OldPrefControlStyle
 
int32_t OldPrefAutoContextMenu
 
C4ScenarioParameters Achievements
 

Protected Member Functions

void ClearControl ()
 
void InitControl ()
 
void UpdateView ()
 
void CheckElimination ()
 
void ExecBaseProduction ()
 
void PlaceReadyBase (int32_t &tx, int32_t &ty, C4Object **pFirstBase)
 
void PlaceReadyVehic (int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
 
void PlaceReadyMaterial (int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
 
void PlaceReadyCrew (int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
 
void CheckCrewExPromotion ()
 

Friends

class C4PlayerList
 

Detailed Description

Definition at line 48 of file C4Player.h.

Member Enumeration Documentation

◆ ControlType

Enumerator
PCID_None 
PCID_Message 
PCID_Special 
PCID_Command 
PCID_DirectCom 

Definition at line 58 of file C4Player.h.

59  {
60  PCID_None, // no control
61  PCID_Message, // chat
62  PCID_Special, // goalruleinfo, etc.
63  PCID_Command, // mouse control
64  PCID_DirectCom // menu or keyboard control
65  };
@ PCID_DirectCom
Definition: C4Player.h:64
@ PCID_Command
Definition: C4Player.h:63
@ PCID_Message
Definition: C4Player.h:61
@ PCID_Special
Definition: C4Player.h:62
@ PCID_None
Definition: C4Player.h:60

◆ StatusTypes

Enumerator
PS_None 
PS_Normal 
PS_TeamSelection 
PS_TeamSelectionPending 

Definition at line 67 of file C4Player.h.

68  {
69  PS_None=0, // player disabled
70  PS_Normal=1, // normal playing
71  PS_TeamSelection = 2, // team selection
72  PS_TeamSelectionPending = 3 // waiting for team selection packet to come through
73  };
@ PS_TeamSelectionPending
Definition: C4Player.h:72
@ PS_None
Definition: C4Player.h:69
@ PS_Normal
Definition: C4Player.h:70
@ PS_TeamSelection
Definition: C4Player.h:71

Constructor & Destructor Documentation

◆ C4Player()

C4Player::C4Player ( )

Definition at line 47 of file C4Player.cpp.

48 {
49  Filename[0] = 0;
51  ID = 0;
52  Team = 0;
54  Menu.Default();
55  Crew.Default();
57  LocalControl = false;
58  BigIcon.Default();
59  Next = nullptr;
60  fFogOfWar = true;
61  LeagueEvaluated = false;
62  GameJoinTime = 0; // overwritten in Init
63  pstatControls = pstatActions = nullptr;
66  LastControlID = 0;
67  pMsgBoardQuery = nullptr;
68  NoEliminationCheck = false;
69  Evaluated = false;
72  ViewLock = true;
74 }
const int32_t C4P_Number_None
Definition: C4Player.h:35
const C4Real Fix0
Definition: C4Real.h:312
void Default()
Definition: C4FacetEx.h:43
void Default() override
Definition: C4MainMenu.cpp:43
virtual void Default()
C4MainMenu Menu
Definition: C4Player.h:103
int32_t ZoomLimitMinWdt
Definition: C4Player.h:112
C4Value SoundModifier
Definition: C4Player.h:140
bool fFogOfWar
Definition: C4Player.h:111
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:124
int32_t ZoomHgt
Definition: C4Player.h:112
bool LocalControl
Definition: C4Player.h:99
C4Player * Next
Definition: C4Player.h:142
bool LeagueEvaluated
Definition: C4Player.h:100
int32_t ZoomLimitMaxHgt
Definition: C4Player.h:112
int32_t GameJoinTime
Definition: C4Player.h:96
int32_t ZoomLimitMinHgt
Definition: C4Player.h:112
C4Real ZoomVal
Definition: C4Player.h:113
int32_t ActionCount
Definition: C4Player.h:147
C4Real ZoomLimitMaxVal
Definition: C4Player.h:113
int32_t ControlCount
Definition: C4Player.h:146
int32_t Team
Definition: C4Player.h:88
int32_t ID
Definition: C4Player.h:87
void DefaultRuntimeData()
Definition: C4Player.cpp:1206
C4ObjectList Crew
Definition: C4Player.h:125
class C4TableGraph * pstatControls
Definition: C4Player.h:145
bool NoEliminationCheck
Definition: C4Player.h:101
int32_t ZoomWdt
Definition: C4Player.h:112
int32_t ZoomLimitMaxWdt
Definition: C4Player.h:112
C4FacetSurface BigIcon
Definition: C4Player.h:138
class C4MessageBoardQuery * pMsgBoardQuery
Definition: C4Player.h:136
bool Evaluated
Definition: C4Player.h:85
int32_t Number
Definition: C4Player.h:86
ControlType LastControlType
Definition: C4Player.h:148
int32_t LastControlID
Definition: C4Player.h:148
C4Real ZoomLimitMinVal
Definition: C4Player.h:113
class C4TableGraph * pstatActions
Definition: C4Player.h:145
char Filename[_MAX_PATH_LEN]
Definition: C4Player.h:80
bool ViewLock
Definition: C4Player.h:107
void Set0()
Definition: C4Value.h:332

References ActionCount, BigIcon, C4P_Number_None, ControlCount, Crew, CrewInfoList, C4FacetSurface::Default(), C4ObjectInfoList::Default(), C4ObjectList::Default(), C4MainMenu::Default(), DefaultRuntimeData(), Evaluated, fFogOfWar, Filename, Fix0, GameJoinTime, ID, LastControlID, LastControlType, LeagueEvaluated, LocalControl, Menu, Next, NoEliminationCheck, Number, PCID_None, pMsgBoardQuery, pstatActions, pstatControls, C4Value::Set0(), SoundModifier, Team, ViewLock, ZoomHgt, ZoomLimitMaxHgt, ZoomLimitMaxVal, ZoomLimitMaxWdt, ZoomLimitMinHgt, ZoomLimitMinVal, ZoomLimitMinWdt, ZoomVal, and ZoomWdt.

Here is the call graph for this function:

◆ ~C4Player()

C4Player::~C4Player ( )

Definition at line 76 of file C4Player.cpp.

77 {
78  ClearGraphs();
79  Menu.Clear();
80  SetSoundModifier(nullptr);
81  while (pMsgBoardQuery)
82  {
84  delete pMsgBoardQuery;
85  pMsgBoardQuery = pNext;
86  }
87  ClearControl();
88 }
void Clear()
Definition: C4Menu.cpp:271
C4MessageBoardQuery * pNext
void ClearControl()
Definition: C4Player.cpp:1373
void ClearGraphs()
Definition: C4Player.cpp:1615
void SetSoundModifier(C4PropList *new_modifier)
Definition: C4Player.cpp:1923

References C4Menu::Clear(), ClearControl(), ClearGraphs(), Menu, pMsgBoardQuery, C4MessageBoardQuery::pNext, and SetSoundModifier().

Here is the call graph for this function:

Member Function Documentation

◆ ActivateMenuMain()

bool C4Player::ActivateMenuMain ( )

Definition at line 1761 of file C4Player.cpp.

1762 {
1763  // Not during game over dialog
1764  if (C4GameOverDlg::IsShown()) return false;
1765  // Open menu
1766  return !!Menu.ActivateMain(Number);
1767 }
static bool IsShown()
Definition: C4GameOverDlg.h:91
bool ActivateMain(int32_t iPlayer)
Definition: C4MainMenu.cpp:566

References C4MainMenu::ActivateMain(), C4GameOverDlg::IsShown(), Menu, and Number.

Here is the call graph for this function:

◆ ActivateMenuTeamSelection()

bool C4Player::ActivateMenuTeamSelection ( bool  fFromMain)

Definition at line 1238 of file C4Player.cpp.

1239 {
1240  // Menu symbol/init
1241  bool fSwitch = !(Status==PS_TeamSelection);
1244  Menu.Refill();
1245  // Go back to options menu on close
1246  if (fFromMain) Menu.SetCloseCommand("ActivateMenu:Main");
1247  return true;
1248 }
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
@ C4MN_TeamSwitch
Definition: C4MainMenu.h:29
@ C4MN_TeamSelection
Definition: C4MainMenu.h:28
@ C4MN_Extra_None
Definition: C4Menu.h:44
@ C4MN_Align_Left
Definition: C4Menu.h:50
@ C4MN_Align_Bottom
Definition: C4Menu.h:53
static C4Facet GetIconFacet(Icons icoIconIndex)
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:56
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:857
bool Refill()
Definition: C4Menu.cpp:915
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1144
int32_t Status
Definition: C4Player.h:82
@ Ico_Team
Definition: C4Gui.h:662

References C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Extra_None, C4MN_TeamSelection, C4MN_TeamSwitch, C4GUI::Icon::GetIconFacet(), C4GUI::Ico_Team, C4MainMenu::InitRefSym(), LoadResStr(), Menu, Number, PS_TeamSelection, C4Menu::Refill(), C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), and Status.

Referenced by Execute(), and C4MainMenu::MenuCommand().

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

◆ ActiveCrewCount()

int32_t C4Player::ActiveCrewCount ( )

Definition at line 1496 of file C4Player.cpp.

1497 {
1498  // get number of objects in crew that is not disabled
1499  int32_t iNum=0;
1500  for (C4Object *cObj : Crew)
1501  if (cObj)
1502  if (!cObj->CrewDisabled)
1503  ++iNum;
1504  // return it
1505  return iNum;
1506 }

References Crew.

◆ AdjustCursorCommand()

void C4Player::AdjustCursorCommand ( )

Definition at line 1059 of file C4Player.cpp.

1060 {
1061  // Reset view
1062  ResetCursorView();
1063  // Default cursor to hirank clonk
1064  if (!Cursor || Cursor->CrewDisabled)
1065  {
1066  C4Object *pHiRank = GetHiRankActiveCrew();
1067  if (!pHiRank)
1068  return;
1069  SetCursor(pHiRank,true);
1070  UpdateView();
1071  }
1072 }
bool CrewDisabled
Definition: C4Object.h:162
C4ObjectPtr Cursor
Definition: C4Player.h:130
void SetCursor(C4Object *pObj, bool fSelectArrow)
Definition: C4Player.cpp:1348
void ResetCursorView(bool immediate_position=false)
Definition: C4Player.cpp:780
C4Object * GetHiRankActiveCrew()
Definition: C4Player.cpp:886
void UpdateView()
Definition: C4Player.cpp:1180

References C4Object::CrewDisabled, Cursor, GetHiRankActiveCrew(), ResetCursorView(), SetCursor(), and UpdateView().

Referenced by ClearPointers(), and FinalInit().

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

◆ CallMessageBoard()

void C4Player::CallMessageBoard ( C4Object pForObj,
const StdStrBuf sQueryString,
bool  fUppercase 
)

Definition at line 1664 of file C4Player.cpp.

1665 {
1666  // remove any previous query for the same object
1667  RemoveMessageBoardQuery(pForObj);
1668  // sort new query to end of list
1669  C4MessageBoardQuery **ppTarget = &pMsgBoardQuery;
1670  while (*ppTarget) ppTarget = &((*ppTarget)->pNext);
1671  *ppTarget = new C4MessageBoardQuery(pForObj, sQueryString, fIsUppercase);
1672 }
bool RemoveMessageBoardQuery(C4Object *pForObj)
Definition: C4Player.cpp:1674

References pMsgBoardQuery, and RemoveMessageBoardQuery().

Here is the call graph for this function:

◆ CheckCrewExPromotion()

void C4Player::CheckCrewExPromotion ( )
protected

Definition at line 905 of file C4Player.cpp.

906 {
907  C4Object *hirank;
908  if ((hirank=GetHiRankActiveCrew()))
909  if (hirank->Info)
910  if (hirank->Info->Rank<1) // No Fähnrich -> except. promo.
911  if ((hirank=GetHiExpActiveCrew()))
912  hirank->Promote(1,true,false);
913 }
C4ObjectInfo * Info
Definition: C4Object.h:143
bool Promote(int32_t torank, bool exception, bool fForceRankName)
C4Object * GetHiExpActiveCrew()
Definition: C4Player.cpp:867

References GetHiExpActiveCrew(), GetHiRankActiveCrew(), C4Object::Info, C4Object::Promote(), and C4ObjectInfoCore::Rank.

Here is the call graph for this function:

◆ CheckElimination()

void C4Player::CheckElimination ( )
protected

Definition at line 1168 of file C4Player.cpp.

1169 {
1170  // Standard elimination: no crew
1171  if (!Crew.GetFirstObject())
1172  // Already eliminated safety
1173  if (!Eliminated)
1174  // No automatic elimination desired?
1175  if (!NoEliminationCheck)
1176  // Do elimination!
1177  Eliminate();
1178 }
C4Object * GetFirstObject() const
Definition: C4ObjectList.h:141
int32_t Eliminated
Definition: C4Player.h:83
void Eliminate()
Definition: C4Player.cpp:1472

References Crew, Eliminate(), Eliminated, C4ObjectList::GetFirstObject(), and NoEliminationCheck.

Referenced by Execute().

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

◆ CheckPromotion()

bool C4PlayerInfoCore::CheckPromotion ( C4RankSystem rRanks)
inherited

Definition at line 145 of file C4InfoCore.cpp.

146 {
147  if (TotalScore >= rRanks.Experience(Rank + 1))
148  {
149  Promote(Rank + 1,rRanks);
150  return true;
151  }
152  return false;
153 }
void Promote(int32_t iRank, C4RankSystem &rRanks)
Definition: C4InfoCore.cpp:139
int32_t TotalScore
Definition: C4InfoCore.h:89
int Experience(int iRank)

References C4RankSystem::Experience(), C4PlayerInfoCore::Promote(), C4PlayerInfoCore::Rank, and C4PlayerInfoCore::TotalScore.

Here is the call graph for this function:

◆ ClearControl()

void C4Player::ClearControl ( )
protected

Definition at line 1373 of file C4Player.cpp.

1374 {
1375  // Mark any control set as unused
1376  Control.Clear();
1377  // Reset control
1378  LocalControl = false;
1380  ControlSet=nullptr;
1381  MouseControl = false;
1382  if (pGamepad)
1383  {
1384  pGamepad->SetPlayer(NO_OWNER);
1385  pGamepad.reset();
1386  }
1387  // no controls issued yet
1388  ControlCount = ActionCount = 0;
1390  LastControlID = 0;
1391 }
const int NO_OWNER
Definition: C4Constants.h:137
C4PlayerControl Control
Definition: C4Player.h:129
class C4PlayerControlAssignmentSet * ControlSet
Definition: C4Player.h:90
std::shared_ptr< class C4GamePadOpener > pGamepad
Definition: C4Player.h:132
int32_t MouseControl
Definition: C4Player.h:92
StdCopyStrBuf ControlSetName
Definition: C4Player.h:91
void Clear()
Definition: StdBuf.h:466

References ActionCount, C4PlayerControl::Clear(), StdStrBuf::Clear(), Control, ControlCount, ControlSet, ControlSetName, LastControlID, LastControlType, LocalControl, MouseControl, NO_OWNER, PCID_None, and pGamepad.

Referenced by Init(), and ~C4Player().

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

◆ ClearGraphs()

void C4Player::ClearGraphs ( )

Definition at line 1615 of file C4Player.cpp.

1616 {
1617  // del all assigned graphs
1618  if (pstatControls)
1619  {
1620  if (Game.pNetworkStatistics) Game.pNetworkStatistics->statControls.RemoveGraph(pstatControls);
1621  delete pstatControls;
1622  pstatControls = nullptr;
1623  }
1624  if (pstatActions)
1625  {
1626  if (Game.pNetworkStatistics) Game.pNetworkStatistics->statActions.RemoveGraph(pstatActions);
1627  delete pstatActions;
1628  pstatActions = nullptr;
1629  }
1630 }
C4Game Game
Definition: C4Globals.cpp:52
std::unique_ptr< C4Network2Stats > pNetworkStatistics
Definition: C4Game.h:95

References Game, C4Game::pNetworkStatistics, pstatActions, and pstatControls.

Referenced by CreateGraphs(), and ~C4Player().

Here is the caller graph for this function:

◆ ClearPointers()

void C4Player::ClearPointers ( C4Object tptr,
bool  fDeath 
)

Definition at line 98 of file C4Player.cpp.

99 {
100  // Crew
101  while (Crew.Remove(pObj)) {}
102  // View-Cursor
103  if (ViewCursor==pObj) ViewCursor = nullptr;
104  // View
105  if (ViewTarget==pObj) ViewTarget=nullptr;
106  // Cursor
107  if (Cursor == pObj)
108  {
109  // object is to be deleted; do NOT do script calls (like in Cursor->UnSelect(true))
110  Cursor = nullptr; AdjustCursorCommand(); // also selects and eventually does a script call!
111  }
112  // Menu
113  Menu.ClearPointers(pObj);
114  // messageboard-queries
116 }
void ClearPointers(C4Object *pObj)
Definition: C4Menu.cpp:1158
virtual bool Remove(C4Object *obj)
C4Object * ViewTarget
Definition: C4Player.h:108
C4ObjectPtr ViewCursor
Definition: C4Player.h:130
void AdjustCursorCommand()
Definition: C4Player.cpp:1059

References AdjustCursorCommand(), C4Menu::ClearPointers(), Crew, Cursor, Menu, C4ObjectList::Remove(), RemoveMessageBoardQuery(), ViewCursor, and ViewTarget.

Referenced by C4Object::AssignDeath(), and C4Object::AssignInfo().

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

◆ CloseMenu()

void C4Player::CloseMenu ( )

Definition at line 1466 of file C4Player.cpp.

1467 {
1468  // cancel all player menus
1469  Menu.Close(false);
1470 }
void Close(bool fOK)

References C4GUI::Dialog::Close(), and Menu.

Here is the call graph for this function:

◆ CompileFunc() [1/2]

void C4PlayerInfoCore::CompileFunc ( StdCompiler pComp)
inherited

Definition at line 155 of file C4InfoCore.cpp.

156 {
157  C4ValueNumbers numbers;
158  pComp->Name("Player");
159  pComp->Value(mkNamingAdapt(toC4CStr(PrefName), "Name", "Neuling"));
160  pComp->Value(mkNamingAdapt(toC4CStr(Comment), "Comment", ""));
161  pComp->Value(mkNamingAdapt(Rank, "Rank", 0));
162  pComp->Value(mkNamingAdapt(toC4CStr(RankName), "RankName", LoadResStr("IDS_MSG_RANK"))); // TODO: check if this would be desirable
163  pComp->Value(mkNamingAdapt(TotalScore, "Score", 0));
164  pComp->Value(mkNamingAdapt(Rounds, "Rounds", 0));
165  pComp->Value(mkNamingAdapt(RoundsWon, "RoundsWon", 0));
166  pComp->Value(mkNamingAdapt(RoundsLost, "RoundsLost", 0));
167  pComp->Value(mkNamingAdapt(TotalPlayingTime, "TotalPlayingTime", 0));
168  pComp->Value(mkNamingAdapt(mkParAdapt(ExtraData, &numbers), "ExtraData", C4ValueMapData()));
169  pComp->Value(mkNamingAdapt(numbers, "ExtraDataValues"));
170  if (pComp->isDeserializer())
171  {
172  numbers.Denumerate();
173  ExtraData.Denumerate(&numbers);
174  }
175  pComp->Value(mkNamingAdapt(toC4CStr(LeagueName), "LeagueName", ""));
176  pComp->NameEnd();
177 
178  pComp->Name("Preferences");
179  pComp->Value(mkNamingAdapt(PrefColor, "Color", 0));
180  pComp->Value(mkNamingAdapt(PrefColorDw, "ColorDw", 0xffu));
181  pComp->Value(mkNamingAdapt(PrefColor2Dw, "AlternateColorDw", 0u));
182  pComp->Value(mkNamingAdapt(PrefMouse, "Mouse", 1));
183  pComp->Value(mkNamingAdapt(OldPrefControl, "Control", 1));
184  pComp->Value(mkNamingAdapt(OldPrefControlStyle, "AutoStopControl", 0));
185  pComp->Value(mkNamingAdapt(OldPrefAutoContextMenu, "AutoContextMenu", -1)); // Compiling default is -1 (if this is detected, AutoContextMenus will be defaulted by control style)
186  pComp->Value(mkNamingAdapt(PrefControl, "ControlSet", StdStrBuf()));
187  pComp->Value(mkNamingAdapt(PrefClonkSkin, "ClonkSkin", 0));
188  pComp->NameEnd();
189 
190  pComp->Value(mkNamingAdapt(LastRound, "LastRound"));
191  pComp->Value(mkNamingAdapt(Achievements, "Achievements"));
192 }
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
#define toC4CStr(szString)
Definition: StdAdaptors.h:24
char Comment[C4MaxComment+1]
Definition: C4InfoCore.h:86
StdCopyStrBuf PrefControl
Definition: C4InfoCore.h:96
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:104
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:99
int32_t RoundsWon
Definition: C4InfoCore.h:90
int32_t PrefColor
Definition: C4InfoCore.h:98
char LeagueName[C4MaxName+1]
Definition: C4InfoCore.h:94
int32_t TotalPlayingTime
Definition: C4InfoCore.h:91
int32_t Rounds
Definition: C4InfoCore.h:90
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:105
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:88
int32_t RoundsLost
Definition: C4InfoCore.h:90
C4RoundResult LastRound
Definition: C4InfoCore.h:92
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:85
int32_t PrefClonkSkin
Definition: C4InfoCore.h:100
uint32_t PrefColorDw
Definition: C4InfoCore.h:99
int32_t PrefMouse
Definition: C4InfoCore.h:97
C4ValueMapData ExtraData
Definition: C4InfoCore.h:93
int32_t OldPrefControl
Definition: C4InfoCore.h:103
C4ScenarioParameters Achievements
Definition: C4InfoCore.h:108
void Denumerate(C4ValueNumbers *)
Definition: C4ValueMap.cpp:254
void Denumerate()
Definition: C4Value.cpp:281
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual void NameEnd(bool fBreak=false)
Definition: StdCompiler.h:78
virtual bool isDeserializer()
Definition: StdCompiler.h:53
virtual bool Name(const char *szName)
Definition: StdCompiler.h:77

References C4PlayerInfoCore::Achievements, C4PlayerInfoCore::Comment, C4ValueNumbers::Denumerate(), C4ValueMapData::Denumerate(), C4PlayerInfoCore::ExtraData, StdCompiler::isDeserializer(), C4PlayerInfoCore::LastRound, C4PlayerInfoCore::LeagueName, LoadResStr(), mkNamingAdapt(), mkParAdapt(), StdCompiler::Name(), StdCompiler::NameEnd(), C4PlayerInfoCore::OldPrefAutoContextMenu, C4PlayerInfoCore::OldPrefControl, C4PlayerInfoCore::OldPrefControlStyle, C4PlayerInfoCore::PrefClonkSkin, C4PlayerInfoCore::PrefColor, C4PlayerInfoCore::PrefColor2Dw, C4PlayerInfoCore::PrefColorDw, C4PlayerInfoCore::PrefControl, C4PlayerInfoCore::PrefMouse, C4PlayerInfoCore::PrefName, C4PlayerInfoCore::Rank, C4PlayerInfoCore::RankName, C4PlayerInfoCore::Rounds, C4PlayerInfoCore::RoundsLost, C4PlayerInfoCore::RoundsWon, toC4CStr, C4PlayerInfoCore::TotalPlayingTime, C4PlayerInfoCore::TotalScore, and StdCompiler::Value().

Here is the call graph for this function:

◆ CompileFunc() [2/2]

void C4Player::CompileFunc ( StdCompiler pComp,
C4ValueNumbers numbers 
)

Definition at line 1074 of file C4Player.cpp.

1075 {
1076  assert(ID);
1077 
1078  pComp->Value(mkNamingAdapt(Status, "Status", 0));
1079  pComp->Value(mkNamingAdapt(AtClient, "AtClient", C4ClientIDUnknown));
1080  pComp->Value(mkNamingAdapt(toC4CStr(AtClientName),"AtClientName", "Local"));
1081  pComp->Value(mkNamingAdapt(Number, "Index", C4P_Number_None));
1082  pComp->Value(mkNamingAdapt(ID, "ID", 0));
1083  pComp->Value(mkNamingAdapt(Eliminated, "Eliminated", 0));
1084  pComp->Value(mkNamingAdapt(Surrendered, "Surrendered", 0));
1085  pComp->Value(mkNamingAdapt(Evaluated, "Evaluated", false));
1086  pComp->Value(mkNamingAdapt(ColorDw, "ColorDw", 0u));
1087  pComp->Value(mkNamingAdapt(Position, "Position", 0));
1088  pComp->Value(mkNamingAdapt(ViewMode, "ViewMode", C4PVM_Cursor));
1089  pComp->Value(mkNamingAdapt(ViewX, "ViewX", 0));
1090  pComp->Value(mkNamingAdapt(ViewY, "ViewY", 0));
1091  pComp->Value(mkNamingAdapt(ViewLock, "ViewLock", true));
1092  pComp->Value(mkNamingAdapt(ZoomLimitMinWdt, "ZoomLimitMinWdt", 0));
1093  pComp->Value(mkNamingAdapt(ZoomLimitMinHgt, "ZoomLimitMinHgt", 0));
1094  pComp->Value(mkNamingAdapt(ZoomLimitMaxWdt, "ZoomLimitMaxWdt", 0));
1095  pComp->Value(mkNamingAdapt(ZoomLimitMaxHgt, "ZoomLimitMaxHgt", 0));
1096  pComp->Value(mkNamingAdapt(ZoomWdt, "ZoomWdt", 0));
1097  pComp->Value(mkNamingAdapt(ZoomHgt, "ZoomHgt", 0));
1098  pComp->Value(mkNamingAdapt(ZoomLimitMinVal, "ZoomLimitMinVal", Fix0));
1099  pComp->Value(mkNamingAdapt(ZoomLimitMaxVal, "ZoomLimitMaxVal", Fix0));
1100  pComp->Value(mkNamingAdapt(ZoomVal, "ZoomVal", Fix0));
1101  pComp->Value(mkNamingAdapt(fFogOfWar, "FogOfWar", false));
1102  pComp->Value(mkNamingAdapt(ShowStartup, "ShowStartup", false));
1103  pComp->Value(mkNamingAdapt(Wealth, "Wealth", 0));
1104  pComp->Value(mkNamingAdapt(CurrentScore, "Score", 0));
1105  pComp->Value(mkNamingAdapt(InitialScore, "InitialScore", 0));
1106  pComp->Value(mkNamingAdapt(ObjectsOwned, "ObjectsOwned", 0));
1107  pComp->Value(mkNamingAdapt(Hostility, "Hostile" ));
1108  pComp->Value(mkNamingAdapt(ProductionDelay, "ProductionDelay", 0));
1109  pComp->Value(mkNamingAdapt(ProductionUnit, "ProductionUnit", 0));
1110  pComp->Value(mkNamingAdapt(CursorFlash, "CursorFlash", 0));
1111  pComp->Value(mkNamingAdapt(Cursor, "Cursor", C4ObjectPtr::Null));
1112  pComp->Value(mkNamingAdapt(ViewCursor, "ViewCursor", C4ObjectPtr::Null));
1113  pComp->Value(mkNamingAdapt(MessageStatus, "MessageStatus", 0));
1114  pComp->Value(mkNamingAdapt(toC4CStr(MessageBuf),"MessageBuf", ""));
1115  pComp->Value(mkNamingAdapt(BaseMaterial, "BaseMaterial" ));
1116  pComp->Value(mkNamingAdapt(BaseProduction, "BaseProduction" ));
1117  pComp->Value(mkNamingAdapt(Knowledge, "Knowledge" ));
1118  pComp->Value(mkNamingAdapt(mkParAdapt(Crew, numbers), "Crew" ));
1119  pComp->Value(mkNamingAdapt(CrewInfoList.iNumCreated, "CrewCreated", 0));
1120  pComp->Value(mkNamingPtrAdapt( pMsgBoardQuery, "MsgBoardQueries" ));
1121  pComp->Value(mkNamingAdapt(mkParAdapt(SoundModifier, numbers), "SoundModifier", C4Value()));
1122 
1123  if (pComp->isDeserializer())
1124  {
1125  SoundModifier.Denumerate(numbers);
1126  }
1127 
1128  // Keys held down
1129  pComp->Value(Control);
1130 }
const int32_t C4ClientIDUnknown
Definition: C4Client.h:24
const int32_t C4PVM_Cursor
Definition: C4Player.h:31
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
Definition: StdAdaptors.h:636
static const C4ObjectPtr Null
Definition: C4ObjectPtr.h:28
int32_t CurrentScore
Definition: C4Player.h:116
C4IDList BaseProduction
Definition: C4Player.h:121
int32_t ObjectsOwned
Definition: C4Player.h:117
int32_t InitialScore
Definition: C4Player.h:116
int32_t ViewMode
Definition: C4Player.h:105
uint32_t ColorDw
Definition: C4Player.h:89
HostilitySet Hostility
Definition: C4Player.h:118
bool ShowStartup
Definition: C4Player.h:109
int32_t Position
Definition: C4Player.h:93
C4IDList BaseMaterial
Definition: C4Player.h:120
int32_t Wealth
Definition: C4Player.h:115
int32_t CursorFlash
Definition: C4Player.h:131
char MessageBuf[256+1]
Definition: C4Player.h:135
C4Real ViewY
Definition: C4Player.h:106
int32_t Surrendered
Definition: C4Player.h:84
int32_t MessageStatus
Definition: C4Player.h:134
char AtClientName[C4MaxTitle+1]
Definition: C4Player.h:98
int32_t ProductionUnit
Definition: C4Player.h:122
C4Real ViewX
Definition: C4Player.h:106
C4IDList Knowledge
Definition: C4Player.h:127
int32_t ProductionDelay
Definition: C4Player.h:122
int32_t AtClient
Definition: C4Player.h:97
void Denumerate(C4ValueNumbers *)
Definition: C4Value.cpp:251

References AtClient, AtClientName, BaseMaterial, BaseProduction, C4ClientIDUnknown, C4P_Number_None, C4PVM_Cursor, ColorDw, Control, Crew, CrewInfoList, CurrentScore, Cursor, CursorFlash, C4Value::Denumerate(), Eliminated, Evaluated, fFogOfWar, Fix0, Hostility, ID, InitialScore, C4ObjectInfoList::iNumCreated, StdCompiler::isDeserializer(), Knowledge, MessageBuf, MessageStatus, mkNamingAdapt(), mkNamingPtrAdapt(), mkParAdapt(), C4ObjectPtr::Null, Number, ObjectsOwned, pMsgBoardQuery, Position, ProductionDelay, ProductionUnit, ShowStartup, SoundModifier, Status, Surrendered, toC4CStr, StdCompiler::Value(), ViewCursor, ViewLock, ViewMode, ViewX, ViewY, Wealth, ZoomHgt, ZoomLimitMaxHgt, ZoomLimitMaxVal, ZoomLimitMaxWdt, ZoomLimitMinHgt, ZoomLimitMinVal, ZoomLimitMinWdt, ZoomVal, and ZoomWdt.

Here is the call graph for this function:

◆ CountControl()

void C4Player::CountControl ( ControlType  eType,
int32_t  iID,
int32_t  iCntAdd = 1 
)

Definition at line 1632 of file C4Player.cpp.

1633 {
1634  // count it
1635  ControlCount += iCntAdd;
1636  // catch doubles
1637  if (eType == LastControlType && iID == LastControlID) return;
1638  // no double: count as action
1639  LastControlType = eType;
1640  LastControlID = iID;
1641  ActionCount += iCntAdd;
1642  // and give experience
1643  if (Cursor && Cursor->Info)
1644  {
1645  if (Cursor->Info)
1646  {
1647  Cursor->Info->ControlCount++; if ((Cursor->Info->ControlCount%5) == 0) Cursor->DoExperience(+1);
1648  }
1649  }
1650 }
void DoExperience(int32_t change)
int32_t ControlCount
Definition: C4ObjectInfo.h:38

References ActionCount, C4ObjectInfo::ControlCount, ControlCount, Cursor, C4Object::DoExperience(), C4Object::Info, LastControlID, and LastControlType.

Here is the call graph for this function:

◆ CreateGraphs()

void C4Player::CreateGraphs ( )

Definition at line 1588 of file C4Player.cpp.

1589 {
1590  // del prev
1591  ClearGraphs();
1592  // create graphs
1594  {
1595  DWORD dwGraphClr = ColorDw;
1596  C4PlayerInfo *pInfo;
1597  if (ID && (pInfo = Game.PlayerInfos.GetPlayerInfoByID(ID)))
1598  {
1599  // set color by player info class
1600  dwGraphClr = pInfo->GetColor();
1601  }
1602  C4GUI::MakeColorReadableOnBlack(dwGraphClr); dwGraphClr &= 0xffffff;
1604  pstatControls->SetColorDw(dwGraphClr);
1607  pstatActions->SetColorDw(dwGraphClr);
1609  // register into
1610  Game.pNetworkStatistics->statControls.AddGraph(pstatControls);
1611  Game.pNetworkStatistics->statActions.AddGraph(pstatActions);
1612  }
1613 }
uint32_t DWORD
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:71
void SetTitle(const char *szNewTitle)
void SetColorDw(DWORD dwClr)
const char * GetName() const
Definition: C4Player.h:151
uint32_t GetColor() const
Definition: C4PlayerInfo.h:153
C4PlayerInfo * GetPlayerInfoByID(int32_t id) const
DWORD MakeColorReadableOnBlack(DWORD &rdwClr)
Definition: C4Gui.cpp:98

References ClearGraphs(), ColorDw, C4TableGraph::DefaultBlockLength, Game, C4PlayerInfo::GetColor(), GetName(), C4PlayerInfoList::GetPlayerInfoByID(), ID, C4GUI::MakeColorReadableOnBlack(), C4Game::PlayerInfos, C4Game::pNetworkStatistics, pstatActions, pstatControls, C4Graph::SetColorDw(), and C4Graph::SetTitle().

Referenced by Init().

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

◆ Default()

void C4PlayerInfoCore::Default ( C4RankSystem pRanks = nullptr)
inherited

Definition at line 40 of file C4InfoCore.cpp.

41 {
42  *Comment = '\0';
43  *RankName = '\0';
44  TotalScore = 0;
45  Rounds = 0;
46  RoundsWon = 0;
47  RoundsLost = 0;
48  TotalPlayingTime = 0;
49  *LeagueName = '\0';
53  Rank = 0;
54  SCopy("Neuling",PrefName);
55  if (pRanks)
56  {
57  SCopy(pRanks->GetRankName(Rank, false).getData(), RankName);
58  }
59  else
60  {
61  SCopy("Rang", RankName);
62  }
63  PrefClonkSkin = 0;
64  PrefColor = 0;
65  PrefColorDw = 0xff;
66  PrefColor2Dw = 0;
67  OldPrefControl = 0;
68  PrefMouse = 1;
72  ExtraData.Reset();
73 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
const char * getData() const
Definition: StdBuf.h:442

References StdStrBuf::Clear(), C4PlayerInfoCore::Comment, C4RoundResult::Default(), C4PlayerInfoCore::ExtraData, StdStrBuf::getData(), C4RankSystem::GetRankName(), C4PlayerInfoCore::LastRound, C4PlayerInfoCore::LeagueName, C4PlayerInfoCore::OldPrefAutoContextMenu, C4PlayerInfoCore::OldPrefControl, C4PlayerInfoCore::OldPrefControlStyle, C4PlayerInfoCore::PrefClonkSkin, C4PlayerInfoCore::PrefColor, C4PlayerInfoCore::PrefColor2Dw, C4PlayerInfoCore::PrefColorDw, C4PlayerInfoCore::PrefControl, C4PlayerInfoCore::PrefMouse, C4PlayerInfoCore::PrefName, C4PlayerInfoCore::Rank, C4PlayerInfoCore::RankName, C4ValueMapData::Reset(), C4PlayerInfoCore::Rounds, C4PlayerInfoCore::RoundsLost, C4PlayerInfoCore::RoundsWon, SCopy(), C4PlayerInfoCore::TotalPlayingTime, and C4PlayerInfoCore::TotalScore.

Referenced by C4PlayerInfoCore::C4PlayerInfoCore(), and C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg().

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

◆ DefaultRuntimeData()

void C4Player::DefaultRuntimeData ( )

Definition at line 1206 of file C4Player.cpp.

1207 {
1208  Status=0;
1209  Eliminated=0;
1210  Surrendered=0;
1212  SCopy("Local",AtClientName);
1213  ControlSet = nullptr;
1215  MouseControl=false;
1216  Position=-1;
1217  PlrStartIndex=0;
1218  RetireDelay=0;
1220  ViewX=ViewY=0;
1221  ViewTarget=nullptr;
1222  ShowStartup=true;
1223  Wealth=0;
1225  ObjectsOwned=0;
1227  Cursor=ViewCursor=nullptr;
1228  CursorFlash=30;
1229  MessageStatus=0;
1230  MessageBuf[0]=0;
1231  Hostility.clear();
1234  Knowledge.Default();
1235  FlashCom=0;
1236 }
void Default()
Definition: stub-handle.cpp:63
int32_t FlashCom
Definition: C4Player.h:110
int32_t RetireDelay
Definition: C4Player.h:95
int32_t PlrStartIndex
Definition: C4Player.h:94

References AtClient, AtClientName, BaseMaterial, BaseProduction, C4ClientIDUnknown, C4PVM_Cursor, StdStrBuf::Clear(), ControlSet, ControlSetName, CurrentScore, Cursor, CursorFlash, C4IDList::Default(), Eliminated, FlashCom, Hostility, InitialScore, Knowledge, MessageBuf, MessageStatus, MouseControl, ObjectsOwned, PlrStartIndex, Position, ProductionDelay, ProductionUnit, RetireDelay, SCopy(), ShowStartup, Status, Surrendered, ViewCursor, ViewMode, ViewTarget, ViewX, ViewY, and Wealth.

Referenced by C4Player().

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

◆ DenumeratePointers()

void C4Player::DenumeratePointers ( )

Definition at line 1258 of file C4Player.cpp.

1259 {
1260  // Crew
1262  // Cursor
1264  // ViewCursor
1266  // messageboard-queries
1267  for (C4MessageBoardQuery *pCheck = pMsgBoardQuery; pCheck; pCheck = pCheck->pNext)
1268  pCheck->CallbackObj.DenumeratePointers();
1269 }
bool DenumeratePointers()
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:49

References Crew, Cursor, C4ObjectList::DenumeratePointers(), C4ObjectPtr::DenumeratePointers(), pMsgBoardQuery, C4MessageBoardQuery::pNext, and ViewCursor.

Referenced by LoadRuntimeData().

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

◆ DoScore()

bool C4Player::DoScore ( int32_t  iChange)

Definition at line 1342 of file C4Player.cpp.

1343 {
1344  CurrentScore = Clamp<int32_t>( CurrentScore+iChange, -100000, 100000 );
1345  return true;
1346 }

References CurrentScore.

◆ DoTeamSelection()

void C4Player::DoTeamSelection ( int32_t  idTeam)

Definition at line 1250 of file C4Player.cpp.

1251 {
1252  // stop team selection. This might close the menu forever if the control gets lost
1253  // let's hope it doesn't!
1256 }
@ CDT_Queue
Definition: C4GameControl.h:34
@ CID_PlrAction
Definition: C4PacketBase.h:166
static C4ControlPlayerAction * InitScenarioPlayer(const C4Player *source, int32_t team)
Definition: C4Control.cpp:605

References CDT_Queue, CID_PlrAction, Control, C4ControlPlayerAction::InitScenarioPlayer(), PS_TeamSelectionPending, and Status.

Referenced by Execute(), and C4MainMenu::MenuCommand().

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

◆ DoWealth()

bool C4Player::DoWealth ( int32_t  change)

Definition at line 729 of file C4Player.cpp.

730 {
731  if (LocalControl)
732  {
733  if (iChange>0) StartSoundEffect("UI::Cash");
734  if (iChange<0) StartSoundEffect("UI::UnCash");
735  }
736  SetWealth(Wealth+iChange);
737 
738  return true;
739 }
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
bool SetWealth(int32_t val)
Definition: C4Player.cpp:741

References LocalControl, SetWealth(), StartSoundEffect(), and Wealth.

Here is the call graph for this function:

◆ DrawHostility()

void C4Player::DrawHostility ( C4Facet cgo,
int32_t  iIndex 
)

Definition at line 995 of file C4Player.cpp.

996 {
997  C4Player *pPlr;
998  if ((pPlr=::Players.GetByIndex(iIndex)))
999  {
1000  ::GraphicsResource.fctCrewClr.DrawClr(cgo, true, pPlr->ColorDw);
1001  // Other player and hostile
1002  if (pPlr != this)
1003  if (Hostility.find(pPlr) != Hostility.end())
1005  }
1006 }
C4GraphicsResource GraphicsResource
C4PlayerList Players
C4Facet GetPhase(int iPhaseX=0, int iPhaseY=0)
Definition: C4Facet.cpp:59
void DrawClr(C4Facet &cgo, bool fAspect=true, DWORD dwClr=0)
Definition: C4Facet.cpp:213
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
C4Player * GetByIndex(int iIndex) const

References ColorDw, C4Facet::Draw(), C4Facet::DrawClr(), C4GraphicsResource::fctCrewClr, C4GraphicsResource::fctMenu, C4PlayerList::GetByIndex(), C4Facet::GetPhase(), GraphicsResource, Hostility, and Players.

Referenced by C4MainMenu::DoRefillInternal().

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

◆ Eliminate()

void C4Player::Eliminate ( )

Definition at line 1472 of file C4Player.cpp.

1473 {
1474  if (Eliminated) return;
1475  Eliminated=true;
1477  StartSoundEffect("UI::Eliminated");
1478  Log(FormatString(LoadResStr("IDS_PRC_PLRELIMINATED"),GetName()).getData());
1479 
1480  // Early client deactivation check
1481  if (::Control.isCtrlHost() && AtClient > C4ClientIDHost && !::Application.isEditor)
1482  {
1483  // Check: Any player left at this client?
1484  C4Player *pPlr = nullptr;
1485  for (int i = 0; (pPlr = ::Players.GetAtClient(AtClient, i)); i++)
1486  if (!pPlr->Eliminated)
1487  break;
1488  // If not, deactivate the client
1489  if (!pPlr)
1490  ::Control.DoInput(CID_ClientUpdate,
1492  CDT_Sync);
1493  }
1494 }
const int32_t C4ClientIDHost
Definition: C4Client.h:25
const int C4RetireDelay
Definition: C4Constants.h:29
@ CUT_Activate
Definition: C4Control.h:367
@ CDT_Sync
Definition: C4GameControl.h:35
C4Application Application
Definition: C4Globals.cpp:44
bool Log(const char *szMessage)
Definition: C4Log.cpp:204
@ CID_ClientUpdate
Definition: C4PacketBase.h:145
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
C4Player * GetAtClient(int iClient, int iIndex=0) const

References Application, AtClient, C4ClientIDHost, C4RetireDelay, CDT_Sync, CID_ClientUpdate, Control, CUT_Activate, Eliminated, FormatString(), C4PlayerList::GetAtClient(), GetName(), C4Application::isEditor, LoadResStr(), Log(), Players, RetireDelay, and StartSoundEffect().

Referenced by CheckElimination().

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

◆ Evaluate()

void C4Player::Evaluate ( )

Definition at line 787 of file C4Player.cpp.

788 {
789  // do not evaluate twice
790  if (Evaluated) return;
791 
792  const int32_t SuccessBonus=100;
793 
794  // Set last round
796  time(reinterpret_cast<time_t *>(&LastRound.Date));
799  // Melee: personal value gain score ...check ::Objects(C4D_Goal)
800  if (Game.C4S.Game.IsMelee()) LastRound.Score = std::max<int32_t>(CurrentScore-InitialScore,0);
801  // Cooperative: shared score
802  else LastRound.Score = std::max(::Players.AverageScoreGain(),0);
803  LastRound.Level = 0; // unknown...
804  LastRound.Bonus = SuccessBonus * LastRound.Won;
807 
808  // Update player
809  Rounds++;
810  if (LastRound.Won) RoundsWon++; else RoundsLost++;
813 
814  // Crew
816 
817  // league
818  if (Game.Parameters.isLeague())
820 
821  // Player is now evaluated
822  Evaluated = true;
823 
824  // round results
826 }
C4RoundResults & RoundResults
Definition: C4Game.h:73
C4Scenario C4S
Definition: C4Game.h:74
C4GameParameters & Parameters
Definition: C4Game.h:67
bool GameOver
Definition: C4Game.h:114
int32_t Time
Definition: C4Game.h:132
StdCopyStrBuf ScenarioTitle
Definition: C4Game.h:103
bool isLeague() const
void EvaluateLeague(bool fDisconnected, bool fWon)
Definition: C4Player.cpp:1515
int AverageScoreGain() const
uint32_t Date
Definition: C4InfoCore.h:68
int32_t Bonus
Definition: C4InfoCore.h:72
int32_t Duration
Definition: C4InfoCore.h:69
int32_t FinalScore
Definition: C4InfoCore.h:71
int32_t TotalScore
Definition: C4InfoCore.h:71
int32_t Level
Definition: C4InfoCore.h:73
int32_t Score
Definition: C4InfoCore.h:71
int32_t Won
Definition: C4InfoCore.h:70
StdCopyStrBuf Title
Definition: C4InfoCore.h:67
void EvaluatePlayer(C4Player *pPlr)
bool IsMelee()
Definition: C4Scenario.cpp:512
C4SGame Game
Definition: C4Scenario.h:234

References C4PlayerList::AverageScoreGain(), C4RoundResult::Bonus, C4Game::C4S, CrewInfoList, CurrentScore, C4RoundResult::Date, C4RoundResult::Duration, Eliminated, C4ObjectInfoList::Evaluate(), Evaluated, EvaluateLeague(), C4RoundResults::EvaluatePlayer(), C4RoundResult::FinalScore, Game, C4Scenario::Game, GameJoinTime, C4Game::GameOver, InitialScore, C4GameParameters::isLeague(), C4SGame::IsMelee(), C4PlayerInfoCore::LastRound, C4RoundResult::Level, C4Game::Parameters, Players, C4Game::RoundResults, C4PlayerInfoCore::Rounds, C4PlayerInfoCore::RoundsLost, C4PlayerInfoCore::RoundsWon, C4Game::ScenarioTitle, C4RoundResult::Score, C4Game::Time, C4RoundResult::Title, C4PlayerInfoCore::TotalPlayingTime, C4RoundResult::TotalScore, C4PlayerInfoCore::TotalScore, and C4RoundResult::Won.

Referenced by C4PlayerList::Retire().

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

◆ EvaluateLeague()

void C4Player::EvaluateLeague ( bool  fDisconnected,
bool  fWon 
)

Definition at line 1515 of file C4Player.cpp.

1516 {
1517  // already evaluated?
1518  if (LeagueEvaluated) return;
1519  LeagueEvaluated=true;
1520  // set fate
1521  C4PlayerInfo *pInfo = GetInfo();
1522  if (pInfo)
1523  {
1524  if (fDisconnected)
1525  pInfo->SetDisconnected();
1526  if (fWon)
1527  pInfo->SetWinner();
1528  }
1529 }
class C4PlayerInfo * GetInfo()
Definition: C4Player.cpp:1552
void SetWinner()
Definition: C4PlayerInfo.h:201
void SetDisconnected()
Definition: C4PlayerInfo.h:200

References GetInfo(), LeagueEvaluated, C4PlayerInfo::SetDisconnected(), and C4PlayerInfo::SetWinner().

Referenced by Evaluate().

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

◆ ExecBaseProduction()

void C4Player::ExecBaseProduction ( )
protected

Definition at line 1153 of file C4Player.cpp.

1154 {
1155  const int32_t MaxBaseProduction = 25;
1156  ProductionDelay++;
1157  if (ProductionDelay>=60) // Minute Production Unit
1158  {
1160  for (int32_t cnt=0; BaseProduction.GetID(cnt); cnt++)
1161  if (BaseProduction.GetCount(cnt)>0)
1162  if (ProductionUnit % Clamp<int32_t>(11-BaseProduction.GetCount(cnt),1,10) ==0)
1163  if (BaseMaterial.GetIDCount(BaseProduction.GetID(cnt)) < MaxBaseProduction)
1165  }
1166 }
int32_t GetCount(size_t index) const
Definition: C4IDList.cpp:125
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:103
bool IncreaseIDCount(C4ID c_id, bool fAddNewID=true, int32_t IncreaseBy=1, bool fRemoveEmpty=false)
Definition: C4IDList.cpp:258
int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const
Definition: stub-handle.cpp:67

References BaseMaterial, BaseProduction, C4IDList::GetCount(), C4IDList::GetID(), C4IDList::GetIDCount(), C4IDList::IncreaseIDCount(), ProductionDelay, and ProductionUnit.

Referenced by Execute().

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

◆ Execute()

void C4Player::Execute ( )

Definition at line 162 of file C4Player.cpp.

163 {
164  if (!Status) return;
165 
166  // Open/refresh team menu if desired
168  {
169  int32_t idSelectedTeam;
170  if ((idSelectedTeam = Game.Teams.GetForcedTeamSelection(ID)))
171  {
172  // There's only one team left to join? Join there immediately.
173  if (Menu.IsActive() && Menu.GetIdentification() == C4MN_TeamSelection) Menu.TryClose(false, false);
174  if (LocalControl && !::Control.isReplay())
175  {
176  // team selection done through queue because TeamSelection-status may not be in sync (may be TeamSelectionPending!)
177  DoTeamSelection(idSelectedTeam);
178  }
179  }
180  else if (!Menu.IsActive()) ActivateMenuTeamSelection(false);
181  else
182  {
183  // during team selection: Update view to selected team, if it has a position assigned
184  C4MenuItem *pSelectedTeamItem;
185  if ((pSelectedTeamItem = Menu.GetSelectedItem()))
186  {
187  int32_t idSelectedTeam = atoi(pSelectedTeamItem->GetCommand()+8);
188  if (idSelectedTeam)
189  {
190  C4Team *pSelectedTeam;
191  if ((pSelectedTeam = Game.Teams.GetTeamByID(idSelectedTeam)))
192  {
193  int32_t iPlrStartIndex = pSelectedTeam->GetPlrStartIndex();
194  if (iPlrStartIndex && Inside<int32_t>(iPlrStartIndex, 1, C4S_MaxPlayer))
195  {
196  if (Game.C4S.PlrStart[iPlrStartIndex-1].Position[0] > -1)
197  {
198  // player has selected a team that has a valid start position assigned
199  // set view to this position!
200  ViewX = Game.C4S.PlrStart[iPlrStartIndex-1].Position[0] * ::Landscape.GetMapZoom();
201  ViewY = Game.C4S.PlrStart[iPlrStartIndex-1].Position[1] * ::Landscape.GetMapZoom();
202  }
203  }
204  }
205  }
206  }
207  }
208  }
210  {
211  Menu.TryClose(false, false);
212  }
213 
214  // Do we have a gamepad?
215  if (pGamepad)
216  {
217  // Check whether it's still connected.
218  if (!pGamepad->IsAttached())
219  {
220  // Allow the player to plug the gamepad back in. This allows
221  // battery replacement or plugging the controller back
222  // in after someone tripped over the wire.
223  if (!FindGamepad())
224  {
225  LogF("%s: No gamepad available.", Name.getData());
226  ::Game.Pause();
227  }
228  }
229  }
230  // Should we have one? The player may have started the game
231  // without turning their controller on, only noticing this
232  // after the game started.
233  else if (LocalControl && ControlSet && ControlSet->HasGamepad())
234  {
235  FindGamepad();
236  }
237 
238  // Tick1
239  UpdateView();
240  ExecuteControl();
241  Menu.Execute();
242 
243  // ::Game.iTick35
244  if (!::Game.iTick35 && Status==PS_Normal)
245  {
248  if (pMsgBoardQuery && LocalControl) ExecMsgBoardQueries();
249  }
250 
251  // Delays
252  if (MessageStatus>0) MessageStatus--;
253  if (RetireDelay>0) RetireDelay--;
254  if (CursorFlash>0) CursorFlash--;
255 }
const int C4S_MaxPlayer
Definition: C4Constants.h:53
C4Landscape Landscape
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
C4TeamList & Teams
Definition: C4Game.h:70
bool Pause()
Definition: C4Game.cpp:1171
int32_t iTick35
Definition: C4Game.h:130
int32_t GetMapZoom() const
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:280
int32_t GetIdentification()
Definition: C4Menu.cpp:612
C4MenuItem * GetSelectedItem()
Definition: C4Menu.cpp:583
void Execute()
Definition: C4Menu.cpp:903
bool IsActive()
Definition: C4Menu.cpp:480
const char * GetCommand() const
Definition: C4Menu.h:113
void DoTeamSelection(int32_t idTeam)
Definition: C4Player.cpp:1250
void ExecBaseProduction()
Definition: C4Player.cpp:1153
void ExecuteControl()
Definition: C4Player.cpp:1054
StdStrBuf Name
Definition: C4Player.h:81
void CheckElimination()
Definition: C4Player.cpp:1168
bool ActivateMenuTeamSelection(bool fFromMain)
Definition: C4Player.cpp:1238
int32_t Position[2]
Definition: C4Scenario.h:145
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:235
Definition: C4Teams.h:31
int32_t GetPlrStartIndex() const
Definition: C4Teams.h:69
C4Team * GetTeamByID(int32_t iID) const
Definition: C4Teams.cpp:383
int32_t GetForcedTeamSelection(int32_t idForPlayer) const
Definition: C4Teams.cpp:863

References ActivateMenuTeamSelection(), C4MN_TeamSelection, C4Game::C4S, C4S_MaxPlayer, CheckElimination(), Control, ControlSet, CursorFlash, DoTeamSelection(), ExecBaseProduction(), C4Menu::Execute(), ExecuteControl(), Game, C4MenuItem::GetCommand(), StdStrBuf::getData(), C4TeamList::GetForcedTeamSelection(), C4Menu::GetIdentification(), C4Landscape::GetMapZoom(), C4Team::GetPlrStartIndex(), C4Menu::GetSelectedItem(), C4TeamList::GetTeamByID(), C4PlayerControlAssignmentSet::HasGamepad(), ID, C4Menu::IsActive(), C4Game::iTick35, Landscape, LocalControl, LogF(), Menu, MessageStatus, Name, C4Game::Pause(), pGamepad, C4Scenario::PlrStart, pMsgBoardQuery, C4SPlrStart::Position, PS_Normal, PS_TeamSelection, RetireDelay, Status, C4Game::Teams, C4Menu::TryClose(), UpdateView(), ViewX, and ViewY.

Referenced by C4PlayerList::Execute(), and FinalInit().

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

◆ ExecuteControl()

void C4Player::ExecuteControl ( )

Definition at line 1054 of file C4Player.cpp.

1055 {
1056  Control.Execute();
1057 }

References Control, and C4PlayerControl::Execute().

Referenced by Execute().

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

◆ FinalInit()

bool C4Player::FinalInit ( bool  fInitialScore)

Definition at line 699 of file C4Player.cpp.

700 {
701  if (!Status) return true;
702 
703  // Init player's mouse control
704  if (LocalControl)
705  if (MouseControl)
706  ::MouseControl.Init(Number);
707 
708  // Set initial score
709  if (fInitialScore)
710  {
712  }
713 
714  // Cursor
715  if (!Cursor) AdjustCursorCommand();
716 
717  // Update counts, pointers, views
718  Execute();
719 
720  return true;
721 }
void Execute()
Definition: C4Player.cpp:162

References AdjustCursorCommand(), CurrentScore, Cursor, Execute(), InitialScore, LocalControl, MouseControl, Number, and Status.

Referenced by ScenarioAndTeamInit().

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

◆ FindNewOwner()

int32_t C4Player::FindNewOwner ( ) const

Definition at line 1279 of file C4Player.cpp.

1280 {
1281  int32_t iNewOwner = NO_OWNER;
1282  C4Team *pTeam;
1283  if (Team) if ((pTeam = Game.Teams.GetTeamByID(Team)))
1284  {
1285  for (int32_t i=0; i<pTeam->GetPlayerCount(); ++i)
1286  {
1287  int32_t iPlrID = pTeam->GetIndexedPlayer(i);
1288  if (iPlrID && iPlrID != ID)
1289  {
1290  C4PlayerInfo *pPlrInfo = Game.PlayerInfos.GetPlayerInfoByID(iPlrID);
1291  if (pPlrInfo) if (pPlrInfo->IsJoined())
1292  {
1293  // this looks like a good new owner
1294  iNewOwner = pPlrInfo->GetInGameNumber();
1295  break;
1296  }
1297  }
1298  }
1299  }
1300  // if noone from the same team was found, try to find another non-hostile player
1301  // (necessary for cooperative rounds without teams)
1302  if (iNewOwner == NO_OWNER)
1303  for (C4Player *pOtherPlr = ::Players.First; pOtherPlr; pOtherPlr = pOtherPlr->Next)
1304  if (pOtherPlr != this) if (!pOtherPlr->Eliminated)
1305  if (!::Players.Hostile(pOtherPlr->Number, Number))
1306  iNewOwner = pOtherPlr->Number;
1307 
1308  return iNewOwner;
1309 }
int32_t GetInGameNumber() const
Definition: C4PlayerInfo.h:189
bool IsJoined() const
Definition: C4PlayerInfo.h:166
bool Hostile(int iPlayer1, int iPlayer2) const
C4Player * First
Definition: C4PlayerList.h:31
int32_t GetIndexedPlayer(int32_t iIndex) const
Definition: C4Teams.h:76
int32_t GetPlayerCount() const
Definition: C4Teams.h:64

References C4PlayerList::First, Game, C4Team::GetIndexedPlayer(), C4PlayerInfo::GetInGameNumber(), C4Team::GetPlayerCount(), C4PlayerInfoList::GetPlayerInfoByID(), C4TeamList::GetTeamByID(), C4PlayerList::Hostile(), ID, C4PlayerInfo::IsJoined(), Next, NO_OWNER, Number, C4Game::PlayerInfos, Players, Team, and C4Game::Teams.

Referenced by NotifyOwnedObjects().

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

◆ GainScenarioAchievement()

bool C4Player::GainScenarioAchievement ( const char *  achievement_id,
int32_t  value,
const char *  scen_name_override = nullptr 
)

Definition at line 1907 of file C4Player.cpp.

1908 {
1909  // Determine full ID of achievement
1910  if (!scen_name_override)
1911  {
1912  if (::Game.C4S.Head.Origin.getLength())
1913  scen_name_override = ::Game.C4S.Head.Origin.getData();
1914  else
1915  scen_name_override = ::Game.ScenarioFilename;
1916  }
1917  StdStrBuf sAchvID = C4ScenarioParameters::AddFilename2ID(scen_name_override, achievement_id);
1918  // Gain achievement iff it's an improvement
1919  Achievements.SetValue(sAchvID.getData(), value, true);
1920  return true;
1921 }
char ScenarioFilename[_MAX_PATH_LEN]
Definition: C4Game.h:102
StdCopyStrBuf Origin
Definition: C4Scenario.h:80
C4SHead Head
Definition: C4Scenario.h:232
void SetValue(const char *id, int32_t value, bool only_if_larger)
static StdStrBuf AddFilename2ID(const char *filename, const char *id)
size_t getLength() const
Definition: StdBuf.h:445

References C4PlayerInfoCore::Achievements, C4ScenarioParameters::AddFilename2ID(), C4Game::C4S, Game, StdStrBuf::getData(), StdStrBuf::getLength(), C4Scenario::Head, C4SHead::Origin, C4Game::ScenarioFilename, and C4ScenarioParameters::SetValue().

Here is the call graph for this function:

◆ GetHiExpActiveCrew()

C4Object * C4Player::GetHiExpActiveCrew ( )

Definition at line 867 of file C4Player.cpp.

868 {
869  C4Object *hiexp=nullptr;
870  int32_t iHighestExp=-2, iExp;
871  for (C4Object *cobj : Crew)
872  {
873  if (!cobj->CrewDisabled)
874  {
875  if (cobj->Info) iExp = cobj->Info->Experience; else iExp=-1;
876  if (!hiexp || (iExp>iHighestExp))
877  {
878  hiexp=cobj;
879  iHighestExp=iExp;
880  }
881  }
882  }
883  return hiexp;
884 }
int32_t Experience
Definition: C4InfoCore.h:43

References Crew, C4ObjectInfoCore::Experience, and C4Object::Info.

Referenced by CheckCrewExPromotion().

Here is the caller graph for this function:

◆ GetHiRankActiveCrew()

C4Object * C4Player::GetHiRankActiveCrew ( )

Definition at line 886 of file C4Player.cpp.

887 {
888  C4Object *hirank=nullptr;
889  int32_t iHighestRank=-2, iRank;
890  for (C4Object *cobj : Crew)
891  {
892  if (!cobj->CrewDisabled)
893  {
894  if (cobj->Info) iRank = cobj->Info->Rank; else iRank=-1;
895  if (!hirank || (iRank>iHighestRank))
896  {
897  hirank=cobj;
898  iHighestRank=iRank;
899  }
900  }
901  }
902  return hirank;
903 }

References Crew, C4Object::Info, and C4ObjectInfoCore::Rank.

Referenced by AdjustCursorCommand(), and CheckCrewExPromotion().

Here is the caller graph for this function:

◆ GetInfo()

C4PlayerInfo * C4Player::GetInfo ( )

Definition at line 1552 of file C4Player.cpp.

1553 {
1555 }

References Game, C4PlayerInfoList::GetPlayerInfoByID(), ID, and C4Game::PlayerInfos.

Referenced by EvaluateLeague(), C4RoundResultsPlayer::EvaluatePlayer(), InitControl(), ScenarioAndTeamInit(), and ScenarioInit().

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

◆ GetName()

const char* C4Player::GetName ( ) const
inline

Definition at line 151 of file C4Player.h.

151 { return Name.getData(); }

References StdStrBuf::getData(), and Name.

Referenced by CreateGraphs(), C4MainMenu::DoRefillInternal(), Eliminate(), C4Object::GetDataString(), C4ViewportWindow::Init(), C4PlayerList::RemoveAtClient(), C4PlayerList::RemoveAtRemoteClient(), C4PlayerList::RemoveLocal(), ScenarioInit(), SetHostility(), and Surrender().

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

◆ GetPrefColorValue()

DWORD C4PlayerInfoCore::GetPrefColorValue ( int32_t  iPrefColor)
staticinherited

Definition at line 75 of file C4InfoCore.cpp.

76 {
77  DWORD valRGB[12] = { 0xFF0000E8, 0xFFF40000, 0xFF00C800, 0xFFFCF41C,
78  0xFFC48444, 0xFF784830, 0xFFA04400, 0xFFF08050,
79  0xFF848484, 0xFFFFFFFF, 0xFF0094F8, 0xFFBC00C0
80  };
81  if (Inside<int32_t>(iPrefColor, 0, 11))
82  {
83  return valRGB[iPrefColor];
84  }
85  return 0xFFAAAAAA;
86 }

Referenced by C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4PlayerInfoCore::Load(), C4StartupPlrPropertiesDlg::OnClrChangeLeft(), and C4StartupPlrPropertiesDlg::OnClrChangeRight().

Here is the caller graph for this function:

◆ GetSelectedCrewCount()

int32_t C4Player::GetSelectedCrewCount ( )

Definition at line 1508 of file C4Player.cpp.

1509 {
1510  if (Cursor && !Cursor->CrewDisabled)
1511  return 1;
1512  return 0;
1513 }

References C4Object::CrewDisabled, and Cursor.

◆ GetType()

C4PlayerType C4Player::GetType ( ) const

Definition at line 1727 of file C4Player.cpp.

1728 {
1729  // type by info
1731  if (pInfo) return pInfo->GetType(); else { assert(false); return C4PT_User; }
1732 }
@ C4PT_User
Definition: C4Constants.h:154
C4PlayerType GetType() const
Definition: C4PlayerInfo.h:152

References C4PT_User, Game, C4PlayerInfoList::GetPlayerInfoByID(), C4PlayerInfo::GetType(), ID, and C4Game::PlayerInfos.

Referenced by InitControl(), C4Object::IsUserPlayerObject(), LocalSync(), C4MainMenu::MenuCommand(), C4PlayerList::Retire(), and Save().

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

◆ HasMessageBoardQuery()

bool C4Player::HasMessageBoardQuery ( )

Definition at line 1698 of file C4Player.cpp.

1699 {
1700  // return whether any object has a messageboard-query
1701  return !!pMsgBoardQuery;
1702 }

References pMsgBoardQuery.

◆ Init()

bool C4Player::Init ( int32_t  iNumber,
int32_t  iAtClient,
const char *  szAtClientName,
const char *  szFilename,
bool  fScenarioInit,
class C4PlayerInfo pInfo,
C4ValueNumbers numbers 
)

Definition at line 257 of file C4Player.cpp.

259 {
260  // safety
261  if (!pInfo)
262  {
263  LogF("ERROR: Init player %s failed: No info!", szFilename);
264  assert(false);
265  return false;
266  }
267  // Status init
269  Number = iNumber;
270  ID = pInfo->GetID();
271  Team = pInfo->GetTeam();
272  NoEliminationCheck = pInfo->IsNoEliminationCheck();
273 
274  // At client
275  AtClient=iAtClient; SCopy(szAtClientName,AtClientName,C4MaxTitle);
276 
277  if (szFilename)
278  {
279  // Load core & crew info list
280  if (!Load(szFilename, !fScenarioInit)) return false;
281  }
282  else
283  {
284  // no core file present: Keep defaults
285  // This can happen for script players only
286  assert(pInfo->GetType() == C4PT_Script);
287  }
288 
289  // Take player name from player info; forcing overloads by the league or because of doubled player names
290  Name.Copy(pInfo->GetName());
291 
292  // view pos init: Start at center pos
294 
295  // Scenario init
296  if (fScenarioInit)
297  {
298  // mark player join in player info list
299  // for non-scenarioinit, player should already be marked as joined
300  pInfo->SetJoined(iNumber);
301 
302  // Number might have changed: Recheck list sorting before scenarioinit, which will do script calls
304 
305  // check for a postponed scenario init, if no team is specified (post-lobby-join in network, or simply non-network)
306  C4Team *pTeam = nullptr;
307  if (Team)
308  {
311  else
312  pTeam = Game.Teams.GetTeamByID(Team);
313  }
314  if (!pTeam && Game.Teams.IsRuntimeJoinTeamChoice())
315  {
316  if (pInfo->GetType() == C4PT_Script)
317  {
318  // script player without team: This can usually not happen, because RecheckPlayerInfoTeams should have been executed
319  // just leave this player without the team
320  assert(false);
321  }
322  else
323  {
324  // postponed init: Chose team first
326  }
327  }
328 
329  // Init control method before scenario init, because script callbacks may need to know it!
330  ClearControl();
331  InitControl();
332 
333  // defaultdisabled controls
334  Control.Init();
335 
336  // Special: Script players may skip scenario initialization altogether, and just desire a single callback to all objects
337  // of a given ID
338  if (!pInfo->IsScenarioInitDesired())
339  {
340  // only initialization that's done anyway is team hostility
341  if (Team) SetTeamHostility();
342  // callback definition passed?
343  C4ID idCallback = pInfo->GetScriptPlayerExtraID();
344  C4Def *pDefCallback;
345  if (idCallback && (pDefCallback = C4Id2Def(idCallback)))
346  {
348  }
349  }
350  else
351  {
352  // player preinit: In case a team needs to be chosen first, no InitializePlayer-broadcast is done
353  // this callback shall give scripters a chance to do stuff like starting an intro or enabling FoW, which might need to be done
355  // direct init
356  if (Status != PS_TeamSelection) if (!ScenarioInit()) return false;
357  }
358  }
359 
360  // Load runtime data
361  else
362  {
363  assert(pInfo->IsJoined());
364  assert(numbers);
365  // (compile using DefaultRuntimeData) - also check if compilation returned sane results, i.e. ID assigned
366  if (!LoadRuntimeData(Game.ScenarioFile, numbers) || !ID)
367  {
368  // for script players in non-savegames, this is OK - it means they get restored using default values
369  // this happens when the users saves a scenario using the "Save scenario"-option while a script player
370  // was joined
371  if (!Game.C4S.Head.SaveGame && pInfo->GetType() == C4PT_Script)
372  {
373  Number = pInfo->GetInGameNumber();
374  ColorDw = pInfo->GetColor();
375  ID = pInfo->GetID();
376  Team = pInfo->GetTeam();
377  }
378  else
379  return false;
380  }
381  // Reset values default-overriden by old runtime data load (safety?)
382  if (Number==C4P_Number_None) Number=iNumber;
383  if (szFilename) SCopy(Config.AtUserDataPath(szFilename),Filename); else *Filename='\0';
384  // NET2: Direct joins always send accurate client IDs and names in params
385  // do not overwrite them with savegame data, because players might as well
386  // change clients
387  // (only call should be savegame recreation by C4PlayerInfoList::RecreatePlayers)
388  AtClient = iAtClient;
389  SCopy(szAtClientName,AtClientName,C4MaxTitle);
390  // Number might have changed: Recheck list sorting
392  // Init control after loading runtime data, because control init will overwrite some of the values
393  InitControl();
394  }
395 
396  // store game joining time
398 
399  // Init FoW-viewobjects: NO_OWNER-FoW-repellers might need to be added
400  for (C4Object *pObj : Objects)
401  {
402  if ((pObj->lightRange || pObj->lightFadeoutRange) && pObj->Owner == NO_OWNER)
403  pObj->UpdateLight();
404  }
405 
406  // init graphs
408 
409  // init sound mod
411 
412  return true;
413 }
C4Config Config
Definition: C4Config.cpp:930
const size_t C4MaxTitle
Definition: C4Constants.h:25
@ C4PT_Script
Definition: C4Constants.h:155
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
#define PSF_InitializeScriptPlayer
Definition: C4GameScript.h:41
#define PSF_PreInitializePlayer
Definition: C4GameScript.h:42
C4GameObjects Objects
Definition: C4Globals.cpp:48
const char * AtUserDataPath(const char *filename)
Definition: C4Config.cpp:586
Definition: C4Def.h:99
C4Value GRBroadcast(const char *function, C4AulParSet *pars=nullptr, bool pass_error=false, bool reject_test=false)
Definition: C4Game.cpp:4761
C4Group ScenarioFile
Definition: C4Game.h:86
Definition: C4Id.h:26
int32_t GetWidth() const
int32_t GetHeight() const
void InitControl()
Definition: C4Player.cpp:1393
void SetTeamHostility()
Definition: C4Player.cpp:915
bool LoadRuntimeData(C4Group &hGroup, C4ValueNumbers *)
Definition: C4Player.cpp:1132
bool ScenarioInit()
Definition: C4Player.cpp:601
bool Load(const char *szFilename, bool fSavegame)
Definition: C4Player.cpp:937
void CreateGraphs()
Definition: C4Player.cpp:1588
void RecheckPlayerSort(C4Player *pForPlayer)
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:114
bool SaveGame
Definition: C4Scenario.h:71
bool IsRuntimeJoinTeamChoice() const
Definition: C4Teams.h:173
bool IsAutoGenerateTeams() const
Definition: C4Teams.h:172
C4Team * GetGenerateTeamByID(int32_t iID)
Definition: C4Teams.cpp:390
C4PropList * getPropList() const
Definition: C4Value.h:116
void Copy()
Definition: StdBuf.h:467

References AtClient, AtClientName, C4Config::AtUserDataPath(), C4Id2Def(), C4MaxTitle, C4P_Number_None, C4PT_Script, C4Game::C4S, C4PropList::Call(), ClearControl(), ColorDw, Config, Control, StdStrBuf::Copy(), CreateGraphs(), Filename, Game, GameJoinTime, C4PlayerInfo::GetColor(), C4TeamList::GetGenerateTeamByID(), C4Landscape::GetHeight(), C4PlayerInfo::GetID(), C4PlayerInfo::GetInGameNumber(), C4PlayerInfo::GetName(), C4Value::getPropList(), C4PlayerInfo::GetScriptPlayerExtraID(), C4PlayerInfo::GetTeam(), C4TeamList::GetTeamByID(), C4PlayerInfo::GetType(), C4Landscape::GetWidth(), C4Game::GRBroadcast(), C4Scenario::Head, ID, C4PlayerControl::Init(), InitControl(), C4TeamList::IsAutoGenerateTeams(), C4PlayerInfo::IsJoined(), C4PlayerInfo::IsNoEliminationCheck(), C4TeamList::IsRuntimeJoinTeamChoice(), C4PlayerInfo::IsScenarioInitDesired(), Landscape, Load(), LoadRuntimeData(), LogF(), Name, NO_OWNER, NoEliminationCheck, Number, Objects, Players, C4Game::pNetworkStatistics, PS_Normal, PS_TeamSelection, PSF_InitializeScriptPlayer, PSF_PreInitializePlayer, C4PlayerList::RecheckPlayerSort(), C4SHead::SaveGame, C4Game::ScenarioFile, ScenarioInit(), SCopy(), C4PlayerInfo::SetJoined(), SetSoundModifier(), SetTeamHostility(), SoundModifier, Status, Team, C4Game::Teams, C4Game::Time, ViewX, and ViewY.

Referenced by C4PlayerList::Join().

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

◆ InitControl()

void C4Player::InitControl ( )
protected

Definition at line 1393 of file C4Player.cpp.

1394 {
1395  // Check local control
1396  if (AtClient == ::Control.ClientID())
1397  if (!GetInfo() || GetInfo()->GetType() == C4PT_User)
1398  if (!::Control.isReplay())
1399  LocalControl=true;
1400  // needs to init control for local players only
1401  if (LocalControl)
1402  {
1403  // Preferred control
1406  // control set unassigned/not known? fallback to some default then (=first defined control set)
1408  // gamepad control safety (assuming the default control set is not using gamepad)
1410  {
1412  }
1413  // Choose next while control taken
1414  // TODO
1415  // init gamepad
1416  if (ControlSet && ControlSet->HasGamepad())
1417  {
1418  if (!FindGamepad())
1419  {
1420  LogF("No gamepad available for %s, please plug one in!", Name.getData());
1421  ::Game.Pause();
1422  }
1423  }
1424  // Mouse
1425  if (ControlSet && ControlSet->HasMouse() && PrefMouse)
1426  if (!::Players.MouseControlTaken())
1427  MouseControl=true;
1428  // Some controls such as gamepad control need special synced GUI elements
1429  // Do a script callback for selected control
1431  }
1432  // clear old control method and register new
1434 }
bool GamepadEnabled
Definition: C4Config.h:61
C4ConfigGeneral General
Definition: C4Config.h:255
static C4ControlPlayerAction * InitPlayerControl(const C4Player *source, const C4PlayerControlAssignmentSet *ctrl_set=nullptr)
Definition: C4Control.cpp:613
C4PlayerControlAssignmentSets PlayerControlUserAssignmentSets
Definition: C4Game.h:93
C4PlayerControlAssignmentSet * GetDefaultSet()
C4PlayerControlAssignmentSet * GetSetByName(const char *szName)
void RegisterKeyset(int32_t iPlr, C4PlayerControlAssignmentSet *pKeyset)
C4PlayerType GetType() const
Definition: C4Player.cpp:1727
bool MouseControlTaken() const

References AtClient, C4PT_User, CDT_Queue, CID_PlrAction, Config, Control, ControlSet, ControlSetName, Game, C4ConfigGeneral::GamepadEnabled, C4Config::General, StdStrBuf::getData(), C4PlayerControlAssignmentSets::GetDefaultSet(), GetInfo(), C4PlayerControlAssignmentSets::GetSetByName(), GetType(), C4PlayerControlAssignmentSet::HasGamepad(), C4PlayerControlAssignmentSet::HasMouse(), C4ControlPlayerAction::InitPlayerControl(), LocalControl, LogF(), MouseControl, C4PlayerList::MouseControlTaken(), Name, Number, C4Game::Pause(), C4Game::PlayerControlUserAssignmentSets, Players, C4PlayerInfoCore::PrefControl, C4PlayerInfoCore::PrefMouse, and C4PlayerControl::RegisterKeyset().

Referenced by Init().

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

◆ IsChosingTeam()

bool C4Player::IsChosingTeam ( ) const
inline

Definition at line 202 of file C4Player.h.

References PS_TeamSelection, PS_TeamSelectionPending, and Status.

◆ IsHostileTowards()

bool C4Player::IsHostileTowards ( const C4Player opponent) const

Definition at line 860 of file C4Player.cpp.

861 {
862  assert(plr);
863  if (!plr) return false;
864  return Hostility.find(plr) != Hostility.end();
865 }

References Hostility.

Referenced by C4PlayerList::Hostile(), and C4PlayerList::HostilityDeclared().

Here is the caller graph for this function:

◆ IsInvisible()

bool C4Player::IsInvisible ( ) const

Definition at line 1734 of file C4Player.cpp.

1735 {
1736  // invisible by info
1738  if (pInfo) return pInfo->IsInvisible(); else { assert(false); return false; }
1739 }
bool IsInvisible() const
Definition: C4PlayerInfo.h:175

References Game, C4PlayerInfoList::GetPlayerInfoByID(), ID, C4PlayerInfo::IsInvisible(), and C4Game::PlayerInfos.

Referenced by C4MainMenu::DoRefillInternal().

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

◆ IsViewLocked()

bool C4Player::IsViewLocked ( ) const
inline

Definition at line 204 of file C4Player.h.

204 { return ViewLock; } // return if view is fixed to cursor, so scrolling is not allowed

References ViewLock.

Referenced by C4MouseControl::UpdateScrolling().

Here is the caller graph for this function:

◆ Load() [1/2]

bool C4PlayerInfoCore::Load ( C4Group hGroup)
inherited

Definition at line 88 of file C4InfoCore.cpp.

89 {
90  // New version
91  StdStrBuf Source;
92  if (hGroup.LoadEntryString(C4CFN_PlayerInfoCore, &Source))
93  {
94  // Compile
95  StdStrBuf GrpName = hGroup.GetFullName();
97  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, Source, GrpName.getData()))
98  {
99  return false;
100  }
101  // Pref for AutoContextMenus is still undecided: default by player's control style
102  if (OldPrefAutoContextMenu == -1)
103  {
105  }
106  // Determine true color from indexed pref color
107  if (!PrefColorDw)
108  {
110  }
111  // Validate colors
112  PrefColorDw &= 0xffffff;
113  PrefColor2Dw &= 0xffffff;
114  // Validate name
116  // Success
117  return true;
118  }
119 
120  // Old version no longer supported - sorry
121  return false;
122 }
#define C4CFN_PlayerInfoCore
Definition: C4Components.h:45
#define DirSep
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2638
bool LoadEntryString(const char *entry_name, StdStrBuf *buffer)
Definition: C4Group.cpp:2430
static bool StripMarkup(char *szText)
Definition: C4Markup.cpp:148
static DWORD GetPrefColorValue(int32_t iPrefColor)
Definition: C4InfoCore.cpp:75
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519

References StdStrBuf::Append(), C4CFN_PlayerInfoCore, DirSep, StdStrBuf::getData(), C4Group::GetFullName(), C4PlayerInfoCore::GetPrefColorValue(), C4Group::LoadEntryString(), C4PlayerInfoCore::OldPrefAutoContextMenu, C4PlayerInfoCore::OldPrefControlStyle, C4PlayerInfoCore::PrefColor, C4PlayerInfoCore::PrefColor2Dw, C4PlayerInfoCore::PrefColorDw, C4PlayerInfoCore::PrefName, and C4Markup::StripMarkup().

Referenced by C4MainMenu::ActivateNewPlayer(), Load(), C4PlayerInfo::LoadFromLocalFile(), and Strip().

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

◆ Load() [2/2]

bool C4Player::Load ( const char *  szFilename,
bool  fSavegame 
)

Definition at line 937 of file C4Player.cpp.

938 {
939  C4Group hGroup;
940  // Open group
941  if (!Reloc.Open(hGroup, szFilename)) return false;
942  // Remember filename
944  // Load core
945  if (!C4PlayerInfoCore::Load(hGroup))
946  { hGroup.Close(); return false; }
947  // Load BigIcon
948  if (hGroup.FindEntry(C4CFN_BigIcon)) BigIcon.Load(hGroup, C4CFN_BigIcon, C4FCT_Full, C4FCT_Full, false, 0);
949  // Load crew info list
950  CrewInfoList.Load(hGroup);
951  // Close group
952  hGroup.Close();
953  // Success
954  return true;
955 }
#define C4CFN_BigIcon
Definition: C4Components.h:111
const int C4FCT_Full
Definition: C4FacetEx.h:26
C4Reloc Reloc
Definition: C4Reloc.cpp:21
#define _MAX_PATH
bool Load(C4Group &hGroup, const char *szName, int iWdt, int iHgt, bool fNoErrIfNotFound, int iFlags)
Definition: C4FacetEx.cpp:84
bool Close()
Definition: C4Group.cpp:971
bool FindEntry(const char *wildcard, StdStrBuf *filename=nullptr, size_t *size=nullptr)
Definition: C4Group.cpp:2211
int32_t Load(C4Group &hGroup)
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:88
bool Open(C4Group &group, const char *filename) const
Definition: C4Reloc.cpp:156

References _MAX_PATH, BigIcon, C4CFN_BigIcon, C4FCT_Full, C4Group::Close(), CrewInfoList, Filename, C4Group::FindEntry(), StdStrBuf::getData(), C4Group::GetFullName(), C4PlayerInfoCore::Load(), C4ObjectInfoList::Load(), C4FacetSurface::Load(), C4Reloc::Open(), Reloc, and SCopy().

Referenced by Init().

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

◆ LoadRuntimeData()

bool C4Player::LoadRuntimeData ( C4Group hGroup,
C4ValueNumbers numbers 
)

Definition at line 1132 of file C4Player.cpp.

1133 {
1134  const char *pSource;
1135  // Use loaded game text component
1136  if (!(pSource = Game.GameText.GetData())) return false;
1137  // safety: Do nothing if player section is not even present (could kill initialized values)
1138  if (!SSearch(pSource, FormatString("[Player%i]", ID).getData())) return false;
1139  // Compile (Search player section - runtime data is stored by unique player ID)
1140  // Always compile exact. Exact data will not be present for savegame load, so it does not matter
1141  assert(ID);
1142  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(
1143  mkNamingAdapt(mkParAdapt(*this, numbers), FormatString("Player%i", ID).getData()),
1144  StdStrBuf(pSource),
1146  return false;
1147  // Denumerate pointers
1149  // Success
1150  return true;
1151 }
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:369
const char * GetData() const
const char * GetFilePath() const
C4ComponentHost GameText
Definition: C4Game.h:79
void DenumeratePointers()
Definition: C4Player.cpp:1258

References DenumeratePointers(), FormatString(), Game, C4Game::GameText, C4ComponentHost::GetData(), C4ComponentHost::GetFilePath(), ID, mkNamingAdapt(), mkParAdapt(), and SSearch().

Referenced by Init().

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

◆ LocalSync()

bool C4Player::LocalSync ( )

Definition at line 1531 of file C4Player.cpp.

1532 {
1533  // local sync not necessary for script players
1534  if (GetType() == C4PT_Script) return true;
1535  // evaluate total playing time
1538  // evaluate total playing time of all the crew
1539  for (C4ObjectInfo *pInf = CrewInfoList.GetFirst(); pInf; pInf=pInf->Next)
1540  if (pInf->InAction)
1541  {
1542  pInf->TotalPlayingTime+=(Game.Time-pInf->InActionTime);
1543  pInf->InActionTime = Game.Time;
1544  }
1545  // save player
1546  if (!Save())
1547  return false;
1548  // done, success
1549  return true;
1550 }
C4ObjectInfo * Next
Definition: C4ObjectInfo.h:41
C4ObjectInfo * GetFirst()
bool Save()
Definition: C4Player.cpp:415

References C4PT_Script, CrewInfoList, Game, GameJoinTime, C4ObjectInfoList::GetFirst(), GetType(), C4ObjectInfo::Next, Save(), C4Game::Time, and C4PlayerInfoCore::TotalPlayingTime.

Here is the call graph for this function:

◆ MakeCrewMember()

bool C4Player::MakeCrewMember ( C4Object pObj,
bool  fForceInfo = true,
bool  fDoCalls = true 
)

Definition at line 1008 of file C4Player.cpp.

1009 {
1010  C4ObjectInfo *cInf = nullptr;
1011  if (!pObj || !pObj->Def->CrewMember || !pObj->Status) return false;
1012 
1013  // only if info is not yet assigned
1014  if (!pObj->Info && fForceInfo)
1015  {
1016  // Find crew info by name
1017  if (pObj->nInfo)
1018  cInf = CrewInfoList.GetIdle(pObj->nInfo.getData());
1019 
1020  // Find crew info by id
1021  if (!cInf)
1022  while (!( cInf = CrewInfoList.GetIdle(pObj->id,::Definitions) ))
1023  if (!CrewInfoList.New(pObj->id,&::Definitions))
1024  return false;
1025 
1026  // Set object info
1027  pObj->Info = cInf;
1028  pObj->SetName(cInf->Name);
1029  }
1030 
1031  // Add to crew
1032  if (!Crew.GetLink(pObj))
1033  Crew.Add(pObj, C4ObjectList::stNone);
1034 
1035  // add light
1036  if (!pObj->lightRange)
1037  pObj->SetLightRange(C4FOW_DefLightRangeX, C4FOW_DefLightFadeoutRangeX);
1038  else
1039  pObj->UpdateLight();
1040 
1041  // controlled by the player
1042  pObj->Controller = Number;
1043 
1044  // OnJoinCrew callback
1045  if (fDoCalls)
1046  {
1047  C4AulParSet parset(Number);
1048  pObj->Call(PSF_OnJoinCrew, &parset);
1049  }
1050 
1051  return true;
1052 }
#define PSF_OnJoinCrew
Definition: C4GameScript.h:93
C4DefList Definitions
Definition: C4Globals.cpp:49
int32_t CrewMember
Definition: C4Def.h:112
int32_t lightRange
Definition: C4Object.h:120
void SetName(const char *NewName=nullptr) override
Definition: C4Object.cpp:783
int32_t Controller
Definition: C4Object.h:109
bool SetLightRange(int32_t iToRange, int32_t iToFadeoutRange)
C4ID id
Definition: C4Object.h:106
StdCopyStrBuf nInfo
Definition: C4Object.h:167
C4Def * Def
Definition: C4Object.h:141
char Name[C4MaxName+1]
Definition: C4InfoCore.h:37
C4ObjectInfo * New(C4ID n_id, C4DefList *pDefs)
C4ObjectInfo * GetIdle(C4ID c_id, C4DefList &rDefs)
const C4ObjectLink * GetLink(const C4Object *obj) const
virtual bool Add(C4Object *new_obj, SortType sort_type, C4ObjectList *sorted_list=nullptr)
int32_t Status
Definition: C4PropList.h:173

References C4ObjectList::Add(), Crew, CrewInfoList, C4Def::CrewMember, C4Object::Def, Definitions, StdStrBuf::getData(), C4ObjectInfoList::GetIdle(), C4ObjectList::GetLink(), C4Object::id, C4Object::Info, C4Object::lightRange, C4ObjectInfoCore::Name, C4ObjectInfoList::New(), C4Object::nInfo, C4Object::SetLightRange(), C4Object::SetName(), C4PropList::Status, and C4ObjectList::stNone.

Referenced by C4Object::AssignInfo(), C4Object::GrabInfo(), and SetObjectCrewStatus().

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

◆ MarkMessageBoardQueryAnswered()

bool C4Player::MarkMessageBoardQueryAnswered ( C4Object pForObj)

Definition at line 1687 of file C4Player.cpp.

1688 {
1689  // get matching query
1691  while (pCheck) if (pCheck->CallbackObj == pForObj && !pCheck->fAnswered) break; else pCheck = pCheck->pNext;
1692  if (!pCheck) return false;
1693  // mark it
1694  pCheck->fAnswered = true;
1695  return true;
1696 }
C4ObjectPtr CallbackObj

References C4MessageBoardQuery::CallbackObj, C4MessageBoardQuery::fAnswered, pMsgBoardQuery, and C4MessageBoardQuery::pNext.

Referenced by C4ChatInputDialog::OnChatCancel(), and C4ChatInputDialog::OnChatInput().

Here is the caller graph for this function:

◆ Message()

bool C4Player::Message ( const char *  szMsg)

Definition at line 929 of file C4Player.cpp.

930 {
931  if (!szMsg) return false;
932  SCopy(szMsg,MessageBuf,256);
933  MessageStatus=SLen(szMsg)*2;
934  return true;
935 }
size_t SLen(const char *sptr)
Definition: Standard.h:74

References MessageBuf, MessageStatus, SCopy(), and SLen().

Here is the call graph for this function:

◆ NotifyOwnedObjects()

void C4Player::NotifyOwnedObjects ( )

Definition at line 1311 of file C4Player.cpp.

1312 {
1313  int32_t iNewOwner = FindNewOwner();
1314  // notify objects in all object lists
1315  for (C4ObjectList *pList = &::Objects; pList; pList = ((pList == &::Objects) ? &::Objects.InactiveObjects : nullptr))
1316  {
1317  for (C4Object *cobj : *pList)
1318  {
1319  if (cobj->Status && cobj->Owner == Number)
1320  {
1321  C4AulFunc *pFn = cobj->GetFunc(PSF_OnOwnerRemoved);
1322  if (pFn)
1323  {
1324  C4AulParSet pars(iNewOwner);
1325  pFn->Exec(cobj, &pars);
1326  }
1327  else
1328  {
1329  // crew members: Those are removed later (AFTER the player has been removed, for backwards compatiblity with relaunch scripting)
1330  if (Crew.IsContained(cobj))
1331  continue;
1332  // Regular objects: Try to find a new, suitable owner from the same team
1333  // Ignore StaticBack, because this would not be compatible with many internal objects such as team account
1334  if ((cobj->Category & C4D_StaticBack) == 0)
1335  cobj->SetOwner(iNewOwner);
1336  }
1337  }
1338  }
1339  }
1340 }
const int32_t C4D_StaticBack
Definition: C4Def.h:40
#define PSF_OnOwnerRemoved
Definition: C4GameScript.h:146
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
C4ObjectList InactiveObjects
Definition: C4GameObjects.h:43
bool IsContained(const C4Object *obj) const
int32_t FindNewOwner() const
Definition: C4Player.cpp:1279

References C4D_StaticBack, Crew, C4AulFunc::Exec(), FindNewOwner(), C4GameObjects::InactiveObjects, C4ObjectList::IsContained(), Number, Objects, and PSF_OnOwnerRemoved.

Referenced by C4PlayerList::Remove().

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

◆ ObjectInCrew()

bool C4Player::ObjectInCrew ( C4Object tobj)

Definition at line 90 of file C4Player.cpp.

91 {
92  if (!tobj) return false;
93  for (C4Object *cobj : Crew)
94  if (cobj==tobj) return true;
95  return false;
96 }

References Crew.

Referenced by C4MouseControl::UpdateSingleSelection().

Here is the caller graph for this function:

◆ OnTeamSelectionFailed()

void C4Player::OnTeamSelectionFailed ( )

Definition at line 1704 of file C4Player.cpp.

1705 {
1706  // looks like a selected team was not available: Go back to team selection if this is not a mislead call
1709 }

References PS_TeamSelection, PS_TeamSelectionPending, and Status.

Referenced by ScenarioAndTeamInit().

Here is the caller graph for this function:

◆ PlaceReadyBase()

void C4Player::PlaceReadyBase ( int32_t &  tx,
int32_t &  ty,
C4Object **  pFirstBase 
)
protected

Definition at line 527 of file C4Player.cpp.

528 {
529  int32_t cnt,cnt2,ctx,cty;
530  C4Def *def;
531  C4ID cid;
532  C4Object *cbase;
533  // Create ready base structures
534  for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyBase.GetID(cnt)); cnt++)
535  {
536  if ((def=C4Id2Def(cid)))
537  for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyBase.GetCount(cnt); cnt2++)
538  {
539  ctx=tx; cty=ty;
541  || FindConSiteSpot(ctx,cty,def->Shape.Wdt,def->Shape.Hgt,20))
542  if ((cbase=Game.CreateObjectConstruction(C4Id2Def(cid),nullptr,Number,ctx,cty,FullCon,true)))
543  {
544  // FirstBase
545  if (!(*pFirstBase)) if ((cbase->Def->Entrance.Wdt>0) && (cbase->Def->Entrance.Hgt>0))
546  { *pFirstBase=cbase; tx=(*pFirstBase)->GetX(); ty=(*pFirstBase)->GetY(); }
547  }
548  }
549  }
550 }
const int32_t FullCon
Definition: C4Constants.h:181
bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt, int32_t hrange)
C4Shape Shape
Definition: C4Def.h:104
C4Rect Entrance
Definition: C4Def.h:105
C4Object * CreateObjectConstruction(C4PropList *type, C4Object *creator, int32_t owner, int32_t center_x=0, int32_t bottom_y=0, int32_t con=1, bool adjust_terrain=false)
Definition: C4Game.cpp:1373
int32_t GetX() const
Definition: C4Object.h:285
int32_t Hgt
Definition: C4Rect.h:30
int32_t Wdt
Definition: C4Rect.h:30
C4IDList ReadyBase
Definition: C4Scenario.h:148
int32_t EnforcePosition
Definition: C4Scenario.h:146

References C4Id2Def(), C4Game::C4S, C4Game::CreateObjectConstruction(), C4Object::Def, C4SPlrStart::EnforcePosition, C4Def::Entrance, FindConSiteSpot(), FullCon, Game, C4IDList::GetCount(), C4IDList::GetID(), C4Object::GetX(), C4Rect::Hgt, Number, C4Scenario::PlrStart, PlrStartIndex, C4SPlrStart::ReadyBase, C4Def::Shape, and C4Rect::Wdt.

Referenced by ScenarioInit().

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

◆ PlaceReadyCrew()

void C4Player::PlaceReadyCrew ( int32_t  tx1,
int32_t  tx2,
int32_t  ty,
C4Object FirstBase 
)
protected

Definition at line 479 of file C4Player.cpp.

480 {
481  int32_t cnt,ctx,cty;
482  C4Object *nobj;
483  C4ObjectInfo *pInfo;
484  C4Def *pDef;
485 
486  // Place crew
487  int32_t iCount;
488  C4ID id;
489  for (cnt=0; (id=Game.C4S.PlrStart[PlrStartIndex].ReadyCrew.GetID(cnt,&iCount)); cnt++)
490  {
491  // Minimum one clonk if empty id
492  iCount = std::max<int32_t>(iCount,1);
493 
494  for (int32_t cnt2=0; cnt2<iCount; cnt2++)
495  {
496  // Select member from home crew, add new if necessary
497  while (!(pInfo=CrewInfoList.GetIdle(id,::Definitions)))
498  if (!CrewInfoList.New(id,&::Definitions))
499  break;
500  // Safety
501  if (!pInfo || !(pDef=C4Id2Def(pInfo->id))) continue;
502  // Crew placement location
503  ctx=tx1+Random(tx2-tx1); cty=ty;
505  FindSolidGround(ctx,cty,pDef->Shape.Wdt*3);
506  // Create object
507  if ((nobj=Game.CreateInfoObject(pInfo,Number,ctx,cty)))
508  {
509  // Add object to crew
511  // add visibility range
512  nobj->SetLightRange(C4FOW_DefLightRangeX, C4FOW_DefLightFadeoutRangeX);
513  // If base is present, enter base
514  if (FirstBase) { nobj->Enter(FirstBase); nobj->SetCommand(C4CMD_Exit); }
515  // OnJoinCrew callback
516  {
517  C4DebugRecOff DbgRecOff{ !DEBUGREC_RECRUITMENT };
518  C4AulParSet parset(Number);
519  nobj->Call(PSF_OnJoinCrew, &parset);
520  }
521  }
522  }
523  }
524 
525 }
@ C4CMD_Exit
Definition: C4Command.h:32
constexpr bool DEBUGREC_RECRUITMENT
Definition: C4Include.h:36
bool FindSolidGround(int32_t &rx, int32_t &ry, int32_t width)
uint32_t Random()
Definition: C4Random.cpp:43
C4Object * CreateInfoObject(C4ObjectInfo *info, int32_t owner, int32_t x=50, int32_t y=50)
Definition: C4Game.cpp:1351
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
void SetCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, C4Object *pTarget2=nullptr, bool fControl=false, C4Value iData=C4VNull, int32_t iRetries=0, C4String *szText=nullptr)
C4IDList ReadyCrew
Definition: C4Scenario.h:147

References C4ObjectList::Add(), C4Id2Def(), C4Game::C4S, C4Game::CreateInfoObject(), Crew, CrewInfoList, Definitions, C4SPlrStart::EnforcePosition, FindSolidGround(), Game, C4IDList::GetID(), C4ObjectInfoList::GetIdle(), C4ObjectInfoCore::id, C4ObjectInfoList::New(), Number, C4Scenario::PlrStart, PlrStartIndex, Random(), C4SPlrStart::ReadyCrew, C4Object::SetLightRange(), C4Def::Shape, C4ObjectList::stNone, and C4Rect::Wdt.

Referenced by ScenarioInit().

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

◆ PlaceReadyMaterial()

void C4Player::PlaceReadyMaterial ( int32_t  tx1,
int32_t  tx2,
int32_t  ty,
C4Object FirstBase 
)
protected

Definition at line 573 of file C4Player.cpp.

574 {
575  int32_t cnt,cnt2,ctx,cty;
576  C4Def *def; C4ID cid;
577 
578  // In base
579  if (FirstBase)
580  {
582  }
583 
584  // Outside
585  else
586  {
587  for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyMaterial.GetID(cnt)); cnt++)
588  {
589  if ((def=C4Id2Def(cid)))
590  for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyMaterial.GetCount(cnt); cnt2++)
591  {
592  ctx=tx1+Random(tx2-tx1); cty=ty;
594  FindSolidGround(ctx,cty,def->Shape.Wdt);
595  Game.CreateObject(cid,nullptr,Number,ctx,cty);
596  }
597  }
598  }
599 }
C4Object * CreateObject(C4PropList *type, C4Object *creator, 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 controller=NO_OWNER)
Definition: C4Game.cpp:1334
bool CreateContentsByList(C4IDList &idlist)
C4IDList ReadyMaterial
Definition: C4Scenario.h:150

References C4Id2Def(), C4Game::C4S, C4Object::CreateContentsByList(), C4Game::CreateObject(), C4SPlrStart::EnforcePosition, FindSolidGround(), Game, C4IDList::GetCount(), C4IDList::GetID(), Number, C4Scenario::PlrStart, PlrStartIndex, Random(), C4SPlrStart::ReadyMaterial, C4Def::Shape, and C4Rect::Wdt.

Referenced by ScenarioInit().

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

◆ PlaceReadyVehic()

void C4Player::PlaceReadyVehic ( int32_t  tx1,
int32_t  tx2,
int32_t  ty,
C4Object FirstBase 
)
protected

Definition at line 552 of file C4Player.cpp.

553 {
554  int32_t cnt,cnt2,ctx,cty;
555  C4Def *def; C4ID cid; C4Object *cobj;
556  for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyVehic.GetID(cnt)); cnt++)
557  {
558  if ((def=C4Id2Def(cid)))
559  for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyVehic.GetCount(cnt); cnt2++)
560  {
561  ctx=tx1+Random(tx2-tx1); cty=ty;
563  FindLevelGround(ctx,cty,def->Shape.Wdt,6);
564  if ((cobj=Game.CreateObject(cid,nullptr,Number,ctx,cty)))
565  {
566  if (FirstBase) // First base overrides target location
567  { cobj->Enter(FirstBase); cobj->SetCommand(C4CMD_Exit); }
568  }
569  }
570  }
571 }
bool FindLevelGround(int32_t &rx, int32_t &ry, int32_t width, int32_t hrange)
C4IDList ReadyVehic
Definition: C4Scenario.h:149

References C4CMD_Exit, C4Id2Def(), C4Game::C4S, C4Game::CreateObject(), C4SPlrStart::EnforcePosition, C4Object::Enter(), FindLevelGround(), Game, C4IDList::GetCount(), C4IDList::GetID(), Number, C4Scenario::PlrStart, PlrStartIndex, Random(), C4SPlrStart::ReadyVehic, C4Object::SetCommand(), C4Def::Shape, and C4Rect::Wdt.

Referenced by ScenarioInit().

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

◆ Promote()

void C4PlayerInfoCore::Promote ( int32_t  iRank,
C4RankSystem rRanks 
)
inherited

Definition at line 139 of file C4InfoCore.cpp.

140 {
141  Rank = iRank;
142  SCopy(rRanks.GetRankName(Rank, true).getData(), RankName, C4MaxName);
143 }
const unsigned int C4MaxName

References C4MaxName, StdStrBuf::getData(), C4RankSystem::GetRankName(), C4PlayerInfoCore::Rank, C4PlayerInfoCore::RankName, and SCopy().

Referenced by C4PlayerInfoCore::CheckPromotion().

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

◆ RemoveCrewObjects()

void C4Player::RemoveCrewObjects ( )

Definition at line 1271 of file C4Player.cpp.

1272 {
1273  C4Object *pCrew;
1274 
1275  // Remove all crew objects
1276  while ((pCrew = Crew.GetObject())) pCrew->AssignRemoval(true);
1277 }
void AssignRemoval(bool exit_contents=false)
Definition: C4Object.cpp:215
C4Object * GetObject(int index=0) const

References C4Object::AssignRemoval(), Crew, and C4ObjectList::GetObject().

Referenced by C4PlayerList::Remove().

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

◆ RemoveMessageBoardQuery()

bool C4Player::RemoveMessageBoardQuery ( C4Object pForObj)

Definition at line 1674 of file C4Player.cpp.

1675 {
1676  // get matching query
1677  C4MessageBoardQuery **ppCheck = &pMsgBoardQuery, *pFound;
1678  while (*ppCheck) if ((*ppCheck)->CallbackObj == pForObj) break; else ppCheck = &((*ppCheck)->pNext);
1679  pFound = *ppCheck;
1680  if (!pFound) return false;
1681  // remove it
1682  *ppCheck = (*ppCheck)->pNext;
1683  delete pFound;
1684  return true;
1685 }

References pMsgBoardQuery, and C4MessageBoardQuery::pNext.

Referenced by CallMessageBoard(), and ClearPointers().

Here is the caller graph for this function:

◆ ResetCursorView()

void C4Player::ResetCursorView ( bool  immediate_position = false)

Definition at line 780 of file C4Player.cpp.

781 {
782  // reset view to cursor if any cursor exists
783  if (!ViewCursor && !Cursor) return;
784  SetViewMode(C4PVM_Cursor, nullptr, immediate_position);
785 }
void SetViewMode(int32_t iMode, C4Object *pTarget=nullptr, bool immediate_position=false)
Definition: C4Player.cpp:767

References C4PVM_Cursor, Cursor, SetViewMode(), and ViewCursor.

Referenced by AdjustCursorCommand().

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

◆ Save() [1/3]

bool C4Player::Save ( )

Definition at line 415 of file C4Player.cpp.

416 {
417  C4Group hGroup;
418  // Regular player saving need not be done for script players
419  if (GetType() == C4PT_Script) return false;
420  // Log
421  LogF(LoadResStr("IDS_PRC_SAVEPLR"), Config.AtRelativePath(Filename));
422  ::GraphicsSystem.MessageBoard->EnsureLastMessage();
423  // copy player to save somewhere else
424  char szPath[_MAX_PATH_LEN];
426  MakeTempFilename(szPath);
427  // For local players, we save over the old player file, as there might
428  // be all kinds of non-essential stuff in it. For non-local players, we
429  // just re-create it every time (it's temporary anyway).
430  if (LocalControl)
431  {
432  // But make sure to copy it first so full hard (flgr stupid) disks
433  // won't corrupt any player files...
434  C4Group_CopyItem(Filename, szPath);
435  }
436  else
437  {
438  // For non-local players, we can actually use the loaded definition
439  // list to strip out all non-existant definitions. This is only valid
440  // because we know the file to be temporary.
442  }
443  // Open group
444  if (!hGroup.Open(szPath,true))
445  return false;
446  // Save
447  if (!Save(hGroup, false, !LocalControl))
448  { hGroup.Close(); return false; }
449  // Close group
450  if (!hGroup.Close()) return false;
451  // resource
453  pDRes = nullptr;
454  bool fOfficial = pRes && ::Control.isCtrlHost();
455  if (pRes) pDRes = pRes->Derive();
456  // move back
458  if (!C4Group_MoveItem(szPath, Filename)) return false;
459  // finish update
460  if (pDRes && fOfficial) pDRes->FinishDerive();
461  // Success
462  return true;
463 }
#define C4CFN_TempPlayer
Definition: C4Components.h:162
C4Network2 Network
Definition: C4Globals.cpp:53
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
bool C4Group_CopyItem(const char *source, const char *target, bool no_sorting, bool reset_attributes)
Definition: C4Group.cpp:115
bool C4Group_MoveItem(const char *source, const char *target, bool no_sorting)
Definition: C4Group.cpp:182
#define _MAX_PATH_LEN
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:833
void MakeTempFilename(char *szFilename)
Definition: StdFile.cpp:320
bool ItemExists(const char *szItemName)
Definition: StdFile.h:75
const char * AtRelativePath(const char *filename)
Definition: C4Config.cpp:741
const char * AtTempPath(const char *filename)
Definition: C4Config.cpp:600
std::unique_ptr< C4MessageBoard > MessageBoard
bool Open(const char *group_name, bool do_create=false)
Definition: C4Group.cpp:660
C4Network2ResList ResList
Definition: C4Network2.h:113
C4Network2Res::Ref Derive()
C4Network2Res::Ref getRefRes(int32_t iResID)
void Strip(C4DefList &rDefs)

References _MAX_PATH, _MAX_PATH_LEN, C4Config::AtRelativePath(), C4Config::AtTempPath(), C4CFN_TempPlayer, C4Group_CopyItem(), C4Group_MoveItem(), C4PT_Script, C4Group::Close(), Config, Control, CrewInfoList, Definitions, C4Network2Res::Derive(), EraseItem(), Filename, C4Network2ResList::getRefRes(), GetType(), GraphicsSystem, ItemExists(), LoadResStr(), LocalControl, LogF(), MakeTempFilename(), C4GraphicsSystem::MessageBoard, Network, C4Group::Open(), C4Network2::ResList, SCopy(), and C4ObjectInfoList::Strip().

Referenced by LocalSync(), and C4PlayerList::Retire().

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

◆ Save() [2/3]

bool C4PlayerInfoCore::Save ( C4Group hGroup)
inherited

Definition at line 124 of file C4InfoCore.cpp.

125 {
126  StdStrBuf Source, Name = hGroup.GetFullName(); Name.Append(DirSep C4CFN_PlayerInfoCore);
127  if (!DecompileToBuf_Log<StdCompilerINIWrite>(*this, &Source, Name.getData()))
128  {
129  return false;
130  }
131  if (!hGroup.Add(C4CFN_PlayerInfoCore, Source, false, true))
132  {
133  return false;
134  }
135  hGroup.Delete("C4Player.ocb");
136  return true;
137 }
bool Add(const char *filename, const char *entry_name)
Definition: C4Group.cpp:1621
bool Delete(const char *files, bool recursive=false)
Definition: C4Group.cpp:1645

References C4Group::Add(), StdStrBuf::Append(), C4CFN_PlayerInfoCore, C4Group::Delete(), DirSep, StdStrBuf::getData(), and C4Group::GetFullName().

Referenced by C4StartupPlrPropertiesDlg::OnClosed(), Save(), Strip(), and C4StartupPlrSelDlg::PlayerListItem::UpdateCore().

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

◆ Save() [3/3]

bool C4Player::Save ( C4Group hGroup,
bool  fSavegame,
bool  fStoreTiny 
)

Definition at line 465 of file C4Player.cpp.

466 {
467  // Save core
468  if (!C4PlayerInfoCore::Save(hGroup))
469  return false;
470  // Save crew
471  C4DefList *pDefs = &::Definitions;
472  if (!CrewInfoList.Save(hGroup, fSavegame, fStoreTiny, pDefs))
473  { hGroup.Close(); return false; }
474  // Sort
475  hGroup.Sort(C4FLS_Player);
476  return true;
477 }
#define C4FLS_Player
Definition: C4Components.h:194
bool Sort(const char *list)
Definition: C4Group.cpp:2470
bool Save(C4Group &hGroup, bool fSavegame, bool fStoreTiny, C4DefList *pDefs)
bool Save(C4Group &hGroup)
Definition: C4InfoCore.cpp:124

References C4FLS_Player, C4Group::Close(), CrewInfoList, Definitions, C4PlayerInfoCore::Save(), C4ObjectInfoList::Save(), and C4Group::Sort().

Here is the call graph for this function:

◆ ScenarioAndTeamInit()

bool C4Player::ScenarioAndTeamInit ( int32_t  idTeam)

Definition at line 118 of file C4Player.cpp.

119 {
120  C4PlayerInfo *pInfo = GetInfo();
121  if (!pInfo) return false;
122  C4Team *pTeam;
123  if (idTeam == TEAMID_New)
124  {
125  // creation of a new team only if allowed by scenario
127  pTeam = nullptr;
128  else
129  {
130  if ((pTeam = Game.Teams.GetGenerateTeamByID(idTeam))) idTeam = pTeam->GetID();
131  }
132  }
133  else
134  {
135  // uage of an existing team
136  pTeam = Game.Teams.GetTeamByID(idTeam);
137  }
138  C4Team *pPrevTeam = Game.Teams.GetTeamByID(Team);
139  // check if join to team is possible; e.g. not too many players
140  if (pPrevTeam != pTeam && idTeam)
141  {
142  if (!Game.Teams.IsJoin2TeamAllowed(idTeam, pInfo->GetType()))
143  {
144  pTeam = nullptr;
145  }
146  }
147  if (!pTeam && idTeam)
148  {
150  return false;
151  }
152  // team selection OK; execute it!
153  if (pPrevTeam) pPrevTeam->RemovePlayerByID(pInfo->GetID());
154  if (pTeam) pTeam->AddPlayer(*pInfo, true);
155  if (!ScenarioInit()) return false;
156  if (!FinalInit(false)) return false;
157  // perform any pending InitializePlayers() callback
159  return true;
160 }
const int32_t TEAMID_New
Definition: C4Teams.h:27
void OnPlayerJoinFinished()
Definition: C4Game.cpp:3791
bool FinalInit(bool fInitialScore)
Definition: C4Player.cpp:699
void OnTeamSelectionFailed()
Definition: C4Player.cpp:1704
int32_t GetID() const
Definition: C4PlayerInfo.h:194
void AddPlayer(class C4PlayerInfo &rInfo, bool fAdjustPlayer)
Definition: C4Teams.cpp:52
int32_t GetID() const
Definition: C4Teams.h:66
void RemovePlayerByID(int32_t iID)
Definition: C4Teams.cpp:94
bool IsJoin2TeamAllowed(int32_t idTeam, C4PlayerType plrType)
Definition: C4Teams.cpp:534

References C4Team::AddPlayer(), FinalInit(), Game, C4TeamList::GetGenerateTeamByID(), C4PlayerInfo::GetID(), C4Team::GetID(), GetInfo(), C4TeamList::GetTeamByID(), C4PlayerInfo::GetType(), C4TeamList::IsAutoGenerateTeams(), C4TeamList::IsJoin2TeamAllowed(), C4Game::OnPlayerJoinFinished(), OnTeamSelectionFailed(), C4Team::RemovePlayerByID(), ScenarioInit(), Team, TEAMID_New, and C4Game::Teams.

Here is the call graph for this function:

◆ ScenarioInit()

bool C4Player::ScenarioInit ( )

Definition at line 601 of file C4Player.cpp.

602 {
603  int32_t ptx,pty;
604 
605  // player start index by team, if specified. Otherwise by player number
607  C4Team *pTeam; int32_t i;
608  if (Team && (pTeam = Game.Teams.GetTeamByID(Team))) if ((i=pTeam->GetPlrStartIndex())) PlrStartIndex=i-1;
609 
610  C4PlayerInfo *pInfo = GetInfo();
611  if (!pInfo) { assert(false); LogF("Internal error: ScenarioInit for ghost player %s!", GetName()); return false; }
612 
613  // set color by player info class
614  // re-setting, because runtime team choice may have altered color
615  ColorDw = pInfo->GetColor();
616 
617  // any team selection is over now
618  Status = PS_Normal;
619 
620  // Wealth, home base materials, abilities
628 
629  // Starting position
632 
633  // Zoomed position
634  if (ptx>-1) ptx = Clamp<int32_t>( ptx * Game.C4S.Landscape.MapZoom.Evaluate(), 0, ::Landscape.GetWidth()-1 );
635  if (pty>-1) pty = Clamp<int32_t>( pty * Game.C4S.Landscape.MapZoom.Evaluate(), 0, ::Landscape.GetHeight()-1 );
636 
637  // Standard position (PrefPosition)
638  if (ptx<0)
639  if (Game.StartupPlayerCount>=2)
640  {
641  int32_t iMaxPos=Game.StartupPlayerCount;
642  // Try to initialize PrefPosition using teams. This should put players of a team next to each other.
643  int PrefPosition = 0;
644  C4PlayerInfo *plr;
645  for (int i = 0; (plr = Game.PlayerInfos.GetPlayerInfoByIndex(i)) != nullptr; i++)
646  {
647  if (plr->GetTeam() < Team)
648  PrefPosition++;
649  }
650  // Map preferred position to available positions
651  int32_t iStartPos=Clamp(PrefPosition*iMaxPos/C4P_MaxPosition,0,iMaxPos-1);
652  int32_t iPosition=iStartPos;
653  // Distribute according to availability
654  while (::Players.PositionTaken(iPosition))
655  {
656  ++iPosition;
657  iPosition %= iMaxPos;
658  if (iPosition == iStartPos)
659  break;
660  }
661  Position=iPosition;
662  // Set x position
663  ptx=Clamp(16+Position*(::Landscape.GetWidth()-32)/(iMaxPos-1),0,::Landscape.GetWidth()-16);
664  }
665 
666  // All-random position
667  if (ptx<0) ptx=16+Random(::Landscape.GetWidth()-32);
668  if (pty<0) pty=16+Random(::Landscape.GetHeight()-32);
669 
670  // Place to solid ground
672  {
673  // Use nearest above-ground...
674  FindSolidGround(ptx,pty,30);
675  // Might have hit a small lake, or similar: Seach a real site spot from here
676  FindConSiteSpot(ptx, pty, 30, 50, 400);
677  }
678 
679  // Place Readies
680  C4Object *FirstBase = nullptr;
681  PlaceReadyBase(ptx,pty,&FirstBase);
682  PlaceReadyMaterial(ptx-10,ptx+10,pty,FirstBase);
683  PlaceReadyVehic(ptx-30,ptx+30,pty,FirstBase);
684  PlaceReadyCrew(ptx-30,ptx+30,pty,FirstBase);
685 
686  // set initial hostility by team info
687  if (Team) SetTeamHostility();
688 
689  // Scenario script initialization
691  ptx,
692  pty,
693  FirstBase,
694  Team,
695  C4Id2Def(GetInfo()->GetScriptPlayerExtraID())));
696  return true;
697 }
const int C4P_MaxPosition
Definition: C4Constants.h:63
#define PSF_InitializePlayer
Definition: C4GameScript.h:40
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
int32_t StartupPlayerCount
Definition: C4Game.h:109
bool ConsolidateValids(C4DefList &rDefs, int32_t dwCategory=0)
Definition: C4IDList.cpp:439
void PlaceReadyBase(int32_t &tx, int32_t &ty, C4Object **pFirstBase)
Definition: C4Player.cpp:527
void PlaceReadyMaterial(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
Definition: C4Player.cpp:573
void PlaceReadyCrew(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
Definition: C4Player.cpp:479
void PlaceReadyVehic(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
Definition: C4Player.cpp:552
int32_t GetTeam() const
Definition: C4PlayerInfo.h:195
C4PlayerInfo * GetPlayerInfoByIndex(int32_t index) const
bool PositionTaken(int iPosition) const
C4SVal MapZoom
Definition: C4Scenario.h:178
C4IDList BaseMaterial
Definition: C4Scenario.h:152
C4IDList BaseProduction
Definition: C4Scenario.h:153
C4SVal Wealth
Definition: C4Scenario.h:144
C4IDList BuildKnowledge
Definition: C4Scenario.h:151
int32_t Evaluate()
Definition: C4Scenario.cpp:50
C4SLandscape Landscape
Definition: C4Scenario.h:236

References C4SPlrStart::BaseMaterial, BaseMaterial, C4SPlrStart::BaseProduction, BaseProduction, C4SPlrStart::BuildKnowledge, C4Id2Def(), C4P_MaxPosition, C4Game::C4S, C4S_MaxPlayer, Clamp(), ColorDw, C4IDList::ConsolidateValids(), Definitions, C4SPlrStart::EnforcePosition, C4SVal::Evaluate(), FindConSiteSpot(), FindSolidGround(), Game, C4PlayerInfo::GetColor(), C4Landscape::GetHeight(), GetInfo(), GetName(), C4PlayerInfoList::GetPlayerInfoByIndex(), C4Team::GetPlrStartIndex(), C4PlayerInfo::GetTeam(), C4TeamList::GetTeamByID(), C4Landscape::GetWidth(), C4Game::GRBroadcast(), Knowledge, Landscape, C4Scenario::Landscape, LogF(), C4SLandscape::MapZoom, Number, PlaceReadyBase(), PlaceReadyCrew(), PlaceReadyMaterial(), PlaceReadyVehic(), C4Game::PlayerInfos, Players, C4Scenario::PlrStart, PlrStartIndex, C4SPlrStart::Position, Position, C4PlayerList::PositionTaken(), PS_Normal, PSF_InitializePlayer, Random(), SetTeamHostility(), C4Game::StartupPlayerCount, Status, Team, C4Game::Teams, C4SPlrStart::Wealth, and Wealth.

Referenced by Init(), and ScenarioAndTeamInit().

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

◆ ScrollView()

void C4Player::ScrollView ( float  iX,
float  iY,
float  ViewWdt,
float  ViewHgt 
)

Definition at line 1364 of file C4Player.cpp.

1365 {
1366  if (ViewLock) return;
1368  float ViewportScrollBorder = Application.isEditor ? 0 : C4ViewportScrollBorder;
1369  ViewX = Clamp<C4Real>( ViewX+ftofix(iX), ftofix(ViewWdt/2.0f-ViewportScrollBorder), ftofix(::Landscape.GetWidth()+ViewportScrollBorder-ViewWdt/2.0f) );
1370  ViewY = Clamp<C4Real>( ViewY+ftofix(iY), ftofix(ViewHgt/2.0f-ViewportScrollBorder), ftofix(::Landscape.GetHeight()+ViewportScrollBorder-ViewHgt/2.0f) );
1371 }
const int C4ViewportScrollBorder
Definition: C4Constants.h:65
const int32_t C4PVM_Scrolling
Definition: C4Player.h:33
C4Fixed ftofix(float x)
Definition: C4Real.h:258

References Application, C4PVM_Scrolling, C4ViewportScrollBorder, ftofix(), C4Landscape::GetHeight(), C4Landscape::GetWidth(), C4Application::isEditor, Landscape, SetViewMode(), ViewLock, ViewX, and ViewY.

Referenced by C4MouseControl::ScrollView().

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

◆ SetCursor()

void C4Player::SetCursor ( C4Object pObj,
bool  fSelectArrow 
)

Definition at line 1348 of file C4Player.cpp.

1349 {
1350  // check disabled
1351  if (pObj) if (pObj->CrewDisabled) return;
1352  bool fChanged = pObj != Cursor;
1353  C4Object *pPrev = Cursor;
1354  // Set cursor
1355  Cursor=pObj;
1356  // unselect previous
1357  if (pPrev && fChanged) pPrev->UnSelect();
1358  // Select object
1359  if (fChanged && Cursor) { Cursor->DoSelect(); }
1360  // View flash
1361  if (fSelectArrow) CursorFlash=30;
1362 }
bool DoSelect()
Definition: C4Object.cpp:1186
void UnSelect()
Definition: C4Object.cpp:1196

References C4Object::CrewDisabled, Cursor, CursorFlash, C4Object::DoSelect(), and C4Object::UnSelect().

Referenced by AdjustCursorCommand().

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

◆ SetFoW()

void C4Player::SetFoW ( bool  fEnable)

Definition at line 723 of file C4Player.cpp.

724 {
725  // set flag
726  fFogOfWar = fEnable;
727 }

References fFogOfWar.

◆ SetHostility()

bool C4Player::SetHostility ( int32_t  iOpponent,
int32_t  iHostility,
bool  fSilent = false 
)

Definition at line 838 of file C4Player.cpp.

839 {
840  assert(hostile == 0 || hostile == 1);
841  // Check opponent valid
842  C4Player *opponent = ::Players.Get(iOpponent);
843  if (!opponent || opponent == this)
844  return false;
845  // Set hostility
846  if (hostile)
847  Hostility.insert(opponent);
848  else
849  Hostility.erase(opponent);
850  // no announce in first frame, or if specified
851  if (!Game.FrameCounter || fSilent) return true;
852  // Announce
853  StartSoundEffect("UI::Trumpet");
854  Log(FormatString(LoadResStr(hostile ? "IDS_PLR_HOSTILITY" : "IDS_PLR_NOHOSTILITY"),
855  GetName(),opponent->GetName()).getData());
856  // Success
857  return true;
858 }
int32_t FrameCounter
Definition: C4Game.h:129
C4Player * Get(int iPlayer) const

References FormatString(), C4Game::FrameCounter, Game, C4PlayerList::Get(), StdStrBuf::getData(), GetName(), Hostility, LoadResStr(), Log(), Players, and StartSoundEffect().

Referenced by SetTeamHostility().

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

◆ SetKnowledge()

bool C4Player::SetKnowledge ( C4ID  id,
bool  fRemove 
)

Definition at line 752 of file C4Player.cpp.

753 {
754  if (fRemove)
755  {
756  long iIndex = Knowledge.GetIndex(id);
757  if (iIndex<0) return false;
758  return Knowledge.DeleteItem(iIndex);
759  }
760  else
761  {
762  if (!C4Id2Def(id)) return false;
763  return Knowledge.SetIDCount(id, 1, true);
764  }
765 }
int32_t GetIndex(C4ID c_id) const
Definition: C4IDList.cpp:236
bool SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID=false)
Definition: stub-handle.cpp:68
bool DeleteItem(size_t iIndex)
Definition: C4IDList.cpp:498

References C4Id2Def(), C4IDList::DeleteItem(), C4IDList::GetIndex(), Knowledge, and C4IDList::SetIDCount().

Here is the call graph for this function:

◆ SetMaxZoom()

void C4Player::SetMaxZoom ( C4Real  zoom,
bool  no_increase,
bool  no_decrease 
)

Definition at line 1830 of file C4Player.cpp.

1831 {
1832  AdjustZoomParameter(&ZoomLimitMaxVal, zoom, no_increase, no_decrease);
1834 }
void ZoomLimitsToViewports()
Definition: C4Player.cpp:1852

References ZoomLimitMaxVal, and ZoomLimitsToViewports().

Here is the call graph for this function:

◆ SetMaxZoomByViewRange()

void C4Player::SetMaxZoomByViewRange ( int32_t  range_wdt,
int32_t  range_hgt,
bool  no_increase,
bool  no_decrease 
)

Definition at line 1811 of file C4Player.cpp.

1812 {
1813  AdjustZoomParameter(&ZoomLimitMaxWdt, range_wdt, no_increase, no_decrease);
1814  AdjustZoomParameter(&ZoomLimitMaxHgt, range_hgt, no_increase, no_decrease);
1816 }

References ZoomLimitMaxHgt, ZoomLimitMaxWdt, and ZoomLimitsToViewports().

Here is the call graph for this function:

◆ SetMinZoom()

void C4Player::SetMinZoom ( C4Real  zoom,
bool  no_increase,
bool  no_decrease 
)

Definition at line 1824 of file C4Player.cpp.

1825 {
1826  AdjustZoomParameter(&ZoomLimitMinVal, zoom, no_increase, no_decrease);
1828 }

References ZoomLimitMinVal, and ZoomLimitsToViewports().

Here is the call graph for this function:

◆ SetMinZoomByViewRange()

void C4Player::SetMinZoomByViewRange ( int32_t  range_wdt,
int32_t  range_hgt,
bool  no_increase,
bool  no_decrease 
)

Definition at line 1804 of file C4Player.cpp.

1805 {
1806  AdjustZoomParameter(&ZoomLimitMinWdt, range_wdt, no_increase, no_decrease);
1807  AdjustZoomParameter(&ZoomLimitMinHgt, range_hgt, no_increase, no_decrease);
1809 }

References ZoomLimitMinHgt, ZoomLimitMinWdt, and ZoomLimitsToViewports().

Here is the call graph for this function:

◆ SetObjectCrewStatus()

bool C4Player::SetObjectCrewStatus ( C4Object pCrew,
bool  fNewStatus 
)

Definition at line 1557 of file C4Player.cpp.

1558 {
1559  // either add...
1560  if (fNewStatus)
1561  {
1562  // is in crew already?
1563  if (Crew.IsContained(pCrew)) return true;
1564  return MakeCrewMember(pCrew, false);
1565  }
1566  else
1567  {
1568  // already outside?
1569  if (!Crew.IsContained(pCrew)) return true;
1570  // ...or remove
1571  Crew.Remove(pCrew);
1572  C4AulParSet parset(Number);
1573  pCrew->Call(PSF_OnRemoveCrew, &parset);
1574  // remove info, if assigned to this player
1575  // theoretically, info objects could remain when the player is deleted
1576  // but then they would be reassigned to the player crew when loaded in a savegame
1577  // by the crew-assignment code kept for backwards compatibility with pre-4.95.2-savegames
1578  if (pCrew->Info && CrewInfoList.IsElement(pCrew->Info))
1579  {
1580  pCrew->Info->Retire();
1581  pCrew->Info = nullptr;
1582  }
1583  }
1584  // done, success
1585  return true;
1586 }
#define PSF_OnRemoveCrew
Definition: C4GameScript.h:94
bool IsElement(C4ObjectInfo *pInfo)
bool MakeCrewMember(C4Object *pObj, bool fForceInfo=true, bool fDoCalls=true)
Definition: C4Player.cpp:1008

References C4PropList::Call(), Crew, CrewInfoList, C4Object::Info, C4ObjectList::IsContained(), C4ObjectInfoList::IsElement(), MakeCrewMember(), Number, PSF_OnRemoveCrew, C4ObjectList::Remove(), and C4ObjectInfo::Retire().

Here is the call graph for this function:

◆ SetPlayerColor()

void C4Player::SetPlayerColor ( uint32_t  dwNewClr)

Definition at line 1711 of file C4Player.cpp.

1712 {
1713  // no change?
1714  if (dwNewClr == ColorDw) return;
1715  // reflect change in all active, player-owned objects
1716  // this can never catch everything (thinking of overlays, etc.); scenarios that allow team changes should take care of the rest
1717  uint32_t dwOldClr = ColorDw;
1718  ColorDw = dwNewClr;
1719  for (C4Object *pObj : Objects)
1720  if (pObj && pObj->Status && pObj->Owner == Number)
1721  {
1722  if ((pObj->Color & 0xffffff) == (dwOldClr & 0xffffff))
1723  pObj->Color = (pObj->Color & 0xff000000u) | (dwNewClr & 0xffffff);
1724  }
1725 }

References ColorDw, Number, and Objects.

Referenced by C4Team::AddPlayer().

Here is the caller graph for this function:

◆ SetSoundModifier()

void C4Player::SetSoundModifier ( C4PropList new_modifier)

Definition at line 1923 of file C4Player.cpp.

1924 {
1925  // set modifier to be applied to all new sounds being played in a player's viewport
1926  // update prop list parameter
1927  C4SoundModifier *mod;
1928  if (new_modifier)
1929  {
1930  SoundModifier.SetPropList(new_modifier);
1931  mod = ::Application.SoundSystem.Modifiers.Get(new_modifier, true);
1932  }
1933  else
1934  {
1935  SoundModifier.Set0();
1936  mod = nullptr;
1937  }
1938  // update in sound system
1940 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
C4SoundModifier * Get(class C4PropList *props, bool create_if_not_found)
void SetGlobalModifier(C4SoundModifier *new_modifier, int32_t player_index)
C4SoundModifierList Modifiers
Definition: C4SoundSystem.h:54
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141

References Application, C4SoundModifierList::Get(), C4SoundSystem::Modifiers, Number, C4Value::Set0(), C4SoundModifierList::SetGlobalModifier(), C4Value::SetPropList(), SoundModifier, and C4Application::SoundSystem.

Referenced by Init(), and ~C4Player().

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

◆ SetTeamHostility()

void C4Player::SetTeamHostility ( )

Definition at line 915 of file C4Player.cpp.

916 {
917  // team only
918  if (!Team) return;
919  // set hostilities
920  for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next)
921  if (pPlr != this)
922  {
923  bool fHostile = (pPlr->Team != Team);
924  SetHostility(pPlr->Number, fHostile, true);
925  pPlr->SetHostility(Number, fHostile, true);
926  }
927 }
bool SetHostility(int32_t iOpponent, int32_t iHostility, bool fSilent=false)
Definition: C4Player.cpp:838

References C4PlayerList::First, Next, Number, Players, SetHostility(), and Team.

Referenced by Init(), and ScenarioInit().

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

◆ SetViewLocked()

void C4Player::SetViewLocked ( bool  to_val)

Definition at line 1898 of file C4Player.cpp.

1899 {
1900  if ((ViewLock = to_val))
1901  {
1902  // view was locked - cancel any scrolling
1904  }
1905 }

References C4PVM_Cursor, C4PVM_Scrolling, SetViewMode(), ViewLock, and ViewMode.

Here is the call graph for this function:

◆ SetViewMode()

void C4Player::SetViewMode ( int32_t  iMode,
C4Object pTarget = nullptr,
bool  immediate_position = false 
)

Definition at line 767 of file C4Player.cpp.

768 {
769  // safe back
770  ViewMode=iMode; ViewTarget=pTarget;
771  // immediate position set desired?
772  if (immediate_position)
773  {
774  UpdateView();
776  if (vp) vp->AdjustPosition(true);
777  }
778 }
C4ViewportList Viewports
void AdjustPosition(bool immediate=false)
Definition: C4Viewport.cpp:653
C4Viewport * GetViewport(int32_t player_nr, C4Viewport *prev=nullptr)

References C4Viewport::AdjustPosition(), C4ViewportList::GetViewport(), Number, UpdateView(), ViewMode, Viewports, and ViewTarget.

Referenced by ResetCursorView(), ScrollView(), SetViewLocked(), and ToggleMouseControl().

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

◆ SetWealth()

bool C4Player::SetWealth ( int32_t  val)

Definition at line 741 of file C4Player.cpp.

742 {
743  if (iVal == Wealth) return true;
744 
745  Wealth=Clamp<int32_t>(iVal,0,1000000000);
746 
748 
749  return true;
750 }
#define PSF_OnWealthChanged
Definition: C4GameScript.h:151

References Game, C4Game::GRBroadcast(), Number, PSF_OnWealthChanged, and Wealth.

Referenced by DoWealth().

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

◆ SetZoom()

void C4Player::SetZoom ( C4Real  zoom,
bool  direct,
bool  no_increase,
bool  no_decrease 
)

Definition at line 1818 of file C4Player.cpp.

1819 {
1820  AdjustZoomParameter(&ZoomVal, zoom, no_increase, no_decrease);
1821  ZoomToViewports(direct, no_increase, no_decrease);
1822 }
void ZoomToViewports(bool direct, bool no_increase=false, bool no_decrease=false)
Definition: C4Player.cpp:1836

References ZoomToViewports(), and ZoomVal.

Here is the call graph for this function:

◆ SetZoomByViewRange()

void C4Player::SetZoomByViewRange ( int32_t  range_wdt,
int32_t  range_hgt,
bool  direct,
bool  no_increase,
bool  no_decrease 
)

Definition at line 1797 of file C4Player.cpp.

1798 {
1799  AdjustZoomParameter(&ZoomWdt, range_wdt, no_increase, no_decrease);
1800  AdjustZoomParameter(&ZoomHgt, range_hgt, no_increase, no_decrease);
1801  ZoomToViewports(direct, no_decrease, no_increase); // inc/dec swapped for zoom, because it's inversely proportional to range
1802 }

References ZoomHgt, ZoomToViewports(), and ZoomWdt.

Here is the call graph for this function:

◆ Strip()

bool C4Player::Strip ( const char *  szFilename,
bool  fAggressive 
)
static

Definition at line 957 of file C4Player.cpp.

958 {
959  // Open group
960  C4Group Grp;
961  if (!Grp.Open(szFilename))
962  return false;
963  // Which type of stripping?
964  if (!fAggressive)
965  {
966  // remove bigicon, if the file size is too large
967  size_t iBigIconSize=0;
968  if (Grp.FindEntry(C4CFN_BigIcon, nullptr, &iBigIconSize))
969  if (iBigIconSize > C4NetResMaxBigicon*1024)
970  Grp.Delete(C4CFN_BigIcon);
971  Grp.Close();
972  }
973  else
974  {
975  // Load info core and crew info list
976  C4PlayerInfoCore PlrInfoCore;
978  if (!PlrInfoCore.Load(Grp) || !CrewInfoList.Load(Grp))
979  return false;
980  // Strip crew info list (remove object infos that are invalid for this scenario)
982  // Create a new group that receives the bare essentials
983  Grp.Close();
984  if (!EraseItem(szFilename) ||
985  !Grp.Open(szFilename, true))
986  return false;
987  // Save info core & crew info list to newly-created file
988  if (!PlrInfoCore.Save(Grp) || !CrewInfoList.Save(Grp, true, true, &::Definitions))
989  return false;
990  Grp.Close();
991  }
992  return true;
993 }
const int32_t C4NetResMaxBigicon
Definition: C4Network2Res.h:36

References C4CFN_BigIcon, C4NetResMaxBigicon, C4Group::Close(), CrewInfoList, Definitions, C4Group::Delete(), EraseItem(), C4Group::FindEntry(), C4PlayerInfoCore::Load(), C4ObjectInfoList::Load(), C4Group::Open(), C4PlayerInfoCore::Save(), C4ObjectInfoList::Save(), and C4ObjectInfoList::Strip().

Referenced by C4Record::AddFile().

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

◆ Surrender()

void C4Player::Surrender ( )

Definition at line 828 of file C4Player.cpp.

829 {
830  if (Surrendered) return;
831  Surrendered=true;
832  Eliminated=true;
834  StartSoundEffect("UI::Eliminated");
835  Log(FormatString(LoadResStr("IDS_PRC_PLRSURRENDERED"),GetName()).getData());
836 }

References C4RetireDelay, Eliminated, FormatString(), GetName(), LoadResStr(), Log(), RetireDelay, StartSoundEffect(), and Surrendered.

Here is the call graph for this function:

◆ ToggleMouseControl()

void C4Player::ToggleMouseControl ( )

Definition at line 1741 of file C4Player.cpp.

1742 {
1743  // Activate mouse control if it's available
1744  if (!MouseControl && !::Players.MouseControlTaken())
1745  {
1746  ::MouseControl.Init(Number);
1747  MouseControl=true;
1748  }
1749  // Deactivate mouse control
1750  else if (MouseControl)
1751  {
1752  ::MouseControl.Clear();
1753  ::MouseControl.Default();
1754  MouseControl = 0;
1755  // Scrolling isn't possible any more
1756  if (ViewMode == C4PVM_Scrolling)
1758  }
1759 }

References C4PVM_Cursor, C4PVM_Scrolling, MouseControl, C4PlayerList::MouseControlTaken(), Number, Players, SetViewMode(), and ViewMode.

Here is the call graph for this function:

◆ UpdateView()

void C4Player::UpdateView ( )
protected

Definition at line 1180 of file C4Player.cpp.

1181 {
1182  // view target/cursor
1183  switch (ViewMode)
1184  {
1185  case C4PVM_Cursor:
1186  {
1187  C4Object *pViewObj;
1188  if (!(pViewObj=ViewCursor)) pViewObj=Cursor;
1189  if (pViewObj)
1190  {
1191  ViewX=pViewObj->GetX(); ViewY=pViewObj->GetY();
1192  }
1193  break;
1194  }
1195  case C4PVM_Target:
1196  if (ViewTarget)
1197  {
1199  }
1200  break;
1201  case C4PVM_Scrolling:
1202  break;
1203  }
1204 }
const int32_t C4PVM_Target
Definition: C4Player.h:32
int32_t GetY() const
Definition: C4Object.h:286

References C4PVM_Cursor, C4PVM_Scrolling, C4PVM_Target, Cursor, C4Object::GetX(), C4Object::GetY(), ViewCursor, ViewMode, ViewTarget, ViewX, and ViewY.

Referenced by AdjustCursorCommand(), Execute(), and SetViewMode().

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

◆ ZoomLimitsToViewport()

void C4Player::ZoomLimitsToViewport ( C4Viewport vp)

Definition at line 1859 of file C4Player.cpp.

1860 {
1861  float zoom_max = ZoomLimitMaxVal ? fixtof(ZoomLimitMaxVal) : vp->GetZoomByViewRange((ZoomLimitMinWdt || ZoomLimitMinHgt) ? ZoomLimitMinWdt : C4VP_DefMinViewRangeX,ZoomLimitMinHgt);
1862  float zoom_min = ZoomLimitMinVal ? fixtof(ZoomLimitMinVal) : vp->GetZoomByViewRange((ZoomLimitMaxWdt || ZoomLimitMaxHgt) ? ZoomLimitMaxWdt : C4VP_DefMaxViewRangeX,ZoomLimitMaxHgt);
1863  vp->SetZoomLimits(zoom_min, zoom_max);
1864 }
float fixtof(const C4Fixed &x)
Definition: C4Real.h:257
void SetZoomLimits(float to_min_zoom, float to_max_zoom)
Definition: C4Viewport.cpp:547

References fixtof(), C4Viewport::GetZoomByViewRange(), ZoomLimitMaxVal, ZoomLimitMinHgt, and ZoomLimitMinWdt.

Referenced by ZoomLimitsToViewports().

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

◆ ZoomLimitsToViewports()

void C4Player::ZoomLimitsToViewports ( )

Definition at line 1852 of file C4Player.cpp.

1853 {
1854  C4Viewport *vp = nullptr;
1855  while((vp = ::Viewports.GetViewport(Number, vp)) != nullptr)
1857 }
void ZoomLimitsToViewport(C4Viewport *vp)
Definition: C4Player.cpp:1859

References C4ViewportList::GetViewport(), Number, Viewports, and ZoomLimitsToViewport().

Referenced by SetMaxZoom(), SetMaxZoomByViewRange(), SetMinZoom(), and SetMinZoomByViewRange().

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

◆ ZoomToViewport()

void C4Player::ZoomToViewport ( C4Viewport vp,
bool  direct,
bool  no_increase = false,
bool  no_decrease = false 
)

Definition at line 1843 of file C4Player.cpp.

1844 {
1845  float new_zoom = ZoomVal ? fixtof(ZoomVal) : vp->GetZoomByViewRange((ZoomWdt || ZoomHgt) ? ZoomWdt : C4VP_DefViewRangeX,ZoomHgt);
1846  float old_zoom = vp->GetZoomTarget();
1847  if (new_zoom > old_zoom && no_increase) return;
1848  if (new_zoom < old_zoom && no_decrease) return;
1849  vp->SetZoom(new_zoom, direct);
1850 }
float GetZoomTarget() const
Definition: C4Viewport.h:61
void SetZoom(float zoom_value)
Definition: C4Viewport.cpp:592

References fixtof(), C4Viewport::GetZoomByViewRange(), ZoomHgt, ZoomVal, and ZoomWdt.

Referenced by ZoomToViewports().

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

◆ ZoomToViewports()

void C4Player::ZoomToViewports ( bool  direct,
bool  no_increase = false,
bool  no_decrease = false 
)

Definition at line 1836 of file C4Player.cpp.

1837 {
1838  C4Viewport *vp = nullptr;
1839  while((vp = ::Viewports.GetViewport(Number, vp)) != nullptr)
1840  ZoomToViewport(vp, direct, no_increase, no_decrease);
1841 }
void ZoomToViewport(C4Viewport *vp, bool direct, bool no_increase=false, bool no_decrease=false)
Definition: C4Player.cpp:1843

References C4ViewportList::GetViewport(), Number, Viewports, and ZoomToViewport().

Referenced by SetZoom(), and SetZoomByViewRange().

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

Friends And Related Function Documentation

◆ C4PlayerList

friend class C4PlayerList
friend

Definition at line 74 of file C4Player.h.

Member Data Documentation

◆ Achievements

C4ScenarioParameters C4PlayerInfoCore::Achievements
inherited

Definition at line 108 of file C4InfoCore.h.

Referenced by C4PlayerInfoCore::CompileFunc(), and GainScenarioAchievement().

◆ ActionCount

int32_t C4Player::ActionCount

Definition at line 147 of file C4Player.h.

Referenced by C4Player(), ClearControl(), and CountControl().

◆ AtClient

int32_t C4Player::AtClient

◆ AtClientName

char C4Player::AtClientName[C4MaxTitle+1]

Definition at line 98 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), and Init().

◆ BaseMaterial

C4IDList C4Player::BaseMaterial

Definition at line 120 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), ExecBaseProduction(), and ScenarioInit().

◆ BaseProduction

C4IDList C4Player::BaseProduction

Definition at line 121 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), ExecBaseProduction(), and ScenarioInit().

◆ BigIcon

C4FacetSurface C4Player::BigIcon

Definition at line 138 of file C4Player.h.

Referenced by C4Player(), C4RoundResultsPlayer::EvaluatePlayer(), and Load().

◆ ColorDw

◆ Comment

char C4PlayerInfoCore::Comment[C4MaxComment+1]
inherited

◆ Control

◆ ControlCount

int32_t C4Player::ControlCount

Definition at line 146 of file C4Player.h.

Referenced by C4Player(), ClearControl(), and CountControl().

◆ ControlSet

◆ ControlSetName

StdCopyStrBuf C4Player::ControlSetName

Definition at line 91 of file C4Player.h.

Referenced by ClearControl(), DefaultRuntimeData(), and InitControl().

◆ Crew

◆ CrewInfoList

◆ CurrentScore

int32_t C4Player::CurrentScore

Definition at line 116 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), DoScore(), Evaluate(), and FinalInit().

◆ Cursor

◆ CursorFlash

int32_t C4Player::CursorFlash

Definition at line 131 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), Execute(), and SetCursor().

◆ Eliminated

◆ Evaluated

bool C4Player::Evaluated

◆ ExtraData

C4ValueMapData C4PlayerInfoCore::ExtraData
inherited

Definition at line 93 of file C4InfoCore.h.

Referenced by C4PlayerInfoCore::CompileFunc(), and C4PlayerInfoCore::Default().

◆ fFogOfWar

bool C4Player::fFogOfWar

Definition at line 111 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), and SetFoW().

◆ Filename

char C4Player::Filename[_MAX_PATH_LEN]

Definition at line 80 of file C4Player.h.

Referenced by C4Player(), C4PlayerList::FileInUse(), Init(), Load(), and Save().

◆ FlashCom

int32_t C4Player::FlashCom

Definition at line 110 of file C4Player.h.

Referenced by DefaultRuntimeData().

◆ GameJoinTime

int32_t C4Player::GameJoinTime

Definition at line 96 of file C4Player.h.

Referenced by C4Player(), Evaluate(), Init(), and LocalSync().

◆ Hostility

HostilitySet C4Player::Hostility

◆ ID

◆ InitialScore

int32_t C4Player::InitialScore

Definition at line 116 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), Evaluate(), and FinalInit().

◆ Knowledge

C4IDList C4Player::Knowledge

Definition at line 127 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), ScenarioInit(), and SetKnowledge().

◆ LastControlID

int32_t C4Player::LastControlID

Definition at line 148 of file C4Player.h.

Referenced by C4Player(), ClearControl(), and CountControl().

◆ LastControlType

ControlType C4Player::LastControlType

Definition at line 148 of file C4Player.h.

Referenced by C4Player(), ClearControl(), and CountControl().

◆ LastRound

C4RoundResult C4PlayerInfoCore::LastRound
inherited

◆ LeagueEvaluated

bool C4Player::LeagueEvaluated

Definition at line 100 of file C4Player.h.

Referenced by C4Player(), and EvaluateLeague().

◆ LeagueName

char C4PlayerInfoCore::LeagueName[C4MaxName+1]
inherited

Definition at line 94 of file C4InfoCore.h.

Referenced by C4PlayerInfoCore::CompileFunc(), and C4PlayerInfoCore::Default().

◆ LocalControl

bool C4Player::LocalControl

◆ Menu

◆ MessageBuf

char C4Player::MessageBuf[256+1]

Definition at line 135 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), and Message().

◆ MessageStatus

int32_t C4Player::MessageStatus

Definition at line 134 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), Execute(), and Message().

◆ MouseControl

int32_t C4Player::MouseControl

◆ Name

StdStrBuf C4Player::Name

Definition at line 81 of file C4Player.h.

Referenced by Execute(), GetName(), Init(), and InitControl().

◆ Next

◆ NoEliminationCheck

bool C4Player::NoEliminationCheck

Definition at line 101 of file C4Player.h.

Referenced by C4Player(), CheckElimination(), and Init().

◆ Number

◆ ObjectsOwned

int32_t C4Player::ObjectsOwned

Definition at line 117 of file C4Player.h.

Referenced by CompileFunc(), and DefaultRuntimeData().

◆ OldPrefAutoContextMenu

int32_t C4PlayerInfoCore::OldPrefAutoContextMenu
inherited

◆ OldPrefControl

int32_t C4PlayerInfoCore::OldPrefControl
inherited

◆ OldPrefControlStyle

int32_t C4PlayerInfoCore::OldPrefControlStyle
inherited

◆ pGamepad

std::shared_ptr<class C4GamePadOpener> C4Player::pGamepad

Definition at line 132 of file C4Player.h.

Referenced by ClearControl(), and Execute().

◆ PlrStartIndex

int32_t C4Player::PlrStartIndex

◆ pMsgBoardQuery

◆ Position

int32_t C4Player::Position

Definition at line 93 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), and ScenarioInit().

◆ PrefClonkSkin

◆ PrefColor

◆ PrefColor2Dw

uint32_t C4PlayerInfoCore::PrefColor2Dw
inherited

◆ PrefColorDw

◆ PrefControl

◆ PrefMouse

int32_t C4PlayerInfoCore::PrefMouse
inherited

◆ PrefName

◆ ProductionDelay

int32_t C4Player::ProductionDelay

Definition at line 122 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), and ExecBaseProduction().

◆ ProductionUnit

int32_t C4Player::ProductionUnit

Definition at line 122 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), and ExecBaseProduction().

◆ pstatActions

class C4TableGraph * C4Player::pstatActions

Definition at line 145 of file C4Player.h.

Referenced by C4Player(), ClearGraphs(), and CreateGraphs().

◆ pstatControls

class C4TableGraph* C4Player::pstatControls

Definition at line 145 of file C4Player.h.

Referenced by C4Player(), ClearGraphs(), and CreateGraphs().

◆ Rank

int32_t C4PlayerInfoCore::Rank
inherited

◆ RankName

char C4PlayerInfoCore::RankName[C4MaxName+1]
inherited

◆ RetireDelay

int32_t C4Player::RetireDelay

Definition at line 95 of file C4Player.h.

Referenced by DefaultRuntimeData(), Eliminate(), Execute(), C4PlayerList::Execute(), and Surrender().

◆ Rounds

int32_t C4PlayerInfoCore::Rounds
inherited

Definition at line 90 of file C4InfoCore.h.

Referenced by C4PlayerInfoCore::CompileFunc(), C4PlayerInfoCore::Default(), and Evaluate().

◆ RoundsLost

int32_t C4PlayerInfoCore::RoundsLost
inherited

Definition at line 90 of file C4InfoCore.h.

Referenced by C4PlayerInfoCore::CompileFunc(), C4PlayerInfoCore::Default(), and Evaluate().

◆ RoundsWon

int32_t C4PlayerInfoCore::RoundsWon
inherited

Definition at line 90 of file C4InfoCore.h.

Referenced by C4PlayerInfoCore::CompileFunc(), C4PlayerInfoCore::Default(), and Evaluate().

◆ ShowStartup

bool C4Player::ShowStartup

Definition at line 109 of file C4Player.h.

Referenced by CompileFunc(), and DefaultRuntimeData().

◆ SoundModifier

C4Value C4Player::SoundModifier

Definition at line 140 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), Init(), and SetSoundModifier().

◆ Status

◆ Surrendered

int32_t C4Player::Surrendered

Definition at line 84 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), and Surrender().

◆ Team

◆ TotalPlayingTime

int32_t C4PlayerInfoCore::TotalPlayingTime
inherited

◆ TotalScore

int32_t C4PlayerInfoCore::TotalScore
inherited

◆ ViewCursor

C4ObjectPtr C4Player::ViewCursor

◆ ViewLock

bool C4Player::ViewLock

Definition at line 107 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), IsViewLocked(), ScrollView(), and SetViewLocked().

◆ ViewMode

int32_t C4Player::ViewMode

◆ ViewTarget

C4Object* C4Player::ViewTarget

Definition at line 108 of file C4Player.h.

Referenced by ClearPointers(), DefaultRuntimeData(), SetViewMode(), and UpdateView().

◆ ViewX

C4Real C4Player::ViewX

Definition at line 106 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), Execute(), Init(), ScrollView(), and UpdateView().

◆ ViewY

C4Real C4Player::ViewY

Definition at line 106 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), Execute(), Init(), ScrollView(), and UpdateView().

◆ Wealth

int32_t C4Player::Wealth

Definition at line 115 of file C4Player.h.

Referenced by CompileFunc(), DefaultRuntimeData(), DoWealth(), ScenarioInit(), and SetWealth().

◆ ZoomHgt

int32_t C4Player::ZoomHgt

Definition at line 112 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), SetZoomByViewRange(), and ZoomToViewport().

◆ ZoomLimitMaxHgt

int32_t C4Player::ZoomLimitMaxHgt

Definition at line 112 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), and SetMaxZoomByViewRange().

◆ ZoomLimitMaxVal

C4Real C4Player::ZoomLimitMaxVal

Definition at line 113 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), SetMaxZoom(), and ZoomLimitsToViewport().

◆ ZoomLimitMaxWdt

int32_t C4Player::ZoomLimitMaxWdt

Definition at line 112 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), and SetMaxZoomByViewRange().

◆ ZoomLimitMinHgt

int32_t C4Player::ZoomLimitMinHgt

Definition at line 112 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), SetMinZoomByViewRange(), and ZoomLimitsToViewport().

◆ ZoomLimitMinVal

C4Real C4Player::ZoomLimitMinVal

Definition at line 113 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), and SetMinZoom().

◆ ZoomLimitMinWdt

int32_t C4Player::ZoomLimitMinWdt

Definition at line 112 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), SetMinZoomByViewRange(), and ZoomLimitsToViewport().

◆ ZoomVal

C4Real C4Player::ZoomVal

Definition at line 113 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), SetZoom(), and ZoomToViewport().

◆ ZoomWdt

int32_t C4Player::ZoomWdt

Definition at line 112 of file C4Player.h.

Referenced by C4Player(), CompileFunc(), SetZoomByViewRange(), and ZoomToViewport().


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