/
Server.hpp
73 lines (61 loc) · 1.39 KB
/
Server.hpp
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
#ifndef SERVER_HPP
#define SERVER_HPP
#include <vector>
#include "Unit.hpp"
#include <string>
#include "ClientInfo.hpp"
#include "Item.hpp"
#include "IDMap.hpp"
#include "Area.hpp"
#include "Bullet.hpp"
#include "BotInformation.hpp"
#include "physics.hpp"
const int SERVER_PORT = 56125;
const double DEFENCE_TIME = 60;
struct DataWriter;
struct Server {
Server();
~Server();
void loop();
void updatePhysics(double t);
void initSocket();
void pollConnections();
void readInputs();
void sendState();
void sendToAll(const void* s, int n);
void sendToAll(DataWriter& w);
void updateBullets(double t);
void updateBases();
void damageUnit(int i, double d,int shooter,Bullet b);
void spawnUnits(double t);
void genSpawnCounts();
void spawnClient(ClientInfo& c);
void sendStats();
volatile bool end;
std::vector<Unit> units;
std::vector<ClientInfo*> clients;
std::vector<Bullet> bullets;
IDMap<Item> items_map;
std::vector<BotInformation*> botinfos;
int sockfd;
int nextID;
Area area;
int* clID;
double spawnTime;
double defenceTime;
int curSpawn;
int botID;
bool win;
int spawnCounts[32][64]; // [type][base]
int itemSpawns[32][64];
int enemyCounts[32];
double unitMove;
double flowSpawnTime;
std::vector<int> kills;
std::vector<int> deaths;
std::vector<int> teamkills;
std::string name[320];
std::vector<int> unitID;
PhysicsContext pc;
};
#endif