OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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+1]
 
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
C4PlayerControlAssignmentSet
ControlSet
 
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
C4GamePadOpener
pGamepad
 
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 50 of file C4Player.h.

Member Enumeration Documentation

Enumerator
PCID_None 
PCID_Message 
PCID_Special 
PCID_Command 
PCID_DirectCom 

Definition at line 60 of file C4Player.h.

61  {
62  PCID_None, // no control
63  PCID_Message, // chat
64  PCID_Special, // goalruleinfo, etc.
65  PCID_Command, // mouse control
66  PCID_DirectCom // menu or keyboard control
67  };
Enumerator
PS_None 
PS_Normal 
PS_TeamSelection 
PS_TeamSelectionPending 

Definition at line 69 of file C4Player.h.

70  {
71  PS_None=0, // player disabled
72  PS_Normal=1, // normal playing
73  PS_TeamSelection = 2, // team selection
74  PS_TeamSelectionPending = 3 // waiting for team selection packet to come through
75  };

Constructor & Destructor Documentation

C4Player::C4Player ( )

Definition at line 49 of file C4Player.cpp.

References ActionCount, BigIcon, C4P_Number_None, ControlCount, Crew, CrewInfoList, C4ObjectInfoList::Default(), C4MainMenu::Default(), C4FacetSurface::Default(), C4ObjectList::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.

50 {
51  Filename[0] = 0;
53  ID = 0;
54  Team = 0;
56  Menu.Default();
57  Crew.Default();
59  LocalControl = false;
60  BigIcon.Default();
61  Next = nullptr;
62  fFogOfWar = true;
63  LeagueEvaluated = false;
64  GameJoinTime = 0; // overwritten in Init
65  pstatControls = pstatActions = nullptr;
68  LastControlID = 0;
69  pMsgBoardQuery = nullptr;
70  NoEliminationCheck = false;
71  Evaluated = false;
74  ViewLock = true;
76 }
int32_t LastControlID
Definition: C4Player.h:150
int32_t Team
Definition: C4Player.h:90
C4MainMenu Menu
Definition: C4Player.h:105
bool ViewLock
Definition: C4Player.h:109
int32_t ControlCount
Definition: C4Player.h:148
int32_t Number
Definition: C4Player.h:88
C4Real ZoomVal
Definition: C4Player.h:115
class C4TableGraph * pstatActions
Definition: C4Player.h:147
char Filename[_MAX_PATH+1]
Definition: C4Player.h:82
ControlType LastControlType
Definition: C4Player.h:150
int32_t ZoomLimitMinHgt
Definition: C4Player.h:114
void Set0()
Definition: C4Value.h:336
virtual void Default()
Definition: C4MainMenu.cpp:44
int32_t ZoomLimitMaxWdt
Definition: C4Player.h:114
void Default()
Definition: C4FacetEx.h:43
int32_t ZoomWdt
Definition: C4Player.h:114
const int32_t C4P_Number_None
Definition: C4Player.h:37
C4FacetSurface BigIcon
Definition: C4Player.h:140
class C4TableGraph * pstatControls
Definition: C4Player.h:147
int32_t GameJoinTime
Definition: C4Player.h:98
bool Evaluated
Definition: C4Player.h:87
C4ObjectList Crew
Definition: C4Player.h:127
C4Value SoundModifier
Definition: C4Player.h:142
int32_t ZoomLimitMinWdt
Definition: C4Player.h:114
bool NoEliminationCheck
Definition: C4Player.h:103
int32_t ID
Definition: C4Player.h:89
int32_t ZoomLimitMaxHgt
Definition: C4Player.h:114
C4Real ZoomLimitMaxVal
Definition: C4Player.h:115
bool LeagueEvaluated
Definition: C4Player.h:102
C4Player * Next
Definition: C4Player.h:144
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
virtual void Default()
int32_t ZoomHgt
Definition: C4Player.h:114
bool fFogOfWar
Definition: C4Player.h:113
void DefaultRuntimeData()
Definition: C4Player.cpp:1208
class C4MessageBoardQuery * pMsgBoardQuery
Definition: C4Player.h:138
int32_t ActionCount
Definition: C4Player.h:149
const C4Real Fix0
Definition: C4Real.h:312
bool LocalControl
Definition: C4Player.h:101
C4Real ZoomLimitMinVal
Definition: C4Player.h:115

Here is the call graph for this function:

C4Player::~C4Player ( )

Definition at line 78 of file C4Player.cpp.

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

79 {
80  ClearGraphs();
81  Menu.Clear();
82  SetSoundModifier(nullptr);
83  while (pMsgBoardQuery)
84  {
86  delete pMsgBoardQuery;
87  pMsgBoardQuery = pNext;
88  }
89  ClearControl();
90 }
C4MainMenu Menu
Definition: C4Player.h:105
void ClearControl()
Definition: C4Player.cpp:1375
void ClearGraphs()
Definition: C4Player.cpp:1616
void Clear()
Definition: C4Menu.cpp:272
C4MessageBoardQuery * pNext
class C4MessageBoardQuery * pMsgBoardQuery
Definition: C4Player.h:138
void SetSoundModifier(C4PropList *new_modifier)
Definition: C4Player.cpp:1924

Here is the call graph for this function:

Member Function Documentation

bool C4Player::ActivateMenuMain ( )

Definition at line 1762 of file C4Player.cpp.

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

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

Here is the call graph for this function:

bool C4Player::ActivateMenuTeamSelection ( bool  fFromMain)

Definition at line 1240 of file C4Player.cpp.

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().

1241 {
1242  // Menu symbol/init
1243  bool fSwitch = !(Status==PS_TeamSelection);
1246  Menu.Refill();
1247  // Go back to options menu on close
1248  if (fFromMain) Menu.SetCloseCommand("ActivateMenu:Main");
1249  return true;
1250 }
bool Refill()
Definition: C4Menu.cpp:916
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1145
C4MainMenu Menu
Definition: C4Player.h:105
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:858
int32_t Number
Definition: C4Player.h:88
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
int32_t Status
Definition: C4Player.h:84
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:57
static C4Facet GetIconFacet(Icons icoIconIndex)

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4Player::ActiveCrewCount ( )

Definition at line 1498 of file C4Player.cpp.

References Crew.

1499 {
1500  // get number of objects in crew that is not disabled
1501  int32_t iNum=0;
1502  for (C4Object *cObj : Crew)
1503  if (cObj)
1504  if (!cObj->CrewDisabled)
1505  ++iNum;
1506  // return it
1507  return iNum;
1508 }
C4ObjectList Crew
Definition: C4Player.h:127
void C4Player::AdjustCursorCommand ( )

Definition at line 1061 of file C4Player.cpp.

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

Referenced by ClearPointers(), and FinalInit().

1062 {
1063  // Reset view
1064  ResetCursorView();
1065  // Default cursor to hirank clonk
1066  if (!Cursor || Cursor->CrewDisabled)
1067  {
1068  C4Object *pHiRank = GetHiRankActiveCrew();
1069  if (!pHiRank)
1070  return;
1071  SetCursor(pHiRank,true);
1072  UpdateView();
1073  }
1074 }
C4ObjectPtr Cursor
Definition: C4Player.h:132
void UpdateView()
Definition: C4Player.cpp:1182
void SetCursor(C4Object *pObj, bool fSelectArrow)
Definition: C4Player.cpp:1350
bool CrewDisabled
Definition: C4Object.h:163
C4Object * GetHiRankActiveCrew()
Definition: C4Player.cpp:888
void ResetCursorView(bool immediate_position=false)
Definition: C4Player.cpp:782

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1665 of file C4Player.cpp.

References pMsgBoardQuery, and RemoveMessageBoardQuery().

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

Here is the call graph for this function:

void C4Player::CheckCrewExPromotion ( )
protected

Definition at line 907 of file C4Player.cpp.

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

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

Here is the call graph for this function:

void C4Player::CheckElimination ( )
protected

Definition at line 1170 of file C4Player.cpp.

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

Referenced by Execute().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PlayerInfoCore::CheckPromotion ( C4RankSystem rRanks)
inherited

Definition at line 127 of file C4InfoCore.cpp.

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

128 {
129  if (TotalScore>=rRanks.Experience(Rank+1))
130  {
131  Promote(Rank+1,rRanks);
132  return true;
133  }
134  return false;
135 }
int32_t TotalScore
Definition: C4InfoCore.h:90
void Promote(int32_t iRank, C4RankSystem &rRanks)
Definition: C4InfoCore.cpp:121
int Experience(int iRank)

Here is the call graph for this function:

void C4Player::ClearControl ( )
protected

Definition at line 1375 of file C4Player.cpp.

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().

1376 {
1377  // Mark any control set as unused
1378  Control.Clear();
1379  // Reset control
1380  LocalControl = false;
1382  ControlSet=nullptr;
1383  MouseControl = false;
1384  if (pGamepad)
1385  {
1386  pGamepad->SetPlayer(NO_OWNER);
1387  pGamepad.reset();
1388  }
1389  // no controls issued yet
1390  ControlCount = ActionCount = 0;
1392  LastControlID = 0;
1393 }
int32_t MouseControl
Definition: C4Player.h:94
int32_t LastControlID
Definition: C4Player.h:150
int32_t ControlCount
Definition: C4Player.h:148
void Clear()
Definition: StdBuf.h:474
ControlType LastControlType
Definition: C4Player.h:150
C4PlayerControl Control
Definition: C4Player.h:131
std::shared_ptr< class C4GamePadOpener > pGamepad
Definition: C4Player.h:134
class C4PlayerControlAssignmentSet * ControlSet
Definition: C4Player.h:92
const int NO_OWNER
Definition: C4Constants.h:138
StdCopyStrBuf ControlSetName
Definition: C4Player.h:93
int32_t ActionCount
Definition: C4Player.h:149
bool LocalControl
Definition: C4Player.h:101

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::ClearGraphs ( )

Definition at line 1616 of file C4Player.cpp.

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

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

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

Here is the caller graph for this function:

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

Definition at line 100 of file C4Player.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::CloseMenu ( )

Definition at line 1468 of file C4Player.cpp.

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

1469 {
1470  // cancel all player menus
1471  Menu.Close(false);
1472 }
C4MainMenu Menu
Definition: C4Player.h:105
void Close(bool fOK)

Here is the call graph for this function:

void C4PlayerInfoCore::CompileFunc ( StdCompiler pComp)
inherited

Definition at line 137 of file C4InfoCore.cpp.

References C4PlayerInfoCore::Achievements, C4PlayerInfoCore::Comment, C4ValueMapData::Denumerate(), C4ValueNumbers::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().

138 {
139  C4ValueNumbers numbers;
140  pComp->Name("Player");
141  pComp->Value(mkNamingAdapt(toC4CStr(PrefName),"Name", "Neuling"));
142  pComp->Value(mkNamingAdapt(toC4CStr(Comment), "Comment", ""));
143  pComp->Value(mkNamingAdapt(Rank, "Rank", 0));
144  pComp->Value(mkNamingAdapt(toC4CStr(RankName),"RankName", LoadResStr("IDS_MSG_RANK"))); // TODO: check if this would be desirable
145  pComp->Value(mkNamingAdapt(TotalScore, "Score", 0));
146  pComp->Value(mkNamingAdapt(Rounds, "Rounds", 0));
147  pComp->Value(mkNamingAdapt(RoundsWon, "RoundsWon", 0));
148  pComp->Value(mkNamingAdapt(RoundsLost, "RoundsLost", 0));
149  pComp->Value(mkNamingAdapt(TotalPlayingTime, "TotalPlayingTime", 0));
150  pComp->Value(mkNamingAdapt(mkParAdapt(ExtraData, &numbers), "ExtraData", C4ValueMapData()));
151  pComp->Value(mkNamingAdapt(numbers, "ExtraDataValues"));
152  if (pComp->isDeserializer())
153  {
154  numbers.Denumerate();
155  ExtraData.Denumerate(&numbers);
156  }
157  pComp->Value(mkNamingAdapt(toC4CStr(LeagueName),"LeagueName", ""));
158  pComp->NameEnd();
159 
160  pComp->Name("Preferences");
161  pComp->Value(mkNamingAdapt(PrefColor, "Color", 0));
162  pComp->Value(mkNamingAdapt(PrefColorDw, "ColorDw", 0xffu));
163  pComp->Value(mkNamingAdapt(PrefColor2Dw, "AlternateColorDw", 0u));
164  pComp->Value(mkNamingAdapt(PrefMouse, "Mouse", 1));
165  pComp->Value(mkNamingAdapt(OldPrefControl, "Control", 1));
166  pComp->Value(mkNamingAdapt(OldPrefControlStyle, "AutoStopControl", 0));
167  pComp->Value(mkNamingAdapt(OldPrefAutoContextMenu, "AutoContextMenu", -1)); // compiling default is -1 (if this is detected, AutoContextMenus will be defaulted by control style)
168  pComp->Value(mkNamingAdapt(PrefControl, "ControlSet", StdStrBuf()));
169  pComp->Value(mkNamingAdapt(PrefClonkSkin, "ClonkSkin", 0));
170  pComp->NameEnd();
171 
172  pComp->Value(mkNamingAdapt(LastRound, "LastRound"));
173 
174  pComp->Value(mkNamingAdapt(Achievements, "Achievements"));
175 }
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:105
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:106
void Denumerate()
Definition: C4Value.cpp:283
int32_t TotalPlayingTime
Definition: C4InfoCore.h:92
int32_t RoundsWon
Definition: C4InfoCore.h:91
int32_t OldPrefControl
Definition: C4InfoCore.h:104
void Denumerate(C4ValueNumbers *)
Definition: C4ValueMap.cpp:259
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:86
int32_t PrefClonkSkin
Definition: C4InfoCore.h:101
char LeagueName[C4MaxName+1]
Definition: C4InfoCore.h:95
StdCopyStrBuf PrefControl
Definition: C4InfoCore.h:97
virtual bool Name(const char *szName)
Definition: StdCompiler.h:87
#define toC4CStr(szString)
Definition: StdAdaptors.h:25
int32_t PrefMouse
Definition: C4InfoCore.h:98
C4ValueMapData ExtraData
Definition: C4InfoCore.h:94
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
int32_t RoundsLost
Definition: C4InfoCore.h:91
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
char Comment[C4MaxComment+1]
Definition: C4InfoCore.h:87
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:89
int32_t PrefColor
Definition: C4InfoCore.h:99
void Value(const T &rStruct)
Definition: StdCompiler.h:171
uint32_t PrefColorDw
Definition: C4InfoCore.h:100
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:100
virtual bool isDeserializer()
Definition: StdCompiler.h:63
int32_t TotalScore
Definition: C4InfoCore.h:90
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:459
int32_t Rounds
Definition: C4InfoCore.h:91
C4ScenarioParameters Achievements
Definition: C4InfoCore.h:109
virtual void NameEnd(bool fBreak=false)
Definition: StdCompiler.h:88
C4RoundResult LastRound
Definition: C4InfoCore.h:93

