OpenClonk
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 "lib/C4InputValidation.h"
24 #include "object/C4Id.h"
26 #include "script/C4ValueMap.h"
27 
28 const int32_t C4MaxPhysical = 100000,
30 
32 {
33 public:
35 public:
37  char Name[C4MaxName+1];
38  int32_t Participation;
39  int32_t Rank;
42  int32_t NextRankExp; // EXP_NoPromotion for no more promotion; 0 if standard rank system is used
43  int32_t Experience,Rounds;
44  int32_t DeathCount;
45  char TypeName[C4MaxName+1+1];
47  int32_t Age;
50 public:
51  bool Save(C4Group &hGroup, class C4DefList *pDefs);
52  bool Load(C4Group &hGroup);
53  void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=nullptr, const char *cpNames=nullptr);
54  void Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName);
55  bool GetNextRankInfo(C4RankSystem &rDefaultRanks, int32_t *piNextRankExp, StdStrBuf *psNextRankName);
56  void CompileFunc(StdCompiler *pComp);
57 protected:
58  bool Compile(const char *szSource);
59  bool Decompile(StdStrBuf &Buf);
60 
61  void UpdateCustomRanks(C4DefList *pDefs); // sets NextRankName and NextRankExp
62 };
63 
65 {
66 public:
68  uint32_t Date = 0;
69  int32_t Duration = 0;
70  int32_t Won = 0;
71  int32_t Score = 0, FinalScore = 0, TotalScore = 0;
72  int32_t Bonus = 0;
73  int32_t Level = 0;
74 public:
75  void Default();
76  void CompileFunc(StdCompiler *pComp);
77 };
78 
80 {
81 public:
83 public:
84  // Player Info
87  int32_t Rank;
89  int32_t TotalScore;
95  // Preferences
96  StdCopyStrBuf PrefControl; // name of control set from definition file
97  int32_t PrefMouse;
98  int32_t PrefColor;
100  int32_t PrefClonkSkin;
101  // Old control method - loaded for backwards compatilibity if PrefControl is unassigned
102  // and stored back so you can use the same player file for CR and OC
103  int32_t OldPrefControl;
106 
107  // achievements indexed by achievement name and scenario
109 public:
110  void Default(C4RankSystem *pRanks=nullptr);
111  void Promote(int32_t iRank, C4RankSystem &rRanks);
112  bool Load(C4Group &hGroup);
113  bool Save(C4Group &hGroup);
114  bool CheckPromotion(C4RankSystem &rRanks);
115  static DWORD GetPrefColorValue(int32_t iPrefColor);
116  void CompileFunc(StdCompiler *pComp);
117 };
118 
119 #endif
const int32_t C4MaxDeathMsg
Definition: C4InfoCore.h:29
const int32_t C4MaxPhysical
Definition: C4InfoCore.h:28
const unsigned int C4MaxComment
const unsigned int C4MaxName
uint32_t DWORD
Definition: C4Id.h:26
static const C4ID None
Definition: C4Id.h:39
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:336
int32_t DeathCount
Definition: C4InfoCore.h:44
int32_t TotalPlayingTime
Definition: C4InfoCore.h:46
void Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName)
Definition: C4InfoCore.cpp:252
char Name[C4MaxName+1]
Definition: C4InfoCore.h:37
void UpdateCustomRanks(C4DefList *pDefs)
Definition: C4InfoCore.cpp:263
bool Compile(const char *szSource)
Definition: C4InfoCore.cpp:389
int32_t NextRankExp
Definition: C4InfoCore.h:42
int32_t Birthday
Definition: C4InfoCore.h:46
StdStrBuf sNextRankName
Definition: C4InfoCore.h:41
int32_t Participation
Definition: C4InfoCore.h:38
int32_t Rounds
Definition: C4InfoCore.h:43
bool Save(C4Group &hGroup, class C4DefList *pDefs)
Definition: C4InfoCore.cpp:343
char TypeName[C4MaxName+1+1]
Definition: C4InfoCore.h:45
void CompileFunc(StdCompiler *pComp)
Definition: C4InfoCore.cpp:362
char DeathMessage[C4MaxDeathMsg+1]
Definition: C4InfoCore.h:48
StdStrBuf sRankName
Definition: C4InfoCore.h:40
int32_t Experience
Definition: C4InfoCore.h:43
C4ValueMapData ExtraData
Definition: C4InfoCore.h:49
bool GetNextRankInfo(C4RankSystem &rDefaultRanks, int32_t *piNextRankExp, StdStrBuf *psNextRankName)
Definition: C4InfoCore.cpp:297
void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=nullptr, const char *cpNames=nullptr)
Definition: C4InfoCore.cpp:201
bool Decompile(StdStrBuf &Buf)
Definition: C4InfoCore.cpp:403
char Comment[C4MaxComment+1]
Definition: C4InfoCore.h:86
StdCopyStrBuf PrefControl
Definition: C4InfoCore.h:96
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:104
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:88
void Promote(int32_t iRank, C4RankSystem &rRanks)
Definition: C4InfoCore.cpp:139
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:99
static DWORD GetPrefColorValue(int32_t iPrefColor)
Definition: C4InfoCore.cpp:75
int32_t RoundsWon
Definition: C4InfoCore.h:90
int32_t PrefColor
Definition: C4InfoCore.h:98
char LeagueName[C4MaxName+1]
Definition: C4InfoCore.h:94
int32_t TotalPlayingTime
Definition: C4InfoCore.h:91
int32_t Rounds
Definition: C4InfoCore.h:90
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:105
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:88
int32_t RoundsLost
Definition: C4InfoCore.h:90
void Default(C4RankSystem *pRanks=nullptr)
Definition: C4InfoCore.cpp:40
void CompileFunc(StdCompiler *pComp)
Definition: C4InfoCore.cpp:155
C4RoundResult LastRound
Definition: C4InfoCore.h:92
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:85
int32_t PrefClonkSkin
Definition: C4InfoCore.h:100
uint32_t PrefColorDw
Definition: C4InfoCore.h:99
int32_t TotalScore
Definition: C4InfoCore.h:89
int32_t PrefMouse
Definition: C4InfoCore.h:97
bool CheckPromotion(C4RankSystem &rRanks)
Definition: C4InfoCore.cpp:145
bool Save(C4Group &hGroup)
Definition: C4InfoCore.cpp:124
C4ValueMapData ExtraData
Definition: C4InfoCore.h:93
int32_t OldPrefControl
Definition: C4InfoCore.h:103
C4ScenarioParameters Achievements
Definition: C4InfoCore.h:108
uint32_t Date
Definition: C4InfoCore.h:68
int32_t Bonus
Definition: C4InfoCore.h:72
int32_t Duration
Definition: C4InfoCore.h:69
int32_t FinalScore
Definition: C4InfoCore.h:71
int32_t TotalScore
Definition: C4InfoCore.h:71
int32_t Level
Definition: C4InfoCore.h:73
int32_t Score
Definition: C4InfoCore.h:71
int32_t Won
Definition: C4InfoCore.h:70
void CompileFunc(StdCompiler *pComp)
Definition: C4InfoCore.cpp:423
StdCopyStrBuf Title
Definition: C4InfoCore.h:67