OpenClonk
C4RankSystem.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) 2013-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 /* Rank list for players or crew members */
19 
20 #ifndef INC_C4RankSystem
21 #define INC_C4RankSystem
22 
23 #include "lib/C4InputValidation.h"
24 
26 {
27 public:
28  C4RankSystem();
30 
31  enum { EXP_NoPromotion = -1 }; // experience value for NextRankExp: No more promotion possible
32 
33 protected:
34  char Register[256+1];
36  int RankBase;
37  char **pszRankNames{nullptr}; // loaded rank names for non-registry ranks
38  char *szRankNames{nullptr}; // loaded rank-name buffer
39  int iRankNum; // number of ranks for loaded rank-names
40  char **pszRankExtensions{nullptr}; // rank extensions (e.g. "%s First class") for even more ranks!
41  int iRankExtNum; // number of rank extensions
42 public:
43  void Default();
44  void Clear();
45  int Init(const char *szRegister, const char *szDefRanks, int iRankBase);
46  bool Load(C4Group &hGroup, const char *szFilenames, int DefRankBase, const char *szLanguage); // init based on nk file in group
47  int Experience(int iRank);
48  int RankByExperience(int iExp); // get rank by experience
49  StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver);
50  bool Check(int iRank, const char *szDefRankName);
51  int32_t GetExtendedRankNum() const { return iRankExtNum; }
52  int32_t GetBaseRankNum() const { return iRankNum; }
53  static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=nullptr); // create facet from rank symbol for definition - use custom rank facets if present
54 };
55 
57 
58 #endif
const unsigned int C4MaxName
C4RankSystem DefaultRanks
int32_t GetBaseRankNum() const
Definition: C4RankSystem.h:52
static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=nullptr)
char * szRankNames
Definition: C4RankSystem.h:38
int Init(const char *szRegister, const char *szDefRanks, int iRankBase)
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
char ** pszRankNames
Definition: C4RankSystem.h:37
int RankByExperience(int iExp)
char RankName[C4MaxName+1]
Definition: C4RankSystem.h:35
int Experience(int iRank)
int32_t GetExtendedRankNum() const
Definition: C4RankSystem.h:51
char Register[256+1]
Definition: C4RankSystem.h:34
char ** pszRankExtensions
Definition: C4RankSystem.h:40
bool Check(int iRank, const char *szDefRankName)
bool Load(C4Group &hGroup, const char *szFilenames, int DefRankBase, const char *szLanguage)