sv_game.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. // sv_game.c -- interface to the game dll
  2. // leave this as first line for PCH reasons...
  3. //
  4. #include "../server/exe_headers.h"
  5. #include "../RMG/RM_Headers.h"
  6. #include "../qcommon/cm_local.h"
  7. #include "server.h"
  8. #include "..\client\vmachine.h"
  9. #include "..\client\client.h"
  10. #include "..\renderer\tr_local.h"
  11. #include "..\renderer\tr_WorldEffects.h"
  12. /*
  13. Ghoul2 Insert Start
  14. */
  15. #if !defined(G2_H_INC)
  16. #include "..\ghoul2\G2.h"
  17. #endif
  18. /*
  19. Ghoul2 Insert End
  20. */
  21. //prototypes
  22. extern void Sys_UnloadGame( void );
  23. extern void *Sys_GetGameAPI( void *parms);
  24. extern void Com_WriteCam ( const char *text );
  25. extern void Com_FlushCamFile();
  26. #ifdef _XBOX
  27. extern int *s_entityWavVol;
  28. #else
  29. extern int s_entityWavVol[MAX_GENTITIES];
  30. #endif
  31. // these functions must be used instead of pointer arithmetic, because
  32. // the game allocates gentities with private information after the server shared part
  33. /*
  34. int SV_NumForGentity( gentity_t *ent ) {
  35. int num;
  36. num = ( (byte *)ent - (byte *)ge->gentities ) / ge->gentitySize;
  37. return num;
  38. }
  39. */
  40. gentity_t *SV_GentityNum( int num ) {
  41. gentity_t *ent;
  42. assert (num >=0);
  43. ent = (gentity_t *)((byte *)ge->gentities + ge->gentitySize*(num));
  44. return ent;
  45. }
  46. svEntity_t *SV_SvEntityForGentity( gentity_t *gEnt ) {
  47. if ( !gEnt || gEnt->s.number < 0 || gEnt->s.number >= MAX_GENTITIES ) {
  48. Com_Error( ERR_DROP, "SV_SvEntityForGentity: bad gEnt" );
  49. }
  50. return &sv.svEntities[ gEnt->s.number ];
  51. }
  52. gentity_t *SV_GEntityForSvEntity( svEntity_t *svEnt ) {
  53. int num;
  54. num = svEnt - sv.svEntities;
  55. return SV_GentityNum( num );
  56. }
  57. /*
  58. ===============
  59. SV_GameSendServerCommand
  60. Sends a command string to a client
  61. ===============
  62. */
  63. void SV_GameSendServerCommand( int clientNum, const char *fmt, ... ) {
  64. char msg[8192];
  65. va_list argptr;
  66. va_start (argptr,fmt);
  67. vsprintf (msg, fmt, argptr);
  68. va_end (argptr);
  69. if ( clientNum == -1 ) {
  70. SV_SendServerCommand( NULL, "%s", msg );
  71. } else {
  72. if ( clientNum < 0 || clientNum >= 1 ) {
  73. return;
  74. }
  75. SV_SendServerCommand( svs.clients + clientNum, "%s", msg );
  76. }
  77. }
  78. /*
  79. ===============
  80. SV_GameDropClient
  81. Disconnects the client with a message
  82. ===============
  83. */
  84. void SV_GameDropClient( int clientNum, const char *reason ) {
  85. if ( clientNum < 0 || clientNum >= 1 ) {
  86. return;
  87. }
  88. SV_DropClient( svs.clients + clientNum, reason );
  89. }
  90. /*
  91. =================
  92. SV_SetBrushModel
  93. sets mins and maxs for inline bmodels
  94. =================
  95. */
  96. void SV_SetBrushModel( gentity_t *ent, const char *name ) {
  97. clipHandle_t h;
  98. vec3_t mins, maxs;
  99. if (!name)
  100. {
  101. Com_Error( ERR_DROP, "SV_SetBrushModel: NULL model for ent number %d", ent->s.number );
  102. }
  103. if (name[0] == '*')
  104. {
  105. ent->s.modelindex = atoi( name + 1 );
  106. if (sv.mLocalSubBSPIndex != -1)
  107. {
  108. ent->s.modelindex += sv.mLocalSubBSPModelOffset;
  109. }
  110. h = CM_InlineModel( ent->s.modelindex );
  111. if (sv.mLocalSubBSPIndex != -1)
  112. {
  113. CM_ModelBounds( SubBSP[sv.mLocalSubBSPIndex], h, mins, maxs );
  114. }
  115. else
  116. {
  117. CM_ModelBounds( cmg, h, mins, maxs);
  118. }
  119. //CM_ModelBounds( h, mins, maxs );
  120. VectorCopy (mins, ent->mins);
  121. VectorCopy (maxs, ent->maxs);
  122. ent->bmodel = qtrue;
  123. if (0) //com_RMG && com_RMG->integer //fixme: this test really should be do we have bsp instances
  124. {
  125. ent->contents = CM_ModelContents( h, sv.mLocalSubBSPIndex );
  126. }
  127. else
  128. {
  129. ent->contents = CM_ModelContents( h, -1 );
  130. }
  131. }
  132. else if (name[0] == '#')
  133. {
  134. ent->s.modelindex = CM_LoadSubBSP(va("maps/%s.bsp", name + 1), qfalse);
  135. CM_ModelBounds( SubBSP[CM_FindSubBSP(ent->s.modelindex)], ent->s.modelindex, mins, maxs );
  136. VectorCopy (mins, ent->mins);
  137. VectorCopy (maxs, ent->maxs);
  138. ent->bmodel = qtrue;
  139. //rwwNOTE: We don't ever want to set contents -1, it includes CONTENTS_LIGHTSABER.
  140. //Lots of stuff will explode if there's a brush with CONTENTS_LIGHTSABER that isn't attached to a client owner.
  141. //ent->contents = -1; // we don't know exactly what is in the brushes
  142. h = CM_InlineModel( ent->s.modelindex );
  143. ent->contents = CM_ModelContents( h, CM_FindSubBSP(ent->s.modelindex) );
  144. // ent->contents = CONTENTS_SOLID;
  145. }
  146. else
  147. {
  148. Com_Error( ERR_DROP, "SV_SetBrushModel: %s isn't a brush model (ent %d)", name, ent->s.number );
  149. }
  150. }
  151. const char *SV_SetActiveSubBSP(int index)
  152. {
  153. if (index >= 0)
  154. {
  155. sv.mLocalSubBSPIndex = CM_FindSubBSP(index);
  156. sv.mLocalSubBSPModelOffset = index;
  157. sv.mLocalSubBSPEntityParsePoint = CM_SubBSPEntityString (sv.mLocalSubBSPIndex);
  158. return sv.mLocalSubBSPEntityParsePoint;
  159. }
  160. else
  161. {
  162. sv.mLocalSubBSPIndex = -1;
  163. }
  164. return NULL;
  165. }
  166. /*
  167. =================
  168. SV_inPVS
  169. Also checks portalareas so that doors block sight
  170. =================
  171. */
  172. qboolean SV_inPVS (const vec3_t p1, const vec3_t p2)
  173. {
  174. int leafnum;
  175. int cluster;
  176. int area1, area2;
  177. #ifdef _XBOX
  178. const byte *mask;
  179. #else
  180. byte *mask;
  181. #endif
  182. int start=0;
  183. if ( com_speeds->integer ) {
  184. start = Sys_Milliseconds ();
  185. }
  186. leafnum = CM_PointLeafnum (p1);
  187. cluster = CM_LeafCluster (leafnum);
  188. area1 = CM_LeafArea (leafnum);
  189. mask = CM_ClusterPVS (cluster);
  190. leafnum = CM_PointLeafnum (p2);
  191. cluster = CM_LeafCluster (leafnum);
  192. area2 = CM_LeafArea (leafnum);
  193. if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) )
  194. {
  195. if ( com_speeds->integer ) {
  196. timeInPVSCheck += Sys_Milliseconds () - start;
  197. }
  198. return qfalse;
  199. }
  200. if (!CM_AreasConnected (area1, area2))
  201. {
  202. timeInPVSCheck += Sys_Milliseconds() - start;
  203. return qfalse; // a door blocks sight
  204. }
  205. if ( com_speeds->integer ) {
  206. timeInPVSCheck += Sys_Milliseconds() - start;
  207. }
  208. return qtrue;
  209. }
  210. /*
  211. =================
  212. SV_inPVSIgnorePortals
  213. Does NOT check portalareas
  214. =================
  215. */
  216. qboolean SV_inPVSIgnorePortals( const vec3_t p1, const vec3_t p2)
  217. {
  218. int leafnum;
  219. int cluster;
  220. int area1, area2;
  221. #ifdef _XBOX
  222. const byte *mask;
  223. #else
  224. byte *mask;
  225. #endif
  226. int start=0;
  227. if ( com_speeds->integer ) {
  228. start = Sys_Milliseconds ();
  229. }
  230. leafnum = CM_PointLeafnum (p1);
  231. cluster = CM_LeafCluster (leafnum);
  232. area1 = CM_LeafArea (leafnum);
  233. mask = CM_ClusterPVS (cluster);
  234. leafnum = CM_PointLeafnum (p2);
  235. cluster = CM_LeafCluster (leafnum);
  236. area2 = CM_LeafArea (leafnum);
  237. if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) )
  238. {
  239. if ( com_speeds->integer ) {
  240. timeInPVSCheck += Sys_Milliseconds() - start;
  241. }
  242. return qfalse;
  243. }
  244. if ( com_speeds->integer ) {
  245. timeInPVSCheck += Sys_Milliseconds() - start;
  246. }
  247. return qtrue;
  248. }
  249. /*
  250. ========================
  251. SV_AdjustAreaPortalState
  252. ========================
  253. */
  254. void SV_AdjustAreaPortalState( gentity_t *ent, qboolean open ) {
  255. if ( !(ent->contents&CONTENTS_OPAQUE) ) {
  256. #ifndef FINAL_BUILD
  257. // Com_Printf( "INFO: entity number %d not opaque: not affecting area portal!\n", ent->s.number );
  258. #endif
  259. return;
  260. }
  261. svEntity_t *svEnt;
  262. svEnt = SV_SvEntityForGentity( ent );
  263. if ( svEnt->areanum2 == -1 ) {
  264. return;
  265. }
  266. CM_AdjustAreaPortalState( svEnt->areanum, svEnt->areanum2, open );
  267. }
  268. /*
  269. ==================
  270. SV_GameAreaEntities
  271. ==================
  272. */
  273. qboolean SV_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *gEnt ) {
  274. const float *origin, *angles;
  275. clipHandle_t ch;
  276. trace_t trace;
  277. // check for exact collision
  278. origin = gEnt->currentOrigin;
  279. angles = gEnt->currentAngles;
  280. ch = SV_ClipHandleForEntity( gEnt );
  281. CM_TransformedBoxTrace ( &trace, vec3_origin, vec3_origin, mins, maxs,
  282. ch, -1, origin, angles );
  283. return trace.startsolid;
  284. }
  285. /*
  286. ===============
  287. SV_GetServerinfo
  288. ===============
  289. */
  290. void SV_GetServerinfo( char *buffer, int bufferSize ) {
  291. if ( bufferSize < 1 ) {
  292. Com_Error( ERR_DROP, "SV_GetServerinfo: bufferSize == %i", bufferSize );
  293. }
  294. Q_strncpyz( buffer, Cvar_InfoString( CVAR_SERVERINFO ), bufferSize );
  295. }
  296. qboolean SV_GetEntityToken( char *buffer, int bufferSize )
  297. {
  298. char *s;
  299. if (sv.mLocalSubBSPIndex == -1)
  300. {
  301. s = COM_Parse( (const char **)&sv.entityParsePoint );
  302. Q_strncpyz( buffer, s, bufferSize );
  303. if ( !sv.entityParsePoint && !s[0] )
  304. {
  305. return qfalse;
  306. }
  307. else
  308. {
  309. return qtrue;
  310. }
  311. }
  312. else
  313. {
  314. s = COM_Parse( (const char **)&sv.mLocalSubBSPEntityParsePoint);
  315. Q_strncpyz( buffer, s, bufferSize );
  316. if ( !sv.mLocalSubBSPEntityParsePoint && !s[0] )
  317. {
  318. return qfalse;
  319. }
  320. else
  321. {
  322. return qtrue;
  323. }
  324. }
  325. }
  326. //==============================================
  327. /*
  328. ===============
  329. SV_ShutdownGameProgs
  330. Called when either the entire server is being killed, or
  331. it is changing to a different game directory.
  332. ===============
  333. */
  334. void SV_ShutdownGameProgs (qboolean shutdownCin) {
  335. if (!ge) {
  336. return;
  337. }
  338. ge->Shutdown ();
  339. #ifdef _XBOX
  340. if(shutdownCin) {
  341. SCR_StopCinematic();
  342. }
  343. #else
  344. SCR_StopCinematic();
  345. #endif
  346. CL_ShutdownCGame(); //we have cgame burried in here.
  347. Sys_UnloadGame (); //this kills cgame as well.
  348. ge = NULL;
  349. cgvm.entryPoint = 0;
  350. }
  351. // this is a compile-helper function since Z_Malloc can now become a macro with __LINE__ etc
  352. //
  353. static void *G_ZMalloc_Helper( int iSize, memtag_t eTag, qboolean bZeroit)
  354. {
  355. return Z_Malloc( iSize, eTag, bZeroit );
  356. }
  357. //rww - RAGDOLL_BEGIN
  358. void G2API_SetRagDoll(CGhoul2Info_v &ghoul2,CRagDollParams *parms);
  359. void G2API_AnimateG2Models(CGhoul2Info_v &ghoul2, int AcurrentTime,CRagDollUpdateParams *params);
  360. qboolean G2API_RagPCJConstraint(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t min, vec3_t max);
  361. qboolean G2API_RagPCJGradientSpeed(CGhoul2Info_v &ghoul2, const char *boneName, const float speed);
  362. qboolean G2API_RagEffectorGoal(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos);
  363. qboolean G2API_GetRagBonePos(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos, vec3_t entAngles, vec3_t entPos, vec3_t entScale);
  364. qboolean G2API_RagEffectorKick(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t velocity);
  365. qboolean G2API_RagForceSolve(CGhoul2Info_v &ghoul2, qboolean force);
  366. qboolean G2API_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params);
  367. qboolean G2API_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params);
  368. //rww - RAGDOLL_END
  369. //This is as good a place as any I guess.
  370. #ifndef _XBOX // Removing terrain from Xbox
  371. void RMG_Init(int terrainID)
  372. {
  373. if (!TheRandomMissionManager)
  374. {
  375. TheRandomMissionManager = new CRMManager;
  376. }
  377. TheRandomMissionManager->SetLandScape(cmg.landScape);
  378. if (TheRandomMissionManager->LoadMission(qtrue))
  379. {
  380. TheRandomMissionManager->SpawnMission(qtrue);
  381. }
  382. // cmg.landScapes[args[1]]->UpdatePatches();
  383. //sv.mRMGChecksum = cm.landScapes[terrainID]->get_rand_seed();
  384. }
  385. CCMLandScape *CM_RegisterTerrain(const char *config, bool server);
  386. int InterfaceCM_RegisterTerrain (const char *info)
  387. {
  388. return CM_RegisterTerrain(info, false)->GetTerrainId();
  389. }
  390. #endif // _XBOX
  391. /*
  392. ===============
  393. SV_InitGameProgs
  394. Init the game subsystem for a new map
  395. ===============
  396. */
  397. void SV_InitGameProgs (void) {
  398. game_import_t import;
  399. int i;
  400. // unload anything we have now
  401. if ( ge ) {
  402. SV_ShutdownGameProgs (qtrue);
  403. }
  404. #ifndef _XBOX
  405. if ( !Cvar_VariableIntegerValue("fs_restrict") && !Sys_CheckCD() )
  406. {
  407. Com_Error( ERR_NEED_CD, SE_GetString("CON_TEXT_NEED_CD") ); //"Game CD not in drive" );
  408. }
  409. #endif
  410. // load a new game dll
  411. import.Printf = Com_Printf;
  412. import.WriteCam = Com_WriteCam;
  413. import.FlushCamFile = Com_FlushCamFile;
  414. import.Error = Com_Error;
  415. import.Milliseconds = Sys_Milliseconds;
  416. import.DropClient = SV_GameDropClient;
  417. import.SendServerCommand = SV_GameSendServerCommand;
  418. import.linkentity = SV_LinkEntity;
  419. import.unlinkentity = SV_UnlinkEntity;
  420. import.EntitiesInBox = SV_AreaEntities;
  421. import.EntityContact = SV_EntityContact;
  422. import.trace = SV_Trace;
  423. import.pointcontents = SV_PointContents;
  424. import.totalMapContents = CM_TotalMapContents;
  425. import.SetBrushModel = SV_SetBrushModel;
  426. import.inPVS = SV_inPVS;
  427. import.inPVSIgnorePortals = SV_inPVSIgnorePortals;
  428. import.SetConfigstring = SV_SetConfigstring;
  429. import.GetConfigstring = SV_GetConfigstring;
  430. import.SetUserinfo = SV_SetUserinfo;
  431. import.GetUserinfo = SV_GetUserinfo;
  432. import.GetServerinfo = SV_GetServerinfo;
  433. import.cvar = Cvar_Get;
  434. import.cvar_set = Cvar_Set;
  435. import.Cvar_VariableIntegerValue = Cvar_VariableIntegerValue;
  436. import.Cvar_VariableStringBuffer = Cvar_VariableStringBuffer;
  437. import.argc = Cmd_Argc;
  438. import.argv = Cmd_Argv;
  439. import.SendConsoleCommand = Cbuf_AddText;
  440. import.FS_FOpenFile = FS_FOpenFileByMode;
  441. import.FS_Read = FS_Read;
  442. import.FS_Write = FS_Write;
  443. import.FS_FCloseFile = FS_FCloseFile;
  444. import.FS_ReadFile = FS_ReadFile;
  445. import.FS_FreeFile = FS_FreeFile;
  446. import.FS_GetFileList = FS_GetFileList;
  447. import.AppendToSaveGame = SG_Append;
  448. #ifndef _XBOX
  449. import.ReadFromSaveGame = SG_Read;
  450. import.ReadFromSaveGameOptional = SG_ReadOptional;
  451. #endif
  452. import.AdjustAreaPortalState = SV_AdjustAreaPortalState;
  453. import.AreasConnected = CM_AreasConnected;
  454. import.VoiceVolume = s_entityWavVol;
  455. import.Malloc = G_ZMalloc_Helper;
  456. import.Free = Z_Free;
  457. import.bIsFromZone = Z_IsFromZone;
  458. /*
  459. Ghoul2 Insert Start
  460. */
  461. import.G2API_AddBolt = G2API_AddBolt;
  462. import.G2API_AttachEnt = G2API_AttachEnt;
  463. import.G2API_AttachG2Model = G2API_AttachG2Model;
  464. import.G2API_CollisionDetect = G2API_CollisionDetect;
  465. import.G2API_DetachEnt = G2API_DetachEnt;
  466. import.G2API_DetachG2Model = G2API_DetachG2Model;
  467. import.G2API_GetAnimFileName = G2API_GetAnimFileName;
  468. import.G2API_GetBoltMatrix = G2API_GetBoltMatrix;
  469. import.G2API_GetBoneAnim = G2API_GetBoneAnim;
  470. import.G2API_GetBoneAnimIndex = G2API_GetBoneAnimIndex;
  471. import.G2API_AddSurface = G2API_AddSurface;
  472. import.G2API_HaveWeGhoul2Models =G2API_HaveWeGhoul2Models;
  473. #ifndef _XBOX
  474. import.G2API_InitGhoul2Model = G2API_InitGhoul2Model;
  475. import.G2API_SetBoneAngles = G2API_SetBoneAngles;
  476. import.G2API_SetBoneAnglesMatrix = G2API_SetBoneAnglesMatrix;
  477. import.G2API_SetBoneAnim = G2API_SetBoneAnim;
  478. import.G2API_SetSkin = G2API_SetSkin;
  479. import.G2API_CopyGhoul2Instance = G2API_CopyGhoul2Instance;
  480. import.G2API_SetBoneAnglesIndex = G2API_SetBoneAnglesIndex;
  481. import.G2API_SetBoneAnimIndex = G2API_SetBoneAnimIndex;
  482. #endif
  483. import.G2API_IsPaused = G2API_IsPaused;
  484. import.G2API_ListBones = G2API_ListBones;
  485. import.G2API_ListSurfaces = G2API_ListSurfaces;
  486. import.G2API_PauseBoneAnim = G2API_PauseBoneAnim;
  487. import.G2API_PauseBoneAnimIndex = G2API_PauseBoneAnimIndex;
  488. import.G2API_PrecacheGhoul2Model = G2API_PrecacheGhoul2Model;
  489. import.G2API_RemoveBolt = G2API_RemoveBolt;
  490. import.G2API_RemoveBone = G2API_RemoveBone;
  491. import.G2API_RemoveGhoul2Model = G2API_RemoveGhoul2Model;
  492. import.G2API_SetLodBias = G2API_SetLodBias;
  493. import.G2API_SetRootSurface = G2API_SetRootSurface;
  494. import.G2API_SetShader = G2API_SetShader;
  495. import.G2API_SetSurfaceOnOff = G2API_SetSurfaceOnOff;
  496. import.G2API_StopBoneAngles = G2API_StopBoneAngles;
  497. import.G2API_StopBoneAnim = G2API_StopBoneAnim;
  498. import.G2API_SetGhoul2ModelFlags = G2API_SetGhoul2ModelFlags;
  499. import.G2API_AddBoltSurfNum = G2API_AddBoltSurfNum;
  500. import.G2API_RemoveSurface = G2API_RemoveSurface;
  501. import.G2API_GetAnimRange = G2API_GetAnimRange;
  502. import.G2API_GetAnimRangeIndex = G2API_GetAnimRangeIndex;
  503. import.G2API_GiveMeVectorFromMatrix = G2API_GiveMeVectorFromMatrix;
  504. import.G2API_GetGhoul2ModelFlags = G2API_GetGhoul2ModelFlags;
  505. import.G2API_CleanGhoul2Models = G2API_CleanGhoul2Models;
  506. import.TheGhoul2InfoArray = TheGhoul2InfoArray;
  507. import.G2API_GetParentSurface = G2API_GetParentSurface;
  508. import.G2API_GetSurfaceIndex = G2API_GetSurfaceIndex;
  509. import.G2API_GetSurfaceName = G2API_GetSurfaceName;
  510. import.G2API_GetGLAName = G2API_GetGLAName;
  511. import.G2API_SetNewOrigin = G2API_SetNewOrigin;
  512. import.G2API_GetBoneIndex = G2API_GetBoneIndex;
  513. import.G2API_StopBoneAnglesIndex = G2API_StopBoneAnglesIndex;
  514. import.G2API_StopBoneAnimIndex = G2API_StopBoneAnimIndex;
  515. import.G2API_SetBoneAnglesMatrixIndex = G2API_SetBoneAnglesMatrixIndex;
  516. import.G2API_SetAnimIndex = G2API_SetAnimIndex;
  517. import.G2API_GetAnimIndex = G2API_GetAnimIndex;
  518. import.G2API_SaveGhoul2Models = G2API_SaveGhoul2Models;
  519. import.G2API_LoadGhoul2Models = G2API_LoadGhoul2Models;
  520. import.G2API_LoadSaveCodeDestructGhoul2Info = G2API_LoadSaveCodeDestructGhoul2Info;
  521. import.G2API_GetAnimFileNameIndex = G2API_GetAnimFileNameIndex;
  522. import.G2API_GetAnimFileInternalNameIndex = G2API_GetAnimFileInternalNameIndex;
  523. import.G2API_GetSurfaceRenderStatus = G2API_GetSurfaceRenderStatus;
  524. //rww - RAGDOLL_BEGIN
  525. import.G2API_SetRagDoll = G2API_SetRagDoll;
  526. import.G2API_AnimateG2Models = G2API_AnimateG2Models;
  527. import.G2API_RagPCJConstraint = G2API_RagPCJConstraint;
  528. import.G2API_RagPCJGradientSpeed = G2API_RagPCJGradientSpeed;
  529. import.G2API_RagEffectorGoal = G2API_RagEffectorGoal;
  530. import.G2API_GetRagBonePos = G2API_GetRagBonePos;
  531. import.G2API_RagEffectorKick = G2API_RagEffectorKick;
  532. import.G2API_RagForceSolve = G2API_RagForceSolve;
  533. import.G2API_SetBoneIKState = G2API_SetBoneIKState;
  534. import.G2API_IKMove = G2API_IKMove;
  535. //rww - RAGDOLL_END
  536. import.G2API_AddSkinGore = G2API_AddSkinGore;
  537. import.G2API_ClearSkinGore = G2API_ClearSkinGore;
  538. #ifndef _XBOX
  539. import.RMG_Init = RMG_Init;
  540. import.CM_RegisterTerrain = InterfaceCM_RegisterTerrain;
  541. #endif
  542. import.SetActiveSubBSP = SV_SetActiveSubBSP;
  543. import.RE_RegisterSkin = RE_RegisterSkin;
  544. import.RE_GetAnimationCFG = RE_GetAnimationCFG;
  545. import.WE_GetWindVector = R_GetWindVector;
  546. import.WE_GetWindGusting = R_GetWindGusting;
  547. import.WE_IsOutside = R_IsOutside;
  548. import.WE_IsOutsideCausingPain = R_IsOutsideCausingPain;
  549. import.WE_GetChanceOfSaberFizz = R_GetChanceOfSaberFizz;
  550. import.WE_IsShaking = R_IsShaking;
  551. import.WE_AddWeatherZone = R_AddWeatherZone;
  552. import.WE_SetTempGlobalFogColor = R_SetTempGlobalFogColor;
  553. /*
  554. Ghoul2 Insert End
  555. */
  556. ge = (game_export_t *)Sys_GetGameAPI (&import);
  557. if (!ge)
  558. Com_Error (ERR_DROP, "failed to load game DLL");
  559. //hook up the client while we're here
  560. #ifdef _XBOX
  561. VM_Create("cl");
  562. #else
  563. if (!VM_Create("cl"))
  564. Com_Error (ERR_DROP, "failed to attach to the client DLL");
  565. #endif
  566. if (ge->apiversion != GAME_API_VERSION)
  567. Com_Error (ERR_DROP, "game is version %i, not %i", ge->apiversion,
  568. GAME_API_VERSION);
  569. sv.entityParsePoint = CM_EntityString();
  570. // use the current msec count for a random seed
  571. Z_TagFree(TAG_G_ALLOC);
  572. ge->Init( sv_mapname->string, sv_spawntarget->string, sv_mapChecksum->integer, CM_EntityString(), sv.time, com_frameTime, Com_Milliseconds(), eSavedGameJustLoaded, qbLoadTransition );
  573. if(!Q_stricmp(sv_mapname->string, "t1_rail") )
  574. {
  575. Cvar_Set("in_shaking_rumble","0");
  576. }
  577. else
  578. {
  579. Cvar_Set("in_shaking_rumble","1");
  580. }
  581. // clear all gentity pointers that might still be set from
  582. // a previous level
  583. for ( i = 0 ; i < 1 ; i++ ) {
  584. svs.clients[i].gentity = NULL;
  585. }
  586. }
  587. /*
  588. ====================
  589. SV_GameCommand
  590. See if the current console command is claimed by the game
  591. ====================
  592. */
  593. qboolean SV_GameCommand( void ) {
  594. if ( sv.state != SS_GAME ) {
  595. return qfalse;
  596. }
  597. return ge->ConsoleCommand();
  598. }