Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
teaminfo.hpp
Go to the documentation of this file.
1 #pragma once
3 
8 
9 #include <string.h>
10 
11 
13 #define MAXTEAMS 128
14 #define MAXNAMELEN 15
15 #define MAXTEAMLEN 4
16 #define MAXTAGLEN 8
17 #define BOTTAG "Bot"
18 
19 enum
20 {
25 };
26 
28 static const char * const teamblipcolor[TEAM_NUM] =
29 {
30  "_neutral", // = 'gray'
31  "_blue",
32  "_red"
33 };
34 
35 // team handling
36 
37 #define MAXNAMELEN 15
38 #define MAXTEAMLEN 4
39 #define MAXTEAMS 128
40 
43 struct teamscore
44 {
45  const char *team;
46  int score;
47  teamscore() {}
48  teamscore(const char *s, int n) : team(s), score(n) {}
49 
50  // used for quicksort template to compare teams
51  static bool compare(const teamscore &x, const teamscore &y)
52  {
53  if(x.score > y.score) return true;
54  if(x.score < y.score) return false;
55  return strcmp(x.team, y.team) < 0;
56  }
57 };
58 
60 static inline uint hthash(const teamscore &t) { return hthash(t.team); }
61 
63 static inline bool htcmp(const char *key, const teamscore &t) { return htcmp(key, t.team); }
64 
66 struct teaminfo
67 {
68  char team[MAXTEAMLEN+1];
69  int frags;
70 };
71 
73 static inline uint hthash(const teaminfo &t) { return hthash(t.team); }
74 
76 static inline bool htcmp(const char *team, const teaminfo &t) { return !strcmp(team, t.team); }
77 
78 
81 {
83 
86  char *sametag()
87  {
88  fpsent *prev = nullptr;
89  loopv(players)
90  {
91  fpsent *p = players[i];
92  if(!p->tag[0]) return nullptr;
93  if(!prev) { prev = p; continue; }
94  if(strcmp(p->tag, prev->tag)) return nullptr; //two tags are not matching
95  }
96  return prev ? prev->tag : nullptr;
97  }
98 };
99 namespace game {
100 extern void clearteaminfo();
101 extern void setteaminfo(const char *team, int frags);
102 }
Definition: teaminfo.hpp:24
unsigned int uint
Definition: cube_types.hpp:9
void setteaminfo(const char *team, int frags)
Definition: scoreboard.cpp:52
int score
Definition: teaminfo.hpp:46
string tag
Definition: fpsent.hpp:30
static bool compare(const teamscore &x, const teamscore &y)
Definition: teaminfo.hpp:51
vector< fpsent * > players
Definition: teaminfo.hpp:82
teamscore(const char *s, int n)
Definition: teaminfo.hpp:48
Definition: teaminfo.hpp:21
static const char *const teamblipcolor[TEAM_NUM]
const radar blip colors
Definition: teaminfo.hpp:28
static uint hthash(const teamscore &t)
create hashes to access hashmaps
Definition: teaminfo.hpp:60
teamscore()
Definition: teaminfo.hpp:47
static bool htcmp(const char *key, const teamscore &t)
compare two teamnames
Definition: teaminfo.hpp:63
int frags
Definition: teaminfo.hpp:69
char team[MAXTEAMLEN+1]
Definition: teaminfo.hpp:68
void t(T x, const char *cmp)
Definition: utilTest.cpp:52
Definition: teaminfo.hpp:23
Definition: teaminfo.hpp:22
#define MAXTEAMLEN
Definition: teaminfo.hpp:38
Definition: fpsent.hpp:12
void clearteaminfo()
Definition: scoreboard.cpp:47
some team modes allow more than 2 teams allow sorting multiple teams using team scores ...
Definition: teaminfo.hpp:43
Used only for the scoreboard.
Definition: teaminfo.hpp:80
char * sametag()
Returns whether this scoregroup is a clan/playing-group, whatever.
Definition: teaminfo.hpp:86
const char * team
Definition: teaminfo.hpp:45
scoreboard team block description
Definition: teaminfo.hpp:66
#define loopv(v)
Definition: cube_loops.hpp:21