Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ctf_server.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "inexor/gamemode/ctf_common.hpp" // for ctfmode, ctfmo...
3 #include "inexor/gamemode/gamemode.hpp" // for m_efficiency
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  bool addflag(int i, const vec &o, int team, int invistime = 0);
16 
17  void ownflag(int i, int owner, int owntime);
18 
19  void returnflag(int i, int invistime = 0);
20 
21  static const int RESETFLAGTIME = 10000;
22  static const int INVISFLAGTIME = 20000;
23 
25 
26  ctfservermode() : notgotflags(false) {}
27 
28  void reset(bool empty)
29  {
30  resetflags();
31  notgotflags = !empty;
32  }
33 
34  void cleanup() override
35  {
36  reset(false);
37  }
38 
39  void setupholdspawns();
40 
41  void setup() override;
42 
43  void newmap() override
44  {
45  reset(true);
46  }
47 
48  void dropflag(int i, const vec &o, int droptime, int dropper = -1, bool penalty = false);
49 
50  void dropflag(clientinfo *ci, clientinfo *dropper = nullptr);
51 
52  void leavegame(clientinfo *ci, bool disconnecting = false) override;
53 
54  void died(clientinfo *ci, clientinfo *actor) override;
55 
56  bool canspawn(clientinfo *ci, bool connecting) override
57  {
58  return m_efficiency || !m_protect ? connecting || !ci->state.lastdeath || gamemillis+curtime-ci->state.lastdeath >= RESPAWNSECS*1000 : true;
59  }
60 
61  bool canchangeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
62  {
63  return ctfteamflag(newteam) > 0;
64  }
65 
66  void changeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
67  {
68  dropflag(ci);
69  }
70 
71  void spawnflag(int i);
72 
73  void scoreflag(clientinfo *ci, int goal, int relay = -1);
74 
75  void takeflag(clientinfo *ci, int i, int version);
76 
77  void update() override;
78 
79  void initclient(clientinfo *ci, packetbuf &p, bool connecting) override;
80 
81  void parseflags(ucharbuf &p, bool commit);
82 
83  bool parse_network_message(int type, clientinfo *ci, clientinfo *cq, packetbuf &p) override;
84 };
85 
86 
87 
88 
89 } // ns server
Definition: client_management.hpp:217
void setupholdspawns()
Definition: ctf_server.cpp:55
#define m_efficiency
Definition: gamemode.hpp:96
template implementation of buffers (networking e.g.).
Definition: buffer_types.hpp:14
#define m_protect
Definition: gamemode.hpp:100
int lastdeath
Definition: client_management.hpp:93
bool canspawn(clientinfo *ci, bool connecting) override
Definition: ctf_server.hpp:56
void spawnflag(int i)
Definition: ctf_server.cpp:124
bool addflag(int i, const vec &o, int team, int invistime=0)
Definition: ctf_server.cpp:23
void resetflags()
Definition: ctf_common.hpp:93
void ownflag(int i, int owner, int owntime)
Definition: ctf_server.cpp:37
#define ctfteamflag(s)
Definition: ctf_common.hpp:12
bool notgotflags
Definition: ctf_server.hpp:24
static const int RESETFLAGTIME
Definition: ctf_server.hpp:21
static const int RESPAWNSECS
Definition: ctf_common.hpp:79
void cleanup() override
Definition: ctf_server.hpp:34
void update() override
Definition: ctf_server.cpp:169
void parseflags(ucharbuf &p, bool commit)
Definition: ctf_server.cpp:222
void returnflag(int i, int invistime=0)
Definition: ctf_server.cpp:46
Definition: ctf_common.hpp:69
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
void initclient(clientinfo *ci, packetbuf &p, bool connecting) override
Definition: ctf_server.cpp:198
void newmap() override
Definition: ctf_server.hpp:43
bool parse_network_message(int type, clientinfo *ci, clientinfo *cq, packetbuf &p) override
process gamemode specific network messages.
Definition: ctf_server.cpp:243
void reset(bool empty)
Definition: ctf_server.hpp:28
int curtime
Definition: legacy_time.cpp:14
bool canchangeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
Definition: ctf_server.hpp:61
void setup() override
Definition: ctf_server.cpp:67
void died(clientinfo *ci, clientinfo *actor) override
Definition: ctf_server.cpp:31
gamestate state
Definition: client_management.hpp:227
Definition: ctf_server.hpp:13
network packet buffer
Definition: buffer_types.hpp:132
void dropflag(int i, const vec &o, int droptime, int dropper=-1, bool penalty=false)
Definition: ctf_server.cpp:88
Definition: gamemode_server.hpp:24
void takeflag(clientinfo *ci, int i, int version)
Definition: ctf_server.cpp:145
void scoreflag(clientinfo *ci, int goal, int relay=-1)
Definition: ctf_server.cpp:135
ctfservermode()
Definition: ctf_server.hpp:26
void changeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
Definition: ctf_server.hpp:66
static const int INVISFLAGTIME
Definition: ctf_server.hpp:22
void leavegame(clientinfo *ci, bool disconnecting=false) override
Definition: ctf_server.cpp:119
int gamemillis
Definition: legacy_time.cpp:15