-
Notifications
You must be signed in to change notification settings - Fork 721
Expand file tree
/
Copy pathcl_cgameapi.cpp
More file actions
2114 lines (1683 loc) · 70.4 KB
/
Copy pathcl_cgameapi.cpp
File metadata and controls
2114 lines (1683 loc) · 70.4 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/>.
===========================================================================
*/
// cl_cgameapi.cpp -- client system interaction with client game
#include "qcommon/cm_public.h"
#include "qcommon/RoffSystem.h"
#include "qcommon/stringed_ingame.h"
#include "qcommon/timing.h"
#include "client.h"
#include "cl_uiapi.h"
#include "botlib/botlib.h"
#include "snd_ambient.h"
#include "FXExport.h"
#include "FxUtil.h"
#include "qcommon/vm_local.h"
#include <unordered_map>
extern IHeapAllocator *G2VertSpaceClient;
extern botlib_export_t *botlib_export;
// cgame interface
static cgameExport_t *cge; // cgame export table
static vm_t *cgvm; // cgame vm, valid for legacy and new api
typedef std::unordered_map<g2handle_t, CGhoul2Info_v*> g2HandleToG2_m;
static g2HandleToG2_m g2Mapping;
static g2handle_t g2NextHandle = (g2handle_t)1; // Start at 1, because 0 has special meaning
static inline CGhoul2Info_v *CL_G2Map_GetG2FromHandle( g2handleptr_t g2h )
{ // Returns the pointer to the g2 object if the handle is valid
// Native libraries should not use the pointer, but in theory they could use
// it. Thus we don't perform any mapping for native libraries to avoid
// issues with custom modules.
if ( cgvm->dllHandle ) return (CGhoul2Info_v*)g2h;
g2handle_t g2handle = (g2handle_t)g2h;
g2HandleToG2_m::iterator ghlIt = g2Mapping.find(g2handle);
if (ghlIt == g2Mapping.end()) return NULL;
return g2Mapping[g2handle];
}
static inline CGhoul2Info_v **CL_G2Map_GetG2PtrFromHandle( g2handleptr_t *g2h )
{ // Returns a pointer to the g2 object pointer in the map so g2 functions can update the pointer
// Native libraries should not use the pointer, but in theory they could use
// it. Thus we don't perform any mapping for native libraries to avoid
// issues with custom modules.
if ( cgvm->dllHandle ) return (CGhoul2Info_v **)g2h;
g2handle_t g2handle = *((g2handle_t*)g2h);
if ( !g2handle )
{ // Special case: the g2 handle is not valid, yet. Return a pointer to a static temporary pointer. Insertion is handled by calling CL_G2Map_Update after calling the G2API
static CGhoul2Info_v *g2Tmp;
g2Tmp = NULL;
return &g2Tmp;
}
return &g2Mapping[g2handle];
}
static void CL_G2Map_Update( g2handleptr_t *g2h, CGhoul2Info_v *g2Ptr )
{ // Inserts and/or erases to/from the map and updates the handle pointer
if ( cgvm->dllHandle ) return;
g2handle_t *g2handle = (g2handle_t*)g2h;
if ( !*g2handle && g2Ptr )
{ // Got a 0 handle, but a non-0 pointer: add to map and set handle
// Unlikely to happen, but should we ever cycle through the whole integer range start searching for gaps
while ( CL_G2Map_GetG2FromHandle(g2NextHandle) || !g2NextHandle ) g2NextHandle++;
g2Mapping[g2NextHandle] = g2Ptr;
*g2handle = g2NextHandle++;
}
else if ( *g2h && !g2Ptr )
{ // Got a non-0 handle, but 0 pointer: remove from map and set handle to 0
g2Mapping.erase( *g2handle );
*g2handle = 0;
}
}
//
// cgame vmMain calls
//
void CGVM_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_INIT, serverMessageNum, serverCommandSequence, clientNum );
return;
}
VMSwap v( cgvm );
cge->Init( serverMessageNum, serverCommandSequence, clientNum );
}
void CGVM_Shutdown( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_SHUTDOWN );
return;
}
VMSwap v( cgvm );
cge->Shutdown();
}
qboolean CGVM_ConsoleCommand( void ) {
if ( cgvm->isLegacy ) {
return (qboolean)VM_Call( cgvm, CG_CONSOLE_COMMAND );
}
VMSwap v( cgvm );
return cge->ConsoleCommand();
}
void CGVM_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_DRAW_ACTIVE_FRAME, serverTime, stereoView, demoPlayback );
return;
}
VMSwap v( cgvm );
cge->DrawActiveFrame( serverTime, stereoView, demoPlayback );
}
int CGVM_CrosshairPlayer( void ) {
if ( cgvm->isLegacy ) {
return VM_Call( cgvm, CG_CROSSHAIR_PLAYER );
}
VMSwap v( cgvm );
return cge->CrosshairPlayer();
}
int CGVM_LastAttacker( void ) {
if ( cgvm->isLegacy ) {
return VM_Call( cgvm, CG_LAST_ATTACKER );
}
VMSwap v( cgvm );
return cge->LastAttacker();
}
void CGVM_KeyEvent( int key, qboolean down ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_KEY_EVENT, key, down );
return;
}
VMSwap v( cgvm );
cge->KeyEvent( key, down );
}
void CGVM_MouseEvent( int x, int y ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_MOUSE_EVENT, x, y );
return;
}
VMSwap v( cgvm );
cge->MouseEvent( x, y );
}
void CGVM_EventHandling( int type ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_EVENT_HANDLING, type );
return;
}
VMSwap v( cgvm );
cge->EventHandling( type );
}
int CGVM_PointContents( void ) {
if ( cgvm->isLegacy ) {
return VM_Call( cgvm, CG_POINT_CONTENTS );
}
VMSwap v( cgvm );
return cge->PointContents();
}
void CGVM_GetLerpOrigin( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_GET_LERP_ORIGIN );
return;
}
VMSwap v( cgvm );
cge->GetLerpOrigin();
}
void CGVM_GetLerpData( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_GET_LERP_DATA );
return;
}
VMSwap v( cgvm );
cge->GetLerpData();
}
void CGVM_Trace( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_TRACE );
return;
}
VMSwap v( cgvm );
cge->Trace();
}
void CGVM_G2Trace( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_G2TRACE );
return;
}
VMSwap v( cgvm );
cge->G2Trace();
}
void CGVM_G2Mark( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_G2MARK );
return;
}
VMSwap v( cgvm );
cge->G2Mark();
}
int CGVM_RagCallback( int callType ) {
if ( cgvm->isLegacy ) {
return VM_Call( cgvm, CG_RAG_CALLBACK, callType );
}
VMSwap v( cgvm );
return cge->RagCallback( callType );
}
qboolean CGVM_IncomingConsoleCommand( void ) {
if ( cgvm->isLegacy ) {
return (qboolean)VM_Call( cgvm, CG_INCOMING_CONSOLE_COMMAND );
}
VMSwap v( cgvm );
return cge->IncomingConsoleCommand();
}
qboolean CGVM_NoUseableForce( void ) {
if ( cgvm->isLegacy ) {
return (qboolean)VM_Call( cgvm, CG_GET_USEABLE_FORCE );
}
VMSwap v( cgvm );
return cge->NoUseableForce();
}
static size_t vec3_size = sizeof(vec3_t);
void CGVM_GetOrigin( int entID, vec3_t out ) {
if ( cgvm->isLegacy ) {
float *out_ptr;
float *out_ptr_vm;
if ( !cgvm->dllHandle ) {
out_ptr = (float*)VM_ExtraMemory_ClaimData(cgvm, (float*)out, vec3_size);
out_ptr_vm = (float*)VM_PtrToOffset( cgvm, (void*)out_ptr );
} else {
out_ptr_vm = out_ptr = out;
}
VM_Call( cgvm, CG_GET_ORIGIN, entID, reinterpret_cast< intptr_t >( out_ptr_vm ) );
if ( !cgvm->dllHandle ) {
// Memory may only be released in reverse order.
if ( out_ptr ) {
VectorCopy( out_ptr, out );
VM_ExtraMemory_Release( cgvm, vec3_size );
}
}
return;
}
VMSwap v( cgvm );
cge->GetOrigin( entID, out );
}
void CGVM_GetAngles( int entID, vec3_t out ) {
if ( cgvm->isLegacy ) {
float *out_ptr;
float *out_ptr_vm;
if ( !cgvm->dllHandle ) {
out_ptr = (float*)VM_ExtraMemory_ClaimData(cgvm, (float*)out, vec3_size);
out_ptr_vm = (float*)VM_PtrToOffset( cgvm, (void*)out_ptr );
} else {
out_ptr_vm = out_ptr = out;
}
VM_Call( cgvm, CG_GET_ANGLES, entID, reinterpret_cast< intptr_t >( out_ptr_vm ) );
if ( !cgvm->dllHandle ) {
// Memory may only be released in reverse order.
if ( out_ptr ) {
VectorCopy( out_ptr, out );
VM_ExtraMemory_Release( cgvm, vec3_size );
}
}
return;
}
VMSwap v( cgvm );
cge->GetAngles( entID, out );
}
trajectory_t *CGVM_GetOriginTrajectory( int entID ) {
if ( cgvm->isLegacy ) {
return (trajectory_t *)VM_Call( cgvm, CG_GET_ORIGIN_TRAJECTORY, entID );
}
VMSwap v( cgvm );
return cge->GetOriginTrajectory( entID );
}
trajectory_t *CGVM_GetAngleTrajectory( int entID ) {
if ( cgvm->isLegacy ) {
return (trajectory_t *)VM_Call( cgvm, CG_GET_ANGLE_TRAJECTORY, entID );
}
VMSwap v( cgvm );
return cge->GetAngleTrajectory( entID );
}
void CGVM_ROFF_NotetrackCallback( int entID, const char *notetrack ) {
if ( cgvm->isLegacy ) {
int notetrack_length = 0;
const char *notetrack_ptr;
if ( !cgvm->dllHandle ) {
notetrack_length = strlen( notetrack ) + 1; // +1 for the terminating 0-byte, which ClaimString automatically allocates, too
notetrack_ptr = (const char*)VM_PtrToOffset( cgvm, VM_ExtraMemory_ClaimString(cgvm, notetrack) );
} else {
notetrack_ptr = notetrack;
}
VM_Call( cgvm, CG_ROFF_NOTETRACK_CALLBACK, entID, reinterpret_cast< intptr_t >( notetrack_ptr ) );
if ( !cgvm->dllHandle ) {
// Memory may only be released in reverse order.
if ( notetrack_ptr && notetrack_length ) VM_ExtraMemory_Release( cgvm, notetrack_length );
}
return;
}
VMSwap v( cgvm );
cge->ROFF_NotetrackCallback( entID, notetrack );
}
void CGVM_MapChange( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_MAP_CHANGE );
return;
}
VMSwap v( cgvm );
cge->MapChange();
}
void CGVM_AutomapInput( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_AUTOMAP_INPUT );
return;
}
VMSwap v( cgvm );
cge->AutomapInput();
}
void CGVM_MiscEnt( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_MISC_ENT );
return;
}
VMSwap v( cgvm );
cge->MiscEnt();
}
void CGVM_CameraShake( void ) {
if ( cgvm->isLegacy ) {
VM_Call( cgvm, CG_FX_CAMERASHAKE );
return;
}
VMSwap v( cgvm );
cge->CameraShake();
}
//
// cgame syscalls
// only used by legacy mods!
//
extern int CL_GetValueForHidden( const char *s ); //cl_parse.cpp
extern qboolean cl_bUseFighterPitch; //cl_input.cpp
int CM_LoadSubBSP( const char *name, qboolean clientload ); //cm_load.cpp
void FX_FeedTrail( effectTrailArgStruct_t *a ); //FxPrimitives.cpp
// wrappers and such
static void CL_AddCgameCommand( const char *cmdName ) {
Cmd_AddCommand( cmdName, NULL );
}
static void CL_CM_LoadMap( const char *mapname, qboolean subBSP ) {
if ( subBSP ) CM_LoadSubBSP( va( "maps/%s.bsp", mapname+1 ), qfalse );
else CM_LoadMap( mapname, qtrue, NULL );
}
static void CL_GetGlconfig( glconfig_t *glconfig ) {
if ( cgvm->dllHandle ) {
// For native libraries we can just copy the struct over cause they should be identical
*glconfig = cls.glconfig;
} else {
// As the QVM is 32 bit internally the size of our glconfig_t is bigger on 64 bit, because of the 4 string
// pointers. Instead of just assigning the glconfig we have to manually copy it over.
glconfig_qvm_t *glconfig_qvm = (glconfig_qvm_t*)glconfig;
// We now reserve additional memory when loading the QVM. The QVM shouldn't try to access it on its own, but it
// is valid inside the QVM and if we set a pointer to it the QVM should be able to access it. Thus we now claim
// some of this extra memory in QVM-scope to write our glconfig strings in there and tell the QVM where to find
// them.
// FIXME: It would probably be a good idea to keep a reference to this extra memory ourselves in case a module
// decides to call this functions multiple times. Currently we would claim additional memory each time.
glconfig_qvm->renderer_string = VM_PtrToOffset( cgvm, VM_ExtraMemory_ClaimString( cgvm, cls.glconfig.renderer_string ) );
glconfig_qvm->vendor_string = VM_PtrToOffset( cgvm, VM_ExtraMemory_ClaimString( cgvm, cls.glconfig.vendor_string ) );
glconfig_qvm->version_string = VM_PtrToOffset( cgvm, VM_ExtraMemory_ClaimString( cgvm, cls.glconfig.version_string ) );
glconfig_qvm->extensions_string = VM_PtrToOffset( cgvm, VM_ExtraMemory_ClaimString( cgvm, cls.glconfig.extensions_string ) );
// Assign the rest of the values
glconfig_qvm->maxTextureSize = cls.glconfig.maxTextureSize;
glconfig_qvm->maxActiveTextures = cls.glconfig.maxActiveTextures;
glconfig_qvm->maxTextureFilterAnisotropy = cls.glconfig.maxTextureFilterAnisotropy;
glconfig_qvm->colorBits = cls.glconfig.colorBits;
glconfig_qvm->depthBits = cls.glconfig.depthBits;
glconfig_qvm->stencilBits = cls.glconfig.stencilBits;
glconfig_qvm->deviceSupportsGamma = cls.glconfig.deviceSupportsGamma;
glconfig_qvm->textureCompression = cls.glconfig.textureCompression;
glconfig_qvm->textureEnvAddAvailable = cls.glconfig.textureEnvAddAvailable;
glconfig_qvm->clampToEdgeAvailable = cls.glconfig.clampToEdgeAvailable;
glconfig_qvm->vidWidth = cls.glconfig.vidWidth;
glconfig_qvm->vidHeight = cls.glconfig.vidHeight;
glconfig_qvm->displayFrequency = cls.glconfig.displayFrequency;
glconfig_qvm->isFullscreen = cls.glconfig.isFullscreen;
glconfig_qvm->stereoEnabled = cls.glconfig.stereoEnabled;
}
}
static void CL_GetGameState( gameState_t *gs ) {
*gs = cl.gameState;
}
static void RegisterSharedMemory( char *memory ) {
cl.mSharedMemory = memory;
}
static int CL_Milliseconds( void ) {
return Sys_Milliseconds();
}
static void CL_AddReliableCommand2( const char *cmd ) {
CL_AddReliableCommand( cmd, qfalse );
}
static int CL_CM_RegisterTerrain( const char *config ) {
return 0;
}
extern int s_entityWavVol[MAX_GENTITIES];
static int CL_S_GetVoiceVolume( int entID ) {
return s_entityWavVol[entID];
}
static void CL_S_Shutup( qboolean shutup ) {
s_shutUp = shutup;
}
static void CL_R_AddRefEntityToScene( const refEntity_t *refEnt ) {
if ( cgvm->dllHandle ) {
// We can directly pass the refEnt for native libraries
re->AddRefEntityToScene( refEnt );
return;
}
// The renderer should look up the handle on its own, but as we have to stay compatible with the modular renderer
// system we can't change the renderer for this and have to meet its expectations instead...
// Get a copy of the refEntity data. For a QVM mod the ghoul2 pointer at the end might contain some additional data,
// because the QVM stores it as 32 bit and if the engine is 64 bit it is going to read slightly out of bounds of the
// struct in the QVM, but CL_G2Map_GetG2FromHandle should take care of that by casting.
refEntity_t refEntCopy = *refEnt;
// Get the ghoul2 instance from the handle
refEntCopy.ghoul2 = CL_G2Map_GetG2FromHandle( (g2handleptr_t)refEnt->ghoul2 );
// Pass our copy
re->AddRefEntityToScene( &refEntCopy );
}
static int CL_GetCurrentCmdNumber( void ) {
return cl.cmdNumber;
}
static void _CL_SetUserCmdValue( int stateValue, float sensitivityScale, float mPitchOverride, float mYawOverride, float mSensitivityOverride, int fpSel, int invenSel, qboolean fighterControls ) {
cl_bUseFighterPitch = fighterControls;
CL_SetUserCmdValue( stateValue, sensitivityScale, mPitchOverride, mYawOverride, mSensitivityOverride, fpSel, invenSel );
}
static void CL_OpenUIMenu( int menuID ) {
UIVM_SetActiveMenu( (uiMenuCommand_t)menuID );
}
static void CGFX_AddLine( vec3_t start, vec3_t end, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, int killTime, qhandle_t shader, int flags ) {
FX_AddLine( start, end, size1, size2, sizeParm, alpha1, alpha2, alphaParm, sRGB, eRGB, rgbParm, killTime, shader, flags );
}
static void CGFX_AddPoly( addpolyArgStruct_t *p ) {
FX_AddPoly( p->p, p->ev, p->numVerts, p->vel, p->accel, p->alpha1, p->alpha2, p->alphaParm, p->rgb1, p->rgb2, p->rgbParm, p->rotationDelta, p->bounce, p->motionDelay, p->killTime, p->shader, p->flags );
}
static void CGFX_AddBezier( addbezierArgStruct_t *b ) {
FX_AddBezier( b->start, b->end, b->control1, b->control1Vel, b->control2, b->control2Vel, b->size1, b->size2, b->sizeParm, b->alpha1, b->alpha2, b->alphaParm, b->sRGB, b->eRGB, b->rgbParm, b->killTime, b->shader, b->flags );
}
static void CGFX_AddPrimitive( effectTrailArgStruct_t *e ) {
FX_FeedTrail( e );
}
static void CGFX_AddSprite( addspriteArgStruct_t *s ) {
vec3_t rgb = { 1.0f, 1.0f, 1.0f };
FX_AddParticle( s->origin, s->vel, s->accel, s->scale, s->dscale, 0, s->sAlpha, s->eAlpha, 0, rgb, rgb, 0, s->rotation, 0, vec3_origin, vec3_origin, s->bounce, 0, 0, s->life, s->shader, s->flags );
}
static void CGFX_AddElectricity( addElectricityArgStruct_t *p ) {
FX_AddElectricity( p->start, p->end, p->size1, p->size2, p->sizeParm, p->alpha1, p->alpha2, p->alphaParm, p->sRGB, p->eRGB, p->rgbParm, p->chaos, p->killTime, p->shader, p->flags );
}
static qboolean CL_ROFF_Clean( void ) {
return theROFFSystem.Clean( qtrue );
}
static void CL_ROFF_UpdateEntities( void ) {
theROFFSystem.UpdateEntities( qtrue );
}
static int CL_ROFF_Cache( char *file ) {
return theROFFSystem.Cache( file, qtrue );
}
static qboolean CL_ROFF_Play( int entID, int roffID, qboolean doTranslation ) {
return theROFFSystem.Play( entID, roffID, doTranslation, qtrue );
}
static qboolean CL_ROFF_Purge_Ent( int entID ) {
return theROFFSystem.PurgeEnt( entID, qtrue );
}
static void CL_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) {
*snapshotNumber = cl.snap.messageNum;
*serverTime = cl.snap.serverTime;
}
static void CL_SetClientForceAngle( int time, vec3_t angle ) {
cl.cgameViewAngleForceTime = time;
VectorCopy(angle, cl.cgameViewAngleForce);
}
static void CL_PrecisionTimerStart( void **p ) {
timing_c *newTimer = new timing_c; //create the new timer
*p = newTimer; //assign the pointer within the pointer to point at the mem addr of our new timer
newTimer->Start(); //start the timer
}
static int CL_PrecisionTimerEnd( void *p ) {
int r = 0;
timing_c *timer = (timing_c *)p; //this is the pointer we assigned in start, so we can directly cast it back
r = timer->End(); //get the result
delete timer; //delete the timer since we're done with it
return r; //return the result
}
static void CL_RMG_Init( int /* terrainID */, const char * /* terrainInfo */ ) { }
static qboolean CGFX_PlayBoltedEffectID( int id, vec3_t org, void *ghoul2, const int boltNum, const int entNum, const int modelNum, int iLooptime, qboolean isRelative ) {
if ( !ghoul2 ) return qfalse;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2));
int boltInfo=0;
if ( re->G2API_AttachEnt( &boltInfo, g2, modelNum, boltNum, entNum, modelNum ) )
{
FX_PlayBoltedEffectID(id, org, boltInfo, &g2, iLooptime, isRelative );
return qtrue;
}
return qfalse;
}
static qboolean CL_SE_GetStringTextString( const char *text, char *buffer, int bufferLength ) {
const char *str;
assert( text && buffer );
str = SE_GetString( text );
if ( str[0] ) {
Q_strncpyz( buffer, str, bufferLength );
return qtrue;
}
Com_sprintf( buffer, bufferLength, "??%s", str );
return qfalse;
}
static void CL_G2API_ListModelSurfaces( void *ghlInfo ) {
re->G2API_ListSurfaces( (CGhoul2Info *)ghlInfo );
}
static void CL_G2API_ListModelBones( void *ghlInfo, int frame ) {
re->G2API_ListBones( (CGhoul2Info *)ghlInfo, frame );
}
static void CL_G2API_SetGhoul2ModelIndexes( void *ghoul2, qhandle_t *modelList, qhandle_t *skinList ) {
if ( !ghoul2 ) return;
re->G2API_SetGhoul2ModelIndexes( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelList, skinList );
}
static qboolean CL_G2API_HaveWeGhoul2Models( void *ghoul2) {
if ( !ghoul2 ) return qfalse;
return re->G2API_HaveWeGhoul2Models( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)) );
}
static qboolean CL_G2API_GetBoltMatrix( void *ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_GetBoltMatrix( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelIndex, boltIndex, matrix, angles, position, frameNum, modelList, scale );
}
static qboolean CL_G2API_GetBoltMatrix_NoReconstruct( void *ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale ) {
if ( !ghoul2 ) return qfalse;
re->G2API_BoltMatrixReconstruction( qfalse );
return re->G2API_GetBoltMatrix( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelIndex, boltIndex, matrix, angles, position, frameNum, modelList, scale );
}
static qboolean CL_G2API_GetBoltMatrix_NoRecNoRot( void *ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale ) {
if ( !ghoul2 ) return qfalse;
// Intentionally not setting bolt matrix reconstruction state per original code comments
re->G2API_BoltMatrixSPMethod( qtrue );
return re->G2API_GetBoltMatrix( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelIndex, boltIndex, matrix, angles, position, frameNum, modelList, scale );
}
static int CL_G2API_InitGhoul2Model( void **ghoul2Ptr, const char *fileName, int modelIndex, qhandle_t customSkin, qhandle_t customShader, int modelFlags, int lodBias ) {
#ifdef _FULL_G2_LEAK_CHECKING
g_G2AllocServer = 0;
#endif
CGhoul2Info_v **g2Ptr = CL_G2Map_GetG2PtrFromHandle( (g2handleptr_t*)ghoul2Ptr );
int ret = re->G2API_InitGhoul2Model( g2Ptr, fileName, modelIndex, customSkin, customShader, modelFlags, lodBias );
CL_G2Map_Update( (g2handleptr_t*)ghoul2Ptr, *g2Ptr );
return ret;
}
static qboolean CL_G2API_SetSkin( void *ghoul2, int modelIndex, qhandle_t customSkin, qhandle_t renderSkin ) {
if ( !ghoul2 ) return qfalse;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2));
return re->G2API_SetSkin( g2, modelIndex, customSkin, renderSkin );
}
static void CL_G2API_CollisionDetect( CollisionRecord_t *collRecMap, void* ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, int traceFlags, int useLod, float fRadius ) {
if ( !ghoul2 ) return;
re->G2API_CollisionDetect( collRecMap, *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), angles, position, frameNumber, entNum, rayStart, rayEnd, scale, G2VertSpaceClient, traceFlags, useLod, fRadius );
}
static void CL_G2API_CollisionDetectCache( CollisionRecord_t *collRecMap, void* ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, int traceFlags, int useLod, float fRadius ) {
if ( !ghoul2 ) return;
re->G2API_CollisionDetectCache( collRecMap, *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), angles, position, frameNumber, entNum, rayStart, rayEnd, scale, G2VertSpaceClient, traceFlags, useLod, fRadius );
}
static void CL_G2API_CleanGhoul2Models( void **ghoul2Ptr ) {
#ifdef _FULL_G2_LEAK_CHECKING
g_G2AllocServer = 0;
#endif
CGhoul2Info_v **g2Ptr = CL_G2Map_GetG2PtrFromHandle( (g2handleptr_t*)ghoul2Ptr );
re->G2API_CleanGhoul2Models( g2Ptr );
CL_G2Map_Update( (g2handleptr_t*)ghoul2Ptr, *g2Ptr );
}
static qboolean CL_G2API_SetBoneAngles( void *ghoul2, int modelIndex, const char *boneName, const vec3_t angles, const int flags, const int up, const int right, const int forward, qhandle_t *modelList, int blendTime , int currentTime ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_SetBoneAngles( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelIndex, boneName, angles, flags, (const Eorientations)up, (const Eorientations)right, (const Eorientations)forward, modelList, blendTime , currentTime );
}
static qboolean CL_G2API_SetBoneAnim( void *ghoul2, const int modelIndex, const char *boneName, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_SetBoneAnim( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelIndex, boneName, startFrame, endFrame, flags, animSpeed, currentTime, setFrame, blendTime );
}
static qboolean CL_G2API_GetBoneAnim( void *ghoul2, const char *boneName, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, int *modelList, const int modelIndex ) {
if ( !ghoul2 ) return qfalse;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2));
return re->G2API_GetBoneAnim( g2, modelIndex, boneName, currentTime, currentFrame, startFrame, endFrame, flags, animSpeed, modelList );
}
static qboolean CL_G2API_GetBoneFrame( void *ghoul2, const char *boneName, const int currentTime, float *currentFrame, int *modelList, const int modelIndex ) {
if ( !ghoul2 ) return qfalse;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2));
int iDontCare1 = 0, iDontCare2 = 0, iDontCare3 = 0;
float fDontCare1 = 0;
return re->G2API_GetBoneAnim(g2, modelIndex, boneName, currentTime, currentFrame, &iDontCare1, &iDontCare2, &iDontCare3, &fDontCare1, modelList);
}
static void CL_G2API_GetGLAName( void *ghoul2, int modelIndex, char *fillBuf ) {
if ( !ghoul2 )
{
fillBuf[0] = '\0';
return;
}
char *tmp = re->G2API_GetGLAName( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelIndex );
if ( tmp )
strcpy( fillBuf, tmp );
else
fillBuf[0] = '\0';
}
static int CL_G2API_CopyGhoul2Instance( void *g2From, void *g2To, int modelIndex ) {
if ( !g2From || !g2To ) return 0;
return re->G2API_CopyGhoul2Instance( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)g2From)), *(CL_G2Map_GetG2FromHandle((g2handleptr_t)g2To)), modelIndex );
}
static void CL_G2API_CopySpecificGhoul2Model( void *g2From, int modelFrom, void *g2To, int modelTo ) {
if ( !g2From || !g2To) return;
re->G2API_CopySpecificG2Model( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)g2From)), modelFrom, *(CL_G2Map_GetG2FromHandle((g2handleptr_t)g2To)), modelTo );
}
static void CL_G2API_DuplicateGhoul2Instance( void *g2From, void **g2To ) {
#ifdef _FULL_G2_LEAK_CHECKING
g_G2AllocServer = 0;
#endif
if ( !g2From || !g2To ) return;
CGhoul2Info_v **g2ToPtr = CL_G2Map_GetG2PtrFromHandle( (g2handleptr_t*)g2To );
re->G2API_DuplicateGhoul2Instance( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)g2From)), g2ToPtr );
CL_G2Map_Update( (g2handleptr_t*)g2To, *g2ToPtr );
}
static qboolean CL_G2API_HasGhoul2ModelOnIndex( void *ghlInfo, int modelIndex ) {
CGhoul2Info_v **g2Ptr = CL_G2Map_GetG2PtrFromHandle( (g2handleptr_t*)ghlInfo );
qboolean ret = re->G2API_HasGhoul2ModelOnIndex( g2Ptr, modelIndex );
CL_G2Map_Update( (g2handleptr_t*)ghlInfo, *g2Ptr );
return ret;
}
static qboolean CL_G2API_RemoveGhoul2Model( void *ghlInfo, int modelIndex ) {
#ifdef _FULL_G2_LEAK_CHECKING
g_G2AllocServer = 0;
#endif
CGhoul2Info_v **g2Ptr = CL_G2Map_GetG2PtrFromHandle( (g2handleptr_t*)ghlInfo );
qboolean ret = re->G2API_RemoveGhoul2Model( g2Ptr, modelIndex );
CL_G2Map_Update( (g2handleptr_t*)ghlInfo, *g2Ptr );
return ret;
}
static qboolean CL_G2API_SkinlessModel( void *ghlInfo, int modelIndex ) {
if ( !ghlInfo ) return qfalse;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghlInfo));
return re->G2API_SkinlessModel( g2, modelIndex );
}
static int CL_G2API_GetNumGoreMarks( void *ghlInfo, int modelIndex ) {
#ifdef _G2_GORE
if ( !ghlInfo ) return 0;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghlInfo));
return re->G2API_GetNumGoreMarks( g2, modelIndex );
#else
return 0;
#endif
}
static void CL_G2API_AddSkinGore( void *ghlInfo, SSkinGoreData *gore ) {
#ifdef _G2_GORE
if ( !ghlInfo ) return;
re->G2API_AddSkinGore( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghlInfo)), *(SSkinGoreData *)gore );
#endif
}
static void CL_G2API_ClearSkinGore( void *ghlInfo ) {
#ifdef _G2_GORE
if ( !ghlInfo ) return;
re->G2API_ClearSkinGore( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghlInfo)) );
#endif
}
static int CL_G2API_Ghoul2Size( void *ghlInfo ) {
if ( !ghlInfo ) return 0;
return re->G2API_Ghoul2Size( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghlInfo)) );
}
static int CL_G2API_AddBolt( void *ghoul2, int modelIndex, const char *boneName ) {
if ( !ghoul2 ) return -1;
return re->G2API_AddBolt( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelIndex, boneName );
}
static qboolean CL_G2API_AttachEnt( int *boltInfo, void *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum ) {
if ( !ghlInfoTo ) return qfalse;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghlInfoTo));
return re->G2API_AttachEnt( boltInfo, g2, 0, toBoltIndex, entNum, toModelNum );
}
static void CL_G2API_SetBoltInfo( void *ghoul2, int modelIndex, int boltInfo ) {
if ( !ghoul2 ) return;
re->G2API_SetBoltInfo( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelIndex, boltInfo );
}
static qboolean CL_G2API_SetRootSurface( void *ghoul2, const int modelIndex, const char *surfaceName ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_SetRootSurface( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), modelIndex, surfaceName );
}
static qboolean CL_G2API_SetSurfaceOnOff( void *ghoul2, const char *surfaceName, const int flags ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_SetSurfaceOnOff( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), surfaceName, flags );
}
static qboolean CL_G2API_SetNewOrigin( void *ghoul2, const int boltIndex ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_SetNewOrigin( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), boltIndex );
}
static qboolean CL_G2API_DoesBoneExist( void *ghoul2, int modelIndex, const char *boneName ) {
if ( !ghoul2 ) return qfalse;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2));
return re->G2API_DoesBoneExist( g2, modelIndex, boneName );
}
static int CL_G2API_GetSurfaceRenderStatus( void *ghoul2, const int modelIndex, const char *surfaceName ) {
if ( !ghoul2 ) return -1;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2));
return re->G2API_GetSurfaceRenderStatus( g2, modelIndex, surfaceName );
}
static int CL_G2API_GetTime( void ) {
return re->G2API_GetTime( 0 );
}
static void CL_G2API_SetTime( int time, int clock ) {
re->G2API_SetTime( time, clock );
}
static void CL_G2API_AbsurdSmoothing( void *ghoul2, qboolean status ) {
if ( !ghoul2 ) return;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2));
re->G2API_AbsurdSmoothing( g2, status );
}
static void CL_G2API_SetRagDoll( void *ghoul2, sharedRagDollParams_t *params ) {
if ( !ghoul2 ) return;
CRagDollParams rdParams;
if ( !params ) {
re->G2API_ResetRagDoll( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)) );
return;
}
VectorCopy( params->angles, rdParams.angles );
VectorCopy( params->position, rdParams.position );
VectorCopy( params->scale, rdParams.scale );
VectorCopy( params->pelvisAnglesOffset, rdParams.pelvisAnglesOffset );
VectorCopy( params->pelvisPositionOffset, rdParams.pelvisPositionOffset );
rdParams.fImpactStrength = params->fImpactStrength;
rdParams.fShotStrength = params->fShotStrength;
rdParams.me = params->me;
rdParams.startFrame = params->startFrame;
rdParams.endFrame = params->endFrame;
rdParams.collisionType = params->collisionType;
rdParams.CallRagDollBegin = params->CallRagDollBegin;
rdParams.RagPhase = (CRagDollParams::ERagPhase)params->RagPhase;
rdParams.effectorsToTurnOff = (CRagDollParams::ERagEffector)params->effectorsToTurnOff;
re->G2API_SetRagDoll( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), &rdParams );
}
static void CL_G2API_AnimateG2Models( void *ghoul2, int time, sharedRagDollUpdateParams_t *params ) {
if ( !ghoul2 ) return;
if ( !params ) return;
CRagDollUpdateParams rduParams;
VectorCopy( params->angles, rduParams.angles );
VectorCopy( params->position, rduParams.position );
VectorCopy( params->scale, rduParams.scale );
VectorCopy( params->velocity, rduParams.velocity );
rduParams.me = params->me;
rduParams.settleFrame = params->settleFrame;
re->G2API_AnimateG2ModelsRag( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), time, &rduParams );
}
static qboolean CL_G2API_RagPCJConstraint( void *ghoul2, const char *boneName, vec3_t min, vec3_t max ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_RagPCJConstraint( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), boneName, min, max );
}
static qboolean CL_G2API_RagPCJGradientSpeed( void *ghoul2, const char *boneName, const float speed ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_RagPCJGradientSpeed( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), boneName, speed );
}
static qboolean CL_G2API_RagEffectorGoal( void *ghoul2, const char *boneName, vec3_t pos ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_RagEffectorGoal( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), boneName, pos );
}
static qboolean CL_G2API_GetRagBonePos( void *ghoul2, const char *boneName, vec3_t pos, vec3_t entAngles, vec3_t entPos, vec3_t entScale ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_GetRagBonePos( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), boneName, pos, entAngles, entPos, entScale );
}
static qboolean CL_G2API_RagEffectorKick( void *ghoul2, const char *boneName, vec3_t velocity ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_RagEffectorKick( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), boneName, velocity );
}
static qboolean CL_G2API_RagForceSolve( void *ghoul2, qboolean force ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_RagForceSolve( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), force );
}
static qboolean CL_G2API_SetBoneIKState( void *ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_SetBoneIKState( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), time, boneName, ikState, params );
}
static qboolean CL_G2API_IKMove( void *ghoul2, int time, sharedIKMoveParams_t *params ) {
if ( !ghoul2 ) return qfalse;
return re->G2API_IKMove( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), time, params );
}
static qboolean CL_G2API_RemoveBone( void *ghoul2, const char *boneName, int modelIndex ) {
if ( !ghoul2 ) return qfalse;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2));
return re->G2API_RemoveBone( g2, modelIndex, boneName );
}
static void CL_G2API_AttachInstanceToEntNum( void *ghoul2, int entityNum, qboolean server ) {
if ( !ghoul2 ) return;
re->G2API_AttachInstanceToEntNum( *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2)), entityNum, server );
}
static void CL_G2API_ClearAttachedInstance( int entityNum ) {
re->G2API_ClearAttachedInstance( entityNum );
}
static void CL_G2API_CleanEntAttachments( void ) {
re->G2API_CleanEntAttachments();
}
static qboolean CL_G2API_OverrideServer( void *serverInstance ) {
if ( !serverInstance ) return qfalse;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)serverInstance));
return re->G2API_OverrideServerWithClientData( g2, 0 );
}
static void CL_G2API_GetSurfaceName( void *ghoul2, int surfNumber, int modelIndex, char *fillBuf ) {
if ( !ghoul2 ) return;
CGhoul2Info_v &g2 = *(CL_G2Map_GetG2FromHandle((g2handleptr_t)ghoul2));
char *tmp = re->G2API_GetSurfaceName( g2, modelIndex, surfNumber );
strcpy( fillBuf, tmp );
}
static void CL_Key_SetCatcher( int catcher ) {
// Don't allow the cgame module to close the console
Key_SetCatcher( catcher | ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) );
}
static void CGVM_Cvar_Set( const char *var_name, const char *value ) {
Cvar_VM_Set( var_name, value, VM_CGAME );