Here is the call graph for this function:

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

Definition at line 1076 of file C4Player.cpp.

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.

1077 {
1078  assert(ID);
1079 
1080  pComp->Value(mkNamingAdapt(Status, "Status", 0));
1081  pComp->Value(mkNamingAdapt(AtClient, "AtClient", C4ClientIDUnknown));
1082  pComp->Value(mkNamingAdapt(toC4CStr(AtClientName),"AtClientName", "Local"));
1083  pComp->Value(mkNamingAdapt(Number, "Index", C4P_Number_None));
1084  pComp->Value(mkNamingAdapt(ID, "ID", 0));
1085  pComp->Value(mkNamingAdapt(Eliminated, "Eliminated", 0));
1086  pComp->Value(mkNamingAdapt(Surrendered, "Surrendered", 0));
1087  pComp->Value(mkNamingAdapt(Evaluated, "Evaluated", false));
1088  pComp->Value(mkNamingAdapt(ColorDw, "ColorDw", 0u));
1089  pComp->Value(mkNamingAdapt(Position, "Position", 0));
1090  pComp->Value(mkNamingAdapt(ViewMode, "ViewMode", C4PVM_Cursor));
1091  pComp->Value(mkNamingAdapt(ViewX, "ViewX", 0));
1092  pComp->Value(mkNamingAdapt(ViewY, "ViewY", 0));
1093  pComp->Value(mkNamingAdapt(ViewLock, "ViewLock", true));
1094  pComp->Value(mkNamingAdapt(ZoomLimitMinWdt, "ZoomLimitMinWdt", 0));
1095  pComp->Value(mkNamingAdapt(ZoomLimitMinHgt, "ZoomLimitMinHgt", 0));
1096  pComp->Value(mkNamingAdapt(ZoomLimitMaxWdt, "ZoomLimitMaxWdt", 0));
1097  pComp->Value(mkNamingAdapt(ZoomLimitMaxHgt, "ZoomLimitMaxHgt", 0));
1098  pComp->Value(mkNamingAdapt(ZoomWdt, "ZoomWdt", 0));
1099  pComp->Value(mkNamingAdapt(ZoomHgt, "ZoomHgt", 0));
1100  pComp->Value(mkNamingAdapt(ZoomLimitMinVal, "ZoomLimitMinVal", Fix0));
1101  pComp->Value(mkNamingAdapt(ZoomLimitMaxVal, "ZoomLimitMaxVal", Fix0));
1102  pComp->Value(mkNamingAdapt(ZoomVal, "ZoomVal", Fix0));
1103  pComp->Value(mkNamingAdapt(fFogOfWar, "FogOfWar", false));
1104  pComp->Value(mkNamingAdapt(ShowStartup, "ShowStartup", false));
1105  pComp->Value(mkNamingAdapt(Wealth, "Wealth", 0));
1106  pComp->Value(mkNamingAdapt(CurrentScore, "Score", 0));
1107  pComp->Value(mkNamingAdapt(InitialScore, "InitialScore", 0));
1108  pComp->Value(mkNamingAdapt(ObjectsOwned, "ObjectsOwned", 0));
1109  pComp->Value(mkNamingAdapt(Hostility, "Hostile" ));
1110  pComp->Value(mkNamingAdapt(ProductionDelay, "ProductionDelay", 0));
1111  pComp->Value(mkNamingAdapt(ProductionUnit, "ProductionUnit", 0));
1112  pComp->Value(mkNamingAdapt(CursorFlash, "CursorFlash", 0));
1113  pComp->Value(mkNamingAdapt(Cursor, "Cursor", C4ObjectPtr::Null));
1114  pComp->Value(mkNamingAdapt(ViewCursor, "ViewCursor", C4ObjectPtr::Null));
1115  pComp->Value(mkNamingAdapt(MessageStatus, "MessageStatus", 0));
1116  pComp->Value(mkNamingAdapt(toC4CStr(MessageBuf),"MessageBuf", ""));
1117  pComp->Value(mkNamingAdapt(BaseMaterial, "BaseMaterial" ));
1118  pComp->Value(mkNamingAdapt(BaseProduction, "BaseProduction" ));
1119  pComp->Value(mkNamingAdapt(Knowledge, "Knowledge" ));
1120  pComp->Value(mkNamingAdapt(mkParAdapt(Crew, numbers), "Crew" ));
1121  pComp->Value(mkNamingAdapt(CrewInfoList.iNumCreated, "CrewCreated", 0));
1122  pComp->Value(mkNamingPtrAdapt( pMsgBoardQuery, "MsgBoardQueries" ));
1123  pComp->Value(mkNamingAdapt(mkParAdapt(SoundModifier, numbers), "SoundModifier", C4Value()));
1124 
1125  if (pComp->isDeserializer())
1126  {
1127  SoundModifier.Denumerate(numbers);
1128  }
1129 
1130  // Keys held down
1131  pComp->Value(Control);
1132 }
char AtClientName[C4MaxTitle+1]
Definition: C4Player.h:100
C4ObjectPtr Cursor
Definition: C4Player.h:132
int32_t ProductionDelay
Definition: C4Player.h:124
bool ViewLock
Definition: C4Player.h:109
int32_t ViewMode
Definition: C4Player.h:107
int32_t Number
Definition: C4Player.h:88
C4Real ZoomVal
Definition: C4Player.h:115
int32_t ObjectsOwned
Definition: C4Player.h:119
bool ShowStartup
Definition: C4Player.h:111
int32_t ZoomLimitMinHgt
Definition: C4Player.h:114
C4PlayerControl Control
Definition: C4Player.h:131
#define toC4CStr(szString)
Definition: StdAdaptors.h:25
int32_t Position
Definition: C4Player.h:95
int32_t ProductionUnit
Definition: C4Player.h:124
int32_t ZoomLimitMaxWdt
Definition: C4Player.h:114
char MessageBuf[256+1]
Definition: C4Player.h:137
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
uint32_t ColorDw
Definition: C4Player.h:91
int32_t CursorFlash
Definition: C4Player.h:133
static const C4ObjectPtr Null
Definition: C4ObjectPtr.h:28
int32_t ZoomWdt
Definition: C4Player.h:114
const int32_t C4P_Number_None
Definition: C4Player.h:37
void Denumerate(C4ValueNumbers *)
Definition: C4Value.cpp:253
int32_t Status
Definition: C4Player.h:84
C4IDList Knowledge
Definition: C4Player.h:129
int32_t MessageStatus
Definition: C4Player.h:136
void Value(const T &rStruct)
Definition: StdCompiler.h:171
bool Evaluated
Definition: C4Player.h:87
const int32_t C4ClientIDUnknown
Definition: C4Client.h:24
int32_t Surrendered
Definition: C4Player.h:86
C4ObjectList Crew
Definition: C4Player.h:127
int32_t Eliminated
Definition: C4Player.h:85
C4Value SoundModifier
Definition: C4Player.h:142
int32_t CurrentScore
Definition: C4Player.h:118
int32_t Wealth
Definition: C4Player.h:117
int32_t ZoomLimitMinWdt
Definition: C4Player.h:114
virtual bool isDeserializer()
Definition: StdCompiler.h:63
int32_t AtClient
Definition: C4Player.h:99
int32_t ID
Definition: C4Player.h:89
int32_t ZoomLimitMaxHgt
Definition: C4Player.h:114
C4Real ViewY
Definition: C4Player.h:108
C4Real ZoomLimitMaxVal
Definition: C4Player.h:115
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
int32_t InitialScore
Definition: C4Player.h:118
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:459
const int32_t C4PVM_Cursor
Definition: C4Player.h:33
int32_t ZoomHgt
Definition: C4Player.h:114
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
Definition: StdAdaptors.h:605
bool fFogOfWar
Definition: C4Player.h:113
C4ObjectPtr ViewCursor
Definition: C4Player.h:132
C4IDList BaseMaterial
Definition: C4Player.h:122
class C4MessageBoardQuery * pMsgBoardQuery
Definition: C4Player.h:138
C4IDList BaseProduction
Definition: C4Player.h:123
const C4Real Fix0
Definition: C4Real.h:312
C4Real ViewX
Definition: C4Player.h:108
HostilitySet Hostility
Definition: C4Player.h:120
C4Real ZoomLimitMinVal
Definition: C4Player.h:115

Here is the call graph for this function:

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

Definition at line 1633 of file C4Player.cpp.

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

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

Here is the call graph for this function:

void C4Player::CreateGraphs ( )

Definition at line 1589 of file C4Player.cpp.

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().

1590 {
1591  // del prev
1592  ClearGraphs();
1593  // create graphs
1595  {
1596  DWORD dwGraphClr = ColorDw;
1597  C4PlayerInfo *pInfo;
1598  if (ID && (pInfo = Game.PlayerInfos.GetPlayerInfoByID(ID)))
1599  {
1600  // set color by player info class
1601  dwGraphClr = pInfo->GetColor();
1602  }
1603  C4GUI::MakeColorReadableOnBlack(dwGraphClr); dwGraphClr &= 0xffffff;
1605  pstatControls->SetColorDw(dwGraphClr);
1608  pstatActions->SetColorDw(dwGraphClr);
1610  // register into
1611  Game.pNetworkStatistics->statControls.AddGraph(pstatControls);
1612  Game.pNetworkStatistics->statActions.AddGraph(pstatActions);
1613  }
1614 }
C4Game Game
Definition: C4Globals.cpp:52
class C4TableGraph * pstatActions
Definition: C4Player.h:147
DWORD MakeColorReadableOnBlack(DWORD &rdwClr)
Definition: C4Gui.cpp:99
C4PlayerInfo * GetPlayerInfoByID(int32_t id) const
uint32_t ColorDw
Definition: C4Player.h:91
class C4TableGraph * pstatControls
Definition: C4Player.h:147
int32_t ID
Definition: C4Player.h:89
uint32_t GetColor() const
Definition: C4PlayerInfo.h:156
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73
const char * GetName() const
Definition: C4Player.h:153
void ClearGraphs()
Definition: C4Player.cpp:1616
void SetTitle(const char *szNewTitle)
std::unique_ptr< C4Network2Stats > pNetworkStatistics
Definition: C4Game.h:97
uint32_t DWORD
void SetColorDw(DWORD dwClr)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 43 of file C4InfoCore.cpp.

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().

44 {
45  *Comment='\0';
46  *RankName='\0';
47  TotalScore=0;
50  *LeagueName='\0';
54  Rank=0;
55  SCopy("Neuling",PrefName);
56  if (pRanks) SCopy(pRanks->GetRankName(Rank,false).getData(),RankName);
57  else SCopy("Rang",RankName);
58  PrefClonkSkin=0;
59  PrefColor=0;
60  PrefColorDw=0xff;
61  PrefColor2Dw=0;
63  PrefMouse=1;
67  ExtraData.Reset();
68 }
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:105
const char * getData() const
Definition: StdBuf.h:450
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:106
int32_t TotalPlayingTime
Definition: C4InfoCore.h:92
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
int32_t RoundsWon
Definition: C4InfoCore.h:91
int32_t OldPrefControl
Definition: C4InfoCore.h:104
void Clear()
Definition: StdBuf.h:474
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:86
int32_t PrefClonkSkin
Definition: C4InfoCore.h:101
char LeagueName[C4MaxName+1]
Definition: C4InfoCore.h:95
StdCopyStrBuf PrefControl
Definition: C4InfoCore.h:97
int32_t PrefMouse
Definition: C4InfoCore.h:98
C4ValueMapData ExtraData
Definition: C4InfoCore.h:94
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
int32_t RoundsLost
Definition: C4InfoCore.h:91
char Comment[C4MaxComment+1]
Definition: C4InfoCore.h:87
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:89
int32_t PrefColor
Definition: C4InfoCore.h:99
uint32_t PrefColorDw
Definition: C4InfoCore.h:100
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:100
int32_t TotalScore
Definition: C4InfoCore.h:90
int32_t Rounds
Definition: C4InfoCore.h:91
C4RoundResult LastRound
Definition: C4InfoCore.h:93

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::DefaultRuntimeData ( )

