Skip to content
Browse files

Uploaded Tremulous 1.1.0 game logic

  • Loading branch information...
1 parent 1c36e59 commit c843a62d806226109568992946a8051b549e4448 @TheDushan committed Aug 15, 2012
Sorry, we could not display the entire diff because it was too big.
View
45 src/gamelogic/base/src/base.sln
@@ -0,0 +1,45 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cgame", "cgame\cgame.vcxproj", "{C878E295-CB82-4B40-8ECF-5CE5525466FA}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "game", "game\game.vcxproj", "{F9EE10DA-2404-4154-B904-F93C936C040A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ui", "ui\ui.vcxproj", "{D454C4C7-7765-4149-ABAD-05FDEB9D94F8}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C878E295-CB82-4B40-8ECF-5CE5525466FA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C878E295-CB82-4B40-8ECF-5CE5525466FA}.Debug|Win32.Build.0 = Debug|Win32
+ {C878E295-CB82-4B40-8ECF-5CE5525466FA}.Debug|x64.ActiveCfg = Debug|x64
+ {C878E295-CB82-4B40-8ECF-5CE5525466FA}.Debug|x64.Build.0 = Debug|x64
+ {C878E295-CB82-4B40-8ECF-5CE5525466FA}.Release|Win32.ActiveCfg = Release|Win32
+ {C878E295-CB82-4B40-8ECF-5CE5525466FA}.Release|Win32.Build.0 = Release|Win32
+ {C878E295-CB82-4B40-8ECF-5CE5525466FA}.Release|x64.ActiveCfg = Release|x64
+ {C878E295-CB82-4B40-8ECF-5CE5525466FA}.Release|x64.Build.0 = Release|x64
+ {F9EE10DA-2404-4154-B904-F93C936C040A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F9EE10DA-2404-4154-B904-F93C936C040A}.Debug|Win32.Build.0 = Debug|Win32
+ {F9EE10DA-2404-4154-B904-F93C936C040A}.Debug|x64.ActiveCfg = Debug|x64
+ {F9EE10DA-2404-4154-B904-F93C936C040A}.Debug|x64.Build.0 = Debug|x64
+ {F9EE10DA-2404-4154-B904-F93C936C040A}.Release|Win32.ActiveCfg = Release|Win32
+ {F9EE10DA-2404-4154-B904-F93C936C040A}.Release|Win32.Build.0 = Release|Win32
+ {F9EE10DA-2404-4154-B904-F93C936C040A}.Release|x64.ActiveCfg = Release|x64
+ {F9EE10DA-2404-4154-B904-F93C936C040A}.Release|x64.Build.0 = Release|x64
+ {D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Debug|Win32.Build.0 = Debug|Win32
+ {D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Debug|x64.ActiveCfg = Debug|x64
+ {D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Debug|x64.Build.0 = Debug|x64
+ {D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Release|Win32.ActiveCfg = Release|Win32
+ {D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Release|Win32.Build.0 = Release|Win32
+ {D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Release|x64.ActiveCfg = Release|x64
+ {D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
111 src/gamelogic/base/src/cgame/cg_animation.cpp
@@ -0,0 +1,111 @@
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+Copyright (C) 2000-2006 Tim Angus
+
+This file is part of OpenWolf.
+
+OpenWolf is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+OpenWolf 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 OpenWolf; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#include "cg_local.h"
+
+/*
+===============
+CG_RunLerpFrame
+
+Sets cg.snap, cg.oldFrame, and cg.backlerp
+cg.time should be between oldFrameTime and frameTime after exit
+===============
+*/
+void CG_RunLerpFrame( lerpFrame_t *lf )
+{
+ int f, numFrames;
+ animation_t *anim;
+
+ // debugging tool to get no animations
+ if( cg_animSpeed.integer == 0 )
+ {
+ lf->oldFrame = lf->frame = lf->backlerp = 0;
+ return;
+ }
+
+ // if we have passed the current frame, move it to
+ // oldFrame and calculate a new frame
+ if( cg.time >= lf->frameTime )
+ {
+ lf->oldFrame = lf->frame;
+ lf->oldFrameTime = lf->frameTime;
+
+ // get the next frame based on the animation
+ anim = lf->animation;
+ if( !anim->frameLerp )
+ return; // shouldn't happen
+
+ if( cg.time < lf->animationTime )
+ lf->frameTime = lf->animationTime; // initial lerp
+ else
+ lf->frameTime = lf->oldFrameTime + anim->frameLerp;
+
+ f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;
+ numFrames = anim->numFrames;
+ if( anim->flipflop )
+ numFrames *= 2;
+
+ if( f >= numFrames )
+ {
+ f -= numFrames;
+ if( anim->loopFrames )
+ {
+ f %= anim->loopFrames;
+ f += anim->numFrames - anim->loopFrames;
+ }
+ else
+ {
+ f = numFrames - 1;
+ // the animation is stuck at the end, so it
+ // can immediately transition to another sequence
+ lf->frameTime = cg.time;
+ }
+ }
+
+ if( anim->reversed )
+ lf->frame = anim->firstFrame + anim->numFrames - 1 - f;
+ else if( anim->flipflop && f >= anim->numFrames )
+ lf->frame = anim->firstFrame + anim->numFrames - 1 - ( f % anim->numFrames );
+ else
+ lf->frame = anim->firstFrame + f;
+
+ if( cg.time > lf->frameTime )
+ {
+ lf->frameTime = cg.time;
+ if( cg_debugAnim.integer )
+ CG_Printf( "Clamp lf->frameTime\n" );
+ }
+ }
+
+ if( lf->frameTime > cg.time + 200 )
+ lf->frameTime = cg.time;
+
+ if( lf->oldFrameTime > cg.time )
+ lf->oldFrameTime = cg.time;
+
+ // calculate current lerp value
+ if( lf->frameTime == lf->oldFrameTime )
+ lf->backlerp = 0;
+ else
+ lf->backlerp = 1.0 - (float)( cg.time - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );
+}
View
203 src/gamelogic/base/src/cgame/cg_animmapobj.cpp
@@ -0,0 +1,203 @@
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+Copyright (C) 2000-2006 Tim Angus
+
+This file is part of OpenWolf.
+
+OpenWolf is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+OpenWolf 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 OpenWolf; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#include "cg_local.h"
+
+
+/*
+===============
+CG_DoorAnimation
+===============
+*/
+static void CG_DoorAnimation( centity_t *cent, int *old, int *now, float *backLerp )
+{
+ CG_RunLerpFrame( &cent->lerpFrame );
+
+ *old = cent->lerpFrame.oldFrame;
+ *now = cent->lerpFrame.frame;
+ *backLerp = cent->lerpFrame.backlerp;
+}
+
+
+/*
+===============
+CG_ModelDoor
+===============
+*/
+void CG_ModelDoor( centity_t *cent )
+{
+ refEntity_t ent;
+ entityState_t *es;
+ animation_t anim;
+ lerpFrame_t *lf = &cent->lerpFrame;
+
+ es = &cent->currentState;
+
+ if( !es->modelindex )
+ return;
+
+ //create the render entity
+ memset( &ent, 0, sizeof( ent ) );
+ VectorCopy( cent->lerpOrigin, ent.origin );
+ VectorCopy( cent->lerpOrigin, ent.oldorigin );
+ AnglesToAxis( cent->lerpAngles, ent.axis );
+
+ ent.renderfx = RF_NOSHADOW;
+
+ //add the door model
+ ent.skinNum = 0;
+ ent.hModel = cgs.gameModels[ es->modelindex ];
+
+ //scale the door
+ VectorScale( ent.axis[ 0 ], es->origin2[ 0 ], ent.axis[ 0 ] );
+ VectorScale( ent.axis[ 1 ], es->origin2[ 1 ], ent.axis[ 1 ] );
+ VectorScale( ent.axis[ 2 ], es->origin2[ 2 ], ent.axis[ 2 ] );
+ ent.nonNormalizedAxes = qtrue;
+
+ //setup animation
+ anim.firstFrame = es->powerups;
+ anim.numFrames = es->weapon;
+ anim.reversed = !es->legsAnim;
+ anim.flipflop = qfalse;
+ anim.loopFrames = 0;
+ anim.frameLerp = 1000 / es->torsoAnim;
+ anim.initialLerp = 1000 / es->torsoAnim;
+
+ //door changed state
+ if( es->legsAnim != cent->doorState )
+ {
+ lf->animationTime = lf->frameTime + anim.initialLerp;
+ cent->doorState = es->legsAnim;
+ }
+
+ lf->animation = &anim;
+
+ //run animation
+ CG_DoorAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp );
+
+ trap_R_AddRefEntityToScene( &ent );
+}
+
+
+/*
+===============
+CG_AMOAnimation
+===============
+*/
+static void CG_AMOAnimation( centity_t *cent, int *old, int *now, float *backLerp )
+{
+ if( !( cent->currentState.eFlags & EF_MOVER_STOP ) )
+ {
+ int delta = cg.time - cent->miscTime;
+
+ //hack to prevent "pausing" mucking up the lerping
+ if( delta > 900 )
+ {
+ cent->lerpFrame.oldFrameTime += delta;
+ cent->lerpFrame.frameTime += delta;
+ }
+
+ CG_RunLerpFrame( &cent->lerpFrame );
+ cent->miscTime = cg.time;
+ }
+
+ *old = cent->lerpFrame.oldFrame;
+ *now = cent->lerpFrame.frame;
+ *backLerp = cent->lerpFrame.backlerp;
+}
+
+
+/*
+==================
+CG_animMapObj
+==================
+*/
+void CG_AnimMapObj( centity_t *cent )
+{
+ refEntity_t ent;
+ entityState_t *es;
+ float scale;
+ animation_t anim;
+
+ es = &cent->currentState;
+
+ // if set to invisible, skip
+ if( !es->modelindex || ( es->eFlags & EF_NODRAW ) )
+ return;
+
+ memset( &ent, 0, sizeof( ent ) );
+
+ VectorCopy( es->angles, cent->lerpAngles );
+ AnglesToAxis( cent->lerpAngles, ent.axis );
+
+ ent.hModel = cgs.gameModels[ es->modelindex ];
+
+ VectorCopy( cent->lerpOrigin, ent.origin);
+ VectorCopy( cent->lerpOrigin, ent.oldorigin);
+
+ ent.nonNormalizedAxes = qfalse;
+
+ //scale the model
+ if( es->angles2[ 0 ] )
+ {
+ scale = es->angles2[ 0 ];
+ VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] );
+ VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] );
+ VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] );
+ ent.nonNormalizedAxes = qtrue;
+ }
+
+ //setup animation
+ anim.firstFrame = es->powerups;
+ anim.numFrames = es->weapon;
+ anim.reversed = qfalse;
+ anim.flipflop = qfalse;
+
+ // if numFrames is negative the animation is reversed
+ if( anim.numFrames < 0 )
+ {
+ anim.numFrames = -anim.numFrames;
+ anim.reversed = qtrue;
+ }
+
+ anim.loopFrames = es->torsoAnim;
+
+ if( !es->legsAnim )
+ {
+ anim.frameLerp = 1000;
+ anim.initialLerp = 1000;
+ }
+ else
+ {
+ anim.frameLerp = 1000 / es->legsAnim;
+ anim.initialLerp = 1000 / es->legsAnim;
+ }
+
+ cent->lerpFrame.animation = &anim;
+
+ //run animation
+ CG_AMOAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp );
+
+ // add to refresh list
+ trap_R_AddRefEntityToScene(&ent);
+}
View
1,082 src/gamelogic/base/src/cgame/cg_api.cpp
@@ -0,0 +1,1082 @@
+/*
+===========================================================================
+
+OpenWolf GPL Source Code
+Copyright (C) 2011 Dusan Jocic <dusanjocic@msn.com>
+
+OpenWolf is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+OpenWolf 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/>.
+
+===========================================================================
+*/
+
+#include "../../../../engine/client/cg_api.h"
+
+static intptr_t(QDECL * syscall) (intptr_t arg, ...) = (intptr_t(QDECL *) (intptr_t,...)) - 1;
+
+void dllEntry(intptr_t(QDECL * syscallptr) (intptr_t arg, ...)) {
+ syscall = syscallptr;
+}
+
+static int FloatAsInt(float f)
+{
+ floatint_t fi;
+
+ fi.f = f;
+ return fi.i;
+}
+#define PASSFLOAT( x ) FloatAsInt( x )
+
+//00.
+//Com_Printf("%s", (char *)VMA(1));
+void trap_Print(const char *fmt) {
+ syscall(CG_PRINT, fmt);
+}
+
+//01.
+//Com_Error(ERR_DROP, "%s", (char *)VMA(1));
+void trap_Error(const char *fmt) {
+ syscall(CG_ERROR, fmt);
+}
+
+//02.
+//return Sys_Milliseconds();
+int trap_Milliseconds(void) {
+ return syscall(CG_MILLISECONDS);
+}
+
+//03.
+//Cvar_Register(VMA(1), VMA(2), VMA(3), args[4]);
+void trap_Cvar_Register(vmCvar_t * vmCvar, const char *varName, const char *defaultValue, int flags) {
+ syscall(CG_CVAR_REGISTER, vmCvar, varName, defaultValue, flags);
+}
+
+//04.
+//Cvar_Update(VMA(1));
+void trap_Cvar_Update(vmCvar_t * vmCvar) {
+ syscall(CG_CVAR_UPDATE, vmCvar);
+}
+
+//05.
+//Cvar_Set(VMA(1), VMA(2));
+void trap_Cvar_Set(const char *var_name, const char *value) {
+ syscall(CG_CVAR_SET, var_name, value);
+}
+
+//06.
+//Cvar_VariableStringBuffer(VMA(1), VMA(2), args[3]);
+void trap_Cvar_VariableStringBuffer(const char *var_name, char *buffer, int bufsize) {
+ syscall(CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize);
+}
+
+//07.
+//Cvar_LatchedVariableStringBuffer(VMA(1), VMA(2), args[3]);
+void trap_Cvar_LatchedVariableStringBuffer(const char *var_name, char *buffer, int bufsize) {
+ syscall(CG_CVAR_LATCHEDVARIABLESTRINGBUFFER, var_name, buffer, bufsize);
+}
+
+//08.
+//return Cmd_Argc();
+int trap_Argc(void) {
+ return syscall(CG_ARGC);
+}
+
+//09.
+//Cmd_ArgvBuffer(args[1], VMA(2), args[3]);
+void trap_Argv(int n, char *buffer, int bufferLength) {
+ syscall(CG_ARGV, n, buffer, bufferLength);
+}
+
+//10.
+//Cmd_ArgsBuffer(VMA(1), args[2]);
+void trap_Args(char *buffer, int bufferLength) {
+ syscall(CG_ARGS, buffer, bufferLength);
+}
+
+//11.
+//Cmd_ArgsBuffer(VMA(1), args[2]);
+void trap_LiteralArgs(char *buffer, int bufferLength) {
+ syscall(CG_LITERAL_ARGS, buffer, bufferLength);
+}
+
+//12.
+//return CL_DemoState( );
+int trap_GetDemoState(void) {
+ return syscall(CG_GETDEMOSTATE);
+}
+
+//13.
+//return CL_DemoPos( );
+int trap_GetDemoPos(void) {
+ return syscall(CG_GETDEMOPOS);
+}
+
+//14.
+//return FS_FOpenFileByMode(VMA(1), VMA(2), args[3]);
+int trap_FS_FOpenFile(const char *qpath, fileHandle_t * f, fsMode_t mode) {
+ return syscall(CG_FS_FOPENFILE, qpath, f, mode);
+}
+
+//15.
+//FS_Read2(VMA(1), args[2], args[3]);
+void trap_FS_Read(void *buffer, int len, fileHandle_t f) {
+ syscall(CG_FS_READ, buffer, len, f);
+}
+
+//16.
+//return FS_Write(VMA(1), args[2], args[3]);
+void trap_FS_Write(const void *buffer, int len, fileHandle_t f) {
+ syscall(CG_FS_WRITE, buffer, len, f);
+}
+
+//17.
+//FS_FCloseFile(args[1]);
+void trap_FS_FCloseFile(fileHandle_t f) {
+ syscall(CG_FS_FCLOSEFILE, f);
+}
+
+//18.
+//return FS_GetFileList(VMA(1), VMA(2), VMA(3), args[4]);
+int trap_FS_GetFileList(const char *path, const char *extension, char *listbuf, int bufsize) {
+ return syscall(CG_FS_GETFILELIST, path, extension, listbuf, bufsize);
+}
+
+//19.
+//return FS_Delete(VMA(1));
+int trap_FS_Delete(const char *filename) {
+ return syscall(CG_FS_DELETEFILE, filename);
+}
+
+//20.
+//Cbuf_AddText(VMA(1));
+void trap_SendConsoleCommand(const char *text) {
+ syscall(CG_SENDCONSOLECOMMAND, text);
+}
+
+//21.
+//CL_AddCgameCommand(VMA(1));
+void trap_AddCommand(const char *cmdName) {
+ syscall(CG_ADDCOMMAND, cmdName);
+}
+
+//22.
+//Cmd_RemoveCommand(VMA(1));
+void trap_RemoveCommand(const char *cmdName) {
+ syscall(CG_REMOVECOMMAND, cmdName);
+}
+
+//23.
+//CL_AddReliableCommand(VMA(1));
+void trap_SendClientCommand(const char *s) {
+ syscall(CG_SENDCLIENTCOMMAND, s);
+}
+
+//24.
+//SCR_UpdateScreen();
+void trap_UpdateScreen(void) {
+ syscall(CG_UPDATESCREEN);
+}
+
+//25.
+//CL_CM_LoadMap(VMA(1));
+void trap_CM_LoadMap(const char *mapname) {
+ syscall(CG_CM_LOADMAP, mapname);
+}
+
+//26.
+//return CM_NumInlineModels();
+int trap_CM_NumInlineModels(void) {
+ return syscall(CG_CM_NUMINLINEMODELS);
+}
+
+//27.
+//return CM_InlineModel(args[1]);
+clipHandle_t trap_CM_InlineModel(int index) {
+ return syscall(CG_CM_INLINEMODEL, index);
+}
+
+//28.
+//return CM_TempBoxModel(VMA(1), VMA(2), qfalse);
+clipHandle_t trap_CM_TempBoxModel(const vec3_t mins, const vec3_t maxs) {
+ return syscall(CG_CM_TEMPBOXMODEL, mins, maxs);
+}
+
+//29.
+//return CM_TempBoxModel(VMA(1), VMA(2), qtrue);
+clipHandle_t trap_CM_TempCapsuleModel(const vec3_t mins, const vec3_t maxs) {
+ return syscall(CG_CM_TEMPCAPSULEMODEL, mins, maxs);
+}
+
+//30.
+//return CM_PointContents(VMA(1), args[2]);
+int trap_CM_PointContents(const vec3_t p, clipHandle_t model) {
+ return syscall(CG_CM_POINTCONTENTS, p, model);
+}
+
+//31.
+//return CM_TransformedPointContents(VMA(1), args[2], VMA(3), VMA(4));
+int trap_CM_TransformedPointContents(const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles) {
+ return syscall(CG_CM_TRANSFORMEDPOINTCONTENTS, p, model, origin, angles);
+}
+
+//32.
+//CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule */ qfalse);
+void trap_CM_BoxTrace(trace_t * results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask) {
+ syscall(CG_CM_BOXTRACE, results, start, end, mins, maxs, model, brushmask);
+}
+
+//33.
+//CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule */ qfalse);
+void trap_CM_TransformedBoxTrace(trace_t * results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask, const vec3_t origin, const vec3_t angles) {
+ syscall(CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles);
+}
+
+//34.
+//CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule */ qtrue);
+void trap_CM_CapsuleTrace(trace_t * results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask) {
+ syscall(CG_CM_CAPSULETRACE, results, start, end, mins, maxs, model, brushmask);
+}
+
+//35.
+//CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule */ qtrue);
+void trap_CM_TransformedCapsuleTrace(trace_t * results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask, const vec3_t origin, const vec3_t angles) {
+ syscall(CG_CM_TRANSFORMEDCAPSULETRACE, results, start, end, mins, maxs, model, brushmask, origin, angles);
+}
+
+//36.
+//CM_BiSphereTrace( VMA(1), VMA(2), VMA(3), VMF(4), VMF(5), args[6], args[7] );
+void trap_CM_BiSphereTrace(trace_t *results, const vec3_t start, const vec3_t end, float startRad, float endRad, clipHandle_t model, int mask) {
+ syscall(CG_CM_BISPHERETRACE, results, start, end, PASSFLOAT( startRad ), PASSFLOAT( endRad ), model, mask);
+}
+
+//37.
+//CM_TransformedBiSphereTrace( VMA(1), VMA(2), VMA(3), VMF(4), VMF(5), args[6], args[7], VMA(8) );
+void trap_CM_TransformedBiSphereTrace(trace_t *results, const vec3_t start, const vec3_t end, float startRad, float endRad, clipHandle_t model, int mask, const vec3_t origin) {
+ syscall(CG_CM_TRANSFORMEDBISPHERETRACE, results, start, end, PASSFLOAT( startRad ), PASSFLOAT( endRad ), model, mask, origin);
+}
+
+//38.
+//return re.MarkFragments(args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7));
+int trap_CM_MarkFragments(int numPoints, const vec3_t * points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t * fragmentBuffer) {
+ return syscall(CG_CM_MARKFRAGMENTS, numPoints, points, projection, maxPoints, pointBuffer, maxFragments, fragmentBuffer);
+}
+
+//39.
+//re.ProjectDecal(args[1], args[2], VMA(3), VMA(4), VMA(5), args[6], args[7]);
+void trap_R_ProjectDecal(qhandle_t hShader, int numPoints, vec3_t * points, vec4_t projection, vec4_t color, int lifeTime, int fadeTime) {
+ syscall(CG_R_PROJECTDECAL, hShader, numPoints, points, projection, color, lifeTime, fadeTime);
+}
+
+//40.
+//re.ClearDecals();
+void trap_R_ClearDecals(void) {
+ syscall(CG_R_CLEARDECALS);
+}
+
+//41.
+//S_StartSound(VMA(1), args[2], args[3], args[4], args[5]);
+void trap_S_StartSound(vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx) {
+ syscall(CG_S_STARTSOUND, origin, entityNum, entchannel, sfx, 127 );
+}
+
+//42.
+//S_StartSoundEx(VMA(1), args[2], args[3], args[4], args[5], args[6]);
+void trap_S_StartSoundEx(vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx, int flags) {
+ syscall(CG_S_STARTSOUNDEX, origin, entityNum, entchannel, sfx, flags, 127 );
+}
+
+//43.
+//S_StartLocalSound(args[1], args[2], args[3]);
+void trap_S_StartLocalSound(sfxHandle_t sfx, int channelNum) {
+ syscall(CG_S_STARTLOCALSOUND, sfx, channelNum, 127 );
+}
+
+//44.
+//S_ClearLoopingSounds();
+//S_ClearLoopingSounds(args[1]);
+void trap_S_ClearLoopingSounds( qboolean killall ) {
+ syscall( CG_S_CLEARLOOPINGSOUNDS, killall );
+}
+
+//45.
+// if(args[1] == 0) {
+// S_ClearSounds(qtrue, qfalse);
+//} else if(args[1] == 1) {
+// S_ClearSounds(qtrue, qtrue);
+//}
+void trap_S_ClearSounds(qboolean killmusic) {
+ syscall(CG_S_CLEARSOUNDS, killmusic);
+}
+
+//46.
+//S_AddLoopingSound(VMA(1), VMA(2), args[3], args[4], args[5], args[6]);
+//S_AddLoopingSound( args[1], VMA(2), VMA(3), args[4] );
+void trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) {
+ syscall( CG_S_ADDLOOPINGSOUND, entityNum, origin, velocity, sfx );
+}
+
+//47.
+//S_AddRealLoopingSound(VMA(1), VMA(2), args[3], args[4], args[5], args[6]);
+//S_AddRealLoopingSound( args[1], VMA(2), VMA(3), args[4] );
+void trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) {
+ syscall( CG_S_ADDREALLOOPINGSOUND, entityNum, origin, velocity, sfx );
+}
+//48.
+//S_StopLoopingSound( args[1] );
+void trap_S_StopLoopingSound(int entityNum) {
+ syscall( CG_S_STOPLOOPINGSOUND, entityNum );
+}
+
+//49.
+//S_StopEntStreamingSound(args[1]);
+void trap_S_StopStreamingSound(int entityNum) {
+ syscall(CG_S_STOPSTREAMINGSOUND, entityNum);
+}
+
+//50.
+//S_UpdateEntityPosition(args[1], VMA(2));
+void trap_S_UpdateEntityPosition(int entityNum, const vec3_t origin) {
+ syscall(CG_S_UPDATEENTITYPOSITION, entityNum, origin);
+}
+
+//51.
+//return S_GetVoiceAmplitude(args[1]);
+int trap_S_GetVoiceAmplitude(int entityNum) {
+ return syscall(CG_S_GETVOICEAMPLITUDE, entityNum);
+}
+
+//52.
+//return S_GetSoundLength(args[1]);
+int trap_S_GetSoundLength(sfxHandle_t sfx) {
+ return syscall(CG_S_GETSOUNDLENGTH, sfx);
+}
+
+//53.
+//return S_GetCurrentSoundTime();
+int trap_S_GetCurrentSoundTime(void) {
+ return syscall(CG_S_GETCURRENTSOUNDTIME);
+}
+
+//54.
+//S_Respatialize(args[1], VMA(2), VMA(3), args[4]);
+void trap_S_Respatialize(int entityNum, const vec3_t origin, vec3_t axis[3], int inwater) {
+ syscall(CG_S_RESPATIALIZE, entityNum, origin, axis, inwater);
+}
+
+//55.
+//return S_RegisterSound(VMA(1), args[2]);
+sfxHandle_t trap_S_RegisterSound(const char *sample, qboolean compressed) {
+ //CG_DrawInformation(qtrue);
+
+ trap_PumpEventLoop();
+ return syscall(CG_S_REGISTERSOUND, sample, qfalse /* compressed */ );
+}
+
+//56.
+//S_StartBackgroundTrack(VMA(1), VMA(2), args[3]);
+//S_StartBackgroundTrack(VMA(1), VMA(2));
+void trap_S_StartBackgroundTrack( const char *intro, const char *loop ) {
+ syscall( CG_S_STARTBACKGROUNDTRACK, intro, loop );
+}
+
+//57.
+//S_FadeStreamingSound(VMF(1), args[2], args[3]);
+void trap_S_FadeBackgroundTrack(float targetvol, int time, int num) {
+ syscall(CG_S_FADESTREAMINGSOUND, PASSFLOAT(targetvol), time, num);
+}
+
+//58.
+//return S_StartStreamingSound(VMA(1), VMA(2), args[3], args[4], args[5]);
+int trap_S_StartStreamingSound(const char *intro, const char *loop, int entnum, int channel, int attenuation) {
+ return syscall(CG_S_STARTSTREAMINGSOUND, intro, loop, entnum, channel, attenuation);
+}
+
+//59.
+//re.LoadWorld(VMA(1));
+void trap_R_LoadWorldMap(const char *mapname) {
+ //CG_DrawInformation(qtrue);
+
+ trap_PumpEventLoop();
+ syscall(CG_R_LOADWORLDMAP, mapname);
+}
+
+//60.
+//return re.RegisterModel(VMA(1));
+qhandle_t trap_R_RegisterModel(const char *name) {
+ //CG_DrawInformation(qtrue);
+
+ trap_PumpEventLoop();
+ return syscall(CG_R_REGISTERMODEL, name);
+}
+
+//61.
+//return re.RegisterSkin(VMA(1));
+qhandle_t trap_R_RegisterSkin(const char *name) {
+ //CG_DrawInformation(qtrue);
+
+ trap_PumpEventLoop();
+ return syscall(CG_R_REGISTERSKIN, name);
+}
+
+//62.
+//return re.GetSkinModel(args[1], VMA(2), VMA(3));
+qboolean trap_R_GetSkinModel(qhandle_t skinid, const char *type, char *name) {
+ return syscall(CG_R_GETSKINMODEL, skinid, type, name);
+}
+
+//63.
+//return re.GetShaderFromModel(args[1], args[2], args[3]);
+qhandle_t trap_R_GetShaderFromModel(qhandle_t modelid, int surfnum, int withlightmap) {
+ return syscall(CG_R_GETMODELSHADER, modelid, surfnum, withlightmap);
+}
+
+//64.
+//return re.RegisterShader(VMA(1));
+qhandle_t trap_R_RegisterShader(const char *name) {
+ //CG_DrawInformation(qtrue);
+
+ trap_PumpEventLoop();
+ return syscall(CG_R_REGISTERSHADER, name);
+}
+
+//65.
+//re.RegisterFont(VMA(1), args[2], VMA(3));
+void trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t * font) {
+ //CG_DrawInformation(qtrue);
+
+ trap_PumpEventLoop();
+ syscall(CG_R_REGISTERFONT, fontName, pointSize, font);
+}
+
+//66.
+//return re.RegisterShaderNoMip(VMA(1));
+qhandle_t trap_R_RegisterShaderNoMip(const char *name) {
+ //CG_DrawInformation(qtrue);
+
+ trap_PumpEventLoop();
+ return syscall(CG_R_REGISTERSHADERNOMIP, name);
+}
+
+//67.
+//return re.RegisterShaderLightAttenuation(VMA(1));
+#if defined(USE_REFLIGHT)
+qhandle_t trap_R_RegisterShaderLightAttenuation(const char *name) {
+ return syscall(CG_R_REGISTERSHADERLIGHTATTENUATION, name);
+}
+#endif
+
+//68.
+//re.ClearScene();
+void trap_R_ClearScene(void) {
+ syscall(CG_R_CLEARSCENE);
+}
+
+//69.
+//re.AddRefEntityToScene(VMA(1));
+void trap_R_AddRefEntityToScene(const refEntity_t * re) {
+ syscall(CG_R_ADDREFENTITYTOSCENE, re);
+}
+
+//70.
+//re.AddRefLightToScene(VMA(1));
+#if defined(USE_REFLIGHT)
+void trap_R_AddRefLightToScene(const refLight_t * light) {
+ syscall(CG_R_ADDREFLIGHTSTOSCENE, light);
+}
+#endif
+
+//71.
+//re.AddPolyToScene(args[1], args[2], VMA(3));
+void trap_R_AddPolyToScene(qhandle_t hShader, int numVerts, const polyVert_t * verts) {
+ syscall(CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts);
+}
+
+//72.
+//re.AddPolysToScene(args[1], args[2], VMA(3), args[4]);
+void trap_R_AddPolysToScene(qhandle_t hShader, int numVerts, const polyVert_t * verts, int numPolys) {
+ syscall(CG_R_ADDPOLYSTOSCENE, hShader, numVerts, verts, numPolys);
+}
+
+//73.
+//re.AddPolyBufferToScene(VMA(1));
+void trap_R_AddPolyBufferToScene(polyBuffer_t * pPolyBuffer) {
+ syscall(CG_R_ADDPOLYBUFFERTOSCENE, pPolyBuffer);
+}
+
+//74.
+//re.AddLightToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), args[7], args[8]);
+void trap_R_AddLightToScene(const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t hShader, int flags) {
+ syscall(CG_R_ADDLIGHTTOSCENE, org, PASSFLOAT(radius), PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b), hShader, flags);
+}
+
+//75.
+//re.AddAdditiveLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) );
+void trap_R_AddAdditiveLightToScene(const vec3_t org, float intensity, float r, float g, float b) {
+ syscall(CG_R_ADDADDITIVELIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b));
+}
+
+//76.
+//return FS_Seek( args[1], args[2], args[3] );
+void trap_GS_FS_Seek(fileHandle_t f, long offset, fsOrigin_t origin) {
+ syscall(CG_FS_SEEK, f, offset, origin);
+}
+
+//77.
+//re.AddCoronaToScene(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), args[6], args[7]);
+void trap_R_AddCoronaToScene(const vec3_t org, float r, float g, float b, float scale, int id, qboolean visible) {
+ syscall(CG_R_ADDCORONATOSCENE, org, PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b), PASSFLOAT(scale), id, visible);
+}
+
+//78.
+//re.SetFog(args[1], args[2], args[3], VMF(4), VMF(5), VMF(6), VMF(7));
+void trap_R_SetFog(int fogvar, int var1, int var2, float r, float g, float b, float density) {
+ syscall(CG_R_SETFOG, fogvar, var1, var2, PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b), PASSFLOAT(density));
+}
+
+//79.
+//re.SetGlobalFog(args[1], args[2], VMF(3), VMF(4), VMF(5), VMF(6));
+void trap_R_SetGlobalFog(qboolean restore, int duration, float r, float g, float b, float depthForOpaque) {
+ syscall(CG_R_SETGLOBALFOG, restore, duration, PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b), PASSFLOAT(depthForOpaque));
+}
+
+//80.
+//re.RenderScene(VMA(1));
+void trap_R_RenderScene(const refdef_t * fd) {
+ syscall(CG_R_RENDERSCENE, fd);
+}
+
+//81.
+//re.SaveViewParms();
+void trap_R_SaveViewParms() {
+ syscall(CG_R_SAVEVIEWPARMS);
+}
+
+//82.
+//re.RestoreViewParms();
+void trap_R_RestoreViewParms() {
+ syscall(CG_R_RESTOREVIEWPARMS);
+}
+
+//83.
+//re.SetColor(VMA(1));
+void trap_R_SetColor(const float *rgba) {
+ syscall(CG_R_SETCOLOR, rgba);
+}
+
+//84.
+//re.SetClipRegion( VMA(1) );
+void trap_R_SetClipRegion(const float *region) {
+ syscall( CG_R_SETCLIPREGION, region );
+}
+
+//85.
+//re.DrawStretchPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9]);
+void trap_R_DrawStretchPic(float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader) {
+ syscall(CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader);
+}
+
+//86.
+//re.DrawRotatedPic(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9], VMF(10));
+void trap_R_DrawRotatedPic(float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle) {
+ syscall(CG_R_DRAWROTATEDPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader, PASSFLOAT(angle));
+}
+
+//87.
+//re.DrawStretchPicGradient(VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9], VMA(10), args[11]);
+void trap_R_DrawStretchPicGradient(float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, const float *gradientColor, int gradientType) {
+ syscall(CG_R_DRAWSTRETCHPIC_GRADIENT, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader, gradientColor, gradientType);
+}
+
+//88.
+//re.Add2dPolys(VMA(1), args[2], args[3]);
+void trap_R_Add2dPolys(polyVert_t * verts, int numverts, qhandle_t hShader) {
+ syscall(CG_R_DRAW2DPOLYS, verts, numverts, hShader);
+}
+
+//89.
+//re.ModelBounds(args[1], VMA(2), VMA(3));
+void trap_R_ModelBounds(clipHandle_t model, vec3_t mins, vec3_t maxs) {
+ syscall(CG_R_MODELBOUNDS, model, mins, maxs);
+}
+
+//90.
+//return re.LerpTag(VMA(1), VMA(2), VMA(3), args[4]);
+int trap_R_LerpTag(orientation_t * tag, const refEntity_t * refent, const char *tagName, int startIndex) {
+ return syscall(CG_R_LERPTAG, tag, refent, tagName, startIndex);
+}
+
+//91.
+//CL_GetGlconfig(VMA(1));
+void trap_GetGlconfig(glconfig_t * glconfig) {
+ syscall(CG_GETGLCONFIG, glconfig);
+}
+
+//92.
+//CL_GetGameState(VMA(1));
+void trap_GetGameState(gameState_t * gamestate) {
+ syscall(CG_GETGAMESTATE, gamestate);
+}
+
+//93.
+//CL_GetCurrentSnapshotNumber(VMA(1), VMA(2));
+void trap_GetCurrentSnapshotNumber(int *snapshotNumber, int *serverTime) {
+ syscall(CG_GETCURRENTSNAPSHOTNUMBER, snapshotNumber, serverTime);
+}
+
+//94.
+//return CL_GetSnapshot(args[1], VMA(2));
+qboolean trap_GetSnapshot(int snapshotNumber, snapshot_t * snapshot) {
+ return syscall(CG_GETSNAPSHOT, snapshotNumber, snapshot);
+}
+
+//95.
+//return CL_GetServerCommand(args[1]);
+qboolean trap_GetServerCommand(int serverCommandNumber) {
+ return syscall(CG_GETSERVERCOMMAND, serverCommandNumber);
+}
+
+//96.
+//return CL_GetCurrentCmdNumber();
+int trap_GetCurrentCmdNumber(void) {
+ return syscall(CG_GETCURRENTCMDNUMBER);
+}
+
+//97.
+//return CL_GetUserCmd(args[1], VMA(2));
+qboolean trap_GetUserCmd(int cmdNumber, usercmd_t * ucmd) {
+ return syscall(CG_GETUSERCMD, cmdNumber, ucmd);
+}
+
+//98.
+//CL_SetUserCmdValue(args[1], args[2], VMF(3), args[4]);
+void trap_SetUserCmdValue(int stateValue, int flags, float sensitivityScale, int mpIdentClient) {
+ syscall(CG_SETUSERCMDVALUE, stateValue, flags, PASSFLOAT(sensitivityScale), mpIdentClient);
+}
+
+//99.
+//CL_SetClientLerpOrigin(VMF(1), VMF(2), VMF(3));
+void trap_SetClientLerpOrigin(float x, float y, float z) {
+ syscall(CG_SETCLIENTLERPORIGIN, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(z));
+}
+
+//100.
+//return Hunk_MemoryRemaining();
+int trap_MemoryRemaining(void) {
+ return syscall(CG_MEMORY_REMAINING);
+}
+
+//101.
+//return Key_IsDown(args[1]);
+qboolean trap_Key_IsDown(int keynum) {
+ return syscall(CG_KEY_ISDOWN, keynum);
+}
+
+//102.
+//return Key_GetCatcher();
+int trap_Key_GetCatcher(void) {
+ return syscall(CG_KEY_GETCATCHER);
+}
+
+//103.
+//Key_SetCatcher(args[1]);
+void trap_Key_SetCatcher(int catcher) {
+ syscall(CG_KEY_SETCATCHER, catcher);
+}
+
+//104.
+//return Key_GetKey(VMA(1));
+int trap_Key_GetKey(const char *binding) {
+ return syscall(CG_KEY_GETKEY, binding);
+}
+
+//105.
+//return Key_GetOverstrikeMode();
+qboolean trap_Key_GetOverstrikeMode(void) {
+ return syscall(CG_KEY_GETOVERSTRIKEMODE);
+}
+
+//106.
+//Key_SetOverstrikeMode(args[1]);
+void trap_Key_SetOverstrikeMode(qboolean state) {
+ syscall(CG_KEY_SETOVERSTRIKEMODE, state);
+}
+
+//107.
+//return (int)memset(VMA(1), args[2], args[3]);
+
+//108.
+//return (int)memcpy(VMA(1), VMA(2), args[3]);
+
+//109.
+//return (int)strncpy(VMA(1), VMA(2), args[3]);
+
+//110
+//return FloatAsInt(sin(VMF(1)));
+
+//111
+//return FloatAsInt(cos(VMF(1)));
+
+//112
+//return FloatAsInt(atan2(VMF(1), VMF(2)));
+
+//113
+//return FloatAsInt(sqrt(VMF(1)));
+
+//114
+//return FloatAsInt(floor(VMF(1)));
+
+//115
+//return FloatAsInt(ceil(VMF(1)));
+
+//116
+//return FloatAsInt(Q_acos(VMF(1)));
+
+//117
+//return botlib_export->PC_AddGlobalDefine(VMA(1));
+int trap_PC_AddGlobalDefine(char *define) {
+ return syscall(CG_PC_ADD_GLOBAL_DEFINE, define);
+}
+
+//118
+//return botlib_export->PC_LoadSourceHandle(VMA(1));
+int trap_PC_LoadSource(const char *filename) {
+ return syscall(CG_PC_LOAD_SOURCE, filename);
+}
+
+//119
+//return botlib_export->PC_FreeSourceHandle(args[1]);
+int trap_PC_FreeSource(int handle) {
+ return syscall(CG_PC_FREE_SOURCE, handle);
+}
+
+//120
+//return botlib_export->PC_ReadTokenHandle(args[1], VMA(2));
+int trap_PC_ReadToken(int handle, pc_token_t * pc_token) {
+ return syscall(CG_PC_READ_TOKEN, handle, pc_token);
+}
+
+//121
+//return botlib_export->PC_SourceFileAndLine(args[1], VMA(2), VMA(3));
+int trap_PC_SourceFileAndLine(int handle, char *filename, int *line) {
+ return syscall(CG_PC_SOURCE_FILE_AND_LINE, handle, filename, line);
+}
+
+//122.
+//botlib_export->PC_UnreadLastTokenHandle(args[1]);
+int trap_PC_UnReadToken(int handle) {
+ return syscall(CG_PC_UNREAD_TOKEN, handle);
+}
+
+//123
+//S_StopBackgroundTrack();
+void trap_S_StopBackgroundTrack(void) {
+ syscall(CG_S_STOPBACKGROUNDTRACK);
+}
+
+//124.
+//return Com_RealTime(VMA(1));
+int trap_RealTime(qtime_t * qtime) {
+ return syscall(CG_REAL_TIME, qtime);
+}
+
+//125.
+//Q_SnapVector(VMA(1));
+void trap_SnapVector(float *v) {
+ syscall(CG_SNAPVECTOR, v);
+}
+
+//126.
+//return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]);
+int trap_CIN_PlayCinematic(const char *arg0, int xpos, int ypos, int width, int height, int bits) {
+ return syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits);
+}
+
+//127.
+//return CIN_StopCinematic(args[1]);
+e_status trap_CIN_StopCinematic(int handle) {
+ return syscall(CG_CIN_STOPCINEMATIC, handle);
+}
+
+//128.
+//return CIN_RunCinematic(args[1]);
+e_status trap_CIN_RunCinematic(int handle) {
+ return syscall(CG_CIN_RUNCINEMATIC, handle);
+}
+
+//129.
+//CIN_DrawCinematic(args[1]);
+void trap_CIN_DrawCinematic(int handle) {
+ syscall(CG_CIN_DRAWCINEMATIC, handle);
+}
+
+//130.
+//CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);
+void trap_CIN_SetExtents(int handle, int x, int y, int w, int h) {
+ syscall(CG_CIN_SETEXTENTS, handle, x, y, w, h);
+}
+
+//131.
+//re.RemapShader(VMA(1), VMA(2), VMA(3));
+void trap_R_RemapShader(const char *oldShader, const char *newShader, const char *timeOffset) {
+ syscall(CG_R_REMAP_SHADER, oldShader, newShader, timeOffset);
+}
+
+//132.
+//Com_Printf("%s%i\n", (char *)VMA(1), args[2]);
+void testPrintInt(char *string, int i) {
+ syscall(CG_TESTPRINTINT, string, i);
+}
+
+//133.
+//Com_Printf("%s%f\n", (char *)VMA(1), VMF(2));
+void testPrintFloat(char *string, float f) {
+ syscall(CG_TESTPRINTFLOAT, string, PASSFLOAT(f));
+}
+
+//134.
+//return loadCamera(args[1], VMA(2));
+qboolean trap_loadCamera(int camNum, const char *name) {
+ return syscall(CG_LOADCAMERA, camNum, name);
+}
+
+//135.
+//if(args[1] == 0)
+//{ // CAM_PRIMARY
+// cl.cameraMode = qtrue;
+//}
+//startCamera(args[1], args[2]);
+void trap_startCamera(int camNum, int time) {
+ syscall(CG_STARTCAMERA, camNum, time);
+}
+
+//136.
+//if(args[1] == 0)
+//{ // CAM_PRIMARY
+// cl.cameraMode = qfalse;
+//}
+void trap_stopCamera(int camNum) {
+ syscall(CG_STOPCAMERA, camNum);
+}
+
+//137.
+//return getCameraInfo(args[1], args[2], VMA(3), VMA(4), VMA(5));
+qboolean trap_getCameraInfo(int camNum, int time, vec3_t * origin, vec3_t * angles, float *fov) {
+ return syscall(CG_GETCAMERAINFO, camNum, time, origin, angles, fov);
+}
+
+//138.
+//return re.GetEntityToken(VMA(1), args[2]);
+qboolean trap_GetEntityToken(char *buffer, int bufferSize) {
+ return syscall(CG_GET_ENTITY_TOKEN, buffer, bufferSize);
+}
+
+//139.
+//if(cls.state == CA_ACTIVE && !clc.demoplaying) {
+// if(uivm) {
+// VM_Call(uivm, UI_SET_ACTIVE_MENU, args[1]);
+// }
+//}
+void trap_UI_Popup(int arg0) {
+ syscall(CG_INGAME_POPUP, arg0);
+}
+
+//140.
+void trap_UI_ClosePopup(const char *arg0) {
+ syscall(CG_INGAME_CLOSEPOPUP, arg0);
+}
+
+//141.
+//Key_GetBindingBuf(args[1], VMA(2), args[3]);
+void trap_Key_GetBindingBuf(int keynum, char *buf, int buflen) {
+ syscall(CG_KEY_GETBINDINGBUF, keynum, buf, buflen);
+}
+
+//142.
+//Key_SetBinding(args[1], VMA(2));
+void trap_Key_SetBinding(int keynum, const char *binding) {
+ syscall(CG_KEY_SETBINDING, keynum, binding);
+}
+
+//143.
+//return Parse_AddGlobalDefine(VMA(1));
+int trap_Parse_AddGlobalDefine(char *define) {
+ return syscall(CG_PARSE_ADD_GLOBAL_DEFINE, define);
+}
+
+//144.
+//return Parse_LoadSourceHandle(VMA(1));
+int trap_Parse_LoadSource(const char *filename) {
+ return syscall(CG_PARSE_LOAD_SOURCE, filename);
+}
+
+//145.
+//return Parse_FreeSourceHandle(args[1]);
+int trap_Parse_FreeSource(int handle) {
+ return syscall(CG_PARSE_FREE_SOURCE, handle);
+}
+
+//146.
+//return Parse_ReadTokenHandle( args[1], VMA(2) );
+int trap_Parse_ReadToken(int handle, pc_token_t *pc_token) {
+ return syscall(CG_PARSE_READ_TOKEN, handle, pc_token);
+}
+
+//147.
+//return Parse_SourceFileAndLine(args[1], VMA(2), VMA(3));
+int trap_Parse_SourceFileAndLine(int handle, char *filename, int *line) {
+ return syscall(CG_PARSE_SOURCE_FILE_AND_LINE, handle, filename, line);
+}
+
+//148.
+//Key_KeynumToStringBuf(args[1], VMA(2), args[3]);
+void trap_Key_KeynumToStringBuf(int keynum, char *buf, int buflen) {
+ syscall(CG_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen);
+}
+
+//149.
+//Key_GetBindingByString(VMA(1), VMA(2), VMA(3));
+void trap_Key_KeysForBinding(const char *binding, int *key1, int *key2) {
+ syscall(CG_KEY_BINDINGTOKEYS, binding, key1, key2);
+}
+
+//150.
+//CL_TranslateString(VMA(1), VMA(2));
+void trap_CG_TranslateString(const char *string, char *buf) {
+ syscall(CG_TRANSLATE_STRING, string, buf);
+}
+
+//151.
+//S_FadeAllSounds(VMF(1), args[2], args[3]);
+void trap_S_FadeAllSound(float targetvol, int time, qboolean stopsounds) {
+ syscall(CG_S_FADEALLSOUNDS, PASSFLOAT(targetvol), time, stopsounds);
+}
+
+//152.
+//return re.inPVS(VMA(1), VMA(2));
+qboolean trap_R_inPVS(const vec3_t p1, const vec3_t p2) {
+ return syscall(CG_R_INPVS, p1, p2);
+}
+
+//153.
+//Com_GetHunkInfo(VMA(1), VMA(2));
+void trap_GetHunkData(int *hunkused, int *hunkexpected) {
+ syscall(CG_GETHUNKDATA, hunkused, hunkexpected);
+}
+
+//154.
+void trap_PumpEventLoop(void) {
+ /*if(!cgs.initing) {
+ return;
+ }
+ syscall(CG_PUMPEVENTLOOP);*/
+}
+
+//155.
+//CL_SendBinaryMessage(VMA(1), args[2]);
+void trap_SendMessage(char *buf, int buflen) {
+ syscall(CG_SENDMESSAGE, buf, buflen);
+}
+
+//156.
+//return CL_BinaryMessageStatus();
+messageStatus_t trap_MessageStatus(void) {
+ return syscall(CG_MESSAGESTATUS);
+}
+
+//157.
+//return re.LoadDynamicShader(VMA(1), VMA(2));
+qboolean trap_R_LoadDynamicShader(const char *shadername, const char *shadertext) {
+ return syscall(CG_R_LOADDYNAMICSHADER, shadername, shadertext);
+}
+
+//158.
+//re.RenderToTexture(args[1], args[2], args[3], args[4], args[5]);
+void trap_R_RenderToTexture(int textureid, int x, int y, int w, int h) {
+ syscall(CG_R_RENDERTOTEXTURE, textureid, x, y, w, h);
+}
+
+//159
+//return re.GetTextureId(VMA(1));
+int trap_R_GetTextureId(const char *name) {
+ return syscall(CG_R_GETTEXTUREID, name);
+}
+
+//160.
+//re.Finish();
+void trap_R_Finish(void) {
+ syscall(CG_R_FINISH);
+}
+
+//161.
+//CL_DemoName( VMA(1), args[2] );
+void trap_GetDemoName(char *buffer, int size) {
+ syscall(CG_GETDEMONAME, buffer, size);
+}
+
+//162.
+void trap_S_StartSoundVControl(vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx, int volume) {
+ syscall(CG_S_STARTSOUND, origin, entityNum, entchannel, sfx, volume);
+}
+
+//163.
+int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ) {
+ return syscall( CG_R_LIGHTFORPOINT, point, ambientLight, directedLight, lightDir );
+}
+
+//164.
+//return S_SoundDuration( args[1] );
+int trap_S_SoundDuration( sfxHandle_t handle ) {
+ return syscall( CG_S_SOUNDDURATION, handle );
+}
+
+//165.
+#if defined(USE_REFENTITY_ANIMATIONSYSTEM)
+qhandle_t trap_R_RegisterAnimation(const char *name) {
+ return syscall(CG_R_REGISTERANIMATION, name);
+}
+
+//166.
+int trap_R_CheckSkeleton(refSkeleton_t * skel, qhandle_t hModel, qhandle_t hAnim) {
+ return syscall(CG_R_CHECKSKELETON, skel, hModel, hAnim);
+}
+
+//167.
+int trap_R_BuildSkeleton(refSkeleton_t * skel, qhandle_t anim, int startFrame, int endFrame, float frac, qboolean clearOrigin) {
+ return syscall(CG_R_BUILDSKELETON, skel, anim, startFrame, endFrame, PASSFLOAT(frac), clearOrigin);
+}
+
+//168.
+int trap_R_BlendSkeleton(refSkeleton_t * skel, const refSkeleton_t * blend, float frac) {
+ return syscall(CG_R_BLENDSKELETON, skel, blend, PASSFLOAT(frac));
+}
+
+//169.
+int trap_R_BoneIndex(qhandle_t hModel, const char *boneName) {
+ return syscall(CG_R_BONEINDEX, hModel, boneName);
+}
+
+//170.
+int trap_R_AnimNumFrames(qhandle_t hAnim) {
+ return syscall(CG_R_ANIMNUMFRAMES, hAnim);
+}
+
+//171.
+int trap_R_AnimFrameRate(qhandle_t hAnim) {
+ return syscall(CG_R_ANIMFRAMERATE, hAnim);
+}
+#endif
+
+//172.
+void trap_CompleteCallback( const char *complete ) {
+ syscall( CG_COMPLETE_CALLBACK, complete );
+}
View
404 src/gamelogic/base/src/cgame/cg_attachment.cpp
@@ -0,0 +1,404 @@
+/*
+===========================================================================
+Copyright (C) 2000-2006 Tim Angus
+
+This file is part of OpenWolf.
+
+OpenWolf is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+OpenWolf 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 OpenWolf; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+// cg_attachment.c -- an abstract attachment system
+
+#include "cg_local.h"
+
+/*
+===============
+CG_AttachmentPoint
+
+Return the attachment point
+===============
+*/
+qboolean CG_AttachmentPoint( attachment_t *a, vec3_t v )
+{
+ centity_t *cent;
+
+ if( !a )
+ return qfalse;
+
+ // if it all breaks, then use the last point we know was correct
+ VectorCopy( a->lastValidAttachmentPoint, v );
+
+ switch( a->type )
+ {
+ case AT_STATIC:
+ if( !a->staticValid )
+ return qfalse;
+
+ VectorCopy( a->origin, v );
+ break;
+
+ case AT_TAG:
+ if( !a->tagValid )
+ return qfalse;
+
+ AxisCopy( axisDefault, a->re.axis );
+ CG_PositionRotatedEntityOnTag( &a->re, &a->parent,
+ a->model, a->tagName );
+ VectorCopy( a->re.origin, v );
+ break;
+
+ case AT_CENT:
+ if( !a->centValid )
+ return qfalse;
+
+ if( a->centNum == cg.predictedPlayerState.clientNum )
+ {
+ // this is smoother if it's the local client
+ VectorCopy( cg.predictedPlayerState.origin, v );
+ }
+ else
+ {
+ cent = &cg_entities[ a->centNum ];
+ VectorCopy( cent->lerpOrigin, v );
+ }
+ break;
+
+ case AT_PARTICLE:
+ if( !a->particleValid )
+ return qfalse;
+
+ if( !a->particle->valid )
+ {
+ a->particleValid = qfalse;
+ return qfalse;
+ }
+ else
+ VectorCopy( a->particle->origin, v );
+ break;
+
+ default:
+ CG_Printf( S_COLOR_RED "ERROR: Invalid attachmentType_t in attachment\n" );
+ break;
+ }
+
+ if( a->hasOffset )
+ VectorAdd( v, a->offset, v );
+
+ VectorCopy( v, a->lastValidAttachmentPoint );
+
+ return qtrue;
+}
+
+/*
+===============
+CG_AttachmentDir
+
+Return the attachment direction
+===============
+*/
+qboolean CG_AttachmentDir( attachment_t *a, vec3_t v )
+{
+ vec3_t forward;
+ centity_t *cent;
+
+ if( !a )
+ return qfalse;
+
+ switch( a->type )
+ {
+ case AT_STATIC:
+ return qfalse;
+ break;
+
+ case AT_TAG:
+ if( !a->tagValid )
+ return qfalse;
+
+ VectorCopy( a->re.axis[ 0 ], v );
+ break;
+
+ case AT_CENT:
+ if( !a->centValid )
+ return qfalse;
+
+ cent = &cg_entities[ a->centNum ];
+ AngleVectors( cent->lerpAngles, forward, NULL, NULL );
+ VectorCopy( forward, v );
+ break;
+
+ case AT_PARTICLE:
+ if( !a->particleValid )
+ return qfalse;
+
+ if( !a->particle->valid )
+ {
+ a->particleValid = qfalse;
+ return qfalse;
+ }
+ else
+ VectorCopy( a->particle->velocity, v );
+ break;
+
+ default:
+ CG_Printf( S_COLOR_RED "ERROR: Invalid attachmentType_t in attachment\n" );
+ break;
+ }
+
+ VectorNormalize( v );
+ return qtrue;
+}
+
+/*
+===============
+CG_AttachmentAxis
+
+Return the attachment axis
+===============
+*/
+qboolean CG_AttachmentAxis( attachment_t *a, vec3_t axis[ 3 ] )
+{
+ centity_t *cent;
+
+ if( !a )
+ return qfalse;
+
+ switch( a->type )
+ {
+ case AT_STATIC:
+ return qfalse;
+ break;
+
+ case AT_TAG:
+ if( !a->tagValid )
+ return qfalse;
+
+ AxisCopy( a->re.axis, axis );
+ break;
+
+ case AT_CENT:
+ if( !a->centValid )
+ return qfalse;
+
+ cent = &cg_entities[ a->centNum ];
+ AnglesToAxis( cent->lerpAngles, axis );
+ break;
+
+ case AT_PARTICLE:
+ return qfalse;
+ break;
+
+ default:
+ CG_Printf( S_COLOR_RED "ERROR: Invalid attachmentType_t in attachment\n" );
+ break;
+ }
+
+ return qtrue;
+}
+
+/*
+===============
+CG_AttachmentVelocity
+
+If the attachment can have velocity, return it
+===============
+*/
+qboolean CG_AttachmentVelocity( attachment_t *a, vec3_t v )
+{
+ if( !a )
+ return qfalse;
+
+ if( a->particleValid && a->particle->valid )
+ {
+ VectorCopy( a->particle->velocity, v );
+ return qtrue;
+ }
+ else if( a->centValid )
+ {
+ centity_t *cent = &cg_entities[ a->centNum ];
+
+ VectorCopy( cent->currentState.pos.trDelta, v );
+ return qtrue;
+ }
+
+ return qfalse;
+}
+
+/*
+===============
+CG_AttachmentCentNum
+
+If the attachment has a centNum, return it
+===============
+*/
+int CG_AttachmentCentNum( attachment_t *a )
+{
+ if( !a || !a->centValid )
+ return -1;
+
+ return a->centNum;
+}
+
+/*
+===============
+CG_Attached
+
+If the attachment is valid, return qtrue
+===============
+*/
+qboolean CG_Attached( attachment_t *a )
+{
+ if( !a )
+ return qfalse;
+
+ return a->attached;
+}
+
+/*
+===============
+CG_AttachToPoint
+
+Attach to a point in space
+===============
+*/
+void CG_AttachToPoint( attachment_t *a )
+{
+ if( !a || !a->staticValid )
+ return;
+
+ a->type = AT_STATIC;
+ a->attached = qtrue;
+}
+
+/*
+===============
+CG_AttachToCent
+
+Attach to a centity_t
+===============
+*/
+void CG_AttachToCent( attachment_t *a )
+{
+ if( !a || !a->centValid )
+ return;
+
+ a->type = AT_CENT;
+ a->attached = qtrue;
+}
+
+/*
+===============
+CG_AttachToTag
+
+Attach to a model tag
+===============
+*/
+void CG_AttachToTag( attachment_t *a )
+{
+ if( !a || !a->tagValid )
+ return;
+
+ a->type = AT_TAG;
+ a->attached = qtrue;
+}
+
+/*
+===============
+CG_AttachToParticle
+
+Attach to a particle
+===============
+*/
+void CG_AttachToParticle( attachment_t *a )
+{
+ if( !a || !a->particleValid )
+ return;
+
+ a->type = AT_PARTICLE;
+ a->attached = qtrue;
+}
+
+/*
+===============
+CG_SetAttachmentPoint
+===============
+*/
+void CG_SetAttachmentPoint( attachment_t *a, vec3_t v )
+{
+ if( !a )
+ return;
+
+ VectorCopy( v, a->origin );
+ a->staticValid = qtrue;
+}
+
+/*
+===============
+CG_SetAttachmentCent
+===============
+*/
+void CG_SetAttachmentCent( attachment_t *a, centity_t *cent )
+{
+ if( !a || !cent )
+ return;
+
+ a->centNum = cent->currentState.number;
+ a->centValid = qtrue;
+}
+
+/*
+===============
+CG_SetAttachmentTag
+===============
+*/
+void CG_SetAttachmentTag( attachment_t *a, refEntity_t parent,
+ qhandle_t model, char *tagName )
+{
+ if( !a )
+ return;
+
+ a->parent = parent;
+ a->model = model;
+ strncpy( a->tagName, tagName, MAX_STRING_CHARS );
+ a->tagValid = qtrue;
+}
+
+/*
+===============
+CG_SetAttachmentParticle
+===============
+*/
+void CG_SetAttachmentParticle( attachment_t *a, particle_t *p )
+{
+ if( !a )
+ return;
+
+ a->particle = p;
+ a->particleValid = qtrue;
+}
+
+/*
+===============
+CG_SetAttachmentOffset
+===============
+*/
+void CG_SetAttachmentOffset( attachment_t *a, vec3_t v )
+{
+ if( !a )
+ return;
+
+ VectorCopy( v, a->offset );
+ a->hasOffset = qtrue;
+}
View
1,065 src/gamelogic/base/src/cgame/cg_buildable.cpp
@@ -0,0 +1,1065 @@
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+Copyright (C) 2000-2006 Tim Angus
+
+This file is part of OpenWolf.
+
+OpenWolf is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+OpenWolf 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 OpenWolf; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+
+#include "cg_local.h"
+
+char *cg_buildableSoundNames[ MAX_BUILDABLE_ANIMATIONS ] =
+{
+ "construct1.wav",
+ "construct2.wav",
+ "idle1.wav",
+ "idle2.wav",
+ "idle3.wav",
+ "attack1.wav",
+ "attack2.wav",
+ "spawn1.wav",
+ "spawn2.wav",
+ "pain1.wav",
+ "pain2.wav",
+ "destroy1.wav",
+ "destroy2.wav",
+ "destroyed.wav"
+};
+
+static sfxHandle_t defaultAlienSounds[ MAX_BUILDABLE_ANIMATIONS ];
+static sfxHandle_t defaultHumanSounds[ MAX_BUILDABLE_ANIMATIONS ];
+
+/*
+===================
+CG_AlienBuildableExplosion
+
+Generated a bunch of gibs launching out from a location
+===================
+*/
+void CG_AlienBuildableExplosion( vec3_t origin, vec3_t dir )
+{
+ particleSystem_t *ps;
+
+ trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.alienBuildableExplosion );
+
+ //particle system
+ ps = CG_SpawnNewParticleSystem( cgs.media.alienBuildableDestroyedPS );
+
+ if( CG_IsParticleSystemValid( &ps ) )
+ {
+ CG_SetAttachmentPoint( &ps->attachment, origin );
+ CG_SetParticleSystemNormal( ps, dir );
+ CG_AttachToPoint( &ps->attachment );
+ }
+}
+
+/*
+=================
+CG_HumanBuildableExplosion
+
+Called for human buildables as they are destroyed
+=================
+*/
+void CG_HumanBuildableExplosion( vec3_t origin, vec3_t dir )
+{
+ particleSystem_t *ps;
+
+ trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.humanBuildableExplosion );
+
+ //particle system
+ ps = CG_SpawnNewParticleSystem( cgs.media.humanBuildableDestroyedPS );
+
+ if( CG_IsParticleSystemValid( &ps ) )
+ {
+ CG_SetAttachmentPoint( &ps->attachment, origin );
+ CG_SetParticleSystemNormal( ps, dir );
+ CG_AttachToPoint( &ps->attachment );
+ }
+}
+
+
+#define CREEP_SIZE 64.0f
+
+/*
+==================
+CG_Creep
+==================
+*/
+static void CG_Creep( centity_t *cent )
+{
+ int msec;
+ float size, frac;
+ trace_t tr;
+ vec3_t temp, origin;
+ int scaleUpTime = BG_FindBuildTimeForBuildable( cent->currentState.modelindex );
+ int time;
+
+ time = cent->currentState.time;
+
+ //should the creep be growing or receding?
+ if( time >= 0 )
+ {
+ msec = cg.time - time;
+ if( msec >= 0 && msec < scaleUpTime )
+ frac = (float)msec / scaleUpTime;
+ else
+ frac = 1.0f;
+ }
+ else if( time < 0 )
+ {
+ msec = cg.time + time;
+ if( msec >= 0 && msec < CREEP_SCALEDOWN_TIME )
+ frac = 1.0f - ( (float)msec / CREEP_SCALEDOWN_TIME );
+ else
+ frac = 0.0f;
+ }
+
+ VectorCopy( cent->currentState.origin2, temp );
+ VectorScale( temp, -4096, temp );
+ VectorAdd( temp, cent->lerpOrigin, temp );
+
+ CG_Trace( &tr, cent->lerpOrigin, NULL, NULL, temp, cent->currentState.number, MASK_SOLID );
+
+ VectorCopy( tr.endpos, origin );
+
+ size = CREEP_SIZE * frac;
+
+ if( size > 0.0f )
+ CG_ImpactMark( cgs.media.creepShader, origin, cent->currentState.origin2,
+ 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, qfalse, size, qtrue );
+}
+
+/*
+======================
+CG_ParseBuildableAnimationFile
+
+Read a configuration file containing animation counts and rates
+models/buildables/hivemind/animation.cfg, etc
+======================
+*/
+static qboolean CG_ParseBuildableAnimationFile( const char *filename, buildable_t buildable )
+{
+ char *text_p;
+ int len;
+ int i;
+ char *token;
+ float fps;
+ char text[ 20000 ];
+ fileHandle_t f;
+ animation_t *animations;
+
+ animations = cg_buildables[ buildable ].animations;
+
+ // load the file
+ len = trap_FS_FOpenFile( filename, &f, FS_READ );
+ if( len <= 0 )
+ return qfalse;
+
+ if( len >= sizeof( text ) - 1 )
+ {
+ CG_Printf( "File %s too long\n", filename );
+ return qfalse;
+ }
+
+ trap_FS_Read( text, len, f );
+ text[ len ] = 0;
+ trap_FS_FCloseFile( f );
+
+ // parse the text
+ text_p = text;
+
+ // read information for each frame
+ for( i = BANIM_NONE + 1; i < MAX_BUILDABLE_ANIMATIONS; i++ )
+ {
+
+ token = COM_Parse( &text_p );
+ if( !*token )
+ break;
+
+ animations[ i ].firstFrame = atoi( token );
+
+ token = COM_Parse( &text_p );
+ if( !*token )
+ break;
+
+ animations[ i ].numFrames = atoi( token );
+ animations[ i ].reversed = qfalse;
+ animations[ i ].flipflop = qfalse;
+
+ // if numFrames is negative the animation is reversed
+ if( animations[ i ].numFrames < 0 )
+ {
+ animations[ i ].numFrames = -animations[ i ].numFrames;
+ animations[ i ].reversed = qtrue;
+ }
+
+ token = COM_Parse( &text_p );
+ if ( !*token )
+ break;
+
+ animations[i].loopFrames = atoi( token );
+
+ token = COM_Parse( &text_p );
+ if( !*token )
+ break;
+
+ fps = atof( token );
+ if( fps == 0 )
+ fps = 1;
+
+ animations[ i ].frameLerp = 1000 / fps;
+ animations[ i ].initialLerp = 1000 / fps;
+ }
+
+ if( i != MAX_BUILDABLE_ANIMATIONS )
+ {
+ CG_Printf( "Error parsing animation file: %s\n", filename );
+ return qfalse;
+ }
+
+ return qtrue;
+}
+
+/*
+======================
+CG_ParseBuildableSoundFile
+
+Read a configuration file containing sound properties
+sound/buildables/hivemind/sound.cfg, etc
+======================
+*/
+static qboolean CG_ParseBuildableSoundFile( const char *filename, buildable_t buildable )
+{
+ char *text_p;
+ int len;
+ int i;
+ char *token;
+ char text[ 20000 ];
+ fileHandle_t f;
+ sound_t *sounds;
+
+ sounds = cg_buildables[ buildable ].sounds;
+
+ // load the file
+ len = trap_FS_FOpenFile( filename, &f, FS_READ );
+ if ( len <= 0 )
+ return qfalse;
+
+ if ( len >= sizeof( text ) - 1 )
+ {
+ CG_Printf( "File %s too long\n", filename );
+ return qfalse;
+ }
+
+ trap_FS_Read( text, len, f );
+ text[len] = 0;
+ trap_FS_FCloseFile( f );
+
+ // parse the text
+ text_p = text;
+
+ // read information for each frame
+ for( i = BANIM_NONE + 1; i < MAX_BUILDABLE_ANIMATIONS; i++ )
+ {
+
+ token = COM_Parse( &text_p );
+ if ( !*token )
+ break;
+
+ sounds[ i ].enabled = atoi( token );
+
+ token = COM_Parse( &text_p );
+ if ( !*token )
+ break;
+
+ sounds[ i ].looped = atoi( token );
+
+ }
+
+ if( i != MAX_BUILDABLE_ANIMATIONS )
+ {
+ CG_Printf( "Error parsing sound file: %s\n", filename );
+ return qfalse;
+ }
+
+ return qtrue;
+}
+/*
+===============
+CG_InitBuildables
+
+Initialises the animation db
+===============
+*/
+void CG_InitBuildables( void )
+{
+ char filename[ MAX_QPATH ];
+ char soundfile[ MAX_QPATH ];
+ char *buildableName;
+ char *modelFile;
+ int i;
+ int j;
+ fileHandle_t f;
+
+ memset( cg_buildables, 0, sizeof( cg_buildables ) );
+
+ //default sounds
+ for( j = BANIM_NONE + 1; j < MAX_BUILDABLE_ANIMATIONS; j++ )
+ {
+ strcpy( soundfile, cg_buildableSoundNames[ j - 1 ] );
+
+ Com_sprintf( filename, sizeof( filename ), "sound/buildables/alien/%s", soundfile );
+ defaultAlienSounds[ j ] = trap_S_RegisterSound( filename, qfalse );
+
+ Com_sprintf( filename, sizeof( filename ), "sound/buildables/human/%s", soundfile );
+ defaultHumanSounds[ j ] = trap_S_RegisterSound( filename, qfalse );
+ }
+
+ cg.buildablesFraction = 0.0f;
+
+ for( i = BA_NONE + 1; i < BA_NUM_BUILDABLES; i++ )
+ {
+ buildableName = BG_FindNameForBuildable( i );
+
+ //animation.cfg
+ Com_sprintf( filename, sizeof( filename ), "models/buildables/%s/animation.cfg", buildableName );
+ if ( !CG_ParseBuildableAnimationFile( filename, i ) )
+ Com_Printf( S_COLOR_YELLOW "WARNING: failed to load animation file %s\n", filename );
+
+ //sound.cfg
+ Com_sprintf( filename, sizeof( filename ), "sound/buildables/%s/sound.cfg", buildableName );
+ if ( !CG_ParseBuildableSoundFile( filename, i ) )
+ Com_Printf( S_COLOR_YELLOW "WARNING: failed to load sound file %s\n", filename );
+
+ //models
+ for( j = 0; j <= 3; j++ )
+ {
+ if( ( modelFile = BG_FindModelsForBuildable( i, j ) ) )
+ cg_buildables[ i ].models[ j ] = trap_R_RegisterModel( modelFile );
+ }
+
+ //sounds
+ for( j = BANIM_NONE + 1; j < MAX_BUILDABLE_ANIMATIONS; j++ )
+ {
+ strcpy( soundfile, cg_buildableSoundNames[ j - 1 ] );
+ Com_sprintf( filename, sizeof( filename ), "sound/buildables/%s/%s", buildableName, soundfile );
+
+ if( cg_buildables[ i ].sounds[ j ].enabled )
+ {
+ if( trap_FS_FOpenFile( filename, &f, FS_READ ) > 0 )
+ {
+ //file exists so close it
+ trap_FS_FCloseFile( f );
+
+ cg_buildables[ i ].sounds[ j ].sound = trap_S_RegisterSound( filename, qfalse );
+ }
+ else
+ {
+ //file doesn't exist - use default
+ if( BG_FindTeamForBuildable( i ) == BIT_ALIENS )
+ cg_buildables[ i ].sounds[ j ].sound = defaultAlienSounds[ j ];
+ else
+ cg_buildables[ i ].sounds[ j ].sound = defaultHumanSounds[ j ];
+ }
+ }
+ }
+
+ cg.buildablesFraction = (float)i / (float)( BA_NUM_BUILDABLES - 1 );
+ trap_UpdateScreen( );
+ }
+
+ cgs.media.teslaZapTS = CG_RegisterTrailSystem( "models/buildables/tesla/zap" );
+}
+
+/*
+===============
+CG_SetBuildableLerpFrameAnimation
+
+may include ANIM_TOGGLEBIT
+===============
+*/
+static void CG_SetBuildableLerpFrameAnimation( buildable_t buildable, lerpFrame_t *lf, int newAnimation )
+{
+ animation_t *anim;
+
+ lf->animationNumber = newAnimation;
+
+ if( newAnimation < 0 || newAnimation >= MAX_BUILDABLE_ANIMATIONS )
+ CG_Error( "Bad animation number: %i", newAnimation );
+
+ anim = &cg_buildables[ buildable ].animations[ newAnimation ];
+
+ //this item has just spawned so lf->frameTime will be zero
+ if( !lf->animation )
+ lf->frameTime = cg.time + 1000; //1 sec delay before starting the spawn anim
+
+ lf->animation = anim;
+ lf->animationTime = lf->frameTime + anim->initialLerp;
+
+ if( cg_debugAnim.integer )
+ CG_Printf( "Anim: %i\n", newAnimation );
+}
+
+/*
+===============
+CG_RunBuildableLerpFrame
+
+Sets cg.snap, cg.oldFrame, and cg.backlerp
+cg.time should be between oldFrameTime and frameTime after exit
+===============
+*/
+static void CG_RunBuildableLerpFrame( centity_t *cent )
+{
+ int f, numFrames;
+ buildable_t buildable = cent->currentState.modelindex;
+ lerpFrame_t *lf = &cent->lerpFrame;
+ animation_t *anim;
+ buildableAnimNumber_t newAnimation = cent->buildableAnim & ~( ANIM_TOGGLEBIT|ANIM_FORCEBIT );
+
+ // debugging tool to get no animations
+ if( cg_animSpeed.integer == 0 )
+ {
+ lf->oldFrame = lf->frame = lf->backlerp = 0;
+ return;
+ }
+
+ // see if the animation sequence is switching
+ if( newAnimation != lf->animationNumber || !lf->animation )
+ {
+ if( cg_debugRandom.integer )
+ CG_Printf( "newAnimation: %d lf->animationNumber: %d lf->animation: %p\n",
+ newAnimation, lf->animationNumber, lf->animation );
+
+ CG_SetBuildableLerpFrameAnimation( buildable, lf, newAnimation );
+
+ if( !cg_buildables[ buildable ].sounds[ newAnimation ].looped &&
+ cg_buildables[ buildable ].sounds[ newAnimation ].enabled )
+ {
+ if( cg_debugRandom.integer )
+ CG_Printf( "Sound for animation %d for a %s\n",
+ newAnimation, BG_FindHumanNameForBuildable( buildable ) );
+
+ trap_S_StartSound( cent->lerpOrigin, cent->currentState.number, CHAN_AUTO,
+ cg_buildables[ buildable ].sounds[ newAnimation ].sound );
+ }
+ }
+
+ if( cg_buildables[ buildable ].sounds[ lf->animationNumber ].looped &&
+ cg_buildables[ buildable ].sounds[ lf->animationNumber ].enabled )
+ /*trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin,
+ cg_buildables[ buildable ].sounds[ lf->animationNumber ].sound, 0 );*/
+
+ // if we have passed the current frame, move it to
+ // oldFrame and calculate a new frame
+ if( cg.time >= lf->frameTime )
+ {
+ lf->oldFrame = lf->frame;
+ lf->oldFrameTime = lf->frameTime;
+
+ // get the next frame based on the animation
+ anim = lf->animation;
+ if( !anim->frameLerp )
+ return; // shouldn't happen
+
+ if ( cg.time < lf->animationTime )
+ lf->frameTime = lf->animationTime; // initial lerp
+ else
+ lf->frameTime = lf->oldFrameTime + anim->frameLerp;
+
+ f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;
+ numFrames = anim->numFrames;
+ if(anim->flipflop)
+ numFrames *= 2;
+
+ if( f >= numFrames )
+ {
+ f -= numFrames;
+ if( anim->loopFrames )
+ {
+ f %= anim->loopFrames;
+ f += anim->numFrames - anim->loopFrames;
+ }
+ else
+ {
+ f = numFrames - 1;
+ // the animation is stuck at the end, so it
+ // can immediately transition to another sequence
+ lf->frameTime = cg.time;
+ cent->buildableAnim = cent->currentState.torsoAnim;
+ }
+ }
+
+ if( anim->reversed )
+ lf->frame = anim->firstFrame + anim->numFrames - 1 - f;
+ else if( anim->flipflop && f >= anim->numFrames )
+ lf->frame = anim->firstFrame + anim->numFrames - 1 - ( f % anim->numFrames );
+ else
+ lf->frame = anim->firstFrame + f;
+
+ if( cg.time > lf->frameTime )
+ {
+ lf->frameTime = cg.time;
+ if( cg_debugAnim.integer )
+ CG_Printf( "Clamp lf->frameTime\n");
+ }
+ }
+
+ if( lf->frameTime > cg.time + 200 )
+ lf->frameTime = cg.time;
+
+ if( lf->oldFrameTime > cg.time )
+ lf->oldFrameTime = cg.time;
+
+ // calculate current lerp value
+ if( lf->frameTime == lf->oldFrameTime )
+ lf->backlerp = 0;
+ else
+ lf->backlerp = 1.0 - (float)( cg.time - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );
+}
+
+/*
+===============
+CG_BuildableAnimation
+===============
+*/
+static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *backLerp )
+{
+ entityState_t *es = &cent->currentState;
+
+ //if no animation is set default to idle anim
+ if( cent->buildableAnim == BANIM_NONE )
+ cent->buildableAnim = es->torsoAnim;
+
+ //display the first frame of the construction anim if not yet spawned
+ if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) )
+ {
+ animation_t *anim = &cg_buildables[ es->modelindex ].animations[ BANIM_CONSTRUCT1 ];
+
+ //so that when animation starts for real it has sensible numbers
+ cent->lerpFrame.oldFrameTime =
+ cent->lerpFrame.frameTime =
+ cent->lerpFrame.animationTime =
+ cg.time;
+
+ *old = cent->lerpFrame.oldFrame = anim->firstFrame;
+ *now = cent->lerpFrame.frame = anim->firstFrame;
+ *backLerp = cent->lerpFrame.backlerp = 0.0f;
+
+ //ensure that an animation is triggered once the buildable has spawned
+ cent->oldBuildableAnim = BANIM_NONE;
+ }
+ else
+ {
+ if( ( cent->oldBuildableAnim ^ es->legsAnim ) & ANIM_TOGGLEBIT )
+ {
+ if( cg_debugAnim.integer )
+ CG_Printf( "%d->%d l:%d t:%d %s(%d)\n",
+ cent->oldBuildableAnim, cent->buildableAnim,
+ es->legsAnim, es->torsoAnim,
+ BG_FindHumanNameForBuildable( es->modelindex ), es->number );
+
+ if( cent->buildableAnim == es->torsoAnim || es->legsAnim & ANIM_FORCEBIT )
+ cent->buildableAnim = cent->oldBuildableAnim = es->legsAnim;
+ else
+ cent->buildableAnim = cent->oldBuildableAnim = es->torsoAnim;
+ }
+
+ CG_RunBuildableLerpFrame( cent );
+
+ *old = cent->lerpFrame.oldFrame;
+ *now = cent->lerpFrame.frame;
+ *backLerp = cent->lerpFrame.backlerp;
+ }
+}
+
+#define TRACE_DEPTH 64.0f
+
+/*
+===============
+CG_PositionAndOrientateBuildable
+===============
+*/
+static void CG_PositionAndOrientateBuildable( const vec3_t angles, const vec3_t inOrigin,
+ const vec3_t normal, const int skipNumber,
+ const vec3_t mins, const vec3_t maxs,
+ vec3_t outAxis[ 3 ], vec3_t outOrigin )
+{
+ vec3_t forward, start, end;
+ trace_t tr;
+
+ AngleVectors( angles, forward, NULL, NULL );
+ VectorCopy( normal, outAxis[ 2 ] );
+ ProjectPointOnPlane( outAxis[ 0 ], forward, outAxis[ 2 ] );
+
+ if( !VectorNormalize( outAxis[ 0 ] ) )
+ {
+ AngleVectors( angles, NULL, NULL, forward );
+ ProjectPointOnPlane( outAxis[ 0 ], forward, outAxis[ 2 ] );
+ VectorNormalize( outAxis[ 0 ] );
+ }
+
+ CrossProduct( outAxis[ 0 ], outAxis[ 2 ], outAxis[ 1 ] );
+ outAxis[ 1 ][ 0 ] = -outAxis[ 1 ][ 0 ];
+ outAxis[ 1 ][ 1 ] = -outAxis[ 1 ][ 1 ];
+ outAxis[ 1 ][ 2 ] = -outAxis[ 1 ][ 2 ];
+
+ VectorMA( inOrigin, -TRACE_DEPTH, normal, end );
+ VectorMA( inOrigin, 1.0f, normal, start );
+ CG_CapTrace( &tr, start, mins, maxs, end, skipNumber, MASK_SOLID );
+
+ if( tr.fraction == 1.0f )
+ {
+ //erm we missed completely - try again with a box trace
+ CG_Trace( &tr, start, mins, maxs, end, skipNumber, MASK_SOLID );
+ }
+
+ VectorMA( inOrigin, tr.fraction * -TRACE_DEPTH, normal, outOrigin );
+}
+
+/*
+==================
+CG_GhostBuildable
+==================
+*/
+void CG_GhostBuildable( buildable_t buildable )
+{
+ refEntity_t ent;
+ playerState_t *ps;
+ vec3_t angles, entity_origin;
+ vec3_t mins, maxs;
+ trace_t tr;
+ float scale;
+
+ ps = &cg.predictedPlayerState;
+
+ memset( &ent, 0, sizeof( ent ) );
+
+ BG_FindBBoxForBuildable( buildable, mins, maxs );
+
+ BG_PositionBuildableRelativeToPlayer( ps, mins, maxs, CG_Trace, entity_origin, angles, &tr );
+
+ CG_PositionAndOrientateBuildable( ps->viewangles, entity_origin, tr.plane.normal, ps->clientNum,
+ mins, maxs, ent.axis, ent.origin );
+
+ //offset on the Z axis if required
+ VectorMA( ent.origin, BG_FindZOffsetForBuildable( buildable ), tr.plane.normal, ent.origin );
+
+ VectorCopy( ent.origin, ent.lightingOrigin );
+ VectorCopy( ent.origin, ent.oldorigin ); // don't positionally lerp at all
+
+ ent.hModel = cg_buildables[ buildable ].models[ 0 ];
+
+ if( ps->stats[ STAT_BUILDABLE ] & SB_VALID_TOGGLEBIT )
+ ent.customShader = cgs.media.greenBuildShader;
+ else
+ ent.customShader = cgs.media.redBuildShader;
+
+ //rescale the model
+ scale = BG_FindModelScaleForBuildable( buildable );
+
+ if( scale != 1.0f )
+ {
+ VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] );
+ VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] );
+ VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] );
+
+ ent.nonNormalizedAxes = qtrue;
+ }
+ else
+ ent.nonNormalizedAxes = qfalse;
+
+ // add to refresh list
+ trap_R_AddRefEntityToScene( &ent );
+}
+
+/*
+==================
+CG_BuildableParticleEffects
+==================
+*/
+static void CG_BuildableParticleEffects( centity_t *cent )
+{
+ entityState_t *es = &cent->currentState;
+ buildableTeam_t team = BG_FindTeamForBuildable( es->modelindex );
+ int health = es->generic1 & ~( B_POWERED_TOGGLEBIT | B_DCCED_TOGGLEBIT | B_SPAWNED_TOGGLEBIT );
+ float healthFrac = (float)health / B_HEALTH_SCALE;
+
+ if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) )
+ return;
+
+ if( team == BIT_HUMANS )
+ {
+ if( healthFrac < 0.33f && !CG_IsParticleSystemValid( &cent->buildablePS ) )
+ {
+ cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.humanBuildableDamagedPS );
+
+ if( CG_IsParticleSystemValid( &cent->buildablePS ) )
+ {
+ CG_SetAttachmentCent( &cent->buildablePS->attachment, cent );
+ CG_AttachToCent( &cent->buildablePS->attachment );
+ }
+ }
+ else if( healthFrac >= 0.33f && CG_IsParticleSystemValid( &cent->buildablePS ) )
+ CG_DestroyParticleSystem( &cent->buildablePS );
+ }
+ else if( team == BIT_ALIENS )
+ {
+ if( healthFrac < 0.33f && !CG_IsParticleSystemValid( &cent->buildablePS ) )
+ {
+ cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.alienBuildableDamagedPS );
+
+ if( CG_IsParticleSystemValid( &cent->buildablePS ) )
+ {
+ CG_SetAttachmentCent( &cent->buildablePS->attachment, cent );
+ CG_SetParticleSystemNormal( cent->buildablePS, es->origin2 );
+