-
Notifications
You must be signed in to change notification settings - Fork 655
Expand file tree
/
Copy pathsv_gameapi.cpp
More file actions
3160 lines (2605 loc) · 105 KB
/
sv_gameapi.cpp
File metadata and controls
3160 lines (2605 loc) · 105 KB
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) 2013 - 2015, OpenJK contributors
This file is part of the OpenJK source code.
OpenJK is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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, see <http://www.gnu.org/licenses/>.
===========================================================================
*/
// sv_gameapi.cpp -- interface to the game dll
//Anything above this #include will be ignored by the compiler
#include "server.h"
#include "botlib/botlib.h"
#include "qcommon/stringed_ingame.h"
#include "qcommon/RoffSystem.h"
#include "ghoul2/ghoul2_shared.h"
#include "qcommon/cm_public.h"
#include "icarus/GameInterface.h"
#include "qcommon/timing.h"
#include "NPCNav/navigator.h"
botlib_export_t *botlib_export;
// game interface
static gameExport_t *ge; // game export table
static vm_t *gvm; // game vm, valid for legacy and new api
//
// game vmMain calls
//
void GVM_InitGame( int levelTime, int randomSeed, int restart ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_INIT, levelTime, randomSeed, restart );
return;
}
VMSwap v( gvm );
ge->InitGame( levelTime, randomSeed, restart );
}
void GVM_ShutdownGame( int restart ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_SHUTDOWN, restart );
return;
}
VMSwap v( gvm );
ge->ShutdownGame( restart );
}
char *GVM_ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) {
if ( gvm->isLegacy )
return (char *)VM_Call( gvm, GAME_CLIENT_CONNECT, clientNum, firstTime, isBot );
VMSwap v( gvm );
return ge->ClientConnect( clientNum, firstTime, isBot );
}
void GVM_ClientBegin( int clientNum ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_CLIENT_BEGIN, clientNum );
return;
}
VMSwap v( gvm );
ge->ClientBegin( clientNum, qtrue );
}
qboolean GVM_ClientUserinfoChanged( int clientNum ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_CLIENT_USERINFO_CHANGED, clientNum );
VMSwap v( gvm );
return ge->ClientUserinfoChanged( clientNum );
}
void GVM_ClientDisconnect( int clientNum ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_CLIENT_DISCONNECT, clientNum );
return;
}
VMSwap v( gvm );
ge->ClientDisconnect( clientNum );
}
void GVM_ClientCommand( int clientNum ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_CLIENT_COMMAND, clientNum );
return;
}
VMSwap v( gvm );
ge->ClientCommand( clientNum );
}
void GVM_ClientThink( int clientNum, usercmd_t *ucmd ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_CLIENT_THINK, clientNum, reinterpret_cast< intptr_t >( ucmd ) );
return;
}
VMSwap v( gvm );
ge->ClientThink( clientNum, ucmd );
}
void GVM_RunFrame( int levelTime ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_RUN_FRAME, levelTime );
return;
}
VMSwap v( gvm );
ge->RunFrame( levelTime );
}
qboolean GVM_ConsoleCommand( void ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_CONSOLE_COMMAND );
VMSwap v( gvm );
return ge->ConsoleCommand();
}
int GVM_BotAIStartFrame( int time ) {
if ( gvm->isLegacy )
return VM_Call( gvm, BOTAI_START_FRAME, time );
VMSwap v( gvm );
return ge->BotAIStartFrame( time );
}
void GVM_ROFF_NotetrackCallback( int entID, const char *notetrack ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ROFF_NOTETRACK_CALLBACK, entID, reinterpret_cast< intptr_t >( notetrack ) );
return;
}
VMSwap v( gvm );
ge->ROFF_NotetrackCallback( entID, notetrack );
}
void GVM_SpawnRMGEntity( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_SPAWN_RMG_ENTITY );
return;
}
VMSwap v( gvm );
ge->SpawnRMGEntity();
}
int GVM_ICARUS_PlaySound( void ) {
if ( gvm->isLegacy )
return VM_Call( gvm, GAME_ICARUS_PLAYSOUND );
VMSwap v( gvm );
return ge->ICARUS_PlaySound();
}
qboolean GVM_ICARUS_Set( void ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_ICARUS_SET );
VMSwap v( gvm );
return ge->ICARUS_Set();
}
void GVM_ICARUS_Lerp2Pos( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_LERP2POS );
return;
}
VMSwap v( gvm );
ge->ICARUS_Lerp2Pos();
}
void GVM_ICARUS_Lerp2Origin( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_LERP2ORIGIN );
return;
}
VMSwap v( gvm );
ge->ICARUS_Lerp2Origin();
}
void GVM_ICARUS_Lerp2Angles( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_LERP2ANGLES );
return;
}
VMSwap v( gvm );
ge->ICARUS_Lerp2Angles();
}
int GVM_ICARUS_GetTag( void ) {
if ( gvm->isLegacy )
return VM_Call( gvm, GAME_ICARUS_GETTAG );
VMSwap v( gvm );
return ge->ICARUS_GetTag();
}
void GVM_ICARUS_Lerp2Start( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_LERP2START );
return;
}
VMSwap v( gvm );
ge->ICARUS_Lerp2Start();
}
void GVM_ICARUS_Lerp2End( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_LERP2END );
return;
}
VMSwap v( gvm );
ge->ICARUS_Lerp2End();
}
void GVM_ICARUS_Use( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_USE );
return;
}
VMSwap v( gvm );
ge->ICARUS_Use();
}
void GVM_ICARUS_Kill( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_KILL );
return;
}
VMSwap v( gvm );
ge->ICARUS_Kill();
}
void GVM_ICARUS_Remove( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_REMOVE );
return;
}
VMSwap v( gvm );
ge->ICARUS_Remove();
}
void GVM_ICARUS_Play( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_PLAY );
return;
}
VMSwap v( gvm );
ge->ICARUS_Play();
}
int GVM_ICARUS_GetFloat( void ) {
if ( gvm->isLegacy )
return VM_Call( gvm, GAME_ICARUS_GETFLOAT );
VMSwap v( gvm );
return ge->ICARUS_GetFloat();
}
int GVM_ICARUS_GetVector( void ) {
if ( gvm->isLegacy )
return VM_Call( gvm, GAME_ICARUS_GETVECTOR );
VMSwap v( gvm );
return ge->ICARUS_GetVector();
}
int GVM_ICARUS_GetString( void ) {
if ( gvm->isLegacy )
return VM_Call( gvm, GAME_ICARUS_GETSTRING );
VMSwap v( gvm );
return ge->ICARUS_GetString();
}
void GVM_ICARUS_SoundIndex( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_ICARUS_SOUNDINDEX );
return;
}
VMSwap v( gvm );
ge->ICARUS_SoundIndex();
}
int GVM_ICARUS_GetSetIDForString( void ) {
if ( gvm->isLegacy )
return VM_Call( gvm, GAME_ICARUS_GETSETIDFORSTRING );
VMSwap v( gvm );
return ge->ICARUS_GetSetIDForString();
}
qboolean GVM_NAV_ClearPathToPoint( int entID, vec3_t pmins, vec3_t pmaxs, vec3_t point, int clipmask, int okToHitEnt ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_NAV_CLEARPATHTOPOINT, entID, reinterpret_cast< intptr_t >( pmins ), reinterpret_cast< intptr_t >( pmaxs ), reinterpret_cast< intptr_t >( point ), clipmask, okToHitEnt );
VMSwap v( gvm );
return ge->NAV_ClearPathToPoint( entID, pmins, pmaxs, point, clipmask, okToHitEnt );
}
qboolean GVM_NPC_ClearLOS2( int entID, const vec3_t end ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_NAV_CLEARLOS, entID, reinterpret_cast< intptr_t >( end ) );
VMSwap v( gvm );
return ge->NPC_ClearLOS2( entID, end );
}
int GVM_NAVNEW_ClearPathBetweenPoints( vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int ignore, int clipmask ) {
if ( gvm->isLegacy )
return VM_Call( gvm, GAME_NAV_CLEARPATHBETWEENPOINTS, reinterpret_cast< intptr_t >( start ), reinterpret_cast< intptr_t >( end ), reinterpret_cast< intptr_t >( mins ), reinterpret_cast< intptr_t >( maxs ), ignore, clipmask );
VMSwap v( gvm );
return ge->NAVNEW_ClearPathBetweenPoints( start, end, mins, maxs, ignore, clipmask );
}
qboolean GVM_NAV_CheckNodeFailedForEnt( int entID, int nodeNum ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_NAV_CHECKNODEFAILEDFORENT, entID, nodeNum );
VMSwap v( gvm );
return ge->NAV_CheckNodeFailedForEnt( entID, nodeNum );
}
qboolean GVM_NAV_EntIsUnlockedDoor( int entityNum ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_NAV_ENTISUNLOCKEDDOOR, entityNum );
VMSwap v( gvm );
return ge->NAV_EntIsUnlockedDoor( entityNum );
}
qboolean GVM_NAV_EntIsDoor( int entityNum ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_NAV_ENTISDOOR, entityNum );
VMSwap v( gvm );
return ge->NAV_EntIsDoor( entityNum );
}
qboolean GVM_NAV_EntIsBreakable( int entityNum ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_NAV_ENTISBREAKABLE, entityNum );
VMSwap v( gvm );
return ge->NAV_EntIsBreakable( entityNum );
}
qboolean GVM_NAV_EntIsRemovableUsable( int entNum ) {
if ( gvm->isLegacy )
return (qboolean)VM_Call( gvm, GAME_NAV_ENTISREMOVABLEUSABLE, entNum );
VMSwap v( gvm );
return ge->NAV_EntIsRemovableUsable( entNum );
}
void GVM_NAV_FindCombatPointWaypoints( void ) {
if ( gvm->isLegacy ) {
VM_Call( gvm, GAME_NAV_FINDCOMBATPOINTWAYPOINTS );
return;
}
VMSwap v( gvm );
ge->NAV_FindCombatPointWaypoints();
}
int GVM_BG_GetItemIndexByTag( int tag, int type ) {
if ( gvm->isLegacy )
return VM_Call( gvm, GAME_GETITEMINDEXBYTAG, tag, type );
VMSwap v( gvm );
return ge->BG_GetItemIndexByTag( tag, type );
}
//
// game syscalls
// only used by legacy mods!
//
// legacy syscall
siegePers_t sv_siegePersData = {qfalse, 0, 0};
extern float g_svCullDist;
int CM_ModelContents( clipHandle_t model, int subBSPIndex );
int CM_LoadSubBSP( const char *name, qboolean clientload );
int CM_FindSubBSP( int modelIndex );
char *CM_SubBSPEntityString( int index );
qboolean Q3_TaskIDPending( sharedEntity_t *ent, taskID_t taskType );
void Q3_TaskIDSet( sharedEntity_t *ent, taskID_t taskType, int taskID );
void Q3_TaskIDComplete( sharedEntity_t *ent, taskID_t taskType );
void Q3_SetVar( int taskID, int entID, const char *type_name, const char *data );
int Q3_VariableDeclared( const char *name );
int Q3_GetFloatVariable( const char *name, float *value );
int Q3_GetStringVariable( const char *name, const char **value );
int Q3_GetVectorVariable( const char *name, vec3_t value );
void SV_BotWaypointReception( int wpnum, wpobject_t **wps );
void SV_BotCalculatePaths( int rmg );
static void SV_LocateGameData( sharedEntity_t *gEnts, int numGEntities, int sizeofGEntity_t, playerState_t *clients, int sizeofGameClient ) {
sv.gentities = gEnts;
sv.gentitySize = sizeofGEntity_t;
sv.num_entities = numGEntities;
sv.gameClients = clients;
sv.gameClientSize = sizeofGameClient;
}
static void SV_GameDropClient( int clientNum, const char *reason ) {
if ( clientNum < 0 || clientNum >= sv_maxclients->integer ) {
return;
}
SV_DropClient( svs.clients + clientNum, reason );
}
static void SV_GameSendServerCommand( int clientNum, const char *text ) {
if ( clientNum == -1 ) {
SV_SendServerCommand( NULL, "%s", text );
} else {
if ( clientNum < 0 || clientNum >= sv_maxclients->integer ) {
return;
}
SV_SendServerCommand( svs.clients + clientNum, "%s", text );
}
}
static qboolean SV_EntityContact( const vec3_t mins, const vec3_t maxs, const sharedEntity_t *gEnt, int capsule ) {
const float *origin, *angles;
clipHandle_t ch;
trace_t trace;
// check for exact collision
origin = gEnt->r.currentOrigin;
angles = gEnt->r.currentAngles;
ch = SV_ClipHandleForEntity( gEnt );
CM_TransformedBoxTrace ( &trace, vec3_origin, vec3_origin, mins, maxs,
ch, -1, origin, angles, capsule );
return (qboolean)trace.startsolid;
}
static void SV_SetBrushModel( sharedEntity_t *ent, const char *name ) {
clipHandle_t h;
vec3_t mins, maxs;
if (!name)
{
Com_Error( ERR_DROP, "SV_SetBrushModel: NULL" );
}
if (name[0] == '*')
{
ent->s.modelindex = atoi( name + 1 );
if (sv.mLocalSubBSPIndex != -1)
{
ent->s.modelindex += sv.mLocalSubBSPModelOffset;
}
h = CM_InlineModel( ent->s.modelindex );
CM_ModelBounds(h, mins, maxs);
VectorCopy (mins, ent->r.mins);
VectorCopy (maxs, ent->r.maxs);
ent->r.bmodel = qtrue;
ent->r.contents = CM_ModelContents( h, -1 );
}
else if (name[0] == '#')
{
ent->s.modelindex = CM_LoadSubBSP(va("maps/%s.bsp", name + 1), qfalse);
CM_ModelBounds( ent->s.modelindex, mins, maxs );
VectorCopy (mins, ent->r.mins);
VectorCopy (maxs, ent->r.maxs);
ent->r.bmodel = qtrue;
//rwwNOTE: We don't ever want to set contents -1, it includes CONTENTS_LIGHTSABER.
//Lots of stuff will explode if there's a brush with CONTENTS_LIGHTSABER that isn't attached to a client owner.
//ent->contents = -1; // we don't know exactly what is in the brushes
h = CM_InlineModel( ent->s.modelindex );
ent->r.contents = CM_ModelContents( h, CM_FindSubBSP(ent->s.modelindex) );
}
else
{
Com_Error( ERR_DROP, "SV_SetBrushModel: %s isn't a brush model", name );
}
}
static qboolean SV_inPVSIgnorePortals( const vec3_t p1, const vec3_t p2 ) {
int leafnum, cluster;
// int area1, area2;
byte *mask;
leafnum = CM_PointLeafnum( p1 );
cluster = CM_LeafCluster( leafnum );
// area1 = CM_LeafArea( leafnum );
mask = CM_ClusterPVS( cluster );
leafnum = CM_PointLeafnum( p2 );
cluster = CM_LeafCluster( leafnum );
// area2 = CM_LeafArea( leafnum );
if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) )
return qfalse;
return qtrue;
}
static void SV_GetServerinfo( char *buffer, int bufferSize ) {
if ( bufferSize < 1 ) {
Com_Error( ERR_DROP, "SV_GetServerinfo: bufferSize == %i", bufferSize );
return;
}
Q_strncpyz( buffer, Cvar_InfoString( CVAR_SERVERINFO ), bufferSize );
}
static void SV_AdjustAreaPortalState( sharedEntity_t *ent, qboolean open ) {
svEntity_t *svEnt;
svEnt = SV_SvEntityForGentity( ent );
if ( svEnt->areanum2 == -1 )
return;
CM_AdjustAreaPortalState( svEnt->areanum, svEnt->areanum2, open );
}
static void SV_GetUsercmd( int clientNum, usercmd_t *cmd ) {
if ( clientNum < 0 || clientNum >= sv_maxclients->integer ) {
Com_Error( ERR_DROP, "SV_GetUsercmd: bad clientNum:%i", clientNum );
return;
}
*cmd = svs.clients[clientNum].lastUsercmd;
}
static sharedEntity_t gLocalModifier;
static sharedEntity_t *ConvertedEntity( sharedEntity_t *ent ) { //Return an entity with the memory shifted around to allow reading/modifying VM memory
int i = 0;
assert(ent);
gLocalModifier.s = ent->s;
gLocalModifier.r = ent->r;
while (i < NUM_TIDS)
{
gLocalModifier.taskID[i] = ent->taskID[i];
i++;
}
i = 0;
gLocalModifier.parms = (parms_t *)VM_ArgPtr((intptr_t)ent->parms);
while (i < NUM_BSETS)
{
gLocalModifier.behaviorSet[i] = (char *)VM_ArgPtr((intptr_t)ent->behaviorSet[i]);
i++;
}
i = 0;
gLocalModifier.script_targetname = (char *)VM_ArgPtr((intptr_t)ent->script_targetname);
gLocalModifier.delayScriptTime = ent->delayScriptTime;
gLocalModifier.fullName = (char *)VM_ArgPtr((intptr_t)ent->fullName);
gLocalModifier.targetname = (char *)VM_ArgPtr((intptr_t)ent->targetname);
gLocalModifier.classname = (char *)VM_ArgPtr((intptr_t)ent->classname);
gLocalModifier.ghoul2 = ent->ghoul2;
return &gLocalModifier;
}
static const char *SV_SetActiveSubBSP( int index ) {
if ( index >= 0 ) {
sv.mLocalSubBSPIndex = CM_FindSubBSP( index );
sv.mLocalSubBSPModelOffset = index;
sv.mLocalSubBSPEntityParsePoint = CM_SubBSPEntityString( sv.mLocalSubBSPIndex );
return sv.mLocalSubBSPEntityParsePoint;
}
sv.mLocalSubBSPIndex = -1;
return NULL;
}
static qboolean SV_GetEntityToken( char *buffer, int bufferSize ) {
char *s;
if ( sv.mLocalSubBSPIndex == -1 ) {
s = COM_Parse( (const char **)&sv.entityParsePoint );
Q_strncpyz( buffer, s, bufferSize );
if ( !sv.entityParsePoint && !s[0] )
return qfalse;
else
return qtrue;
}
else {
s = COM_Parse( (const char **)&sv.mLocalSubBSPEntityParsePoint);
Q_strncpyz( buffer, s, bufferSize );
if ( !sv.mLocalSubBSPEntityParsePoint && !s[0] )
return qfalse;
else
return qtrue;
}
}
static void SV_PrecisionTimerStart( void **timer ) {
timing_c *newTimer = new timing_c; //create the new timer
*timer = newTimer; //assign the pointer within the pointer to point at the mem addr of our new timer
newTimer->Start(); //start the timer
}
static int SV_PrecisionTimerEnd( void *timer ) {
int r;
timing_c *theTimer = (timing_c *)timer; //this is the pointer we assigned in start, so we can directly cast it back
r = theTimer->End(); //get the result
delete theTimer; //delete the timer since we're done with it
return r; //return the result
}
static void SV_RegisterSharedMemory( char *memory ) {
sv.mSharedMemory = memory;
}
static void SV_SetServerCull( float cullDistance ) {
g_svCullDist = cullDistance;
}
static void SV_SiegePersSet( siegePers_t *siegePers ) {
sv_siegePersData = *siegePers;
}
static void SV_SiegePersGet( siegePers_t *siegePers ) {
*siegePers = sv_siegePersData;
}
qboolean SV_ROFF_Clean( void ) {
return theROFFSystem.Clean( qfalse );
}
void SV_ROFF_UpdateEntities( void ) {
theROFFSystem.UpdateEntities( qfalse );
}
int SV_ROFF_Cache( char *file ) {
return theROFFSystem.Cache( file, qfalse );
}
qboolean SV_ROFF_Play( int entID, int roffID, qboolean doTranslation ) {
return theROFFSystem.Play( entID, roffID, doTranslation, qfalse );
}
qboolean SV_ROFF_Purge_Ent( int entID ) {
return theROFFSystem.PurgeEnt( entID, qfalse );
}
static qboolean SV_ICARUS_RegisterScript( const char *name, qboolean bCalledDuringInterrogate ) {
return (qboolean)ICARUS_RegisterScript( name, bCalledDuringInterrogate );
}
static qboolean SV_ICARUS_ValidEnt( sharedEntity_t *ent ) {
return (qboolean)ICARUS_ValidEnt( ent );
}
static qboolean ICARUS_IsInitialized( int entID ) {
if ( !gSequencers[entID] || !gTaskManagers[entID] )
return qfalse;
return qtrue;
}
static qboolean ICARUS_MaintainTaskManager( int entID ) {
if ( gTaskManagers[entID] ) {
gTaskManagers[entID]->Update();
return qtrue;
}
return qfalse;
}
static qboolean ICARUS_IsRunning( int entID ) {
if ( !gTaskManagers[entID] || !gTaskManagers[entID]->IsRunning() )
return qfalse;
return qtrue;
}
static qboolean ICARUS_TaskIDPending( sharedEntity_t *ent, int taskID ) {
return Q3_TaskIDPending( ent, (taskID_t)taskID );
}
static void SV_ICARUS_TaskIDSet( sharedEntity_t *ent, int taskType, int taskID ) {
Q3_TaskIDSet( ent, (taskID_t)taskType, taskID );
}
static void SV_ICARUS_TaskIDComplete( sharedEntity_t *ent, int taskType ) {
Q3_TaskIDComplete( ent, (taskID_t)taskType );
}
static int SV_ICARUS_GetStringVariable( const char *name, const char *value ) {
const char *rec = (const char *)value;
return Q3_GetStringVariable( name, (const char **)&rec );
}
static int SV_ICARUS_GetVectorVariable( const char *name, const vec3_t value ) {
return Q3_GetVectorVariable( name, (float *)value );
}
static void SV_Nav_Init( void ) {
navigator.Init();
}
static void SV_Nav_Free( void ) {
navigator.Free();
}
static qboolean SV_Nav_Load( const char *filename, int checksum ) {
return (qboolean)navigator.Load( filename, checksum );
}
static qboolean SV_Nav_Save( const char *filename, int checksum ) {
return (qboolean)navigator.Save( filename, checksum );
}
static int SV_Nav_AddRawPoint( vec3_t point, int flags, int radius ) {
return navigator.AddRawPoint( point, flags, radius );
}
static void SV_Nav_CalculatePaths( qboolean recalc ) {
navigator.CalculatePaths( recalc );
}
static void SV_Nav_HardConnect( int first, int second ) {
navigator.HardConnect( first, second );
}
static void SV_Nav_ShowNodes( void ) {
navigator.ShowNodes();
}
static void SV_Nav_ShowEdges( void ) {
navigator.ShowEdges();
}
static void SV_Nav_ShowPath( int start, int end ) {
navigator.ShowPath( start, end );
}
static int SV_Nav_GetNearestNode( sharedEntity_t *ent, int lastID, int flags, int targetID ) {
return navigator.GetNearestNode( ent, lastID, flags, targetID );
}
static int SV_Nav_GetBestNode( int startID, int endID, int rejectID ) {
return navigator.GetBestNode( startID, endID, rejectID );
}
static int SV_Nav_GetNodePosition( int nodeID, vec3_t out ) {
return navigator.GetNodePosition( nodeID, out );
}
static int SV_Nav_GetNodeNumEdges( int nodeID ) {
return navigator.GetNodeNumEdges( nodeID );
}
static int SV_Nav_GetNodeEdge( int nodeID, int edge ) {
return navigator.GetNodeEdge( nodeID, edge );
}
static int SV_Nav_GetNumNodes( void ) {
return navigator.GetNumNodes();
}
static qboolean SV_Nav_Connected( int startID, int endID ) {
return (qboolean)navigator.Connected( startID, endID );
}
static int SV_Nav_GetPathCost( int startID, int endID ) {
return navigator.GetPathCost( startID, endID );
}
static int SV_Nav_GetEdgeCost( int startID, int endID ) {
return navigator.GetEdgeCost( startID, endID );
}
static int SV_Nav_GetProjectedNode( vec3_t origin, int nodeID ) {
return navigator.GetProjectedNode( origin, nodeID );
}
static void SV_Nav_CheckFailedNodes( sharedEntity_t *ent ) {
navigator.CheckFailedNodes( ent );
}
static void SV_Nav_AddFailedNode( sharedEntity_t *ent, int nodeID ) {
navigator.AddFailedNode( ent, nodeID );
}
static qboolean SV_Nav_NodeFailed( sharedEntity_t *ent, int nodeID ) {
return navigator.NodeFailed( ent, nodeID );
}
static qboolean SV_Nav_NodesAreNeighbors( int startID, int endID ) {
return navigator.NodesAreNeighbors( startID, endID );
}
static void SV_Nav_ClearFailedEdge( failedEdge_t *failedEdge ) {
navigator.ClearFailedEdge( failedEdge );
}
static void SV_Nav_ClearAllFailedEdges( void ) {
navigator.ClearAllFailedEdges();
}
static int SV_Nav_EdgeFailed( int startID, int endID ) {
return navigator.EdgeFailed( startID, endID );
}
static void SV_Nav_AddFailedEdge( int entID, int startID, int endID ) {
navigator.AddFailedEdge( entID, startID, endID );
}
static qboolean SV_Nav_CheckFailedEdge( failedEdge_t *failedEdge ) {
return navigator.CheckFailedEdge( failedEdge );
}
static void SV_Nav_CheckAllFailedEdges( void ) {
navigator.CheckAllFailedEdges();
}
static qboolean SV_Nav_RouteBlocked( int startID, int testEdgeID, int endID, int rejectRank ) {
return navigator.RouteBlocked( startID, testEdgeID, endID, rejectRank );
}
static int SV_Nav_GetBestNodeAltRoute( int startID, int endID, int *pathCost, int rejectID ) {
return navigator.GetBestNodeAltRoute( startID, endID, pathCost, rejectID );
}
static int SV_Nav_GetBestNodeAltRoute2( int startID, int endID, int rejectID ) {
return navigator.GetBestNodeAltRoute( startID, endID, rejectID );
}
static int SV_Nav_GetBestPathBetweenEnts( sharedEntity_t *ent, sharedEntity_t *goal, int flags ) {
return navigator.GetBestPathBetweenEnts( ent, goal, flags );
}
static int SV_Nav_GetNodeRadius( int nodeID ) {
return navigator.GetNodeRadius( nodeID );
}
static void SV_Nav_CheckBlockedEdges( void ) {
navigator.CheckBlockedEdges();
}
static void SV_Nav_ClearCheckedNodes( void ) {
navigator.ClearCheckedNodes();
}
static int SV_Nav_CheckedNode( int wayPoint, int ent ) {
return navigator.CheckedNode( wayPoint, ent );
}
static void SV_Nav_SetCheckedNode( int wayPoint, int ent, int value ) {
navigator.SetCheckedNode( wayPoint, ent, value );
}
static void SV_Nav_FlagAllNodes( int newFlag ) {
navigator.FlagAllNodes( newFlag );
}
static qboolean SV_Nav_GetPathsCalculated( void ) {
return navigator.pathsCalculated;
}
static void SV_Nav_SetPathsCalculated( qboolean newVal ) {
navigator.pathsCalculated = newVal;
}
static int SV_BotLoadCharacter( char *charfile, float skill ) {
return botlib_export->ai.BotLoadCharacter( charfile, skill );
}
static void SV_BotFreeCharacter( int character ) {
botlib_export->ai.BotFreeCharacter( character );
}
static float SV_Characteristic_Float( int character, int index ) {
return botlib_export->ai.Characteristic_Float( character, index );
}
static float SV_Characteristic_BFloat( int character, int index, float min, float max ) {
return botlib_export->ai.Characteristic_BFloat( character, index, min, max );
}
static int SV_Characteristic_Integer( int character, int index ) {
return botlib_export->ai.Characteristic_Integer( character, index );
}
static int SV_Characteristic_BInteger( int character, int index, int min, int max ) {
return botlib_export->ai.Characteristic_BInteger( character, index, min, max );
}
static void SV_Characteristic_String( int character, int index, char *buf, int size ) {
botlib_export->ai.Characteristic_String( character, index, buf, size );
}
static int SV_BotAllocChatState( void ) {
return botlib_export->ai.BotAllocChatState();
}
static void SV_BotFreeChatState( int handle ) {
botlib_export->ai.BotFreeChatState( handle );
}
static void SV_BotQueueConsoleMessage( int chatstate, int type, char *message ) {
botlib_export->ai.BotQueueConsoleMessage( chatstate, type, message );
}
static void SV_BotRemoveConsoleMessage( int chatstate, int handle ) {
botlib_export->ai.BotRemoveConsoleMessage( chatstate, handle );
}
static int SV_BotNextConsoleMessage( int chatstate, void *cm ) {
return botlib_export->ai.BotNextConsoleMessage( chatstate, (bot_consolemessage_s *)cm );
}
static int SV_BotNumConsoleMessages( int chatstate ) {
return botlib_export->ai.BotNumConsoleMessages( chatstate );
}
static void SV_BotInitialChat( int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 ) {
botlib_export->ai.BotInitialChat( chatstate, type, mcontext, var0, var1, var2, var3, var4, var5, var6, var7 );
}
static int SV_BotReplyChat( int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 ) {
return botlib_export->ai.BotReplyChat( chatstate, message, mcontext, vcontext, var0, var1, var2, var3, var4, var5, var6, var7 );
}
static int SV_BotChatLength( int chatstate ) {
return botlib_export->ai.BotChatLength( chatstate );
}
static void SV_BotEnterChat( int chatstate, int client, int sendto ) {
botlib_export->ai.BotEnterChat( chatstate, client, sendto );
}
static int SV_StringContains( char *str1, char *str2, int casesensitive ) {
return botlib_export->ai.StringContains( str1, str2, casesensitive );
}
static int SV_BotFindMatch( char *str, void *match, unsigned long int context ) {
return botlib_export->ai.BotFindMatch( str, (bot_match_s *)match, context );
}
static void SV_BotMatchVariable( void *match, int variable, char *buf, int size ) {
botlib_export->ai.BotMatchVariable( (bot_match_s *)match, variable, buf, size );
}
static void SV_UnifyWhiteSpaces( char *string ) {
botlib_export->ai.UnifyWhiteSpaces( string );
}
static void SV_BotReplaceSynonyms( char *string, unsigned long int context ) {
botlib_export->ai.BotReplaceSynonyms( string, context );
}
static int SV_BotLoadChatFile( int chatstate, char *chatfile, char *chatname ) {
return botlib_export->ai.BotLoadChatFile( chatstate, chatfile, chatname );
}
static void SV_BotSetChatGender( int chatstate, int gender ) {
botlib_export->ai.BotSetChatGender( chatstate, gender );
}
static void SV_BotSetChatName( int chatstate, char *name, int client ) {
botlib_export->ai.BotSetChatName( chatstate, name, client );
}
static void SV_BotResetGoalState( int goalstate ) {
botlib_export->ai.BotResetGoalState( goalstate );
}