-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhost_cmd.pas
1745 lines (1475 loc) · 36.9 KB
/
host_cmd.pas
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ------------------------------------------------------------------------------
// DelphiQuake, Copyright (C) 2005-2011 by Jim Valavanis
// E-Mail: [email protected]
//
// Copyright (C) 1996-1997 Id Software, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// ------------------------------------------------------------------------------
{$I dquake.inc}
{$Z4}
unit host_cmd;
interface
uses
q_delphi;
procedure Host_InitCommands;
procedure Host_Quit_f;
var
noclip_anglehack: qboolean;
current_skill: integer;
implementation
uses
keys,
cl_main,
client,
menu,
cl_main_h,
host,
sys_win,
server_h,
cmd,
sv_main,
console,
cvar,
quakedef,
net_main,
pr_edict,
host_h,
sv_user,
gl_screen,
cl_demo,
common,
progs_h,
zone,
world,
protocol,
pr_exec,
gl_model_h,
gl_model;
(*
==================
Host_Quit_f
==================
*)
procedure Host_Quit_f;
begin
if (key_dest <> key_console) and (cls.state <> ca_dedicated) then
begin
M_Menu_Quit_f;
exit;
end;
CL_Disconnect;
Host_ShutdownServer(false);
Sys_Quit;
end;
(*
==================
Host_Status_f
==================
*)
type
print_t = procedure(p: PChar; const A: array of const);
procedure Host_Status_f;
var
client: Pclient_t;
seconds: integer;
minutes: integer;
hours: integer;
j: integer;
print: print_t;
begin
if cmd_source = src_command then
begin
if not sv.active then
begin
Cmd_ForwardToServer;
exit;
end;
print := Con_Printf;
end
else
print := SV_ClientPrintf;
print('host: %s'#10, [Cvar_VariableString('hostname')]);
print('version: %4.2f'#10, [VERSION]);
if tcpipAvailable then
print('tcp/ip: %s'#10, [my_tcpip_address]);
if ipxAvailable then
print('ipx: %s'#10, [my_ipx_address]);
print('map: %s'#10, [sv.name]);
print('players: %d active (%d max)'#10#10, [net_activeconnections, svs.maxclients]);
client := @svs.clients[0]; // JVAL check this
for j := 0 to svs.maxclients - 1 do
begin
if client.active then
begin
seconds := intval(net_time - client.netconnection.connecttime);
minutes := seconds div 60;
if minutes <> 0 then
begin
seconds := seconds - (minutes * 60);
hours := minutes div 60;
if hours <> 0 then
minutes := minutes - (hours * 60);
end
else
hours := 0;
print('#%-2u %-16.16s %3d %2d:%02d:%02d'#10, // JVAL SOS
[j + 1, client.name, intval(client.edict.v.frags), hours, minutes, seconds]);
print(' %s'#10, [client.netconnection.address]);
end;
inc(client);
end;
end;
(*
==================
Host_God_f
Sets client to godmode
==================
*)
procedure Host_God_f;
begin
if cmd_source = src_command then
begin
Cmd_ForwardToServer;
exit;
end;
if (pr_global_struct.deathmatch <> 0) and not host_client.privileged then
exit;
sv_player.v.flags := intval(sv_player.v.flags) xor FL_GODMODE; // JVAL check xor
if intval(sv_player.v.flags) and FL_GODMODE = 0 then
SV_ClientPrintf('godmode OFF'#10)
else
SV_ClientPrintf('godmode ON'#10);
end;
procedure Host_Notarget_f;
begin
if cmd_source = src_command then
begin
Cmd_ForwardToServer;
exit;
end;
if (pr_global_struct.deathmatch <> 0) and not host_client.privileged then
exit;
sv_player.v.flags := intval(sv_player.v.flags) xor FL_NOTARGET; // JVAL check xor
if (intval(sv_player.v.flags) and FL_NOTARGET) = 0 then
SV_ClientPrintf('notarget OFF'#10)
else
SV_ClientPrintf('notarget ON'#10);
end;
procedure Host_Noclip_f;
begin
if cmd_source = src_command then
begin
Cmd_ForwardToServer;
exit;
end;
if (pr_global_struct.deathmatch <> 0) and not host_client.privileged then
exit;
if sv_player.v.movetype <> MOVETYPE_NOCLIP then
begin
noclip_anglehack := true;
sv_player.v.movetype := MOVETYPE_NOCLIP;
SV_ClientPrintf('noclip ON'#10);
end
else
begin
noclip_anglehack := false;
sv_player.v.movetype := MOVETYPE_WALK;
SV_ClientPrintf('noclip OFF'#10);
end;
end;
(*
==================
Host_Fly_f
Sets client to flymode
==================
*)
procedure Host_Fly_f;
begin
if cmd_source = src_command then
begin
Cmd_ForwardToServer;
exit;
end;
if (pr_global_struct.deathmatch <> 0) and not (host_client.privileged) then
exit;
if sv_player.v.movetype <> MOVETYPE_FLY then
begin
sv_player.v.movetype := MOVETYPE_FLY;
SV_ClientPrintf('flymode ON'#10);
end
else
begin
sv_player.v.movetype := MOVETYPE_WALK;
SV_ClientPrintf('flymode OFF'#10);
end;
end;
(*
==================
Host_Ping_f
==================
*)
procedure Host_Ping_f;
var
i, j: integer;
total: single;
client: Pclient_t;
begin
if cmd_source = src_command then
begin
Cmd_ForwardToServer;
exit;
end;
SV_ClientPrintf('Client ping times:'#10);
client := @svs.clients[0]; // JVAL check this
for i := 0 to svs.maxclients - 1 do
begin
if client.active then
begin
total := 0.0;
for j := 0 to NUM_PING_TIMES - 1 do
total := total + client.ping_times[j];
total := total / NUM_PING_TIMES;
SV_ClientPrintf('%4d %s'#10, [int(total * 1000), client.name]);
end;
inc(client);
end;
end;
(*
===============================================================================
SERVER TRANSITIONS
===============================================================================
*)
(*
======================
Host_Map_f
handle a
map <servername>
command from the console. Active clients are kicked off.
======================
*)
procedure Host_Map_f;
var
i: integer;
name: array[0..MAX_QPATH - 1] of char;
begin
if cmd_source <> src_command then
exit;
cls.demonum := -1; // stop demo loop in case this fails
CL_Disconnect;
Host_ShutdownServer(false);
key_dest := key_game; // remove console or menu
SCR_BeginLoadingPlaque;
cls.mapstring[0] := #0;
for i := 0 to Cmd_Argc_f - 1 do
begin
strcat(cls.mapstring, Cmd_Argv_f(i));
strcat(cls.mapstring, ' ');
end;
strcat(cls.mapstring, #10);
svs.serverflags := 0; // haven't completed an episode yet
strcpy(name, Cmd_Argv_f(1));
SV_SpawnServer(name);
if not sv.active then
exit;
if cls.state <> ca_dedicated then
begin
strcpy(cls.spawnparms, '');
for i := 2 to Cmd_Argc_f - 1 do
begin
strcat(cls.spawnparms, Cmd_Argv_f(i));
strcat(cls.spawnparms, ' ');
end;
Cmd_ExecuteString('connect local', src_command);
end;
end;
(*
==================
Host_Changelevel_f
Goes to a new map, taking all clients along
==================
*)
procedure Host_Changelevel_f;
var
level: array[0..MAX_QPATH - 1] of char;
begin
if Cmd_Argc_f <> 2 then
begin
Con_Printf('changelevel <levelname> : continue game on a new level'#10);
exit;
end;
if not sv.active or cls.demoplayback then
begin
Con_Printf('Only the server may changelevel'#10);
exit;
end;
SV_SaveSpawnparms;
strcpy(level, Cmd_Argv_f(1));
SV_SpawnServer(level);
end;
(*
==================
Host_Restart_f
Restarts the current server for a dead player
==================
*)
procedure Host_Restart_f;
var
mapname: array[0..MAX_QPATH - 1] of char;
begin
if cls.demoplayback or not sv.active then
exit;
if cmd_source <> src_command then
exit;
strcpy(mapname, sv.name); // must copy out, because it gets cleared
// in sv_spawnserver
SV_SpawnServer(mapname);
end;
(*
==================
Host_Reconnect_f
This command causes the client to wait for the signon messages again.
This is sent just before a server changes levels
==================
*)
procedure Host_Reconnect_f;
begin
SCR_BeginLoadingPlaque;
cls.signon := 0; // need new connection messages
end;
(*
=====================
Host_Connect_f
User command to connect to server
=====================
*)
procedure Host_Connect_f;
var
name: array[0..MAX_QPATH - 1] of char;
begin
cls.demonum := -1; // stop demo loop in case this fails
if cls.demoplayback then
begin
CL_StopPlayback;
CL_Disconnect;
end;
strcpy(name, Cmd_Argv_f(1));
CL_EstablishConnection(name);
Host_Reconnect_f;
end;
(*
===============================================================================
LOAD / SAVE GAME
===============================================================================
*)
const
SAVEGAME_VERSION = 5;
(*
===============
Host_SavegameComment
Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
===============
*)
procedure Host_SavegameComment(text: PChar);
var
i: integer;
kills: array[0..19] of char;
begin
for i := 0 to SAVEGAME_COMMENT_LENGTH - 1 do
text[i] := ' ';
memcpy(text, @cl.levelname, strlen(cl.levelname));
sprintf(kills, 'kills:%3d/%3d', [cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]]);
memcpy(@text[22], @kills, strlen(kills));
// convert space to _ to make stdio happy
for i := 0 to SAVEGAME_COMMENT_LENGTH - 1 do
if text[i] = ' ' then
text[i] := '_';
text[SAVEGAME_COMMENT_LENGTH] := #0;
end;
(*
===============
Host_Savegame_f
===============
*)
procedure Host_Savegame_f;
var
name: array[0..255] of char;
f: text;
i: integer;
comment: array[0..SAVEGAME_COMMENT_LENGTH] of char;
begin
if cmd_source <> src_command then
exit;
if not sv.active then
begin
Con_Printf('Not playing a local game.'#10);
exit;
end;
if cl.intermission <> 0 then
begin
Con_Printf('Can''t save in intermission.'#10);
exit;
end;
if svs.maxclients <> 1 then
begin
Con_Printf('Can''t save multiplayer games.'#10);
exit;
end;
if Cmd_Argc_f <> 2 then
begin
Con_Printf('save <savename> : save a game'#10);
exit;
end;
if strstr(Cmd_Argv_f(1), '..') <> nil then
begin
Con_Printf('Relative pathnames are not allowed.'#10);
exit;
end;
for i := 0 to svs.maxclients - 1 do
begin
if svs.clients[i].active and (svs.clients[i].edict.v.health <= 0) then
begin
Con_Printf('Can''t savegame with a dead player'#10);
exit;
end;
end;
sprintf(name, '%s/%s', [com_gamedir, Cmd_Argv_f(1)]);
COM_DefaultExtension(name, '.sav');
Con_Printf('Saving game to %s...'#10, [name]);
if not fopen(name, 'w', f) then
begin
Con_Printf('ERROR: couldn''t open.'#10);
exit;
end;
fprintf(f, '%d'#10, [SAVEGAME_VERSION]);
Host_SavegameComment(comment);
fprintf(f, '%s'#10, [comment]);
for i := 0 to NUM_SPAWN_PARMS - 1 do
fprintf(f, '%f'#10, [svs.clients[0].spawn_parms[i]]);
fprintf(f, '%d'#10, [current_skill]);
fprintf(f, '%s'#10, [sv.name]);
fprintf(f, '%f'#10, [sv.time]);
// write the light styles
for i := 0 to MAX_LIGHTSTYLES - 1 do
begin
if sv.lightstyles[i] <> nil then
fprintf(f, '%s'#10, [sv.lightstyles[i]])
else
fprintf(f, 'm'#10);
end;
ED_WriteGlobals(f);
for i := 0 to sv.num_edicts - 1 do
begin
ED_Write(f, EDICT_NUM(i));
flush(f);
end;
fclose(f);
Con_Printf('done.'#10);
end;
(*
===============
Host_Loadgame_f
===============
*)
procedure Host_Loadgame_f;
var
name: array[0..MAX_OSPATH - 1] of char;
f: text;
mapname: array[0..MAX_QPATH - 1] of char;
time, tfloat: single;
str: array[0..32767] of char;
start: PChar;
i: integer;
r: char;
ent: Pedict_t;
entnum: integer;
version: integer;
spawn_parms: array[0..NUM_SPAWN_PARMS - 1] of single;
begin
if cmd_source <> src_command then
exit;
if Cmd_Argc_f <> 2 then
begin
Con_Printf('load <savename> : load a game'#10);
exit;
end;
cls.demonum := -1; // stop demo loop in case this fails
sprintf(name, '%s/%s', [com_gamedir, Cmd_Argv_f(1)]);
COM_DefaultExtension(name, '.sav');
// we can't call SCR_BeginLoadingPlaque, because too much stack space has
// been used. The menu calls it before stuffing loadgame command
// SCR_BeginLoadingPlaque ();
Con_Printf('Loading game from %s...'#10, [name]);
if not fopen(name, 'r', f) then
begin
Con_Printf('ERROR: couldn''t open.'#10);
exit;
end;
fscanf(f, version);
if version <> SAVEGAME_VERSION then
begin
fclose(f);
Con_Printf('Savegame is version %d, not %d'#10, [version, SAVEGAME_VERSION]);
exit;
end;
fscanf(f, str);
for i := 0 to NUM_SPAWN_PARMS - 1 do
fscanf(f, spawn_parms[i]);
// this silliness is so we can load 1.06 save files, which have float skill values
fscanf(f, tfloat);
current_skill := intval(tfloat + 0.1);
Cvar_SetValue('skill', current_skill);
fscanf(f, mapname);
fscanf(f, time);
CL_Disconnect_f;
SV_SpawnServer(mapname);
if not sv.active then
begin
Con_Printf('Couldn''t load map'#10);
exit;
end;
sv.paused := true; // pause until all clients connect
sv.loadgame := true;
// load the light styles
for i := 0 to MAX_LIGHTSTYLES - 1 do
begin
fscanf(f, str);
sv.lightstyles[i] := Hunk_Alloc(strlen(str) + 1);
strcpy(sv.lightstyles[i], str);
end;
// load the edicts out of the savegame file
entnum := -1; // -1 is the globals
while not eof(f) do
begin
i := 0;
while i < SizeOf(str) - 1 do
begin
getc(f, r);
if eof(f) or (r = #0) then
break;
str[i] := r;
if r = '}' then
begin
inc(i);
break;
end;
inc(i);
end;
if i = SizeOf(str) - 1 then
Sys_Error('Loadgame buffer overflow');
str[i] := #0;
start := COM_Parse(str);
if com_token[0] = #0 then
break; // end of file
if strcmp(com_token, '{') <> 0 then
Sys_Error('First token isn''t a brace');
if entnum = -1 then
begin // parse the global vars
ED_ParseGlobals(start);
end
else
begin // parse an edict
ent := EDICT_NUM(entnum);
ZeroMemory(@ent.v, progs.entityfields * 4);
ent.free := false;
ED_ParseEdict(start, ent);
// link it into the bsp tree
if not ent.free then
SV_LinkEdict(ent, false);
end;
inc(entnum);
end;
sv.num_edicts := entnum;
sv.time := time;
fclose(f);
for i := 0 to NUM_SPAWN_PARMS - 1 do
svs.clients[0].spawn_parms[i] := spawn_parms[i];
if cls.state <> ca_dedicated then
begin
CL_EstablishConnection('local');
Host_Reconnect_f;
end;
end;
//============================================================================
(*
======================
Host_Name_f
======================
*)
procedure Host_Name_f;
var
newName: PChar;
begin
if Cmd_Argc_f = 1 then
begin
Con_Printf('"name" is "%s"'#10, [cl_name.text]);
exit;
end;
if Cmd_Argc_f = 2 then
newName := Cmd_Argv_f(1)
else
newName := Cmd_Args_f;
newName[15] := #0;
if cmd_source = src_command then
begin
if Q_strcmp(cl_name.text, newName) = 0 then
exit;
Cvar_Set('_cl_name', newName);
if cls.state = ca_connected then
Cmd_ForwardToServer;
exit;
end;
if boolval(host_client.name[0]) and boolval(strcmp(host_client.name, 'unconnected')) then
if Q_strcmp(host_client.name, newName) <> 0 then
Con_Printf('%s renamed to %s'#10, [host_client.name, newName]);
Q_strcpy(host_client.name, newName);
host_client.edict.v.netname := integer(@host_client.name) - integer(pr_strings); // JVAL SOS
// send notification to all clients
MSG_WriteByte(@sv.reliable_datagram, svc_updatename);
MSG_WriteByte(@sv.reliable_datagram, (integer(host_client) - integer(svs.clients)) div SizeOf(client_t));
MSG_WriteString(@sv.reliable_datagram, host_client.name);
end;
procedure Host_Version_f;
begin
Con_Printf('Version %4.2f'#10, [VERSION]);
Con_Printf('Exe: %s %s'#10, [__TIME__, __DATE__]); // JVAL change this, how???
end;
procedure Host_Say(teamonly: qboolean);
var
client: Pclient_t;
save: Pclient_t;
j: integer;
p: PChar;
text: array[0..64] of char;
fromServer: qboolean;
begin
fromServer := false;
if cmd_source = src_command then
begin
if cls.state = ca_dedicated then
begin
fromServer := true;
teamonly := false;
end
else
begin
Cmd_ForwardToServer;
exit;
end;
end;
if Cmd_Argc_f < 2 then
exit;
save := host_client;
p := Cmd_Args_f;
// remove quotes if present
if p^ = '"' then
begin
inc(p);
p[Q_strlen(p) - 1] := #0;
end;
// turn on color set 1
if not fromServer then
sprintf(text, '%s%s: ', [Chr(1), save.name]) // JVAL check formating string!
else
sprintf(text, '%s<%s> ', [Chr(1), hostname.text]); // JVAL check formating string!
j := SizeOf(text) - 2 - Q_strlen(text); // -2 for /n and null terminator
if Q_strlen(p) > j then
p[j] := #0;
strcat(text, p);
strcat(text, #10);
client := @svs.clients[0]; // JVAL check this
for j := 0 to svs.maxclients - 1 do
begin
if (client = nil) or not client.active or not client.spawned then
begin
inc(client);
continue;
end;
if (teamplay.value <> 0) and teamonly and (client.edict.v.team <> save.edict.v.team) then
begin
inc(client);
continue;
end;
host_client := client;
SV_ClientPrintf('%s', [text]);
inc(client);
end;
host_client := save;
Sys_Printf('%s', [@text[1]]);
end;
procedure Host_Say_f;
begin
Host_Say(false);
end;
procedure Host_Say_Team_f;
begin
Host_Say(true);
end;
procedure Host_Tell_f;
var
client: Pclient_t;
save: Pclient_t;
j: integer;
p: PChar;
text: array[0..63] of char;
begin
if cmd_source = src_command then
begin
Cmd_ForwardToServer;
exit;
end;
if Cmd_Argc_f < 3 then
exit;
Q_strcpy(text, host_client.name);
Q_strcat(text, ': ');
p := Cmd_Args_f;
// remove quotes if present
if p^ = '"' then
begin
inc(p);
p[Q_strlen(p) - 1] := #0;
end;
// check length & truncate if necessary
j := SizeOf(text) - 2 - Q_strlen(text); // -2 for /n and null terminator
if Q_strlen(p) > j then
p[j] := #0;
strcat(text, p);
strcat(text, #10);
save := host_client;
client := @svs.clients[0]; // JVAL check this
for j := 0 to svs.maxclients - 1 do
begin
if not client.active or not client.spawned then
begin
inc(client);
continue;
end;
if Q_strcasecmp(client.name, Cmd_Argv_f(1)) <> 0 then
begin
inc(client);
continue;
end;
host_client := client;
SV_ClientPrintf('%s', [text]);
break;
end;
host_client := save;
end;
(*
==================
Host_Color_f
==================
*)
procedure Host_Color_f;
var
top, bottom: integer;
playercolor: integer;
begin
if Cmd_Argc_f = 1 then
begin
Con_Printf('"color" is "%d %d"'#10, [(intval(cl_color.value) shr 4), intval(cl_color.value) and $0F]);
Con_Printf('color <0-13> [0-13]'#10);
exit;
end;
if Cmd_Argc_f = 2 then
begin
top := atoi(Cmd_Argv_f(1));
bottom := top;
end
else
begin
top := atoi(Cmd_Argv_f(1));
bottom := atoi(Cmd_Argv_f(2));
end;
top := top and 15; // JVAL mayby same proc inside func to adjust top & bottom
if top > 13 then
top := 13;
bottom := bottom and 15;
if bottom > 13 then
bottom := 13;
playercolor := top * 16 + bottom;
if cmd_source = src_command then
begin
Cvar_SetValue('_cl_color', playercolor);
if cls.state = ca_connected then
Cmd_ForwardToServer;
exit;
end;
host_client.colors := playercolor;
host_client.edict.v.team := bottom + 1;
// send notification to all clients
MSG_WriteByte(@sv.reliable_datagram, svc_updatecolors);
MSG_WriteByte(@sv.reliable_datagram, (integer(host_client) - integer(svs.clients)) div SizeOf(client_t));
MSG_WriteByte(@sv.reliable_datagram, host_client.colors);
end;
(*
==================
Host_Kill_f
==================
*)
procedure Host_Kill_f;
begin
if cmd_source = src_command then
begin
Cmd_ForwardToServer;
exit;
end;
if sv_player.v.health <= 0 then
begin
SV_ClientPrintf('Can''t suicide -- allready dead!'#10);
exit;
end;
pr_global_struct.time := sv.time;
pr_global_struct.self := EDICT_TO_PROG(sv_player);
PR_ExecuteProgram(pr_global_struct.ClientKill);
end;