OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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; // loaded rank names for non-registry ranks
38  char *szRankNames; // loaded rank-name buffer
39  int iRankNum; // number of ranks for loaded rank-names
40  char **pszRankExtensions; // 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
bool Load(C4Group &hGroup, const char *szFilenames, int DefRankBase, const char *szLanguage)
char ** pszRankExtensions
Definition: C4RankSystem.h:40
char RankName[C4MaxName+1]
Definition: C4RankSystem.h:35
int32_t GetBaseRankNum() const
Definition: C4RankSystem.h:52
char Register[256+1]
Definition: C4RankSystem.h:34
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
char * szRankNames
Definition: C4RankSystem.h:38
static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=nullptr)
const unsigned int C4MaxName
C4RankSystem DefaultRanks
int Init(const char *szRegister, const char *szDefRanks, int iRankBase)
bool Check(int iRank, const char *szDefRankName)
int RankByExperience(int iExp)
int32_t GetExtendedRankNum() const
Definition: C4RankSystem.h:51
char ** pszRankNames
Definition: C4RankSystem.h:37
int Experience(int iRank)