Definition at line 1208 of file C4Player.cpp.

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().

1209 {
1210  Status=0;
1211  Eliminated=0;
1212  Surrendered=0;
1214  SCopy("Local",AtClientName);
1215  ControlSet = nullptr;
1217  MouseControl=false;
1218  Position=-1;
1219  PlrStartIndex=0;
1220  RetireDelay=0;
1222  ViewX=ViewY=0;
1223  ViewTarget=nullptr;
1224  ShowStartup=true;
1225  Wealth=0;
1227  ObjectsOwned=0;
1229  Cursor=ViewCursor=nullptr;
1230  CursorFlash=30;
1231  MessageStatus=0;
1232  MessageBuf[0]=0;
1233  Hostility.clear();
1236  Knowledge.Default();
1237  FlashCom=0;
1238 }
int32_t MouseControl
Definition: C4Player.h:94
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
char AtClientName[C4MaxTitle+1]
Definition: C4Player.h:100
C4ObjectPtr Cursor
Definition: C4Player.h:132
int32_t ProductionDelay
Definition: C4Player.h:124
int32_t ViewMode
Definition: C4Player.h:107
int32_t FlashCom
Definition: C4Player.h:112
void Clear()
Definition: StdBuf.h:474
int32_t ObjectsOwned
Definition: C4Player.h:119
bool ShowStartup
Definition: C4Player.h:111
int32_t PlrStartIndex
Definition: C4Player.h:96
int32_t Position
Definition: C4Player.h:95
int32_t ProductionUnit
Definition: C4Player.h:124
char MessageBuf[256+1]
Definition: C4Player.h:137
int32_t CursorFlash
Definition: C4Player.h:133
class C4PlayerControlAssignmentSet * ControlSet
Definition: C4Player.h:92
void Default()
Definition: stub-handle.cpp:63
int32_t Status
Definition: C4Player.h:84
C4IDList Knowledge
Definition: C4Player.h:129
int32_t MessageStatus
Definition: C4Player.h:136
const int32_t C4ClientIDUnknown
Definition: C4Client.h:24
int32_t Surrendered
Definition: C4Player.h:86
int32_t Eliminated
Definition: C4Player.h:85
int32_t CurrentScore
Definition: C4Player.h:118
int32_t Wealth
Definition: C4Player.h:117
int32_t AtClient
Definition: C4Player.h:99
C4Real ViewY
Definition: C4Player.h:108
StdCopyStrBuf ControlSetName
Definition: C4Player.h:93
int32_t InitialScore
Definition: C4Player.h:118
int32_t RetireDelay
Definition: C4Player.h:97
C4Object * ViewTarget
Definition: C4Player.h:110
const int32_t C4PVM_Cursor
Definition: C4Player.h:33
C4ObjectPtr ViewCursor
Definition: C4Player.h:132
C4IDList BaseMaterial
Definition: C4Player.h:122
C4IDList BaseProduction
Definition: C4Player.h:123
C4Real ViewX
Definition: C4Player.h:108
HostilitySet Hostility
Definition: C4Player.h:120

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::DenumeratePointers ( )

Definition at line 1260 of file C4Player.cpp.

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

Referenced by LoadRuntimeData().

1261 {
1262  // Crew
1264  // Cursor
1266  // ViewCursor
1268  // messageboard-queries
1269  for (C4MessageBoardQuery *pCheck = pMsgBoardQuery; pCheck; pCheck = pCheck->pNext)
1270  pCheck->CallbackObj.DenumeratePointers();
1271 }
C4ObjectPtr Cursor
Definition: C4Player.h:132
bool DenumeratePointers()
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:46
C4ObjectList Crew
Definition: C4Player.h:127
C4MessageBoardQuery * pNext
C4ObjectPtr ViewCursor
Definition: C4Player.h:132
class C4MessageBoardQuery * pMsgBoardQuery
Definition: C4Player.h:138

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::DoScore ( int32_t  iChange)

Definition at line 1344 of file C4Player.cpp.

References CurrentScore.

1345 {
1346  CurrentScore = Clamp<int32_t>( CurrentScore+iChange, -100000, 100000 );
1347  return true;
1348 }
int32_t CurrentScore
Definition: C4Player.h:118
void C4Player::DoTeamSelection ( int32_t  idTeam)

Definition at line 1252 of file C4Player.cpp.

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

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

1253 {
1254  // stop team selection. This might close the menu forever if the control gets lost
1255  // let's hope it doesn't!
1258 }
C4PlayerControl Control
Definition: C4Player.h:131
int32_t Status
Definition: C4Player.h:84
static C4ControlPlayerAction * InitScenarioPlayer(const C4Player *source, int32_t team)
Definition: C4Control.cpp:615

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::DoWealth ( int32_t  change)

Definition at line 731 of file C4Player.cpp.

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

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

Here is the call graph for this function:

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

Definition at line 997 of file C4Player.cpp.

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

Referenced by C4MainMenu::DoRefillInternal().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::Eliminate ( )

Definition at line 1474 of file C4Player.cpp.

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().

1475 {
1476  if (Eliminated) return;
1477  Eliminated=true;
1479  StartSoundEffect("UI::Eliminated");
1480  Log(FormatString(LoadResStr("IDS_PRC_PLRELIMINATED"),GetName()).getData());
1481 
1482  // Early client deactivation check
1483  if (::Control.isCtrlHost() && AtClient > C4ClientIDHost && !::Application.isEditor)
1484  {
1485  // Check: Any player left at this client?
1486  C4Player *pPlr = nullptr;
1487  for (int i = 0; (pPlr = ::Players.GetAtClient(AtClient, i)); i++)
1488  if (!pPlr->Eliminated)
1489  break;
1490  // If not, deactivate the client
1491  if (!pPlr)
1492  ::Control.DoInput(CID_ClientUpdate,
1494  CDT_Sync);
1495  }
1496 }
const int C4RetireDelay
Definition: C4Constants.h:29
C4PlayerControl Control
Definition: C4Player.h:131
C4Player * GetAtClient(int iClient, int iIndex=0) const
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
C4PlayerList Players
int32_t Eliminated
Definition: C4Player.h:85
int32_t AtClient
Definition: C4Player.h:99
const char * GetName() const
Definition: C4Player.h:153
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
int32_t RetireDelay
Definition: C4Player.h:97
C4Application Application
Definition: C4Globals.cpp:44
const int32_t C4ClientIDHost
Definition: C4Client.h:25
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::Evaluate ( )

Definition at line 789 of file C4Player.cpp.

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().

790 {
791  // do not evaluate twice
792  if (Evaluated) return;
793 
794  const int32_t SuccessBonus=100;
795 
796  // Set last round
798  time(reinterpret_cast<time_t *>(&LastRound.Date));
801  // Melee: personal value gain score ...check ::Objects(C4D_Goal)
802  if (Game.C4S.Game.IsMelee()) LastRound.Score = std::max<int32_t>(CurrentScore-InitialScore,0);
803  // Cooperative: shared score
804  else LastRound.Score = std::max(::Players.AverageScoreGain(),0);
805  LastRound.Level = 0; // unknown...
806  LastRound.Bonus = SuccessBonus * LastRound.Won;
809 
810  // Update player
811  Rounds++;
812  if (LastRound.Won) RoundsWon++; else RoundsLost++;
815 
816  // Crew
818 
819  // league
820  if (Game.Parameters.isLeague())
822 
823  // Player is now evaluated
824  Evaluated = true;
825 
826  // round results
828 }
int32_t TotalScore
Definition: C4InfoCore.h:72
int32_t TotalPlayingTime
Definition: C4InfoCore.h:92
int32_t Won
Definition: C4InfoCore.h:71
int32_t Score
Definition: C4InfoCore.h:72
bool IsMelee()
Definition: C4Scenario.cpp:510
C4Game Game
Definition: C4Globals.cpp:52
int32_t RoundsWon
Definition: C4InfoCore.h:91
C4Scenario C4S
Definition: C4Game.h:76
int AverageScoreGain() const
StdCopyStrBuf ScenarioTitle
Definition: C4Game.h:105
C4GameParameters & Parameters
Definition: C4Game.h:69
int32_t RoundsLost
Definition: C4InfoCore.h:91
uint32_t Date
Definition: C4InfoCore.h:69
bool GameOver
Definition: C4Game.h:116
C4PlayerList Players
int32_t Time
Definition: C4Game.h:133
int32_t GameJoinTime
Definition: C4Player.h:98
bool Evaluated
Definition: C4Player.h:87
C4RoundResults & RoundResults
Definition: C4Game.h:75
int32_t Eliminated
Definition: C4Player.h:85
int32_t CurrentScore
Definition: C4Player.h:118
int32_t FinalScore
Definition: C4InfoCore.h:72
void EvaluateLeague(bool fDisconnected, bool fWon)
Definition: C4Player.cpp:1517
int32_t TotalScore
Definition: C4InfoCore.h:90
C4SGame Game
Definition: C4Scenario.h:232
void EvaluatePlayer(C4Player *pPlr)
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
int32_t InitialScore
Definition: C4Player.h:118
bool isLeague() const
int32_t Rounds
Definition: C4InfoCore.h:91
int32_t Duration
Definition: C4InfoCore.h:70
int32_t Level
Definition: C4InfoCore.h:74
int32_t Bonus
Definition: C4InfoCore.h:73
StdCopyStrBuf Title
Definition: C4InfoCore.h:68
C4RoundResult LastRound
Definition: C4InfoCore.h:93

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1517 of file C4Player.cpp.

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

Referenced by Evaluate().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::ExecBaseProduction ( )
protected

Definition at line 1155 of file C4Player.cpp.

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

Referenced by Execute().

1156 {
1157  const int32_t MaxBaseProduction = 25;
1158  ProductionDelay++;
1159  if (ProductionDelay>=60) // Minute Production Unit
1160  {
1162  for (int32_t cnt=0; BaseProduction.GetID(cnt); cnt++)
1163  if (BaseProduction.GetCount(cnt)>0)
1164  if (ProductionUnit % Clamp<int32_t>(11-BaseProduction.GetCount(cnt),1,10) ==0)
1165  if (BaseMaterial.GetIDCount(BaseProduction.GetID(cnt)) < MaxBaseProduction)
1167  }
1168 }
int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const
Definition: stub-handle.cpp:67
int32_t ProductionDelay
Definition: C4Player.h:124
int32_t GetCount(size_t index) const
Definition: C4IDList.cpp:111
int32_t ProductionUnit
Definition: C4Player.h:124
bool IncreaseIDCount(C4ID c_id, bool fAddNewID=true, int32_t IncreaseBy=1, bool fRemoveEmpty=false)
Definition: C4IDList.cpp:220
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
C4IDList BaseMaterial
Definition: C4Player.h:122
C4IDList BaseProduction
Definition: C4Player.h:123

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::Execute ( )

Definition at line 164 of file C4Player.cpp.

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().

