File: PlayerBase.cpp

package info (click to toggle)
spring 104.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 47,512 kB
  • sloc: cpp: 391,093; ansic: 79,943; python: 12,356; java: 12,201; awk: 5,889; sh: 1,826; xml: 655; makefile: 486; perl: 405; php: 211; objc: 194; sed: 2
file content (51 lines) | stat: -rw-r--r-- 1,120 bytes parent folder | download | duplicates (3)
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
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#include "PlayerBase.h"

#include <cstdlib>
#include "System/creg/STL_Map.h"


CR_BIND_DERIVED(PlayerBase,TeamController, )
CR_REG_METADATA(PlayerBase, (
	CR_MEMBER(rank),
	CR_MEMBER(countryCode),
	CR_MEMBER(spectator),
	CR_MEMBER(isFromDemo),
	CR_MEMBER(readyToStart),
	CR_MEMBER(desynced),
	CR_MEMBER(cpuUsage),
	CR_MEMBER(customValues)
))



PlayerBase::PlayerBase() :
	TeamController(),
	rank(-1),
	cpuUsage (0.0f),
	spectator(false),
	isFromDemo(false),
	readyToStart(false),
	desynced(false)
{
}

void PlayerBase::SetValue(const std::string& key, const std::string& value)
{
	if (key == "team") {
		team = std::atoi(value.c_str());
	} else if (key == "name") {
		name = value;
	} else if (key == "rank") {
		rank = std::atoi(value.c_str());
	} else if (key == "countrycode") {
		countryCode = value;
	} else if (key == "spectator") {
		spectator = static_cast<bool>(std::atoi(value.c_str()));
	} else if (key == "isfromdemo") {
		isFromDemo = static_cast<bool>(std::atoi(value.c_str()));
	} else {
		customValues[key] = value;
	}
}