Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
capture_server.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "inexor/gamemode/capture_common.hpp" // for capturemode_co...
3 #include "inexor/gamemode/gamemode.hpp" // for m_regencapture
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/shared/ents.hpp" // for ::CS_ALIVE
8 #include "inexor/shared/geom.hpp" // for vec
9 #include "inexor/util/legacy_time.hpp" // for curtime, gamem...
10 
11 namespace server {
12 
14 {
15  bool notgotbases = false;
16 
17  void reset(bool empty)
18  {
19  resetbases();
20  notgotbases = !empty;
21  }
22 
23  void cleanup() override
24  {
25  reset(false);
26  }
27 
28  void setup() override;
29 
30  void newmap() override
31  {
32  reset(true);
33  }
34 
35  void stealbase(int n, const char *team);
36 
37  void replenishammo(clientinfo *ci);
38 
39  void movebases(const char *team, const vec &oldpos, bool oldclip, const vec &newpos, bool newclip);
40 
41  void leavebases(const char *team, const vec &o)
42  {
43  movebases(team, o, false, vec(-1e10f, -1e10f, -1e10f), true);
44  }
45 
46  void enterbases(const char *team, const vec &o)
47  {
48  movebases(team, vec(-1e10f, -1e10f, -1e10f), true, o, false);
49  }
50 
51  void addscore(int base, const char *team, int n);
52 
53  void regenowners(baseinfo &b, int ticks);
54 
55  void update() override;
56 
57  void sendbaseinfo(int i);
58 
59  void sendbases();
60 
61  void initclient(clientinfo *ci, packetbuf &p, bool connecting) override;
62 
63  void endcheck();
64 
65  void entergame(clientinfo *ci) override
66  {
67  if(notgotbases || ci->state.state!=CS_ALIVE || ci->gameclip) return;
68  enterbases(ci->team, ci->state.o);
69  }
70 
71  void spawned(clientinfo *ci) override
72  {
73  if(notgotbases || ci->gameclip) return;
74  enterbases(ci->team, ci->state.o);
75  }
76 
77  void leavegame(clientinfo *ci, bool disconnecting = false) override
78  {
79  if(notgotbases || ci->state.state!=CS_ALIVE || ci->gameclip) return;
80  leavebases(ci->team, ci->state.o);
81  }
82 
83  void died(clientinfo *ci, clientinfo *actor) override
84  {
85  if(notgotbases || ci->gameclip) return;
86  leavebases(ci->team, ci->state.o);
87  }
88 
89  bool canspawn(clientinfo *ci, bool connecting) override
90  {
91  return connecting || !ci->state.lastdeath || gamemillis+curtime-ci->state.lastdeath >= (m_regencapture ? REGENRESPAWNSECS : RESPAWNSECS)*1000;
92  }
93 
94  void moved(clientinfo *ci, const vec &oldpos, bool oldclip, const vec &newpos, bool newclip) override
95  {
96  if(notgotbases) return;
97  movebases(ci->team, oldpos, oldclip, newpos, newclip);
98  }
99 
100  void changeteam(clientinfo *ci, const char *oldteam, const char *newteam) override;
101 
102  void parsebases(ucharbuf &p, bool commit);
103 
104  bool extinfoteam(const char *team, ucharbuf &p) override;
105 
106  bool parse_network_message(int type, clientinfo *ci, clientinfo *cq, packetbuf &p) override;
107 };
108 
109 
110 
111 
112 } // ns server
void stealbase(int n, const char *team)
Definition: capture_server.cpp:47
Definition: client_management.hpp:217
void moved(clientinfo *ci, const vec &oldpos, bool oldclip, const vec &newpos, bool newclip) override
Definition: capture_server.hpp:94
void initclient(clientinfo *ci, packetbuf &p, bool connecting) override
Definition: capture_server.cpp:161
template implementation of buffers (networking e.g.).
Definition: buffer_types.hpp:14
bool notgotbases
Definition: capture_server.hpp:15
bool canspawn(clientinfo *ci, bool connecting) override
Definition: capture_server.hpp:89
int lastdeath
Definition: client_management.hpp:93
void changeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
Definition: capture_server.cpp:254
bool gameclip
Definition: client_management.hpp:236
#define m_regencapture
Definition: gamemode.hpp:98
void sendbaseinfo(int i)
Definition: capture_server.cpp:150
vec o
Definition: client_management.hpp:91
void reset(bool empty)
Definition: capture_server.hpp:17
void resetbases()
Definition: capture_common.hpp:141
void regenowners(baseinfo &b, int ticks)
Definition: capture_server.cpp:80
void died(clientinfo *ci, clientinfo *actor) override
Definition: capture_server.hpp:83
void update() override
Definition: capture_server.cpp:117
void enterbases(const char *team, const vec &o)
Definition: capture_server.hpp:46
void leavegame(clientinfo *ci, bool disconnecting=false) override
Definition: capture_server.hpp:77
string team
Definition: client_management.hpp:220
void newmap() override
Definition: capture_server.hpp:30
int state
Definition: client_management.hpp:92
void endcheck()
Definition: capture_server.cpp:186
Definition: capture_server.hpp:13
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
void cleanup() override
Definition: capture_server.hpp:23
Definition: ents.hpp:120
void replenishammo(clientinfo *ci)
Definition: capture_server.cpp:32
Definition: capture_common.hpp:12
int curtime
Definition: legacy_time.cpp:14
gamestate state
Definition: client_management.hpp:227
static const int REGENRESPAWNSECS
Definition: capture_common.hpp:29
void spawned(clientinfo *ci) override
Definition: capture_server.hpp:71
network packet buffer
Definition: buffer_types.hpp:132
void movebases(const char *team, const vec &oldpos, bool oldclip, const vec &newpos, bool newclip)
Definition: capture_server.cpp:59
Definition: gamemode_server.hpp:24
void leavebases(const char *team, const vec &o)
Definition: capture_server.hpp:41
void addscore(int base, const char *team, int n)
Definition: capture_server.cpp:73
static map entities ("entity") and dynamic entities (players/monsters, "dynent") the gamecode extends...
mathmatics for vectors, matrices, quaterions and more
void setup() override
Definition: capture_server.cpp:17
bool extinfoteam(const char *team, ucharbuf &p) override
Definition: capture_server.cpp:228
void parsebases(ucharbuf &p, bool commit)
Definition: capture_server.cpp:236
void sendbases()
Definition: capture_server.cpp:155
void entergame(clientinfo *ci) override
Definition: capture_server.hpp:65
bool parse_network_message(int type, clientinfo *ci, clientinfo *cq, packetbuf &p) override
process gamemode specific network messages.
Definition: capture_server.cpp:214
static const int RESPAWNSECS
Definition: capture_common.hpp:28
int gamemillis
Definition: legacy_time.cpp:15