165 {
166  if (!Status) return;
167 
168  // Open/refresh team menu if desired
170  {
171  int32_t idSelectedTeam;
172  if ((idSelectedTeam = Game.Teams.GetForcedTeamSelection(ID)))
173  {
174  // There's only one team left to join? Join there immediately.
175  if (Menu.IsActive() && Menu.GetIdentification() == C4MN_TeamSelection) Menu.TryClose(false, false);
176  if (LocalControl && !::Control.isReplay())
177  {
178  // team selection done through queue because TeamSelection-status may not be in sync (may be TeamSelectionPending!)
179  DoTeamSelection(idSelectedTeam);
180  }
181  }
182  else if (!Menu.IsActive()) ActivateMenuTeamSelection(false);
183  else
184  {
185  // during team selection: Update view to selected team, if it has a position assigned
186  C4MenuItem *pSelectedTeamItem;
187  if ((pSelectedTeamItem = Menu.GetSelectedItem()))
188  {
189  int32_t idSelectedTeam = atoi(pSelectedTeamItem->GetCommand()+8);
190  if (idSelectedTeam)
191  {
192  C4Team *pSelectedTeam;
193  if ((pSelectedTeam = Game.Teams.GetTeamByID(idSelectedTeam)))
194  {
195  int32_t iPlrStartIndex = pSelectedTeam->GetPlrStartIndex();
196  if (iPlrStartIndex && Inside<int32_t>(iPlrStartIndex, 1, C4S_MaxPlayer))
197  {
198  if (Game.C4S.PlrStart[iPlrStartIndex-1].Position[0] > -1)
199  {
200  // player has selected a team that has a valid start position assigned
201  // set view to this position!
202  ViewX = Game.C4S.PlrStart[iPlrStartIndex-1].Position[0] * ::Landscape.GetMapZoom();
203  ViewY = Game.C4S.PlrStart[iPlrStartIndex-1].Position[1] * ::Landscape.GetMapZoom();
204  }
205  }
206  }
207  }
208  }
209  }
210  }
212  {
213  Menu.TryClose(false, false);
214  }
215 
216  // Do we have a gamepad?
217  if (pGamepad)
218  {
219  // Check whether it's still connected.
220  if (!pGamepad->IsAttached())
221  {
222  // Allow the player to plug the gamepad back in. This allows
223  // battery replacement or plugging the controller back
224  // in after someone tripped over the wire.
225  if (!FindGamepad())
226  {
227  LogF("%s: No gamepad available.", Name.getData());
228  ::Game.Pause();
229  }
230  }
231  }
232  // Should we have one? The player may have started the game
233  // without turning their controller on, only noticing this
234  // after the game started.
235  else if (LocalControl && ControlSet && ControlSet->HasGamepad())
236  {
237  FindGamepad();
238  }
239 
240  // Tick1
241  UpdateView();
242  ExecuteControl();
243  Menu.Execute();
244 
245  // ::Game.iTick35
246  if (!::Game.iTick35 && Status==PS_Normal)
247  {
250  if (pMsgBoardQuery && LocalControl) ExecMsgBoardQueries();
251  }
252 
253  // Delays
254  if (MessageStatus>0) MessageStatus--;
255  if (RetireDelay>0) RetireDelay--;
256  if (CursorFlash>0) CursorFlash--;
257 }
const char * getData() const
Definition: StdBuf.h:450
C4MainMenu Menu
Definition: C4Player.h:105
C4Game Game
Definition: C4Globals.cpp:52
int32_t iTick35
Definition: C4Game.h:131
C4Scenario C4S
Definition: C4Game.h:76
Definition: C4Teams.h:30
void UpdateView()
Definition: C4Player.cpp:1182
const int C4S_MaxPlayer
Definition: C4Constants.h:53
C4PlayerControl Control
Definition: C4Player.h:131
C4Team * GetTeamByID(int32_t iID) const
Definition: C4Teams.cpp:384
StdStrBuf Name
Definition: C4Player.h:83
C4TeamList & Teams
Definition: C4Game.h:72
bool ActivateMenuTeamSelection(bool fFromMain)
Definition: C4Player.cpp:1240
std::shared_ptr< class C4GamePadOpener > pGamepad
Definition: C4Player.h:134
bool Pause()
Definition: C4Game.cpp:954
int32_t CursorFlash
Definition: C4Player.h:133
class C4PlayerControlAssignmentSet * ControlSet
Definition: C4Player.h:92
int32_t Status
Definition: C4Player.h:84
C4MenuItem * GetSelectedItem()
Definition: C4Menu.cpp:584
int32_t GetForcedTeamSelection(int32_t idForPlayer) const
Definition: C4Teams.cpp:851
C4Landscape Landscape
int32_t GetPlrStartIndex() const
Definition: C4Teams.h:69
int32_t MessageStatus
Definition: C4Player.h:136
int32_t GetIdentification()
Definition: C4Menu.cpp:613
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
bool IsActive()
Definition: C4Menu.cpp:481
void CheckElimination()
Definition: C4Player.cpp:1170
void DoTeamSelection(int32_t idTeam)
Definition: C4Player.cpp:1252
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:281
int32_t ID
Definition: C4Player.h:89
C4Real ViewY
Definition: C4Player.h:108
int32_t GetMapZoom() const
void Execute()
Definition: C4Menu.cpp:904
void ExecuteControl()
Definition: C4Player.cpp:1056
int32_t RetireDelay
Definition: C4Player.h:97
int32_t Position[2]
Definition: C4Scenario.h:143
const char * GetCommand() const
Definition: C4Menu.h:113
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
class C4MessageBoardQuery * pMsgBoardQuery
Definition: C4Player.h:138
void ExecBaseProduction()
Definition: C4Player.cpp:1155
bool LocalControl
Definition: C4Player.h:101
C4Real ViewX
Definition: C4Player.h:108

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::ExecuteControl ( )

Definition at line 1056 of file C4Player.cpp.

References Control, and C4PlayerControl::Execute().

Referenced by Execute().

1057 {
1058  Control.Execute();
1059 }
C4PlayerControl Control
Definition: C4Player.h:131

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::FinalInit ( bool  fInitialScore)

Definition at line 701 of file C4Player.cpp.

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

Referenced by C4Game::InitGameFinal(), C4Game::JoinPlayer(), and ScenarioAndTeamInit().

702 {
703  if (!Status) return true;
704 
705  // Init player's mouse control
706  if (LocalControl)
707  if (MouseControl)
708  ::MouseControl.Init(Number);
709 
710  // Set initial score
711  if (fInitialScore)
712  {
714  }
715 
716  // Cursor
717  if (!Cursor) AdjustCursorCommand();
718 
719  // Update counts, pointers, views
720  Execute();
721 
722  return true;
723 }
int32_t MouseControl
Definition: C4Player.h:94
C4ObjectPtr Cursor
Definition: C4Player.h:132
int32_t Number
Definition: C4Player.h:88
int32_t Status
Definition: C4Player.h:84
void Execute()
Definition: C4Player.cpp:164
int32_t CurrentScore
Definition: C4Player.h:118
int32_t InitialScore
Definition: C4Player.h:118
void AdjustCursorCommand()
Definition: C4Player.cpp:1061
bool LocalControl
Definition: C4Player.h:101

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4Player::FindNewOwner ( ) const

Definition at line 1281 of file C4Player.cpp.

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().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1908 of file C4Player.cpp.

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

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

Here is the call graph for this function:

C4Object * C4Player::GetHiExpActiveCrew ( )

Definition at line 869 of file C4Player.cpp.

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

Referenced by CheckCrewExPromotion().

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

Here is the caller graph for this function:

C4Object * C4Player::GetHiRankActiveCrew ( )

Definition at line 888 of file C4Player.cpp.

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

Referenced by AdjustCursorCommand(), and CheckCrewExPromotion().

889 {
890  C4Object *hirank=nullptr;
891  int32_t iHighestRank=-2, iRank;
892  for (C4Object *cobj : Crew)
893  {
894  if (!cobj->CrewDisabled)
895  {
896  if (cobj->Info) iRank = cobj->Info->Rank; else iRank=-1;
897  if (!hirank || (iRank>iHighestRank))
898  {
899  hirank=cobj;
900  iHighestRank=iRank;
901  }
902  }
903  }
904  return hirank;
905 }
C4ObjectInfo * Info
Definition: C4Object.h:145
C4ObjectList Crew
Definition: C4Player.h:127

Here is the caller graph for this function:

C4PlayerInfo * C4Player::GetInfo ( )

Definition at line 1553 of file C4Player.cpp.

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

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

1554 {
1556 }
C4Game Game
Definition: C4Globals.cpp:52
C4PlayerInfo * GetPlayerInfoByID(int32_t id) const
int32_t ID
Definition: C4Player.h:89
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73

Here is the call graph for this function:

Here is the caller graph for this function:

const char* C4Player::GetName ( ) const
inline

Definition at line 153 of file C4Player.h.

References StdStrBuf::getData().

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

153 { return Name.getData(); }
const char * getData() const
Definition: StdBuf.h:450
StdStrBuf Name
Definition: C4Player.h:83

Here is the call graph for this function:

Here is the caller graph for this function:

DWORD C4PlayerInfoCore::GetPrefColorValue ( int32_t  iPrefColor)
staticinherited

Definition at line 70 of file C4InfoCore.cpp.

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

71 {
72  DWORD valRGB[12] = { 0xFF0000E8, 0xFFF40000, 0xFF00C800, 0xFFFCF41C,
73  0xFFC48444, 0xFF784830, 0xFFA04400, 0xFFF08050,
74  0xFF848484, 0xFFFFFFFF, 0xFF0094F8, 0xFFBC00C0
75  };
76  if (Inside<int32_t>(iPrefColor, 0, 11))
77  return valRGB[iPrefColor];
78  return 0xFFAAAAAA;
79 }
uint32_t DWORD

Here is the caller graph for this function:

int32_t C4Player::GetSelectedCrewCount ( )

Definition at line 1510 of file C4Player.cpp.

References C4Object::CrewDisabled, and Cursor.

1511 {
1512  if (Cursor && !Cursor->CrewDisabled)
1513  return 1;
1514  return 0;
1515 }
C4ObjectPtr Cursor
Definition: C4Player.h:132
bool CrewDisabled
Definition: C4Object.h:163
C4PlayerType C4Player::GetType ( ) const

Definition at line 1728 of file C4Player.cpp.

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

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

1729 {
1730  // type by info
1732  if (pInfo) return pInfo->GetType(); else { assert(false); return C4PT_User; }
1733 }
C4Game Game
Definition: C4Globals.cpp:52
C4PlayerInfo * GetPlayerInfoByID(int32_t id) const
int32_t ID
Definition: C4Player.h:89
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73
C4PlayerType GetType() const
Definition: C4PlayerInfo.h:155

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::HasMessageBoardQuery ( )

Definition at line 1699 of file C4Player.cpp.

References pMsgBoardQuery.

1700 {
1701  // return whether any object has a messageboard-query
1702  return !!pMsgBoardQuery;
1703 }
class C4MessageBoardQuery * pMsgBoardQuery
Definition: C4Player.h:138
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 259 of file C4Player.cpp.

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().

261 {
262  // safety
263  if (!pInfo)
264  {
265  LogF("ERROR: Init player %s failed: No info!", szFilename);
266  assert(false);
267  return false;
268  }
269  // Status init
271  Number = iNumber;
272  ID = pInfo->GetID();
273  Team = pInfo->GetTeam();
274  NoEliminationCheck = pInfo->IsNoEliminationCheck();
275 
276  // At client
277  AtClient=iAtClient; SCopy(szAtClientName,AtClientName,C4MaxTitle);
278 
279  if (szFilename)
280  {
281  // Load core & crew info list
282  if (!Load(szFilename, !fScenarioInit)) return false;
283  }
284  else
285  {
286  // no core file present: Keep defaults
287  // This can happen for script players only
288  assert(pInfo->GetType() == C4PT_Script);
289  }
290 
291  // Take player name from player info; forcing overloads by the league or because of doubled player names
292  Name.Copy(pInfo->GetName());
293 
294  // view pos init: Start at center pos
296 
297  // Scenario init
298  if (fScenarioInit)
299  {
300  // mark player join in player info list
301  // for non-scenarioinit, player should already be marked as joined
302  pInfo->SetJoined(iNumber);
303 
304  // Number might have changed: Recheck list sorting before scenarioinit, which will do script calls
306 
307  // check for a postponed scenario init, if no team is specified (post-lobby-join in network, or simply non-network)
308  C4Team *pTeam = nullptr;
309  if (Team)
310  {
313  else
314  pTeam = Game.Teams.GetTeamByID(Team);
315  }
316  if (!pTeam && Game.Teams.IsRuntimeJoinTeamChoice())
317  {
318  if (pInfo->GetType() == C4PT_Script)
319  {
320  // script player without team: This can usually not happen, because RecheckPlayerInfoTeams should have been executed
321  // just leave this player without the team
322  assert(false);
323  }
324  else
325  {
326  // postponed init: Chose team first
328  }
329  }
330 
331  // Init control method before scenario init, because script callbacks may need to know it!
332  ClearControl();
333  InitControl();
334 
335  // defaultdisabled controls
336  Control.Init();
337 
338  // Special: Script players may skip scenario initialization altogether, and just desire a single callback to all objects
339  // of a given ID
340  if (!pInfo->IsScenarioInitDesired())
341  {
342  // only initialization that's done anyway is team hostility
343  if (Team) SetTeamHostility();
344  // callback definition passed?
345  C4ID idCallback = pInfo->GetScriptPlayerExtraID();
346  C4Def *pDefCallback;
347  if (idCallback && (pDefCallback = C4Id2Def(idCallback)))
348  {
350  }
351  }
352  else
353  {
354  // player preinit: In case a team needs to be chosen first, no InitializePlayer-broadcast is done
355  // this callback shall give scripters a chance to do stuff like starting an intro or enabling FoW, which might need to be done
357  // direct init
358  if (Status != PS_TeamSelection) if (!ScenarioInit()) return false;
359  }
360  }
361 
362  // Load runtime data
363  else
364  {
365  assert(pInfo->IsJoined());
366  assert(numbers);
367  // (compile using DefaultRuntimeData) - also check if compilation returned sane results, i.e. ID assigned
368  if (!LoadRuntimeData(Game.ScenarioFile, numbers) || !ID)
369  {
370  // for script players in non-savegames, this is OK - it means they get restored using default values
371  // this happens when the users saves a scenario using the "Save scenario"-option while a script player
372  // was joined
373  if (!Game.C4S.Head.SaveGame && pInfo->GetType() == C4PT_Script)
374  {
375  Number = pInfo->GetInGameNumber();
376  ColorDw = pInfo->GetColor();
377  ID = pInfo->GetID();
378  Team = pInfo->GetTeam();
379  }
380  else
381  return false;
382  }
383  // Reset values default-overriden by old runtime data load (safety?)
384  if (Number==C4P_Number_None) Number=iNumber;
385  if (szFilename) SCopy(Config.AtUserDataPath(szFilename),Filename); else *Filename='\0';
386  // NET2: Direct joins always send accurate client IDs and names in params
387  // do not overwrite them with savegame data, because players might as well
388  // change clients
389  // (only call should be savegame recreation by C4PlayerInfoList::RecreatePlayers)
390  AtClient = iAtClient;
391  SCopy(szAtClientName,AtClientName,C4MaxTitle);
392  // Number might have changed: Recheck list sorting
394  // Init control after loading runtime data, because control init will overwrite some of the values
395  InitControl();
396  }
397 
398  // store game joining time
400 
401  // Init FoW-viewobjects: NO_OWNER-FoW-repellers might need to be added
402  for (C4Object *pObj : Objects)
403  {
404  if ((pObj->lightRange || pObj->lightFadeoutRange) && pObj->Owner == NO_OWNER)
405  pObj->UpdateLight();
406  }
407 
408  // init graphs
410 
411  // init sound mod
413 
414  return true;
415 }
void RecheckPlayerSort(C4Player *pForPlayer)
C4Config Config
Definition: C4Config.cpp:837
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
const size_t C4MaxTitle
Definition: C4Constants.h:25
char AtClientName[C4MaxTitle+1]
Definition: C4Player.h:100
int32_t Team
Definition: C4Player.h:90
C4Game Game
Definition: C4Globals.cpp:52
int32_t Number
Definition: C4Player.h:88
C4Scenario C4S
Definition: C4Game.h:76
Definition: C4Teams.h:30
bool IsAutoGenerateTeams() const
Definition: C4Teams.h:173
char Filename[_MAX_PATH+1]
Definition: C4Player.h:82
void ClearControl()
Definition: C4Player.cpp:1375
C4Team * GetGenerateTeamByID(int32_t iID)
Definition: C4Teams.cpp:391
bool Load(const char *szFilename, bool fSavegame)
Definition: C4Player.cpp:939
C4PlayerControl Control
Definition: C4Player.h:131
C4Team * GetTeamByID(int32_t iID) const
Definition: C4Teams.cpp:384
StdStrBuf Name
Definition: C4Player.h:83
C4TeamList & Teams
Definition: C4Game.h:72
uint32_t ColorDw
Definition: C4Player.h:91
bool SaveGame
Definition: C4Scenario.h:71
const int32_t C4P_Number_None
Definition: C4Player.h:37
bool LoadRuntimeData(C4Group &hGroup, C4ValueNumbers *)
Definition: C4Player.cpp:1134
int32_t Status
Definition: C4Player.h:84
void CreateGraphs()
Definition: C4Player.cpp:1589
C4Landscape Landscape
C4Group ScenarioFile
Definition: C4Game.h:88
C4PlayerList Players
int32_t Time
Definition: C4Game.h:133
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars=0, bool fPassError=false, bool fRejectTest=false)
Definition: C4Game.cpp:3850
Definition: C4Def.h:100
const int NO_OWNER
Definition: C4Constants.h:138
int32_t GameJoinTime
Definition: C4Player.h:98
Definition: C4Id.h:28
C4Value SoundModifier
Definition: C4Player.h:142
bool ScenarioInit()
Definition: C4Player.cpp:603
int32_t AtClient
Definition: C4Player.h:99
bool NoEliminationCheck
Definition: C4Player.h:103
int32_t GetHeight() const
int32_t ID
Definition: C4Player.h:89
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
C4Real ViewY
Definition: C4Player.h:108
void SetTeamHostility()
Definition: C4Player.cpp:917
const char * AtUserDataPath(const char *szFilename)
Definition: C4Config.cpp:530
#define PSF_PreInitializePlayer
Definition: C4GameScript.h:42
void InitControl()
Definition: C4Player.cpp:1395
bool IsRuntimeJoinTeamChoice() const
Definition: C4Teams.h:174
C4SHead Head
Definition: C4Scenario.h:230
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112
std::unique_ptr< C4Network2Stats > pNetworkStatistics
Definition: C4Game.h:97
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
#define PSF_InitializeScriptPlayer
Definition: C4GameScript.h:41
void Copy()
Definition: StdBuf.h:475
int32_t GetWidth() const
void SetSoundModifier(C4PropList *new_modifier)
Definition: C4Player.cpp:1924
C4GameObjects Objects
Definition: C4Globals.cpp:48
C4Real ViewX
Definition: C4Player.h:108
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::InitControl ( )
protected

