Extract cvar recorder to own inc

This commit is contained in:
Jackz 2022-07-06 19:42:38 -05:00
parent bd6526f85d
commit 57e922f1bc
No known key found for this signature in database
GPG key ID: E0BBD94CF657F603
2 changed files with 75 additions and 39 deletions

View file

@ -40,50 +40,15 @@ bool FindSpawnPosition(float pos[3], bool includePlayers = true) {
return false;
}
static char buffer[64];
methodmap GameConVar < ConVar {
public GameConVar(const char[] name) {
return view_as<GameConVar>(FindConVar(name));
}
public void RecordInt(int value, bool record = false) {
if(record) {
this.GetName(buffer, sizeof(buffer));
previousCvarValues.SetValue(buffer, float(value));
}
this.IntValue = value;
}
public void RecordFloat(float value, bool record = false) {
if(record) {
this.GetName(buffer, sizeof(buffer));
previousCvarValues.SetValue(buffer, value);
}
this.FloatValue = value;
}
public void RecordString(const char[] value, bool record = false) {
if(record) {
char prevValue[32];
this.GetName(buffer, sizeof(buffer));
this.GetString(prevValue, sizeof(prevValue));
previousCvarValues.SetString(buffer, prevValue);
}
this.SetString(value);
}
}
static char buffer[128];
methodmap GuessWhoGame {
property int Seeker {
public get() {
if(currentSeeker > 0 && IsClientConnected(currentSeeker)) {
return currentSeeker;
} else {
return this._FindSeeker();
}
if(currentSeeker <= 0 || !IsClientConnected(currentSeeker))
currentSeeker = this._FindSeeker();
return currentSeeker;
}
public set(int client) {
for(int i = 1; i <= MaxClients; i++) {
@ -258,6 +223,13 @@ methodmap GuessWhoGame {
}
}
public void SetPoints(MovePoints points) {
if(movePoints != null) {
delete movePoints;
}
movePoints = points;
}
// Ignores seeker
property int AlivePlayers {
public get() {