Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
hideandseek_server.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <string.h> // for strcmp
3 
4 #include "inexor/gamemode/hideandseek_common.hpp" // for TEAM_HIDE, TEA...
5 #include "inexor/server/client_management.hpp" // for clientinfo (pt...
6 #include "inexor/server/gamemode/gamemode_server.hpp" // for servmode
7 #include "inexor/shared/cube_vector.hpp" // for vector
8 #include "inexor/shared/ents.hpp" // for ::CS_SPECTATOR
9 
10 struct fpsent;
11 struct packetbuf;
12 
13 #define ishider(ci) (strcmp(ci->team, TEAM_HIDE) == 0 && ci->state.state != CS_SPECTATOR ? true : false)
14 #define isseeker(ci) (strcmp(ci->team, TEAM_SEEK) == 0 && ci->state.state != CS_SPECTATOR ? true : false)
15 
16 namespace server {
17 
19 {
20  struct seekersinfo
21  {
22  int cn;
23  bool freezed;
24  seekersinfo(int cn_, bool freezed_) : cn(cn_), freezed(freezed_) {}
25  };
26 
29 
30  void setup() override;
31 
32  void initplayers();
33 
35  {
36  sethider(ci);
37  }
38 
39  void initclient(clientinfo *ci, packetbuf &p, bool connecting) override
40  {
41  setseeker(ci);
42  }
43 
44  void connected(clientinfo *ci) override
45  {
46  setseeker(ci);
47  }
48 
49  void leavegame(clientinfo *ci, bool disconnecting) override;
50 
51  void cleanup() override
52  {
53  seekersinfos.deletecontents();
54  }
55 
56  bool checkfinished();
57 
58  void update() override;
59 
60  void intermission() override
61  {
62  }
63 
64  void spawned(fpsent *d)
65  {
66  }
67 
68  bool canspawn(clientinfo *ci, bool connecting) override
69  {
70  return true;
71  }
72 
73  bool canhit(clientinfo *target, clientinfo *actor) override;
74 
75  void died(clientinfo *target, clientinfo *actor) override;
76 
77  bool canchangeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
78  {
79  return false;
80  }
81 
82  void setseeker(clientinfo *ci);
83 
84  void sethider(clientinfo *ci);
85 
87 
88  int getremaininghiders();
89 
90  bool isfreezed(clientinfo *ci);
91 
92  void setfreezedstate(clientinfo *ci, bool state);
93 
95 
96  void announceseekers(char* msg);
97 
98  bool parse_network_message(int type, clientinfo *ci, clientinfo *cq, packetbuf &p) override
99  {
100  switch(type)
101  {
102  /*
103  case N_RACEFINISH:
104  {
105  break;
106  }
107  */
108  default: break;
109  }
110  return false;
111  }
112 };
113 
114 
115 
116 
117 } // ns server
Definition: client_management.hpp:217
Vector template.
Definition: cube_vector.hpp:22
void announceseekers(char *msg)
Definition: hideandseek_server.cpp:124
void spawned(fpsent *d)
Definition: hideandseek_server.hpp:64
vector< seekersinfo * > seekersinfos
Definition: hideandseek_server.hpp:27
void cleanup() override
Definition: hideandseek_server.hpp:51
Definition: hideandseek_server.hpp:20
void leavegame(clientinfo *ci, bool disconnecting) override
Definition: hideandseek_server.cpp:31
bool parse_network_message(int type, clientinfo *ci, clientinfo *cq, packetbuf &p) override
process gamemode specific network messages.
Definition: hideandseek_server.hpp:98
void setfreezedstate(clientinfo *ci, bool state)
Definition: hideandseek_server.cpp:137
void update() override
Definition: hideandseek_server.cpp:47
void connected(clientinfo *ci) override
Definition: hideandseek_server.hpp:44
bool checkfinished()
Definition: hideandseek_server.cpp:38
void died(clientinfo *target, clientinfo *actor) override
Definition: hideandseek_server.cpp:65
void initplayers()
Definition: hideandseek_server.cpp:23
static enum recorder::@19 state
int getremaininghiders()
Definition: hideandseek_server.cpp:118
bool isfreezed(clientinfo *ci)
Definition: hideandseek_server.cpp:141
seekersinfo(int cn_, bool freezed_)
Definition: hideandseek_server.hpp:24
int lastupdatecheck
Definition: hideandseek_server.hpp:28
vector< clientinfo * > getactiveplayers()
Definition: hideandseek_server.cpp:107
int cn
Definition: hideandseek_server.hpp:22
void setseeker(clientinfo *ci)
Definition: hideandseek_server.cpp:96
int d
Definition: octaedit.cpp:1749
int getnonfreezedseekers()
Definition: hideandseek_server.cpp:131
bool freezed
Definition: hideandseek_server.hpp:23
void intermission() override
Definition: hideandseek_server.hpp:60
network packet buffer
Definition: buffer_types.hpp:132
Definition: gamemode_server.hpp:24
Definition: fpsent.hpp:12
void initclient(clientinfo *ci, packetbuf &p, bool connecting) override
Definition: hideandseek_server.hpp:39
bool canspawn(clientinfo *ci, bool connecting) override
Definition: hideandseek_server.hpp:68
void sethider(clientinfo *ci)
Definition: hideandseek_server.cpp:102
Definition: hideandseek_common.hpp:7
bool canhit(clientinfo *target, clientinfo *actor) override
Definition: hideandseek_server.cpp:55
static map entities ("entity") and dynamic entities (players/monsters, "dynent") the gamecode extends...
void initplayer(clientinfo *ci)
Definition: hideandseek_server.hpp:34
Definition: hideandseek_server.hpp:18
void setup() override
Definition: hideandseek_server.cpp:17
bool target(fpsent *d, aistate &b, int pursue=0, bool force=false, float mindist=0.f)
Definition: ai.cpp:393
bool canchangeteam(clientinfo *ci, const char *oldteam, const char *newteam) override
Definition: hideandseek_server.hpp:77