Definition at line 1395 of file C4Player.cpp.

References AtClient, C4PT_User, CDT_Queue, CID_PlrAction, Config, Control, ControlSet, ControlSetName, Game, C4ConfigGeneral::GamepadEnabled, C4Config::General, StdStrBuf::getData(), C4PlayerControlAssignmentSets::GetDefaultSet(), GetInfo(), C4PlayerControlAssignmentSets::GetSetByName(), C4PlayerInfo::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().

1396 {
1397  // Check local control
1398  if (AtClient == ::Control.ClientID())
1399  if (!GetInfo() || GetInfo()->GetType() == C4PT_User)
1400  if (!::Control.isReplay())
1401  LocalControl=true;
1402  // needs to init control for local players only
1403  if (LocalControl)
1404  {
1405  // Preferred control
1408  // control set unassigned/not known? fallback to some default then (=first defined control set)
1410  // gamepad control safety (assuming the default control set is not using gamepad)
1412  {
1414  }
1415  // Choose next while control taken
1416  // TODO
1417  // init gamepad
1418  if (ControlSet && ControlSet->HasGamepad())
1419  {
1420  if (!FindGamepad())
1421  {
1422  LogF("No gamepad available for %s, please plug one in!", Name.getData());
1423  ::Game.Pause();
1424  }
1425  }
1426  // Mouse
1427  if (ControlSet && ControlSet->HasMouse() && PrefMouse)
1428  if (!::Players.MouseControlTaken())
1429  MouseControl=true;
1430  // Some controls such as gamepad control need special synced GUI elements
1431  // Do a script callback for selected control
1433  }
1434  // clear old control method and register new
1436 }
const char * getData() const
Definition: StdBuf.h:450
class C4PlayerInfo * GetInfo()
Definition: C4Player.cpp:1553
int32_t MouseControl
Definition: C4Player.h:94
C4Config Config
Definition: C4Config.cpp:837
C4PlayerControlAssignmentSet * GetDefaultSet()
C4PlayerControlAssignmentSet * GetSetByName(const char *szName)
C4Game Game
Definition: C4Globals.cpp:52
int32_t Number
Definition: C4Player.h:88
C4ConfigGeneral General
Definition: C4Config.h:252
StdCopyStrBuf PrefControl
Definition: C4InfoCore.h:97
C4PlayerControl Control
Definition: C4Player.h:131
bool GamepadEnabled
Definition: C4Config.h:59
StdStrBuf Name
Definition: C4Player.h:83
int32_t PrefMouse
Definition: C4InfoCore.h:98
bool Pause()
Definition: C4Game.cpp:954
class C4PlayerControlAssignmentSet * ControlSet
Definition: C4Player.h:92
C4PlayerList Players
void RegisterKeyset(int32_t iPlr, C4PlayerControlAssignmentSet *pKeyset)
bool MouseControlTaken() const
static C4ControlPlayerAction * InitPlayerControl(const C4Player *source, const C4PlayerControlAssignmentSet *ctrl_set=nullptr)
Definition: C4Control.cpp:623
int32_t AtClient
Definition: C4Player.h:99
StdCopyStrBuf ControlSetName
Definition: C4Player.h:93
C4PlayerType GetType() const
Definition: C4PlayerInfo.h:155
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
C4PlayerControlAssignmentSets PlayerControlUserAssignmentSets
Definition: C4Game.h:95
bool LocalControl
Definition: C4Player.h:101

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::IsChosingTeam ( ) const
inline
bool C4Player::IsHostileTowards ( const C4Player opponent) const

Definition at line 862 of file C4Player.cpp.

References Hostility.

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

863 {
864  assert(plr);
865  if (!plr) return false;
866  return Hostility.find(plr) != Hostility.end();
867 }
HostilitySet Hostility
Definition: C4Player.h:120

Here is the caller graph for this function:

bool C4Player::IsInvisible ( ) const

Definition at line 1735 of file C4Player.cpp.

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

Referenced by C4MainMenu::DoRefillInternal().

1736 {
1737  // invisible by info
1739  if (pInfo) return pInfo->IsInvisible(); else { assert(false); return false; }
1740 }
C4Game Game
Definition: C4Globals.cpp:52
bool IsInvisible() const
Definition: C4PlayerInfo.h:178
C4PlayerInfo * GetPlayerInfoByID(int32_t id) const
int32_t ID
Definition: C4Player.h:89
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::IsViewLocked ( ) const
inline

Definition at line 206 of file C4Player.h.

References ViewLock.

Referenced by C4MouseControl::UpdateScrolling().

206 { return ViewLock; } // return if view is fixed to cursor, so scrolling is not allowed
bool ViewLock
Definition: C4Player.h:109

Here is the caller graph for this function:

bool C4PlayerInfoCore::Load ( C4Group hGroup)
inherited

Definition at line 81 of file C4InfoCore.cpp.

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().

82 {
83  // New version
84  StdStrBuf Source;
85  if (hGroup.LoadEntryString(C4CFN_PlayerInfoCore,&Source))
86  {
87  // Compile
88  StdStrBuf GrpName = hGroup.GetFullName(); GrpName.Append(DirSep C4CFN_PlayerInfoCore);
89  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, Source, GrpName.getData()))
90  return false;
91  // Pref for AutoContextMenus is still undecided: default by player's control style
92  if (OldPrefAutoContextMenu == -1)
94  // Determine true color from indexed pref color
95  if (!PrefColorDw)
97  // Validate colors
98  PrefColorDw &= 0xffffff;
99  PrefColor2Dw &= 0xffffff;
100  // Validate name
102  // Success
103  return true;
104  }
105 
106  // Old version no longer supported - sorry
107  return false;
108 }
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:105
const char * getData() const
Definition: StdBuf.h:450
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:106
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:86
static DWORD GetPrefColorValue(int32_t iPrefColor)
Definition: C4InfoCore.cpp:70
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
#define C4CFN_PlayerInfoCore
Definition: C4Components.h:45
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
int32_t PrefColor
Definition: C4InfoCore.h:99
uint32_t PrefColorDw
Definition: C4InfoCore.h:100
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:100
bool LoadEntryString(const char *szEntryName, StdStrBuf *Buf)
Definition: C4Group.cpp:1932
#define DirSep
static bool StripMarkup(char *szText)
Definition: C4Markup.cpp:113

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 939 of file C4Player.cpp.

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

Referenced by Init().

940 {
941  C4Group hGroup;
942  // Open group
943  if (!Reloc.Open(hGroup, szFilename)) return false;
944  // Remember filename
946  // Load core
947  if (!C4PlayerInfoCore::Load(hGroup))
948  { hGroup.Close(); return false; }
949  // Load BigIcon
950  if (hGroup.FindEntry(C4CFN_BigIcon)) BigIcon.Load(hGroup, C4CFN_BigIcon, C4FCT_Full, C4FCT_Full, false, 0);
951  // Load crew info list
952  CrewInfoList.Load(hGroup);
953  // Close group
954  hGroup.Close();
955  // Success
956  return true;
957 }
const char * getData() const
Definition: StdBuf.h:450
bool FindEntry(const char *szWildCard, StdStrBuf *sFileName=nullptr, size_t *iSize=nullptr)
Definition: C4Group.cpp:1774
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
int32_t Load(C4Group &hGroup)
bool Load(C4Group &hGroup, const char *szName, int iWdt, int iHgt, bool fNoErrIfNotFound, int iFlags)
Definition: C4FacetEx.cpp:78
char Filename[_MAX_PATH+1]
Definition: C4Player.h:82
#define _MAX_PATH
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:81
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
C4FacetSurface BigIcon
Definition: C4Player.h:140
bool Close()
Definition: C4Group.cpp:755
bool Open(C4Group &hGroup, const char *filename) const
Definition: C4Reloc.cpp:69
C4Reloc Reloc
Definition: C4Reloc.cpp:22
#define C4CFN_BigIcon
Definition: C4Components.h:111
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
const int C4FCT_Full
Definition: C4FacetEx.h:26

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1134 of file C4Player.cpp.

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

Referenced by Init().

