-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhost_cmd.c
2304 lines (1956 loc) · 47.8 KB
/
host_cmd.c
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
/*
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.
*/
// host_cmd.c
#include <stdarg.h>
#include "quakedef.h"
extern cvar_t pausable, host_mapname;
extern qboolean allow_postcache;
//extern cvar_t sv_protocol;
// these two are not intended to be set directly
cvar_t cl_name = {"_cl_name", "player", CVAR_FLAG_ARCHIVE};
cvar_t cl_color = {"_cl_color", "0", CVAR_FLAG_ARCHIVE};
#ifndef RQM_SV_ONLY
cvar_t cl_confirmquit = {"cl_confirmquit", "1", CVAR_FLAG_ARCHIVE};
#endif
#ifdef HEXEN2_SUPPORT
extern cvar_t cl_playerclass;
#ifndef RQM_SV_ONLY
extern int loading_stage;
#endif
// unsigned int info_mask, info_mask2;
static double old_time;
#endif
/*
==================
Host_Quit
==================
*/
void Host_Quit (void)
{
// host_quitting = true;
#ifndef RQM_SV_ONLY
CL_Disconnect (true);
#endif
Host_ShutdownServer (false);
Sys_Quit ();
}
/*
==================
Host_Quit_f
==================
*/
void Host_Quit_f (cmd_source_t src)
{
#ifndef RQM_SV_ONLY
if (cl_confirmquit.value)
{
// JDH: added ca_connected case
//if ((key_dest != key_console && cls.state != ca_dedicated) || (cls.state == ca_connected))
if (cls.state != ca_dedicated)
{
M_Menu_Quit_f (src);
return;
}
}
#endif
Host_Quit ();
}
/*
==================
Host_Status_f
==================
*/
void Host_Status_f (cmd_source_t src)
{
client_t *client;
int seconds, minutes, hours = 0, j;
qboolean (*print)(const char *msg);
if (src != SRC_CLIENT)
{
#ifndef RQM_SV_ONLY
if (!sv.active)
{
Cmd_ForwardToServer (src);
return;
}
#endif
print = Con_Print;
}
else
{
print = Host_PrintToClient;
}
print (va("host: %s\n", Cvar_VariableString("hostname")));
print (va("version: reQuiem %s\n", REQUIEM_VERSION));
if (tcpipAvailable)
print (va("tcp/ip: %s\n", my_tcpip_address));
if (ipxAvailable)
print (va("ipx: %s\n", my_ipx_address));
print (va("map: %s\n", sv.name));
print (va("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients));
for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
{
if (!client->active)
continue;
seconds = (int)(net_time - client->netconnection->connecttime);
minutes = seconds / 60;
if (minutes)
{
seconds -= (minutes * 60);
hours = minutes / 60;
if (hours)
minutes -= (hours * 60);
}
else
{
hours = 0;
}
print (va("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name,
(int)client->edict->v.frags, hours, minutes, seconds));
print (va(" %s\n", client->netconnection->address));
}
}
/*
==================
Host_God_f
Sets client to godmode
==================
*/
void Host_God_f (cmd_source_t src)
{
qboolean on;
#ifndef RQM_SV_ONLY
if (src != SRC_CLIENT)
{
Cmd_ForwardToServer (src);
return;
}
#endif
if (PR_GLOBAL(deathmatch))
return;
#ifdef HEXEN2_SUPPORT
if (hexen2 && (PR_GLOBAL(coop) || skill.value > 2))
return;
#endif
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
on = (int)sv_player->v.flags & FL_GODMODE;
SV_ClientPrintf (host_client, "godmode %s\n", on ? "ON" : "OFF");
}
void Host_Notarget_f (cmd_source_t src)
{
qboolean on;
#ifndef RQM_SV_ONLY
if (src != SRC_CLIENT)
{
Cmd_ForwardToServer (src);
return;
}
#endif
if (PR_GLOBAL(deathmatch))
return;
#ifdef HEXEN2_SUPPORT
if (hexen2 && (skill.value > 2))
return;
#endif
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
on = (int)sv_player->v.flags & FL_NOTARGET;
SV_ClientPrintf (host_client, "notarget %s\n", on ? "ON" : "OFF");
}
qboolean noclip_anglehack;
void Host_Noclip_f (cmd_source_t src)
{
#ifndef RQM_SV_ONLY
if (src != SRC_CLIENT)
{
Cmd_ForwardToServer (src);
return;
}
#endif
if (PR_GLOBAL(deathmatch))
return;
#ifdef HEXEN2_SUPPORT
if (hexen2 && (PR_GLOBAL(coop) || skill.value > 2))
return;
#endif
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
{
sv_player->v.movetype = MOVETYPE_NOCLIP;
noclip_anglehack = true;
}
else
{
sv_player->v.movetype = MOVETYPE_WALK;
noclip_anglehack = false;
}
SV_ClientPrintf (host_client, "noclip %s\n", noclip_anglehack ? "ON" : "OFF");
}
/*
==================
Host_Fly_f
Sets client to flymode
==================
*/
void Host_Fly_f (cmd_source_t src)
{
qboolean flyon;
#ifndef RQM_SV_ONLY
if (src != SRC_CLIENT)
{
Cmd_ForwardToServer (src);
return;
}
#endif
if (PR_GLOBAL(deathmatch))
return;
if (sv_player->v.movetype != MOVETYPE_FLY)
{
sv_player->v.movetype = MOVETYPE_FLY;
flyon = true;
}
else
{
sv_player->v.movetype = MOVETYPE_WALK;
flyon = false;
}
SV_ClientPrintf (host_client, "flymode %s\n", flyon ? "ON" : "OFF");
}
/*
==================
Host_Ping_f
==================
*/
void Host_Ping_f (cmd_source_t src)
{
int i, j;
float total;
client_t *client;
#ifndef RQM_SV_ONLY
const char *n; // joe, from ProQuake: for ping +N
if (src != SRC_CLIENT)
{
// JPG - check for ping +N
if (Cmd_Argc() == 2)
{
if (cls.state != ca_connected)
return;
n = Cmd_Argv (1);
if (*n == '+')
{
Cvar_Set ("pq_lag", n+1);
return;
}
}
// cl.console_ping = true; // joe: FIXME
Cmd_ForwardToServer (src);
return;
}
#endif
SV_ClientPrint (host_client, "Client ping times:\n");
for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
{
if (!client->active)
continue;
total = 0;
for (j=0 ; j<NUM_PING_TIMES ; j++)
total += client->ping_times[j];
total /= NUM_PING_TIMES;
SV_ClientPrintf (host_client, "%4i %s\n", (int)(total*1000), client->name);
}
}
/*
===============================================================================
SERVER TRANSITIONS
===============================================================================
*/
/*
======================
Host_Map_f
handle a
map <servername>
command from the console. Active clients are kicked off.
======================
*/
void Host_Map_f (cmd_source_t src)
{
int i, len;
char name[MAX_QPATH];
if (src == SRC_CLIENT)
return; // client can't tell server to change maps
#ifndef RQM_SV_ONLY
if (nehahra && (NehGameType == NEH_TYPE_DEMO))
{
M_Menu_Main_f (src);
return;
}
#endif
if (Cmd_Argc() < 2) // no map name given
{
Con_Print ("map <levelname>: start a new server\n");
#ifndef RQM_SV_ONLY
if (cl.levelname[0])
Con_Printf (" Currently on: \"%s\" (%s)\n", cl.levelname, host_mapname.string);
//Con_Printf ("%s\n", cls.mapstring);
#endif
return;
}
#ifndef RQM_SV_ONLY
cls.demonum = -1; // stop demo loop in case this fails
CL_Disconnect (false);
#endif
Host_ShutdownServer (false);
#ifndef RQM_SV_ONLY
key_dest = key_game; // remove console or menu
SCR_BeginLoadingPlaque (Cmd_Argv(1));
cls.mapstring[0] = 0;
len = 0;
for (i=0 ; i < Cmd_Argc() ; i++)
{
len += Q_strcpy (cls.mapstring + len, Cmd_Argv(i), sizeof(cls.mapstring)-len);
len += Q_strcpy (cls.mapstring + len, " ", sizeof(cls.mapstring)-len);
}
Q_strcpy (cls.mapstring + len, "\n", sizeof(cls.mapstring)-len);
#endif
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
sv.info_mask = 0;
if (!coop.value && deathmatch.value)
sv.info_mask2 = 0x80000000;
else
sv.info_mask2 = 0;
}
#endif
svs.serverflags = 0; // haven't completed an episode yet
len = Q_strcpy (name, Cmd_Argv(1), sizeof(name));
if ((len > 4) && COM_FilenamesEqual(name+len-4, ".bsp"))
name[len-4] = 0;
#ifdef HEXEN2_SUPPORT
SV_SpawnServer (name, NULL);
#else
SV_SpawnServer (name);
#endif
if (!sv.active)
return;
#ifndef RQM_SV_ONLY
if (cls.state != ca_dedicated)
{
#ifdef HEXEN2_SUPPORT
if (hexen2)
loading_stage = 2;
#endif
cls.spawnparms[0] = 0;
len = 0;
for (i=2 ; i<Cmd_Argc() ; i++)
{
len += Q_strcpy (cls.spawnparms + len, Cmd_Argv(i), sizeof(cls.spawnparms)-len);
len += Q_strcpy (cls.spawnparms + len , " ", sizeof(cls.spawnparms)-len);
}
Cmd_ExecuteString ("connect local", SRC_COMMAND);
}
#endif
}
/*
==================
Host_Changelevel_f
Goes to a new map, taking all clients along
==================
*/
void Host_Changelevel_f (cmd_source_t src)
{
char level[MAX_QPATH];
qboolean spawned;
#ifdef HEXEN2_SUPPORT
char _startspot[MAX_QPATH];
char *startspot;
#endif
if (Cmd_Argc() != 2)
{
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
if (Cmd_Argc() != 3)
{
Con_Print ("changelevel <levelname> [<startspot>]: continue game on a new level in the unit\n");
return;
}
}
else
#endif
{
Con_Print ("changelevel <levelname> : continue game on a new level\n");
return;
}
}
if (!sv.active /*|| cls.demoplayback*/)
{
Con_Print ("Only the server may changelevel\n");
return;
}
SV_SaveSpawnparms ();
Q_strcpy (level, Cmd_Argv(1), sizeof(level));
#ifdef HEXEN2_SUPPORT
if (!hexen2 || (Cmd_Argc() == 2))
startspot = NULL;
else
{
Q_strcpy (_startspot, Cmd_Argv(2), sizeof(_startspot));
startspot = _startspot;
}
spawned = SV_SpawnServer (level, startspot);
#else
spawned = SV_SpawnServer (level);
#endif
#ifndef RQM_SV_ONLY
if (!spawned)
CL_Disconnect_f (SRC_COMMAND);
#endif
}
#ifdef HEXEN2_SUPPORT
/*
==================
Host_RestoreClients
==================
*/
void Host_RestoreClients (void)
{
int i,j;
edict_t *ent;
double time_diff;
if (!Host_LoadGamestate (NULL, NULL, 1))
return;
time_diff = sv.time - old_time;
for (i=0,host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
{
if (host_client->active)
{
ent = host_client->edict;
ent->v.team = (host_client->colors & 15) + 1;
ent->v.netname = host_client->name - pr_strings;
ent->v.playerclass = host_client->playerclass;
// copy spawn parms out of the client_t
for (j=0 ; j< NUM_SPAWN_PARMS ; j++)
(pr_global_ptrs.parm1)[j] = host_client->spawn_parms[j];
// call the spawn function
*pr_global_ptrs.time = sv.time;
*pr_global_ptrs.self = EDICT_TO_PROG(ent);
G_FLOAT(OFS_PARM0) = time_diff;
PR_ExecuteProgram (*pr_global_ptrs.ClientReEnter);
}
}
Host_SaveGamestate(true);
}
/*
==================
Host_Changelevel2_f
- changing levels within a unit
==================
*/
void Host_Changelevel2_f (cmd_source_t src)
{
char level[MAX_QPATH];
char _startspot[MAX_QPATH];
char *startspot;
if (Cmd_Argc() < 3)
{
Con_Print ("changelevel2 <levelname> <startspot>: continue game on a new level in the unit\n");
return;
}
if (!sv.active /*|| cls.demoplayback*/)
{
Con_Print ("Only the server may changelevel2\n");
return;
}
Q_strcpy (level, Cmd_Argv(1), sizeof(level));
if (Cmd_Argc() == 2)
startspot = NULL;
else
{
Q_strcpy (_startspot, Cmd_Argv(2), sizeof(_startspot));
startspot = _startspot;
}
SV_SaveSpawnparms ();
// save the current level's state
old_time = sv.time;
Host_SaveGamestate (false);
// try to restore the new level
if (!Host_LoadGamestate (level, startspot, 0))
{
SV_SpawnServer (level, startspot);
Host_RestoreClients ();
}
}
#endif
/*
==================
Host_Restart_f
Restarts the current server for a dead player
==================
*/
void Host_Restart_f (cmd_source_t src)
{
char mapname[MAX_QPATH];
#ifdef HEXEN2_SUPPORT
char startspot[MAX_QPATH];
#endif
if (!sv.active /*||cls.demoplayback*/)
return;
if (src == SRC_CLIENT)
return;
Q_strcpy (mapname, sv.name, sizeof(mapname)); // must copy out, because it gets cleared in sv_spawnserver
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
if ((Cmd_Argc() == 2) && !Q_strcasecmp(Cmd_Argv(1),"restore"))
{
if (!Host_LoadGamestate (mapname, startspot, 3))
{
SV_SpawnServer (mapname, startspot);
Host_RestoreClients ();
}
}
else
{
SV_SpawnServer (mapname, startspot);
}
}
else SV_SpawnServer (mapname, NULL);
#else
SV_SpawnServer (mapname);
#endif
}
#ifndef RQM_SV_ONLY
/*
==================
Host_Reconnect_f
This command causes the client to wait for the signon messages again.
This is sent just before a server changes levels
==================
*/
void Host_Reconnect_f (cmd_source_t src)
{
const char *mapname;
extern float scr_centertime_off;
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
R_ClearParticles (); //jfm: for restarts which didn't use to clear parts.
if (/*oem.value &&*/ cl.intermission == 9)
{
CL_Disconnect (false);
return;
}
}
#endif
scr_centertime_off = 0;
mapname = (Cmd_Argc() > 1 ? Cmd_Argv(1) : NULL); // JDH
SCR_BeginLoadingPlaque (mapname);
cls.signon = 0; // need new connection messages
}
extern char server_name[MAX_QPATH];
/*
=====================
Host_Connect_f
User command to connect to server
=====================
*/
void Host_Connect_f (cmd_source_t src)
{
char name[MAX_QPATH];
extern cmd_arglist_t cmd_arglist;
cls.demonum = -1; // stop demo loop in case this fails
if (cls.demoplayback)
{
CL_StopPlayback ();
CL_Disconnect (false);
}
Q_strcpy (name, Cmd_Argv(1), sizeof(name));
CL_EstablishConnection (name);
cmd_arglist.argc = 1; // JDH: don't want Reconnect mistaking server name for map name
Host_Reconnect_f (src);
Q_strcpy (server_name, name, sizeof(server_name)); // added from ProQuake
}
#endif //#ifndef RQM_SV_ONLY
//============================================================================
/*
======================
Host_Name_f
======================
*/
void Host_Name_f (cmd_source_t src)
{
// char *newName;
const char *arg;
char newName[16];
#ifdef HEXEN2_SUPPORT
char *pdest;
#endif
if (Cmd_Argc() == 1)
{
Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
return;
}
arg = (Cmd_Argc() == 2) ? Cmd_Argv (1) : Cmd_Args (1);
Q_strcpy (newName, arg, sizeof(newName));
newName[15] = 0;
#ifdef HEXEN2_SUPPORT
//this is for the fuckers who put braces in the name causing loadgame to crash.
if (hexen2)
{
pdest = strchr(newName,'{');
if (pdest)
{
*pdest = 0; //zap the brace
Con_Print ("Illegal char in name removed!\n");
}
}
#endif
#ifndef RQM_SV_ONLY
if (src != SRC_CLIENT)
{
if (!strcmp(cl_name.string, newName))
return;
Cvar_SetDirect (&cl_name, newName);
if (cls.state == ca_connected)
Cmd_ForwardToServer (src);
return;
}
#endif
if (host_client->name[0] && strcmp(host_client->name, "unconnected"))
if (strcmp(host_client->name, newName))
Con_Printf ("%s renamed to %s\n", host_client->name, newName);
Q_strcpy (host_client->name, newName, sizeof(host_client->name));
host_client->edict->v.netname = host_client->name - pr_strings;
// send notification to all clients
MSG_WriteCmd (&sv.reliable_datagram, svc_updatename);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
MSG_WriteString (&sv.reliable_datagram, host_client->name);
}
#ifdef HEXEN2_SUPPORT
extern const char *ClassNames[NUM_CLASSES];
/*
======================
Host_Class_f
======================
*/
void Host_Class_f (cmd_source_t src)
{
float newClass;
if (Cmd_Argc () == 1)
{
if (!(int)cl_playerclass.value)
Con_Printf ("\"playerclass\" is %d (\"unknown\")\n", (int)cl_playerclass.value);
else
Con_Printf ("\"playerclass\" is %d (\"%s\")\n", (int)cl_playerclass.value, ClassNames[(int)cl_playerclass.value-1]);
return;
}
// if (Cmd_Argc () == 2)
newClass = Q_atof(Cmd_Argv(1));
// else
// newClass = Q_atof(Cmd_Args(1));
// if (!registered.value && !oem.value && (newClass == CLASS_CLERIC || newClass == CLASS_NECROMANCER))
// {
// Con_Print("That class is not available in the demo version.\n");
// return;
// }
#ifndef RQM_SV_ONLY
if (src != SRC_CLIENT)
{
Cvar_SetValueDirect (&cl_playerclass, newClass);
// when classes changes after map load, update cl_playerclass, cl_playerclass should
// probably only be used in worldspawn, though
if (pr_global_ptrs.cl_playerclass)
*pr_global_ptrs.cl_playerclass = newClass;
if (cls.state == ca_connected)
Cmd_ForwardToServer (src);
return;
}
#endif
if (sv.loadgame || host_client->playerclass)
{
if (host_client->edict->v.playerclass)
newClass = host_client->edict->v.playerclass;
else if (host_client->playerclass)
newClass = host_client->playerclass;
}
host_client->playerclass = newClass;
host_client->edict->v.playerclass = newClass;
// Change the weapon model used
*pr_global_ptrs.self = EDICT_TO_PROG(host_client->edict);
PR_ExecuteProgram (*pr_global_ptrs.ClassChangeWeapon);
// send notification to all clients
MSG_WriteCmd (&sv.reliable_datagram, svc_updateclass);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
MSG_WriteByte (&sv.reliable_datagram, (byte)newClass);
}
#endif // #ifdef HEXEN2_SUPPORT
/*
=========
Host_Say
=========
*/
void Host_Say (cmd_source_t src, qboolean teamonly)
{
client_t *client;
int j, len;
char *p;
char text[64], args[64];
qboolean fromServer = false;
#ifndef RQM_SV_ONLY
if (src != SRC_CLIENT)
{
if (cls.state == ca_dedicated)
{
fromServer = true;
teamonly = false;
}
else
{
Cmd_ForwardToServer (src);
return;
}
}
#else
fromServer = true;
teamonly = false;
#endif
if (Cmd_Argc () < 2)
return;
// p = Cmd_Args ();
len = Q_strcpy (args, Cmd_Args (1), sizeof(args));
p = args;
// remove quotes if present
if (*p == '"')
{
p++;
// p[strlen(p)-1] = 0;
if (p[len-2] == '"')
p[len-2] = 0;
}
// turn on color set 1
if (!fromServer)
len = Q_snprintfz (text, sizeof(text), "\x01""%s: ", host_client->name);
else
len = Q_snprintfz (text, sizeof(text), "\x01""<%s> ", hostname.string);
j = sizeof(text) - 2 - len; // -2 for \n and null terminator
if (strlen(p) > j)
p[j] = 0;
len += Q_strcpy (text+len, p, sizeof(text)-len);
Q_strcpy (text+len, "\n", sizeof(text)-len);
for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
{
if (!client || !client->active || !client->spawned)
continue;
if (teamplay.value && teamonly && client->edict->v.team != host_client->edict->v.team)
continue;
SV_ClientPrint (client, text);
}
Sys_Printf ("%s", &text[1]);
}
void Host_Say_f (cmd_source_t src)
{
Host_Say (src, false);
}
void Host_Say_Team_f (cmd_source_t src)
{
Host_Say (src, true);
}
void Host_Tell_f (cmd_source_t src)
{
client_t *client;
int j, len;
char text[64];
const char *p, *name;
#ifndef RQM_SV_ONLY
if (src != SRC_CLIENT)
{
Cmd_ForwardToServer (src);
return;
}
#endif
if (Cmd_Argc () < 3)
return;
p = Cmd_Args (2);
j = strlen (p);
// remove quotes if present
if (*p == '"')
{
p++;
j--;
if (p[j-1] == '"')
j--;
}
// len = Q_strcpy (text, host_client->name, sizeof(text));
// len += Q_strcpy (text+len, ": ", sizeof(text)-len);
name = Cmd_Argv (1);
len = Q_snprintfz (text, sizeof(text), "%s [to %s]: ", host_client->name, name);
len += Q_strncpy (text+len, sizeof(text)-len, p, j);
// check length & truncate if necessary
j = sizeof(text) - 2; // -2 for \n and null terminator
if (len > j)
{
text[j] = 0;
len = j;
}
Q_strcpy (text+len, "\n", sizeof(text)-len);
for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
{
if (!client->active || !client->spawned)
continue;
if (Q_strcasecmp(client->name, name))
continue;
SV_ClientPrint (client, text);
break;
}
}
/*
==================
Host_Color_f
==================
*/
void Host_Color_f (cmd_source_t src)
{
int top, bottom, playercolor;
if (Cmd_Argc() == 1)
{
Con_Printf ("player color is currently \"%i %i\" (%s = %d)\n", ((int)cl_color.value) >> 4,
((int)cl_color.value) & 0x0f, cl_color.name, (int)cl_color.value);
// Con_Printf ("color <0-13> [0-13]\n");
Con_Printf ("usage: color <top> [bottom]\n (values must be 0-13)\n");
return;
}
if (Cmd_Argc() == 2)
top = bottom = atoi(Cmd_Argv(1));
else
{
top = atoi(Cmd_Argv(1));
bottom = atoi(Cmd_Argv(2));
}
top &= 15;