Skip to content

Commit 50c4309

Browse files
authored
Merge pull request #23 from PrawyCoD1/stable
fix client ping on scoreboard, hook SV_BotUserMove, adsair disabled b…
2 parents 52157e9 + d777fe9 commit 50c4309

File tree

17 files changed

+847
-94
lines changed

17 files changed

+847
-94
lines changed

bin/codextended.so

124 KB
Binary file not shown.

src/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ $compiler $params -c g_spawn.c -o obj/g_spawn.o
155155
$compiler $params -c g_active.c -o obj/g_active.o
156156
$compiler $params -c q_math.c -o obj/q_math.o
157157
$compiler $params -c files.c -o obj/files.o
158+
$compiler $params -c gsc_bots.c -o obj/gsc_bots.o
158159
echo "[SERVER]"
159160
nasm -f elf sv_snapshot.asm -o obj/sv_snapshot_asm.o
160161
$compiler $params -c sv_snapshot.c -o obj/sv_snapshot.o

src/codextended.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ void CoDExtended() {
391391
void custom_SV_WriteDownloadToClient(client_t *cl, msg_t *msg);
392392
__jmp(0x8086290, (int)custom_SV_WriteDownloadToClient);
393393

394-
const char *__cdecl FS_ReferencedPakChecksums();
395-
const char *__cdecl FS_ReferencedPakNames();
394+
void custom_SV_BotUserMove(client_t *client);
395+
__jmp(0x0808cccc, (int)custom_SV_BotUserMove);
396396

397397
/* sv_snapshot.asm */
398398
unsigned TestGetAddr();

src/gsc_bots.c

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
#include "script.h"
2+
3+
void gsc_bots_setbotstance(scr_entref_t ref)
4+
{
5+
int id = ref.entnum;
6+
char *stance = Scr_GetString(0);
7+
8+
if (id >= MAX_CLIENTS)
9+
{
10+
stackError("gsc_bots_setbotstance() entity %i is not a player", id);
11+
Scr_AddUndefined();
12+
return;
13+
}
14+
15+
client_t *client = &svs.clients[id];
16+
17+
if (client->netchan.remoteAddress.type != NA_BOT)
18+
{
19+
stackError("gsc_bots_setbotstance() player %i is not a bot", id);
20+
Scr_AddUndefined();
21+
return;
22+
}
23+
24+
if (!strcmp(stance, "stand"))
25+
{
26+
customPlayerState[id].botUpMove &= ~(-KEY_MASK_JUMP | KEY_MASK_JUMP);
27+
customPlayerState[id].botWButtons &= ~(KEY_MASK_CROUCH | KEY_MASK_PRONE);
28+
}
29+
else if(!strcmp(stance, "crouch"))
30+
customPlayerState[id].botWButtons |= KEY_MASK_CROUCH;
31+
else if(!strcmp(stance, "prone"))
32+
customPlayerState[id].botWButtons |= KEY_MASK_PRONE;
33+
else if(!strcmp(stance, "jump"))
34+
customPlayerState[id].botUpMove |= KEY_MASK_JUMP;
35+
else
36+
{
37+
stackError("gsc_bots_setbotstance() invalid argument '%s'. Valid arguments are: 'stand' 'crouch' 'prone' 'jump'", stance);
38+
Scr_AddUndefined();
39+
return;
40+
}
41+
42+
Scr_AddBool(qtrue);
43+
}
44+
45+
void gsc_bots_meleeweapon(scr_entref_t ref)
46+
{
47+
int id = ref.entnum;
48+
int melee = Scr_GetInt(0);
49+
50+
if (id >= MAX_CLIENTS)
51+
{
52+
stackError("gsc_bots_meleeweapon() entity %i is not a player", id);
53+
Scr_AddUndefined();
54+
return;
55+
}
56+
57+
client_t *client = &svs.clients[id];
58+
59+
if (client->netchan.remoteAddress.type != NA_BOT)
60+
{
61+
stackError("gsc_bots_meleeweapon() player %i is not a bot", id);
62+
Scr_AddUndefined();
63+
return;
64+
}
65+
66+
if(!melee)
67+
customPlayerState[id].botButtons &= ~KEY_MASK_MELEE;
68+
else
69+
customPlayerState[id].botButtons |= KEY_MASK_MELEE;
70+
71+
Scr_AddBool(qtrue);
72+
}
73+
74+
void gsc_bots_setaim(scr_entref_t ref)
75+
{
76+
int id = ref.entnum;
77+
int ads = Scr_GetInt(0);
78+
79+
if (id >= MAX_CLIENTS)
80+
{
81+
stackError("gsc_bots_setaim() entity %i is not a player", id);
82+
Scr_AddUndefined();
83+
return;
84+
}
85+
86+
client_t *client = &svs.clients[id];
87+
88+
if (client->netchan.remoteAddress.type != NA_BOT)
89+
{
90+
stackError("gsc_bots_setaim() player %i is not a bot", id);
91+
Scr_AddUndefined();
92+
return;
93+
}
94+
95+
if(!ads)
96+
customPlayerState[id].botButtons &= ~KEY_MASK_ADS_MODE;
97+
else
98+
customPlayerState[id].botButtons |= KEY_MASK_ADS_MODE;
99+
100+
Scr_AddBool(qtrue);
101+
}
102+
103+
void gsc_bots_fireweapon(scr_entref_t ref)
104+
{
105+
int id = ref.entnum;
106+
int shoot = Scr_GetInt(0);
107+
108+
if (id >= MAX_CLIENTS)
109+
{
110+
stackError("gsc_bots_fireweapon() entity %i is not a player", id);
111+
Scr_AddUndefined();
112+
return;
113+
}
114+
115+
client_t *client = &svs.clients[id];
116+
117+
if (client->netchan.remoteAddress.type != NA_BOT)
118+
{
119+
stackError("gsc_bots_fireweapon() player %i is not a bot", id);
120+
Scr_AddUndefined();
121+
return;
122+
}
123+
124+
if(!shoot)
125+
customPlayerState[id].botButtons &= ~KEY_MASK_FIRE;
126+
else
127+
customPlayerState[id].botButtons |= KEY_MASK_FIRE;
128+
129+
Scr_AddBool(qtrue);
130+
}
131+
132+
void gsc_bots_setlean(scr_entref_t ref)
133+
{
134+
int id = ref.entnum;
135+
char *lean = Scr_GetString(0);
136+
137+
if (id >= MAX_CLIENTS)
138+
{
139+
stackError("gsc_bots_setlean() entity %i is not a player", id);
140+
Scr_AddUndefined();
141+
return;
142+
}
143+
144+
client_t *client = &svs.clients[id];
145+
146+
if (client->netchan.remoteAddress.type != NA_BOT)
147+
{
148+
stackError("gsc_bots_setlean() player %i is not a bot", id);
149+
Scr_AddUndefined();
150+
return;
151+
}
152+
153+
if(!strcmp(lean, "none"))
154+
customPlayerState[id].botWButtons &= ~(KEY_MASK_LEANLEFT | KEY_MASK_LEANRIGHT);
155+
else if(!strcmp(lean, "left"))
156+
customPlayerState[id].botWButtons |= KEY_MASK_LEANLEFT;
157+
else if(!strcmp(lean, "right"))
158+
customPlayerState[id].botWButtons |= KEY_MASK_LEANRIGHT;
159+
else
160+
{
161+
stackError("gsc_bots_setlean() invalid argument '%s'. Valid arguments are: 'right' 'left'", lean);
162+
Scr_AddUndefined();
163+
return;
164+
}
165+
166+
Scr_AddBool(qtrue);
167+
}
168+
169+
void gsc_bots_reloadweapon(scr_entref_t ref)
170+
{
171+
int id = ref.entnum;
172+
int reload = Scr_GetInt(0);
173+
174+
if (id >= MAX_CLIENTS)
175+
{
176+
stackError("gsc_bots_reloadweapon() entity %i is not a player", id);
177+
Scr_AddUndefined();
178+
return;
179+
}
180+
181+
client_t *client = &svs.clients[id];
182+
183+
if (client->netchan.remoteAddress.type != NA_BOT)
184+
{
185+
stackError("gsc_bots_reloadweapon() player %i is not a bot", id);
186+
Scr_AddUndefined();
187+
return;
188+
}
189+
190+
if(!reload)
191+
customPlayerState[id].botWButtons &= ~KEY_MASK_RELOAD;
192+
else
193+
customPlayerState[id].botWButtons |= KEY_MASK_RELOAD;
194+
195+
Scr_AddBool(qtrue);
196+
}
197+
198+
void gsc_bots_switchtoweaponid(scr_entref_t ref)
199+
{
200+
int id = ref.entnum;
201+
int weaponid = Scr_GetInt(0);
202+
203+
if (id >= MAX_CLIENTS)
204+
{
205+
stackError("gsc_bots_switchtoweaponid() entity %i is not a player", id);
206+
Scr_AddUndefined();
207+
return;
208+
}
209+
210+
client_t *client = &svs.clients[id];
211+
212+
if (client->netchan.remoteAddress.type != NA_BOT)
213+
{
214+
stackError("gsc_bots_switchtoweaponid() player %i is not a bot", id);
215+
Scr_AddUndefined();
216+
return;
217+
}
218+
219+
customPlayerState[id].botWeapon = weaponid;
220+
221+
Scr_AddBool(qtrue);
222+
}
223+
224+
void gsc_bots_setwalkdir(scr_entref_t ref)
225+
{
226+
int id = ref.entnum;
227+
char *dir = Scr_GetString(0);
228+
229+
if (id >= MAX_CLIENTS)
230+
{
231+
stackError("gsc_bots_setwalkdir() entity %i is not a player", id);
232+
Scr_AddUndefined();
233+
return;
234+
}
235+
236+
client_t *client = &svs.clients[id];
237+
238+
if (client->netchan.remoteAddress.type != NA_BOT)
239+
{
240+
stackError("gsc_bots_setwalkdir() player %i is not a bot", id);
241+
Scr_AddUndefined();
242+
return;
243+
}
244+
245+
if (!strcmp(dir, "none"))
246+
{
247+
customPlayerState[id].botForwardMove = KEY_MASK_NONE;
248+
customPlayerState[id].botRightMove = KEY_MASK_NONE;
249+
}
250+
else if(!strcmp(dir, "forward"))
251+
customPlayerState[id].botForwardMove = KEY_MASK_FORWARD;
252+
else if(!strcmp(dir, "back"))
253+
customPlayerState[id].botForwardMove = KEY_MASK_BACK;
254+
else if(!strcmp(dir, "right"))
255+
customPlayerState[id].botRightMove = KEY_MASK_MOVERIGHT;
256+
else if(!strcmp(dir, "left"))
257+
customPlayerState[id].botRightMove = KEY_MASK_MOVELEFT;
258+
else
259+
{
260+
stackError("gsc_bots_setwalkdir() invalid argument '%s'. Valid arguments are: 'none' 'forward' 'back' 'right' 'left'", dir);
261+
Scr_AddUndefined();
262+
return;
263+
}
264+
265+
Scr_AddBool(qtrue);
266+
}
267+
268+
void gsc_bots_setwalkvalues(scr_entref_t ref)
269+
{
270+
int id = ref.entnum;
271+
int fwcount = Scr_GetInt(0);
272+
int rgcount = Scr_GetInt(1);
273+
274+
customPlayerState[id].botForwardMove = fwcount;
275+
customPlayerState[id].botRightMove = rgcount;
276+
277+
Scr_AddBool(qtrue);
278+
}

src/inc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,4 +549,5 @@ extern x##_t x
549549
#define sv_downloadNotifications xtn_sv_downloadNotifications
550550
#define MSG_WriteBitsCompress xtn_MSG_WriteBitsCompress
551551
#define sv_debugRate xtn_sv_debugRate
552-
#define sv_showAverageBPS xtn_sv_showAverageBPS
552+
#define Scr_IsSystemActive xtn_Scr_IsSystemActive
553+
#define trap_SendServerCommand xtn_trap_SendServerCommand

0 commit comments

Comments
 (0)