-
Notifications
You must be signed in to change notification settings - Fork 0
/
CRank.h
143 lines (120 loc) · 3.31 KB
/
CRank.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// CSX Module
//
#ifndef CRANK_H
#define CRANK_H
#define RANK_VERSION 11
#include "amxxmodule.h"
// *****************************************************
// class Stats
// *****************************************************
struct Stats {
int hits;
int shots;
int damage;
int hs;
int tks;
int kills;
int deaths;
int bodyHits[9]; ////////////////////
// SiDLuke start
int bPlants;
int bExplosions;
int bDefusions;
int bDefused;
// SiDLuke end :D
Stats();
void commit(Stats* a);
};
// *****************************************************
// class RankSystem
// *****************************************************
class RankSystem
{
public:
class RankStats;
friend class RankStats;
class iterator;
class RankStats : public Stats {
friend class RankSystem;
friend class iterator;
RankSystem* parent;
RankStats* next;
RankStats* prev;
char* unique;
short int uniquelen;
char* name;
short int namelen;
int score;
int id;
RankStats( const char* uu, const char* nn, RankSystem* pp );
~RankStats();
void setUnique( const char* nn );
inline void goDown() {++id;}
inline void goUp() {--id;}
inline void addStats(Stats* a) { commit( a ); }
public:
void setName( const char* nn );
inline const char* getName() const { return name ? name : ""; }
inline const char* getUnique() const { return unique ? unique : ""; }
inline int getPosition() const { return id; }
inline void updatePosition( Stats* points ) {
parent->updatePos( this , points );
}
inline void deletePosition() {
parent->deletePos( this );
}
};
private:
RankStats* head;
RankStats* tail;
int rankNum;
struct scoreCalc{
AMX amx;
void* code;
int func;
cell amxAddr1;
cell amxAddr2;
cell *physAddr1;
cell *physAddr2;
} calc;
void put_before( RankStats* a, RankStats* ptr );
void put_after( RankStats* a, RankStats* ptr );
void unlink( RankStats* ptr );
void updatePos( RankStats* r , Stats* s );
void deletePos( RankStats* r );
public:
RankSystem();
~RankSystem();
void saveRank( const char* filename );
void loadRank( const char* filename );
RankStats* findEntryInRank(const char* unique, const char* name, bool isip=false);
RankStats* newEntryInRank(const char* unique, const char* name);
bool loadCalc(const char* filename, char* error, size_t maxLength);
inline int getRankNum( ) const { return rankNum; }
void clear();
void unloadCalc();
class iterator {
RankStats* ptr;
public:
iterator() {}
iterator(RankStats* a): ptr(a){}
inline iterator& operator++() { ptr = ptr->next; return *this; }
inline iterator& operator--() { ptr = ptr->prev; return *this;}
inline RankStats& operator*() { return *ptr;}operator bool () { return (ptr != 0); }
iterator subs( const iterator& it, int a );
iterator add( const iterator& it , int a );
void setEntryByRank( const int rank );
};
inline iterator front() { return iterator(head); }
inline iterator begin() { return iterator(tail); }
};
#endif