1135 {
1136  const char *pSource;
1137  // Use loaded game text component
1138  if (!(pSource = Game.GameText.GetData())) return false;
1139  // safety: Do nothing if player section is not even present (could kill initialized values)
1140  if (!SSearch(pSource, FormatString("[Player%i]", ID).getData())) return false;
1141  // Compile (Search player section - runtime data is stored by unique player ID)
1142  // Always compile exact. Exact data will not be present for savegame load, so it does not matter
1143  assert(ID);
1144  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(
1145  mkNamingAdapt(mkParAdapt(*this, numbers), FormatString("Player%i", ID).getData()),
1146  StdStrBuf(pSource),
1148  return false;
1149  // Denumerate pointers
1151  // Success
1152  return true;
1153 }
const char * getData() const
Definition: StdBuf.h:450
C4Game Game
Definition: C4Globals.cpp:52
const char * GetData() const
C4ComponentHost GameText
Definition: C4Game.h:81
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:340
void DenumeratePointers()
Definition: C4Player.cpp:1260
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
int32_t ID
Definition: C4Player.h:89
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:459
const char * GetFilePath() const
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::LocalSync ( )

Definition at line 1532 of file C4Player.cpp.

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

1533 {
1534  // local sync not necessary for script players
1535  if (GetType() == C4PT_Script) return true;
1536  // evaluate total playing time
1539  // evaluate total playing time of all the crew
1540  for (C4ObjectInfo *pInf = CrewInfoList.GetFirst(); pInf; pInf=pInf->Next)
1541  if (pInf->InAction)
1542  {
1543  pInf->TotalPlayingTime+=(Game.Time-pInf->InActionTime);
1544  pInf->InActionTime = Game.Time;
1545  }
1546  // save player
1547  if (!Save())
1548  return false;
1549  // done, success
1550  return true;
1551 }
int32_t TotalPlayingTime
Definition: C4InfoCore.h:92
C4Game Game
Definition: C4Globals.cpp:52
C4ObjectInfo * Next
Definition: C4ObjectInfo.h:41
C4ObjectInfo * GetFirst()
int32_t Time
Definition: C4Game.h:133
int32_t GameJoinTime
Definition: C4Player.h:98
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
bool Save()
Definition: C4Player.cpp:417
C4PlayerType GetType() const
Definition: C4Player.cpp:1728

Here is the call graph for this function:

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

Definition at line 1010 of file C4Player.cpp.

References C4ObjectList::Add(), C4PropList::Call(), C4Object::Controller, 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, Number, PSF_OnJoinCrew, C4Object::SetLightRange(), C4Object::SetName(), C4PropList::Status, C4ObjectList::stNone, and C4Object::UpdateLight().

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

1011 {
1012  C4ObjectInfo *cInf = nullptr;
1013  if (!pObj || !pObj->Def->CrewMember || !pObj->Status) return false;
1014 
1015  // only if info is not yet assigned
1016  if (!pObj->Info && fForceInfo)
1017  {
1018  // Find crew info by name
1019  if (pObj->nInfo)
1020  cInf = CrewInfoList.GetIdle(pObj->nInfo.getData());
1021 
1022  // Find crew info by id
1023  if (!cInf)
1024  while (!( cInf = CrewInfoList.GetIdle(pObj->id,::Definitions) ))
1025  if (!CrewInfoList.New(pObj->id,&::Definitions))
1026  return false;
1027 
1028  // Set object info
1029  pObj->Info = cInf;
1030  pObj->SetName(cInf->Name);
1031  }
1032 
1033  // Add to crew
1034  if (!Crew.GetLink(pObj))
1035  Crew.Add(pObj, C4ObjectList::stNone);
1036 
1037  // add light
1038  if (!pObj->lightRange)
1039  pObj->SetLightRange(C4FOW_DefLightRangeX, C4FOW_DefLightFadeoutRangeX);
1040  else
1041  pObj->UpdateLight();
1042 
1043  // controlled by the player
1044  pObj->Controller = Number;
1045 
1046  // OnJoinCrew callback
1047  if (fDoCalls)
1048  {
1049  C4AulParSet parset(Number);
1050  pObj->Call(PSF_OnJoinCrew, &parset);
1051  }
1052 
1053  return true;
1054 }
const char * getData() const
Definition: StdBuf.h:450
void SetName(const char *NewName=0)
Definition: C4Object.cpp:1686
C4ID id
Definition: C4Object.h:108
virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted=nullptr)
int32_t Number
Definition: C4Player.h:88
#define PSF_OnJoinCrew
Definition: C4GameScript.h:93
C4ObjectInfo * Info
Definition: C4Object.h:145
const C4ObjectLink * GetLink(const C4Object *pObj) const
C4Def * Def
Definition: C4Object.h:143
int32_t lightRange
Definition: C4Object.h:122
char Name[C4MaxName+1]
Definition: C4InfoCore.h:38
int32_t Status
Definition: C4PropList.h:170
C4ObjectList Crew
Definition: C4Player.h:127
int32_t CrewMember
Definition: C4Def.h:114
StdCopyStrBuf nInfo
Definition: C4Object.h:168
bool SetLightRange(int32_t iToRange, int32_t iToFadeoutRange)
Definition: C4Object.cpp:4012
void UpdateLight()
Definition: C4Object.cpp:4035
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
C4DefList Definitions
Definition: C4Globals.cpp:49
C4ObjectInfo * New(C4ID n_id, C4DefList *pDefs)
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112
C4ObjectInfo * GetIdle(C4ID c_id, C4DefList &rDefs)
int32_t Controller
Definition: C4Object.h:111

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::MarkMessageBoardQueryAnswered ( C4Object pForObj)

Definition at line 1688 of file C4Player.cpp.

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

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

1689 {
1690  // get matching query
1692  while (pCheck) if (pCheck->CallbackObj == pForObj && !pCheck->fAnswered) break; else pCheck = pCheck->pNext;
1693  if (!pCheck) return false;
1694  // mark it
1695  pCheck->fAnswered = true;
1696  return true;
1697 }
C4ObjectPtr CallbackObj
C4MessageBoardQuery * pNext
class C4MessageBoardQuery * pMsgBoardQuery
Definition: C4Player.h:138

Here is the caller graph for this function:

bool C4Player::Message ( const char *  szMsg)

Definition at line 931 of file C4Player.cpp.

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

932 {
933  if (!szMsg) return false;
934  SCopy(szMsg,MessageBuf,256);
935  MessageStatus=SLen(szMsg)*2;
936  return true;
937 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
size_t SLen(const char *sptr)
Definition: Standard.h:78
char MessageBuf[256+1]
Definition: C4Player.h:137
int32_t MessageStatus
Definition: C4Player.h:136

Here is the call graph for this function:

void C4Player::NotifyOwnedObjects ( )

Definition at line 1313 of file C4Player.cpp.

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

Referenced by C4PlayerList::Remove().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::ObjectInCrew ( C4Object tobj)

Definition at line 92 of file C4Player.cpp.

References Crew.

Referenced by C4MouseControl::UpdateSingleSelection().

93 {
94  if (!tobj) return false;
95  for (C4Object *cobj : Crew)
96  if (cobj==tobj) return true;
97  return false;
98 }
C4ObjectList Crew
Definition: C4Player.h:127

Here is the caller graph for this function:

void C4Player::OnTeamSelectionFailed ( )

Definition at line 1705 of file C4Player.cpp.

References PS_TeamSelection, PS_TeamSelectionPending, and Status.

Referenced by ScenarioAndTeamInit().

1706 {
1707  // looks like a selected team was not available: Go back to team selection if this is not a mislead call
1710 }
int32_t Status
Definition: C4Player.h:84

Here is the caller graph for this function:

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

Definition at line 529 of file C4Player.cpp.

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().

530 {
531  int32_t cnt,cnt2,ctx,cty;
532  C4Def *def;
533  C4ID cid;
534  C4Object *cbase;
535  // Create ready base structures
536  for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyBase.GetID(cnt)); cnt++)
537  {
538  if ((def=C4Id2Def(cid)))
539  for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyBase.GetCount(cnt); cnt2++)
540  {
541  ctx=tx; cty=ty;
543  || FindConSiteSpot(ctx,cty,def->Shape.Wdt,def->Shape.Hgt,20))
544  if ((cbase=Game.CreateObjectConstruction(C4Id2Def(cid),nullptr,Number,ctx,cty,FullCon,true)))
545  {
546  // FirstBase
547  if (!(*pFirstBase)) if ((cbase->Def->Entrance.Wdt>0) && (cbase->Def->Entrance.Hgt>0))
548  { *pFirstBase=cbase; tx=(*pFirstBase)->GetX(); ty=(*pFirstBase)->GetY(); }
549  }
550  }
551  }
552 }
C4Object * CreateObjectConstruction(C4PropList *type, C4Object *pCreator, int32_t owner, int32_t ctx=0, int32_t bty=0, int32_t con=1, bool terrain=false)
Definition: C4Game.cpp:1106
int32_t EnforcePosition
Definition: C4Scenario.h:144
C4Game Game
Definition: C4Globals.cpp:52
int32_t Number
Definition: C4Player.h:88
C4Scenario C4S
Definition: C4Game.h:76
int32_t GetCount(size_t index) const
Definition: C4IDList.cpp:111
int32_t PlrStartIndex
Definition: C4Player.h:96
const int32_t FullCon
Definition: C4Constants.h:182
int32_t Wdt
Definition: C4Rect.h:32
C4Shape Shape
Definition: C4Def.h:106
C4Def * Def
Definition: C4Object.h:143
bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt, int32_t hrange)
int32_t GetX() const
Definition: C4Object.h:286
Definition: C4Def.h:100
Definition: C4Id.h:28
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
C4IDList ReadyBase
Definition: C4Scenario.h:146
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
C4Rect Entrance
Definition: C4Def.h:107
int32_t Hgt
Definition: C4Rect.h:32
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 481 of file C4Player.cpp.

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

Referenced by ScenarioInit().

482 {
483  int32_t cnt,ctx,cty;
484  C4Object *nobj;
485  C4ObjectInfo *pInfo;
486  C4Def *pDef;
487 
488  // Place crew
489  int32_t iCount;
490  C4ID id;
491  for (cnt=0; (id=Game.C4S.PlrStart[PlrStartIndex].ReadyCrew.GetID(cnt,&iCount)); cnt++)
492  {
493  // Minimum one clonk if empty id
494  iCount = std::max<int32_t>(iCount,1);
495 
496  for (int32_t cnt2=0; cnt2<iCount; cnt2++)
497  {
498  // Select member from home crew, add new if necessary
499  while (!(pInfo=CrewInfoList.GetIdle(id,::Definitions)))
500  if (!CrewInfoList.New(id,&::Definitions))
501  break;
502  // Safety
503  if (!pInfo || !(pDef=C4Id2Def(pInfo->id))) continue;
504  // Crew placement location
505  ctx=tx1+Random(tx2-tx1); cty=ty;
507  FindSolidGround(ctx,cty,pDef->Shape.Wdt*3);
508  // Create object
509  if ((nobj=Game.CreateInfoObject(pInfo,Number,ctx,cty)))
510  {
511  // Add object to crew
513  // add visibility range
514  nobj->SetLightRange(C4FOW_DefLightRangeX, C4FOW_DefLightFadeoutRangeX);
515  // If base is present, enter base
516  if (FirstBase) { nobj->Enter(FirstBase); nobj->SetCommand(C4CMD_Exit); }
517  // OnJoinCrew callback
518  {
519  C4DebugRecOff DbgRecOff{ !DEBUGREC_RECRUITMENT };
520  C4AulParSet parset(Number);
521  nobj->Call(PSF_OnJoinCrew, &parset);
522  }
523  }
524  }
525  }
526 
527 }
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1267
int32_t EnforcePosition
Definition: C4Scenario.h:144
uint32_t Random()
Definition: C4Random.cpp:43
virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted=nullptr)
C4Game Game
Definition: C4Globals.cpp:52
int32_t Number
Definition: C4Player.h:88
#define PSF_OnJoinCrew
Definition: C4GameScript.h:93
C4Scenario C4S
Definition: C4Game.h:76
C4IDList ReadyCrew
Definition: C4Scenario.h:145
int32_t PlrStartIndex
Definition: C4Player.h:96
int32_t Wdt
Definition: C4Rect.h:32
C4Shape Shape
Definition: C4Def.h:106
Definition: C4Def.h:100
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)
Definition: C4Object.cpp:2602
Definition: C4Id.h:28
C4ObjectList Crew
Definition: C4Player.h:127
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
bool SetLightRange(int32_t iToRange, int32_t iToFadeoutRange)
Definition: C4Object.cpp:4012
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
C4DefList Definitions
Definition: C4Globals.cpp:49
C4ObjectInfo * New(C4ID n_id, C4DefList *pDefs)
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
bool FindSolidGround(int32_t &rx, int32_t &ry, int32_t width)
C4ObjectInfo * GetIdle(C4ID c_id, C4DefList &rDefs)
constexpr bool DEBUGREC_RECRUITMENT
Definition: C4Include.h:36
C4Object * CreateInfoObject(C4ObjectInfo *cinf, int32_t owner, int32_t tx=50, int32_t ty=50)
Definition: C4Game.cpp:1090

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 575 of file C4Player.cpp.

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().

576 {
577  int32_t cnt,cnt2,ctx,cty;
578  C4Def *def; C4ID cid;
579 
580  // In base
581  if (FirstBase)
582  {
584  }
585 
586  // Outside
587  else
588  {
589  for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyMaterial.GetID(cnt)); cnt++)
590  {
591  if ((def=C4Id2Def(cid)))
592  for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyMaterial.GetCount(cnt); cnt2++)
593  {
594  ctx=tx1+Random(tx2-tx1); cty=ty;
596  FindSolidGround(ctx,cty,def->Shape.Wdt);
597  Game.CreateObject(cid,nullptr,Number,ctx,cty);
598  }
599  }
600  }
601 }
int32_t EnforcePosition
Definition: C4Scenario.h:144
uint32_t Random()
Definition: C4Random.cpp:43
C4Game Game
Definition: C4Globals.cpp:52
int32_t Number
Definition: C4Player.h:88
C4Scenario C4S
Definition: C4Game.h:76
bool CreateContentsByList(C4IDList &idlist)
Definition: C4Object.cpp:1451
int32_t GetCount(size_t index) const
Definition: C4IDList.cpp:111
int32_t PlrStartIndex
Definition: C4Player.h:96
int32_t Wdt
Definition: C4Rect.h:32
C4Shape Shape
Definition: C4Def.h:106
Definition: C4Def.h:100
Definition: C4Id.h:28
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
C4IDList ReadyMaterial
Definition: C4Scenario.h:148
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
bool FindSolidGround(int32_t &rx, int32_t &ry, int32_t width)
C4Object * CreateObject(C4PropList *type, C4Object *pCreator, 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 iController=NO_OWNER)
Definition: C4Game.cpp:1076

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 554 of file C4Player.cpp.

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().

