Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
collect_server.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "inexor/gamemode/collect_common.hpp" // for collectmode_co...
3 #include "inexor/gamemode/gamemode.hpp" // for isteam
4 #include "inexor/network/legacy/buffer_types.hpp" // for packetbuf (ptr...
5 #include "inexor/server/client_management.hpp" // for clientinfo
6 #include "inexor/server/gamemode/gamemode_server.hpp" // for servmode
7 #include "inexor/util/legacy_time.hpp" // for curtime, gamem...
8 
9 struct vec;
10 
11 namespace server {
12 
14 {
15  token &droptoken(const vec &o, int yaw, int team, int droptime, int dropper);
16  bool notgotbases = false;
17 
18  void reset(bool empty)
19  {
20  resetbases();
21  notgotbases = !empty;
22  }
23 
24  void cleanup() override
25  {
26  reset(false);
27  }
28 
29  void setup() override;
30 
31  void newmap() override
32  {
33  reset(true);
34  }
35 
36 #if 0
37  void losetokens(clientinfo *ci)
38  {
39  if(notgotbases || ci->state.tokens <= 0) return;
40  sendf(-1, 1, "ri2", N_LOSETOKENS, ci->clientnum);
41  ci->state.tokens = 0;
42  }
43 #endif
44 
45  void droptokens(clientinfo *ci, bool penalty = false);
46 
47  void leavegame(clientinfo *ci, bool disconnecting = false) override;
48 
49  void died(clientinfo *ci, clientinfo *actor) override
50  {
51  droptokens(ci, !actor || isteam(actor->team, ci->team));
52  }
53 
54  bool canspawn(clientinfo *ci, bool connecting) override
55  {
56  return connecting || !ci->state.lastdeath || gamemillis+curtime-ci->state.lastdeath >= RESPAWNSECS*1000;
57  }
58 
59  bool canchangeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
60  {
61  return collectteambase(newteam) > 0;
62  }
63 
64  void changeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
65  {
66  }
67 
68  void deposittokens(clientinfo *ci, int basenum);
69 
70  void taketoken(clientinfo *ci, int id);
71 
72  void update() override;
73 
74  void initclient(clientinfo *ci, packetbuf &p, bool connecting) override;
75 
76  void parsebases(ucharbuf &p, bool commit);
77 
78  bool parse_network_message(int type, clientinfo *ci, clientinfo *cq, packetbuf &p) override;
79 };
80 
81 
82 
83 } // ns server
Definition: client_management.hpp:217
template implementation of buffers (networking e.g.).
Definition: buffer_types.hpp:14
Definition: collect_server.hpp:13
void initclient(clientinfo *ci, packetbuf &p, bool connecting) override
Definition: collect_server.cpp:161
int lastdeath
Definition: client_management.hpp:93
void droptokens(clientinfo *ci, bool penalty=false)
Definition: collect_server.cpp:40
void leavegame(clientinfo *ci, bool disconnecting=false) override
Definition: collect_server.cpp:74
#define isteam(a, b)
Definition: gamemode.hpp:105
token & droptoken(const vec &o, int yaw, int team, int droptime, int dropper)
Definition: collect_server.cpp:19
bool canchangeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
Definition: collect_server.hpp:59
void reset(bool empty)
Definition: collect_server.hpp:18
#define collectteambase(s)
Definition: collect_common.hpp:10
void update() override
Definition: collect_server.cpp:145
string team
Definition: client_management.hpp:220
void changeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
Definition: collect_server.hpp:64
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
int clientnum
Definition: client_management.hpp:219
bool parse_network_message(int type, clientinfo *ci, clientinfo *cq, packetbuf &p) override
process gamemode specific network messages.
Definition: collect_server.cpp:202
static const int RESPAWNSECS
Definition: collect_common.hpp:24
void died(clientinfo *ci, clientinfo *actor) override
Definition: collect_server.hpp:49
int curtime
Definition: legacy_time.cpp:14
void cleanup() override
Definition: collect_server.hpp:24
gamestate state
Definition: client_management.hpp:227
void parsebases(ucharbuf &p, bool commit)
Definition: collect_server.cpp:183
network packet buffer
Definition: buffer_types.hpp:132
Definition: gamemode_server.hpp:24
ENetPacket * sendf(int cn, int chan, const char *format,...)
Definition: network_send.cpp:33
void newmap() override
Definition: collect_server.hpp:31
bool notgotbases
Definition: collect_server.hpp:16
int tokens
Definition: client_management.hpp:96
void setup() override
Definition: collect_server.cpp:28
void taketoken(clientinfo *ci, int id)
Definition: collect_server.cpp:136
void resetbases()
Definition: collect_common.hpp:74
void deposittokens(clientinfo *ci, int basenum)
Definition: collect_server.cpp:106
bool canspawn(clientinfo *ci, bool connecting) override
Definition: collect_server.hpp:54
int gamemillis
Definition: legacy_time.cpp:15
Definition: collect_common.hpp:14
Definition: collect_common.hpp:51