File: Player.h

package info (click to toggle)
spring 0.81.2.1%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,496 kB
  • ctags: 37,096
  • sloc: cpp: 238,659; ansic: 13,784; java: 12,175; awk: 3,428; python: 1,159; xml: 738; perl: 405; sh: 297; makefile: 267; pascal: 228; objc: 192
file content (89 lines) | stat: -rw-r--r-- 1,700 bytes parent folder | download
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
#ifndef PLAYER_H
#define PLAYER_H
// Player.h: interface for the CPlayer class.
//
//////////////////////////////////////////////////////////////////////

#include <string>
#include <set>

#include "creg/creg_cond.h"
#include "PlayerBase.h"
#include "PlayerStatistics.h"
#include "float3.h"

class CPlayer;
class CUnit;
struct DirectControlStruct {
	bool forward;
	bool back;
	bool left;
	bool right;
	bool mouse1;
	bool mouse2;

	float3 viewDir;
	float3 targetPos;
	float targetDist;
	CUnit* target;
	CPlayer* myController;
};

struct DirectControlClientState {
	DirectControlClientState() {
		oldPitch   = 0;
		oldHeading = 0;
		oldState   = 255;
		oldDCpos   = ZeroVector;
	}

	void SendStateUpdate(bool*);

	CUnit* playerControlledUnit; //! synced
	short oldHeading, oldPitch;  //! unsynced
	unsigned char oldState;      //! unsynced
	float3 oldDCpos;             //! unsynced

	// todo: relocate the CUnit* from GlobalUnsynced
	// to here as well so everything is in one place
};


class CPlayer : public PlayerBase
{
public:
	CR_DECLARE(CPlayer);
	CPlayer();
	~CPlayer();

	bool CanControlTeam(int teamID) const {
		return (controlledTeams.find(teamID) != controlledTeams.end());
	}
	void SetControlledTeams();
	static void UpdateControlledTeams(); // SetControlledTeams() for all players

	void StartSpectating();
	void GameFrame(int frameNum);

	void operator=(const PlayerBase& base) { PlayerBase::operator=(base); };

	bool active;

	int playerNum;

	int ping;

	typedef PlayerStatistics Statistics;

	Statistics currentStats;

	DirectControlStruct myControl;
	DirectControlClientState dccs;

	void StopControllingUnit();

private:
	std::set<int> controlledTeams;
};

#endif /* PLAYER_H */