-
Notifications
You must be signed in to change notification settings - Fork 3
/
listteams.patch
110 lines (104 loc) · 3.83 KB
/
listteams.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Index: src/fpsgame/client.cpp
===================================================================
--- src/fpsgame/client.cpp (revision 6488)
+++ src/fpsgame/client.cpp (working copy)
@@ -372,18 +372,46 @@
}
ICOMMAND(getclientnum, "s", (char *name), intret(name[0] ? parseplayer(name) : player1->clientnum));
- void listclients(bool local, bool bots)
+ void listteams(bool local, bool bots, bool specs)
{
vector<char> buf;
+ int numgroups = groupplayers();
+ if(!numgroups || (numgroups==1 && !groups[0]->team)) return;
+ loopi(numgroups)
+ {
+ if(!local || !bots || !specs)
+ {
+ bool include = false;
+ loopvj(groups[i]->players)
+ {
+ fpsent *p = groups[i]->players[j];
+ if((local || p!=player1) && (bots || p->aitype==AI_NONE) && (specs || p->state!=CS_SPECTATOR)) {
+ include = true;
+ break;
+ }
+ }
+ if(!include) continue;
+ }
+ if(buf.length()) buf.add(' ');
+ if(groups[i]->team) buf.put(groups[i]->team, strlen(groups[i]->team));
+ }
+ buf.add('\0');
+ result(buf.getbuf());
+ }
+ ICOMMAND(listteams, "bbb", (int *local, int *bots, int *specs), listteams(*local!=0, *bots!=0, *specs!=0));
+
+ void listclients(bool local, bool bots, bool specs, const char *team)
+ {
+ vector<char> buf;
string cn;
int numclients = 0;
- if(local && connected)
+ if(local && connected && (specs || player1->state!=CS_SPECTATOR) && (!*team || !strcasecmp(team, player1->team)))
{
formatstring(cn, "%d", player1->clientnum);
buf.put(cn, strlen(cn));
numclients++;
}
- loopv(clients) if(clients[i] && (bots || clients[i]->aitype == AI_NONE))
+ loopv(clients) if(clients[i] && (bots || clients[i]->aitype == AI_NONE) && (specs || clients[i]->state!=CS_SPECTATOR) && (!*team || !strcasecmp(team, clients[i]->team)))
{
formatstring(cn, "%d", clients[i]->clientnum);
if(numclients++) buf.add(' ');
@@ -392,7 +420,7 @@
buf.add('\0');
result(buf.getbuf());
}
- ICOMMAND(listclients, "bb", (int *local, int *bots), listclients(*local>0, *bots!=0));
+ ICOMMAND(listclients, "bbbs", (int *local, int *bots, int *specs, char *team), listclients(*local>0, *bots!=0, *specs!=0, team));
void clearbans()
{
Index: src/fpsgame/game.h
===================================================================
--- src/fpsgame/game.h (revision 6488)
+++ src/fpsgame/game.h (working copy)
@@ -825,6 +825,14 @@
extern void setteaminfo(const char *team, int frags);
extern int statuscolor(fpsent *d, int color);
+ struct scoregroup : teamscore
+ {
+ vector<fpsent *> players;
+ };
+ extern vector<scoregroup *> groups;
+ extern vector<fpsent *> spectators;
+ extern int groupplayers();
+
// render
struct playermodelinfo
{
Index: src/fpsgame/scoreboard.cpp
===================================================================
--- src/fpsgame/scoreboard.cpp (revision 6488)
+++ src/fpsgame/scoreboard.cpp (working copy)
@@ -81,12 +81,8 @@
}
}
- struct scoregroup : teamscore
- {
- vector<fpsent *> players;
- };
- static vector<scoregroup *> groups;
- static vector<fpsent *> spectators;
+ vector<scoregroup *> groups;
+ vector<fpsent *> spectators;
static inline bool scoregroupcmp(const scoregroup *x, const scoregroup *y)
{
@@ -102,7 +98,7 @@
return x->team && y->team && strcmp(x->team, y->team) < 0;
}
- static int groupplayers()
+ int groupplayers()
{
int numgroups = 0;
spectators.setsize(0);