OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4InfoCore.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Structures for object and player info components */
19 
20 #ifndef INC_C4InfoCore
21 #define INC_C4InfoCore
22 
23 #include "object/C4Id.h"
24 #include "script/C4ValueMap.h"
25 #include "lib/C4Real.h"
26 #include "lib/C4InputValidation.h"
28 
29 const int32_t C4MaxPhysical = 100000,
31 
33 {
34 public:
36 public:
38  char Name[C4MaxName+1];
39  int32_t Participation;
40  int32_t Rank;
43  int32_t NextRankExp; // EXP_NoPromotion for no more promotion; 0 if standard rank system is used
44  int32_t Experience,Rounds;
45  int32_t DeathCount;
46  char TypeName[C4MaxName+1+1];
48  int32_t Age;
51 public:
52  bool Save(C4Group &hGroup, class C4DefList *pDefs);
53  bool Load(C4Group &hGroup);
54  void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=nullptr, const char *cpNames=nullptr);
55  void Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName);
56  bool GetNextRankInfo(C4RankSystem &rDefaultRanks, int32_t *piNextRankExp, StdStrBuf *psNextRankName);
57  void CompileFunc(StdCompiler *pComp);
58 protected:
59  bool Compile(const char *szSource);
60  bool Decompile(char **ppOutput, size_t *ipSize);
61 
62  void UpdateCustomRanks(C4DefList *pDefs); // sets NextRankName and NextRankExp
63 };
64 
66 {
67 public:
69  uint32_t Date = 0;
70  int32_t Duration = 0;
71  int32_t Won = 0;
72  int32_t Score = 0, FinalScore = 0, TotalScore = 0;
73  int32_t Bonus = 0;
74  int32_t Level = 0;
75 public:
76  void Default();
77  void CompileFunc(StdCompiler *pComp);
78 };
79 
81 {
82 public:
84 public:
85  // Player Info
88  int32_t Rank;
90  int32_t TotalScore;
96  // Preferences
97  StdCopyStrBuf PrefControl; // name of control set from definition file
98  int32_t PrefMouse;
99  int32_t PrefColor;
101  int32_t PrefClonkSkin;
102  // Old control method - loaded for backwards compatilibity if PrefControl is unassigned
103  // and stored back so you can use the same player file for CR and OC
104  int32_t OldPrefControl;
107 
108  // achievements indexed by achievement name and scenario
110 public:
111  void Default(C4RankSystem *pRanks=nullptr);
112  void Promote(int32_t iRank, C4RankSystem &rRanks);
113  bool Load(C4Group &hGroup);
114  bool Save(C4Group &hGroup);
115  bool CheckPromotion(C4RankSystem &rRanks);
116  static DWORD GetPrefColorValue(int32_t iPrefColor);
117  void CompileFunc(StdCompiler *pComp);
118 };
119 
120 #endif
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:105
const int32_t C4MaxPhysical
Definition: C4InfoCore.h:29
bool GetNextRankInfo(C4RankSystem &rDefaultRanks, int32_t *piNextRankExp, StdStrBuf *psNextRankName)
Definition: C4InfoCore.cpp:265
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:106
int32_t TotalScore
Definition: C4InfoCore.h:72
int32_t TotalPlayingTime
Definition: C4InfoCore.h:92
int32_t Rounds
Definition: C4InfoCore.h:44
void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=nullptr, const char *cpNames=nullptr)
Definition: C4InfoCore.cpp:184
int32_t Won
Definition: C4InfoCore.h:71
int32_t Score
Definition: C4InfoCore.h:72
int32_t RoundsWon
Definition: C4InfoCore.h:91
int32_t OldPrefControl
Definition: C4InfoCore.h:104
bool Decompile(char **ppOutput, size_t *ipSize)
Definition: C4InfoCore.cpp:350
bool Save(C4Group &hGroup, class C4DefList *pDefs)
Definition: C4InfoCore.cpp:300
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
StdStrBuf sRankName
Definition: C4InfoCore.h:41
char DeathMessage[C4MaxDeathMsg+1]
Definition: C4InfoCore.h:49
int32_t Participation
Definition: C4InfoCore.h:39
int32_t PrefMouse
Definition: C4InfoCore.h:98
C4ValueMapData ExtraData
Definition: C4InfoCore.h:94
int32_t RoundsLost
Definition: C4InfoCore.h:91
int32_t TotalPlayingTime
Definition: C4InfoCore.h:47
char Comment[C4MaxComment+1]
Definition: C4InfoCore.h:87
static DWORD GetPrefColorValue(int32_t iPrefColor)
Definition: C4InfoCore.cpp:70
const unsigned int C4MaxComment
int32_t NextRankExp
Definition: C4InfoCore.h:43
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:81
uint32_t Date
Definition: C4InfoCore.h:69
void Default(C4RankSystem *pRanks=nullptr)
Definition: C4InfoCore.cpp:43
bool Save(C4Group &hGroup)
Definition: C4InfoCore.cpp:110
const int32_t C4MaxDeathMsg
Definition: C4InfoCore.h:30
static const C4ID None
Definition: C4Id.h:42
C4ValueMapData ExtraData
Definition: C4InfoCore.h:50
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:89
int32_t Birthday
Definition: C4InfoCore.h:47
const unsigned int C4MaxName
char Name[C4MaxName+1]
Definition: C4InfoCore.h:38
void UpdateCustomRanks(C4DefList *pDefs)
Definition: C4InfoCore.cpp:234
void CompileFunc(StdCompiler *pComp)
Definition: C4InfoCore.cpp:375
int32_t PrefColor
Definition: C4InfoCore.h:99
bool CheckPromotion(C4RankSystem &rRanks)
Definition: C4InfoCore.cpp:127
uint32_t PrefColorDw
Definition: C4InfoCore.h:100
Definition: C4Id.h:28
StdStrBuf sNextRankName
Definition: C4InfoCore.h:42
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:100
void CompileFunc(StdCompiler *pComp)
Definition: C4InfoCore.cpp:137
int32_t FinalScore
Definition: C4InfoCore.h:72
void Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName)
Definition: C4InfoCore.cpp:226
int32_t TotalScore
Definition: C4InfoCore.h:90
void CompileFunc(StdCompiler *pComp)
Definition: C4InfoCore.cpp:312
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:293
int32_t Experience
Definition: C4InfoCore.h:44
bool Compile(const char *szSource)
Definition: C4InfoCore.cpp:339
int32_t Rounds
Definition: C4InfoCore.h:91
void Promote(int32_t iRank, C4RankSystem &rRanks)
Definition: C4InfoCore.cpp:121
uint32_t DWORD
int32_t DeathCount
Definition: C4InfoCore.h:45
int32_t Duration
Definition: C4InfoCore.h:70
int32_t Level
Definition: C4InfoCore.h:74
C4ScenarioParameters Achievements
Definition: C4InfoCore.h:109
int32_t Bonus
Definition: C4InfoCore.h:73
char TypeName[C4MaxName+1+1]
Definition: C4InfoCore.h:46
StdCopyStrBuf Title
Definition: C4InfoCore.h:68
C4RoundResult LastRound
Definition: C4InfoCore.h:93