555 {
556  int32_t cnt,cnt2,ctx,cty;
557  C4Def *def; C4ID cid; C4Object *cobj;
558  for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyVehic.GetID(cnt)); cnt++)
559  {
560  if ((def=C4Id2Def(cid)))
561  for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyVehic.GetCount(cnt); cnt2++)
562  {
563  ctx=tx1+Random(tx2-tx1); cty=ty;
565  FindLevelGround(ctx,cty,def->Shape.Wdt,6);
566  if ((cobj=Game.CreateObject(cid,nullptr,Number,ctx,cty)))
567  {
568  if (FirstBase) // First base overrides target location
569  { cobj->Enter(FirstBase); cobj->SetCommand(C4CMD_Exit); }
570  }
571  }
572  }
573 }
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1267
int32_t EnforcePosition
Definition: C4Scenario.h:144
uint32_t Random()
Definition: C4Random.cpp:43
C4Game Game
Definition: C4Globals.cpp:52
int32_t Number
Definition: C4Player.h:88
C4Scenario C4S
Definition: C4Game.h:76
int32_t GetCount(size_t index) const
Definition: C4IDList.cpp:111
int32_t PlrStartIndex
Definition: C4Player.h:96
int32_t Wdt
Definition: C4Rect.h:32
C4Shape Shape
Definition: C4Def.h:106
Definition: C4Def.h:100
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)
Definition: C4Object.cpp:2602
Definition: C4Id.h:28
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
C4IDList ReadyVehic
Definition: C4Scenario.h:147
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
bool FindLevelGround(int32_t &rx, int32_t &ry, int32_t width, int32_t hrange)
C4Object * CreateObject(C4PropList *type, C4Object *pCreator, 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 iController=NO_OWNER)
Definition: C4Game.cpp:1076

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 121 of file C4InfoCore.cpp.

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

Referenced by C4PlayerInfoCore::CheckPromotion().

122 {
123  Rank=iRank;
125 }
const char * getData() const
Definition: StdBuf.h:450
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:89
const unsigned int C4MaxName

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::RemoveCrewObjects ( )

Definition at line 1273 of file C4Player.cpp.

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

Referenced by C4PlayerList::Remove().

1274 {
1275  C4Object *pCrew;
1276 
1277  // Remove all crew objects
1278  while ((pCrew = Crew.GetObject())) pCrew->AssignRemoval(true);
1279 }
void AssignRemoval(bool fExitContents=false)
Definition: C4Object.cpp:257
C4Object * GetObject(int Index=0) const
C4ObjectList Crew
Definition: C4Player.h:127

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::RemoveMessageBoardQuery ( C4Object pForObj)

Definition at line 1675 of file C4Player.cpp.

References pMsgBoardQuery, and C4MessageBoardQuery::pNext.

Referenced by CallMessageBoard(), and ClearPointers().

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

Here is the caller graph for this function:

void C4Player::ResetCursorView ( bool  immediate_position = false)

Definition at line 782 of file C4Player.cpp.

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

Referenced by AdjustCursorCommand().

783 {
784  // reset view to cursor if any cursor exists
785  if (!ViewCursor && !Cursor) return;
786  SetViewMode(C4PVM_Cursor, nullptr, immediate_position);
787 }
C4ObjectPtr Cursor
Definition: C4Player.h:132
void SetViewMode(int32_t iMode, C4Object *pTarget=nullptr, bool immediate_position=false)
Definition: C4Player.cpp:769
const int32_t C4PVM_Cursor
Definition: C4Player.h:33
C4ObjectPtr ViewCursor
Definition: C4Player.h:132

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PlayerInfoCore::Save ( C4Group hGroup)
inherited

Definition at line 110 of file C4InfoCore.cpp.

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().

111 {
112  StdStrBuf Source, Name = hGroup.GetFullName(); Name.Append(DirSep C4CFN_PlayerInfoCore);
113  if (!DecompileToBuf_Log<StdCompilerINIWrite>(*this, &Source, Name.getData()))
114  return false;
115  if (!hGroup.Add(C4CFN_PlayerInfoCore,Source,false,true))
116  return false;
117  hGroup.Delete("C4Player.ocb");
118  return true;
119 }
const char * getData() const
Definition: StdBuf.h:450
bool Delete(const char *szFiles, bool fRecursive=false)
Definition: C4Group.cpp:1334
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
#define C4CFN_PlayerInfoCore
Definition: C4Components.h:45
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
bool Add(const char *szFile, const char *szAddAs)
Definition: C4Group.cpp:1316
#define DirSep

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Player::Save ( )

Definition at line 417 of file C4Player.cpp.

References _MAX_PATH, 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().

418 {
419  C4Group hGroup;
420  // Regular player saving need not be done for script players
421  if (GetType() == C4PT_Script) return false;
422  // Log
423  LogF(LoadResStr("IDS_PRC_SAVEPLR"), Config.AtRelativePath(Filename));
424  ::GraphicsSystem.MessageBoard->EnsureLastMessage();
425  // copy player to save somewhere else
426  char szPath[_MAX_PATH + 1];
428  MakeTempFilename(szPath);
429  // For local players, we save over the old player file, as there might
430  // be all kinds of non-essential stuff in it. For non-local players, we
431  // just re-create it every time (it's temporary anyway).
432  if (LocalControl)
433  {
434  // But make sure to copy it first so full hard (flgr stupid) disks
435  // won't corrupt any player files...
436  C4Group_CopyItem(Filename, szPath);
437  }
438  else
439  {
440  // For non-local players, we can actually use the loaded definition
441  // list to strip out all non-existant definitions. This is only valid
442  // because we know the file to be temporary.
444  }
445  // Open group
446  if (!hGroup.Open(szPath,true))
447  return false;
448  // Save
449  if (!Save(hGroup, false, !LocalControl))
450  { hGroup.Close(); return false; }
451  // Close group
452  if (!hGroup.Close()) return false;
453  // resource
455  pDRes = nullptr;
456  bool fOfficial = pRes && ::Control.isCtrlHost();
457  if (pRes) pDRes = pRes->Derive();
458  // move back
460  if (!C4Group_MoveItem(szPath, Filename)) return false;
461  // finish update
462  if (pDRes && fOfficial) pDRes->FinishDerive();
463  // Success
464  return true;
465 }
C4Config Config
Definition: C4Config.cpp:837
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
char Filename[_MAX_PATH+1]
Definition: C4Player.h:82
C4PlayerControl Control
Definition: C4Player.h:131
#define _MAX_PATH
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
bool C4Group_CopyItem(const char *szSource, const char *szTarget1, bool fNoSort, bool fResetAttributes)
Definition: C4Group.cpp:100
C4Network2Res::Ref Derive()
bool Close()
Definition: C4Group.cpp:755
C4Network2Res::Ref getRefRes(int32_t iResID)
C4Network2ResList ResList
Definition: C4Network2.h:113
bool C4Group_MoveItem(const char *szSource, const char *szTarget1, bool fNoSort)
Definition: C4Group.cpp:144
#define C4CFN_TempPlayer
Definition: C4Components.h:162
std::unique_ptr< C4MessageBoard > MessageBoard
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:819
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
C4DefList Definitions
Definition: C4Globals.cpp:49
bool Save()
Definition: C4Player.cpp:417
const char * AtTempPath(const char *szFilename)
Definition: C4Config.cpp:544
const char * AtRelativePath(const char *szFilename)
Definition: C4Config.cpp:660
void MakeTempFilename(char *szFilename)
Definition: StdFile.cpp:333
void Strip(C4DefList &rDefs)
bool ItemExists(const char *szItemName)
Definition: StdFile.h:75
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
bool LocalControl
Definition: C4Player.h:101
C4PlayerType GetType() const
Definition: C4Player.cpp:1728

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 467 of file C4Player.cpp.

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

468 {
469  // Save core
470  if (!C4PlayerInfoCore::Save(hGroup))
471  return false;
472  // Save crew
473  C4DefList *pDefs = &::Definitions;
474  if (!CrewInfoList.Save(hGroup, fSavegame, fStoreTiny, pDefs))
475  { hGroup.Close(); return false; }
476  // Sort
477  hGroup.Sort(C4FLS_Player);
478  return true;
479 }
bool Save(C4Group &hGroup)
Definition: C4InfoCore.cpp:110
bool Close()
Definition: C4Group.cpp:755
bool Save(C4Group &hGroup, bool fSavegame, bool fStoreTiny, C4DefList *pDefs)
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
#define C4FLS_Player
Definition: C4Components.h:193
C4DefList Definitions
Definition: C4Globals.cpp:49
bool Sort(const char *szSortList)
Definition: C4Group.cpp:1963

Here is the call graph for this function:

bool C4Player::ScenarioAndTeamInit ( int32_t  idTeam)

Definition at line 120 of file C4Player.cpp.

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

121 {
122  C4PlayerInfo *pInfo = GetInfo();
123  if (!pInfo) return false;
124  C4Team *pTeam;
125  if (idTeam == TEAMID_New)
126  {
127  // creation of a new team only if allowed by scenario
129  pTeam = nullptr;
130  else
131  {
132  if ((pTeam = Game.Teams.GetGenerateTeamByID(idTeam))) idTeam = pTeam->GetID();
133  }
134  }
135  else
136  {
137  // uage of an existing team
138  pTeam = Game.Teams.GetTeamByID(idTeam);
139  }
140  C4Team *pPrevTeam = Game.Teams.GetTeamByID(Team);
141  // check if join to team is possible; e.g. not too many players
142  if (pPrevTeam != pTeam && idTeam)
143  {
144  if (!Game.Teams.IsJoin2TeamAllowed(idTeam, pInfo->GetType()))
145  {
146  pTeam = nullptr;
147  }
148  }
149  if (!pTeam && idTeam)
150  {
152  return false;
153  }
154  // team selection OK; execute it!
155  if (pPrevTeam) pPrevTeam->RemovePlayerByID(pInfo->GetID());
156  if (pTeam) pTeam->AddPlayer(*pInfo, true);
157  if (!ScenarioInit()) return false;
158  if (!FinalInit(false)) return false;
159  // perform any pending InitializePlayers() callback
161  return true;
162 }
class C4PlayerInfo * GetInfo()
Definition: C4Player.cpp:1553
int32_t GetID() const
Definition: C4Teams.h:66
int32_t Team
Definition: C4Player.h:90
C4Game Game
Definition: C4Globals.cpp:52
Definition: C4Teams.h:30
bool IsAutoGenerateTeams() const
Definition: C4Teams.h:173
void OnPlayerJoinFinished()
Definition: C4Game.cpp:3084
C4Team * GetGenerateTeamByID(int32_t iID)
Definition: C4Teams.cpp:391
C4Team * GetTeamByID(int32_t iID) const
Definition: C4Teams.cpp:384
C4TeamList & Teams
Definition: C4Game.h:72
bool FinalInit(bool fInitialScore)
Definition: C4Player.cpp:701
void OnTeamSelectionFailed()
Definition: C4Player.cpp:1705
void AddPlayer(class C4PlayerInfo &rInfo, bool fAdjustPlayer)
Definition: C4Teams.cpp:53
const int32_t TEAMID_New
Definition: C4Teams.h:27
bool ScenarioInit()
Definition: C4Player.cpp:603
void RemovePlayerByID(int32_t iID)
Definition: C4Teams.cpp:95
int32_t GetID() const
Definition: C4PlayerInfo.h:197
C4PlayerType GetType() const
Definition: C4PlayerInfo.h:155
bool IsJoin2TeamAllowed(int32_t idTeam, C4PlayerType plrType)
Definition: C4Teams.cpp:535

Here is the call graph for this function:

bool C4Player::ScenarioInit ( )

Definition at line 603 of file C4Player.cpp.

References BaseMaterial, C4SPlrStart::BaseMaterial, BaseProduction, C4SPlrStart::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, C4Scenario::Landscape, Landscape, LogF(), C4SLandscape::MapZoom, Number, PlaceReadyBase(), PlaceReadyCrew(), PlaceReadyMaterial(), PlaceReadyVehic(), C4Game::PlayerInfos, Players, C4Scenario::PlrStart, PlrStartIndex, Position, C4SPlrStart::Position, C4PlayerList::PositionTaken(), PS_Normal, PSF_InitializePlayer, Random(), SetTeamHostility(), C4Game::StartupPlayerCount, Status, Team, C4Game::Teams, Wealth, and C4SPlrStart::Wealth.

Referenced by Init(), C4Game::InitGameFinal(), and ScenarioAndTeamInit().

