Used clang-format on cgame module

This commit is contained in:
smallmodel 2023-07-05 21:24:23 +02:00
parent 13828994fb
commit f930d39a42
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
33 changed files with 9525 additions and 10982 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -61,22 +61,25 @@ Debugging command to print the current position
*/
static void CG_Viewpos_f(void)
{
cgi.Printf("(%i %i %i) : %i\n", (int)cg.refdef.vieworg[0],
(int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2],
(int)cg.refdefViewAngles[YAW]);
cgi.Printf(
"(%i %i %i) : %i\n",
(int)cg.refdef.vieworg[0],
(int)cg.refdef.vieworg[1],
(int)cg.refdef.vieworg[2],
(int)cg.refdefViewAngles[YAW]
);
}
void CG_SetDesiredObjectiveAlpha(float fAlpha)
{
cg.ObjectivesDesiredAlpha = fAlpha;
cg.ObjectivesAlphaTime = (float)(cg.time + 250);
cg.ObjectivesBaseAlpha = cg.ObjectivesCurrentAlpha;
cg.ObjectivesAlphaTime = (float)(cg.time + 250);
cg.ObjectivesBaseAlpha = cg.ObjectivesCurrentAlpha;
}
void CG_ScoresDown_f( void )
void CG_ScoresDown_f(void)
{
if (cgs.gametype == GT_SINGLE_PLAYER)
{
if (cgs.gametype == GT_SINGLE_PLAYER) {
if (!cg.scoresRequestTime) {
cg.scoresRequestTime = cg.time;
CG_SetDesiredObjectiveAlpha(1.0f);
@ -85,32 +88,29 @@ void CG_ScoresDown_f( void )
return;
}
if ( cg.scoresRequestTime + 2000 >= cg.time )
{
if (cg.scoresRequestTime + 2000 >= cg.time) {
// send another request
cg.showScores = qtrue;
CG_PrepScoreBoardInfo();
cgi.UI_ShowScoreBoard(cg.scoresMenuName);
return;
}
cg.scoresRequestTime = cg.time;
cgi.SendClientCommand( "score" );
return;
}
if ( !cg.showScores ) {
// don't display anything until first score returns
cg.showScores = qtrue;
cg.scoresRequestTime = cg.time;
cgi.SendClientCommand("score");
if (!cg.showScores) {
// don't display anything until first score returns
cg.showScores = qtrue;
CG_PrepScoreBoardInfo();
cgi.UI_ShowScoreBoard(cg.scoresMenuName);
}
}
}
void CG_ScoresUp_f( void )
void CG_ScoresUp_f(void)
{
if (cgs.gametype == GT_SINGLE_PLAYER)
{
if (!cg.scoresRequestTime)
{
if (cgs.gametype == GT_SINGLE_PLAYER) {
if (!cg.scoresRequestTime) {
cg.scoresRequestTime = cg.time;
CG_SetDesiredObjectiveAlpha(0.0f);
}
@ -126,12 +126,12 @@ void CG_ScoresUp_f( void )
cgi.UI_HideScoreBoard();
}
baseshader_t* CG_GetShaderUnderCrosshair(qboolean bVerbose, trace_t* pRetTrace)
baseshader_t *CG_GetShaderUnderCrosshair(qboolean bVerbose, trace_t *pRetTrace)
{
vec3_t vPos, vEnd;
vec3_t axis[3];
baseshader_t* pShader;
trace_t trace;
vec3_t vPos, vEnd;
vec3_t axis[3];
baseshader_t *pShader;
trace_t trace;
AnglesToAxis(cg.refdefViewAngles, axis);
vPos[0] = cg.refdef.vieworg[0];
@ -140,18 +140,13 @@ baseshader_t* CG_GetShaderUnderCrosshair(qboolean bVerbose, trace_t* pRetTrace)
VectorMA(vPos, 4096.0, axis[0], vEnd);
CG_Trace(&trace, vPos, vec3_origin, vec3_origin, vEnd, 0, MASK_SHOT, 0, 0, "CG_GetShaderUnderCrosshair");
if (trace.startsolid || trace.fraction == 1.0) {
return NULL;
}
if (bVerbose)
{
cgi.Printf(
"Surface hit at (%i %i %i)\n",
(int)trace.endpos[0],
(int)trace.endpos[1],
(int)trace.endpos[2]);
if (bVerbose) {
cgi.Printf("Surface hit at (%i %i %i)\n", (int)trace.endpos[0], (int)trace.endpos[1], (int)trace.endpos[2]);
}
pShader = cgi.GetShader(trace.shaderNum);
@ -179,19 +174,15 @@ static void CG_PrintSurfaceType(int iSurfType)
void CG_GetCHShader(void)
{
trace_t trace;
baseshader_t* pShader;
trace_t trace;
baseshader_t *pShader;
pShader = CG_GetShaderUnderCrosshair(qtrue, &trace);
cgi.Printf("\n");
if (pShader)
{
if (pShader->surfaceFlags & SURF_SKY)
{
if (pShader) {
if (pShader->surfaceFlags & SURF_SKY) {
cgi.Printf("Hit the sky\n");
}
else
{
} else {
cgi.Printf("Shader: %s\n", pShader->shader);
cgi.Printf("Shader Contents:");
CG_PrintContentTypes(pShader->contentFlags);
@ -212,28 +203,23 @@ void CG_GetCHShader(void)
CG_PrintSurfaceType(trace.surfaceFlags);
cgi.Printf("\n\n");
}
}
else
{
} else {
cgi.Printf("No surface selected\n");
}
}
void CG_EditCHShader(void)
{
char name[1024];
baseshader_t* pShader;
char name[1024];
baseshader_t *pShader;
pShader = CG_GetShaderUnderCrosshair(qfalse, NULL);
if (pShader)
{
if (pShader) {
strcpy(name, "editspecificshader ");
strcat(name, pShader->shader);
strcat(name, "\n");
cgi.AddCommand(name);
}
else
{
} else {
cgi.Printf("No surface selected\n");
}
}
@ -348,61 +334,61 @@ void CG_AddTestModel (void) {
#endif
typedef struct {
char* cmd;
char *cmd;
void (*function)(void);
} consoleCommand_t;
static consoleCommand_t commands[] = {
{ "useweaponclass", &CG_UseWeaponClass_f },
{ "weapnext", &CG_NextWeapon_f },
{ "weapprev", &CG_PrevWeapon_f },
{ "uselast", &CG_UseLastWeapon_f },
{ "holster", &CG_HolsterWeapon_f },
{ "weapdrop", &CG_DropWeapon_f },
{ "toggleitem", &CG_ToggleItem_f },
{ "+scores", &CG_ScoresDown_f },
{ "-scores", &CG_ScoresUp_f },
{ "viewpos", &CG_Viewpos_f },
{ "sizeup", &CG_SizeUp_f },
{ "sizedown", &CG_SizeDown_f },
{ "cg_eventlist", &CG_EventList_f },
{ "cg_eventhelp", &CG_EventHelp_f },
{ "cg_dumpevents", &CG_DumpEventHelp_f },
{ "cg_pendingevents", &CG_PendingEvents_f },
{ "cg_classlist", &CG_ClassList_f },
{ "cg_classtree", &CG_ClassTree_f },
{ "cg_classevents", &CG_ClassEvents_f },
{ "cg_dumpclassevents", &CG_DumpClassEvents_f },
{ "cg_dumpallclasses", &CG_DumpAllClasses_f },
{ "testemitter", &CG_TestEmitter_f },
{ "triggertestemitter", &CG_TriggerTestEmitter_f },
{ "prevemittercommand", &CG_PrevEmitterCommand_f },
{ "nextemittercommand", &CG_NextEmitterCommand_f },
{ "newemittercommand", &CG_NewEmitterCommand_f },
{ "deleteemittercommand", &CG_DeleteEmitterCommand_f },
{ "dumpemitter", &CG_DumpEmitter_f },
{ "loademitter", &CG_LoadEmitter_f },
{ "resetvss", &CG_ResetVSSSources },
{ "getchshader", &CG_GetCHShader },
{ "editchshader", &CG_EditCHShader },
{ "messagemode", &CG_MessageMode_f },
{ "messagemode_all", &CG_MessageMode_All_f },
{ "messagemode_team", &CG_MessageMode_Team_f },
{ "messagemode_private", &CG_MessageMode_Private_f },
{ "say", &CG_MessageSingleAll_f },
{ "sayteam", &CG_MessageSingleTeam_f },
{ "teamsay", &CG_MessageSingleTeam_f },
{ "sayprivate", &CG_MessageSingleClient_f },
{ "sayone", &CG_MessageSingleClient_f },
{ "wisper", &CG_MessageSingleClient_f },
{ "instamsg_main", &CG_InstaMessageMain_f },
{ "instamsg_group_a", &CG_InstaMessageGroupA_f },
{ "instamsg_group_b", &CG_InstaMessageGroupB_f },
{ "instamsg_group_c", &CG_InstaMessageGroupC_f },
{ "instamsg_group_d", &CG_InstaMessageGroupD_f },
{ "instamsg_group_e", &CG_InstaMessageGroupE_f },
{ "pushmenu_teamselect", &CG_PushMenuTeamSelect_f },
{ "pushmenu_weaponselect", &CG_PushMenuWeaponSelect_f },
{"useweaponclass", &CG_UseWeaponClass_f },
{"weapnext", &CG_NextWeapon_f },
{"weapprev", &CG_PrevWeapon_f },
{"uselast", &CG_UseLastWeapon_f },
{"holster", &CG_HolsterWeapon_f },
{"weapdrop", &CG_DropWeapon_f },
{"toggleitem", &CG_ToggleItem_f },
{"+scores", &CG_ScoresDown_f },
{"-scores", &CG_ScoresUp_f },
{"viewpos", &CG_Viewpos_f },
{"sizeup", &CG_SizeUp_f },
{"sizedown", &CG_SizeDown_f },
{"cg_eventlist", &CG_EventList_f },
{"cg_eventhelp", &CG_EventHelp_f },
{"cg_dumpevents", &CG_DumpEventHelp_f },
{"cg_pendingevents", &CG_PendingEvents_f },
{"cg_classlist", &CG_ClassList_f },
{"cg_classtree", &CG_ClassTree_f },
{"cg_classevents", &CG_ClassEvents_f },
{"cg_dumpclassevents", &CG_DumpClassEvents_f },
{"cg_dumpallclasses", &CG_DumpAllClasses_f },
{"testemitter", &CG_TestEmitter_f },
{"triggertestemitter", &CG_TriggerTestEmitter_f },
{"prevemittercommand", &CG_PrevEmitterCommand_f },
{"nextemittercommand", &CG_NextEmitterCommand_f },
{"newemittercommand", &CG_NewEmitterCommand_f },
{"deleteemittercommand", &CG_DeleteEmitterCommand_f},
{"dumpemitter", &CG_DumpEmitter_f },
{"loademitter", &CG_LoadEmitter_f },
{"resetvss", &CG_ResetVSSSources },
{"getchshader", &CG_GetCHShader },
{"editchshader", &CG_EditCHShader },
{"messagemode", &CG_MessageMode_f },
{"messagemode_all", &CG_MessageMode_All_f },
{"messagemode_team", &CG_MessageMode_Team_f },
{"messagemode_private", &CG_MessageMode_Private_f },
{"say", &CG_MessageSingleAll_f },
{"sayteam", &CG_MessageSingleTeam_f },
{"teamsay", &CG_MessageSingleTeam_f },
{"sayprivate", &CG_MessageSingleClient_f },
{"sayone", &CG_MessageSingleClient_f },
{"wisper", &CG_MessageSingleClient_f },
{"instamsg_main", &CG_InstaMessageMain_f },
{"instamsg_group_a", &CG_InstaMessageGroupA_f },
{"instamsg_group_b", &CG_InstaMessageGroupB_f },
{"instamsg_group_c", &CG_InstaMessageGroupC_f },
{"instamsg_group_d", &CG_InstaMessageGroupD_f },
{"instamsg_group_e", &CG_InstaMessageGroupE_f },
{"pushmenu_teamselect", &CG_PushMenuTeamSelect_f },
{"pushmenu_weaponselect", &CG_PushMenuWeaponSelect_f},
};
/*
@ -415,8 +401,8 @@ Cmd_Argc() / Cmd_Argv()
*/
qboolean CG_ConsoleCommand(void)
{
const char* cmd;
int i;
const char *cmd;
int i;
cmd = cgi.Argv(0);
@ -475,7 +461,7 @@ void CG_PushMenuTeamSelect_f(void)
default:
cgi.Cmd_Execute(EXEC_NOW, "pushmenu SelectTeam\n");
break;
}
}
}
void CG_PushMenuWeaponSelect_f(void)
@ -489,7 +475,7 @@ void CG_PushMenuWeaponSelect_f(void)
void CG_UseWeaponClass_f(void)
{
const char* cmd;
const char *cmd;
cmd = cgi.Argv(1);
@ -520,37 +506,37 @@ void CG_UseWeaponClass_f(void)
void CG_NextWeapon_f(void)
{
cg.iWeaponCommand = WEAPON_COMMAND_USE_NEXT_WEAPON;
cg.iWeaponCommand = WEAPON_COMMAND_USE_NEXT_WEAPON;
cg.iWeaponCommandSend = 0;
}
void CG_PrevWeapon_f(void)
{
cg.iWeaponCommand = WEAPON_COMMAND_USE_PREV_WEAPON;
cg.iWeaponCommand = WEAPON_COMMAND_USE_PREV_WEAPON;
cg.iWeaponCommandSend = 0;
}
void CG_UseLastWeapon_f(void)
{
cg.iWeaponCommand = WEAPON_COMMAND_USE_LAST_WEAPON;
cg.iWeaponCommand = WEAPON_COMMAND_USE_LAST_WEAPON;
cg.iWeaponCommandSend = 0;
}
void CG_HolsterWeapon_f(void)
{
cg.iWeaponCommand = WEAPON_COMMAND_HOLSTER;
cg.iWeaponCommand = WEAPON_COMMAND_HOLSTER;
cg.iWeaponCommandSend = 0;
}
void CG_DropWeapon_f(void)
{
cg.iWeaponCommand = WEAPON_COMMAND_DROP;
cg.iWeaponCommand = WEAPON_COMMAND_DROP;
cg.iWeaponCommandSend = 0;
}
void CG_ToggleItem_f(void)
{
cg.iWeaponCommand = WEAPON_COMMAND_USE_ITEM1;
cg.iWeaponCommand = WEAPON_COMMAND_USE_ITEM1;
cg.iWeaponCommandSend = 0;
}
@ -562,7 +548,7 @@ int CG_WeaponCommandButtonBits(void)
return 0;
}
iShiftedWeaponCommand = cg.iWeaponCommand << 7;
iShiftedWeaponCommand = cg.iWeaponCommand << 7;
cg.iWeaponCommandSend++;
if (cg.iWeaponCommandSend > 2) {

File diff suppressed because it is too large Load diff

View file

@ -37,48 +37,42 @@ FUNCTIONS CALLED EACH FRAME
CG_SetEntitySoundPosition
======================
*/
void CG_SetEntitySoundPosition( centity_t *cent )
{
vec3_t origin;
void CG_SetEntitySoundPosition(centity_t *cent)
{
vec3_t origin;
if ( cent->currentState.solid == SOLID_BMODEL )
{
float *v;
vec3_t vel;
if (cent->currentState.solid == SOLID_BMODEL) {
float *v;
vec3_t vel;
v = cgs.inlineModelMidpoints[ cent->currentState.modelindex ];
VectorAdd( cent->lerpOrigin, v, origin );
v = cgs.inlineModelMidpoints[cent->currentState.modelindex];
VectorAdd(cent->lerpOrigin, v, origin);
vel[0] = 0.0;
vel[1] = 0.0;
vel[2] = 0.0;
vel[0] = 0.0;
vel[1] = 0.0;
vel[2] = 0.0;
cgi.S_UpdateEntity( cent->currentState.number, origin, vel, qfalse );
}
else
{
if ( cent && cg.snap && cent->currentState.parent == cg.snap->ps.clientNum )
{
vec3_t origin;
vec3_t velocity;
cgi.S_UpdateEntity(cent->currentState.number, origin, vel, qfalse);
} else {
if (cent && cg.snap && cent->currentState.parent == cg.snap->ps.clientNum) {
vec3_t origin;
vec3_t velocity;
origin[0] = 0;
origin[1] = 0;
origin[2] = 0;
origin[0] = 0;
origin[1] = 0;
origin[2] = 0;
velocity[0] = 0;
velocity[1] = 0;
velocity[2] = 0;
velocity[0] = 0;
velocity[1] = 0;
velocity[2] = 0;
cgi.S_UpdateEntity( cent->currentState.number, origin, velocity, qtrue );
}
else
{
CG_GetOrigin( cent, origin );
cgi.S_UpdateEntity( cent->currentState.number, origin, cent->currentState.pos.trDelta, qfalse );
}
}
}
cgi.S_UpdateEntity(cent->currentState.number, origin, velocity, qtrue);
} else {
CG_GetOrigin(cent, origin);
cgi.S_UpdateEntity(cent->currentState.number, origin, cent->currentState.pos.trDelta, qfalse);
}
}
}
/*
==================
@ -87,165 +81,173 @@ CG_EntityEffects
Add continuous entity effects, like local entity emission and lighting
==================
*/
void CG_EntityEffects( centity_t *cent )
{
// initialize with the client colors
cent->color[ 0 ] = cent->client_color[ 0 ];
cent->color[ 1 ] = cent->client_color[ 1 ];
cent->color[ 2 ] = cent->client_color[ 2 ];
cent->color[ 3 ] = cent->client_color[ 3 ];
void CG_EntityEffects(centity_t *cent)
{
// initialize with the client colors
cent->color[0] = cent->client_color[0];
cent->color[1] = cent->client_color[1];
cent->color[2] = cent->client_color[2];
cent->color[3] = cent->client_color[3];
if ( cent->currentState.constantLight != 0xffffff )
{
int style;
unsigned cl;
float i, r, g, b;
if (cent->currentState.constantLight != 0xffffff) {
int style;
unsigned cl;
float i, r, g, b;
cl = cent->currentState.constantLight;
style = ( cl & 255 );
r = ( float )style / 255.0f;
g = ( float )( ( cl >> 8 ) & 255 ) / 255.0f;
b = ( float )( ( cl >> 16 ) & 255 ) / 255.0f;
i = ( ( cl >> 24 ) & 255 ) * CONSTANTLIGHT_RADIUS_SCALE;
if ( cent->currentState.renderfx & RF_LIGHTSTYLE_DLIGHT )
{
float color[ 4 ];
cl = cent->currentState.constantLight;
style = (cl & 255);
r = (float)style / 255.0f;
g = (float)((cl >> 8) & 255) / 255.0f;
b = (float)((cl >> 16) & 255) / 255.0f;
i = ((cl >> 24) & 255) * CONSTANTLIGHT_RADIUS_SCALE;
if (cent->currentState.renderfx & RF_LIGHTSTYLE_DLIGHT) {
float color[4];
CG_LightStyleColor( style, cg.time, color, qfalse );
r = color[ 0 ];
g = color[ 1 ];
b = color[ 2 ];
i *= color[ 3 ];
}
if ( i )
{
int flags;
CG_LightStyleColor(style, cg.time, color, qfalse);
r = color[0];
g = color[1];
b = color[2];
i *= color[3];
}
if (i) {
int flags;
flags = 0;
if ( cent->currentState.renderfx & RF_LENSFLARE )
{
flags |= lensflare;
flags = 0;
if (cent->currentState.renderfx & RF_LENSFLARE) {
flags |= lensflare;
} else if (cent->currentState.renderfx & RF_VIEWLENSFLARE) {
flags |= viewlensflare;
}
else if ( cent->currentState.renderfx & RF_VIEWLENSFLARE )
{
flags |= viewlensflare;
if (cent->currentState.renderfx & RF_ADDITIVE_DLIGHT) {
flags |= additive;
}
if ( cent->currentState.renderfx & RF_ADDITIVE_DLIGHT )
{
flags |= additive;
}
cgi.R_AddLightToScene( cent->lerpOrigin, i, r, g, b, flags );
}
if ( r < cent->color[ 0 ] )
cent->color[ 0 ] = r;
if ( g < cent->color[ 1 ] )
cent->color[ 1 ] = g;
if ( b < cent->color[ 2 ] )
cent->color[ 2 ] = b;
}
}
cgi.R_AddLightToScene(cent->lerpOrigin, i, r, g, b, flags);
}
if (r < cent->color[0]) {
cent->color[0] = r;
}
if (g < cent->color[1]) {
cent->color[1] = g;
}
if (b < cent->color[2]) {
cent->color[2] = b;
}
}
}
/*
==================
CG_General
==================
*/
void CG_General( centity_t *cent ) {
refEntity_t ent;
entityState_t *s1;
int i;
vec3_t vMins, vMaxs, vTmp;
void CG_General(centity_t *cent)
{
refEntity_t ent;
entityState_t *s1;
int i;
vec3_t vMins, vMaxs, vTmp;
s1 = &cent->currentState;
s1 = &cent->currentState;
// add loop sound
if ( s1->loopSound )
{
cgi.S_AddLoopingSound( cent->lerpOrigin, vec3_origin, cgs.sound_precache[s1->loopSound], s1->loopSoundVolume, s1->loopSoundMinDist, s1->loopSoundMaxDist, s1->loopSoundPitch, s1->loopSoundFlags );
}
if ( cent->tikiLoopSound )
cgi.S_AddLoopingSound( cent->lerpOrigin, vec3_origin, cent->tikiLoopSound, cent->tikiLoopSoundVolume, cent->tikiLoopSoundMinDist, cent->tikiLoopSoundMaxDist, cent->tikiLoopSoundPitch, cent->tikiLoopSoundFlags );
// add loop sound
if (s1->loopSound) {
cgi.S_AddLoopingSound(
cent->lerpOrigin,
vec3_origin,
cgs.sound_precache[s1->loopSound],
s1->loopSoundVolume,
s1->loopSoundMinDist,
s1->loopSoundMaxDist,
s1->loopSoundPitch,
s1->loopSoundFlags
);
}
if (cent->tikiLoopSound) {
cgi.S_AddLoopingSound(
cent->lerpOrigin,
vec3_origin,
cent->tikiLoopSound,
cent->tikiLoopSoundVolume,
cent->tikiLoopSoundMinDist,
cent->tikiLoopSoundMaxDist,
cent->tikiLoopSoundPitch,
cent->tikiLoopSoundFlags
);
}
// if set to invisible, skip
if (!s1->modelindex) {
return;
}
// if set to invisible, skip
if (!s1->modelindex) {
return;
}
memset (&ent, 0, sizeof(ent));
memset(&ent, 0, sizeof(ent));
// set frame
// set frame
ent.wasframe = s1->wasframe;
ent.wasframe = s1->wasframe;
VectorCopy( cent->lerpOrigin, ent.origin);
VectorCopy( cent->lerpOrigin, ent.oldorigin);
VectorCopy(cent->lerpOrigin, ent.origin);
VectorCopy(cent->lerpOrigin, ent.oldorigin);
// set skin
IntegerToBoundingBox(s1->solid, vMins, vMaxs);
VectorSubtract(vMins, vMaxs, vTmp);
// set skin
IntegerToBoundingBox(s1->solid, vMins, vMaxs);
VectorSubtract(vMins, vMaxs, vTmp);
ent.lightingOrigin[0] = ent.origin[0] + (vMins[0] + vMaxs[0]) * 0.5;
ent.lightingOrigin[1] = ent.origin[1] + (vMins[1] + vMaxs[1]) * 0.5;
ent.lightingOrigin[2] = ent.origin[2] + (vMins[2] + vMaxs[2]) * 0.5;
ent.radius = VectorLength(vTmp) * 0.5;
ent.radius = VectorLength(vTmp) * 0.5;
ent.skinNum = s1->skinNum;
ent.skinNum = s1->skinNum;
ent.hModel = cgs.model_draw[s1->modelindex];
ent.hModel = cgs.model_draw[s1->modelindex];
// set surfaces
memcpy( ent.surfaces, s1->surfaces, MAX_MODEL_SURFACES );
// set surfaces
memcpy(ent.surfaces, s1->surfaces, MAX_MODEL_SURFACES);
// Modulation based off the color
for( i=0; i<3; i++ )
ent.shaderRGBA[ i ] = cent->color[ i ] * 255;
// Modulation based off the color
for (i = 0; i < 3; i++) {
ent.shaderRGBA[i] = cent->color[i] * 255;
}
// take the alpha from the entity if less than 1, else grab it from the client commands version
if ( s1->alpha < 1 )
{
ent.shaderRGBA[ 3 ] = s1->alpha * 255;
}
else
{
ent.shaderRGBA[ 3 ] = cent->color[ 3 ] * 255;
}
// take the alpha from the entity if less than 1, else grab it from the client commands version
if (s1->alpha < 1) {
ent.shaderRGBA[3] = s1->alpha * 255;
} else {
ent.shaderRGBA[3] = cent->color[3] * 255;
}
// convert angles to axis
AnglesToAxis( cent->lerpAngles, ent.axis );
// convert angles to axis
AnglesToAxis(cent->lerpAngles, ent.axis);
// Interpolated state variables
if ( cent->interpolate )
{
ent.scale = s1->scale + cg.frameInterpolation * ( cent->nextState.scale - cent->currentState.scale );
}
else
{
ent.scale = s1->scale;
}
// set the entity number
ent.entityNumber = s1->number;
// Interpolated state variables
if (cent->interpolate) {
ent.scale = s1->scale + cg.frameInterpolation * (cent->nextState.scale - cent->currentState.scale);
} else {
ent.scale = s1->scale;
}
// set the entity number
ent.entityNumber = s1->number;
// copy shader specific data
ent.shader_data[ 0 ] = s1->tag_num;
ent.shader_data[ 1 ] = s1->skinNum;
ent.renderfx |= s1->renderfx;
// copy shader specific data
ent.shader_data[0] = s1->tag_num;
ent.shader_data[1] = s1->skinNum;
ent.renderfx |= s1->renderfx;
if ( ent.renderfx & RF_SKYORIGIN )
{
memcpy( cg.sky_axis, ent.axis, sizeof( cg.sky_axis ) );
VectorCopy( ent.origin, cg.sky_origin );
}
if (ent.renderfx & RF_SKYORIGIN) {
memcpy(cg.sky_axis, ent.axis, sizeof(cg.sky_axis));
VectorCopy(ent.origin, cg.sky_origin);
}
ent.tiki = cgi.R_Model_GetHandle(cgs.model_draw[s1->modelindex]);
ent.frameInfo[0].index = s1->frameInfo[0].index;
ent.frameInfo[0].time = s1->frameInfo[0].time;
ent.frameInfo[0].weight = s1->frameInfo[0].weight;
ent.actionWeight = 1.0;
ent.tiki = cgi.R_Model_GetHandle(cgs.model_draw[s1->modelindex]);
ent.frameInfo[0].index = s1->frameInfo[0].index;
ent.frameInfo[0].time = s1->frameInfo[0].time;
ent.frameInfo[0].weight = s1->frameInfo[0].weight;
ent.actionWeight = 1.0;
// add to refresh list
cgi.R_AddRefEntityToScene (&ent, ENTITYNUM_NONE);
// add to refresh list
cgi.R_AddRefEntityToScene(&ent, ENTITYNUM_NONE);
if (ent.tiki)
{
if (ent.tiki) {
// update any emitter's...
CG_UpdateEntityEmitters(s1->number, &ent, cent);
}
@ -258,58 +260,57 @@ CG_Speaker
Speaker entities can automatically play sounds
==================
*/
void CG_Speaker( centity_t *cent )
{
if ( ! cent->currentState.clientNum ) // FIXME: use something other than clientNum...
{
return; // not auto triggering
}
void CG_Speaker(centity_t *cent)
{
if (!cent->currentState.clientNum) // FIXME: use something other than clientNum...
{
return; // not auto triggering
}
if ( cg.time < cent->miscTime )
{
return;
}
// FIXME
//cgi.S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.sound_precache[cent->currentState.eventParm] );
if (cg.time < cent->miscTime) {
return;
}
// ent->s.frame = ent->wait * 10;
// ent->s.clientNum = ent->random * 10;
cent->miscTime = cg.time + cent->currentState.wasframe * 100 + cent->currentState.clientNum * 100 * crandom();
}
// FIXME
//cgi.S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.sound_precache[cent->currentState.eventParm] );
// ent->s.frame = ent->wait * 10;
// ent->s.clientNum = ent->random * 10;
cent->miscTime = cg.time + cent->currentState.wasframe * 100 + cent->currentState.clientNum * 100 * crandom();
}
/*
===============
CG_Mover
===============
*/
void CG_Mover( centity_t *cent ) {
refEntity_t ent;
entityState_t *s1;
void CG_Mover(centity_t *cent)
{
refEntity_t ent;
entityState_t *s1;
s1 = &cent->currentState;
s1 = &cent->currentState;
// create the render entity
memset (&ent, 0, sizeof(ent));
VectorCopy( cent->lerpOrigin, ent.origin);
VectorCopy( cent->lerpOrigin, ent.oldorigin);
AnglesToAxis( cent->lerpAngles, ent.axis );
// 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_SHADOW;
ent.renderfx &= ~RF_SHADOW;
// flicker between two skins (FIXME?)
ent.skinNum = ( cg.time >> 6 ) & 1;
// flicker between two skins (FIXME?)
ent.skinNum = (cg.time >> 6) & 1;
// get the model, either as a bmodel or a modelindex
if ( s1->solid == SOLID_BMODEL ) {
ent.hModel = cgs.inlineDrawModel[s1->modelindex];
} else {
ent.hModel = cgs.model_draw[s1->modelindex];
}
// get the model, either as a bmodel or a modelindex
if (s1->solid == SOLID_BMODEL) {
ent.hModel = cgs.inlineDrawModel[s1->modelindex];
} else {
ent.hModel = cgs.model_draw[s1->modelindex];
}
// add to refresh list
cgi.R_AddRefEntityToScene(&ent, ENTITYNUM_NONE);
// add to refresh list
cgi.R_AddRefEntityToScene(&ent, ENTITYNUM_NONE);
}
/*
@ -317,120 +318,116 @@ void CG_Mover( centity_t *cent ) {
CG_Beam
===============
*/
void CG_Beam( centity_t *cent ) {
entityState_t *s1;
vec3_t vz={0,0,0},origin={0,0,0};
float modulate[4];
int i;
void CG_Beam(centity_t *cent)
{
entityState_t *s1;
vec3_t vz = {0, 0, 0}, origin = {0, 0, 0};
float modulate[4];
int i;
s1 = &cent->currentState;
s1 = &cent->currentState;
for ( i=0;i<4;i++ )
modulate[i] = cent->color[i];
for (i = 0; i < 4; i++) {
modulate[i] = cent->color[i];
}
if ( s1->beam_entnum != ENTITYNUM_NONE )
{
refEntity_t *parent;
parent = cgi.R_GetRenderEntity( s1->beam_entnum);
if (s1->beam_entnum != ENTITYNUM_NONE) {
refEntity_t *parent;
parent = cgi.R_GetRenderEntity(s1->beam_entnum);
if ( !parent )
{
cgi.DPrintf( "CG_Beam: Could not find parent entity\n" );
return;
}
if (!parent) {
cgi.DPrintf("CG_Beam: Could not find parent entity\n");
return;
}
VectorAdd( s1->origin, parent->origin, origin );
}
else
{
VectorCopy( s1->origin, origin );
}
VectorAdd(s1->origin, parent->origin, origin);
} else {
VectorCopy(s1->origin, origin);
}
CG_CreateBeam( origin, // start
vz, // dir ( auto calculated by using origin2-origin )
s1->number, // owner number
cgs.model_draw[s1->modelindex], //hModel
s1->alpha, // alpha
s1->scale, // scale
s1->skinNum, // flags
0, // length ( auto calculated )
PKT_TO_BEAM_PARM( s1->surfaces[0] ) * 1000, // life
qfalse, // don't always create the beam, just update it
s1->origin2, // endpoint
s1->bone_angles[0][0], // min offset
s1->bone_angles[0][1], // max offset
PKT_TO_BEAM_PARM( s1->surfaces[3] ), // overlap
s1->surfaces[4], // subdivisions
PKT_TO_BEAM_PARM( s1->surfaces[5] ) * 1000, // delay
CG_ConfigString( CS_IMAGES + s1->tag_num ), // index for shader configstring
modulate, // modulate color
s1->surfaces[6], // num sphere beams
PKT_TO_BEAM_PARM( s1->surfaces[7] ), // sphere radius
PKT_TO_BEAM_PARM( s1->surfaces[8] ), // toggle delay
PKT_TO_BEAM_PARM( s1->surfaces[9] ), // end alpha
s1->renderfx,
""
);
CG_CreateBeam(
origin, // start
vz, // dir ( auto calculated by using origin2-origin )
s1->number, // owner number
cgs.model_draw[s1->modelindex], //hModel
s1->alpha, // alpha
s1->scale, // scale
s1->skinNum, // flags
0, // length ( auto calculated )
PKT_TO_BEAM_PARM(s1->surfaces[0]) * 1000, // life
qfalse, // don't always create the beam, just update it
s1->origin2, // endpoint
s1->bone_angles[0][0], // min offset
s1->bone_angles[0][1], // max offset
PKT_TO_BEAM_PARM(s1->surfaces[3]), // overlap
s1->surfaces[4], // subdivisions
PKT_TO_BEAM_PARM(s1->surfaces[5]) * 1000, // delay
CG_ConfigString(CS_IMAGES + s1->tag_num), // index for shader configstring
modulate, // modulate color
s1->surfaces[6], // num sphere beams
PKT_TO_BEAM_PARM(s1->surfaces[7]), // sphere radius
PKT_TO_BEAM_PARM(s1->surfaces[8]), // toggle delay
PKT_TO_BEAM_PARM(s1->surfaces[9]), // end alpha
s1->renderfx,
""
);
}
void CG_Decal(centity_t *cent)
void CG_Decal
(
centity_t *cent
)
{
qhandle_t shader;
vec3_t dir;
entityState_t *s1;
{
qhandle_t shader;
vec3_t dir;
entityState_t *s1;
s1 = &cent->currentState;
s1 = &cent->currentState;
shader = cgi.R_RegisterShader( CG_ConfigString( CS_IMAGES + s1->tag_num ) );
ByteToDir( s1->surfaces[0], dir );
CG_ImpactMark( shader,
s1->origin,
dir,
s1->angles[2],
cent->color[0],
cent->color[1],
cent->color[2],
cent->color[3],
qtrue,
s1->scale,
qfalse,
-1,
qfalse,
0.f,
0.f);
}
shader = cgi.R_RegisterShader(CG_ConfigString(CS_IMAGES + s1->tag_num));
ByteToDir(s1->surfaces[0], dir);
CG_ImpactMark(
shader,
s1->origin,
dir,
s1->angles[2],
cent->color[0],
cent->color[1],
cent->color[2],
cent->color[3],
qtrue,
s1->scale,
qfalse,
-1,
qfalse,
0.f,
0.f
);
}
/*
===============
CG_Portal
===============
*/
void CG_Portal(centity_t* cent)
{
}
void CG_Portal(centity_t *cent) {}
/*
================
BG_EvaluateTrajectory
================
*/
void BG_EvaluateTrajectory(const trajectory_t* tr, int atTime, const vec3_t base, vec3_t result) {
float deltaTime;
void BG_EvaluateTrajectory(const trajectory_t *tr, int atTime, const vec3_t base, vec3_t result)
{
float deltaTime;
if (atTime > cg_smoothClientsTime->integer + tr->trTime) {
atTime = cg_smoothClientsTime->integer + tr->trTime;
}
if (atTime > cg_smoothClientsTime->integer + tr->trTime) {
atTime = cg_smoothClientsTime->integer + tr->trTime;
}
deltaTime = (float)(atTime - tr->trTime) / 1000.0;
deltaTime = (float)(atTime - tr->trTime) / 1000.0;
result[0] = tr->trDelta[0] * deltaTime + base[0];
result[1] = tr->trDelta[1] * deltaTime + base[1];
result[2] = tr->trDelta[2] * deltaTime + base[2];
result[0] = tr->trDelta[0] * deltaTime + base[0];
result[1] = tr->trDelta[1] * deltaTime + base[1];
result[2] = tr->trDelta[2] * deltaTime + base[2];
}
/*
@ -439,17 +436,15 @@ CG_CalcEntityLerpPositions
===============
*/
void CG_CalcEntityLerpPositions( centity_t *cent )
void CG_CalcEntityLerpPositions(centity_t *cent)
{
int i;
float f;
float f;
f = cg.frameInterpolation;
if (cent->currentState.eType == ET_PLAYER)
{
if (cent->currentState.number == cg.snap->ps.clientNum)
{
if (cent->currentState.eType == ET_PLAYER) {
if (cent->currentState.number == cg.snap->ps.clientNum) {
// if the player, take position from prediction
VectorCopy(cg.predicted_player_state.origin, cent->lerpOrigin);
for (i = 0; i < 3; i++) {
@ -471,28 +466,26 @@ void CG_CalcEntityLerpPositions( centity_t *cent )
}
for (i = 0; i < 3; i++) {
cent->lerpOrigin[i] = cent->currentState.origin[i] +
f * (cent->nextState.origin[i] - cent->currentState.origin[i]);
cent->lerpOrigin[i] =
cent->currentState.origin[i] + f * (cent->nextState.origin[i] - cent->currentState.origin[i]);
}
if (!memcmp(cent->currentState.angles, cent->nextState.angles, sizeof(vec3_t))) {
VectorCopy(cent->currentState.angles, cent->lerpAngles);
}
else {
} else {
// use spherical interpolation using quaternions so that bound objects
// rotate properly without gimble lock.
SlerpQuaternion(cent->currentState.quat, cent->nextState.quat, f, quat);
QuatToMat(quat, mat);
MatrixToEulerAngles(mat, cent->lerpAngles);
}
}
else if (cent->interpolate) {
} else if (cent->interpolate) {
float quat[4];
float mat[3][3];
// if the entity has a valid next state, interpolate a value between the frames
// unless it is a mover with a known start and stop
vec3_t current, next;
vec3_t current, next;
// this will linearize a sine or parabolic curve, but it is important
// to not extrapolate player positions if more recent data is available
@ -505,16 +498,14 @@ void CG_CalcEntityLerpPositions( centity_t *cent )
if (!memcmp(cent->currentState.angles, cent->nextState.angles, sizeof(vec3_t))) {
VectorCopy(cent->currentState.angles, cent->lerpAngles);
}
else {
} else {
// use spherical interpolation using quaternions so that bound objects
// rotate properly without gimble lock.
SlerpQuaternion(cent->currentState.quat, cent->nextState.quat, f, quat);
QuatToMat(quat, mat);
MatrixToEulerAngles(mat, cent->lerpAngles);
}
}
else {
} else {
// just use the current frame and evaluate as best we can
BG_EvaluateTrajectory(&cent->currentState.pos, cg.time, cent->currentState.origin, cent->lerpOrigin);
VectorCopy(cent->currentState.angles, cent->lerpAngles);
@ -527,7 +518,7 @@ CG_AddCEntity
===============
*/
void CG_AddCEntity(centity_t* cent)
void CG_AddCEntity(centity_t *cent)
{
// event-only entities will have been dealt with already
if (cent->currentState.eType >= ET_EVENTS) {
@ -558,10 +549,10 @@ void CG_AddCEntity(centity_t* cent)
CG_ModelAnim(cent, qtrue);
break;
case ET_PLAYER:
CG_Player(cent);
CG_Splash(cent);
case ET_ITEM:
CG_ModelAnim(cent, qfalse);
CG_Player(cent);
CG_Splash(cent);
case ET_ITEM:
CG_ModelAnim(cent, qfalse);
break;
case ET_GENERAL:
CG_General(cent);
@ -588,10 +579,10 @@ void CG_AddCEntity(centity_t* cent)
break;
case ET_ROPE: // skip
CG_Rope(cent);
break;
case ET_EXEC_COMMANDS:
CG_ModelAnim(cent, qfalse);
break;
break;
case ET_EXEC_COMMANDS:
CG_ModelAnim(cent, qfalse);
break;
}
}
@ -601,29 +592,30 @@ CG_AddPacketEntities
===============
*/
void CG_AddPacketEntities( void ) {
int num;
centity_t *cent;
int child, parent;
qboolean processed[MAX_ENTITIES];
int i;
void CG_AddPacketEntities(void)
{
int num;
centity_t *cent;
int child, parent;
qboolean processed[MAX_ENTITIES];
int i;
// the auto-rotating items will all have the same axis
cg.autoAngles[0] = 0;
cg.autoAngles[1] = ( cg.time & 2047 ) * 360 / 2048.0;
cg.autoAngles[2] = 0;
// the auto-rotating items will all have the same axis
cg.autoAngles[0] = 0;
cg.autoAngles[1] = (cg.time & 2047) * 360 / 2048.0;
cg.autoAngles[2] = 0;
cg.autoAnglesSlow[0] = 0;
cg.autoAnglesSlow[1] = ( cg.time & 4095 ) * 360 / 4096.0f;
cg.autoAnglesSlow[2] = 0;
cg.autoAnglesSlow[0] = 0;
cg.autoAnglesSlow[1] = (cg.time & 4095) * 360 / 4096.0f;
cg.autoAnglesSlow[2] = 0;
cg.autoAnglesFast[0] = 0;
cg.autoAnglesFast[1] = ( cg.time & 1023 ) * 360 / 1024.0f;
cg.autoAnglesFast[2] = 0;
cg.autoAnglesFast[0] = 0;
cg.autoAnglesFast[1] = (cg.time & 1023) * 360 / 1024.0f;
cg.autoAnglesFast[2] = 0;
AnglesToAxis( cg.autoAngles, cg.autoAxis );
AnglesToAxis( cg.autoAnglesSlow, cg.autoAxisSlow );
AnglesToAxis( cg.autoAnglesFast, cg.autoAxisFast );
AnglesToAxis(cg.autoAngles, cg.autoAxis);
AnglesToAxis(cg.autoAnglesSlow, cg.autoAxisSlow);
AnglesToAxis(cg.autoAnglesFast, cg.autoAxisFast);
for (i = 0; i < MAX_ENTITIES; i++) {
processed[i] = qtrue;
@ -636,50 +628,43 @@ void CG_AddPacketEntities( void ) {
// add each entity sent over by the server
for (num = 0; num < cg.snap->numEntities; num++) {
child = cg.snap->entities[num].number;
cent = &cg_entities[child];
cent = &cg_entities[child];
// add the parent first
// so attachments are consistent
for (parent = cent->currentState.parent;
parent != ENTITYNUM_NONE && !processed[parent];
parent = cg_entities[parent].currentState.parent)
{
for (parent = cent->currentState.parent; parent != ENTITYNUM_NONE && !processed[parent];
parent = cg_entities[parent].currentState.parent) {
processed[parent] = qtrue;
CG_AddCEntity(&cg_entities[parent]);
}
if (!processed[child])
{
if (!processed[child]) {
// now add the children if not processed
processed[child] = qtrue;
CG_AddCEntity(cent);
}
}
// Add in the multibeams at the end
for ( num = 0 ; num < cg.snap->numEntities ; num++ ) {
cent = &cg_entities[ cg.snap->entities[ num ].number ];
if ( cent->currentState.eType == ET_MULTIBEAM )
CG_MultiBeam( cent );
}
// Add in the multibeams at the end
for (num = 0; num < cg.snap->numEntities; num++) {
cent = &cg_entities[cg.snap->entities[num].number];
if (cent->currentState.eType == ET_MULTIBEAM) {
CG_MultiBeam(cent);
}
}
}
void CG_GetOrigin(centity_t* cent, vec3_t origin)
void CG_GetOrigin(centity_t *cent, vec3_t origin)
{
if (cent->currentState.parent == ENTITYNUM_NONE)
{
if (cent->currentState.parent == ENTITYNUM_NONE) {
VectorCopy(cent->lerpOrigin, origin);
}
else
{
} else {
int i;
orientation_t or;
refEntity_t* parent;
orientation_t or ;
refEntity_t *parent;
parent = cgi.R_GetRenderEntity(cent->currentState.parent);
if (!parent)
{
if (!parent) {
cgi.DPrintf("CG_GetOrigin: Could not find parent entity\n");
return;
}
@ -689,9 +674,8 @@ void CG_GetOrigin(centity_t* cent, vec3_t origin)
VectorCopy(parent->origin, origin);
for (i = 0; i < 3; i++)
{
VectorMA(origin, or .origin[i], parent->axis[i], origin);
for (i = 0; i < 3; i++) {
VectorMA(origin, or.origin[i], parent->axis[i], origin);
}
}
}

View file

@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_local.h"
/*
==============
CG_EntityEvent
@ -34,6 +33,4 @@ An entity has an event value
==============
*/
void CG_EntityEvent( centity_t *cent, vec3_t position )
{
}
void CG_EntityEvent(centity_t *cent, vec3_t position) {}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -27,83 +27,83 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_parsemsg.h"
#ifdef _WIN32
#include <windows.h>
# include <windows.h>
#endif
clientGameImport_t cgi;
clientGameImport_t cgi;
static clientGameExport_t cge;
cvar_t* paused;
cvar_t* developer;
cg_t cg;
cgs_t cgs;
int cg_protocol;
centity_t cg_entities[MAX_GENTITIES];
cvar_t *paused;
cvar_t *developer;
cg_t cg;
cgs_t cgs;
int cg_protocol;
centity_t cg_entities[MAX_GENTITIES];
cvar_t* cg_animSpeed;
cvar_t* cg_debugAnim;
cvar_t* cg_debugAnimWatch;
cvar_t* cg_errorDecay;
cvar_t* cg_nopredict;
cvar_t* cg_showmiss;
cvar_t* cg_addMarks;
cvar_t* cg_maxMarks;
cvar_t* cg_viewsize;
cvar_t* cg_3rd_person;
cvar_t* cg_drawviewmodel;
cvar_t* cg_synchronousClients;
cvar_t* cg_stereoSeparation;
cvar_t* cg_stats;
cvar_t* cg_lagometer;
cvar_t* r_lerpmodels;
cvar_t* cg_cameraheight;
cvar_t* cg_cameradist;
cvar_t* cg_cameraverticaldisplacement;
cvar_t* cg_camerascale;
cvar_t* cg_shadows;
cvar_t* cg_hidetempmodels;
cvar_t* cg_traceinfo;
cvar_t* cg_debugFootsteps;
cvar_t* cg_smoothClients;
cvar_t* cg_smoothClientsTime;
cvar_t* pmove_fixed;
cvar_t* pmove_msec;
cvar_t* cg_pmove_msec;
cvar_t* dm_playermodel;
cvar_t* dm_playergermanmodel;
cvar_t* cg_forceModel;
cvar_t* cg_animationviewmodel;
cvar_t* cg_hitmessages;
cvar_t* cg_acidtrip;
cvar_t* cg_hud;
cvar_t* cg_huddraw_force;
cvar_t* cg_drawsvlag;
cvar_t* vm_offset_max;
cvar_t* vm_offset_speed;
cvar_t* vm_sway_front;
cvar_t* vm_sway_side;
cvar_t* vm_sway_up;
cvar_t* vm_offset_air_front;
cvar_t* vm_offset_air_side;
cvar_t* vm_offset_air_up;
cvar_t* vm_offset_crouch_front;
cvar_t* vm_offset_crouch_side;
cvar_t* vm_offset_crouch_up;
cvar_t* vm_offset_rocketcrouch_front;
cvar_t* vm_offset_rocketcrouch_side;
cvar_t* vm_offset_rocketcrouch_up;
cvar_t* vm_offset_shotguncrouch_front;
cvar_t* vm_offset_shotguncrouch_side;
cvar_t* vm_offset_shotguncrouch_up;
cvar_t* vm_offset_vel_base;
cvar_t* vm_offset_vel_front;
cvar_t* vm_offset_vel_side;
cvar_t* vm_offset_vel_up;
cvar_t* vm_offset_upvel;
cvar_t* vm_lean_lower;
cvar_t* voiceChat;
cvar_t* cg_shadowscount;
cvar_t* cg_shadowdebug;
cvar_t *cg_animSpeed;
cvar_t *cg_debugAnim;
cvar_t *cg_debugAnimWatch;
cvar_t *cg_errorDecay;
cvar_t *cg_nopredict;
cvar_t *cg_showmiss;
cvar_t *cg_addMarks;
cvar_t *cg_maxMarks;
cvar_t *cg_viewsize;
cvar_t *cg_3rd_person;
cvar_t *cg_drawviewmodel;
cvar_t *cg_synchronousClients;
cvar_t *cg_stereoSeparation;
cvar_t *cg_stats;
cvar_t *cg_lagometer;
cvar_t *r_lerpmodels;
cvar_t *cg_cameraheight;
cvar_t *cg_cameradist;
cvar_t *cg_cameraverticaldisplacement;
cvar_t *cg_camerascale;
cvar_t *cg_shadows;
cvar_t *cg_hidetempmodels;
cvar_t *cg_traceinfo;
cvar_t *cg_debugFootsteps;
cvar_t *cg_smoothClients;
cvar_t *cg_smoothClientsTime;
cvar_t *pmove_fixed;
cvar_t *pmove_msec;
cvar_t *cg_pmove_msec;
cvar_t *dm_playermodel;
cvar_t *dm_playergermanmodel;
cvar_t *cg_forceModel;
cvar_t *cg_animationviewmodel;
cvar_t *cg_hitmessages;
cvar_t *cg_acidtrip;
cvar_t *cg_hud;
cvar_t *cg_huddraw_force;
cvar_t *cg_drawsvlag;
cvar_t *vm_offset_max;
cvar_t *vm_offset_speed;
cvar_t *vm_sway_front;
cvar_t *vm_sway_side;
cvar_t *vm_sway_up;
cvar_t *vm_offset_air_front;
cvar_t *vm_offset_air_side;
cvar_t *vm_offset_air_up;
cvar_t *vm_offset_crouch_front;
cvar_t *vm_offset_crouch_side;
cvar_t *vm_offset_crouch_up;
cvar_t *vm_offset_rocketcrouch_front;
cvar_t *vm_offset_rocketcrouch_side;
cvar_t *vm_offset_rocketcrouch_up;
cvar_t *vm_offset_shotguncrouch_front;
cvar_t *vm_offset_shotguncrouch_side;
cvar_t *vm_offset_shotguncrouch_up;
cvar_t *vm_offset_vel_base;
cvar_t *vm_offset_vel_front;
cvar_t *vm_offset_vel_side;
cvar_t *vm_offset_vel_up;
cvar_t *vm_offset_upvel;
cvar_t *vm_lean_lower;
cvar_t *voiceChat;
cvar_t *cg_shadowscount;
cvar_t *cg_shadowdebug;
/*
=================
@ -112,78 +112,78 @@ CG_RegisterCvars
*/
void CG_RegisterCvars(void)
{
cvar_t* temp;
cvar_t *temp;
cgi.Cvar_Get("g_subtitle", "0", CVAR_ARCHIVE);
cg_viewsize = cgi.Cvar_Get("viewsize", "100", CVAR_ARCHIVE);
cg_addMarks = cgi.Cvar_Get("cg_marks_add", "0", CVAR_ARCHIVE);
cg_maxMarks = cgi.Cvar_Get("cg_marks_max", "256", CVAR_ARCHIVE | CVAR_LATCH);
cg_animSpeed = cgi.Cvar_Get("cg_animspeed", "1", CVAR_CHEAT);
cg_debugAnim = cgi.Cvar_Get("cg_debuganim", "0", CVAR_CHEAT);
cg_debugAnimWatch = cgi.Cvar_Get("cg_debuganimwatch", "0", CVAR_CHEAT);
cg_errorDecay = cgi.Cvar_Get("cg_errordecay", "100", 0);
cg_nopredict = cgi.Cvar_Get("cg_nopredict", "0", 0);
cg_showmiss = cgi.Cvar_Get("cg_showmiss", "0", 0);
cg_stats = cgi.Cvar_Get("cg_stats", "0", 0);
cg_hidetempmodels = cgi.Cvar_Get("cg_hidetempmodels", "0", 0);
cg_synchronousClients = cgi.Cvar_Get("g_synchronousClients", "0", 0);
cg_stereoSeparation = cgi.Cvar_Get("cg_stereosep", "0.4", CVAR_ARCHIVE);
cg_lagometer = cgi.Cvar_Get("cg_lagometer", "0", 0);
paused = cgi.Cvar_Get("paused", "0", 0);
r_lerpmodels = cgi.Cvar_Get("r_lerpmodels", "1", 0);
cg_3rd_person = cgi.Cvar_Get("cg_3rd_person", "0", CVAR_CHEAT);
cg_drawviewmodel = cgi.Cvar_Get("cg_drawviewmodel", "2", CVAR_ARCHIVE);
cg_cameraheight = cgi.Cvar_Get("cg_cameraheight", "18", CVAR_ARCHIVE);
cg_cameradist = cgi.Cvar_Get("cg_cameradist", "120", CVAR_ARCHIVE);
cg_viewsize = cgi.Cvar_Get("viewsize", "100", CVAR_ARCHIVE);
cg_addMarks = cgi.Cvar_Get("cg_marks_add", "0", CVAR_ARCHIVE);
cg_maxMarks = cgi.Cvar_Get("cg_marks_max", "256", CVAR_ARCHIVE | CVAR_LATCH);
cg_animSpeed = cgi.Cvar_Get("cg_animspeed", "1", CVAR_CHEAT);
cg_debugAnim = cgi.Cvar_Get("cg_debuganim", "0", CVAR_CHEAT);
cg_debugAnimWatch = cgi.Cvar_Get("cg_debuganimwatch", "0", CVAR_CHEAT);
cg_errorDecay = cgi.Cvar_Get("cg_errordecay", "100", 0);
cg_nopredict = cgi.Cvar_Get("cg_nopredict", "0", 0);
cg_showmiss = cgi.Cvar_Get("cg_showmiss", "0", 0);
cg_stats = cgi.Cvar_Get("cg_stats", "0", 0);
cg_hidetempmodels = cgi.Cvar_Get("cg_hidetempmodels", "0", 0);
cg_synchronousClients = cgi.Cvar_Get("g_synchronousClients", "0", 0);
cg_stereoSeparation = cgi.Cvar_Get("cg_stereosep", "0.4", CVAR_ARCHIVE);
cg_lagometer = cgi.Cvar_Get("cg_lagometer", "0", 0);
paused = cgi.Cvar_Get("paused", "0", 0);
r_lerpmodels = cgi.Cvar_Get("r_lerpmodels", "1", 0);
cg_3rd_person = cgi.Cvar_Get("cg_3rd_person", "0", CVAR_CHEAT);
cg_drawviewmodel = cgi.Cvar_Get("cg_drawviewmodel", "2", CVAR_ARCHIVE);
cg_cameraheight = cgi.Cvar_Get("cg_cameraheight", "18", CVAR_ARCHIVE);
cg_cameradist = cgi.Cvar_Get("cg_cameradist", "120", CVAR_ARCHIVE);
cg_cameraverticaldisplacement = cgi.Cvar_Get("cg_cameraverticaldisplacement", "-2", CVAR_ARCHIVE);
cg_camerascale = cgi.Cvar_Get("cg_camerascale", "0.3", CVAR_ARCHIVE);
cg_traceinfo = cgi.Cvar_Get("cg_traceinfo", "0", CVAR_ARCHIVE);
cg_debugFootsteps = cgi.Cvar_Get("cg_debugfootsteps", "0", CVAR_CHEAT);
cg_smoothClients = cgi.Cvar_Get("cg_smoothClients", "1", CVAR_ARCHIVE);
cg_smoothClientsTime = cgi.Cvar_Get("cg_smoothClientsTime", "100", CVAR_ARCHIVE);
pmove_fixed = cgi.Cvar_Get("pmove_fixed", "0", 0);
pmove_msec = cgi.Cvar_Get("pmove_msec", "8", 0);
cg_pmove_msec = cgi.Cvar_Get("cg_pmove_msec", "8", 0);
cg_shadows = cgi.Cvar_Get("cg_shadows", "0", CVAR_ARCHIVE);
cg_shadowscount = cgi.Cvar_Get("cg_shadowscount", "8", 0);
cg_shadowdebug = cgi.Cvar_Get("cg_shadowdebug", "0", 0);
developer = cgi.Cvar_Get("developer", "0", 0);
dm_playermodel = cgi.Cvar_Get("dm_playermodel", "american_army", 3);
dm_playergermanmodel = cgi.Cvar_Get("dm_playergermanmodel", "german_wehrmacht_soldier", 3);
cg_forceModel = cgi.Cvar_Get("cg_forceModel", "0", CVAR_ARCHIVE);
cg_animationviewmodel = cgi.Cvar_Get("cg_animationviewmodel", "0", 8);
cg_hitmessages = cgi.Cvar_Get("cg_hitmessages", "1", CVAR_ARCHIVE);
cg_acidtrip = cgi.Cvar_Get("cg_acidtrip", "0", CVAR_CHEAT);
cg_hud = cgi.Cvar_Get("cg_hud", "0", 0);
cg_huddraw_force = cgi.Cvar_Get("cg_huddraw_force", "0", CVAR_SAVEGAME);
cg_drawsvlag = cgi.Cvar_Get("cg_drawsvlag", "1", CVAR_ARCHIVE);
vm_offset_max = cgi.Cvar_Get("vm_offset_max", "8.0", 0);
vm_offset_speed = cgi.Cvar_Get("vm_offset_speed", "8.0", 0);
vm_sway_front = cgi.Cvar_Get("vm_sway_front", "0.1", 0);
vm_sway_side = cgi.Cvar_Get("vm_sway_side", "0.005", 0);
vm_sway_up = cgi.Cvar_Get("vm_sway_up", "0.003", 0);
vm_offset_air_front = cgi.Cvar_Get("vm_offset_air_front", "-3.0", 0);
vm_offset_air_side = cgi.Cvar_Get("vm_offset_air_side", "1.5", 0);
vm_offset_air_up = cgi.Cvar_Get("vm_offset_air_up", "-6.0", 0);
vm_offset_crouch_front = cgi.Cvar_Get("vm_offset_crouch_front", "-0.5", 0);
vm_offset_crouch_side = cgi.Cvar_Get("vm_offset_crouch_side", "2.25", 0);
vm_offset_crouch_up = cgi.Cvar_Get("vm_offset_crouch_up", "0.2", 0);
vm_offset_rocketcrouch_front = cgi.Cvar_Get("vm_offset_rocketcrouch_front", "0", 0);
vm_offset_rocketcrouch_side = cgi.Cvar_Get("vm_offset_rocketcrouch_side", "0", 0);
vm_offset_rocketcrouch_up = cgi.Cvar_Get("vm_offset_rocketcrouch_up", "0", 0);
cg_camerascale = cgi.Cvar_Get("cg_camerascale", "0.3", CVAR_ARCHIVE);
cg_traceinfo = cgi.Cvar_Get("cg_traceinfo", "0", CVAR_ARCHIVE);
cg_debugFootsteps = cgi.Cvar_Get("cg_debugfootsteps", "0", CVAR_CHEAT);
cg_smoothClients = cgi.Cvar_Get("cg_smoothClients", "1", CVAR_ARCHIVE);
cg_smoothClientsTime = cgi.Cvar_Get("cg_smoothClientsTime", "100", CVAR_ARCHIVE);
pmove_fixed = cgi.Cvar_Get("pmove_fixed", "0", 0);
pmove_msec = cgi.Cvar_Get("pmove_msec", "8", 0);
cg_pmove_msec = cgi.Cvar_Get("cg_pmove_msec", "8", 0);
cg_shadows = cgi.Cvar_Get("cg_shadows", "0", CVAR_ARCHIVE);
cg_shadowscount = cgi.Cvar_Get("cg_shadowscount", "8", 0);
cg_shadowdebug = cgi.Cvar_Get("cg_shadowdebug", "0", 0);
developer = cgi.Cvar_Get("developer", "0", 0);
dm_playermodel = cgi.Cvar_Get("dm_playermodel", "american_army", 3);
dm_playergermanmodel = cgi.Cvar_Get("dm_playergermanmodel", "german_wehrmacht_soldier", 3);
cg_forceModel = cgi.Cvar_Get("cg_forceModel", "0", CVAR_ARCHIVE);
cg_animationviewmodel = cgi.Cvar_Get("cg_animationviewmodel", "0", 8);
cg_hitmessages = cgi.Cvar_Get("cg_hitmessages", "1", CVAR_ARCHIVE);
cg_acidtrip = cgi.Cvar_Get("cg_acidtrip", "0", CVAR_CHEAT);
cg_hud = cgi.Cvar_Get("cg_hud", "0", 0);
cg_huddraw_force = cgi.Cvar_Get("cg_huddraw_force", "0", CVAR_SAVEGAME);
cg_drawsvlag = cgi.Cvar_Get("cg_drawsvlag", "1", CVAR_ARCHIVE);
vm_offset_max = cgi.Cvar_Get("vm_offset_max", "8.0", 0);
vm_offset_speed = cgi.Cvar_Get("vm_offset_speed", "8.0", 0);
vm_sway_front = cgi.Cvar_Get("vm_sway_front", "0.1", 0);
vm_sway_side = cgi.Cvar_Get("vm_sway_side", "0.005", 0);
vm_sway_up = cgi.Cvar_Get("vm_sway_up", "0.003", 0);
vm_offset_air_front = cgi.Cvar_Get("vm_offset_air_front", "-3.0", 0);
vm_offset_air_side = cgi.Cvar_Get("vm_offset_air_side", "1.5", 0);
vm_offset_air_up = cgi.Cvar_Get("vm_offset_air_up", "-6.0", 0);
vm_offset_crouch_front = cgi.Cvar_Get("vm_offset_crouch_front", "-0.5", 0);
vm_offset_crouch_side = cgi.Cvar_Get("vm_offset_crouch_side", "2.25", 0);
vm_offset_crouch_up = cgi.Cvar_Get("vm_offset_crouch_up", "0.2", 0);
vm_offset_rocketcrouch_front = cgi.Cvar_Get("vm_offset_rocketcrouch_front", "0", 0);
vm_offset_rocketcrouch_side = cgi.Cvar_Get("vm_offset_rocketcrouch_side", "0", 0);
vm_offset_rocketcrouch_up = cgi.Cvar_Get("vm_offset_rocketcrouch_up", "0", 0);
vm_offset_shotguncrouch_front = cgi.Cvar_Get("vm_offset_shotguncrouch_front", "-1", 0);
vm_offset_shotguncrouch_side = cgi.Cvar_Get("vm_offset_shotguncrouch_side", "2.5", 0);
vm_offset_shotguncrouch_up = cgi.Cvar_Get("vm_offset_shotguncrouch_up", "-1.1", 0);
vm_offset_vel_base = cgi.Cvar_Get("vm_offset_vel_base", "100", 0);
vm_offset_vel_front = cgi.Cvar_Get("vm_offset_vel_front", "-2.0", 0);
vm_offset_vel_side = cgi.Cvar_Get("vm_offset_vel_side", "1.5", 0);
vm_offset_vel_up = cgi.Cvar_Get("vm_offset_vel_up", "-4.0", 0);
vm_offset_upvel = cgi.Cvar_Get("vm_offset_upvel", "0.0025", 0);
vm_lean_lower = cgi.Cvar_Get("vm_lean_lower", "0.1", 0);
voiceChat = cgi.Cvar_Get("cg_voicechat", "1", 0);
vm_offset_shotguncrouch_side = cgi.Cvar_Get("vm_offset_shotguncrouch_side", "2.5", 0);
vm_offset_shotguncrouch_up = cgi.Cvar_Get("vm_offset_shotguncrouch_up", "-1.1", 0);
vm_offset_vel_base = cgi.Cvar_Get("vm_offset_vel_base", "100", 0);
vm_offset_vel_front = cgi.Cvar_Get("vm_offset_vel_front", "-2.0", 0);
vm_offset_vel_side = cgi.Cvar_Get("vm_offset_vel_side", "1.5", 0);
vm_offset_vel_up = cgi.Cvar_Get("vm_offset_vel_up", "-4.0", 0);
vm_offset_upvel = cgi.Cvar_Get("vm_offset_upvel", "0.0025", 0);
vm_lean_lower = cgi.Cvar_Get("vm_lean_lower", "0.1", 0);
voiceChat = cgi.Cvar_Get("cg_voicechat", "1", 0);
// see if we are also running the server on this machine
temp = cgi.Cvar_Get("sv_running", "0", 0);
temp = cgi.Cvar_Get("sv_running", "0", 0);
cgs.localServer = temp->integer;
}
@ -194,17 +194,18 @@ CG_RegisterSounds
called during a precache command
=================
*/
void CG_RegisterSounds( void )
void CG_RegisterSounds(void)
{
int startTime;
int endTime;
int startTime;
int endTime;
char filename[MAX_QPATH];
Com_Printf("\n\n-----------PARSING UBERSOUND------------\n");
Com_Printf(
"Any SetCurrentTiki errors means that tiki wasn't prefetched and "
"tiki-specific sounds for it won't work. To fix prefe"
"tch the tiki. Ignore if you don't use that tiki on this level.\n");
"tch the tiki. Ignore if you don't use that tiki on this level.\n"
);
Com_sprintf(filename, sizeof(filename), "ubersound/ubersound.scr");
startTime = cgi.Milliseconds();
@ -218,7 +219,8 @@ void CG_RegisterSounds( void )
Com_Printf(
"Any SetCurrentTiki errors means that tiki wasn't prefetched and "
"tiki-specific sounds for it won't work. To fix prefe"
"tch the tiki. Ignore if you don't use that tiki on this level.\n");
"tch the tiki. Ignore if you don't use that tiki on this level.\n"
);
Com_sprintf(filename, sizeof(filename), "ubersound/uberdialog.scr");
startTime = cgi.Milliseconds();
@ -236,157 +238,132 @@ CG_ProcessConfigString
*/
void CG_ProcessConfigString(int num)
{
const char* str = CG_ConfigString(num);
int i;
const char *str = CG_ConfigString(num);
int i;
switch (num)
{
case CS_RAIN_DENSITY:
cg.rain.density = atof(str);
return;
switch (num) {
case CS_RAIN_DENSITY:
cg.rain.density = atof(str);
return;
case CS_RAIN_SPEED:
cg.rain.speed = atof(str);
return;
return;
case CS_RAIN_SPEEDVARY:
cg.rain.speed_vary = atoi(str);
return;
return;
case CS_RAIN_SLANT:
cg.rain.slant = atoi(str);
return;
return;
case CS_RAIN_LENGTH:
cg.rain.length = atof(str);
return;
return;
case CS_RAIN_MINDIST:
cg.rain.min_dist = atof(str);
return;
return;
case CS_RAIN_WIDTH:
cg.rain.width = atof(str);
return;
case CS_RAIN_SHADER:
if (cg.rain.numshaders)
{
for (i = 0; i < cg.rain.numshaders; i++)
{
sprintf(cg.rain.shader[i], "%s%i", str, i);
}
}
else {
strcpy(cg.rain.shader[0], str);
}
return;
case CS_RAIN_NUMSHADERS:
return;
case CS_RAIN_SHADER:
if (cg.rain.numshaders) {
for (i = 0; i < cg.rain.numshaders; i++) {
sprintf(cg.rain.shader[i], "%s%i", str, i);
}
} else {
strcpy(cg.rain.shader[0], str);
}
return;
case CS_RAIN_NUMSHADERS:
cg.rain.numshaders = atoi(str);
if (cg.rain.numshaders)
{
for (i = 0; i < cg.rain.numshaders; i++)
{
if (cg.rain.numshaders) {
for (i = 0; i < cg.rain.numshaders; i++) {
sprintf(cg.rain.shader[i], "%s%i", str, i);
}
}
return;
}
return;
}
if (num >= CS_OBJECTIVES && num < CS_OBJECTIVES + MAX_OBJECTIVES)
{
cobjective_t* objective = &cg.Objectives[num - CS_OBJECTIVES];
objective->flags = atoi(Info_ValueForKey(str, "flags"));
strcpy(objective->text, Info_ValueForKey(str, "text"));
}
if (num >= CS_OBJECTIVES && num < CS_OBJECTIVES + MAX_OBJECTIVES) {
cobjective_t *objective = &cg.Objectives[num - CS_OBJECTIVES];
objective->flags = atoi(Info_ValueForKey(str, "flags"));
strcpy(objective->text, Info_ValueForKey(str, "text"));
}
switch (num)
{
switch (num) {
case CS_MUSIC:
cgi.MUSIC_NewSoundtrack(str);
return;
case CS_WARMUP:
cg.matchStartTime = atoi(str);
return;
return;
case CS_WARMUP:
cg.matchStartTime = atoi(str);
return;
case CS_FOGINFO:
CG_ParseFogInfo(str);
return;
return;
case CS_SKYINFO:
sscanf
(
str,
"%f %d",
&cg.sky_alpha,
&cg.sky_portal
);
return;
case CS_SERVERINFO:
sscanf(str, "%f %d", &cg.sky_alpha, &cg.sky_portal);
return;
case CS_SERVERINFO:
CG_ParseServerinfo();
return;
return;
case CS_LEVEL_START_TIME:
cgs.levelStartTime = atoi(str);
return;
return;
case CS_MATCHEND:
cgs.matchEndTime = atoi(str);
return;
}
return;
}
if (num >= CS_MODELS && num < CS_MODELS + MAX_MODELS)
{
if (num >= CS_MODELS && num < CS_MODELS + MAX_MODELS) {
qhandle_t hOldModel = cgs.model_draw[num - CS_MODELS];
if (str && str[0])
{
qhandle_t hModel = cgi.R_RegisterServerModel(str);
dtiki_t* tiki;
if (str && str[0]) {
qhandle_t hModel = cgi.R_RegisterServerModel(str);
dtiki_t *tiki;
if (hModel != hOldModel)
{
if (hOldModel) {
cgi.R_UnregisterServerModel(hOldModel);
}
if (hModel != hOldModel) {
if (hOldModel) {
cgi.R_UnregisterServerModel(hOldModel);
}
cgs.model_draw[num - CS_MODELS] = hModel;
}
tiki = cgi.R_Model_GetHandle(hModel);
cgs.model_draw[num - CS_MODELS] = hModel;
}
tiki = cgi.R_Model_GetHandle(hModel);
if (tiki) {
CG_ProcessCacheInitCommands(tiki);
}
} else {
// clear out the model
if (hOldModel) {
cgi.R_UnregisterServerModel(hOldModel);
}
cgs.model_draw[num - CS_MODELS] = 0;
}
else
{
// clear out the model
if (hOldModel) {
cgi.R_UnregisterServerModel(hOldModel);
}
cgs.model_draw[num - CS_MODELS] = 0;
}
}
else if (num >= CS_SOUNDS && num < CS_SOUNDS + MAX_SOUNDS)
{
size_t len = strlen(str);
if (len)
{
qboolean streamed;
char buf[1024];
strcpy(buf, str);
} else if (num >= CS_SOUNDS && num < CS_SOUNDS + MAX_SOUNDS) {
size_t len = strlen(str);
if (len) {
qboolean streamed;
char buf[1024];
strcpy(buf, str);
streamed = buf[len - 1] != '0';
buf[len - 1] = 0;
streamed = buf[len - 1] != '0';
buf[len - 1] = 0;
if (buf[0] != '*') {
cgs.sound_precache[num - CS_SOUNDS] = cgi.S_RegisterSound(buf, streamed);
}
}
}
else if (num >= CS_LIGHTSTYLES && num < CS_LIGHTSTYLES + MAX_LIGHTSTYLES)
{
CG_SetLightStyle(num - CS_LIGHTSTYLES, str);
}
else if (num >= CS_PLAYERS && num < CS_PLAYERS + MAX_CLIENTS)
{
const char* value;
value = Info_ValueForKey(str, "name");
if (value) {
strncpy(cg.clientinfo[num - CS_PLAYERS].name, value, sizeof(cg.clientinfo[num - CS_PLAYERS].name));
}
else {
strncpy(cg.clientinfo[num - CS_PLAYERS].name, "UnnamedSoldier", sizeof(cg.clientinfo[num - CS_PLAYERS].name));
}
}
} else if (num >= CS_LIGHTSTYLES && num < CS_LIGHTSTYLES + MAX_LIGHTSTYLES) {
CG_SetLightStyle(num - CS_LIGHTSTYLES, str);
} else if (num >= CS_PLAYERS && num < CS_PLAYERS + MAX_CLIENTS) {
const char *value;
value = Info_ValueForKey(str, "name");
if (value) {
strncpy(cg.clientinfo[num - CS_PLAYERS].name, value, sizeof(cg.clientinfo[num - CS_PLAYERS].name));
} else {
strncpy(
cg.clientinfo[num - CS_PLAYERS].name, "UnnamedSoldier", sizeof(cg.clientinfo[num - CS_PLAYERS].name)
);
}
value = Info_ValueForKey(str, "team");
if (value) {
cg.clientinfo[num - CS_PLAYERS].team = atoi(value);
@ -406,7 +383,7 @@ Call before entering a new level, or after changing renderers
This function may execute for a couple of minutes with a slow disk.
=================
*/
void CG_PrepRefresh( void )
void CG_PrepRefresh(void)
{
int i;
@ -417,43 +394,40 @@ void CG_PrepRefresh( void )
// register the inline models
cgs.numInlineModels = cgi.CM_NumInlineModels();
for (i = 1; i < cgs.numInlineModels; i++)
{
char name[10];
vec3_t mins, maxs;
int j;
for (i = 1; i < cgs.numInlineModels; i++) {
char name[10];
vec3_t mins, maxs;
int j;
Com_sprintf(name, sizeof(name), "*%i", i);
cgs.inlineDrawModel[i] = cgi.R_RegisterModel(name);
cgi.R_ModelBounds(cgs.inlineDrawModel[i], mins, maxs);
for (j = 0; j < 3; j++)
{
for (j = 0; j < 3; j++) {
cgs.inlineModelMidpoints[i][j] = mins[j] + 0.5 * (maxs[j] - mins[j]);
}
}
// register media shaders
cgs.media.shadowMarkShader = cgi.R_RegisterShader("markShadow");
cgs.media.footShadowMarkShader = cgi.R_RegisterShader("footShadow");
cgs.media.wakeMarkShader = cgi.R_RegisterShader("ripple.spr");
cgs.media.lagometerShader = cgi.R_RegisterShaderNoMip("gfx/2d/blank");
cgs.media.levelExitShader = cgi.R_RegisterShaderNoMip("textures/menu/exit");
cgs.media.pausedShader = cgi.R_RegisterShaderNoMip("textures/menu/paused");
cgs.media.backTileShader = cgi.R_RegisterShader("gfx/2d/backtile");
cgs.media.zoomOverlayShader = cgi.R_RegisterShaderNoMip("textures/hud/zoomoverlay");
cgs.media.kar98TopOverlayShader = cgi.R_RegisterShaderNoMip("textures/hud/kartop.tga");
cgs.media.shadowMarkShader = cgi.R_RegisterShader("markShadow");
cgs.media.footShadowMarkShader = cgi.R_RegisterShader("footShadow");
cgs.media.wakeMarkShader = cgi.R_RegisterShader("ripple.spr");
cgs.media.lagometerShader = cgi.R_RegisterShaderNoMip("gfx/2d/blank");
cgs.media.levelExitShader = cgi.R_RegisterShaderNoMip("textures/menu/exit");
cgs.media.pausedShader = cgi.R_RegisterShaderNoMip("textures/menu/paused");
cgs.media.backTileShader = cgi.R_RegisterShader("gfx/2d/backtile");
cgs.media.zoomOverlayShader = cgi.R_RegisterShaderNoMip("textures/hud/zoomoverlay");
cgs.media.kar98TopOverlayShader = cgi.R_RegisterShaderNoMip("textures/hud/kartop.tga");
cgs.media.kar98BottomOverlayShader = cgi.R_RegisterShaderNoMip("textures/hud/karbottom.tga");
cgs.media.binocularsOverlayShader = cgi.R_RegisterShaderNoMip("textures/hud/binocularsoverlay");
cgs.media.hudDrawFont = cgi.R_LoadFont("verdana-14");
cgs.media.attackerFont = cgi.R_LoadFont("facfont-20");
cgs.media.objectiveFont = cgi.R_LoadFont("courier-16");
cgs.media.objectivesBackShader = cgi.R_RegisterShaderNoMip("textures/hud/objectives_backdrop");
cgs.media.checkedBoxShader = cgi.R_RegisterShaderNoMip("textures/objectives/filledbox");
cgs.media.uncheckedBoxShader = cgi.R_RegisterShaderNoMip("textures/objectives/emptybox");
cgs.media.binocularsOverlayShader = cgi.R_RegisterShaderNoMip("textures/hud/binocularsoverlay");
cgs.media.hudDrawFont = cgi.R_LoadFont("verdana-14");
cgs.media.attackerFont = cgi.R_LoadFont("facfont-20");
cgs.media.objectiveFont = cgi.R_LoadFont("courier-16");
cgs.media.objectivesBackShader = cgi.R_RegisterShaderNoMip("textures/hud/objectives_backdrop");
cgs.media.checkedBoxShader = cgi.R_RegisterShaderNoMip("textures/objectives/filledbox");
cgs.media.uncheckedBoxShader = cgi.R_RegisterShaderNoMip("textures/objectives/emptybox");
// go through all the configstrings and process them
for (i = CS_SYSTEMINFO + 1; i < MAX_CONFIGSTRINGS; i++)
{
for (i = CS_SYSTEMINFO + 1; i < MAX_CONFIGSTRINGS; i++) {
CG_ProcessConfigString(i);
}
}
@ -465,16 +439,16 @@ void CG_PrepRefresh( void )
CG_ConfigString
=================
*/
const char *CG_ConfigString( int index ) {
if ( index < 0 || index >= MAX_CONFIGSTRINGS ) {
cgi.Error( ERR_DROP, "CG_ConfigString: bad index: %i", index );
}
return cgs.gameState.stringData + cgs.gameState.stringOffsets[ index ];
const char *CG_ConfigString(int index)
{
if (index < 0 || index >= MAX_CONFIGSTRINGS) {
cgi.Error(ERR_DROP, "CG_ConfigString: bad index: %i", index);
}
return cgs.gameState.stringData + cgs.gameState.stringOffsets[index];
}
//==================================================================
void CG_GetRendererConfig(void)
{
// get the rendering configuration from the client system
@ -490,9 +464,9 @@ CG_GameStateReceived
Displays the info screen while loading media
======================
*/
void CG_GameStateReceived( void )
void CG_GameStateReceived(void)
{
const char* s;
const char *s;
// clear everything
memset(&cg, 0, sizeof(cg));
@ -513,7 +487,7 @@ void CG_GameStateReceived( void )
cgi.Error(ERR_DROP, "Client/Server game mismatch: %s/%s", GAME_VERSION, s);
}
s = CG_ConfigString(CS_LEVEL_START_TIME);
s = CG_ConfigString(CS_LEVEL_START_TIME);
cgs.levelStartTime = atoi(s);
CG_ParseServerinfo();
@ -539,11 +513,11 @@ CG_ServerRestarted
The server has beeen restarted, adjust our cgame data accordingly
======================
*/
void CG_ServerRestarted( void )
void CG_ServerRestarted(void)
{
const char* s;
const char *s;
s = CG_ConfigString(CS_LEVEL_START_TIME);
s = CG_ConfigString(CS_LEVEL_START_TIME);
cgs.levelStartTime = atoi(s);
CG_ParseServerinfo();
@ -563,7 +537,7 @@ void CG_ServerRestarted( void )
CG_InitializeObjectives();
}
void* CG_Malloc(int size)
void *CG_Malloc(int size)
{
return malloc(size);
}
@ -580,13 +554,12 @@ CG_Init
Called after every level change or subsystem restart
=================
*/
void CG_Init(clientGameImport_t* imported, int serverMessageNum,
int serverCommandSequence, int clientNum)
void CG_Init(clientGameImport_t *imported, int serverMessageNum, int serverCommandSequence, int clientNum)
{
cgi = *imported;
#if _DEBUG
cgi.Malloc = &CG_Malloc;
cgi.Free = &CG_Free;
cgi.Free = &CG_Free;
#endif
cg_protocol = cgi.Cvar_Get("com_protocol", "", 0)->integer;
@ -596,8 +569,8 @@ void CG_Init(clientGameImport_t* imported, int serverMessageNum,
memset(&cg, 0, sizeof(cg));
memset(&cgs, 0, sizeof(cgs));
cg.clientNum = clientNum;
cgs.processedSnapshotNum = serverMessageNum;
cg.clientNum = clientNum;
cgs.processedSnapshotNum = serverMessageNum;
cgs.serverCommandSequence = serverCommandSequence;
CG_RegisterCvars();
@ -613,21 +586,21 @@ void CG_Init(clientGameImport_t* imported, int serverMessageNum,
CG_InitConsoleCommands();
cg.vEyeOffsetMax[0] = 40.0f;
cg.vEyeOffsetMax[1] = 45.0f;
cg.vEyeOffsetMax[2] = 60.0f;
cg.fEyeOffsetFrac = 0.1f;
cg.fCurrentViewHeight = 0.0f;
cg.fCurrentViewBobPhase = 0.0f;
cg.fCurrentViewBobAmp = 0.0f;
cg.pLastPlayerWorldModel = NULL;
cg.pPlayerFPSModel = NULL;
cg.hPlayerFPSModelHandle = 0;
cg.pAlliedPlayerModel = NULL;
cg.vEyeOffsetMax[0] = 40.0f;
cg.vEyeOffsetMax[1] = 45.0f;
cg.vEyeOffsetMax[2] = 60.0f;
cg.fEyeOffsetFrac = 0.1f;
cg.fCurrentViewHeight = 0.0f;
cg.fCurrentViewBobPhase = 0.0f;
cg.fCurrentViewBobAmp = 0.0f;
cg.pLastPlayerWorldModel = NULL;
cg.pPlayerFPSModel = NULL;
cg.hPlayerFPSModelHandle = 0;
cg.pAlliedPlayerModel = NULL;
cg.hAlliedPlayerModelHandle = 0;
cg.pAxisPlayerModel = NULL;
cg.hAxisPlayerModelHandle = 0;
cg.bFPSOnGround = qtrue;
cg.pAxisPlayerModel = NULL;
cg.hAxisPlayerModelHandle = 0;
cg.bFPSOnGround = qtrue;
// Pop the stats UI screen menu
cgi.UI_HideMenu("StatsScreen", 1);
@ -664,7 +637,7 @@ void CG_Shutdown(void)
int CG_GetParent(int entnum)
{
return cg_entities[entnum].currentState.parent;
return cg_entities[entnum].currentState.parent;
}
float CG_GetObjectiveAlpha()
@ -681,34 +654,34 @@ The only exported function from this module
*/
clientGameExport_t *GetCGameAPI(void)
{
cge.CG_Init = CG_Init;
cge.CG_DrawActiveFrame = CG_DrawActiveFrame;
cge.CG_Shutdown = CG_Shutdown;
cge.CG_ConsoleCommand = CG_ConsoleCommand;
cge.CG_GetRendererConfig = CG_GetRendererConfig;
cge.CG_Draw2D = CG_Draw2D;
cge.CG_EyePosition = CG_EyePosition;
cge.CG_EyeOffset = CG_EyeOffset;
cge.CG_EyeAngles = CG_EyeAngles;
cge.CG_SensitivityScale = CG_SensitivityScale;
cge.CG_RefreshHudDrawElements = CG_RefreshHudDrawElements;
cge.CG_HudDrawShader = CG_HudDrawShader;
cge.CG_HudDrawFont = CG_HudDrawFont;
cge.CG_PermanentMark = CG_PermanentMark;
cge.CG_PermanentTreadMarkDecal = CG_PermanentTreadMarkDecal;
cge.CG_PermanentUpdateTreadMark = CG_PermanentUpdateTreadMark;
cge.CG_Command_ProcessFile = CG_Command_ProcessFile;
cge.CG_ProcessInitCommands = CG_ProcessInitCommands;
cge.CG_EndTiki = CG_EndTiki;
cge.CG_GetParent = CG_GetParent;
cge.CG_GetObjectiveAlpha = CG_GetObjectiveAlpha;
cge.CG_WeaponCommandButtonBits = CG_WeaponCommandButtonBits;
cge.CG_CheckCaptureKey = CG_CheckCaptureKey;
cge.CG_Init = CG_Init;
cge.CG_DrawActiveFrame = CG_DrawActiveFrame;
cge.CG_Shutdown = CG_Shutdown;
cge.CG_ConsoleCommand = CG_ConsoleCommand;
cge.CG_GetRendererConfig = CG_GetRendererConfig;
cge.CG_Draw2D = CG_Draw2D;
cge.CG_EyePosition = CG_EyePosition;
cge.CG_EyeOffset = CG_EyeOffset;
cge.CG_EyeAngles = CG_EyeAngles;
cge.CG_SensitivityScale = CG_SensitivityScale;
cge.CG_RefreshHudDrawElements = CG_RefreshHudDrawElements;
cge.CG_HudDrawShader = CG_HudDrawShader;
cge.CG_HudDrawFont = CG_HudDrawFont;
cge.CG_PermanentMark = CG_PermanentMark;
cge.CG_PermanentTreadMarkDecal = CG_PermanentTreadMarkDecal;
cge.CG_PermanentUpdateTreadMark = CG_PermanentUpdateTreadMark;
cge.CG_Command_ProcessFile = CG_Command_ProcessFile;
cge.CG_ProcessInitCommands = CG_ProcessInitCommands;
cge.CG_EndTiki = CG_EndTiki;
cge.CG_GetParent = CG_GetParent;
cge.CG_GetObjectiveAlpha = CG_GetObjectiveAlpha;
cge.CG_WeaponCommandButtonBits = CG_WeaponCommandButtonBits;
cge.CG_CheckCaptureKey = CG_CheckCaptureKey;
// FIXME
//cge.profStruct = NULL;
// FIXME
//cge.profStruct = NULL;
return &cge;
return &cge;
}
/*
@ -720,7 +693,7 @@ Perform all drawing needed to completely fill the screen
*/
void CG_DrawActive(stereoFrame_t stereoView)
{
float separation;
float separation;
vec3_t baseOrg;
switch (stereoView) {
@ -744,8 +717,7 @@ void CG_DrawActive(stereoFrame_t stereoView)
// offset vieworg appropriately if we're doing stereo separation
VectorCopy(cg.refdef.vieworg, baseOrg);
if (separation != 0) {
VectorMA(cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1],
cg.refdef.vieworg);
VectorMA(cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg);
}
// draw 3D view
@ -760,68 +732,72 @@ void CG_DrawActive(stereoFrame_t stereoView)
#ifndef CGAME_HARD_LINKED
// this is only here so the functions in q_shared.c and bg_*.c can link (FIXME)
void Com_Error( int level, const char *error, ... ) {
va_list argptr;
char text[1024];
void Com_Error(int level, const char *error, ...)
{
va_list argptr;
char text[1024];
va_start (argptr, error);
vsprintf (text, error, argptr);
va_end (argptr);
va_start(argptr, error);
vsprintf(text, error, argptr);
va_end(argptr);
cgi.Error( level, "%s", text);
cgi.Error(level, "%s", text);
}
void Com_Printf( const char *msg, ... ) {
va_list argptr;
char text[1024];
void Com_Printf(const char *msg, ...)
{
va_list argptr;
char text[1024];
va_start (argptr, msg);
vsprintf (text, msg, argptr);
va_end (argptr);
va_start(argptr, msg);
vsprintf(text, msg, argptr);
va_end(argptr);
cgi.Printf( "%s", text);
cgi.Printf("%s", text);
}
#endif
void CG_ParseFogInfo_ver_15(const char* str) {
sscanf(
void CG_ParseFogInfo_ver_15(const char *str)
{
sscanf(
str,
"%d %f %f %f %f %f %f %f %d %f %f %f %f",
&cg.farplane_cull,
&cg.farplane_distance,
&cg.farplane_bias,
&cg.skyboxFarplane,
&cg.skyboxSpeed,
&cg.farplane_color[0],
&cg.farplane_color[1],
&cg.farplane_color[2],
&cg.renderTerrain,
&cg.farclipOverride,
&cg.farplaneColorOverride[0],
&cg.farplaneColorOverride[1],
&cg.farplaneColorOverride[2]
"%d %f %f %f %f %f %f %f %d %f %f %f %f",
&cg.farplane_cull,
&cg.farplane_distance,
&cg.farplane_bias,
&cg.skyboxFarplane,
&cg.skyboxSpeed,
&cg.farplane_color[0],
&cg.farplane_color[1],
&cg.farplane_color[2],
&cg.renderTerrain,
&cg.farclipOverride,
&cg.farplaneColorOverride[0],
&cg.farplaneColorOverride[1],
&cg.farplaneColorOverride[2]
);
}
void CG_ParseFogInfo_ver_6(const char* str) {
cg.farclipOverride = 0.0;
cg.farplaneColorOverride[0] = -1.0;
cg.farplaneColorOverride[1] = -1.0;
cg.farplaneColorOverride[2] = -1.0;
sscanf
(
str,
"%d %f %f %f %f",
&cg.farplane_cull,
&cg.farplane_distance,
&cg.farplane_color[0],
&cg.farplane_color[1],
&cg.farplane_color[2]
);
void CG_ParseFogInfo_ver_6(const char *str)
{
cg.farclipOverride = 0.0;
cg.farplaneColorOverride[0] = -1.0;
cg.farplaneColorOverride[1] = -1.0;
cg.farplaneColorOverride[2] = -1.0;
sscanf(
str,
"%d %f %f %f %f",
&cg.farplane_cull,
&cg.farplane_distance,
&cg.farplane_color[0],
&cg.farplane_color[1],
&cg.farplane_color[2]
);
}
void CG_ParseFogInfo(const char* str) {
void CG_ParseFogInfo(const char *str)
{
if (cg_protocol >= PROTOCOL_MOHTA_MIN) {
CG_ParseFogInfo_ver_15(str);
} else {

View file

@ -33,10 +33,9 @@ MARK POLYS
===================================================================
*/
markPoly_t cg_activeMarkPolys; // double linked list
markPoly_t *cg_freeMarkPolys; // single linked list
markPoly_t cg_markPolys[MAX_MARK_POLYS];
markPoly_t cg_activeMarkPolys; // double linked list
markPoly_t *cg_freeMarkPolys; // single linked list
markPoly_t cg_markPolys[MAX_MARK_POLYS];
vec3_t vec_upwards;
@ -55,19 +54,18 @@ void CG_InitMarks(void)
cg_activeMarkPolys.nextMark = &cg_activeMarkPolys;
cg_activeMarkPolys.prevMark = &cg_activeMarkPolys;
cg_freeMarkPolys = cg_markPolys;
cg_freeMarkPolys = cg_markPolys;
for (i = 0; i < MAX_MARK_POLYS - 1; i++) {
cg_markPolys[i].nextMark = &cg_markPolys[i + 1];
}
}
/*
==================
CG_FreeMarkPoly
==================
*/
void CG_FreeMarkPoly(markPoly_t* le)
void CG_FreeMarkPoly(markPoly_t *le)
{
if (!le->prevMark) {
cgi.Error(ERR_DROP, "CG_FreeLocalEntity: not active");
@ -78,7 +76,7 @@ void CG_FreeMarkPoly(markPoly_t* le)
le->nextMark->prevMark = le->prevMark;
// the free list is only singly linked
le->nextMark = cg_freeMarkPolys;
le->nextMark = cg_freeMarkPolys;
cg_freeMarkPolys = le;
}
@ -89,31 +87,30 @@ CG_AllocMark
Will allways succeed, even if it requires freeing an old active mark
===================
*/
markPoly_t* CG_AllocMark(void)
markPoly_t *CG_AllocMark(void)
{
markPoly_t* le;
markPoly_t *le;
if (!cg_freeMarkPolys) {
int time;
// no free entities, so free the one at the end of the chain
// remove the oldest active entity
time = cg_activeMarkPolys.prevMark->time;
while (cg_activeMarkPolys.prevMark &&
time == cg_activeMarkPolys.prevMark->time) {
while (cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time) {
CG_FreeMarkPoly(cg_activeMarkPolys.prevMark);
}
}
le = cg_freeMarkPolys;
le = cg_freeMarkPolys;
cg_freeMarkPolys = cg_freeMarkPolys->nextMark;
memset(le, 0, sizeof(*le));
// link into the active list
le->nextMark = cg_activeMarkPolys.nextMark;
le->prevMark = &cg_activeMarkPolys;
le->nextMark = cg_activeMarkPolys.nextMark;
le->prevMark = &cg_activeMarkPolys;
cg_activeMarkPolys.nextMark->prevMark = le;
cg_activeMarkPolys.nextMark = le;
cg_activeMarkPolys.nextMark = le;
return le;
}
@ -128,37 +125,36 @@ temporary marks will not be stored or randomly oriented, but immediately
passed to the renderer.
=================
*/
#define MAX_MARK_FRAGMENTS 128
#define MAX_MARK_POINTS 384
#define MAX_MARK_FRAGMENTS 128
#define MAX_MARK_POINTS 384
void CG_ImpactMark
(
qhandle_t markShader,
const vec3_t origin,
const vec3_t dir,
float orientation,
float red,
float green,
float blue,
float alpha,
qboolean alphaFade,
float radius,
qboolean temporary,
int lightstyle,
qboolean fadein,
float fSCenter,
float fTCenter
)
void CG_ImpactMark(
qhandle_t markShader,
const vec3_t origin,
const vec3_t dir,
float orientation,
float red,
float green,
float blue,
float alpha,
qboolean alphaFade,
float radius,
qboolean temporary,
int lightstyle,
qboolean fadein,
float fSCenter,
float fTCenter
)
{
vec3_t axis[3];
float texCoordScale;
vec3_t originalPoints[4];
byte colors[4];
int i, j;
int numFragments;
vec3_t axis[3];
float texCoordScale;
vec3_t originalPoints[4];
byte colors[4];
int i, j;
int numFragments;
markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf;
vec3_t markPoints[MAX_MARK_POINTS];
vec3_t projection;
vec3_t markPoints[MAX_MARK_POINTS];
vec3_t projection;
if (!cg_addMarks->integer) {
return;
@ -192,23 +188,19 @@ void CG_ImpactMark
// create the full polygon
for (i = 0; i < 3; i++) {
originalPoints[0][i] =
origin[i] - radius * axis[1][i] - radius * axis[2][i];
originalPoints[1][i] =
origin[i] + radius * axis[1][i] - radius * axis[2][i];
originalPoints[2][i] =
origin[i] + radius * axis[1][i] + radius * axis[2][i];
originalPoints[3][i] =
origin[i] - radius * axis[1][i] + radius * axis[2][i];
originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i];
originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i];
originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i];
originalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i];
}
// get the fragments
VectorScale(dir, -32, projection);
// FIXME: fRadiusSquared
numFragments = cgi.R_MarkFragments(4, (void*)originalPoints, projection,
MAX_MARK_POINTS, markPoints[0],
MAX_MARK_FRAGMENTS, markFragments, 0.f);
numFragments = cgi.R_MarkFragments(
4, (void *)originalPoints, projection, MAX_MARK_POINTS, markPoints[0], MAX_MARK_FRAGMENTS, markFragments, 0.f
);
if (fadein) {
colors[0] = 0;
@ -223,9 +215,9 @@ void CG_ImpactMark
}
for (i = 0, mf = markFragments; i < numFragments; i++, mf++) {
polyVert_t* v;
polyVert_t verts[MAX_VERTS_ON_POLY];
markPoly_t* mark;
polyVert_t *v;
polyVert_t verts[MAX_VERTS_ON_POLY];
markPoly_t *mark;
// we have an upper limit on the complexity of polygons
// that we store persistantly
@ -238,9 +230,9 @@ void CG_ImpactMark
VectorCopy(markPoints[mf->firstPoint + j], v->xyz);
VectorSubtract(v->xyz, origin, delta);
v->st[0] = 0.5 + DotProduct(delta, axis[1]) * texCoordScale;
v->st[1] = 0.5 + DotProduct(delta, axis[2]) * texCoordScale;
*(int*)v->modulate = *(int*)colors;
v->st[0] = 0.5 + DotProduct(delta, axis[1]) * texCoordScale;
v->st[1] = 0.5 + DotProduct(delta, axis[2]) * texCoordScale;
*(int *)v->modulate = *(int *)colors;
}
// if it is a temporary (shadow) mark, add it immediately and forget
@ -251,38 +243,38 @@ void CG_ImpactMark
}
// otherwise save it persistantly
mark = CG_AllocMark();
mark->time = cg.time;
mark->alphaFade = alphaFade;
mark->markShader = markShader;
mark = CG_AllocMark();
mark->time = cg.time;
mark->alphaFade = alphaFade;
mark->markShader = markShader;
mark->poly.numVerts = mf->numPoints;
mark->color[0] = red;
mark->color[1] = green;
mark->color[2] = blue;
mark->color[3] = alpha;
mark->fadein = fadein;
mark->lightstyle = lightstyle;
mark->color[0] = red;
mark->color[1] = green;
mark->color[2] = blue;
mark->color[3] = alpha;
mark->fadein = fadein;
mark->lightstyle = lightstyle;
memcpy(mark->verts, verts, mf->numPoints * sizeof(verts[0]));
}
}
void CG_ImpactMarkSimple(
qhandle_t markShader,
vec_t* origin,
vec_t* dir,
float orientation,
float fRadius,
float red,
float green,
float blue,
float alpha,
qboolean alphaFade,
qboolean temporary,
qboolean dolighting,
qboolean fadein
qhandle_t markShader,
vec_t *origin,
vec_t *dir,
float orientation,
float fRadius,
float red,
float green,
float blue,
float alpha,
qboolean alphaFade,
qboolean temporary,
qboolean dolighting,
qboolean fadein
)
{
// FIXME: unimplemented
// FIXME: unimplemented
}
/*
@ -290,15 +282,15 @@ void CG_ImpactMarkSimple(
CG_AddMarks
===============
*/
#define MARK_TOTAL_TIME 10000
#define MARK_FADE_TIME 1000
#define MARK_TOTAL_TIME 10000
#define MARK_FADE_TIME 1000
void CG_AddMarks(void)
{
int j;
int j;
markPoly_t *mp, *next;
int t;
int fade;
int t;
int fade;
if (!cg_addMarks->integer) {
return;
@ -383,55 +375,34 @@ qboolean CG_CheckMakeMarkOnEntity(int iEntIndex)
}
void CG_InitTestTreadMark()
{
// FIXME: unimplemented
}
int CG_StartTreadMark(
int iReference,
qhandle_t treadShader,
vec_t* vStartPos,
float fWidth,
float fAlpha)
{
// FIXME: unimplemented
return 0;
}
qboolean CG_MakeTreadMarkDecal_PerPolyCallback(
vec3_t* markPoints,
markFragment_t* mf,
polyVert_t* verts,
void* pCustom
)
{
// FIXME: unimplemented
return qfalse;
}
int CG_MakeTreadMarkDecal_GetLeafCallback(
markFragment_t* mf,
void* pCustom
)
int CG_StartTreadMark(int iReference, qhandle_t treadShader, vec_t *vStartPos, float fWidth, float fAlpha)
{
// FIXME: unimplemented
return 0;
}
void CG_MakeTreadMarkDecal(
treadMark_t* pTread,
qboolean bStartSegment,
qboolean bTemporary
)
qboolean CG_MakeTreadMarkDecal_PerPolyCallback(vec3_t *markPoints, markFragment_t *mf, polyVert_t *verts, void *pCustom)
{
// FIXME: unimplemented
return qfalse;
}
int CG_MakeTreadMarkDecal_GetLeafCallback(markFragment_t *mf, void *pCustom)
{
// FIXME: unimplemented
return 0;
}
void CG_MakeTreadMarkDecal(treadMark_t *pTread, qboolean bStartSegment, qboolean bTemporary)
{
// FIXME: unimplemented
}
int CG_UpdateTreadMark(
int iReference,
vec_t* vNewPos,
float fAlpha
)
int CG_UpdateTreadMark(int iReference, vec_t *vNewPos, float fAlpha)
{
// FIXME: unimplemented
return 0;
@ -443,20 +414,20 @@ void CG_AddTreadMarks()
}
int CG_PermanentMark(
const vec3_t origin,
const vec3_t dir,
float orientation,
float fSScale,
float fTScale,
float red,
float green,
float blue,
float alpha,
qboolean dolighting,
float fSCenter,
float fTCenter,
markFragment_t* pMarkFragments,
void* pVoidPolyVerts
const vec3_t origin,
const vec3_t dir,
float orientation,
float fSScale,
float fTScale,
float red,
float green,
float blue,
float alpha,
qboolean dolighting,
float fSCenter,
float fTCenter,
markFragment_t *pMarkFragments,
void *pVoidPolyVerts
)
{
// FIXME: unimplemented
@ -464,11 +435,11 @@ int CG_PermanentMark(
}
int CG_PermanentTreadMarkDecal(
treadMark_t* pTread,
qboolean bStartSegment,
qboolean dolighting,
markFragment_t* pMarkFragments,
void* pVoidPolyVerts
treadMark_t *pTread,
qboolean bStartSegment,
qboolean dolighting,
markFragment_t *pMarkFragments,
void *pVoidPolyVerts
)
{
// FIXME: unimplemented
@ -476,12 +447,7 @@ int CG_PermanentTreadMarkDecal(
}
int CG_PermanentUpdateTreadMark(
treadMark_t* pTread,
float fAlpha,
float fMinSegment,
float fMaxSegment,
float fMaxOffset,
float fTexScale
treadMark_t *pTread, float fAlpha, float fMinSegment, float fMaxSegment, float fMaxOffset, float fTexScale
)
{
// FIXME: unimplemented

File diff suppressed because it is too large Load diff

View file

@ -26,22 +26,22 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_local.h"
#include "cg_commands.h"
cvar_t* cg_rain;
cvar_t* cg_rain_drawcoverage;
cvar_t *cg_rain;
cvar_t *cg_rain_drawcoverage;
void RainTouch(ctempmodel_t* ct, trace_t* trace)
void RainTouch(ctempmodel_t *ct, trace_t *trace)
{
Vector norm, neworg;
ct->ent.hModel = cgi.R_RegisterModel("splash_z.spr");
ct->cgd.velocity = vec_zero;
ct->cgd.accel = vec_zero;
ct->killTime = cg.time + 400;
norm = trace->plane.normal;
norm.x = -norm.x;
norm.y = -norm.y;
ct->cgd.angles = norm.toAngles();
ct->ent.scale = 0.3f;
ct->ent.hModel = cgi.R_RegisterModel("splash_z.spr");
ct->cgd.velocity = vec_zero;
ct->cgd.accel = vec_zero;
ct->killTime = cg.time + 400;
norm = trace->plane.normal;
norm.x = -norm.x;
norm.y = -norm.y;
ct->cgd.angles = norm.toAngles();
ct->ent.scale = 0.3f;
ct->cgd.scaleRate = 4.0;
ct->cgd.flags |= T_FADE;
@ -49,7 +49,7 @@ void RainTouch(ctempmodel_t* ct, trace_t* trace)
VectorCopy(neworg, ct->ent.origin);
}
void ClientGameCommandManager::RainTouch(Event* ev)
void ClientGameCommandManager::RainTouch(Event *ev)
{
// FIXME: unimplemented
}
@ -59,15 +59,16 @@ void ClientGameCommandManager::InitializeRainCvars()
int i;
cg_rain = cgi.Cvar_Get("cg_rain", "0", CVAR_ARCHIVE);
cg_rain_drawcoverage = cgi.Cvar_Get("cg_rain_drawcoverage", "0", CVAR_SAVEGAME | CVAR_SERVER_CREATED | CVAR_SYSTEMINFO);
cg_rain_drawcoverage =
cgi.Cvar_Get("cg_rain_drawcoverage", "0", CVAR_SAVEGAME | CVAR_SERVER_CREATED | CVAR_SYSTEMINFO);
cg.rain.density = 0.0;
cg.rain.speed = 2048.0f;
cg.rain.length = 90.0f;
cg.rain.min_dist = 512.0f;
cg.rain.width = 1.0f;
cg.rain.density = 0.0;
cg.rain.speed = 2048.0f;
cg.rain.length = 90.0f;
cg.rain.min_dist = 512.0f;
cg.rain.width = 1.0f;
cg.rain.speed_vary = 512;
cg.rain.slant = 50;
cg.rain.slant = 50;
for (i = 0; i < MAX_RAIN_SHADERS; i++) {
cg.rain.shader[i][0] = 0;
@ -76,19 +77,19 @@ void ClientGameCommandManager::InitializeRainCvars()
cg.rain.numshaders = 0;
}
void CG_Rain(centity_t* cent)
void CG_Rain(centity_t *cent)
{
int iLife;
vec3_t mins, maxs;
vec3_t vOmins, vOmaxs, vOe;
float fcolor[4];
vec3_t vStart, vEnd;
int iNumSpawn;
int i;
int iRandom;
float fDensity;
vec3_t vLength;
const char* shadername;
int iLife;
vec3_t mins, maxs;
vec3_t vOmins, vOmaxs, vOe;
float fcolor[4];
vec3_t vStart, vEnd;
int iNumSpawn;
int i;
int iRandom;
float fDensity;
vec3_t vLength;
const char *shadername;
fcolor[0] = 1.0;
fcolor[1] = 1.0;
@ -133,35 +134,26 @@ void CG_Rain(centity_t* cent)
return;
}
if (cg_rain_drawcoverage->integer)
{
if (cg_rain_drawcoverage->integer) {
cgi.R_DebugLine(
Vector(vOmins[0], vOmins[1], vOmins[2]),
Vector(vOmaxs[0], vOmins[1], vOmins[2]),
1.0, 0.0, 0.0, 1.0
Vector(vOmins[0], vOmins[1], vOmins[2]), Vector(vOmaxs[0], vOmins[1], vOmins[2]), 1.0, 0.0, 0.0, 1.0
);
cgi.R_DebugLine(
Vector(vOmaxs[0], vOmins[1], vOmins[2]),
Vector(vOmaxs[0], vOmaxs[1], vOmins[2]),
1.0, 0.0, 0.0, 1.0
Vector(vOmaxs[0], vOmins[1], vOmins[2]), Vector(vOmaxs[0], vOmaxs[1], vOmins[2]), 1.0, 0.0, 0.0, 1.0
);
cgi.R_DebugLine(
Vector(vOmaxs[0], vOmaxs[1], vOmins[2]),
Vector(vOmins[0], vOmaxs[1], vOmins[2]),
1.0, 0.0, 0.0, 1.0
Vector(vOmaxs[0], vOmaxs[1], vOmins[2]), Vector(vOmins[0], vOmaxs[1], vOmins[2]), 1.0, 0.0, 0.0, 1.0
);
cgi.R_DebugLine(
Vector(vOmins[0], vOmaxs[1], vOmins[2]),
Vector(vOmins[0], vOmins[1], vOmins[2]),
1.0, 0.0, 0.0, 1.0
Vector(vOmins[0], vOmaxs[1], vOmins[2]), Vector(vOmins[0], vOmins[1], vOmins[2]), 1.0, 0.0, 0.0, 1.0
);
}
VectorSubtract(vOmaxs, vOmins, vOe);
fDensity = cg.rain.density / 200.0;
fDensity = cg.rain.density / 200.0;
iNumSpawn = (int)(sqrt(vOe[0] * vOe[1]) * fDensity);
if (iNumSpawn > MAX_BEAMS) {
iNumSpawn = MAX_BEAMS;
@ -171,21 +163,18 @@ void CG_Rain(centity_t* cent)
if (cg.rain.numshaders) {
shadername = cg.rain.shader[iRandom % cg.rain.numshaders];
}
else {
} else {
shadername = cg.rain.shader[0];
}
for (i = 0; i < iNumSpawn; ++i)
{
iLife = (int)(vOe[2] / ((float)(iRandom % cg.rain.speed_vary) + cg.rain.speed) * 1000.0);
for (i = 0; i < iNumSpawn; ++i) {
iLife = (int)(vOe[2] / ((float)(iRandom % cg.rain.speed_vary) + cg.rain.speed) * 1000.0);
vStart[0] = (float)(iRandom % (int)(vOe[0] + 1.0)) + vOmins[0];
iRandom = ((214013 * iRandom + 2531011) >> 16) & 0x7FFF;
iRandom = ((214013 * iRandom + 2531011) >> 16) & 0x7FFF;
vStart[1] = (float)(iRandom % (int)(vOe[1] + 1.0)) + vOmins[1];
vStart[2] = vOmaxs[2];
if (cg.snap)
{
if (cg.snap) {
vLength[0] = cg.snap->ps.origin[0] - vStart[0];
vLength[1] = cg.snap->ps.origin[1] - vStart[1];
vLength[2] = 0.0;

File diff suppressed because it is too large Load diff

View file

@ -29,9 +29,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
extern "C" {
#endif
void CG_AddBulletTracers();
void CG_AddBulletImpacts();
void CG_InitCGMessageAPI(clientGameExport_t *cge);
void CG_AddBulletTracers();
void CG_AddBulletImpacts();
void CG_InitCGMessageAPI(clientGameExport_t *cge);
#ifdef __cplusplus
}

View file

@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// DESCRIPTION:
// Player functions for the cgame
// Player functions for the cgame
#include "cg_local.h"
#include "cg_commands.h"
@ -42,9 +42,9 @@ CG_ResetPlayerEntity
A player just came into view or teleported, so reset all animation info
===============
*/
void CG_ResetPlayerEntity( centity_t *cent )
void CG_ResetPlayerEntity(centity_t *cent)
{
cent->errorTime = -99999; // guarantee no error decay added
cent->errorTime = -99999; // guarantee no error decay added
cent->extrapolated = qfalse;
VectorCopy(cent->currentState.origin, cent->lerpOrigin);
@ -53,8 +53,7 @@ void CG_ResetPlayerEntity( centity_t *cent )
VectorCopy(cent->currentState.angles, cent->lerpAngles);
VectorCopy(cent->lerpAngles, cent->rawAngles);
if (cent->currentState.number == cg.snap->ps.clientNum)
{
if (cent->currentState.number == cg.snap->ps.clientNum) {
// initialize the camera position
VectorCopy(cent->lerpOrigin, cg.currentViewPos);
// initialize the camera angles
@ -70,7 +69,7 @@ void CG_ResetPlayerEntity( centity_t *cent )
CG_Player
===============
*/
void CG_Player( centity_t *cent )
{
//CG_PlayerSplash( cent );
}
void CG_Player(centity_t *cent)
{
//CG_PlayerSplash( cent );
}

View file

@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// DESCRIPTION:
//
//
// this file acts on changes in a new playerState_t.
// With normal play, this will be done after local prediction, but when
// following another player or playing back a demo, it will be checked
@ -35,8 +35,4 @@ CG_TransitionPlayerState
===============
*/
void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops )
{
}
void CG_TransitionPlayerState(playerState_t *ps, playerState_t *ops) {}

View file

@ -30,9 +30,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
static pmove_t cg_pmove;
static int cg_numSolidEntities;
static centity_t* cg_solidEntities[MAX_ENTITIES_IN_SNAPSHOT];
static int cg_numTriggerEntities;
static int cg_numSolidEntities;
static centity_t *cg_solidEntities[MAX_ENTITIES_IN_SNAPSHOT];
static int cg_numTriggerEntities;
// static centity_t *cg_triggerEntities[MAX_ENTITIES_IN_SNAPSHOT];
/*
@ -46,12 +47,12 @@ efficient collision detection
*/
void CG_BuildSolidList(void)
{
int i;
centity_t* cent;
snapshot_t* snap;
entityState_t* ent;
int i;
centity_t *cent;
snapshot_t *snap;
entityState_t *ent;
cg_numSolidEntities = 0;
cg_numSolidEntities = 0;
cg_numTriggerEntities = 0;
if (cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport) {
@ -62,10 +63,9 @@ void CG_BuildSolidList(void)
for (i = 0; i < snap->numEntities; i++) {
cent = &cg_entities[snap->entities[i].number];
ent = &cent->currentState;
ent = &cent->currentState;
if (ent->eType == ET_ITEM || ent->eType == ET_PUSH_TRIGGER ||
ent->eType == ET_TELEPORT_TRIGGER) {
if (ent->eType == ET_ITEM || ent->eType == ET_PUSH_TRIGGER || ent->eType == ET_TELEPORT_TRIGGER) {
/*
cg_triggerEntities[cg_numTriggerEntities] = cent;
cg_numTriggerEntities++;
@ -87,22 +87,28 @@ CG_ClipMoveToEntities
====================
*/
void CG_ClipMoveToEntities(const vec3_t start, const vec3_t mins,
const vec3_t maxs, const vec3_t end,
int skipNumber, int mask, trace_t* tr,
qboolean cylinder)
void CG_ClipMoveToEntities(
const vec3_t start,
const vec3_t mins,
const vec3_t maxs,
const vec3_t end,
int skipNumber,
int mask,
trace_t *tr,
qboolean cylinder
)
{
int i;
trace_t trace;
entityState_t* ent;
clipHandle_t cmodel;
vec3_t bmins, bmaxs;
vec3_t origin, angles;
centity_t* cent;
int i;
trace_t trace;
entityState_t *ent;
clipHandle_t cmodel;
vec3_t bmins, bmaxs;
vec3_t origin, angles;
centity_t *cent;
for (i = 0; i < cg_numSolidEntities; i++) {
cent = cg_solidEntities[i];
ent = &cent->currentState;
ent = &cent->currentState;
if (ent->number == skipNumber) {
continue;
@ -116,41 +122,43 @@ void CG_ClipMoveToEntities(const vec3_t start, const vec3_t mins,
}
} else {
IntegerToBoundingBox(ent->solid, bmins, bmaxs);
cmodel = cgi.CM_TempBoxModel(
bmins, bmaxs,
CONTENTS_BBOX);
cmodel = cgi.CM_TempBoxModel(bmins, bmaxs, CONTENTS_BBOX);
}
VectorCopy(cent->lerpOrigin, origin);
if (ent->eFlags & EF_LINKANGLES) {
VectorCopy(cent->lerpAngles, angles);
}
else {
} else {
VectorClear(angles);
}
cgi.CM_TransformedBoxTrace(&trace, start, end, mins, maxs, cmodel, mask,
origin, angles, cylinder);
cgi.CM_TransformedBoxTrace(&trace, start, end, mins, maxs, cmodel, mask, origin, angles, cylinder);
if (trace.allsolid || trace.fraction < tr->fraction) {
trace.entityNum = ent->number;
*tr = trace;
*tr = trace;
} else if (trace.startsolid) {
tr->startsolid = qtrue;
}
}
}
void CG_ShowTrace(trace_t* trace, int passent, const char* reason)
void CG_ShowTrace(trace_t *trace, int passent, const char *reason)
{
char text[1024];
assert(reason);
assert(trace);
sprintf(text, "%0.2f : Pass (%d) Frac %f Hit (%d): '%s'\n",
(float)cg.time / 1000.0f, passent, trace->fraction,
trace->entityNum, reason ? reason : "");
sprintf(
text,
"%0.2f : Pass (%d) Frac %f Hit (%d): '%s'\n",
(float)cg.time / 1000.0f,
passent,
trace->fraction,
trace->entityNum,
reason ? reason : ""
);
if (cg_traceinfo->integer == 3) {
cgi.DebugPrintf(text);
@ -164,10 +172,18 @@ void CG_ShowTrace(trace_t* trace, int passent, const char* reason)
CG_Trace
================
*/
void CG_Trace(trace_t* result, const vec3_t start, const vec3_t mins,
const vec3_t maxs, const vec3_t end, int skipNumber, int mask,
qboolean cylinder, qboolean cliptoentities,
const char* description)
void CG_Trace(
trace_t *result,
const vec3_t start,
const vec3_t mins,
const vec3_t maxs,
const vec3_t end,
int skipNumber,
int mask,
qboolean cylinder,
qboolean cliptoentities,
const char *description
)
{
trace_t t;
@ -182,8 +198,7 @@ void CG_Trace(trace_t* result, const vec3_t start, const vec3_t mins,
if (cliptoentities) {
// check all other solid models
CG_ClipMoveToEntities(start, mins, maxs, end, skipNumber, mask, &t,
cylinder);
CG_ClipMoveToEntities(start, mins, maxs, end, skipNumber, mask, &t, cylinder);
}
*result = t;
@ -198,12 +213,19 @@ void CG_Trace(trace_t* result, const vec3_t start, const vec3_t mins,
CG_PlayerTrace
================
*/
void CG_PlayerTrace(trace_t* result, const vec3_t start, const vec3_t mins,
const vec3_t maxs, const vec3_t end, int skipNumber,
int mask, qboolean cylinder, qboolean tracedeep)
void CG_PlayerTrace(
trace_t *result,
const vec3_t start,
const vec3_t mins,
const vec3_t maxs,
const vec3_t end,
int skipNumber,
int mask,
qboolean cylinder,
qboolean tracedeep
)
{
CG_Trace(result, start, mins, maxs, end, skipNumber, mask, cylinder, qtrue,
"PlayerTrace");
CG_Trace(result, start, mins, maxs, end, skipNumber, mask, cylinder, qtrue, "PlayerTrace");
}
/*
@ -213,11 +235,11 @@ CG_PointContents
*/
int CG_PointContents(const vec3_t point, int passEntityNum)
{
int i;
entityState_t* ent;
centity_t* cent;
clipHandle_t cmodel;
int contents;
int i;
entityState_t *ent;
centity_t *cent;
clipHandle_t cmodel;
int contents;
contents = cgi.CM_PointContents(point, 0);
@ -239,8 +261,7 @@ int CG_PointContents(const vec3_t point, int passEntityNum)
continue;
}
contents |= cgi.CM_TransformedPointContents(point, cmodel, ent->origin,
ent->angles);
contents |= cgi.CM_TransformedPointContents(point, cmodel, ent->origin, ent->angles);
}
return contents;
@ -256,8 +277,8 @@ cg.snap->player_state and cg.nextFrame->player_state
*/
static void CG_InterpolatePlayerStateCamera(void)
{
float f;
int i;
float f;
int i;
snapshot_t *prev, *next;
prev = cg.snap;
@ -279,8 +300,7 @@ static void CG_InterpolatePlayerStateCamera(void)
return;
}
f = (float)(cg.time - prev->serverTime) /
(next->serverTime - prev->serverTime);
f = (float)(cg.time - prev->serverTime) / (next->serverTime - prev->serverTime);
// interpolate fov
cg.camera_fov = prev->ps.fov + f * (next->ps.fov - prev->ps.fov);
@ -290,11 +310,8 @@ static void CG_InterpolatePlayerStateCamera(void)
}
for (i = 0; i < 3; i++) {
cg.camera_origin[i] =
prev->ps.camera_origin[i] +
f * (next->ps.camera_origin[i] - prev->ps.camera_origin[i]);
cg.camera_angles[i] =
LerpAngle(prev->ps.camera_angles[i], next->ps.camera_angles[i], f);
cg.camera_origin[i] = prev->ps.camera_origin[i] + f * (next->ps.camera_origin[i] - prev->ps.camera_origin[i]);
cg.camera_angles[i] = LerpAngle(prev->ps.camera_angles[i], next->ps.camera_angles[i], f);
}
}
@ -308,12 +325,12 @@ cg.snap->player_state and cg.nextFrame->player_state
*/
static void CG_InterpolatePlayerState(qboolean grabAngles)
{
float f;
int i;
playerState_t* out;
snapshot_t *prev, *next;
float f;
int i;
playerState_t *out;
snapshot_t *prev, *next;
out = &cg.predicted_player_state;
out = &cg.predicted_player_state;
prev = cg.snap;
next = cg.nextSnap;
@ -325,7 +342,7 @@ static void CG_InterpolatePlayerState(qboolean grabAngles)
// if we are still allowing local input, short circuit the view angles
if (grabAngles) {
usercmd_t cmd;
int cmdNum;
int cmdNum;
cmdNum = cgi.GetCurrentCmdNumber();
cgi.GetUserCmd(cmdNum, &cmd);
@ -345,14 +362,11 @@ static void CG_InterpolatePlayerState(qboolean grabAngles)
f = cg.frameInterpolation;
for (i = 0; i < 3; i++) {
out->origin[i] =
prev->ps.origin[i] + f * (next->ps.origin[i] - prev->ps.origin[i]);
out->origin[i] = prev->ps.origin[i] + f * (next->ps.origin[i] - prev->ps.origin[i]);
if (!grabAngles) {
out->viewangles[i] =
LerpAngle(prev->ps.viewangles[i], next->ps.viewangles[i], f);
out->viewangles[i] = LerpAngle(prev->ps.viewangles[i], next->ps.viewangles[i], f);
}
out->velocity[i] = prev->ps.velocity[i] +
f * (next->ps.velocity[i] - prev->ps.velocity[i]);
out->velocity[i] = prev->ps.velocity[i] + f * (next->ps.velocity[i] - prev->ps.velocity[i]);
}
}
@ -384,10 +398,10 @@ to ease the jerk.
*/
void CG_PredictPlayerState(void)
{
int cmdNum, current;
int cmdNum, current;
playerState_t oldPlayerState;
qboolean moved;
usercmd_t latestCmd;
qboolean moved;
usercmd_t latestCmd;
cg.hyperspace = qfalse; // will be set if touching a trigger_teleport
@ -395,13 +409,12 @@ void CG_PredictPlayerState(void)
// predicted_player_state is valid even if there is some
// other error condition
if (!cg.validPPS) {
cg.validPPS = qtrue;
cg.validPPS = qtrue;
cg.predicted_player_state = cg.snap->ps;
}
// demo playback just copies the moves
if (cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_NO_PREDICTION) ||
(cg.snap->ps.pm_flags & PMF_FROZEN)) {
if (cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_NO_PREDICTION) || (cg.snap->ps.pm_flags & PMF_FROZEN)) {
CG_InterpolatePlayerState(qfalse);
return;
}
@ -410,15 +423,14 @@ void CG_PredictPlayerState(void)
// FIXME
// Noclip is jittery for some reason, so I'm disabling prediction while
// noclipping
if (cg_nopredict->integer || cg_synchronousClients->integer ||
(cg.snap->ps.pm_type == PM_NOCLIP)) {
if (cg_nopredict->integer || cg_synchronousClients->integer || (cg.snap->ps.pm_type == PM_NOCLIP)) {
CG_InterpolatePlayerState(qtrue);
return;
}
// prepare for pmove
cg_pmove.ps = &cg.predicted_player_state;
cg_pmove.trace = CG_PlayerTrace;
cg_pmove.ps = &cg.predicted_player_state;
cg_pmove.trace = CG_PlayerTrace;
cg_pmove.pointcontents = CG_PointContents;
if (cg_pmove.ps->pm_type == PM_DEAD) {
@ -444,24 +456,22 @@ void CG_PredictPlayerState(void)
// be ahead of everything else anyway
if (cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport) {
cg.predicted_player_state = cg.nextSnap->ps;
cg.physicsTime = cg.nextSnap->serverTime;
cg.physicsTime = cg.nextSnap->serverTime;
} else {
cg.predicted_player_state = cg.snap->ps;
cg.physicsTime = cg.snap->serverTime;
cg.physicsTime = cg.snap->serverTime;
}
if (pmove_msec->integer >= 8)
{
if (pmove_msec->integer > 33)
if (pmove_msec->integer >= 8) {
if (pmove_msec->integer > 33) {
cgi.Cvar_Set("pmove_msec", "33");
}
else
{
}
} else {
cgi.Cvar_Set("pmove_msec", "8");
}
cg_pmove.pmove_fixed = pmove_fixed->integer;
cg_pmove.pmove_msec = pmove_msec->integer;
cg_pmove.pmove_msec = pmove_msec->integer;
// run cmds
moved = qfalse;
@ -488,9 +498,7 @@ void CG_PredictPlayerState(void)
// from the snapshot, but on a wan we will have
// to predict several commands to get to the point
// we want to compare
if (cg.predicted_player_state.commandTime ==
oldPlayerState.commandTime) {
if (cg.predicted_player_state.commandTime == oldPlayerState.commandTime) {
if (cg.thisFrameTeleport) {
// a teleport will not cause an error decay
VectorClear(cg.predictedError);
@ -504,13 +512,12 @@ void CG_PredictPlayerState(void)
// if our feet are falling, don't try to move
if (cg_pmove.ps->feetfalling && (cg_pmove.waterlevel < 2)) {
cg_pmove.cmd.forwardmove = 0;
cg_pmove.cmd.rightmove = 0;
cg_pmove.cmd.rightmove = 0;
}
if (cg_pmove.pmove_fixed) {
cg_pmove.cmd.serverTime = pmove_msec->integer
* ((cg_pmove.cmd.serverTime + pmove_msec->integer - 1)
/ pmove_msec->integer);
cg_pmove.cmd.serverTime =
pmove_msec->integer * ((cg_pmove.cmd.serverTime + pmove_msec->integer - 1) / pmove_msec->integer);
}
Pmove(&cg_pmove);
@ -530,8 +537,8 @@ void CG_PredictPlayerState(void)
// Interpolate the player position
if (cg.predicted_player_state.groundEntityNum != ENTITYNUM_WORLD) {
centity_t* cent;
vec3_t offset;
centity_t *cent;
vec3_t offset;
cent = &cg_entities[cg.predicted_player_state.groundEntityNum];
@ -540,9 +547,15 @@ void CG_PredictPlayerState(void)
f = cg.frameInterpolation - 1.0;
offset[0] = (cent->nextState.origin[0] - cg_entities[cg.predicted_player_state.groundEntityNum].currentState.origin[0]) * f;
offset[1] = (cent->nextState.origin[1] - cg_entities[cg.predicted_player_state.groundEntityNum].currentState.origin[1]) * f;
offset[2] = (cent->nextState.origin[2] - cg_entities[cg.predicted_player_state.groundEntityNum].currentState.origin[2]) * f;
offset[0] = (cent->nextState.origin[0]
- cg_entities[cg.predicted_player_state.groundEntityNum].currentState.origin[0])
* f;
offset[1] = (cent->nextState.origin[1]
- cg_entities[cg.predicted_player_state.groundEntityNum].currentState.origin[1])
* f;
offset[2] = (cent->nextState.origin[2]
- cg_entities[cg.predicted_player_state.groundEntityNum].currentState.origin[2])
* f;
cg.predicted_player_state.origin[0] += offset[0];
cg.predicted_player_state.origin[1] += offset[1];

View file

@ -27,58 +27,55 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define __CG_PUBLIC_H__
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
#define MAGIC_UNUSED_NUMBER 7777
#define CMD_BACKUP 128
#define CMD_MASK (CMD_BACKUP - 1)
// allow a lot of command backups for very fast systems
// multiple commands may be combined into a single packet, so this
// needs to be larger than PACKET_BACKUP
#define MAGIC_UNUSED_NUMBER 7777
#define CMD_BACKUP 128
#define CMD_MASK (CMD_BACKUP - 1)
// allow a lot of command backups for very fast systems
// multiple commands may be combined into a single packet, so this
// needs to be larger than PACKET_BACKUP
#define MAX_ENTITIES_IN_SNAPSHOT 1024
#define MAX_ENTITIES_IN_SNAPSHOT 1024
// snapshots are a view of the server at a given time
// snapshots are a view of the server at a given time
// Snapshots are generated at regular time intervals by the server,
// but they may not be sent if a client's rate level is exceeded, or
// they may be dropped by the network.
typedef struct {
int snapFlags; // SNAPFLAG_RATE_DELAYED, etc
int ping;
// Snapshots are generated at regular time intervals by the server,
// but they may not be sent if a client's rate level is exceeded, or
// they may be dropped by the network.
typedef struct {
int snapFlags; // SNAPFLAG_RATE_DELAYED, etc
int ping;
int serverTime; // server time the message is valid for (in msec)
int serverTime; // server time the message is valid for (in msec)
byte areamask[MAX_MAP_AREA_BYTES]; // portalarea visibility bits
byte areamask[MAX_MAP_AREA_BYTES]; // portalarea visibility bits
playerState_t ps; // complete information about the current player at this time
playerState_t ps; // complete information about the current player at this time
int numEntities; // all of the entities that need to be presented
entityState_t entities[MAX_ENTITIES_IN_SNAPSHOT]; // at the time of this snapshot
int numEntities; // all of the entities that need to be presented
entityState_t entities[MAX_ENTITIES_IN_SNAPSHOT]; // at the time of this snapshot
int numServerCommands; // text based server commands to execute when this
int serverCommandSequence; // snapshot becomes current
int numServerCommands; // text based server commands to execute when this
int serverCommandSequence; // snapshot becomes current
int number_of_sounds;
server_sound_t sounds[MAX_SERVER_SOUNDS];
} snapshot_t;
int number_of_sounds;
server_sound_t sounds[ MAX_SERVER_SOUNDS ];
} snapshot_t;
typedef struct stopWatch_s {
int iStartTime;
int iEndTime;
typedef struct stopWatch_s
{
int iStartTime;
int iEndTime;
} stopWatch_t;
} stopWatch_t;
typedef struct AliasList_s AliasList_t;
typedef struct AliasListNode_s AliasListNode_t;
typedef struct dtiki_s dtiki_t;
typedef struct tiki_cmd_s tiki_cmd_t;
typedef struct AliasList_s AliasList_t;
typedef struct AliasListNode_s AliasListNode_t;
typedef struct dtiki_s dtiki_t;
typedef struct tiki_cmd_s tiki_cmd_t;
/*
/*
==================================================================
functions imported from the main executable
@ -86,9 +83,9 @@ functions imported from the main executable
==================================================================
*/
#define CGAME_IMPORT_API_VERSION 3
#define CGAME_IMPORT_API_VERSION 3
/*
/*
==================================================================
functions exported to the main executable
@ -96,274 +93,344 @@ functions exported to the main executable
==================================================================
*/
typedef struct
{
int apiversion;
//============== general services ==================
typedef struct {
int apiversion;
// print message on the local console
void (*Printf)( const char *fmt, ...);
void (*DPrintf)( const char *fmt, ...);
void (*DebugPrintf)( const char *fmt, ...);
//============== general services ==================
// managed memory allocation
void *(*Malloc)( int size );
void (*Free)( void *block );
// print message on the local console
void (*Printf)(const char *fmt, ...);
void (*DPrintf)(const char *fmt, ...);
void (*DebugPrintf)(const char *fmt, ...);
// abort the game
void (*Error)( int errorLevel, const char *fmt, ...);
// managed memory allocation
void *(*Malloc)(int size);
void (*Free)(void *block);
// milliseconds should only be used for profiling, never
// for anything game related. Get time from CG_ReadyToBuildScene.
int (*Milliseconds)( void );
// abort the game
void (*Error)(int errorLevel, const char *fmt, ...);
// localization
const char* (*LV_ConvertString)(const char* string);
// milliseconds should only be used for profiling, never
// for anything game related. Get time from CG_ReadyToBuildScene.
int (*Milliseconds)(void);
// console variable interaction
cvar_t * (*Cvar_Get)( const char *var_name, const char *value, int flags );
void (*Cvar_Set)( const char *var_name, const char *value );
// localization
const char *(*LV_ConvertString)(const char *string);
// ClientCommand and ConsoleCommand parameter access
int (*Argc)( void );
char * (*Argv)( int n );
char * (*Args)( void ); // concatenation of all argv >= 1
void (*AddCommand)( const char *cmd );
void (*Cmd_Stuff)(const char* text);
void (*Cmd_Execute)(int execWhen, const char* text);
void (*Cmd_TokenizeString)(const char* textIn);
// console variable interaction
cvar_t *(*Cvar_Get)(const char *var_name, const char *value, int flags);
void (*Cvar_Set)(const char *var_name, const char *value);
// a -1 return means the file does not exist
// NULL can be passed for buf to just determine existance
long (*FS_ReadFile)( const char *name, void **buf, qboolean quiet );
void (*FS_FreeFile)( void *buf );
int (*FS_WriteFile)( const char *qpath, const void *buffer, int size );
void (*FS_WriteTextFile)( const char *qpath, const void *buffer, int size );
// add commands to the local console as if they were typed in
// for map changing, etc. The command is not executed immediately,
// but will be executed in order the next time console commands
// are processed
void (*SendConsoleCommand)( const char *text );
// ClientCommand and ConsoleCommand parameter access
int (*Argc)(void);
char *(*Argv)(int n);
char *(*Args)(void); // concatenation of all argv >= 1
void (*AddCommand)(const char *cmd);
void (*Cmd_Stuff)(const char *text);
void (*Cmd_Execute)(int execWhen, const char *text);
void (*Cmd_TokenizeString)(const char *textIn);
// =========== client specific functions ===============
// a -1 return means the file does not exist
// NULL can be passed for buf to just determine existance
long (*FS_ReadFile)(const char *name, void **buf, qboolean quiet);
void (*FS_FreeFile)(void *buf);
int (*FS_WriteFile)(const char *qpath, const void *buffer, int size);
void (*FS_WriteTextFile)(const char *qpath, const void *buffer, int size);
// add commands to the local console as if they were typed in
// for map changing, etc. The command is not executed immediately,
// but will be executed in order the next time console commands
// are processed
void (*SendConsoleCommand)(const char *text);
// send a string to the server over the network
int (*MSG_ReadBits)(int bits);
int (*MSG_ReadChar)();
int (*MSG_ReadByte)();
int (*MSG_ReadSVC)();
int (*MSG_ReadShort)();
int (*MSG_ReadLong)();
float (*MSG_ReadFloat)();
char* (*MSG_ReadString)();
char* (*MSG_ReadStringLine)();
float (*MSG_ReadAngle8)();
float (*MSG_ReadAngle16)();
void (*MSG_ReadData)(void* data, int len);
float (*MSG_ReadCoord)();
void (*MSG_ReadDir)(vec3_t dir);
void (*SendClientCommand)( const char *s );
// =========== client specific functions ===============
// CM functions
void (*CM_LoadMap)( const char *name );
clipHandle_t (*CM_InlineModel)( int index ); // 0 = world, 1+ = bmodels
int (*CM_NumInlineModels)( void );
int (*CM_PointContents)( const vec3_t p, int headnode );
int (*CM_TransformedPointContents)(const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles);
void (*CM_BoxTrace)( trace_t *results, const vec3_t start, const vec3_t end,
const vec3_t mins, const vec3_t maxs,
int headnode, int brushmask, qboolean cylinder );
void (*CM_TransformedBoxTrace)( trace_t *results, const vec3_t start, const vec3_t end,
const vec3_t mins, const vec3_t maxs,
int headnode, int brushmask,
const vec3_t origin, const vec3_t angles,
qboolean cylinder
);
clipHandle_t (*CM_TempBoxModel)( const vec3_t mins, const vec3_t maxs, int contents );
void (*CM_PrintBSPFileSizes)();
qboolean (*CM_LeafInPVS)(int leaf1, int leaf2);
int (*CM_PointLeafnum)(const vec3_t p);
int (*R_MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection,
int maxPoints, vec3_t pointBuffer,
int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared );
int (*R_MarkFragmentsForInlineModel)(clipHandle_t bmodel, const vec3_t vAngles, const vec3_t vOrigin,
int numPoints, const vec3_t *points, const vec3_t projection,
int maxPoints, vec3_t pointBuffer,
int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared );
// send a string to the server over the network
int (*MSG_ReadBits)(int bits);
int (*MSG_ReadChar)();
int (*MSG_ReadByte)();
int (*MSG_ReadSVC)();
int (*MSG_ReadShort)();
int (*MSG_ReadLong)();
float (*MSG_ReadFloat)();
char *(*MSG_ReadString)();
char *(*MSG_ReadStringLine)();
float (*MSG_ReadAngle8)();
float (*MSG_ReadAngle16)();
void (*MSG_ReadData)(void *data, int len);
float (*MSG_ReadCoord)();
void (*MSG_ReadDir)(vec3_t dir);
void (*SendClientCommand)(const char *s);
void (*R_GetInlineModelBounds)(int index, vec3_t mins, vec3_t maxs);
void (*R_GetLightingForDecal)(vec3_t light, vec3_t facing, vec3_t origin);
void (*R_GetLightingForSmoke)(vec3_t light, vec3_t origin);
int (*R_GatherLightSources)(const vec3_t pos, vec3_t* lightPos, vec3_t* lightIntensity, int maxLights);
// CM functions
void (*CM_LoadMap)(const char *name);
clipHandle_t (*CM_InlineModel)(int index); // 0 = world, 1+ = bmodels
int (*CM_NumInlineModels)(void);
int (*CM_PointContents)(const vec3_t p, int headnode);
int (*CM_TransformedPointContents)(
const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles
);
void (*CM_BoxTrace)(
trace_t *results,
const vec3_t start,
const vec3_t end,
const vec3_t mins,
const vec3_t maxs,
int headnode,
int brushmask,
qboolean cylinder
);
void (*CM_TransformedBoxTrace)(
trace_t *results,
const vec3_t start,
const vec3_t end,
const vec3_t mins,
const vec3_t maxs,
int headnode,
int brushmask,
const vec3_t origin,
const vec3_t angles,
qboolean cylinder
);
clipHandle_t (*CM_TempBoxModel)(const vec3_t mins, const vec3_t maxs, int contents);
void (*CM_PrintBSPFileSizes)();
qboolean (*CM_LeafInPVS)(int leaf1, int leaf2);
int (*CM_PointLeafnum)(const vec3_t p);
int (*R_MarkFragments)(
int numPoints,
const vec3_t *points,
const vec3_t projection,
int maxPoints,
vec3_t pointBuffer,
int maxFragments,
markFragment_t *fragmentBuffer,
float fRadiusSquared
);
int (*R_MarkFragmentsForInlineModel)(
clipHandle_t bmodel,
const vec3_t vAngles,
const vec3_t vOrigin,
int numPoints,
const vec3_t *points,
const vec3_t projection,
int maxPoints,
vec3_t pointBuffer,
int maxFragments,
markFragment_t *fragmentBuffer,
float fRadiusSquared
);
// =========== sound function calls ===============
void (*R_GetInlineModelBounds)(int index, vec3_t mins, vec3_t maxs);
void (*R_GetLightingForDecal)(vec3_t light, vec3_t facing, vec3_t origin);
void (*R_GetLightingForSmoke)(vec3_t light, vec3_t origin);
int (*R_GatherLightSources)(const vec3_t pos, vec3_t *lightPos, vec3_t *lightIntensity, int maxLights);
void (*S_StartSound)(const vec3_t origin, int entNum, int entChannel, sfxHandle_t sfxHandle, float volume, float minDist, float pitch, float maxDist, int streamed);
void (*S_StartLocalSound)(const char* soundName, qboolean forceLoad);
void (*S_StopSound)( int entnum, int channel );
void (*S_ClearLoopingSounds)(void);
void (*S_AddLoopingSound)(const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle, float volume, float minDist, float maxDist, float pitch, int flags);
void (*S_Respatialize)( int entityNum, const vec3_t origin, vec3_t axis[3] );
void (*S_BeginRegistration)( void );
sfxHandle_t (*S_RegisterSound)( const char *sample, int streamed );
void (*S_EndRegistration)( void );
void (*S_UpdateEntity)( int entityNum, const vec3_t origin, const vec3_t velocity, qboolean use_listener );
void (*S_SetReverb)( int reverb_type, float reverb_level );
void (*S_SetGlobalAmbientVolumeLevel)( float volume );
float (*S_GetSoundTime)(sfxHandle_t handle);
int (*S_ChannelNameToNum)(const char* name);
const char* (*S_ChannelNumToName)(int channel);
int (*S_IsSoundPlaying)(int channelNumber, const char* name);
// =========== sound function calls ===============
// =========== music function calls ===============
void (*S_StartSound)(
const vec3_t origin,
int entNum,
int entChannel,
sfxHandle_t sfxHandle,
float volume,
float minDist,
float pitch,
float maxDist,
int streamed
);
void (*S_StartLocalSound)(const char *soundName, qboolean forceLoad);
void (*S_StopSound)(int entnum, int channel);
void (*S_ClearLoopingSounds)(void);
void (*S_AddLoopingSound)(
const vec3_t origin,
const vec3_t velocity,
sfxHandle_t sfxHandle,
float volume,
float minDist,
float maxDist,
float pitch,
int flags
);
void (*S_Respatialize)(int entityNum, const vec3_t origin, vec3_t axis[3]);
void (*S_BeginRegistration)(void);
sfxHandle_t (*S_RegisterSound)(const char *sample, int streamed);
void (*S_EndRegistration)(void);
void (*S_UpdateEntity)(int entityNum, const vec3_t origin, const vec3_t velocity, qboolean use_listener);
void (*S_SetReverb)(int reverb_type, float reverb_level);
void (*S_SetGlobalAmbientVolumeLevel)(float volume);
float (*S_GetSoundTime)(sfxHandle_t handle);
int (*S_ChannelNameToNum)(const char *name);
const char *(*S_ChannelNumToName)(int channel);
int (*S_IsSoundPlaying)(int channelNumber, const char *name);
void (*MUSIC_NewSoundtrack)( const char *name );
void (*MUSIC_UpdateMood)( int current_mood, int fallback_mood );
void (*MUSIC_UpdateVolume)( float volume, float fade_time );
// =========== music function calls ===============
// =========== camera function calls ===============
void (*MUSIC_NewSoundtrack)(const char *name);
void (*MUSIC_UpdateMood)(int current_mood, int fallback_mood);
void (*MUSIC_UpdateVolume)(float volume, float fade_time);
float * (*get_camera_offset)( qboolean *lookactive, qboolean *resetview );
// =========== camera function calls ===============
// =========== renderer function calls ================
void (*R_ClearScene)( void );
void (*R_RenderScene)( const refdef_t *fd );
void (*R_LoadWorldMap)(const char* mapname);
void (*R_PrintBSPFileSizes)();
int (*MapVersion)();
int (*R_MapVersion)();
qhandle_t (*R_RegisterModel)( const char *name );
qhandle_t (*R_SpawnEffectModel)(const char* name, vec3_t pos, vec3_t axis[3]);
qhandle_t (*R_RegisterServerModel)(const char* name);
void (*R_UnregisterServerModel)(qhandle_t hModel);
qhandle_t (*R_RegisterSkin)( const char *name );
qhandle_t (*R_RegisterShader)( const char *name );
qhandle_t (*R_RegisterShaderNoMip)( const char *name );
void (*R_AddRefEntityToScene)(const refEntity_t *ent, int parentEntityNumber );
void (*R_AddRefSpriteToScene)(const refEntity_t *ent );
void (*R_AddLightToScene)(const vec3_t origin, float intensity, float r, float g, float b, int type );
qboolean (*R_AddPolyToScene)(qhandle_t hShader, int numVerts, const polyVert_t* verts, int renderfx);
void (*R_AddTerrainMarkToScene)(int terrainIndex, qhandle_t hShader, int numVerts, const polyVert_t* verts, int renderFx);
void (*R_SetColor)( const vec4_t rgba ); // NULL = 1,1,1,1
void (*R_DrawStretchPic) ( float x, float y, float w, float h,
float s1, float t1, float s2, float t2,
qhandle_t hShader ); // 0 = white
fontheader_t* (*R_LoadFont)(const char* name);
void (*R_DrawString)(fontheader_t* font, const char* text, float x, float y, int maxLen, qboolean virtualScreen);
refEntity_t * (*R_GetRenderEntity)( int entityNumber );
void (*R_ModelBounds)( clipHandle_t model, vec3_t mins, vec3_t maxs );
float (*R_ModelRadius)( clipHandle_t model );
float (*R_Noise)( float x, float y, float z, float t );
void (*R_DebugLine)(const vec3_t start, const vec3_t end, float r, float g, float b, float alpha);
baseshader_t* (*GetShader)(int shaderNum);
// =========== Swipes =============
void (*R_SwipeBegin) ( float thistime, float life, qhandle_t shader );
void (*R_SwipePoint) ( vec3_t p1, vec3_t p2, float time );
void (*R_SwipeEnd) ( void );
int (*R_GetShaderWidth)( qhandle_t shader );
int (*R_GetShaderHeight)( qhandle_t shader );
void (*R_DrawBox)( float x, float y, float w, float h );
float *(*get_camera_offset)(qboolean *lookactive, qboolean *resetview);
// =========== data shared with the client =============
void (*GetGameState)( gameState_t *gamestate );
int (*GetSnapshot)( int snapshotNumber, snapshot_t *snapshot );
int (*GetServerStartTime)();
void (*SetTime)(int time);
void (*GetCurrentSnapshotNumber)( int *snapshotNumber, int *serverTime );
void (*GetGlconfig)( glconfig_t *glconfig );
// =========== renderer function calls ================
void (*R_ClearScene)(void);
void (*R_RenderScene)(const refdef_t *fd);
void (*R_LoadWorldMap)(const char *mapname);
void (*R_PrintBSPFileSizes)();
int (*MapVersion)();
int (*R_MapVersion)();
qhandle_t (*R_RegisterModel)(const char *name);
qhandle_t (*R_SpawnEffectModel)(const char *name, vec3_t pos, vec3_t axis[3]);
qhandle_t (*R_RegisterServerModel)(const char *name);
void (*R_UnregisterServerModel)(qhandle_t hModel);
qhandle_t (*R_RegisterSkin)(const char *name);
qhandle_t (*R_RegisterShader)(const char *name);
qhandle_t (*R_RegisterShaderNoMip)(const char *name);
void (*R_AddRefEntityToScene)(const refEntity_t *ent, int parentEntityNumber);
void (*R_AddRefSpriteToScene)(const refEntity_t *ent);
void (*R_AddLightToScene)(const vec3_t origin, float intensity, float r, float g, float b, int type);
qboolean (*R_AddPolyToScene)(qhandle_t hShader, int numVerts, const polyVert_t *verts, int renderfx);
void (*R_AddTerrainMarkToScene)(
int terrainIndex, qhandle_t hShader, int numVerts, const polyVert_t *verts, int renderFx
);
void (*R_SetColor)(const vec4_t rgba); // NULL = 1,1,1,1
void (*R_DrawStretchPic)(
float x,
float y,
float w,
float h,
float s1,
float t1,
float s2,
float t2,
qhandle_t hShader
); // 0 = white
fontheader_t *(*R_LoadFont)(const char *name);
void (*R_DrawString)(
fontheader_t *font, const char *text, float x, float y, int maxLen, qboolean virtualScreen
);
refEntity_t *(*R_GetRenderEntity)(int entityNumber);
void (*R_ModelBounds)(clipHandle_t model, vec3_t mins, vec3_t maxs);
float (*R_ModelRadius)(clipHandle_t model);
float (*R_Noise)(float x, float y, float z, float t);
void (*R_DebugLine)(const vec3_t start, const vec3_t end, float r, float g, float b, float alpha);
baseshader_t *(*GetShader)(int shaderNum);
// =========== Swipes =============
void (*R_SwipeBegin)(float thistime, float life, qhandle_t shader);
void (*R_SwipePoint)(vec3_t p1, vec3_t p2, float time);
void (*R_SwipeEnd)(void);
int (*R_GetShaderWidth)(qhandle_t shader);
int (*R_GetShaderHeight)(qhandle_t shader);
void (*R_DrawBox)(float x, float y, float w, float h);
// will return false if the number is so old that it doesn't exist in the buffer anymore
qboolean (*GetParseEntityState)( int parseEntityNumber, entityState_t *state );
int (*GetCurrentCmdNumber)( void ); // returns the most recent command number
// which is the local predicted command for
// the following frame
qboolean (*GetUserCmd)( int cmdNumber, usercmd_t *ucmd );
qboolean (*GetServerCommand)(int serverCommandNumber, qboolean differentServer);
// =========== data shared with the client =============
void (*GetGameState)(gameState_t *gamestate);
int (*GetSnapshot)(int snapshotNumber, snapshot_t *snapshot);
int (*GetServerStartTime)();
void (*SetTime)(int time);
void (*GetCurrentSnapshotNumber)(int *snapshotNumber, int *serverTime);
void (*GetGlconfig)(glconfig_t *glconfig);
// ALIAS STUFF
qboolean (*Alias_Add)( const char * alias, const char * name, const char *parameters );
qboolean (*Alias_ListAdd)(AliasList_t* list, const char* alias, const char* name, const char* parameters);
const char* (*Alias_FindRandom)(const char* alias, AliasListNode_t **ret);
const char* (*Alias_ListFindRandom)(AliasList_t* list, const char* alias, AliasListNode_t** ret);
void (*Alias_Dump)( void );
void (*Alias_Clear)( void );
AliasList_t* (*AliasList_New)(const char* name);
void (*Alias_ListFindRandomRange)(AliasList_t* list, const char* alias, int* minIndex, int* maxIndex, float* totalWeight);
AliasList_t* (*Alias_GetGlobalList)();
// will return false if the number is so old that it doesn't exist in the buffer anymore
qboolean (*GetParseEntityState)(int parseEntityNumber, entityState_t *state);
int (*GetCurrentCmdNumber)(void); // returns the most recent command number
// which is the local predicted command for
// the following frame
qboolean (*GetUserCmd)(int cmdNumber, usercmd_t *ucmd);
qboolean (*GetServerCommand)(int serverCommandNumber, qboolean differentServer);
// ==================== UI STUFF ==========================
void (*UI_ShowMenu)(const char* name, qboolean bForce);
void (*UI_HideMenu)(const char* name, qboolean bForce);
int (*UI_FontStringWidth)(fontheader_t* font, const char* string, int maxLen);
// ALIAS STUFF
qboolean (*Alias_Add)(const char *alias, const char *name, const char *parameters);
qboolean (*Alias_ListAdd)(AliasList_t *list, const char *alias, const char *name, const char *parameters);
const char *(*Alias_FindRandom)(const char *alias, AliasListNode_t **ret);
const char *(*Alias_ListFindRandom)(AliasList_t *list, const char *alias, AliasListNode_t **ret);
void (*Alias_Dump)(void);
void (*Alias_Clear)(void);
AliasList_t *(*AliasList_New)(const char *name);
void (*Alias_ListFindRandomRange)(
AliasList_t *list, const char *alias, int *minIndex, int *maxIndex, float *totalWeight
);
AliasList_t *(*Alias_GetGlobalList)();
int (*Key_StringToKeynum)(const char* str);
const char* (*Key_KeynumToBindString)(int keyNum);
void (*Key_GetKeysForCommand)(const char* command, int* key1, int* key2);
// ==================== UI STUFF ==========================
void (*UI_ShowMenu)(const char *name, qboolean bForce);
void (*UI_HideMenu)(const char *name, qboolean bForce);
int (*UI_FontStringWidth)(fontheader_t *font, const char *string, int maxLen);
// ==================== TIKI STUFF ==========================
// TIKI SPECIFIC STUFF
dtiki_t* (*R_Model_GetHandle)(qhandle_t handle);
int (*TIKI_NumAnims)(dtiki_t* pmdl);
void (*TIKI_CalculateBounds)(dtiki_t* pmdl, float scale, vec3_t mins, vec3_t maxs);
const char* (*TIKI_Name)(dtiki_t* tiki);
void* (*TIKI_GetSkeletor)(dtiki_t* tiki, int entNum);
void (*TIKI_SetEyeTargetPos)(dtiki_t* tiki, int entNum, vec3_t pos);
int (*Key_StringToKeynum)(const char *str);
const char *(*Key_KeynumToBindString)(int keyNum);
void (*Key_GetKeysForCommand)(const char *command, int *key1, int *key2);
// ANIM SPECIFIC STUFF
const char * (*Anim_NameForNum) (dtiki_t* tiki, int animnum );
int (*Anim_NumForName) (dtiki_t* tiki, const char * name );
int (*Anim_Random) (dtiki_t* tiki, const char * name );
int (*Anim_NumFrames) (dtiki_t* tiki, int animnum );
float (*Anim_Time) (dtiki_t* tiki, int animnum);
float (*Anim_Frametime) (dtiki_t* tiki, int animnum);
void (*Anim_Delta) (dtiki_t* tiki, int animnum, vec3_t delta );
int (*Anim_Flags) (dtiki_t* tiki, int animnum);
int (*Anim_FlagsSkel) (dtiki_t* tiki, int animnum);
float (*Anim_CrossblendTime) (dtiki_t* tiki, int animnum );
qboolean (*Anim_HasCommands) (dtiki_t* tiki, int animnum );
// ==================== TIKI STUFF ==========================
// TIKI SPECIFIC STUFF
dtiki_t *(*R_Model_GetHandle)(qhandle_t handle);
int (*TIKI_NumAnims)(dtiki_t *pmdl);
void (*TIKI_CalculateBounds)(dtiki_t *pmdl, float scale, vec3_t mins, vec3_t maxs);
const char *(*TIKI_Name)(dtiki_t *tiki);
void *(*TIKI_GetSkeletor)(dtiki_t *tiki, int entNum);
void (*TIKI_SetEyeTargetPos)(dtiki_t *tiki, int entNum, vec3_t pos);
// FRAME SPECIFIC STUFF
qboolean (*Frame_Commands) (dtiki_t* tiki, int animnum, int framenum, tiki_cmd_t * tiki_cmd );
qboolean (*Frame_CommandsTime) (dtiki_t* tiki, int animnum, float start, float end, tiki_cmd_t * tiki_cmd );
// ANIM SPECIFIC STUFF
const char *(*Anim_NameForNum)(dtiki_t *tiki, int animnum);
int (*Anim_NumForName)(dtiki_t *tiki, const char *name);
int (*Anim_Random)(dtiki_t *tiki, const char *name);
int (*Anim_NumFrames)(dtiki_t *tiki, int animnum);
float (*Anim_Time)(dtiki_t *tiki, int animnum);
float (*Anim_Frametime)(dtiki_t *tiki, int animnum);
void (*Anim_Delta)(dtiki_t *tiki, int animnum, vec3_t delta);
int (*Anim_Flags)(dtiki_t *tiki, int animnum);
int (*Anim_FlagsSkel)(dtiki_t *tiki, int animnum);
float (*Anim_CrossblendTime)(dtiki_t *tiki, int animnum);
qboolean (*Anim_HasCommands)(dtiki_t *tiki, int animnum);
// SURFACE SPECIFIC STUFF
int (*Surface_NameToNum) (dtiki_t* tiki, const char * name );
//const char * (*Surface_NumToName) (dtiki_t* tiki, int num );
//int (*Surface_Flags) (dtiki_t* tiki, int num );
//int (*Surface_NumSkins) (dtiki_t* tiki, int num );
// FRAME SPECIFIC STUFF
qboolean (*Frame_Commands)(dtiki_t *tiki, int animnum, int framenum, tiki_cmd_t *tiki_cmd);
qboolean (*Frame_CommandsTime)(dtiki_t *tiki, int animnum, float start, float end, tiki_cmd_t *tiki_cmd);
// TAG SPECIFIC STUFF
int (*Tag_NumForName) (dtiki_t* tiki, const char * name );
const char * (*Tag_NameForNum) (dtiki_t* tiki, int num );
void (*ForceUpdatePose)(refEntity_t* model);
orientation_t (*TIKI_Orientation)(refEntity_t* model, int tagNum);
qboolean (*TIKI_IsOnGround)(refEntity_t* model, int tagNum, float threshold);
// SURFACE SPECIFIC STUFF
int (*Surface_NameToNum)(dtiki_t *tiki, const char *name);
//const char * (*Surface_NumToName) (dtiki_t* tiki, int num );
//int (*Surface_Flags) (dtiki_t* tiki, int num );
//int (*Surface_NumSkins) (dtiki_t* tiki, int num );
// MISCELLANEOUS SPECIFIC STUFF
void (*UI_ShowScoreBoard)(const char* menuName);
void (*UI_HideScoreBoard)();
void (*UI_SetScoreBoardItem)(int itemNumber, const char* data1,
const char* data2, const char* data3,
const char* data4, const char* data5,
const char* data6, const char* data7,
const char* data8, const vec4_t textColor,
const vec4_t backColor, qboolean isHeader);
void (*UI_DeleteScoreBoardItems)(int maxIndex);
void (*UI_ToggleDMMessageConsole)(int consoleMode);
dtiki_t* (*TIKI_FindTiki)(const char* path);
void (*LoadResource)(const char* name);
void (*FS_CanonicalFilename)(char* name);
// TAG SPECIFIC STUFF
int (*Tag_NumForName)(dtiki_t *tiki, const char *name);
const char *(*Tag_NameForNum)(dtiki_t *tiki, int num);
void (*ForceUpdatePose)(refEntity_t *model);
orientation_t (*TIKI_Orientation)(refEntity_t *model, int tagNum);
qboolean (*TIKI_IsOnGround)(refEntity_t *model, int tagNum, float threshold);
cvar_t* fsDebug;
hdelement_t* HudDrawElements;
clientAnim_t* anim;
stopWatch_t* stopWatch;
// MISCELLANEOUS SPECIFIC STUFF
void (*UI_ShowScoreBoard)(const char *menuName);
void (*UI_HideScoreBoard)();
void (*UI_SetScoreBoardItem)(
int itemNumber,
const char *data1,
const char *data2,
const char *data3,
const char *data4,
const char *data5,
const char *data6,
const char *data7,
const char *data8,
const vec4_t textColor,
const vec4_t backColor,
qboolean isHeader
);
void (*UI_DeleteScoreBoardItems)(int maxIndex);
void (*UI_ToggleDMMessageConsole)(int consoleMode);
dtiki_t *(*TIKI_FindTiki)(const char *path);
void (*LoadResource)(const char *name);
void (*FS_CanonicalFilename)(char *name);
} clientGameImport_t;
cvar_t *fsDebug;
hdelement_t *HudDrawElements;
clientAnim_t *anim;
stopWatch_t *stopWatch;
} clientGameImport_t;
/*
/*
==================================================================
functions exported to the main executable
@ -371,51 +438,74 @@ functions exported to the main executable
==================================================================
*/
typedef struct {
void (*CG_Init)( clientGameImport_t *imported, int serverMessageNum, int serverCommandSequence, int clientNum );
void (*CG_Shutdown)( void );
void (*CG_DrawActiveFrame)( int serverTime, int frameTime, stereoFrame_t stereoView, qboolean demoPlayback );
qboolean (*CG_ConsoleCommand)( void );
void (*CG_GetRendererConfig)( void );
void (*CG_Draw2D)( void );
void (*CG_EyePosition)(vec3_t* eyePos);
void (*CG_EyeOffset)(vec3_t* eyeOffset);
void (*CG_EyeAngles)(vec3_t* eyeAngles);
float (*CG_SensitivityScale)();
void (*CG_ParseCGMessage)();
void (*CG_RefreshHudDrawElements)();
void (*CG_HudDrawShader)(int info);
void (*CG_HudDrawFont)(int info);
int (*CG_GetParent)(int entNum);
float (*CG_GetObjectiveAlpha)();
int (*CG_PermanentMark)(const vec3_t origin, const vec3_t dir, float orientation, float sScale, float tScale, float red, float green, float blue, float alpha, qboolean doLighting, float sCenter, float tCenter, markFragment_t* markFragments, void* polyVerts);
int (*CG_PermanentTreadMarkDecal)(treadMark_t* treadMark, qboolean startSegment, qboolean doLighting, markFragment_t* markFragments, void* polyVerts);
int (*CG_PermanentUpdateTreadMark)(treadMark_t* treadMark, float alpha, float minSegment, float maxSegment, float maxOffset, float texScale);
void (*CG_ProcessInitCommands)(dtiki_t* tiki, refEntity_t* ent);
void (*CG_EndTiki)(dtiki_t* tiki);
const char* (*CG_GetColumnName)(int columnNum, int* columnWidth);
void (*CG_GetScoreBoardColor)(float* red, float* green, float* blue, float* alpha);
void (*CG_GetScoreBoardFontColor)(float* red, float* green, float* blue, float* alpha);
int (*CG_GetScoreBoardDrawHeader)();
void (*CG_GetScoreBoardPosition)(float* x, float* y, float* width, float* height);
int (*CG_WeaponCommandButtonBits)();
int (*CG_CheckCaptureKey)(int key, qboolean down, unsigned int time);
typedef struct {
void (*CG_Init)(clientGameImport_t *imported, int serverMessageNum, int serverCommandSequence, int clientNum);
void (*CG_Shutdown)(void);
void (*CG_DrawActiveFrame)(int serverTime, int frameTime, stereoFrame_t stereoView, qboolean demoPlayback);
qboolean (*CG_ConsoleCommand)(void);
void (*CG_GetRendererConfig)(void);
void (*CG_Draw2D)(void);
void (*CG_EyePosition)(vec3_t *eyePos);
void (*CG_EyeOffset)(vec3_t *eyeOffset);
void (*CG_EyeAngles)(vec3_t *eyeAngles);
float (*CG_SensitivityScale)();
void (*CG_ParseCGMessage)();
void (*CG_RefreshHudDrawElements)();
void (*CG_HudDrawShader)(int info);
void (*CG_HudDrawFont)(int info);
int (*CG_GetParent)(int entNum);
float (*CG_GetObjectiveAlpha)();
int (*CG_PermanentMark)(
const vec3_t origin,
const vec3_t dir,
float orientation,
float sScale,
float tScale,
float red,
float green,
float blue,
float alpha,
qboolean doLighting,
float sCenter,
float tCenter,
markFragment_t *markFragments,
void *polyVerts
);
int (*CG_PermanentTreadMarkDecal)(
treadMark_t *treadMark,
qboolean startSegment,
qboolean doLighting,
markFragment_t *markFragments,
void *polyVerts
);
int (*CG_PermanentUpdateTreadMark)(
treadMark_t *treadMark, float alpha, float minSegment, float maxSegment, float maxOffset, float texScale
);
void (*CG_ProcessInitCommands)(dtiki_t *tiki, refEntity_t *ent);
void (*CG_EndTiki)(dtiki_t *tiki);
const char *(*CG_GetColumnName)(int columnNum, int *columnWidth);
void (*CG_GetScoreBoardColor)(float *red, float *green, float *blue, float *alpha);
void (*CG_GetScoreBoardFontColor)(float *red, float *green, float *blue, float *alpha);
int (*CG_GetScoreBoardDrawHeader)();
void (*CG_GetScoreBoardPosition)(float *x, float *y, float *width, float *height);
int (*CG_WeaponCommandButtonBits)();
int (*CG_CheckCaptureKey)(int key, qboolean down, unsigned int time);
// FIXME
//prof_cgame_t* profStruct;
// FIXME
//prof_cgame_t* profStruct;
qboolean (*CG_Command_ProcessFile)(const char* name, qboolean quiet, dtiki_t* curTiki);
qboolean (*CG_Command_ProcessFile)(const char *name, qboolean quiet, dtiki_t *curTiki);
} clientGameExport_t;
} clientGameExport_t;
#ifdef CGAME_DLL
#ifdef WIN32
__declspec(dllexport)
#else
__attribute__((visibility("default")))
# ifdef WIN32
__declspec(dllexport)
# else
__attribute__((visibility("default")))
# endif
#endif
#endif
clientGameExport_t* GetCGameAPI(void);
clientGameExport_t *GetCGameAPI(void);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load diff

View file

@ -25,11 +25,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_local.h"
static const char* IsWeaponAllowed(int dmFlags, int flags) {
static const char *IsWeaponAllowed(int dmFlags, int flags)
{
return (dmFlags & flags) ? "0" : "1";
}
static qboolean QueryLandminesAllowed2(const char* mapname, int dmflags) {
static qboolean QueryLandminesAllowed2(const char *mapname, int dmflags)
{
if (dmflags & DF_WEAPON_NO_LANDMINE) {
return qfalse;
}
@ -38,43 +40,61 @@ static qboolean QueryLandminesAllowed2(const char* mapname, int dmflags) {
return qtrue;
}
if (!Q_stricmpn(mapname, "obj/obj_", 8u))
return qfalse;
if (!Q_stricmpn(mapname, "dm/mohdm", 8u))
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Bahnhof_DM"))
return qfalse;
if (!Q_stricmp(mapname, "obj/MP_Ardennes_TOW"))
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Bazaar_DM"))
return qfalse;
if (!Q_stricmp(mapname, "obj/MP_Berlin_TOW"))
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Brest_DM"))
return qfalse;
if (!Q_stricmp(mapname, "obj/MP_Druckkammern_TOW"))
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Gewitter_DM"))
return qfalse;
if (!Q_stricmp(mapname, "obj/MP_Flughafen_TOW"))
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Holland_DM"))
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Malta_DM"))
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Stadt_DM"))
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Unterseite_DM"))
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Verschneit_DM"))
if (!Q_stricmpn(mapname, "obj/obj_", 8u)) {
return qfalse;
if (!Q_stricmp(mapname, "lib/mp_ship_lib"))
}
if (!Q_stricmpn(mapname, "dm/mohdm", 8u)) {
return qfalse;
if (!Q_stricmp(mapname, "DM/MP_Verschneit_DM"))
}
if (!Q_stricmp(mapname, "DM/MP_Bahnhof_DM")) {
return qfalse;
if (!Q_stricmp(mapname, "lib/mp_ship_lib"))
}
if (!Q_stricmp(mapname, "obj/MP_Ardennes_TOW")) {
return qfalse;
return qtrue;
}
if (!Q_stricmp(mapname, "DM/MP_Bazaar_DM")) {
return qfalse;
}
if (!Q_stricmp(mapname, "obj/MP_Berlin_TOW")) {
return qfalse;
}
if (!Q_stricmp(mapname, "DM/MP_Brest_DM")) {
return qfalse;
}
if (!Q_stricmp(mapname, "obj/MP_Druckkammern_TOW")) {
return qfalse;
}
if (!Q_stricmp(mapname, "DM/MP_Gewitter_DM")) {
return qfalse;
}
if (!Q_stricmp(mapname, "obj/MP_Flughafen_TOW")) {
return qfalse;
}
if (!Q_stricmp(mapname, "DM/MP_Holland_DM")) {
return qfalse;
}
if (!Q_stricmp(mapname, "DM/MP_Malta_DM")) {
return qfalse;
}
if (!Q_stricmp(mapname, "DM/MP_Stadt_DM")) {
return qfalse;
}
if (!Q_stricmp(mapname, "DM/MP_Unterseite_DM")) {
return qfalse;
}
if (!Q_stricmp(mapname, "DM/MP_Verschneit_DM")) {
return qfalse;
}
if (!Q_stricmp(mapname, "lib/mp_ship_lib")) {
return qfalse;
}
if (!Q_stricmp(mapname, "DM/MP_Verschneit_DM")) {
return qfalse;
}
if (!Q_stricmp(mapname, "lib/mp_ship_lib")) {
return qfalse;
}
return qtrue;
}
/*
@ -87,25 +107,25 @@ and whenever the server updates any serverinfo flagged cvars
*/
void CG_ParseServerinfo(void)
{
const char* info;
const char* mapname;
char map[MAX_QPATH];
char* spawnpos;
const char* version;
const char *info;
const char *mapname;
char map[MAX_QPATH];
char *spawnpos;
const char *version;
info = CG_ConfigString(CS_SERVERINFO);
cgs.gametype = atoi(Info_ValueForKey(info, "g_gametype"));
cgs.dmflags = atoi(Info_ValueForKey(info, "dmflags"));
cgs.teamflags = atoi(Info_ValueForKey(info, "teamflags"));
cgs.fraglimit = atoi(Info_ValueForKey(info, "fraglimit"));
cgs.timelimit = atoi(Info_ValueForKey(info, "timelimit"));
info = CG_ConfigString(CS_SERVERINFO);
cgs.gametype = atoi(Info_ValueForKey(info, "g_gametype"));
cgs.dmflags = atoi(Info_ValueForKey(info, "dmflags"));
cgs.teamflags = atoi(Info_ValueForKey(info, "teamflags"));
cgs.fraglimit = atoi(Info_ValueForKey(info, "fraglimit"));
cgs.timelimit = atoi(Info_ValueForKey(info, "timelimit"));
cgs.maxclients = atoi(Info_ValueForKey(info, "sv_maxclients"));
version = Info_ValueForKey(info, "version");
if (strstr(version, "Spearhead")) {
cgi.Cvar_Set("g_servertype", "1");
} else {
cgi.Cvar_Set("g_servertype", "2");
cgi.Cvar_Set("g_servertype", "2");
}
cgi.Cvar_Set("cg_gametype", Info_ValueForKey(info, "g_gametype"));
@ -142,22 +162,16 @@ void CG_ParseServerinfo(void)
Com_sprintf(cgs.mapname, sizeof(cgs.mapname), "maps/%s.bsp", map);
// hide/show huds
if (cgs.gametype)
{
if (cgs.gametype) {
cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_timelimit\n");
if (cgs.fraglimit)
{
if (cgs.fraglimit) {
cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_fraglimit\n");
cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_score\n");
}
else
{
} else {
cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_score\n");
cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_fraglimit\n");
}
}
else
{
} else {
cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_timelimit\n");
cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_fraglimit\n");
cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_score\n");
@ -256,7 +270,7 @@ Cmd_Argc() / Cmd_Argv()
*/
static void CG_ServerCommand(void)
{
const char* cmd;
const char *cmd;
cmd = cgi.Argv(0);
@ -276,52 +290,47 @@ static void CG_ServerCommand(void)
CG_HudPrint_f();
}
return;
}
else if (!strcmp(cmd, "printdeathmsg")) {
const char* s1, * s2, * s3, * s4, * s5;
const char* result1, * result2;
int hudColor;
} else if (!strcmp(cmd, "printdeathmsg")) {
const char *s1, *s2, *s3, *s4, *s5;
const char *result1, *result2;
int hudColor;
result1 = NULL;
result2 = NULL;
s1 = cgi.Argv(1);
s2 = cgi.Argv(2);
s3 = cgi.Argv(3);
s4 = cgi.Argv(4);
s5 = cgi.Argv(5);
result1 = NULL;
result2 = NULL;
s1 = cgi.Argv(1);
s2 = cgi.Argv(2);
s3 = cgi.Argv(3);
s4 = cgi.Argv(4);
s5 = cgi.Argv(5);
if (*s5 == tolower(*s5)) {
hudColor = 4;
} else {
hudColor = 5;
hudColor = 5;
}
if (*s1 != 'x')
result1 = cgi.LV_ConvertString(s1);
if (*s2 != 'x')
result2 = cgi.LV_ConvertString(s2);
if (tolower(*s5) == 's')
{
cgi.Printf("%c%s %s\n", hudColor, s4, result1);
}
else if (tolower(*s5) == 'p')
{
if (*s2 == 'x')
cgi.Printf("%c%s %s %s\n", hudColor, s4, result1, s3);
else
cgi.Printf("%c%s %s %s%s\n", hudColor, s4, result1, s3, result2);
}
else if (tolower(*s5) == 'w')
{
cgi.Printf("%c%s %s\n", hudColor, s4, result1);
}
else
{
cgi.Printf("%s", cgi.Argv(1));
}
if (*s1 != 'x') {
result1 = cgi.LV_ConvertString(s1);
}
if (*s2 != 'x') {
result2 = cgi.LV_ConvertString(s2);
}
if (tolower(*s5) == 's') {
cgi.Printf("%c%s %s\n", hudColor, s4, result1);
} else if (tolower(*s5) == 'p') {
if (*s2 == 'x') {
cgi.Printf("%c%s %s %s\n", hudColor, s4, result1, s3);
} else {
cgi.Printf("%c%s %s %s%s\n", hudColor, s4, result1, s3, result2);
}
} else if (tolower(*s5) == 'w') {
cgi.Printf("%c%s %s\n", hudColor, s4, result1);
} else {
cgi.Printf("%s", cgi.Argv(1));
}
return;
}
if (!strcmp(cmd, "stufftext")) {
cgi.Cmd_Stuff(cgi.Argv(1));
cgi.Cmd_Stuff("\n");

View file

@ -32,10 +32,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
CG_ResetEntity
==================
*/
static void CG_ResetEntity(centity_t* cent)
static void CG_ResetEntity(centity_t *cent)
{
dtiki_t* tiki;
int i;
dtiki_t *tiki;
int i;
VectorCopy(cent->currentState.origin, cent->lerpOrigin);
@ -62,7 +62,7 @@ static void CG_ResetEntity(centity_t* cent)
// Reset splash info
cent->splash_last_spawn_time = 0;
cent->splash_still_count = -1;
cent->splash_still_count = -1;
tiki = cgi.R_Model_GetHandle(cgs.model_draw[cent->currentState.modelindex]);
// reset client command
@ -71,7 +71,7 @@ static void CG_ResetEntity(centity_t* cent)
// reset the animation for the entities
if (tiki && tiki->a->bIsCharacter) {
for (i = 0; i < MAX_FRAMEINFOS; i++) {
cent->animLast[i] = cent->currentState.frameInfo[i].index;
cent->animLast[i] = cent->currentState.frameInfo[i].index;
cent->animLastTimes[i] = cent->currentState.frameInfo[i].time;
if (cent->currentState.frameInfo[i].weight) {
cent->animLastWeight |= 1 << i;
@ -89,8 +89,8 @@ static void CG_ResetEntity(centity_t* cent)
cent->animLastWeight = 0;
}
cent->usageIndexLast = 0;
cent->bFootOnGround_Left = qtrue;
cent->usageIndexLast = 0;
cent->bFootOnGround_Left = qtrue;
cent->bFootOnGround_Right = qtrue;
if (cent->currentState.eType == ET_PLAYER) {
@ -105,7 +105,7 @@ CG_TransitionEntity
cent->nextState is moved to cent->currentState and events are fired
===============
*/
static void CG_TransitionEntity(centity_t* cent)
static void CG_TransitionEntity(centity_t *cent)
{
cent->currentState = cent->nextState;
cent->currentValid = qtrue;
@ -134,11 +134,11 @@ on tourney restarts. All other times will use
CG_TransitionSnapshot instead.
==================
*/
void CG_SetInitialSnapshot(snapshot_t* snap)
void CG_SetInitialSnapshot(snapshot_t *snap)
{
int i;
centity_t* cent;
entityState_t* state;
int i;
centity_t *cent;
entityState_t *state;
cg.snap = snap;
@ -149,19 +149,17 @@ void CG_SetInitialSnapshot(snapshot_t* snap)
for (i = 0; i < cg.snap->numEntities; i++) {
state = &cg.snap->entities[i];
cent = &cg_entities[state->number];
cent = &cg_entities[state->number];
cent->currentState = *state;
cent->interpolate = qfalse;
cent->interpolate = qfalse;
cent->currentValid = qtrue;
CG_ResetEntity(cent);
}
cgi.MUSIC_UpdateMood(snap->ps.current_music_mood,
snap->ps.fallback_music_mood);
cgi.MUSIC_UpdateVolume(snap->ps.music_volume,
snap->ps.music_volume_fade_time);
cgi.MUSIC_UpdateMood(snap->ps.current_music_mood, snap->ps.fallback_music_mood);
cgi.MUSIC_UpdateVolume(snap->ps.music_volume, snap->ps.music_volume_fade_time);
cgi.S_SetReverb(snap->ps.reverb_type, snap->ps.reverb_level);
}
@ -174,9 +172,9 @@ The transition point from snap to nextSnap has passed
*/
static void CG_TransitionSnapshot(qboolean differentServer)
{
centity_t* cent;
snapshot_t* oldFrame;
int i;
centity_t *cent;
snapshot_t *oldFrame;
int i;
if (differentServer) {
CG_ServerRestarted();
@ -187,13 +185,13 @@ static void CG_TransitionSnapshot(qboolean differentServer)
// clear the currentValid flag for all entities in the existing snapshot
for (i = 0; i < cg.snap->numEntities; i++) {
cent = &cg_entities[cg.snap->entities[i].number];
cent = &cg_entities[cg.snap->entities[i].number];
cent->currentValid = qfalse;
}
// move nextSnap to snap and do the transitions
oldFrame = cg.snap;
cg.snap = cg.nextSnap;
cg.snap = cg.nextSnap;
// FAKK: Commented out to make our stuff work
// cg_entities[ cg.snap->ps.clientNum ].interpolate = qfalse;
@ -202,7 +200,7 @@ static void CG_TransitionSnapshot(qboolean differentServer)
cent = &cg_entities[cg.snap->entities[i].number];
if (differentServer) {
cent->interpolate = qfalse;
cent->teleported = qfalse;
cent->teleported = qfalse;
}
CG_TransitionEntity(cent);
}
@ -220,28 +218,25 @@ static void CG_TransitionSnapshot(qboolean differentServer)
playerState_t *ops, *ps;
ops = &oldFrame->ps;
ps = &cg.snap->ps;
ps = &cg.snap->ps;
// teleporting checks are irrespective of prediction
if (ps->pm_flags & PMF_RESPAWNED) {
cg.thisFrameTeleport = qtrue;
}
if ((ops->music_volume != ps->music_volume) ||
(ops->music_volume_fade_time != ps->music_volume_fade_time)) {
cgi.MUSIC_UpdateVolume(ps->music_volume,
ps->music_volume_fade_time);
if ((ops->music_volume != ps->music_volume) || (ops->music_volume_fade_time != ps->music_volume_fade_time)) {
cgi.MUSIC_UpdateVolume(ps->music_volume, ps->music_volume_fade_time);
}
if ((ops->reverb_type != ps->reverb_type) ||
(ops->reverb_level != ps->reverb_level)) {
if ((ops->reverb_type != ps->reverb_type) || (ops->reverb_level != ps->reverb_level)) {
cgi.S_SetReverb(ps->reverb_type, ps->reverb_level);
}
// if we are not doing client side movement prediction for any
// reason, then the client events and view changes will be issued now
if (cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_NO_PREDICTION) ||
cg_nopredict->integer || cg_synchronousClients->integer) {
if (cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_NO_PREDICTION) || cg_nopredict->integer
|| cg_synchronousClients->integer) {
CG_TransitionPlayerState(ps, ops);
}
}
@ -254,11 +249,11 @@ CG_SetNextSnap
A new snapshot has just been read in from the client system.
===================
*/
static void CG_SetNextSnap(snapshot_t* snap)
static void CG_SetNextSnap(snapshot_t *snap)
{
int num;
entityState_t* es;
centity_t* cent;
int num;
entityState_t *es;
centity_t *cent;
cg.nextSnap = snap;
@ -266,17 +261,15 @@ static void CG_SetNextSnap(snapshot_t* snap)
// check for extrapolation errors
for (num = 0; num < snap->numEntities; num++) {
es = &snap->entities[num];
es = &snap->entities[num];
cent = &cg_entities[es->number];
cent->nextState = *es;
// if this frame is a teleport, or the entity wasn't in the
// previous frame, don't interpolate
if (!cent->currentValid ||
((cent->currentState.eFlags ^ es->eFlags) & EF_TELEPORT_BIT) ||
(cent->currentState.parent != es->parent) ||
(cent->currentState.modelindex != es->modelindex)) {
if (!cent->currentValid || ((cent->currentState.eFlags ^ es->eFlags) & EF_TELEPORT_BIT)
|| (cent->currentState.parent != es->parent) || (cent->currentState.modelindex != es->modelindex)) {
cent->interpolate = qfalse;
// if this isn't the first frame and we have valid data, set the
// teleport flag
@ -302,8 +295,7 @@ static void CG_SetNextSnap(snapshot_t* snap)
}
// if the camera cut bit changed, than the next frame is a camera cut
if ((cg.nextSnap->ps.camera_flags & CF_CAMERA_CUT_BIT) !=
(cg.snap->ps.camera_flags & CF_CAMERA_CUT_BIT)) {
if ((cg.nextSnap->ps.camera_flags & CF_CAMERA_CUT_BIT) != (cg.snap->ps.camera_flags & CF_CAMERA_CUT_BIT)) {
cg.nextFrameCameraCut = qtrue;
} else {
cg.nextFrameCameraCut = qfalse;
@ -329,14 +321,15 @@ times if the client system fails to return a
valid snapshot.
========================
*/
static snapshot_t* CG_ReadNextSnapshot(void)
static snapshot_t *CG_ReadNextSnapshot(void)
{
qboolean r;
snapshot_t* dest;
qboolean r;
snapshot_t *dest;
if (cg.latestSnapshotNum > cgs.processedSnapshotNum + 1000) {
cgi.Error(ERR_DROP, "CG_ReadNextSnapshot: way out of range, %i > %i",
cg.latestSnapshotNum, cgs.processedSnapshotNum);
cgi.Error(
ERR_DROP, "CG_ReadNextSnapshot: way out of range, %i > %i", cg.latestSnapshotNum, cgs.processedSnapshotNum
);
}
while (cgs.processedSnapshotNum < cg.latestSnapshotNum) {
@ -394,17 +387,16 @@ of an interpolating one)
*/
void CG_ProcessSnapshots(void)
{
snapshot_t* snap;
int n;
qboolean differentServer;
snapshot_t *snap;
int n;
qboolean differentServer;
// see what the latest snapshot the client system has is
cgi.GetCurrentSnapshotNumber(&n, &cg.latestSnapshotTime);
if (n != cg.latestSnapshotNum) {
if (n < cg.latestSnapshotNum) {
// this should never happen
cgi.Error(ERR_DROP,
"CG_ProcessSnapshots: n < cg.latestSnapshotNum");
cgi.Error(ERR_DROP, "CG_ProcessSnapshots: n < cg.latestSnapshotNum");
}
cg.latestSnapshotNum = n;
}
@ -445,11 +437,8 @@ void CG_ProcessSnapshots(void)
// if time went backwards, we have a level restart
if (cg.nextSnap->serverTime < cg.snap->serverTime) {
// only drop if this is not a restart or loadgame
if (!((cg.nextSnap->snapFlags ^ cg.snap->snapFlags) &
SNAPFLAG_SERVERCOUNT)) {
cgi.Error(
ERR_DROP,
"CG_ProcessSnapshots: Server time went backwards");
if (!((cg.nextSnap->snapFlags ^ cg.snap->snapFlags) & SNAPFLAG_SERVERCOUNT)) {
cgi.Error(ERR_DROP, "CG_ProcessSnapshots: Server time went backwards");
}
}
}
@ -457,9 +446,7 @@ void CG_ProcessSnapshots(void)
differentServer = cg.snap->serverTime <= cgi.GetServerStartTime();
// if our time is < nextFrame's, we have a nice interpolating state
if (cg.time >= cg.snap->serverTime &&
cg.time < cg.nextSnap->serverTime &&
!differentServer) {
if (cg.time >= cg.snap->serverTime && cg.time < cg.nextSnap->serverTime && !differentServer) {
break;
}
@ -477,7 +464,6 @@ void CG_ProcessSnapshots(void)
cgi.SetTime(cg.time);
}
if (cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time) {
cgi.Error(ERR_DROP,
"CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time");
cgi.Error(ERR_DROP, "CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time");
}
}

View file

@ -25,15 +25,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_local.h"
void CG_ProcessSound( server_sound_t *sound )
{
if ( sound->stop_flag )
{
cgi.S_StopSound( sound->entity_number, sound->channel );
}
else
{
cgi.S_StartSound( sound->origin, sound->entity_number, sound->channel, cgs.sound_precache[sound->sound_index],
sound->volume, sound->min_dist, sound->pitch, sound->maxDist, sound->streamed );
}
}
void CG_ProcessSound(server_sound_t *sound)
{
if (sound->stop_flag) {
cgi.S_StopSound(sound->entity_number, sound->channel);
} else {
cgi.S_StartSound(
sound->origin,
sound->entity_number,
sound->channel,
cgs.sound_precache[sound->sound_index],
sound->volume,
sound->min_dist,
sound->pitch,
sound->maxDist,
sound->streamed
);
}
}

File diff suppressed because it is too large Load diff

View file

@ -31,10 +31,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define MAX_SPECIAL_EFFECT_COMMANDS 32
class specialeffectcommand_t : public Class {
class specialeffectcommand_t : public Class
{
public:
spawnthing_t* emitter;
float fCommandTime;
spawnthing_t *emitter;
float fCommandTime;
void (*endfcn)();
Event *pEvent;
@ -45,39 +46,40 @@ public:
class specialeffect_t : public Class
{
public:
int m_iCommandCount;
specialeffectcommand_t* m_commands[MAX_SPECIAL_EFFECT_COMMANDS];
int m_iCommandCount;
specialeffectcommand_t *m_commands[MAX_SPECIAL_EFFECT_COMMANDS];
public:
specialeffect_t();
specialeffectcommand_t* AddNewCommand();
specialeffectcommand_t *AddNewCommand();
};
#define MAX_SPECIAL_EFFECTS 99
#define SPECIAL_EFFECT_TEST MAX_SPECIAL_EFFECTS - 1
class ClientSpecialEffectsManager : public Listener {
class ClientSpecialEffectsManager : public Listener
{
specialeffect_t m_effects[99];
qboolean m_bEffectsLoaded;
int m_iNumPendingEvents;
qboolean m_bEffectsLoaded;
int m_iNumPendingEvents;
public:
CLASS_PROTOTYPE(ClientSpecialEffectsManager);
private:
void ContinueEffectExecution(Event* ev);
void ContinueEffectExecution(Event *ev);
void ExecuteEffect(int iEffect, int iStartCommand, Vector vPos, Vector vAngles, float axis[3][3]);
public:
ClientSpecialEffectsManager();
void LoadEffects();
qboolean EffectsPending();
void MakeEffect_Normal(int iEffect, Vector vPos, Vector vNormal);
void MakeEffect_Angles(int iEffect, Vector vPos, Vector vAngles);
void MakeEffect_Axis(int iEffect, Vector vPos, float axis[3][3]);
specialeffect_t* GetTestEffectPointer();
void LoadEffects();
qboolean EffectsPending();
void MakeEffect_Normal(int iEffect, Vector vPos, Vector vNormal);
void MakeEffect_Angles(int iEffect, Vector vPos, Vector vAngles);
void MakeEffect_Axis(int iEffect, Vector vPos, float axis[3][3]);
specialeffect_t *GetTestEffectPointer();
};
extern ClientSpecialEffectsManager sfxManager;

View file

@ -25,256 +25,228 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_commands.h"
swipething_t m_swipes[MAX_SWIPES];
extern int current_entity_number;
swipething_t m_swipes[MAX_SWIPES];
extern int current_entity_number;
extern refEntity_t *current_entity;
extern dtiki_t* current_tiki;
extern centity_t *current_centity;
extern dtiki_t *current_tiki;
extern centity_t *current_centity;
void ClientGameCommandManager::SwipeOn
(
Event *ev
)
void ClientGameCommandManager::SwipeOn(Event *ev)
{
// Make a swipe for this if available
int i;
int freeswipe = -1;
str tagname_start,tagname_end;
qhandle_t shader;
{
// Make a swipe for this if available
int i;
int freeswipe = -1;
str tagname_start, tagname_end;
qhandle_t shader;
if ( ev->NumArgs () != 4 )
return;
if (ev->NumArgs() != 4) {
return;
}
shader = cgi.R_RegisterShader( ev->GetString( 1 ) );
tagname_start = ev->GetString( 2 );
tagname_end = ev->GetString( 3 );
for ( i=0; i < MAX_SWIPES; i++ )
{
swipething_t &swipe = m_swipes[i];
shader = cgi.R_RegisterShader(ev->GetString(1));
tagname_start = ev->GetString(2);
tagname_end = ev->GetString(3);
if ( !swipe.enabled ||
(
( swipe.entitynum == current_entity_number ) &&
( tagname_start == swipe.tagname_start ) &&
( tagname_end == swipe.tagname_end ) &&
( shader == swipe.shader )
)
)
{
freeswipe = i;
break;
}
}
for (i = 0; i < MAX_SWIPES; i++) {
swipething_t& swipe = m_swipes[i];
if ( freeswipe == -1 )
return;
if (!swipe.enabled
|| ((swipe.entitynum == current_entity_number) && (tagname_start == swipe.tagname_start)
&& (tagname_end == swipe.tagname_end) && (shader == swipe.shader))) {
freeswipe = i;
break;
}
}
swipething_t &swipe = m_swipes[freeswipe];
if (freeswipe == -1) {
return;
}
if ( !swipe.enabled )
{
swipe.Init ();
swipe.enabled = qtrue;
swipe.entitynum = current_entity_number;
}
swipething_t& swipe = m_swipes[freeswipe];
swipe.shader = cgi.R_RegisterShader( ev->GetString( 1 ) );
swipe.tagname_start = ev->GetString ( 2 );
swipe.tagname_end = ev->GetString ( 3 );
swipe.life = ev->GetFloat ( 4 ) * 1000.f;
if (!swipe.enabled) {
swipe.Init();
swipe.enabled = qtrue;
swipe.entitynum = current_entity_number;
}
if ( current_centity )
current_centity->clientFlags |= CF_UPDATESWIPE;
}
swipe.shader = cgi.R_RegisterShader(ev->GetString(1));
swipe.tagname_start = ev->GetString(2);
swipe.tagname_end = ev->GetString(3);
swipe.life = ev->GetFloat(4) * 1000.f;
void ClientGameCommandManager::SwipeOff
(
Event *ev
)
if (current_centity) {
current_centity->clientFlags |= CF_UPDATESWIPE;
}
}
{
qboolean was_enabled;
int i;
void ClientGameCommandManager::SwipeOff(Event *ev)
was_enabled = qfalse;
for ( i=0; i < MAX_SWIPES; i++ )
{
swipething_t &swipe = m_swipes[i];
{
qboolean was_enabled;
int i;
if ( swipe.enabled && swipe.entitynum == current_entity_number )
{
swipe.enabled = qfalse;
was_enabled = qtrue;
}
}
was_enabled = qfalse;
for (i = 0; i < MAX_SWIPES; i++) {
swipething_t& swipe = m_swipes[i];
if ( was_enabled )
{
//cgi.R_SwipeBegin ( 0.f, 0.f, -1 );
//cgi.R_SwipeEnd ();
if (swipe.enabled && swipe.entitynum == current_entity_number) {
swipe.enabled = qfalse;
was_enabled = qtrue;
}
}
if ( current_centity )
current_centity->clientFlags &= ~CF_UPDATESWIPE;
}
}
if (was_enabled) {
//cgi.R_SwipeBegin ( 0.f, 0.f, -1 );
//cgi.R_SwipeEnd ();
void ClientGameCommandManager::Swipe
(
Event *ev
)
if (current_centity) {
current_centity->clientFlags &= ~CF_UPDATESWIPE;
}
}
}
{
// This does a swipe effect on the entity
int i,swipenum;
orientation_t _or;
int tagnum_start,tagnum_end;
qboolean add_cnt_point = qfalse;
vec3_t tmp;
void ClientGameCommandManager::Swipe(Event *ev)
assert(current_entity);
assert(current_tiki);
{
// This does a swipe effect on the entity
int i, swipenum;
orientation_t _or;
int tagnum_start, tagnum_end;
qboolean add_cnt_point = qfalse;
vec3_t tmp;
if (!current_entity || !current_tiki)
{
return;
}
assert(current_entity);
assert(current_tiki);
// Let's find us a new (or current) swipe
for ( swipenum=0; swipenum < MAX_SWIPES; swipenum++ )
{
swipething_t &swipe = m_swipes[swipenum];
if (!current_entity || !current_tiki) {
return;
}
if ( swipe.enabled && swipe.entitynum == current_entity_number )
{
while ( swipe.num_live_swipes > 1 )
{
i = ( swipe.first_swipe + 1 ) % MAX_SWIPE_POINTS;
swipepoint_t &swipepoint = swipe.swipepoints[i];
// Let's find us a new (or current) swipe
for (swipenum = 0; swipenum < MAX_SWIPES; swipenum++) {
swipething_t& swipe = m_swipes[swipenum];
if ( swipepoint.time < cg.time - swipe.life )
{
// then let's delete the previous
swipe.first_swipe = ( swipe.first_swipe + 1 ) % MAX_SWIPE_POINTS;
swipe.num_live_swipes--;
}
else
{
break;
}
if (swipe.enabled && swipe.entitynum == current_entity_number) {
while (swipe.num_live_swipes > 1) {
i = (swipe.first_swipe + 1) % MAX_SWIPE_POINTS;
swipepoint_t& swipepoint = swipe.swipepoints[i];
if (swipepoint.time < cg.time - swipe.life) {
// then let's delete the previous
swipe.first_swipe = (swipe.first_swipe + 1) % MAX_SWIPE_POINTS;
swipe.num_live_swipes--;
} else {
break;
}
}
if ( swipe.num_live_swipes == 1 )
{
swipepoint_t &swipepoint = swipe.swipepoints[swipe.first_swipe];
if ( swipepoint.time < cg.time - swipe.life )
{
swipe.num_live_swipes = 0;
}
if (swipe.num_live_swipes == 1) {
swipepoint_t& swipepoint = swipe.swipepoints[swipe.first_swipe];
if (swipepoint.time < cg.time - swipe.life) {
swipe.num_live_swipes = 0;
}
}
swipe.cntPoint.time = cg.time;
VectorCopy ( current_entity->origin, swipe.cntPoint.points[0] );
swipe.cntPoint.time = cg.time;
VectorCopy(current_entity->origin, swipe.cntPoint.points[0]);
tagnum_start = cgi.Tag_NumForName( current_tiki, swipe.tagname_start.c_str() );
_or = cgi.TIKI_Orientation(current_entity, tagnum_start);
tagnum_start = cgi.Tag_NumForName(current_tiki, swipe.tagname_start.c_str());
_or = cgi.TIKI_Orientation(current_entity, tagnum_start);
// Clear out the points
VectorClear ( tmp );
VectorClear ( swipe.cntPoint.points[0] );
VectorClear ( swipe.cntPoint.points[1] );
// Clear out the points
VectorClear(tmp);
VectorClear(swipe.cntPoint.points[0]);
VectorClear(swipe.cntPoint.points[1]);
if ( ev->NumArgs() > 0 )
VectorCopy( ev->GetVector( 1 ), tmp );
else
VectorCopy ( current_entity->origin, tmp );
// Transform the origin of the tag by the axis of the entity and add it to the origin of the entity
for ( i = 0; i < 3; i++ )
{
VectorMA ( tmp, _or.origin[i], current_entity->axis[i], tmp );
if (ev->NumArgs() > 0) {
VectorCopy(ev->GetVector(1), tmp);
} else {
VectorCopy(current_entity->origin, tmp);
}
// Copy tmp into the startpoint
VectorCopy ( tmp, swipe.cntPoint.points[0] );
tagnum_end = cgi.Tag_NumForName( current_tiki, swipe.tagname_end.c_str() );
_or = cgi.TIKI_Orientation(current_entity, tagnum_end);
if ( ev->NumArgs() > 0 )
VectorCopy( ev->GetVector( 1 ), tmp );
else
VectorCopy ( current_entity->origin, tmp );
// Transform the origin of the tag by the axis of the entity and add it to the origin of the entity
for ( i = 0; i < 3; i++ )
{
VectorMA ( tmp, _or.origin[i], current_entity->axis[i], tmp );
// Transform the origin of the tag by the axis of the entity and add it to the origin of the entity
for (i = 0; i < 3; i++) {
VectorMA(tmp, _or.origin[i], current_entity->axis[i], tmp);
}
// Copy tmp into the startpoint
VectorCopy ( tmp, swipe.cntPoint.points[1] );
// Copy tmp into the startpoint
VectorCopy(tmp, swipe.cntPoint.points[0]);
if ( swipe.num_live_swipes == 0 )
add_cnt_point = qtrue;
else
{
float deltime = swipe.life / float ( MAX_SWIPES );
swipepoint_t &lastpoint = swipe.swipepoints[ ( swipe.first_swipe + swipe.num_live_swipes - 1 ) % MAX_SWIPE_POINTS];
tagnum_end = cgi.Tag_NumForName(current_tiki, swipe.tagname_end.c_str());
_or = cgi.TIKI_Orientation(current_entity, tagnum_end);
if ( swipe.cntPoint.time - lastpoint.time >= deltime )
add_cnt_point = qtrue;
if (ev->NumArgs() > 0) {
VectorCopy(ev->GetVector(1), tmp);
} else {
VectorCopy(current_entity->origin, tmp);
}
cgi.R_SwipeBegin ( cg.time, swipe.life, swipe.shader );
if ( add_cnt_point )
{
swipepoint_t &swipepoint = swipe.swipepoints[ ( swipe.first_swipe + swipe.num_live_swipes ) % MAX_SWIPE_POINTS];
swipepoint = swipe.cntPoint;
if ( swipe.num_live_swipes == MAX_SWIPE_POINTS )
swipe.first_swipe = ( swipe.first_swipe + 1 ) % MAX_SWIPE_POINTS;
else
swipe.num_live_swipes++;
// Transform the origin of the tag by the axis of the entity and add it to the origin of the entity
for (i = 0; i < 3; i++) {
VectorMA(tmp, _or.origin[i], current_entity->axis[i], tmp);
}
for ( i = 0; i != swipe.num_live_swipes; i++ )
{
swipepoint_t &swipepoint = swipe.swipepoints[ ( swipe.first_swipe + i ) % MAX_SWIPE_POINTS];
// Copy tmp into the startpoint
VectorCopy(tmp, swipe.cntPoint.points[1]);
cgi.R_SwipePoint ( swipepoint.points[0], swipepoint.points[1], swipepoint.time );
if (swipe.num_live_swipes == 0) {
add_cnt_point = qtrue;
} else {
float deltime = swipe.life / float(MAX_SWIPES);
swipepoint_t& lastpoint =
swipe.swipepoints[(swipe.first_swipe + swipe.num_live_swipes - 1) % MAX_SWIPE_POINTS];
if (swipe.cntPoint.time - lastpoint.time >= deltime) {
add_cnt_point = qtrue;
}
}
if ( !add_cnt_point )
cgi.R_SwipePoint ( swipe.cntPoint.points[0], swipe.cntPoint.points[1], swipe.cntPoint.time );
cgi.R_SwipeBegin(cg.time, swipe.life, swipe.shader);
cgi.R_SwipeEnd ();
}
}
}
if (add_cnt_point) {
swipepoint_t& swipepoint =
swipe.swipepoints[(swipe.first_swipe + swipe.num_live_swipes) % MAX_SWIPE_POINTS];
void ClientGameCommandManager::ClearSwipes
(
void
)
swipepoint = swipe.cntPoint;
{
int i;
if (swipe.num_live_swipes == MAX_SWIPE_POINTS) {
swipe.first_swipe = (swipe.first_swipe + 1) % MAX_SWIPE_POINTS;
} else {
swipe.num_live_swipes++;
}
}
for ( i=0; i < MAX_SWIPES; i++ )
{
swipething_t &swipe = m_swipes[i];
for (i = 0; i != swipe.num_live_swipes; i++) {
swipepoint_t& swipepoint = swipe.swipepoints[(swipe.first_swipe + i) % MAX_SWIPE_POINTS];
swipe.enabled = qfalse;
}
cgi.R_SwipePoint(swipepoint.points[0], swipepoint.points[1], swipepoint.time);
}
cgi.R_SwipeBegin ( 0.f, 0.f, -1 );
cgi.R_SwipeEnd ();
}
if (!add_cnt_point) {
cgi.R_SwipePoint(swipe.cntPoint.points[0], swipe.cntPoint.points[1], swipe.cntPoint.time);
}
cgi.R_SwipeEnd();
}
}
}
void ClientGameCommandManager::ClearSwipes(void)
{
int i;
for (i = 0; i < MAX_SWIPES; i++) {
swipething_t& swipe = m_swipes[i];
swipe.enabled = qfalse;
}
cgi.R_SwipeBegin(0.f, 0.f, -1);
cgi.R_SwipeEnd();
}
/*
===================
@ -283,7 +255,7 @@ CG_ClearSwipes
This is called at startup and for tournement restarts
===================
*/
void CG_ClearSwipes( void )
{
commandManager.ClearSwipes();
}
void CG_ClearSwipes(void)
{
commandManager.ClearSwipes();
}

File diff suppressed because it is too large Load diff

View file

@ -26,103 +26,103 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_commands.h"
#include "cg_specialfx.h"
cvar_t* cg_te_alpha;
cvar_t* cg_te_dietouch;
cvar_t* cg_te_bouncefactor;
cvar_t* cg_te_scale;
cvar_t* cg_te_scalemin;
cvar_t* cg_te_scalemax;
cvar_t* cg_te_model;
cvar_t* cg_te_life;
cvar_t* cg_te_color_r;
cvar_t* cg_te_color_g;
cvar_t* cg_te_color_b;
cvar_t* cg_te_accel_x;
cvar_t* cg_te_accel_y;
cvar_t* cg_te_accel_z;
cvar_t* cg_te_count;
cvar_t* cg_te_fade;
cvar_t* cg_te_fadedelay;
cvar_t* cg_te_fadein;
cvar_t* cg_te_spawnrate;
cvar_t* cg_te_offsbase_x;
cvar_t* cg_te_offsbase_y;
cvar_t* cg_te_offsbase_z;
cvar_t* cg_te_offsamp_x;
cvar_t* cg_te_offsamp_y;
cvar_t* cg_te_offsamp_z;
cvar_t* cg_te_scalerate;
cvar_t* cg_te_circle;
cvar_t* cg_te_sphere;
cvar_t* cg_te_insphere;
cvar_t* cg_te_radius;
cvar_t* cg_te_align;
cvar_t* cg_te_flickeralpha;
cvar_t* cg_te_collision;
cvar_t* cg_te_randomroll;
cvar_t* cg_te_anglesbase_p;
cvar_t* cg_te_anglesbase_y;
cvar_t* cg_te_anglesbase_r;
cvar_t* cg_te_anglesamp_p;
cvar_t* cg_te_anglesamp_y;
cvar_t* cg_te_anglesamp_r;
cvar_t* cg_te_forwardvel;
cvar_t* cg_te_randvelbase_x;
cvar_t* cg_te_randvelbase_y;
cvar_t* cg_te_randvelbase_z;
cvar_t* cg_te_randvelamp_x;
cvar_t* cg_te_randvelamp_y;
cvar_t* cg_te_randvelamp_z;
cvar_t* cg_te_clampvelmin_x;
cvar_t* cg_te_clampvelmax_x;
cvar_t* cg_te_clampvelmin_y;
cvar_t* cg_te_clampvelmax_y;
cvar_t* cg_te_clampvelmin_z;
cvar_t* cg_te_clampvelmax_z;
cvar_t* cg_te_clampvelaxis;
cvar_t* cg_te_volumetric;
cvar_t* cg_te_randaxis;
cvar_t* cg_te_axisoffsbase_x;
cvar_t* cg_te_axisoffsbase_y;
cvar_t* cg_te_axisoffsbase_z;
cvar_t* cg_te_axisoffsamp_x;
cvar_t* cg_te_axisoffsamp_y;
cvar_t* cg_te_axisoffsamp_z;
cvar_t* cg_te_swarm_freq;
cvar_t* cg_te_swarm_maxspeed;
cvar_t* cg_te_swarm_delta;
cvar_t* cg_te_avelbase_p;
cvar_t* cg_te_avelbase_y;
cvar_t* cg_te_avelbase_r;
cvar_t* cg_te_avelamp_p;
cvar_t* cg_te_avelamp_y;
cvar_t* cg_te_avelamp_r;
cvar_t* cg_te_radial_scale;
cvar_t* cg_te_radial_min;
cvar_t* cg_te_radial_max;
cvar_t* cg_te_friction;
cvar_t* cg_te_varycolor;
cvar_t* cg_te_spritegridlighting;
cvar_t* cg_te_cone_height;
cvar_t* cg_te_alignstretch_scale;
cvar_t* cg_te_spawnrange_a;
cvar_t* cg_te_spawnrange_b;
cvar_t* cg_te_command_time;
cvar_t* cg_te_singlelinecommand;
cvar_t* cg_te_tag;
cvar_t* cg_te_xangles;
cvar_t* cg_te_yangles;
cvar_t* cg_te_zangles;
cvar_t *cg_te_alpha;
cvar_t *cg_te_dietouch;
cvar_t *cg_te_bouncefactor;
cvar_t *cg_te_scale;
cvar_t *cg_te_scalemin;
cvar_t *cg_te_scalemax;
cvar_t *cg_te_model;
cvar_t *cg_te_life;
cvar_t *cg_te_color_r;
cvar_t *cg_te_color_g;
cvar_t *cg_te_color_b;
cvar_t *cg_te_accel_x;
cvar_t *cg_te_accel_y;
cvar_t *cg_te_accel_z;
cvar_t *cg_te_count;
cvar_t *cg_te_fade;
cvar_t *cg_te_fadedelay;
cvar_t *cg_te_fadein;
cvar_t *cg_te_spawnrate;
cvar_t *cg_te_offsbase_x;
cvar_t *cg_te_offsbase_y;
cvar_t *cg_te_offsbase_z;
cvar_t *cg_te_offsamp_x;
cvar_t *cg_te_offsamp_y;
cvar_t *cg_te_offsamp_z;
cvar_t *cg_te_scalerate;
cvar_t *cg_te_circle;
cvar_t *cg_te_sphere;
cvar_t *cg_te_insphere;
cvar_t *cg_te_radius;
cvar_t *cg_te_align;
cvar_t *cg_te_flickeralpha;
cvar_t *cg_te_collision;
cvar_t *cg_te_randomroll;
cvar_t *cg_te_anglesbase_p;
cvar_t *cg_te_anglesbase_y;
cvar_t *cg_te_anglesbase_r;
cvar_t *cg_te_anglesamp_p;
cvar_t *cg_te_anglesamp_y;
cvar_t *cg_te_anglesamp_r;
cvar_t *cg_te_forwardvel;
cvar_t *cg_te_randvelbase_x;
cvar_t *cg_te_randvelbase_y;
cvar_t *cg_te_randvelbase_z;
cvar_t *cg_te_randvelamp_x;
cvar_t *cg_te_randvelamp_y;
cvar_t *cg_te_randvelamp_z;
cvar_t *cg_te_clampvelmin_x;
cvar_t *cg_te_clampvelmax_x;
cvar_t *cg_te_clampvelmin_y;
cvar_t *cg_te_clampvelmax_y;
cvar_t *cg_te_clampvelmin_z;
cvar_t *cg_te_clampvelmax_z;
cvar_t *cg_te_clampvelaxis;
cvar_t *cg_te_volumetric;
cvar_t *cg_te_randaxis;
cvar_t *cg_te_axisoffsbase_x;
cvar_t *cg_te_axisoffsbase_y;
cvar_t *cg_te_axisoffsbase_z;
cvar_t *cg_te_axisoffsamp_x;
cvar_t *cg_te_axisoffsamp_y;
cvar_t *cg_te_axisoffsamp_z;
cvar_t *cg_te_swarm_freq;
cvar_t *cg_te_swarm_maxspeed;
cvar_t *cg_te_swarm_delta;
cvar_t *cg_te_avelbase_p;
cvar_t *cg_te_avelbase_y;
cvar_t *cg_te_avelbase_r;
cvar_t *cg_te_avelamp_p;
cvar_t *cg_te_avelamp_y;
cvar_t *cg_te_avelamp_r;
cvar_t *cg_te_radial_scale;
cvar_t *cg_te_radial_min;
cvar_t *cg_te_radial_max;
cvar_t *cg_te_friction;
cvar_t *cg_te_varycolor;
cvar_t *cg_te_spritegridlighting;
cvar_t *cg_te_cone_height;
cvar_t *cg_te_alignstretch_scale;
cvar_t *cg_te_spawnrange_a;
cvar_t *cg_te_spawnrange_b;
cvar_t *cg_te_command_time;
cvar_t *cg_te_singlelinecommand;
cvar_t *cg_te_tag;
cvar_t *cg_te_xangles;
cvar_t *cg_te_yangles;
cvar_t *cg_te_zangles;
class specialeffect_t;
refEntity_t te_refEnt;
cvar_t* cg_te_emittermodel;
cvar_t* cg_te_mode;
cvar_t* cg_te_mode_name;
cvar_t* cg_te_currCommand;
cvar_t* cg_te_numCommands;
float te_vEmitterOrigin[3];
int te_iNumCommands;
int te_iCurrCommand;
refEntity_t te_refEnt;
cvar_t *cg_te_emittermodel;
cvar_t *cg_te_mode;
cvar_t *cg_te_mode_name;
cvar_t *cg_te_currCommand;
cvar_t *cg_te_numCommands;
float te_vEmitterOrigin[3];
int te_iNumCommands;
int te_iCurrCommand;
specialeffect_t *pTesteffect;
#define MAX_TESTEMITTERS_SAVE 32
@ -212,94 +212,94 @@ str cg_te_command_timeG[MAX_TESTEMITTERS_SAVE];
str cg_te_singlelinecommandG[MAX_TESTEMITTERS_SAVE];
str cg_te_tagG[MAX_TESTEMITTERS_SAVE];
spawnthing_t* testspawnthing = NULL;
spawnthing_t *testspawnthing = NULL;
void CG_SaveEffectCommandCvars(int iCommand)
{
cg_te_alphaG[iCommand] = cg_te_alpha->string;
cg_te_dietouchG[iCommand] = cg_te_dietouch->string;
cg_te_bouncefactorG[iCommand] = cg_te_bouncefactor->string;
cg_te_scaleG[iCommand] = cg_te_scale->string;
cg_te_scaleminG[iCommand] = cg_te_scalemin->string;
cg_te_scalemaxG[iCommand] = cg_te_scalemax->string;
cg_te_modelG[iCommand] = cg_te_model->string;
cg_te_lifeG[iCommand] = cg_te_life->string;
cg_te_color_rG[iCommand] = cg_te_color_r->string;
cg_te_color_gG[iCommand] = cg_te_color_g->string;
cg_te_color_bG[iCommand] = cg_te_color_b->string;
cg_te_accel_xG[iCommand] = cg_te_accel_x->string;
cg_te_accel_yG[iCommand] = cg_te_accel_y->string;
cg_te_accel_zG[iCommand] = cg_te_accel_z->string;
cg_te_countG[iCommand] = cg_te_count->string;
cg_te_fadeG[iCommand] = cg_te_fade->string;
cg_te_fadedelayG[iCommand] = cg_te_fadedelay->string;
cg_te_fadeinG[iCommand] = cg_te_fadein->string;
cg_te_spawnrateG[iCommand] = cg_te_spawnrate->string;
cg_te_offsbase_xG[iCommand] = cg_te_offsbase_x->string;
cg_te_offsbase_yG[iCommand] = cg_te_offsbase_y->string;
cg_te_offsbase_zG[iCommand] = cg_te_offsbase_z->string;
cg_te_offsamp_xG[iCommand] = cg_te_offsamp_x->string;
cg_te_offsamp_yG[iCommand] = cg_te_offsamp_y->string;
cg_te_offsamp_zG[iCommand] = cg_te_offsamp_z->string;
cg_te_scalerateG[iCommand] = cg_te_scalerate->string;
cg_te_circleG[iCommand] = cg_te_circle->string;
cg_te_sphereG[iCommand] = cg_te_sphere->string;
cg_te_insphereG[iCommand] = cg_te_insphere->string;
cg_te_radiusG[iCommand] = cg_te_radius->string;
cg_te_alignG[iCommand] = cg_te_align->string;
cg_te_flickeralphaG[iCommand] = cg_te_flickeralpha->string;
cg_te_collisionG[iCommand] = cg_te_collision->string;
cg_te_randomrollG[iCommand] = cg_te_randomroll->string;
cg_te_anglesbase_pG[iCommand] = cg_te_anglesbase_p->string;
cg_te_anglesbase_yG[iCommand] = cg_te_anglesbase_y->string;
cg_te_anglesbase_rG[iCommand] = cg_te_anglesbase_r->string;
cg_te_anglesamp_pG[iCommand] = cg_te_anglesamp_p->string;
cg_te_anglesamp_yG[iCommand] = cg_te_anglesamp_y->string;
cg_te_anglesamp_rG[iCommand] = cg_te_anglesamp_r->string;
cg_te_forwardvelG[iCommand] = cg_te_forwardvel->string;
cg_te_randvelbase_xG[iCommand] = cg_te_randvelbase_x->string;
cg_te_randvelbase_yG[iCommand] = cg_te_randvelbase_y->string;
cg_te_randvelbase_zG[iCommand] = cg_te_randvelbase_z->string;
cg_te_randvelamp_xG[iCommand] = cg_te_randvelamp_x->string;
cg_te_randvelamp_yG[iCommand] = cg_te_randvelamp_y->string;
cg_te_randvelamp_zG[iCommand] = cg_te_randvelamp_z->string;
cg_te_clampvelmin_xG[iCommand] = cg_te_clampvelmin_x->string;
cg_te_clampvelmax_xG[iCommand] = cg_te_clampvelmax_x->string;
cg_te_clampvelmin_yG[iCommand] = cg_te_clampvelmin_y->string;
cg_te_clampvelmax_yG[iCommand] = cg_te_clampvelmax_y->string;
cg_te_clampvelmin_zG[iCommand] = cg_te_clampvelmin_z->string;
cg_te_clampvelmax_zG[iCommand] = cg_te_clampvelmax_z->string;
cg_te_clampvelaxisG[iCommand] = cg_te_clampvelaxis->string;
cg_te_volumetricG[iCommand] = cg_te_volumetric->string;
cg_te_randaxisG[iCommand] = cg_te_randaxis->string;
cg_te_axisoffsbase_xG[iCommand] = cg_te_axisoffsbase_x->string;
cg_te_axisoffsbase_yG[iCommand] = cg_te_axisoffsbase_y->string;
cg_te_axisoffsbase_zG[iCommand] = cg_te_axisoffsbase_z->string;
cg_te_axisoffsamp_xG[iCommand] = cg_te_axisoffsamp_x->string;
cg_te_axisoffsamp_yG[iCommand] = cg_te_axisoffsamp_y->string;
cg_te_axisoffsamp_zG[iCommand] = cg_te_axisoffsamp_z->string;
cg_te_swarm_freqG[iCommand] = cg_te_swarm_freq->string;
cg_te_swarm_maxspeedG[iCommand] = cg_te_swarm_maxspeed->string;
cg_te_swarm_deltaG[iCommand] = cg_te_swarm_delta->string;
cg_te_avelbase_pG[iCommand] = cg_te_avelbase_p->string;
cg_te_avelbase_yG[iCommand] = cg_te_avelbase_y->string;
cg_te_avelbase_rG[iCommand] = cg_te_avelbase_r->string;
cg_te_avelamp_pG[iCommand] = cg_te_avelamp_p->string;
cg_te_avelamp_yG[iCommand] = cg_te_avelamp_y->string;
cg_te_avelamp_rG[iCommand] = cg_te_avelamp_r->string;
cg_te_radial_scaleG[iCommand] = cg_te_radial_scale->string;
cg_te_radial_minG[iCommand] = cg_te_radial_min->string;
cg_te_radial_maxG[iCommand] = cg_te_radial_max->string;
cg_te_frictionG[iCommand] = cg_te_friction->string;
cg_te_varycolorG[iCommand] = cg_te_varycolor->string;
cg_te_alphaG[iCommand] = cg_te_alpha->string;
cg_te_dietouchG[iCommand] = cg_te_dietouch->string;
cg_te_bouncefactorG[iCommand] = cg_te_bouncefactor->string;
cg_te_scaleG[iCommand] = cg_te_scale->string;
cg_te_scaleminG[iCommand] = cg_te_scalemin->string;
cg_te_scalemaxG[iCommand] = cg_te_scalemax->string;
cg_te_modelG[iCommand] = cg_te_model->string;
cg_te_lifeG[iCommand] = cg_te_life->string;
cg_te_color_rG[iCommand] = cg_te_color_r->string;
cg_te_color_gG[iCommand] = cg_te_color_g->string;
cg_te_color_bG[iCommand] = cg_te_color_b->string;
cg_te_accel_xG[iCommand] = cg_te_accel_x->string;
cg_te_accel_yG[iCommand] = cg_te_accel_y->string;
cg_te_accel_zG[iCommand] = cg_te_accel_z->string;
cg_te_countG[iCommand] = cg_te_count->string;
cg_te_fadeG[iCommand] = cg_te_fade->string;
cg_te_fadedelayG[iCommand] = cg_te_fadedelay->string;
cg_te_fadeinG[iCommand] = cg_te_fadein->string;
cg_te_spawnrateG[iCommand] = cg_te_spawnrate->string;
cg_te_offsbase_xG[iCommand] = cg_te_offsbase_x->string;
cg_te_offsbase_yG[iCommand] = cg_te_offsbase_y->string;
cg_te_offsbase_zG[iCommand] = cg_te_offsbase_z->string;
cg_te_offsamp_xG[iCommand] = cg_te_offsamp_x->string;
cg_te_offsamp_yG[iCommand] = cg_te_offsamp_y->string;
cg_te_offsamp_zG[iCommand] = cg_te_offsamp_z->string;
cg_te_scalerateG[iCommand] = cg_te_scalerate->string;
cg_te_circleG[iCommand] = cg_te_circle->string;
cg_te_sphereG[iCommand] = cg_te_sphere->string;
cg_te_insphereG[iCommand] = cg_te_insphere->string;
cg_te_radiusG[iCommand] = cg_te_radius->string;
cg_te_alignG[iCommand] = cg_te_align->string;
cg_te_flickeralphaG[iCommand] = cg_te_flickeralpha->string;
cg_te_collisionG[iCommand] = cg_te_collision->string;
cg_te_randomrollG[iCommand] = cg_te_randomroll->string;
cg_te_anglesbase_pG[iCommand] = cg_te_anglesbase_p->string;
cg_te_anglesbase_yG[iCommand] = cg_te_anglesbase_y->string;
cg_te_anglesbase_rG[iCommand] = cg_te_anglesbase_r->string;
cg_te_anglesamp_pG[iCommand] = cg_te_anglesamp_p->string;
cg_te_anglesamp_yG[iCommand] = cg_te_anglesamp_y->string;
cg_te_anglesamp_rG[iCommand] = cg_te_anglesamp_r->string;
cg_te_forwardvelG[iCommand] = cg_te_forwardvel->string;
cg_te_randvelbase_xG[iCommand] = cg_te_randvelbase_x->string;
cg_te_randvelbase_yG[iCommand] = cg_te_randvelbase_y->string;
cg_te_randvelbase_zG[iCommand] = cg_te_randvelbase_z->string;
cg_te_randvelamp_xG[iCommand] = cg_te_randvelamp_x->string;
cg_te_randvelamp_yG[iCommand] = cg_te_randvelamp_y->string;
cg_te_randvelamp_zG[iCommand] = cg_te_randvelamp_z->string;
cg_te_clampvelmin_xG[iCommand] = cg_te_clampvelmin_x->string;
cg_te_clampvelmax_xG[iCommand] = cg_te_clampvelmax_x->string;
cg_te_clampvelmin_yG[iCommand] = cg_te_clampvelmin_y->string;
cg_te_clampvelmax_yG[iCommand] = cg_te_clampvelmax_y->string;
cg_te_clampvelmin_zG[iCommand] = cg_te_clampvelmin_z->string;
cg_te_clampvelmax_zG[iCommand] = cg_te_clampvelmax_z->string;
cg_te_clampvelaxisG[iCommand] = cg_te_clampvelaxis->string;
cg_te_volumetricG[iCommand] = cg_te_volumetric->string;
cg_te_randaxisG[iCommand] = cg_te_randaxis->string;
cg_te_axisoffsbase_xG[iCommand] = cg_te_axisoffsbase_x->string;
cg_te_axisoffsbase_yG[iCommand] = cg_te_axisoffsbase_y->string;
cg_te_axisoffsbase_zG[iCommand] = cg_te_axisoffsbase_z->string;
cg_te_axisoffsamp_xG[iCommand] = cg_te_axisoffsamp_x->string;
cg_te_axisoffsamp_yG[iCommand] = cg_te_axisoffsamp_y->string;
cg_te_axisoffsamp_zG[iCommand] = cg_te_axisoffsamp_z->string;
cg_te_swarm_freqG[iCommand] = cg_te_swarm_freq->string;
cg_te_swarm_maxspeedG[iCommand] = cg_te_swarm_maxspeed->string;
cg_te_swarm_deltaG[iCommand] = cg_te_swarm_delta->string;
cg_te_avelbase_pG[iCommand] = cg_te_avelbase_p->string;
cg_te_avelbase_yG[iCommand] = cg_te_avelbase_y->string;
cg_te_avelbase_rG[iCommand] = cg_te_avelbase_r->string;
cg_te_avelamp_pG[iCommand] = cg_te_avelamp_p->string;
cg_te_avelamp_yG[iCommand] = cg_te_avelamp_y->string;
cg_te_avelamp_rG[iCommand] = cg_te_avelamp_r->string;
cg_te_radial_scaleG[iCommand] = cg_te_radial_scale->string;
cg_te_radial_minG[iCommand] = cg_te_radial_min->string;
cg_te_radial_maxG[iCommand] = cg_te_radial_max->string;
cg_te_frictionG[iCommand] = cg_te_friction->string;
cg_te_varycolorG[iCommand] = cg_te_varycolor->string;
cg_te_spritegridlightingG[iCommand] = cg_te_spritegridlighting->string;
cg_te_spawnrange_aG[iCommand] = cg_te_spawnrange_a->string;
cg_te_spawnrange_bG[iCommand] = cg_te_spawnrange_b->string;
cg_te_cone_heightG[iCommand] = cg_te_cone_height->string;
cg_te_spawnrange_aG[iCommand] = cg_te_spawnrange_a->string;
cg_te_spawnrange_bG[iCommand] = cg_te_spawnrange_b->string;
cg_te_cone_heightG[iCommand] = cg_te_cone_height->string;
cg_te_alignstretch_scaleG[iCommand] = cg_te_alignstretch_scale->string;
cg_te_command_timeG[iCommand] = cg_te_command_time->string;
cg_te_singlelinecommandG[iCommand] = cg_te_singlelinecommand->string;
cg_te_tagG[iCommand] = cg_te_tag->string;
cg_te_command_timeG[iCommand] = cg_te_command_time->string;
cg_te_singlelinecommandG[iCommand] = cg_te_singlelinecommand->string;
cg_te_tagG[iCommand] = cg_te_tag->string;
}
void CG_ResetEffectCommandCvars()
@ -327,7 +327,7 @@ void CG_TriggerTestEmitter_f(void)
// FIXME: unimplemented
}
void CG_DumpBaseAndAmplitude(str* buff, char* prefix, Vector* base, Vector* amplitude)
void CG_DumpBaseAndAmplitude(str *buff, char *prefix, Vector *base, Vector *amplitude)
{
// FIXME: unimplemented
}
@ -337,7 +337,9 @@ void CG_DumpEmitter_f(void)
// FIXME: unimplemented
}
void CG_LoadBaseAndAmplitude(char** pBufer, char* szCvarX, char* szCvarY, char* szCvarZ, char* szCvarXAmp, char* szCvarYAmp, char* szCvarZAmp)
void CG_LoadBaseAndAmplitude(
char **pBufer, char *szCvarX, char *szCvarY, char *szCvarZ, char *szCvarXAmp, char *szCvarYAmp, char *szCvarZAmp
)
{
// FIXME: unimplemented
}
@ -374,111 +376,111 @@ void CG_DeleteEmitterCommand_f(void)
void CG_InitTestEmitter(void)
{
cg_te_life = cgi.Cvar_Get("cg_te_life", "1", 0);
cg_te_alpha = cgi.Cvar_Get("cg_te_alpha", "1", 0);
cg_te_dietouch = cgi.Cvar_Get("cg_te_dietouch", "0", 0);
cg_te_bouncefactor = cgi.Cvar_Get("cg_te_bouncefactor", "0.3", 0);
cg_te_scale = cgi.Cvar_Get("cg_te_scale", "1", 0);
cg_te_scalemin = cgi.Cvar_Get("cg_te_scalemin", "0", 0);
cg_te_scalemax = cgi.Cvar_Get("cg_te_scalemax", "0", 0);
cg_te_model = cgi.Cvar_Get("cg_te_model", "none", 0);
cg_te_life = cgi.Cvar_Get("cg_te_life", "1", 0);
cg_te_color_r = cgi.Cvar_Get("cg_te_color_r", "1", 0);
cg_te_color_g = cgi.Cvar_Get("cg_te_color_g", "1", 0);
cg_te_color_b = cgi.Cvar_Get("cg_te_color_b", "1", 0);
cg_te_accel_x = cgi.Cvar_Get("cg_te_accel_x", "0", 0);
cg_te_accel_y = cgi.Cvar_Get("cg_te_accel_y", "0", 0);
cg_te_accel_z = cgi.Cvar_Get("cg_te_accel_z", "0", 0);
cg_te_count = cgi.Cvar_Get("cg_te_count", "1", 0);
cg_te_fade = cgi.Cvar_Get("cg_te_fade", "0", 0);
cg_te_fadedelay = cgi.Cvar_Get("cg_te_fadedelay", "0", 0);
cg_te_fadein = cgi.Cvar_Get("cg_te_fadein", "0", 0);
cg_te_spawnrate = cgi.Cvar_Get("cg_te_spawnrate", "1", 0);
cg_te_scalerate = cgi.Cvar_Get("cg_te_scalerate", "0", 0);
cg_te_circle = cgi.Cvar_Get("cg_te_circle", "0", 0);
cg_te_sphere = cgi.Cvar_Get("cg_te_sphere", "0", 0);
cg_te_insphere = cgi.Cvar_Get("cg_te_insphere", "0", 0);
cg_te_radius = cgi.Cvar_Get("cg_te_radius", "0", 0);
cg_te_align = cgi.Cvar_Get("cg_te_align", "0", 0);
cg_te_flickeralpha = cgi.Cvar_Get("cg_te_flickeralpha", "0", 0);
cg_te_collision = cgi.Cvar_Get("cg_te_collision", "0", 0);
cg_te_randomroll = cgi.Cvar_Get("cg_te_randomroll", "0", 0);
cg_te_offsbase_x = cgi.Cvar_Get("cg_te_offsbase_x", "0", 0);
cg_te_offsbase_y = cgi.Cvar_Get("cg_te_offsbase_y", "0", 0);
cg_te_offsbase_z = cgi.Cvar_Get("cg_te_offsbase_z", "0", 0);
cg_te_offsamp_x = cgi.Cvar_Get("cg_te_offsamp_x", "0", 0);
cg_te_offsamp_y = cgi.Cvar_Get("cg_te_offsamp_y", "0", 0);
cg_te_offsamp_z = cgi.Cvar_Get("cg_te_offsamp_z", "0", 0);
cg_te_anglesbase_p = cgi.Cvar_Get("cg_te_anglesbase_p", "0", 0);
cg_te_anglesbase_y = cgi.Cvar_Get("cg_te_anglesbase_y", "0", 0);
cg_te_anglesbase_r = cgi.Cvar_Get("cg_te_anglesbase_r", "0", 0);
cg_te_anglesamp_p = cgi.Cvar_Get("cg_te_anglesamp_p", "0", 0);
cg_te_anglesamp_y = cgi.Cvar_Get("cg_te_anglesamp_y", "0", 0);
cg_te_anglesamp_r = cgi.Cvar_Get("cg_te_anglesamp_r", "0", 0);
cg_te_randvelbase_x = cgi.Cvar_Get("cg_te_randvelbase_x", "0", 0);
cg_te_randvelbase_y = cgi.Cvar_Get("cg_te_randvelbase_y", "0", 0);
cg_te_randvelbase_z = cgi.Cvar_Get("cg_te_randvelbase_z", "0", 0);
cg_te_randvelamp_x = cgi.Cvar_Get("cg_te_randvelamp_x", "0", 0);
cg_te_randvelamp_y = cgi.Cvar_Get("cg_te_randvelamp_y", "0", 0);
cg_te_randvelamp_z = cgi.Cvar_Get("cg_te_randvelamp_z", "0", 0);
cg_te_clampvelmin_x = cgi.Cvar_Get("cg_te_clampvelmin_x", "-9999", 0);
cg_te_clampvelmax_x = cgi.Cvar_Get("cg_te_clampvelmax_x", "9999", 0);
cg_te_clampvelmin_y = cgi.Cvar_Get("cg_te_clampvelmin_y", "-9999", 0);
cg_te_clampvelmax_y = cgi.Cvar_Get("cg_te_clampvelmax_y", "9999", 0);
cg_te_clampvelmin_z = cgi.Cvar_Get("cg_te_clampvelmin_z", "-9999", 0);
cg_te_clampvelmax_z = cgi.Cvar_Get("cg_te_clampvelmax_z", "9999", 0);
cg_te_clampvelaxis = cgi.Cvar_Get("cg_te_clampvelaxis", "0", 0);
cg_te_forwardvel = cgi.Cvar_Get("cg_te_forwardvel", "0", 0);
cg_te_volumetric = cgi.Cvar_Get("cg_te_volumetric", "0", 0);
cg_te_randaxis = cgi.Cvar_Get("cg_te_randaxis", "0", 0);
cg_te_axisoffsbase_x = cgi.Cvar_Get("cg_te_axisoffsbase_x", "0", 0);
cg_te_axisoffsbase_y = cgi.Cvar_Get("cg_te_axisoffsbase_y", "0", 0);
cg_te_axisoffsbase_z = cgi.Cvar_Get("cg_te_axisoffsbase_z", "0", 0);
cg_te_axisoffsamp_x = cgi.Cvar_Get("cg_te_axisoffsamp_x", "0", 0);
cg_te_axisoffsamp_y = cgi.Cvar_Get("cg_te_axisoffsamp_y", "0", 0);
cg_te_axisoffsamp_z = cgi.Cvar_Get("cg_te_axisoffsamp_z", "0", 0);
cg_te_swarm_freq = cgi.Cvar_Get("cg_te_swarm_freq", "0", 0);
cg_te_swarm_maxspeed = cgi.Cvar_Get("cg_te_swarm_maxspeed", "0", 0);
cg_te_swarm_delta = cgi.Cvar_Get("cg_te_swarm_delta", "0", 0);
cg_te_avelbase_p = cgi.Cvar_Get("cg_te_avelbase_p", "0", 0);
cg_te_avelbase_y = cgi.Cvar_Get("cg_te_avelbase_y", "0", 0);
cg_te_avelbase_r = cgi.Cvar_Get("cg_te_avelbase_r", "0", 0);
cg_te_avelamp_p = cgi.Cvar_Get("cg_te_avelamp_p", "0", 0);
cg_te_avelamp_y = cgi.Cvar_Get("cg_te_avelamp_y", "0", 0);
cg_te_avelamp_r = cgi.Cvar_Get("cg_te_avelamp_r", "0", 0);
cg_te_radial_scale = cgi.Cvar_Get("cg_te_radial_scale", "0", 0);
cg_te_radial_min = cgi.Cvar_Get("cg_te_radial_min", "0", 0);
cg_te_radial_max = cgi.Cvar_Get("cg_te_radial_max", "0", 0);
cg_te_friction = cgi.Cvar_Get("cg_te_friction", "0", 0);
cg_te_varycolor = cgi.Cvar_Get("cg_te_varycolor", "0", 0);
cg_te_life = cgi.Cvar_Get("cg_te_life", "1", 0);
cg_te_alpha = cgi.Cvar_Get("cg_te_alpha", "1", 0);
cg_te_dietouch = cgi.Cvar_Get("cg_te_dietouch", "0", 0);
cg_te_bouncefactor = cgi.Cvar_Get("cg_te_bouncefactor", "0.3", 0);
cg_te_scale = cgi.Cvar_Get("cg_te_scale", "1", 0);
cg_te_scalemin = cgi.Cvar_Get("cg_te_scalemin", "0", 0);
cg_te_scalemax = cgi.Cvar_Get("cg_te_scalemax", "0", 0);
cg_te_model = cgi.Cvar_Get("cg_te_model", "none", 0);
cg_te_life = cgi.Cvar_Get("cg_te_life", "1", 0);
cg_te_color_r = cgi.Cvar_Get("cg_te_color_r", "1", 0);
cg_te_color_g = cgi.Cvar_Get("cg_te_color_g", "1", 0);
cg_te_color_b = cgi.Cvar_Get("cg_te_color_b", "1", 0);
cg_te_accel_x = cgi.Cvar_Get("cg_te_accel_x", "0", 0);
cg_te_accel_y = cgi.Cvar_Get("cg_te_accel_y", "0", 0);
cg_te_accel_z = cgi.Cvar_Get("cg_te_accel_z", "0", 0);
cg_te_count = cgi.Cvar_Get("cg_te_count", "1", 0);
cg_te_fade = cgi.Cvar_Get("cg_te_fade", "0", 0);
cg_te_fadedelay = cgi.Cvar_Get("cg_te_fadedelay", "0", 0);
cg_te_fadein = cgi.Cvar_Get("cg_te_fadein", "0", 0);
cg_te_spawnrate = cgi.Cvar_Get("cg_te_spawnrate", "1", 0);
cg_te_scalerate = cgi.Cvar_Get("cg_te_scalerate", "0", 0);
cg_te_circle = cgi.Cvar_Get("cg_te_circle", "0", 0);
cg_te_sphere = cgi.Cvar_Get("cg_te_sphere", "0", 0);
cg_te_insphere = cgi.Cvar_Get("cg_te_insphere", "0", 0);
cg_te_radius = cgi.Cvar_Get("cg_te_radius", "0", 0);
cg_te_align = cgi.Cvar_Get("cg_te_align", "0", 0);
cg_te_flickeralpha = cgi.Cvar_Get("cg_te_flickeralpha", "0", 0);
cg_te_collision = cgi.Cvar_Get("cg_te_collision", "0", 0);
cg_te_randomroll = cgi.Cvar_Get("cg_te_randomroll", "0", 0);
cg_te_offsbase_x = cgi.Cvar_Get("cg_te_offsbase_x", "0", 0);
cg_te_offsbase_y = cgi.Cvar_Get("cg_te_offsbase_y", "0", 0);
cg_te_offsbase_z = cgi.Cvar_Get("cg_te_offsbase_z", "0", 0);
cg_te_offsamp_x = cgi.Cvar_Get("cg_te_offsamp_x", "0", 0);
cg_te_offsamp_y = cgi.Cvar_Get("cg_te_offsamp_y", "0", 0);
cg_te_offsamp_z = cgi.Cvar_Get("cg_te_offsamp_z", "0", 0);
cg_te_anglesbase_p = cgi.Cvar_Get("cg_te_anglesbase_p", "0", 0);
cg_te_anglesbase_y = cgi.Cvar_Get("cg_te_anglesbase_y", "0", 0);
cg_te_anglesbase_r = cgi.Cvar_Get("cg_te_anglesbase_r", "0", 0);
cg_te_anglesamp_p = cgi.Cvar_Get("cg_te_anglesamp_p", "0", 0);
cg_te_anglesamp_y = cgi.Cvar_Get("cg_te_anglesamp_y", "0", 0);
cg_te_anglesamp_r = cgi.Cvar_Get("cg_te_anglesamp_r", "0", 0);
cg_te_randvelbase_x = cgi.Cvar_Get("cg_te_randvelbase_x", "0", 0);
cg_te_randvelbase_y = cgi.Cvar_Get("cg_te_randvelbase_y", "0", 0);
cg_te_randvelbase_z = cgi.Cvar_Get("cg_te_randvelbase_z", "0", 0);
cg_te_randvelamp_x = cgi.Cvar_Get("cg_te_randvelamp_x", "0", 0);
cg_te_randvelamp_y = cgi.Cvar_Get("cg_te_randvelamp_y", "0", 0);
cg_te_randvelamp_z = cgi.Cvar_Get("cg_te_randvelamp_z", "0", 0);
cg_te_clampvelmin_x = cgi.Cvar_Get("cg_te_clampvelmin_x", "-9999", 0);
cg_te_clampvelmax_x = cgi.Cvar_Get("cg_te_clampvelmax_x", "9999", 0);
cg_te_clampvelmin_y = cgi.Cvar_Get("cg_te_clampvelmin_y", "-9999", 0);
cg_te_clampvelmax_y = cgi.Cvar_Get("cg_te_clampvelmax_y", "9999", 0);
cg_te_clampvelmin_z = cgi.Cvar_Get("cg_te_clampvelmin_z", "-9999", 0);
cg_te_clampvelmax_z = cgi.Cvar_Get("cg_te_clampvelmax_z", "9999", 0);
cg_te_clampvelaxis = cgi.Cvar_Get("cg_te_clampvelaxis", "0", 0);
cg_te_forwardvel = cgi.Cvar_Get("cg_te_forwardvel", "0", 0);
cg_te_volumetric = cgi.Cvar_Get("cg_te_volumetric", "0", 0);
cg_te_randaxis = cgi.Cvar_Get("cg_te_randaxis", "0", 0);
cg_te_axisoffsbase_x = cgi.Cvar_Get("cg_te_axisoffsbase_x", "0", 0);
cg_te_axisoffsbase_y = cgi.Cvar_Get("cg_te_axisoffsbase_y", "0", 0);
cg_te_axisoffsbase_z = cgi.Cvar_Get("cg_te_axisoffsbase_z", "0", 0);
cg_te_axisoffsamp_x = cgi.Cvar_Get("cg_te_axisoffsamp_x", "0", 0);
cg_te_axisoffsamp_y = cgi.Cvar_Get("cg_te_axisoffsamp_y", "0", 0);
cg_te_axisoffsamp_z = cgi.Cvar_Get("cg_te_axisoffsamp_z", "0", 0);
cg_te_swarm_freq = cgi.Cvar_Get("cg_te_swarm_freq", "0", 0);
cg_te_swarm_maxspeed = cgi.Cvar_Get("cg_te_swarm_maxspeed", "0", 0);
cg_te_swarm_delta = cgi.Cvar_Get("cg_te_swarm_delta", "0", 0);
cg_te_avelbase_p = cgi.Cvar_Get("cg_te_avelbase_p", "0", 0);
cg_te_avelbase_y = cgi.Cvar_Get("cg_te_avelbase_y", "0", 0);
cg_te_avelbase_r = cgi.Cvar_Get("cg_te_avelbase_r", "0", 0);
cg_te_avelamp_p = cgi.Cvar_Get("cg_te_avelamp_p", "0", 0);
cg_te_avelamp_y = cgi.Cvar_Get("cg_te_avelamp_y", "0", 0);
cg_te_avelamp_r = cgi.Cvar_Get("cg_te_avelamp_r", "0", 0);
cg_te_radial_scale = cgi.Cvar_Get("cg_te_radial_scale", "0", 0);
cg_te_radial_min = cgi.Cvar_Get("cg_te_radial_min", "0", 0);
cg_te_radial_max = cgi.Cvar_Get("cg_te_radial_max", "0", 0);
cg_te_friction = cgi.Cvar_Get("cg_te_friction", "0", 0);
cg_te_varycolor = cgi.Cvar_Get("cg_te_varycolor", "0", 0);
cg_te_spritegridlighting = cgi.Cvar_Get("cg_te_spritegridlighting", "0", 0);
cg_te_spawnrange_a = cgi.Cvar_Get("cg_te_spawnrange_a", "0", 0);
cg_te_spawnrange_b = cgi.Cvar_Get("cg_te_spawnrange_b", "0", 0);
cg_te_cone_height = cgi.Cvar_Get("cg_te_cone_height", "0", 0);
cg_te_spawnrange_a = cgi.Cvar_Get("cg_te_spawnrange_a", "0", 0);
cg_te_spawnrange_b = cgi.Cvar_Get("cg_te_spawnrange_b", "0", 0);
cg_te_cone_height = cgi.Cvar_Get("cg_te_cone_height", "0", 0);
cg_te_alignstretch_scale = cgi.Cvar_Get("cg_te_alignstretch_scale", "0", 0);
cg_te_command_time = cgi.Cvar_Get("cg_te_command_time", "0", 0);
cg_te_singlelinecommand = cgi.Cvar_Get("cg_te_singlelinecommand", "", 0);
cg_te_tag = cgi.Cvar_Get("cg_te_tag", "", 0);
cg_te_command_time = cgi.Cvar_Get("cg_te_command_time", "0", 0);
cg_te_singlelinecommand = cgi.Cvar_Get("cg_te_singlelinecommand", "", 0);
cg_te_tag = cgi.Cvar_Get("cg_te_tag", "", 0);
for (int i = 0; i < MAX_TESTEMITTERS_SAVE; ++i) {
CG_SaveEffectCommandCvars(i);
}
cg_te_xangles = cgi.Cvar_Get("cg_te_xangles", "0", 0);
cg_te_yangles = cgi.Cvar_Get("cg_te_yangles", "0", 0);
cg_te_zangles = cgi.Cvar_Get("cg_te_zangles", "0", 0);
cg_te_xangles = cgi.Cvar_Get("cg_te_xangles", "0", 0);
cg_te_yangles = cgi.Cvar_Get("cg_te_yangles", "0", 0);
cg_te_zangles = cgi.Cvar_Get("cg_te_zangles", "0", 0);
cg_te_emittermodel = cgi.Cvar_Get("cg_te_emittermodel", "", 0);
cg_te_mode = cgi.Cvar_Get("cg_te_mode", "0", 0);
cg_te_mode_name = cgi.Cvar_Get("cg_te_mode_name", "Emitter Mode", 0);
cg_te_currCommand = cgi.Cvar_Get("cg_te_currCommand", "0", 0);
cg_te_mode = cgi.Cvar_Get("cg_te_mode", "0", 0);
cg_te_mode_name = cgi.Cvar_Get("cg_te_mode_name", "Emitter Mode", 0);
cg_te_currCommand = cgi.Cvar_Get("cg_te_currCommand", "0", 0);
te_vEmitterOrigin[2] = 0.0;
te_vEmitterOrigin[1] = 0.0;
te_vEmitterOrigin[0] = 0.0;
te_refEnt.scale = 0.0;
cg_te_numCommands = cgi.Cvar_Get("cg_te_numCommands", "0", 0);
te_iNumCommands = 0;
te_iCurrCommand = 0;
te_refEnt.scale = 0.0;
cg_te_numCommands = cgi.Cvar_Get("cg_te_numCommands", "0", 0);
te_iNumCommands = 0;
te_iCurrCommand = 0;
pTesteffect = sfxManager.GetTestEffectPointer();
}

View file

@ -62,8 +62,7 @@ void CG_MessageMode_Private_f(void)
}
clientNum = atoi(cgi.Argv(1)) - 1;
if (clientNum < 0 || clientNum >= MAX_CLIENTS)
{
if (clientNum < 0 || clientNum >= MAX_CLIENTS) {
cgi.Printf(HUD_MESSAGE_CHAT_WHITE "Message Error: %s is a bad client number\n", cgi.Argv(1));
return;
}
@ -79,8 +78,7 @@ void CG_MessageSingleAll_f(void)
if (cgi.Argc() > 1) {
cgi.SendClientCommand(va("dmmessage 0 %s\n", cgi.Args()));
}
else {
} else {
cgi.UI_ToggleDMMessageConsole(-100);
}
}
@ -93,8 +91,7 @@ void CG_MessageSingleTeam_f(void)
if (cgi.Argc() > 1) {
cgi.SendClientCommand(va("dmmessage -1 %s\n", cgi.Args()));
}
else {
} else {
cgi.UI_ToggleDMMessageConsole(-200);
}
}
@ -108,14 +105,12 @@ void CG_MessageSingleClient_f(void)
}
clientNum = atoi(cgi.Argv(1));
if (clientNum < 1 || clientNum > MAX_CLIENTS)
{
if (clientNum < 1 || clientNum > MAX_CLIENTS) {
cgi.Printf(HUD_MESSAGE_CHAT_WHITE "Message Error: %s is a bad client number\n", cgi.Argv(1));
return;
}
if (cgi.Argc() > 2)
{
if (cgi.Argc() > 2) {
int i;
str sString;
@ -129,8 +124,7 @@ void CG_MessageSingleClient_f(void)
sString += "\n";
cgi.SendClientCommand(sString.c_str());
}
else {
} else {
cgi.UI_ToggleDMMessageConsole(-clientNum);
}
}

View file

@ -26,17 +26,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_local.h"
#include "cg_commands.h"
void CG_Vehicle(centity_t* cent)
{
void CG_Vehicle(centity_t *cent) {}
}
void ClientGameCommandManager::SpawnTreads(Event* ev)
void ClientGameCommandManager::SpawnTreads(Event *ev)
{
// stub
}
void ClientGameCommandManager::TreadsOff(Event* ev)
void ClientGameCommandManager::TreadsOff(Event *ev)
{
// stub
}

View file

@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//============================================================================
/*
=================
CG_CalcVrect
@ -33,38 +32,37 @@ CG_CalcVrect
Sets the coordinates of the rendered window
=================
*/
static void CG_CalcVrect (void) {
int size;
static void CG_CalcVrect(void)
{
int size;
// the intermission should allways be full screen
if ( cg.snap->ps.pm_flags & PMF_INTERMISSION ) {
size = 100;
} else {
// bound normal viewsize
if (cg_viewsize->integer < 30) {
cgi.Cvar_Set ("viewsize","30");
size = 30;
} else if (cg_viewsize->integer > 100) {
cgi.Cvar_Set ("viewsize","100");
size = 100;
} else {
size = cg_viewsize->integer;
}
// the intermission should allways be full screen
if (cg.snap->ps.pm_flags & PMF_INTERMISSION) {
size = 100;
} else {
// bound normal viewsize
if (cg_viewsize->integer < 30) {
cgi.Cvar_Set("viewsize", "30");
size = 30;
} else if (cg_viewsize->integer > 100) {
cgi.Cvar_Set("viewsize", "100");
size = 100;
} else {
size = cg_viewsize->integer;
}
}
cg.refdef.width = cgs.glconfig.vidWidth * size / 100;
cg.refdef.width &= ~1;
}
cg.refdef.width = cgs.glconfig.vidWidth*size/100;
cg.refdef.width &= ~1;
cg.refdef.height = cgs.glconfig.vidHeight * size / 100;
cg.refdef.height &= ~1;
cg.refdef.height = cgs.glconfig.vidHeight*size/100;
cg.refdef.height &= ~1;
cg.refdef.x = (cgs.glconfig.vidWidth - cg.refdef.width)/2;
cg.refdef.y = (cgs.glconfig.vidHeight - cg.refdef.height)/2;
cg.refdef.x = (cgs.glconfig.vidWidth - cg.refdef.width) / 2;
cg.refdef.y = (cgs.glconfig.vidHeight - cg.refdef.height) / 2;
}
//==============================================================================
/*
===============
CG_OffsetThirdPersonView
@ -72,110 +70,100 @@ CG_OffsetThirdPersonView
===============
*/
#define CAMERA_MINIMUM_DISTANCE 40
static void CG_OffsetThirdPersonView( void )
static void CG_OffsetThirdPersonView(void)
{
vec3_t forward;
vec3_t original_camera_position;
vec3_t new_vieworg;
trace_t trace;
vec3_t min, max;
float *look_offset;
float *target_angles;
float *target_position;
vec3_t delta;
vec3_t original_angles;
qboolean lookactive, resetview;
static vec3_t saved_look_offset;
vec3_t camera_offset;
vec3_t forward;
vec3_t original_camera_position;
vec3_t new_vieworg;
trace_t trace;
vec3_t min, max;
float *look_offset;
float *target_angles;
float *target_position;
vec3_t delta;
vec3_t original_angles;
qboolean lookactive, resetview;
static vec3_t saved_look_offset;
vec3_t camera_offset;
target_angles = cg.refdefViewAngles;
target_position = cg.refdef.vieworg;
target_angles = cg.refdefViewAngles;
target_position = cg.refdef.vieworg;
// see if angles are absolute
if ( cg.predicted_player_state.camera_flags & CF_CAMERA_ANGLES_ABSOLUTE )
{
VectorClear( target_angles );
}
// see if angles are absolute
if (cg.predicted_player_state.camera_flags & CF_CAMERA_ANGLES_ABSOLUTE) {
VectorClear(target_angles);
}
// see if we need to ignore yaw
if ( cg.predicted_player_state.camera_flags & CF_CAMERA_ANGLES_IGNORE_YAW )
{
target_angles[ YAW ] = 0;
}
// see if we need to ignore yaw
if (cg.predicted_player_state.camera_flags & CF_CAMERA_ANGLES_IGNORE_YAW) {
target_angles[YAW] = 0;
}
// see if we need to ignore pitch
if ( cg.predicted_player_state.camera_flags & CF_CAMERA_ANGLES_IGNORE_PITCH )
{
target_angles[ PITCH ] = 0;
}
// see if we need to ignore pitch
if (cg.predicted_player_state.camera_flags & CF_CAMERA_ANGLES_IGNORE_PITCH) {
target_angles[PITCH] = 0;
}
// offset the current angles by the camera offset
VectorSubtract( target_angles, cg.predicted_player_state.camera_offset, target_angles );
// offset the current angles by the camera offset
VectorSubtract(target_angles, cg.predicted_player_state.camera_offset, target_angles);
// Get the position of the camera after any needed rotation
look_offset = cgi.get_camera_offset( &lookactive, &resetview );
// Get the position of the camera after any needed rotation
look_offset = cgi.get_camera_offset(&lookactive, &resetview);
if (
( !resetview ) &&
(
( cg.predicted_player_state.camera_flags & CF_CAMERA_ANGLES_ALLOWOFFSET ) ||
( lookactive )
)
)
{
VectorSubtract( look_offset, saved_look_offset, camera_offset );
VectorAdd( target_angles, camera_offset, target_angles );
if ( target_angles[ PITCH ] > 90 )
target_angles[ PITCH ] = 90;
else if ( target_angles[ PITCH ] < -90 )
target_angles[ PITCH ] = -90;
}
else
{
VectorCopy( look_offset, saved_look_offset );
}
if ((!resetview) && ((cg.predicted_player_state.camera_flags & CF_CAMERA_ANGLES_ALLOWOFFSET) || (lookactive))) {
VectorSubtract(look_offset, saved_look_offset, camera_offset);
VectorAdd(target_angles, camera_offset, target_angles);
if (target_angles[PITCH] > 90) {
target_angles[PITCH] = 90;
} else if (target_angles[PITCH] < -90) {
target_angles[PITCH] = -90;
}
} else {
VectorCopy(look_offset, saved_look_offset);
}
target_angles[ YAW ] = AngleNormalize360( target_angles[ YAW ] );
target_angles[ PITCH ] = AngleNormalize180( target_angles[ PITCH ] );
target_angles[YAW] = AngleNormalize360(target_angles[YAW]);
target_angles[PITCH] = AngleNormalize180(target_angles[PITCH]);
// Move reference point up
// Move reference point up
target_position[2] += cg_cameraheight->value;
target_position[2] += cg_cameraheight->value;
VectorCopy(target_position, original_camera_position);
VectorCopy(target_position, original_camera_position);
// Move camera back from reference point
// Move camera back from reference point
AngleVectors(target_angles, forward, NULL, NULL);
AngleVectors(target_angles, forward, NULL, NULL);
VectorMA(target_position, -cg_cameradist->value, forward, new_vieworg);
VectorMA(target_position, -cg_cameradist->value, forward, new_vieworg);
new_vieworg[ 2 ] += cg_cameraverticaldisplacement->value;
new_vieworg[2] += cg_cameraverticaldisplacement->value;
// Create a bounding box for our camera
// Create a bounding box for our camera
min[0] = -5;
min[1] = -5;
min[2] = -5;
min[0] = -5;
min[1] = -5;
min[2] = -5;
max[0] = 5;
max[1] = 5;
max[2] = 5;
max[0] = 5;
max[1] = 5;
max[2] = 5;
// Make sure camera does not collide with anything
CG_Trace(&trace, cg.playerHeadPos, min, max, new_vieworg, 0, MASK_CAMERASOLID, qfalse, qtrue, "ThirdPersonTrace 1" );
// Make sure camera does not collide with anything
CG_Trace(&trace, cg.playerHeadPos, min, max, new_vieworg, 0, MASK_CAMERASOLID, qfalse, qtrue, "ThirdPersonTrace 1");
VectorCopy(trace.endpos, target_position);
VectorCopy(trace.endpos, target_position);
// calculate distance from end position to head position
VectorSubtract( target_position, cg.playerHeadPos, delta );
// kill any negative z difference in delta
if ( delta[ 2 ] < CAMERA_MINIMUM_DISTANCE )
delta[ 2 ] = 0;
if ( VectorLength( delta ) < CAMERA_MINIMUM_DISTANCE )
{
VectorNormalize( delta);
/*
// calculate distance from end position to head position
VectorSubtract(target_position, cg.playerHeadPos, delta);
// kill any negative z difference in delta
if (delta[2] < CAMERA_MINIMUM_DISTANCE) {
delta[2] = 0;
}
if (VectorLength(delta) < CAMERA_MINIMUM_DISTANCE) {
VectorNormalize(delta);
/*
// see if we are going straight up
if ( ( delta[ 2 ] > 0.75 ) && ( height > 0.85f * cg.predicted_player_state.viewheight ) )
{
@ -186,46 +174,55 @@ static void CG_OffsetThirdPersonView( void )
}
else
*/
{
// we are probably up against the wall so we want the camera to pitch up on top of the player
// save off the original angles
VectorCopy( target_angles, original_angles );
// start cranking up the target angles, pitch until we are the correct distance away from the player
while ( target_angles[ PITCH ] < 90 )
{
target_angles[ PITCH ] += 2;
{
// we are probably up against the wall so we want the camera to pitch up on top of the player
// save off the original angles
VectorCopy(target_angles, original_angles);
// start cranking up the target angles, pitch until we are the correct distance away from the player
while (target_angles[PITCH] < 90) {
target_angles[PITCH] += 2;
AngleVectors(target_angles, forward, NULL, NULL);
AngleVectors(target_angles, forward, NULL, NULL);
VectorMA( original_camera_position, -cg_cameradist->value, forward, new_vieworg);
VectorMA(original_camera_position, -cg_cameradist->value, forward, new_vieworg);
new_vieworg[ 2 ] += cg_cameraverticaldisplacement->value;
new_vieworg[2] += cg_cameraverticaldisplacement->value;
CG_Trace(&trace, cg.playerHeadPos, min, max, new_vieworg, 0, MASK_CAMERASOLID, qfalse, qtrue, "ThirdPersonTrace 3" );
CG_Trace(
&trace,
cg.playerHeadPos,
min,
max,
new_vieworg,
0,
MASK_CAMERASOLID,
qfalse,
qtrue,
"ThirdPersonTrace 3"
);
VectorCopy(trace.endpos, target_position);
VectorCopy(trace.endpos, target_position);
// calculate distance from end position to head position
VectorSubtract( target_position, cg.playerHeadPos, delta );
// kill any negative z difference in delta
if ( delta[ 2 ] < 0 )
delta[ 2 ] = 0;
if ( VectorLength( delta ) >= CAMERA_MINIMUM_DISTANCE )
{
target_angles[ PITCH ] = ( 0.25f * target_angles[ PITCH ] ) + ( 0.75f * original_angles[ PITCH ] );
// set the pitch to be that of the angle we are currently looking
//target_angles[ PITCH ] = original_angles[ PITCH ];
break;
}
// calculate distance from end position to head position
VectorSubtract(target_position, cg.playerHeadPos, delta);
// kill any negative z difference in delta
if (delta[2] < 0) {
delta[2] = 0;
}
if (VectorLength(delta) >= CAMERA_MINIMUM_DISTANCE) {
target_angles[PITCH] = (0.25f * target_angles[PITCH]) + (0.75f * original_angles[PITCH]);
// set the pitch to be that of the angle we are currently looking
//target_angles[ PITCH ] = original_angles[ PITCH ];
break;
}
}
if ( target_angles[ PITCH ] > 90 )
{
// if we failed, go with the original angles
target_angles[ PITCH ] = original_angles[ PITCH ];
if (target_angles[PITCH] > 90) {
// if we failed, go with the original angles
target_angles[PITCH] = original_angles[PITCH];
}
}
}
}
}
}
}
/*
===============
@ -233,23 +230,23 @@ CG_OffsetFirstPersonView
===============
*/
void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
void CG_OffsetFirstPersonView(refEntity_t *pREnt, qboolean bUseWorldPosition)
{
float* origin;
centity_t* pCent;
dtiki_t* tiki;
int iTag;
int i;
int iMask;
vec3_t vDelta;
float mat[3][3];
vec3_t vOldOrigin;
vec3_t vStart, vEnd, vMins, vMaxs;
trace_t trace;
float *origin;
centity_t *pCent;
dtiki_t *tiki;
int iTag;
int i;
int iMask;
vec3_t vDelta;
float mat[3][3];
vec3_t vOldOrigin;
vec3_t vStart, vEnd, vMins, vMaxs;
trace_t trace;
VectorSet(vMins, -6, -6, -6);
VectorSet(vMaxs, 6, 6, 6);
//
//
//
@ -260,32 +257,28 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
tiki = cgi.R_Model_GetHandle(cgs.model_draw[pCent->currentState.modelindex]);
iTag = cgi.Tag_NumForName(tiki, "eyes bone");
if (iTag != -1)
{
if (bUseWorldPosition)
{
if (iTag != -1) {
if (bUseWorldPosition) {
orientation_t oHead;
float mat3[3][3];
vec3_t vHeadAng, vDelta;
float mat3[3][3];
vec3_t vHeadAng, vDelta;
VectorCopy(pCent->lerpOrigin, origin);
AxisCopy(pREnt->axis, mat);
oHead = cgi.TIKI_Orientation(pREnt, iTag);
for (i = 0; i < 3; i++ ) {
for (i = 0; i < 3; i++) {
VectorMA(origin, oHead.origin[i], mat[i], origin);
}
R_ConcatRotations(oHead.axis, mat, mat3);
MatrixToEulerAngles(mat3, vHeadAng);
AnglesSubtract(vHeadAng, cg.refdefViewAngles, vDelta);
VectorMA(cg.refdefViewAngles, cg.fEyeOffsetFrac, vDelta, cg.refdefViewAngles);
VectorCopy(vHeadAng, cg.refdefViewAngles);
}
else
{
} else {
orientation_t oHead;
vec3_t vHeadAng;
vec3_t vHeadAng;
VectorCopy(pCent->lerpOrigin, origin);
AxisCopy(pREnt->axis, mat);
@ -298,44 +291,35 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
cg.refdefViewAngles[2] += cg.predicted_player_state.fLeanAngle * 0.3;
}
}
else
{
} else {
cgi.DPrintf("CG_OffsetFirstPersonView warning: Couldn't find 'eyes bone' for player\n");
}
VectorCopy(origin, vOldOrigin);
if (bUseWorldPosition)
{
if (bUseWorldPosition) {
iMask = MASK_VIEWSOLID;
}
else
{
float fTargHeight;
float fHeightDelta, fHeightChange;
float fPhase, fVel;
} else {
float fTargHeight;
float fHeightDelta, fHeightChange;
float fPhase, fVel;
vec3_t vDelta;
vec3_t vPivotPoint;
vec3_t vForward, vLeft;
origin[0] = cg.predicted_player_state.origin[0];
origin[1] = cg.predicted_player_state.origin[1];
fTargHeight = cg.predicted_player_state.origin[2] + cg.predicted_player_state.viewheight;
origin[0] = cg.predicted_player_state.origin[0];
origin[1] = cg.predicted_player_state.origin[1];
fTargHeight = cg.predicted_player_state.origin[2] + cg.predicted_player_state.viewheight;
fHeightDelta = fTargHeight - cg.fCurrentViewHeight;
if (fabs(fHeightDelta) < 0.1 || !cg.fCurrentViewHeight)
{
if (fabs(fHeightDelta) < 0.1 || !cg.fCurrentViewHeight) {
cg.fCurrentViewHeight = fTargHeight;
}
else
{
} else {
if (fHeightDelta > 32.f) {
fHeightDelta = 32.f;
fHeightDelta = 32.f;
cg.fCurrentViewHeight = fTargHeight - 32.0;
}
else if (fHeightDelta < -32.f) {
fHeightDelta = -32.f;
} else if (fHeightDelta < -32.f) {
fHeightDelta = -32.f;
cg.fCurrentViewHeight = fTargHeight + 32.0;
}
@ -351,7 +335,7 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
cg.fCurrentViewHeight += fHeightChange;
}
origin[2] = cg.fCurrentViewHeight;
origin[2] = cg.fCurrentViewHeight;
vPivotPoint[0] = cg.refdefViewAngles[0];
vPivotPoint[1] = cg.refdefViewAngles[1];
vPivotPoint[2] = 0.0;
@ -359,16 +343,13 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
VectorCopy(origin, vStart);
if (cg.predicted_player_state.pm_type != PM_CLIMBWALL)
{
if (cg.predicted_player_state.pm_type != PM_CLIMBWALL) {
if (cg.refdefViewAngles[0] > 0.0) {
vStart[2] -= (cg.fCurrentViewHeight - cg.predicted_player_state.origin[2]) * 0.4;
}
else {
} else {
vStart[2] -= (cg.fCurrentViewHeight - cg.predicted_player_state.origin[2]) * 0.2;
}
}
else {
} else {
vStart[2] -= (cg.fCurrentViewHeight - cg.predicted_player_state.origin[2]) * 0.15;
}
@ -385,16 +366,14 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
VectorAdd(vStart, vEnd, origin);
}
if (cg.predicted_player_state.walking)
{
fVel = VectorLength(cg.predicted_player_state.velocity);
if (cg.predicted_player_state.walking) {
fVel = VectorLength(cg.predicted_player_state.velocity);
fPhase = fVel * 0.0015 + 0.9;
cg.fCurrentViewBobPhase += (cg.frametime / 1000.0 + cg.frametime / 1000.0) * M_PI * fPhase;
if (cg.fCurrentViewBobAmp) {
cg.fCurrentViewBobAmp = fVel;
}
else {
} else {
cg.fCurrentViewBobAmp = fVel * 0.5;
}
@ -403,25 +382,21 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
}
cg.fCurrentViewBobAmp *= (1.0 - fabs(cg.refdefViewAngles[0]) * (1.0 / 90.0) * 0.5) * 0.5;
}
else if (cg.fCurrentViewBobAmp > 0.0)
{
cg.fCurrentViewBobAmp -= (cg.frametime / 1000.0 * cg.fCurrentViewBobAmp)
+ (cg.frametime / 1000.0 * cg.fCurrentViewBobAmp);
} else if (cg.fCurrentViewBobAmp > 0.0) {
cg.fCurrentViewBobAmp -=
(cg.frametime / 1000.0 * cg.fCurrentViewBobAmp) + (cg.frametime / 1000.0 * cg.fCurrentViewBobAmp);
if (cg.fCurrentViewBobAmp < 0.1) {
cg.fCurrentViewBobAmp = 0.0;
}
}
if (cg.fCurrentViewBobAmp > 0.0)
{
if (cg.fCurrentViewBobAmp > 0.0) {
fPhase = sin(cg.fCurrentViewBobPhase) * cg.fCurrentViewBobAmp * 0.03;
if (fPhase > 16.0) {
fPhase = 16.0;
}
else if (fPhase < -16.0) {
} else if (fPhase < -16.0) {
fPhase = -16.0;
}
@ -432,8 +407,7 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
if (fPhase > 16.0) {
fPhase = 16.0;
}
else if (fPhase < -16.0) {
} else if (fPhase < -16.0) {
fPhase = -16.0;
}
@ -446,11 +420,13 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
vStart[0] = cg.predicted_player_state.origin[0];
vStart[1] = cg.predicted_player_state.origin[1];
vStart[2] = cg.predicted_player_state.origin[2] + cg.predicted_player_state.viewheight;
vEnd[0] = cg.predicted_player_state.origin[0];
vEnd[1] = cg.predicted_player_state.origin[1];
vEnd[2] = origin[2];
vEnd[0] = cg.predicted_player_state.origin[0];
vEnd[1] = cg.predicted_player_state.origin[1];
vEnd[2] = origin[2];
CG_Trace(&trace, vStart, vMins, vMaxs, vEnd, cg.snap->ps.clientNum, iMask, qfalse, qtrue, "FirstPerson Height Check");
CG_Trace(
&trace, vStart, vMins, vMaxs, vEnd, cg.snap->ps.clientNum, iMask, qfalse, qtrue, "FirstPerson Height Check"
);
VectorCopy(trace.endpos, vStart);
vEnd[0] = origin[0];
@ -462,8 +438,7 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
VectorSubtract(origin, vOldOrigin, vDelta);
VectorAdd(pREnt->origin, vDelta, pREnt->origin);
if (!bUseWorldPosition)
{
if (!bUseWorldPosition) {
VectorCopy(cg.refdefViewAngles, vDelta);
vDelta[0] *= 0.5;
vDelta[2] *= 0.75;
@ -471,10 +446,7 @@ void CG_OffsetFirstPersonView(refEntity_t* pREnt, qboolean bUseWorldPosition)
AngleVectorsLeft(vDelta, mat[0], mat[1], mat[2]);
CG_CalcViewModelMovement(
cg.fCurrentViewBobPhase,
cg.fCurrentViewBobAmp,
cg.predicted_player_state.velocity,
vDelta
cg.fCurrentViewBobPhase, cg.fCurrentViewBobAmp, cg.predicted_player_state.velocity, vDelta
);
VectorMA(pREnt->origin, vDelta[0], mat[0], pREnt->origin);
@ -492,20 +464,20 @@ CG_CalcFov
Fixed fov at intermissions, otherwise account for fov variable and zooms.
====================
*/
#define WAVE_AMPLITUDE 1
#define WAVE_FREQUENCY 0.4
#define WAVE_AMPLITUDE 1
#define WAVE_FREQUENCY 0.4
static int CG_CalcFov( void )
static int CG_CalcFov(void)
{
float x;
float phase;
float v;
int contents;
float fov_x, fov_y;
int inwater;
float x;
float phase;
float v;
int contents;
float fov_x, fov_y;
int inwater;
fov_x = cg.camera_fov;
x = cg.refdef.width / tan(fov_x / 360 * M_PI);
x = cg.refdef.width / tan(fov_x / 360 * M_PI);
fov_y = atan2(cg.refdef.height, x);
fov_y = fov_y * 360 / M_PI;
@ -513,24 +485,21 @@ static int CG_CalcFov( void )
contents = CG_PointContents(cg.refdef.vieworg, -1);
if (contents & (CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA)) {
phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;
v = WAVE_AMPLITUDE * sin(phase);
v = WAVE_AMPLITUDE * sin(phase);
fov_x += v;
fov_y -= v;
inwater = qtrue;
}
else {
} else {
inwater = qfalse;
}
// set it
cg.refdef.fov_x = fov_x;
cg.refdef.fov_y = fov_y;
cg.refdef.fov_x = fov_x;
cg.refdef.fov_y = fov_y;
cg.zoomSensitivity = cg.refdef.fov_y / 75.0;
return inwater;
}
/*
===============
CG_CalcViewValues
@ -540,8 +509,8 @@ Sets cg.refdef view values
*/
static int CG_CalcViewValues(void)
{
playerState_t* ps;
float SoundAngles[3];
playerState_t *ps;
float SoundAngles[3];
memset(&cg.refdef, 0, sizeof(cg.refdef));
@ -554,7 +523,7 @@ static int CG_CalcViewValues(void)
cg.refdef.farplane_cull = cg.farplane_cull;
// setup portal sky
cg.refdef.sky_alpha = cg.sky_alpha;
cg.refdef.sky_alpha = cg.sky_alpha;
cg.refdef.sky_portal = cg.sky_portal;
memcpy(cg.refdef.sky_axis, cg.sky_axis, sizeof(cg.sky_axis));
VectorCopy(cg.sky_origin, cg.refdef.sky_origin);
@ -564,47 +533,37 @@ static int CG_CalcViewValues(void)
VectorCopy(ps->origin, cg.refdef.vieworg);
VectorCopy(ps->viewangles, cg.refdefViewAngles);
if (cg.snap->ps.stats[STAT_HEALTH] > 0)
{
if (cg.snap->ps.stats[STAT_HEALTH] > 0) {
VectorSubtract(cg.refdefViewAngles, cg.predicted_player_state.damage_angles, cg.refdefViewAngles);
cg.refdefViewAngles[0] += cg.viewkick[0];
cg.refdefViewAngles[1] += cg.viewkick[1];
if (cg.viewkick[0] || cg.viewkick[1])
{
int i;
if (cg.viewkick[0] || cg.viewkick[1]) {
int i;
float fDecay;
for (i = 0; i < 2; i++)
{
for (i = 0; i < 2; i++) {
fDecay = cg.viewkick[i] * cg.viewkickRecenter;
if (fDecay > cg.viewkickMaxDecay)
{
if (fDecay > cg.viewkickMaxDecay) {
fDecay = cg.viewkickMaxDecay;
}
else if (fDecay < -cg.viewkickMaxDecay) {
} else if (fDecay < -cg.viewkickMaxDecay) {
fDecay = -cg.viewkickMaxDecay;
}
if (fabs(fDecay) < cg.viewkickMinDecay)
{
if (fabs(fDecay) < cg.viewkickMinDecay) {
if (fDecay > 0.0) {
fDecay = cg.viewkickMinDecay;
}
else {
} else {
fDecay = -cg.viewkickMinDecay;
}
}
if (cg.viewkick[i] > 0.0)
{
if (cg.viewkick[i] > 0.0) {
cg.viewkick[i] -= fDecay * (float)cg.frametime / 1000.0;
if (cg.viewkick[i] < 0.0) {
cg.viewkick[i] = 0.0;
}
}
else
{
} else {
cg.viewkick[i] -= fDecay * (float)cg.frametime / 1000.0;
if (cg.viewkick[i] > 0.0) {
cg.viewkick[i] = 0.0;
@ -617,19 +576,15 @@ static int CG_CalcViewValues(void)
// FIXME: fffx screen shake on win32 builds?
// add error decay
if (cg_errorDecay->value > 0)
{
int t;
float f;
if (cg_errorDecay->value > 0) {
int t;
float f;
t = cg.time - cg.predictedErrorTime;
f = (cg_errorDecay->value - t) / cg_errorDecay->value;
if (f > 0 && f < 1)
{
if (f > 0 && f < 1) {
VectorMA(cg.refdef.vieworg, f, cg.predictedError, cg.refdef.vieworg);
}
else
{
} else {
cg.predictedErrorTime = 0;
}
}
@ -651,23 +606,20 @@ static int CG_CalcViewValues(void)
// decide on third person view
cg.renderingThirdPerson = cg_3rd_person->integer;
if (cg.renderingThirdPerson)
{
if (cg.renderingThirdPerson) {
// back away from character
CG_OffsetThirdPersonView();
}
// if we are in a camera view, we take our audio cues directly from the camera
if (ps->pm_flags & PMF_CAMERA_VIEW)
{
if (ps->pm_flags & PMF_CAMERA_VIEW) {
// Set the aural position to that of the camera
VectorCopy(cg.camera_origin, cg.refdef.vieworg);
// Set the aural axis to the camera's angles
VectorCopy(cg.camera_angles, cg.refdefViewAngles);
if (ps->camera_posofs[0] || ps->camera_posofs[1] || ps->camera_posofs[2])
{
if (ps->camera_posofs[0] || ps->camera_posofs[1] || ps->camera_posofs[2]) {
vec3_t vAxis[3], vOrg;
AnglesToAxis(cg.refdefViewAngles, vAxis);
MatrixTransformVector(ps->camera_posofs, vAxis, vOrg);
@ -690,21 +642,21 @@ static int CG_CalcViewValues(void)
return CG_CalcFov();
}
void CG_EyePosition(vec3_t* o_vPos)
void CG_EyePosition(vec3_t *o_vPos)
{
(*o_vPos)[0] = cg.playerHeadPos[0];
(*o_vPos)[1] = cg.playerHeadPos[1];
(*o_vPos)[2] = cg.playerHeadPos[2];
}
void CG_EyeOffset(vec3_t* o_vOfs)
void CG_EyeOffset(vec3_t *o_vOfs)
{
(*o_vOfs)[0] = cg.playerHeadPos[0] - cg.predicted_player_state.origin[0];
(*o_vOfs)[1] = cg.playerHeadPos[1] - cg.predicted_player_state.origin[1];
(*o_vOfs)[2] = cg.playerHeadPos[2] - cg.predicted_player_state.origin[2];
}
void CG_EyeAngles(vec3_t* o_vAngles)
void CG_EyeAngles(vec3_t *o_vAngles)
{
(*o_vAngles)[0] = cg.refdefViewAngles[0];
(*o_vAngles)[1] = cg.refdefViewAngles[1];
@ -730,10 +682,10 @@ CG_DrawActiveFrame
Generates and draws a game scene and status information at the given time.
=================
*/
void CG_DrawActiveFrame( int serverTime, int frameTime, stereoFrame_t stereoView, qboolean demoPlayback )
void CG_DrawActiveFrame(int serverTime, int frameTime, stereoFrame_t stereoView, qboolean demoPlayback)
{
cg.time = serverTime;
cg.frametime = frameTime;
cg.time = serverTime;
cg.frametime = frameTime;
cg.demoPlayback = demoPlayback;
// any looped sounds will be respecified as entities
@ -748,8 +700,7 @@ void CG_DrawActiveFrame( int serverTime, int frameTime, stereoFrame_t stereoView
// if we haven't received any snapshots yet, all
// we can draw is the information screen
if (!cg.snap || (cg.snap->snapFlags & SNAPFLAG_NOT_ACTIVE))
{
if (!cg.snap || (cg.snap->snapFlags & SNAPFLAG_NOT_ACTIVE)) {
return;
}
@ -758,18 +709,16 @@ void CG_DrawActiveFrame( int serverTime, int frameTime, stereoFrame_t stereoView
// set cg.frameInterpolation
if (cg.nextSnap && r_lerpmodels->integer) {
int delta;
int delta;
delta = (cg.nextSnap->serverTime - cg.snap->serverTime);
if (delta == 0) {
cg.frameInterpolation = 0;
}
else {
} else {
cg.frameInterpolation = (float)(cg.time - cg.snap->serverTime) / delta;
}
}
else {
cg.frameInterpolation = 0; // actually, it should never be used, because
} else {
cg.frameInterpolation = 0; // actually, it should never be used, because
// no entities should be marked as interpolating
}
@ -780,19 +729,15 @@ void CG_DrawActiveFrame( int serverTime, int frameTime, stereoFrame_t stereoView
CG_CalcViewValues();
// display the intermission
if (cg.snap->ps.pm_flags & PMF_INTERMISSION)
{
if (cg.snap->ps.pm_flags & PMF_INTERMISSION) {
if (cgs.gametype != GT_SINGLE_PLAYER) {
CG_ScoresDown_f();
}
else if (cg.bIntermissionDisplay)
{
if (cg.nextSnap)
{
} else if (cg.bIntermissionDisplay) {
if (cg.nextSnap) {
if (cgi.Cvar_Get("g_success", "", 0)->integer) {
cgi.UI_ShowMenu("StatsScreen_Success", qfalse);
cgi.UI_ShowMenu("StatsScreen_Success", qfalse);
} else {
cgi.UI_ShowMenu("StatsScreen_Failed", qfalse);
cgi.UI_ShowMenu("StatsScreen_Failed", qfalse);
}
}
} else {
@ -800,14 +745,10 @@ void CG_DrawActiveFrame( int serverTime, int frameTime, stereoFrame_t stereoView
}
cg.bIntermissionDisplay = qtrue;
}
else if (cg.bIntermissionDisplay)
{
} else if (cg.bIntermissionDisplay) {
if (cgs.gametype != GT_SINGLE_PLAYER) {
CG_ScoresUp_f();
}
else
{
} else {
if (cgi.Cvar_Get("g_success", "", 0)->integer) {
cgi.UI_ShowMenu("StatsScreen_Success", qfalse);
} else {
@ -819,9 +760,8 @@ void CG_DrawActiveFrame( int serverTime, int frameTime, stereoFrame_t stereoView
}
// build the render lists
if (!cg.hyperspace)
{
CG_AddPacketEntities(); // after calcViewValues, so predicted player state is correct
if (!cg.hyperspace) {
CG_AddPacketEntities(); // after calcViewValues, so predicted player state is correct
CG_AddMarks();
}
@ -841,8 +781,9 @@ void CG_DrawActiveFrame( int serverTime, int frameTime, stereoFrame_t stereoView
CG_UpdateTestEmitter();
CG_AddPendingEffects();
if (!cg_hidetempmodels->integer)
if (!cg_hidetempmodels->integer) {
CG_AddTempModels();
}
if (vss_draw->integer) {
CG_AddVSSSources();
@ -860,9 +801,7 @@ void CG_DrawActiveFrame( int serverTime, int frameTime, stereoFrame_t stereoView
// actually issue the rendering calls
CG_DrawActive(stereoView);
if (cg_stats->integer)
{
if (cg_stats->integer) {
cgi.Printf("cg.clientFrame:%i\n", cg.clientFrame);
}
}

View file

@ -26,8 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_local.h"
#include "tiki.h"
static const char* AnimPrefixList[] =
{
static const char *AnimPrefixList[] = {
"",
"papers",
"colt45",
@ -79,11 +78,9 @@ static const char* AnimPrefixList[] =
"minedetectoraxis",
"detonator",
"kar98mortar",
"PIAT"
};
"PIAT"};
enum animPrefix_e
{
enum animPrefix_e {
WPREFIX_NONE,
WPREFIX_PAPERS,
WPREFIX_COLT45,
@ -102,191 +99,224 @@ enum animPrefix_e
WPREFIX_BAZOOKA,
WPREFIX_PANZERSCHRECK,
WPREFIX_SHOTGUN,
WPREFIX_UNARMED,
//
// Team Assault and Team Tactics weapons
WPREFIX_MG42_PORTABLE,
WPREFIX_WEBLEY,
WPREFIX_NAGANTREV,
WPREFIX_BERETTA,
WPREFIX_ENFIELD,
WPREFIX_SVT,
WPREFIX_MOSIN,
WPREFIX_G43,
WPREFIX_ENFIELDL42A,
WPREFIX_CARCANO,
WPREFIX_DELISLE,
WPREFIX_STEN,
WPREFIX_PPSH,
WPREFIX_MOSCHETTO,
WPREFIX_FG42,
WPREFIX_VICKERS,
WPREFIX_BREDA,
WPREFIX_F1_GRENADE,
WPREFIX_MILLS_GRENADE,
WPREFIX_NEBELHANDGRANATE,
WPREFIX_M18_SMOKE_GRENADE,
WPREFIX_RDG1_SMOKE_GRENADE,
WPREFIX_UNARMED,
//
// Team Assault and Team Tactics weapons
WPREFIX_MG42_PORTABLE,
WPREFIX_WEBLEY,
WPREFIX_NAGANTREV,
WPREFIX_BERETTA,
WPREFIX_ENFIELD,
WPREFIX_SVT,
WPREFIX_MOSIN,
WPREFIX_G43,
WPREFIX_ENFIELDL42A,
WPREFIX_CARCANO,
WPREFIX_DELISLE,
WPREFIX_STEN,
WPREFIX_PPSH,
WPREFIX_MOSCHETTO,
WPREFIX_FG42,
WPREFIX_VICKERS,
WPREFIX_BREDA,
WPREFIX_F1_GRENADE,
WPREFIX_MILLS_GRENADE,
WPREFIX_NEBELHANDGRANATE,
WPREFIX_M18_SMOKE_GRENADE,
WPREFIX_RDG1_SMOKE_GRENADE,
WPREFIX_BOMBA,
WPREFIX_BOMBA_BREDA,
WPREFIX_MINE,
WPREFIX_MINE_DETECTOR,
WPREFIX_MINE_DETECTOR_AXIS,
WPREFIX_DETONATOR,
WPREFIX_KAR98_MORTAR,
WPREFIX_PIAT
WPREFIX_BOMBA_BREDA,
WPREFIX_MINE,
WPREFIX_MINE_DETECTOR,
WPREFIX_MINE_DETECTOR_AXIS,
WPREFIX_DETONATOR,
WPREFIX_KAR98_MORTAR,
WPREFIX_PIAT
};
int CG_GetVMAnimPrefixIndex()
{
const char* szWeaponName;
int iWeaponClass;
const char *szWeaponName;
int iWeaponClass;
iWeaponClass = cg.snap->ps.stats[STAT_EQUIPPED_WEAPON];
szWeaponName = CG_ConfigString(CS_WEAPONS + cg.snap->ps.activeItems[1]);
if (iWeaponClass & WEAPON_CLASS_ANY_ITEM)
{
if (!Q_stricmp(szWeaponName, "Papers"))
return WPREFIX_PAPERS;
if (!Q_stricmp(szWeaponName, "Packed MG42 Turret"))
return WPREFIX_MG42_PORTABLE;
}
else if (iWeaponClass & WEAPON_CLASS_PISTOL)
{
if (!Q_stricmp(szWeaponName, "Colt 45"))
if (iWeaponClass & WEAPON_CLASS_ANY_ITEM) {
if (!Q_stricmp(szWeaponName, "Papers")) {
return WPREFIX_PAPERS;
}
if (!Q_stricmp(szWeaponName, "Packed MG42 Turret")) {
return WPREFIX_MG42_PORTABLE;
}
} else if (iWeaponClass & WEAPON_CLASS_PISTOL) {
if (!Q_stricmp(szWeaponName, "Colt 45")) {
return WPREFIX_COLT45;
if (!Q_stricmp(szWeaponName, "Walther P38"))
}
if (!Q_stricmp(szWeaponName, "Walther P38")) {
return WPREFIX_P38;
if (!Q_stricmp(szWeaponName, "Hi-Standard Silenced"))
return WPREFIX_HISTANDARD;
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "Webley Revolver"))
return WPREFIX_WEBLEY;
if (!Q_stricmp(szWeaponName, "Nagant Revolver"))
return WPREFIX_NAGANTREV;
if (!Q_stricmp(szWeaponName, "Beretta"))
return WPREFIX_BERETTA;
return WPREFIX_COLT45;
}
else if (iWeaponClass & WEAPON_CLASS_RIFLE)
{
if (!Q_stricmp(szWeaponName, "M1 Garand"))
return WPREFIX_GARAND;
if (!Q_stricmp(szWeaponName, "Mauser KAR 98K"))
return WPREFIX_KAR98;
if (!Q_stricmp(szWeaponName, "KAR98 - Sniper"))
return WPREFIX_KAR98SNIPER;
if (!Q_stricmp(szWeaponName, "Springfield '03 Sniper"))
return WPREFIX_SPRINGFIELD;
}
if (!Q_stricmp(szWeaponName, "Hi-Standard Silenced")) {
return WPREFIX_HISTANDARD;
}
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "Lee-Enfield"))
return WPREFIX_SPRINGFIELD;
if (!Q_stricmp(szWeaponName, "SVT 40"))
return WPREFIX_SVT;
if (!Q_stricmp(szWeaponName, "Mosin Nagant Rifle"))
return WPREFIX_MOSIN;
if (!Q_stricmp(szWeaponName, "G 43"))
return WPREFIX_G43;
if (!Q_stricmp(szWeaponName, "Enfield L42A1"))
return WPREFIX_ENFIELD;
if (!Q_stricmp(szWeaponName, "Carcano"))
return WPREFIX_CARCANO;
if (!Q_stricmp(szWeaponName, "DeLisle"))
return WPREFIX_DELISLE;
if (!Q_stricmp(szWeaponName, "Webley Revolver")) {
return WPREFIX_WEBLEY;
}
if (!Q_stricmp(szWeaponName, "Nagant Revolver")) {
return WPREFIX_NAGANTREV;
}
if (!Q_stricmp(szWeaponName, "Beretta")) {
return WPREFIX_BERETTA;
}
return WPREFIX_COLT45;
} else if (iWeaponClass & WEAPON_CLASS_RIFLE) {
if (!Q_stricmp(szWeaponName, "M1 Garand")) {
return WPREFIX_GARAND;
}
if (!Q_stricmp(szWeaponName, "Mauser KAR 98K")) {
return WPREFIX_KAR98;
}
if (!Q_stricmp(szWeaponName, "KAR98 - Sniper")) {
return WPREFIX_KAR98SNIPER;
}
if (!Q_stricmp(szWeaponName, "Springfield '03 Sniper")) {
return WPREFIX_SPRINGFIELD;
}
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "Lee-Enfield")) {
return WPREFIX_SPRINGFIELD;
}
if (!Q_stricmp(szWeaponName, "SVT 40")) {
return WPREFIX_SVT;
}
if (!Q_stricmp(szWeaponName, "Mosin Nagant Rifle")) {
return WPREFIX_MOSIN;
}
if (!Q_stricmp(szWeaponName, "G 43")) {
return WPREFIX_G43;
}
if (!Q_stricmp(szWeaponName, "Enfield L42A1")) {
return WPREFIX_ENFIELD;
}
if (!Q_stricmp(szWeaponName, "Carcano")) {
return WPREFIX_CARCANO;
}
if (!Q_stricmp(szWeaponName, "DeLisle")) {
return WPREFIX_DELISLE;
}
return WPREFIX_GARAND;
}
else if (iWeaponClass & WEAPON_CLASS_SMG)
{
if (!Q_stricmp(szWeaponName, "Thompson"))
} else if (iWeaponClass & WEAPON_CLASS_SMG) {
if (!Q_stricmp(szWeaponName, "Thompson")) {
return WPREFIX_THOMPSON;
if (!Q_stricmp(szWeaponName, "MP40"))
return WPREFIX_MP40;
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "Sten Mark II"))
return WPREFIX_STEN;
if (!Q_stricmp(szWeaponName, "PPSH SMG"))
return WPREFIX_PPSH;
if (!Q_stricmp(szWeaponName, "Moschetto"))
return WPREFIX_MOSCHETTO;
}
if (!Q_stricmp(szWeaponName, "MP40")) {
return WPREFIX_MP40;
}
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "Sten Mark II")) {
return WPREFIX_STEN;
}
if (!Q_stricmp(szWeaponName, "PPSH SMG")) {
return WPREFIX_PPSH;
}
if (!Q_stricmp(szWeaponName, "Moschetto")) {
return WPREFIX_MOSCHETTO;
}
return WPREFIX_THOMPSON;
}
else if (iWeaponClass & WEAPON_CLASS_MG)
{
if (!Q_stricmp(szWeaponName, "BAR"))
} else if (iWeaponClass & WEAPON_CLASS_MG) {
if (!Q_stricmp(szWeaponName, "BAR")) {
return WPREFIX_BAR;
if (!Q_stricmp(szWeaponName, "StG 44"))
return WPREFIX_MP44;
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "FG 42"))
return WPREFIX_MP44;
if (!Q_stricmp(szWeaponName, "Vickers-Berthier"))
return WPREFIX_MP44;
if (!Q_stricmp(szWeaponName, "Breda"))
return WPREFIX_MP44;
}
if (!Q_stricmp(szWeaponName, "StG 44")) {
return WPREFIX_MP44;
}
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "FG 42")) {
return WPREFIX_MP44;
}
if (!Q_stricmp(szWeaponName, "Vickers-Berthier")) {
return WPREFIX_MP44;
}
if (!Q_stricmp(szWeaponName, "Breda")) {
return WPREFIX_MP44;
}
return WPREFIX_BAR;
}
else if (iWeaponClass & WEAPON_CLASS_GRENADE)
{
if (!Q_stricmp(szWeaponName, "Frag Grenade"))
} else if (iWeaponClass & WEAPON_CLASS_GRENADE) {
if (!Q_stricmp(szWeaponName, "Frag Grenade")) {
return WPREFIX_FRAGGRENADE;
if (!Q_stricmp(szWeaponName, "Stielhandgranate"))
return WPREFIX_STIELHANDGRANATE;
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "F1 Grenade"))
return WPREFIX_F1_GRENADE;
if (!Q_stricmp(szWeaponName, "Mills Grenade"))
return WPREFIX_MILLS_GRENADE;
if (!Q_stricmp(szWeaponName, "Nebelhandgranate"))
}
if (!Q_stricmp(szWeaponName, "Stielhandgranate")) {
return WPREFIX_STIELHANDGRANATE;
}
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "F1 Grenade")) {
return WPREFIX_F1_GRENADE;
}
if (!Q_stricmp(szWeaponName, "Mills Grenade")) {
return WPREFIX_MILLS_GRENADE;
}
if (!Q_stricmp(szWeaponName, "Nebelhandgranate")) {
return WPREFIX_NEBELHANDGRANATE;
if (!Q_stricmp(szWeaponName, "M18 Smoke Grenade"))
return WPREFIX_M18_SMOKE_GRENADE;
if (!Q_stricmp(szWeaponName, "RDG-1 Smoke Grenade"))
return WPREFIX_RDG1_SMOKE_GRENADE;
if (!Q_stricmp(szWeaponName, "Bomba A Mano"))
}
if (!Q_stricmp(szWeaponName, "M18 Smoke Grenade")) {
return WPREFIX_M18_SMOKE_GRENADE;
}
if (!Q_stricmp(szWeaponName, "RDG-1 Smoke Grenade")) {
return WPREFIX_RDG1_SMOKE_GRENADE;
}
if (!Q_stricmp(szWeaponName, "Bomba A Mano")) {
return WPREFIX_BOMBA;
if (!Q_stricmp(szWeaponName, "Bomba A Mano Breda"))
return WPREFIX_BOMBA_BREDA;
if (!Q_stricmp(szWeaponName, "LandmineAllies"))
return WPREFIX_MINE;
if (!Q_stricmp(szWeaponName, "LandmineAxis"))
return WPREFIX_MINE;
if (!Q_stricmp(szWeaponName, "Minensuchgerat"))
return WPREFIX_MINE_DETECTOR_AXIS;
if (!Q_stricmp(szWeaponName, "Minedetector"))
return WPREFIX_MINE_DETECTOR;
}
if (!Q_stricmp(szWeaponName, "Bomba A Mano Breda")) {
return WPREFIX_BOMBA_BREDA;
}
if (!Q_stricmp(szWeaponName, "LandmineAllies")) {
return WPREFIX_MINE;
}
if (!Q_stricmp(szWeaponName, "LandmineAxis")) {
return WPREFIX_MINE;
}
if (!Q_stricmp(szWeaponName, "Minensuchgerat")) {
return WPREFIX_MINE_DETECTOR_AXIS;
}
if (!Q_stricmp(szWeaponName, "Minedetector")) {
return WPREFIX_MINE_DETECTOR;
}
return WPREFIX_FRAGGRENADE;
}
else if (iWeaponClass & WEAPON_CLASS_HEAVY)
{
if (!Q_stricmp(szWeaponName, "Bazooka"))
} else if (iWeaponClass & WEAPON_CLASS_HEAVY) {
if (!Q_stricmp(szWeaponName, "Bazooka")) {
return WPREFIX_BAZOOKA;
if (!Q_stricmp(szWeaponName, "Panzerschreck"))
}
if (!Q_stricmp(szWeaponName, "Panzerschreck")) {
return WPREFIX_PANZERSCHRECK;
if (!Q_stricmp(szWeaponName, "Shotgun"))
return WPREFIX_SHOTGUN;
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "PIAT"))
return WPREFIX_PIAT;
}
if (!Q_stricmp(szWeaponName, "Shotgun")) {
return WPREFIX_SHOTGUN;
}
//
// Team Assault and Team Tactics
//
if (!Q_stricmp(szWeaponName, "PIAT")) {
return WPREFIX_PIAT;
}
return WPREFIX_BAZOOKA;
}
@ -294,63 +324,55 @@ int CG_GetVMAnimPrefixIndex()
return WPREFIX_UNARMED;
}
void CG_ViewModelAnimation(refEntity_t* pModel)
void CG_ViewModelAnimation(refEntity_t *pModel)
{
int i;
int iAnimFlags;
float fCrossblendTime, fCrossblendFrac, fCrossblendAmount;
float fAnimLength;
int iAnimPrefixIndex;
const char* pszAnimSuffix;
char szAnimName[MAX_QPATH];
dtiki_t* pTiki;
qboolean bAnimChanged;
int i;
int iAnimFlags;
float fCrossblendTime, fCrossblendFrac, fCrossblendAmount;
float fAnimLength;
int iAnimPrefixIndex;
const char *pszAnimSuffix;
char szAnimName[MAX_QPATH];
dtiki_t *pTiki;
qboolean bAnimChanged;
fCrossblendFrac = 0.0;
bAnimChanged = 0;
pTiki = pModel->tiki;
bAnimChanged = 0;
pTiki = pModel->tiki;
if (cgi.anim->g_iLastEquippedWeaponStat == cg.snap->ps.stats[STAT_EQUIPPED_WEAPON]
&& !strcmp(cgi.anim->g_szLastActiveItem, CG_ConfigString(CS_WEAPONS + cg.snap->ps.activeItems[1])))
{
&& !strcmp(cgi.anim->g_szLastActiveItem, CG_ConfigString(CS_WEAPONS + cg.snap->ps.activeItems[1]))) {
iAnimPrefixIndex = cgi.anim->g_iLastAnimPrefixIndex;
}
else
{
iAnimPrefixIndex = CG_GetVMAnimPrefixIndex();
} else {
iAnimPrefixIndex = CG_GetVMAnimPrefixIndex();
cgi.anim->g_iLastEquippedWeaponStat = cg.snap->ps.stats[STAT_EQUIPPED_WEAPON];
strcpy(cgi.anim->g_szLastActiveItem, CG_ConfigString(CS_WEAPONS + cg.snap->ps.activeItems[1]));
cgi.anim->g_iLastAnimPrefixIndex = iAnimPrefixIndex;
bAnimChanged = qtrue;
bAnimChanged = qtrue;
}
if (cgi.anim->g_iLastVMAnim == -1)
{
if (cgi.anim->g_iLastVMAnim == -1) {
sprintf(szAnimName, "%s_idle", AnimPrefixList[iAnimPrefixIndex]);
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index = cgi.Anim_NumForName(pTiki, szAnimName);
if (cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index == -1)
{
if (cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index == -1) {
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index = cgi.Anim_NumForName(pTiki, "idle");
cgi.DPrintf("Warning: Couldn't find view model animation %s\n", szAnimName);
}
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].time = 0.0;
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].time = 0.0;
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].weight = 1.0;
cgi.anim->g_iLastVMAnim = 0;
cgi.anim->g_iLastVMAnim = 0;
}
if (cg.snap->ps.iViewModelAnimChanged != cgi.anim->g_iLastVMAnimChanged)
{
bAnimChanged = qtrue;
cgi.anim->g_iLastVMAnim = cg.snap->ps.iViewModelAnim;
if (cg.snap->ps.iViewModelAnimChanged != cgi.anim->g_iLastVMAnimChanged) {
bAnimChanged = qtrue;
cgi.anim->g_iLastVMAnim = cg.snap->ps.iViewModelAnim;
cgi.anim->g_iLastVMAnimChanged = cg.snap->ps.iViewModelAnimChanged;
}
if (bAnimChanged)
{
switch (cgi.anim->g_iLastVMAnim)
{
if (bAnimChanged) {
switch (cgi.anim->g_iLastVMAnim) {
case VM_ANIM_CHARGE:
pszAnimSuffix = "charge";
break;
@ -381,39 +403,35 @@ void CG_ViewModelAnimation(refEntity_t* pModel)
case VM_ANIM_LADDERSTEP:
pszAnimSuffix = "ladderstep";
break;
case VM_ANIM_IDLE_0:
pszAnimSuffix = "idle0";
break;
case VM_ANIM_IDLE_1:
pszAnimSuffix = "idle1";
break;
case VM_ANIM_IDLE_2:
pszAnimSuffix = "idle2";
break;
case VM_ANIM_DISABLED:
pszAnimSuffix = "disabled";
break;
case VM_ANIM_IDLE_0:
pszAnimSuffix = "idle0";
break;
case VM_ANIM_IDLE_1:
pszAnimSuffix = "idle1";
break;
case VM_ANIM_IDLE_2:
pszAnimSuffix = "idle2";
break;
case VM_ANIM_DISABLED:
pszAnimSuffix = "disabled";
break;
default:
case VM_ANIM_IDLE:
pszAnimSuffix = "idle";
break;
case VM_ANIM_IDLE:
pszAnimSuffix = "idle";
break;
}
sprintf(szAnimName, "%s_%s", AnimPrefixList[iAnimPrefixIndex], pszAnimSuffix);
fCrossblendTime = cgi.Anim_CrossblendTime(pTiki, cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index);
fCrossblendAmount = cgi.anim->g_iCurrentVMDuration / 1000.0;
if (fCrossblendAmount < fCrossblendTime && fCrossblendAmount > 0.0)
{
if (fCrossblendAmount < fCrossblendTime && fCrossblendAmount > 0.0) {
fCrossblendFrac = fCrossblendAmount / fCrossblendTime;
for (i = 0; i < MAX_FRAMEINFOS; ++i)
{
if (cgi.anim->g_VMFrameInfo[i].weight)
{
for (i = 0; i < MAX_FRAMEINFOS; ++i) {
if (cgi.anim->g_VMFrameInfo[i].weight) {
if (i == cgi.anim->g_iCurrentVMAnimSlot) {
cgi.anim->g_VMFrameInfo[i].weight = fCrossblendFrac;
}
else {
} else {
cgi.anim->g_VMFrameInfo[i].weight *= (1.0 - fCrossblendFrac);
}
}
@ -423,94 +441,75 @@ void CG_ViewModelAnimation(refEntity_t* pModel)
cgi.anim->g_iCurrentVMAnimSlot = (cgi.anim->g_iCurrentVMAnimSlot + 1) % MAX_FRAMEINFOS;
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index = cgi.Anim_NumForName(pTiki, szAnimName);
if (cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index == -1)
{
if (cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index == -1) {
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index = cgi.Anim_NumForName(pTiki, "idle");
cgi.DPrintf("Warning: Couldn't find view model animation %s\n", szAnimName);
}
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].time = 0.0;
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].time = 0.0;
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].weight = 1.0;
cgi.anim->g_iCurrentVMDuration = 0;
cgi.anim->g_iCurrentVMDuration = 0;
fCrossblendTime = cgi.Anim_CrossblendTime(pTiki, cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index);
if (!fCrossblendTime)
{
for (i = 0; i < MAX_FRAMEINFOS; ++i)
{
if (!fCrossblendTime) {
for (i = 0; i < MAX_FRAMEINFOS; ++i) {
if (i != cgi.anim->g_iCurrentVMAnimSlot) {
cgi.anim->g_VMFrameInfo[i].weight = 0.0;
}
}
cgi.anim->g_bCrossblending = qfalse;
}
else
{
} else {
cgi.anim->g_bCrossblending = qtrue;
}
}
cgi.anim->g_iCurrentVMDuration += cg.frametime;
if (cgi.anim->g_bCrossblending)
{
if (cgi.anim->g_bCrossblending) {
fCrossblendTime = cgi.Anim_CrossblendTime(pTiki, cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index);
fCrossblendAmount = cgi.anim->g_iCurrentVMDuration / 1000.0;
if (fCrossblendAmount >= fCrossblendTime || fCrossblendAmount <= 0.0)
{
if (fCrossblendAmount >= fCrossblendTime || fCrossblendAmount <= 0.0) {
// clear crossblend values
for (i = 0; i < MAX_FRAMEINFOS; ++i)
{
for (i = 0; i < MAX_FRAMEINFOS; ++i) {
if (i != cgi.anim->g_iCurrentVMAnimSlot) {
cgi.anim->g_VMFrameInfo[i].weight = 0.0;
}
}
cgi.anim->g_bCrossblending = qfalse;
}
else {
} else {
fCrossblendFrac = fCrossblendAmount / fCrossblendTime;
}
}
for (i = 0; i < MAX_FRAMEINFOS; ++i)
{
if (!cgi.anim->g_VMFrameInfo[i].weight)
{
for (i = 0; i < MAX_FRAMEINFOS; ++i) {
if (!cgi.anim->g_VMFrameInfo[i].weight) {
// clear the weight values of the ref entity
pModel->frameInfo[i].index = 0;
pModel->frameInfo[i].time = 0.0;
pModel->frameInfo[i].index = 0;
pModel->frameInfo[i].time = 0.0;
pModel->frameInfo[i].weight = 0.0;
}
else
{
} else {
fAnimLength = cgi.Anim_Time(pTiki, cgi.anim->g_VMFrameInfo[i].index);
cgi.anim->g_VMFrameInfo[i].time += cg.frametime / 1000.0;
if (cgi.anim->g_VMFrameInfo[i].time > fAnimLength)
{
if (cgi.anim->g_VMFrameInfo[i].time > fAnimLength) {
if (cgi.Anim_Flags(pTiki, cgi.anim->g_VMFrameInfo[i].index) & TAF_DELTADRIVEN) {
cgi.anim->g_VMFrameInfo[i].time -= fAnimLength;
}
else {
} else {
cgi.anim->g_VMFrameInfo[i].time = fAnimLength;
}
}
pModel->frameInfo[i].index = cgi.anim->g_VMFrameInfo[i].index;
pModel->frameInfo[i].time = cgi.anim->g_VMFrameInfo[i].time;
pModel->frameInfo[i].time = cgi.anim->g_VMFrameInfo[i].time;
if (cgi.anim->g_bCrossblending)
{
if (cgi.anim->g_bCrossblending) {
if (i == cgi.anim->g_iCurrentVMAnimSlot) {
pModel->frameInfo[i].weight = fCrossblendFrac;
}
else {
} else {
pModel->frameInfo[i].weight *= (1.0 - fCrossblendFrac);
}
}
else
{
} else {
pModel->frameInfo[i].weight = 1.0;
}
}
@ -519,60 +518,48 @@ void CG_ViewModelAnimation(refEntity_t* pModel)
pModel->actionWeight = 1.0;
}
void CG_CalcViewModelMovement(float fViewBobPhase, float fViewBobAmp, vec_t* vVelocity, vec_t* vMovement)
void CG_CalcViewModelMovement(float fViewBobPhase, float fViewBobAmp, vec_t *vVelocity, vec_t *vMovement)
{
int i;
float fPhase, fDelta;
int i;
float fPhase, fDelta;
vec3_t vTargOfs;
vec3_t vNorm;
fPhase = sin(fViewBobPhase + M_PI / 10) * fViewBobAmp * vm_sway_side->value;
fPhase = sin(fViewBobPhase + M_PI / 10) * fViewBobAmp * vm_sway_side->value;
vMovement[0] = fPhase * vm_sway_front->value;
vMovement[1] = fPhase;
fPhase = sin(fViewBobPhase - 0.94 + fViewBobPhase - 0.94 + M_PI);
fPhase = sin(fViewBobPhase - 0.94 + fViewBobPhase - 0.94 + M_PI);
vMovement[2] = (sin((fViewBobPhase - 0.94) * 4.0 + M_PI / 2) * 0.125 + fPhase) * fViewBobAmp * vm_sway_up->value;
if (cg.predicted_player_state.walking)
{
if (cg.predicted_player_state.viewheight == CROUCH_EYE_HEIGHT)
{
if (cgi.anim->g_iLastAnimPrefixIndex == WPREFIX_BAZOOKA || cgi.anim->g_iLastAnimPrefixIndex == WPREFIX_PANZERSCHRECK)
{
if (cg.predicted_player_state.walking) {
if (cg.predicted_player_state.viewheight == CROUCH_EYE_HEIGHT) {
if (cgi.anim->g_iLastAnimPrefixIndex == WPREFIX_BAZOOKA
|| cgi.anim->g_iLastAnimPrefixIndex == WPREFIX_PANZERSCHRECK) {
vTargOfs[0] = vm_offset_rocketcrouch_front->value;
vTargOfs[1] = vm_offset_rocketcrouch_side->value;
vTargOfs[2] = vm_offset_rocketcrouch_up->value;
}
else if (cgi.anim->g_iLastAnimPrefixIndex == WPREFIX_SHOTGUN)
{
} else if (cgi.anim->g_iLastAnimPrefixIndex == WPREFIX_SHOTGUN) {
vTargOfs[0] = vm_offset_shotguncrouch_front->value;
vTargOfs[1] = vm_offset_shotguncrouch_side->value;
vTargOfs[2] = vm_offset_shotguncrouch_up->value;
}
else
{
} else {
vTargOfs[0] = vm_offset_crouch_front->value;
vTargOfs[1] = vm_offset_crouch_side->value;
vTargOfs[2] = vm_offset_crouch_up->value;
}
}
else
{
} else {
memset(vTargOfs, 0, sizeof(vTargOfs));
}
}
else
{
} else {
vTargOfs[0] = vm_offset_air_front->value;
vTargOfs[1] = vm_offset_air_side->value;
vTargOfs[2] = vm_offset_air_up->value;
}
if (cg.predicted_player_state.walking)
{
if (cg.predicted_player_state.walking) {
fDelta = VectorLength(vVelocity) - vm_offset_vel_base->value;
if (fDelta > 0.0)
{
if (fDelta > 0.0) {
if (fDelta > 250.0 - vm_offset_vel_base->value) {
fDelta = 250.0 - vm_offset_vel_base->value;
}
@ -582,23 +569,19 @@ void CG_CalcViewModelMovement(float fViewBobPhase, float fViewBobAmp, vec_t* vVe
vTargOfs[1] += fPhase * vm_offset_vel_side->value;
vTargOfs[2] += fPhase * vm_offset_vel_up->value;
}
}
else if (vVelocity[2]) {
} else if (vVelocity[2]) {
vTargOfs[2] -= vVelocity[2] * vm_offset_upvel->value;
}
for (i = 0; i < 3; i++)
{
for (i = 0; i < 3; i++) {
fDelta = vTargOfs[i] - cgi.anim->g_vCurrentVMPosOffset[i];
cgi.anim->g_vCurrentVMPosOffset[i] += cg.frametime / 1000.0 * fDelta * vm_offset_speed->value;
if (fDelta > 0.0)
{
if (fDelta > 0.0) {
if (cgi.anim->g_vCurrentVMPosOffset[i] > vTargOfs[i]) {
cgi.anim->g_vCurrentVMPosOffset[i] = vTargOfs[i];
}
}
else if (fDelta < 0.0) {
} else if (fDelta < 0.0) {
if (cgi.anim->g_vCurrentVMPosOffset[i] < vTargOfs[i]) {
cgi.anim->g_vCurrentVMPosOffset[i] = vTargOfs[i];
}

File diff suppressed because it is too large Load diff