604 {
605  int32_t ptx,pty;
606 
607  // player start index by team, if specified. Otherwise by player number
609  C4Team *pTeam; int32_t i;
610  if (Team && (pTeam = Game.Teams.GetTeamByID(Team))) if ((i=pTeam->GetPlrStartIndex())) PlrStartIndex=i-1;
611 
612  C4PlayerInfo *pInfo = GetInfo();
613  if (!pInfo) { assert(false); LogF("Internal error: ScenarioInit for ghost player %s!", GetName()); return false; }
614 
615  // set color by player info class
616  // re-setting, because runtime team choice may have altered color
617  ColorDw = pInfo->GetColor();
618 
619  // any team selection is over now
620  Status = PS_Normal;
621 
622  // Wealth, home base materials, abilities
630 
631  // Starting position
634 
635  // Zoomed position
636  if (ptx>-1) ptx = Clamp<int32_t>( ptx * Game.C4S.Landscape.MapZoom.Evaluate(), 0, ::Landscape.GetWidth()-1 );
637  if (pty>-1) pty = Clamp<int32_t>( pty * Game.C4S.Landscape.MapZoom.Evaluate(), 0, ::Landscape.GetHeight()-1 );
638 
639  // Standard position (PrefPosition)
640  if (ptx<0)
641  if (Game.StartupPlayerCount>=2)
642  {
643  int32_t iMaxPos=Game.StartupPlayerCount;
644  // Try to initialize PrefPosition using teams. This should put players of a team next to each other.
645  int PrefPosition = 0;
646  C4PlayerInfo *plr;
647  for (int i = 0; (plr = Game.PlayerInfos.GetPlayerInfoByIndex(i)) != nullptr; i++)
648  {
649  if (plr->GetTeam() < Team)
650  PrefPosition++;
651  }
652  // Map preferred position to available positions
653  int32_t iStartPos=Clamp(PrefPosition*iMaxPos/C4P_MaxPosition,0,iMaxPos-1);
654  int32_t iPosition=iStartPos;
655  // Distribute according to availability
656  while (::Players.PositionTaken(iPosition))
657  {
658  ++iPosition;
659  iPosition %= iMaxPos;
660  if (iPosition == iStartPos)
661  break;
662  }
663  Position=iPosition;
664  // Set x position
665  ptx=Clamp(16+Position*(::Landscape.GetWidth()-32)/(iMaxPos-1),0,::Landscape.GetWidth()-16);
666  }
667 
668  // All-random position
669  if (ptx<0) ptx=16+Random(::Landscape.GetWidth()-32);
670  if (pty<0) pty=16+Random(::Landscape.GetHeight()-32);
671 
672  // Place to solid ground
674  {
675  // Use nearest above-ground...
676  FindSolidGround(ptx,pty,30);
677  // Might have hit a small lake, or similar: Seach a real site spot from here
678  FindConSiteSpot(ptx, pty, 30, 50, 400);
679  }
680 
681  // Place Readies
682  C4Object *FirstBase = nullptr;
683  PlaceReadyBase(ptx,pty,&FirstBase);
684  PlaceReadyMaterial(ptx-10,ptx+10,pty,FirstBase);
685  PlaceReadyVehic(ptx-30,ptx+30,pty,FirstBase);
686  PlaceReadyCrew(ptx-30,ptx+30,pty,FirstBase);
687 
688  // set initial hostility by team info
689  if (Team) SetTeamHostility();
690 
691  // Scenario script initialization
693  ptx,
694  pty,
695  FirstBase,
696  Team,
697  C4Id2Def(GetInfo()->GetScriptPlayerExtraID())));
698  return true;
699 }
class C4PlayerInfo * GetInfo()
Definition: C4Player.cpp:1553
C4IDList BuildKnowledge
Definition: C4Scenario.h:149
bool ConsolidateValids(C4DefList &rDefs, int32_t dwCategory=0)
Definition: C4IDList.cpp:367
int32_t EnforcePosition
Definition: C4Scenario.h:144
int32_t Team
Definition: C4Player.h:90
uint32_t Random()
Definition: C4Random.cpp:43
C4Game Game
Definition: C4Globals.cpp:52
int32_t Number
Definition: C4Player.h:88
C4Scenario C4S
Definition: C4Game.h:76
C4IDList BaseProduction
Definition: C4Scenario.h:151
Definition: C4Teams.h:30
C4SLandscape Landscape
Definition: C4Scenario.h:234
C4PlayerInfo * GetPlayerInfoByIndex(int32_t index) const
const int C4S_MaxPlayer
Definition: C4Constants.h:53
int32_t PlrStartIndex
Definition: C4Player.h:96
C4Team * GetTeamByID(int32_t iID) const
Definition: C4Teams.cpp:384
int32_t Position
Definition: C4Player.h:95
C4TeamList & Teams
Definition: C4Game.h:72
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:46
uint32_t ColorDw
Definition: C4Player.h:91
C4SVal MapZoom
Definition: C4Scenario.h:176
bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt, int32_t hrange)
int32_t Status
Definition: C4Player.h:84
C4IDList Knowledge
Definition: C4Player.h:129
C4SVal Wealth
Definition: C4Scenario.h:142
C4Landscape Landscape
C4PlayerList Players
int32_t GetTeam() const
Definition: C4PlayerInfo.h:198
int32_t GetPlrStartIndex() const
Definition: C4Teams.h:69
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars=0, bool fPassError=false, bool fRejectTest=false)
Definition: C4Game.cpp:3850
void PlaceReadyCrew(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
Definition: C4Player.cpp:481
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
void PlaceReadyBase(int32_t &tx, int32_t &ty, C4Object **pFirstBase)
Definition: C4Player.cpp:529
bool PositionTaken(int iPosition) const
int32_t Wealth
Definition: C4Player.h:117
int32_t GetHeight() const
uint32_t GetColor() const
Definition: C4PlayerInfo.h:156
int32_t StartupPlayerCount
Definition: C4Game.h:111
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
const char * GetName() const
Definition: C4Player.h:153
void SetTeamHostility()
Definition: C4Player.cpp:917
const int C4P_MaxPosition
Definition: C4Constants.h:63
int32_t Position[2]
Definition: C4Scenario.h:143
void PlaceReadyVehic(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
Definition: C4Player.cpp:554
C4DefList Definitions
Definition: C4Globals.cpp:49
#define PSF_InitializePlayer
Definition: C4GameScript.h:40
C4IDList BaseMaterial
Definition: C4Player.h:122
bool FindSolidGround(int32_t &rx, int32_t &ry, int32_t width)
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
int32_t Evaluate()
Definition: C4Scenario.cpp:50
int32_t GetWidth() const
void PlaceReadyMaterial(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
Definition: C4Player.cpp:575
C4IDList BaseProduction
Definition: C4Player.h:123
C4IDList BaseMaterial
Definition: C4Scenario.h:150

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1366 of file C4Player.cpp.

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

Referenced by C4MouseControl::ScrollView().

1367 {
1368  if (ViewLock) return;
1370  float ViewportScrollBorder = Application.isEditor ? 0 : C4ViewportScrollBorder;
1371  ViewX = Clamp<C4Real>( ViewX+ftofix(iX), ftofix(ViewWdt/2.0f-ViewportScrollBorder), ftofix(::Landscape.GetWidth()+ViewportScrollBorder-ViewWdt/2.0f) );
1372  ViewY = Clamp<C4Real>( ViewY+ftofix(iY), ftofix(ViewHgt/2.0f-ViewportScrollBorder), ftofix(::Landscape.GetHeight()+ViewportScrollBorder-ViewHgt/2.0f) );
1373 }
const int32_t C4PVM_Scrolling
Definition: C4Player.h:35
bool ViewLock
Definition: C4Player.h:109
const int C4ViewportScrollBorder
Definition: C4Constants.h:65
C4Landscape Landscape
void SetViewMode(int32_t iMode, C4Object *pTarget=nullptr, bool immediate_position=false)
Definition: C4Player.cpp:769
C4Fixed ftofix(float x)
Definition: C4Real.h:258
int32_t GetHeight() const
C4Real ViewY
Definition: C4Player.h:108
C4Application Application
Definition: C4Globals.cpp:44
int32_t GetWidth() const
C4Real ViewX
Definition: C4Player.h:108

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1350 of file C4Player.cpp.

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

Referenced by AdjustCursorCommand().

1351 {
1352  // check disabled
1353  if (pObj) if (pObj->CrewDisabled) return;
1354  bool fChanged = pObj != Cursor;
1355  C4Object *pPrev = Cursor;
1356  // Set cursor
1357  Cursor=pObj;
1358  // unselect previous
1359  if (pPrev && fChanged) pPrev->UnSelect();
1360  // Select object
1361  if (fChanged && Cursor) { Cursor->DoSelect(); }
1362  // View flash
1363  if (fSelectArrow) CursorFlash=30;
1364 }
bool DoSelect()
Definition: C4Object.cpp:4316
C4ObjectPtr Cursor
Definition: C4Player.h:132
int32_t CursorFlash
Definition: C4Player.h:133
bool CrewDisabled
Definition: C4Object.h:163
void UnSelect()
Definition: C4Object.cpp:4326

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::SetFoW ( bool  fEnable)

Definition at line 725 of file C4Player.cpp.

References fFogOfWar.

726 {
727  // set flag
728  fFogOfWar = fEnable;
729 }
bool fFogOfWar
Definition: C4Player.h:113
bool C4Player::SetHostility ( int32_t  iOpponent,
int32_t  iHostility,
bool  fSilent = false 
)

Definition at line 840 of file C4Player.cpp.

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

Referenced by SetTeamHostility().

841 {
842  assert(hostile == 0 || hostile == 1);
843  // Check opponent valid
844  C4Player *opponent = ::Players.Get(iOpponent);
845  if (!opponent || opponent == this)
846  return false;
847  // Set hostility
848  if (hostile)
849  Hostility.insert(opponent);
850  else
851  Hostility.erase(opponent);
852  // no announce in first frame, or if specified
853  if (!Game.FrameCounter || fSilent) return true;
854  // Announce
855  StartSoundEffect("UI::Trumpet");
856  Log(FormatString(LoadResStr(hostile ? "IDS_PLR_HOSTILITY" : "IDS_PLR_NOHOSTILITY"),
857  GetName(),opponent->GetName()).getData());
858  // Success
859  return true;
860 }
C4Game Game
Definition: C4Globals.cpp:52
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
C4Player * Get(int iPlayer) const
int32_t FrameCounter
Definition: C4Game.h:130
C4PlayerList Players
const char * GetName() const
Definition: C4Player.h:153
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277
HostilitySet Hostility
Definition: C4Player.h:120

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 754 of file C4Player.cpp.

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

755 {
756  if (fRemove)
757  {
758  long iIndex = Knowledge.GetIndex(id);
759  if (iIndex<0) return false;
760  return Knowledge.DeleteItem(iIndex);
761  }
762  else
763  {
764  if (!C4Id2Def(id)) return false;
765  return Knowledge.SetIDCount(id, 1, true);
766  }
767 }
C4IDList Knowledge
Definition: C4Player.h:129
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
bool SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID=false)
Definition: stub-handle.cpp:68
bool DeleteItem(size_t iIndex)
Definition: C4IDList.cpp:423
int32_t GetIndex(C4ID c_id) const
Definition: C4IDList.cpp:202

Here is the call graph for this function:

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

Definition at line 1831 of file C4Player.cpp.

References ZoomLimitMaxVal, and ZoomLimitsToViewports().

1832 {
1833  AdjustZoomParameter(&ZoomLimitMaxVal, zoom, no_increase, no_decrease);
1835 }
void ZoomLimitsToViewports()
Definition: C4Player.cpp:1853
C4Real ZoomLimitMaxVal
Definition: C4Player.h:115

Here is the call graph for this function:

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

Definition at line 1812 of file C4Player.cpp.

References ZoomLimitMaxHgt, ZoomLimitMaxWdt, and ZoomLimitsToViewports().

1813 {
1814  AdjustZoomParameter(&ZoomLimitMaxWdt, range_wdt, no_increase, no_decrease);
1815  AdjustZoomParameter(&ZoomLimitMaxHgt, range_hgt, no_increase, no_decrease);
1817 }
void ZoomLimitsToViewports()
Definition: C4Player.cpp:1853
int32_t ZoomLimitMaxWdt
Definition: C4Player.h:114
int32_t ZoomLimitMaxHgt
Definition: C4Player.h:114

Here is the call graph for this function:

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

Definition at line 1825 of file C4Player.cpp.

References ZoomLimitMinVal, and ZoomLimitsToViewports().

1826 {
1827  AdjustZoomParameter(&ZoomLimitMinVal, zoom, no_increase, no_decrease);
1829 }
void ZoomLimitsToViewports()
Definition: C4Player.cpp:1853
C4Real ZoomLimitMinVal
Definition: C4Player.h:115

Here is the call graph for this function:

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

Definition at line 1805 of file C4Player.cpp.

References ZoomLimitMinHgt, ZoomLimitMinWdt, and ZoomLimitsToViewports().

1806 {
1807  AdjustZoomParameter(&ZoomLimitMinWdt, range_wdt, no_increase, no_decrease);
1808  AdjustZoomParameter(&ZoomLimitMinHgt, range_hgt, no_increase, no_decrease);
1810 }
int32_t ZoomLimitMinHgt
Definition: C4Player.h:114
void ZoomLimitsToViewports()
Definition: C4Player.cpp:1853
int32_t ZoomLimitMinWdt
Definition: C4Player.h:114

Here is the call graph for this function:

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

Definition at line 1558 of file C4Player.cpp.

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

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

Here is the call graph for this function:

void C4Player::SetPlayerColor ( uint32_t  dwNewClr)

Definition at line 1712 of file C4Player.cpp.

References ColorDw, Number, and Objects.

Referenced by C4Team::AddPlayer().

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

Here is the caller graph for this function:

void C4Player::SetSoundModifier ( C4PropList new_modifier)

Definition at line 1924 of file C4Player.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::SetTeamHostility ( )

Definition at line 917 of file C4Player.cpp.

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

Referenced by Init(), and ScenarioInit().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Player::SetViewLocked ( bool  to_val)

Definition at line 1899 of file C4Player.cpp.

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

1900 {
1901  if ((ViewLock = to_val))
1902  {
1903  // view was locked - cancel any scrolling
1905  }
1906 }
const int32_t C4PVM_Scrolling
Definition: C4Player.h:35
bool ViewLock
Definition: C4Player.h:109
int32_t ViewMode
Definition: C4Player.h:107
void SetViewMode(int32_t iMode, C4Object *pTarget=nullptr, bool immediate_position=false)
Definition: C4Player.cpp:769
const int32_t C4PVM_Cursor
Definition: C4Player.h:33

Here is the call graph for this function:

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