1053 lines
33 KiB
C
1053 lines
33 KiB
C
/*
|
|
===========================================================================
|
|
Copyright (C) 1999-2005 Id Software, Inc.
|
|
Copyright (C) 2007 HermitWorks Entertainment Corporation
|
|
|
|
This file is part of the Space Trader source code.
|
|
|
|
The Space Trader source code is free software; you can redistribute it
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
or (at your option) any later version.
|
|
|
|
The Space Trader source code is distributed in the hope that it will be
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with the Space Trader source code; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
===========================================================================
|
|
*/
|
|
|
|
#include "cg_local.h"
|
|
|
|
// cg_main.c -- initialization and primary entry point for cgame
|
|
|
|
|
|
displayContextDef_t cgDC;
|
|
|
|
int forceModelModificationCount = -1;
|
|
|
|
void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum );
|
|
void CG_Shutdown( void );
|
|
|
|
vec3_t axisDefault[3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
|
|
|
|
|
|
/*
|
|
================
|
|
vmMain
|
|
|
|
This is the only way control passes into the module.
|
|
This must be the very first function compiled into the .q3vm file
|
|
================
|
|
*/
|
|
int QDECL vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
|
|
|
|
REF_PARAM( arg3 );
|
|
REF_PARAM( arg4 );
|
|
REF_PARAM( arg5 );
|
|
REF_PARAM( arg6 );
|
|
REF_PARAM( arg7 );
|
|
REF_PARAM( arg8 );
|
|
REF_PARAM( arg9 );
|
|
REF_PARAM( arg10 );
|
|
REF_PARAM( arg11 );
|
|
|
|
switch ( command ) {
|
|
case CG_INIT:
|
|
CG_Init( arg0, arg1, arg2 );
|
|
return 0;
|
|
case CG_SHUTDOWN:
|
|
CG_Shutdown();
|
|
return 0;
|
|
case CG_CONSOLE_COMMAND:
|
|
return CG_ConsoleCommand();
|
|
|
|
case CG_DRAW_ACTIVE_FRAME:
|
|
CG_DrawActiveFrame( arg0, arg1, arg2, arg3 );
|
|
return 0;
|
|
|
|
case CG_DRAW_OVERLAYS:
|
|
CG_DrawOverlays( arg0, arg1, arg2 );
|
|
return 0;
|
|
|
|
case CG_CROSSHAIR_PLAYER:
|
|
return CG_CrosshairPlayer();
|
|
case CG_LAST_ATTACKER:
|
|
return CG_LastAttacker();
|
|
case CG_KEY_EVENT:
|
|
return 0;
|
|
case CG_MOUSE_EVENT:
|
|
return 0;
|
|
case CG_EVENT_HANDLING:
|
|
return 0;
|
|
|
|
default:
|
|
CG_Error( "vmMain: unknown command %i", command );
|
|
break;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
|
|
cg_t cg;
|
|
cgs_t cgs;
|
|
centity_t cg_entities[MAX_GENTITIES];
|
|
weaponInfo_t cg_weapons[MAX_WEAPONS];
|
|
itemInfo_t cg_items[MAX_ITEMS];
|
|
|
|
|
|
vmCvar_t cg_runpitch;
|
|
vmCvar_t cg_runroll;
|
|
vmCvar_t cg_bobup;
|
|
vmCvar_t cg_bobpitch;
|
|
vmCvar_t cg_bobroll;
|
|
vmCvar_t cg_swingSpeed;
|
|
vmCvar_t cg_shadows;
|
|
vmCvar_t cg_gibs;
|
|
vmCvar_t cg_drawTimer;
|
|
vmCvar_t cg_drawFPS;
|
|
vmCvar_t cg_drawSnapshot;
|
|
vmCvar_t cg_draw3dIcons;
|
|
vmCvar_t cg_drawIcons;
|
|
vmCvar_t cg_drawAmmoWarning;
|
|
vmCvar_t cg_drawCrosshair;
|
|
vmCvar_t cg_drawCrosshairNames;
|
|
vmCvar_t cg_drawRewards;
|
|
vmCvar_t cg_crosshairSize;
|
|
vmCvar_t cg_crosshairX;
|
|
vmCvar_t cg_crosshairY;
|
|
vmCvar_t cg_crosshairHealth;
|
|
vmCvar_t cg_crosshairColorR;
|
|
vmCvar_t cg_crosshairColorG;
|
|
vmCvar_t cg_crosshairColorB;
|
|
vmCvar_t cg_crosshairColorA;
|
|
vmCvar_t cg_draw2D;
|
|
vmCvar_t cg_drawStatus;
|
|
vmCvar_t cg_animSpeed;
|
|
vmCvar_t cg_debugAnim;
|
|
vmCvar_t cg_debugPosition;
|
|
vmCvar_t cg_debugEvents;
|
|
vmCvar_t cg_errorDecay;
|
|
vmCvar_t cg_nopredict;
|
|
vmCvar_t cg_noPlayerAnims;
|
|
vmCvar_t cg_showmiss;
|
|
vmCvar_t cg_footsteps;
|
|
vmCvar_t cg_addMarks;
|
|
vmCvar_t cg_brassTime;
|
|
vmCvar_t cg_viewsize;
|
|
vmCvar_t cg_drawGun;
|
|
vmCvar_t cg_gun_frame;
|
|
vmCvar_t cg_gun_x;
|
|
vmCvar_t cg_gun_y;
|
|
vmCvar_t cg_gun_z;
|
|
vmCvar_t cg_tracerChance;
|
|
vmCvar_t cg_tracerWidth;
|
|
vmCvar_t cg_tracerLength;
|
|
vmCvar_t cg_autoswitch;
|
|
vmCvar_t cg_ignore;
|
|
vmCvar_t cg_simpleItems;
|
|
vmCvar_t cg_fov;
|
|
vmCvar_t cg_zoomFov;
|
|
vmCvar_t cg_thirdPerson;
|
|
vmCvar_t cg_thirdPersonRange;
|
|
vmCvar_t cg_thirdPersonAngle;
|
|
vmCvar_t cg_stereoSeparation;
|
|
vmCvar_t cg_lagometer;
|
|
vmCvar_t cg_drawAttacker;
|
|
vmCvar_t cg_synchronousClients;
|
|
vmCvar_t cg_teamChatTime;
|
|
vmCvar_t cg_teamChatHeight;
|
|
vmCvar_t cg_stats;
|
|
vmCvar_t cg_buildScript;
|
|
vmCvar_t cg_forceModel;
|
|
vmCvar_t cg_paused;
|
|
vmCvar_t cg_blood;
|
|
vmCvar_t cg_predictItems;
|
|
vmCvar_t cg_deferPlayers;
|
|
vmCvar_t cg_teamChatsOnly;
|
|
vmCvar_t cg_noVoiceChats;
|
|
vmCvar_t cg_noVoiceText;
|
|
vmCvar_t cg_scorePlum;
|
|
vmCvar_t cg_smoothClients;
|
|
vmCvar_t pmove_fixed;
|
|
//vmCvar_t cg_pmove_fixed;
|
|
vmCvar_t pmove_msec;
|
|
vmCvar_t cg_pmove_msec;
|
|
vmCvar_t cg_cameraMode;
|
|
vmCvar_t cg_cameraOrbit;
|
|
vmCvar_t cg_cameraOrbitDelay;
|
|
vmCvar_t cg_timescaleFadeEnd;
|
|
vmCvar_t cg_timescaleFadeSpeed;
|
|
vmCvar_t cg_timescale;
|
|
vmCvar_t cg_smallFont;
|
|
vmCvar_t cg_noTaunt;
|
|
vmCvar_t cg_noProjectileTrail;
|
|
|
|
vmCvar_t cg_singlePlayer;
|
|
vmCvar_t cg_enableDust;
|
|
vmCvar_t cg_enableBreath;
|
|
vmCvar_t cg_singlePlayerActive;
|
|
vmCvar_t cg_cubemap;
|
|
vmCvar_t cg_spacetrader;
|
|
|
|
vmCvar_t cg_loadcomplete;
|
|
|
|
vmCvar_t cg_announcer;
|
|
|
|
//set to 0 to turn off autoreloading your gun
|
|
vmCvar_t cg_autoreload;
|
|
typedef struct {
|
|
vmCvar_t *vmCvar;
|
|
char *cvarName;
|
|
char *defaultString;
|
|
int cvarFlags;
|
|
int count;
|
|
} cvarTable_t;
|
|
|
|
static cvarTable_t cvarTable[] = { // bk001129
|
|
{ &cg_ignore, "cg_ignore", "0", 0 }, // used for debugging
|
|
{ &cg_autoswitch, "cg_autoswitch", "0", CVAR_ARCHIVE },
|
|
{ &cg_drawGun, "cg_drawGun", "1", CVAR_ARCHIVE },
|
|
{ &cg_zoomFov, "cg_zoomfov", "22.5", CVAR_ARCHIVE },
|
|
{ &cg_fov, "cg_fov", "90", CVAR_ARCHIVE },
|
|
{ &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE },
|
|
{ &cg_stereoSeparation, "cg_stereoSeparation", "0.4", CVAR_ARCHIVE },
|
|
{ &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE },
|
|
{ &cg_gibs, "cg_gibs", "1", CVAR_ARCHIVE },
|
|
{ &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE },
|
|
{ &cg_drawStatus, "cg_drawStatus", "1", CVAR_ARCHIVE },
|
|
{ &cg_drawTimer, "cg_drawTimer", "0", CVAR_ARCHIVE },
|
|
{ &cg_drawFPS, "cg_drawFPS", "0", CVAR_ARCHIVE },
|
|
{ &cg_drawSnapshot, "cg_drawSnapshot", "0", CVAR_ARCHIVE },
|
|
{ &cg_draw3dIcons, "cg_draw3dIcons", "1", CVAR_ARCHIVE },
|
|
{ &cg_drawIcons, "cg_drawIcons", "1", CVAR_ARCHIVE },
|
|
{ &cg_drawAmmoWarning, "cg_drawAmmoWarning", "0", CVAR_ARCHIVE },
|
|
{ &cg_drawAttacker, "cg_drawAttacker", "1", CVAR_ARCHIVE },
|
|
{ &cg_drawCrosshair, "cg_drawCrosshair", "4", CVAR_ARCHIVE },
|
|
{ &cg_drawCrosshairNames, "cg_drawCrosshairNames", "1", CVAR_ARCHIVE },
|
|
{ &cg_drawRewards, "cg_drawRewards", "1", CVAR_ARCHIVE },
|
|
{ &cg_crosshairSize, "cg_crosshairSize", "15", CVAR_ARCHIVE },
|
|
{ &cg_crosshairHealth, "cg_crosshairHealth", "1", CVAR_ARCHIVE },
|
|
{ &cg_crosshairColorR, "cg_crosshairColorR", "1.0", CVAR_ARCHIVE },
|
|
{ &cg_crosshairColorG, "cg_crosshairColorG", "1.0", CVAR_ARCHIVE },
|
|
{ &cg_crosshairColorB, "cg_crosshairColorB", "1.0", CVAR_ARCHIVE },
|
|
{ &cg_crosshairColorA, "cg_crosshairColorA", "1.0", CVAR_ARCHIVE },
|
|
{ &cg_crosshairX, "cg_crosshairX", "0", CVAR_ARCHIVE },
|
|
{ &cg_crosshairY, "cg_crosshairY", "0", CVAR_ARCHIVE },
|
|
{ &cg_brassTime, "cg_brassTime", "2500", CVAR_ARCHIVE },
|
|
{ &cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE },
|
|
{ &cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE },
|
|
{ &cg_lagometer, "cg_lagometer", "0", CVAR_ARCHIVE },
|
|
{ &cg_gun_x, "cg_gunX", "0", CVAR_CHEAT },
|
|
{ &cg_gun_y, "cg_gunY", "0", CVAR_CHEAT },
|
|
{ &cg_gun_z, "cg_gunZ", "0", CVAR_CHEAT },
|
|
{ &cg_runpitch, "cg_runpitch", "0.002", CVAR_ARCHIVE},
|
|
{ &cg_runroll, "cg_runroll", "0.005", CVAR_ARCHIVE },
|
|
{ &cg_bobup , "cg_bobup", "0.005", CVAR_CHEAT },
|
|
{ &cg_bobpitch, "cg_bobpitch", "0.002", CVAR_ARCHIVE },
|
|
{ &cg_bobroll, "cg_bobroll", "0.002", CVAR_ARCHIVE },
|
|
{ &cg_swingSpeed, "cg_swingSpeed", "0.3", CVAR_CHEAT },
|
|
{ &cg_animSpeed, "cg_animspeed", "1", CVAR_CHEAT },
|
|
{ &cg_debugAnim, "cg_debuganim", "0", CVAR_CHEAT },
|
|
{ &cg_debugPosition, "cg_debugposition", "0", CVAR_CHEAT },
|
|
{ &cg_debugEvents, "cg_debugevents", "0", CVAR_CHEAT },
|
|
{ &cg_errorDecay, "cg_errordecay", "100", 0 },
|
|
{ &cg_nopredict, "cg_nopredict", "0", 0 },
|
|
{ &cg_noPlayerAnims, "cg_noplayeranims", "0", CVAR_CHEAT },
|
|
{ &cg_showmiss, "cg_showmiss", "0", 0 },
|
|
{ &cg_footsteps, "cg_footsteps", "1", CVAR_CHEAT },
|
|
{ &cg_tracerChance, "cg_tracerchance", "0.8", CVAR_CHEAT },
|
|
{ &cg_tracerWidth, "cg_tracerwidth", "4", CVAR_CHEAT },
|
|
{ &cg_tracerLength, "cg_tracerlength", "150", CVAR_CHEAT },
|
|
{ &cg_thirdPersonRange, "cg_thirdPersonRange", "40", CVAR_CHEAT },
|
|
{ &cg_thirdPersonAngle, "cg_thirdPersonAngle", "0", CVAR_CHEAT },
|
|
{ &cg_thirdPerson, "cg_thirdPerson", "0", 0 },
|
|
{ &cg_teamChatTime, "cg_teamChatTime", "3000", CVAR_ARCHIVE },
|
|
{ &cg_teamChatHeight, "cg_teamChatHeight", "0", CVAR_ARCHIVE },
|
|
{ &cg_forceModel, "cg_forceModel", "0", CVAR_ARCHIVE },
|
|
{ &cg_predictItems, "cg_predictItems", "1", CVAR_ARCHIVE },
|
|
{ &cg_stats, "cg_stats", "0", 0 },
|
|
{ &cg_teamChatsOnly, "cg_teamChatsOnly", "0", CVAR_ARCHIVE },
|
|
{ &cg_noVoiceChats, "cg_noVoiceChats", "0", CVAR_ARCHIVE },
|
|
{ &cg_noVoiceText, "cg_noVoiceText", "0", CVAR_ARCHIVE },
|
|
// the following variables are created in other parts of the system,
|
|
// but we also reference them here
|
|
{ &cg_buildScript, "com_buildScript", "0", 0 }, // force loading of all possible data amd error on failures
|
|
{ &cg_paused, "cl_paused", "0", CVAR_ROM },
|
|
{ &cg_blood, "com_blood", "1", CVAR_ARCHIVE },
|
|
{ &cg_synchronousClients, "g_synchronousClients", "0", 0 }, // communicated by systeminfo
|
|
{ &cg_singlePlayer, "ui_singlePlayerActive", "0", CVAR_USERINFO},
|
|
{ &cg_enableDust, "g_enableDust", "0", CVAR_SERVERINFO},
|
|
{ &cg_enableBreath, "g_enableBreath", "0", CVAR_SERVERINFO},
|
|
{ &cg_singlePlayerActive, "ui_singlePlayerActive", "0", CVAR_USERINFO},
|
|
{ &cg_cameraOrbit, "cg_cameraOrbit", "0", CVAR_CHEAT},
|
|
{ &cg_cameraOrbitDelay, "cg_cameraOrbitDelay", "50", CVAR_ARCHIVE},
|
|
{ &cg_timescaleFadeEnd, "cg_timescaleFadeEnd", "1", 0},
|
|
{ &cg_timescaleFadeSpeed, "cg_timescaleFadeSpeed", "0", 0},
|
|
{ &cg_timescale, "timescale", "1", 0},
|
|
{ &cg_scorePlum, "cg_scorePlums", "1", CVAR_USERINFO | CVAR_ARCHIVE},
|
|
{ &cg_smoothClients, "cg_smoothClients", "0", CVAR_USERINFO | CVAR_ARCHIVE},
|
|
{ &cg_cameraMode, "com_cameraMode", "0", CVAR_CHEAT},
|
|
|
|
{ &pmove_fixed, "pmove_fixed", "0", 0},
|
|
{ &pmove_msec, "pmove_msec", "8", 0},
|
|
{ &cg_noTaunt, "cg_noTaunt", "0", CVAR_ARCHIVE},
|
|
{ &cg_noProjectileTrail, "cg_noProjectileTrail", "0", CVAR_ARCHIVE},
|
|
{ &cg_smallFont, "ui_smallFont", "0.25", CVAR_ARCHIVE},
|
|
{ &cg_autoreload, "cg_autoreload", "1", CVAR_ARCHIVE},
|
|
{ &cg_spacetrader, "cl_spacetrader", "0", CVAR_TEMP},
|
|
{ &cg_cubemap, "cg_cubemap", "0", CVAR_CHEAT },
|
|
{ &cg_announcer, "cg_announcer", "1", CVAR_ARCHIVE},
|
|
{ &cg_loadcomplete, "cg_loadcomplete", "", CVAR_TEMP},
|
|
// { &cg_pmove_fixed, "cg_pmove_fixed", "0", CVAR_USERINFO | CVAR_ARCHIVE }
|
|
};
|
|
|
|
static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] );
|
|
|
|
/*
|
|
=================
|
|
CG_RegisterCvars
|
|
=================
|
|
*/
|
|
void CG_RegisterCvars( void ) {
|
|
int i;
|
|
cvarTable_t *cv;
|
|
char var[MAX_TOKEN_CHARS];
|
|
|
|
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
|
|
if ( cv->count < 1 )
|
|
cv->count = 1;
|
|
|
|
if ( cv->count == 1 )
|
|
trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
|
|
else
|
|
{
|
|
int j;
|
|
for ( j=0; j<cv->count; j++ )
|
|
trap_Cvar_Register( cv->vmCvar + j, va("%s%d", cv->cvarName, j), cv->defaultString, cv->cvarFlags );
|
|
}
|
|
}
|
|
|
|
// see if we are also running the server on this machine
|
|
trap_Cvar_VariableStringBuffer( "sv_running", var, sizeof( var ) );
|
|
cgs.localServer = atoi( var );
|
|
|
|
forceModelModificationCount = cg_forceModel.modificationCount;
|
|
|
|
//disable defering players.
|
|
cg_deferPlayers.integer = 0;
|
|
|
|
trap_Cvar_Register(NULL, "model", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );
|
|
trap_Cvar_Register(NULL, "headmodel", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );
|
|
}
|
|
|
|
/*
|
|
===================
|
|
CG_ForceModelChange
|
|
===================
|
|
*/
|
|
static void CG_ForceModelChange( void ) {
|
|
int i;
|
|
|
|
for (i=0 ; i<MAX_CLIENTS ; i++) {
|
|
const char *clientInfo;
|
|
|
|
clientInfo = CG_ConfigString( CS_PLAYERS+i );
|
|
if ( !clientInfo[0] ) {
|
|
continue;
|
|
}
|
|
CG_NewClientInfo( i );
|
|
}
|
|
}
|
|
|
|
/*
|
|
=================
|
|
CG_UpdateCvars
|
|
=================
|
|
*/
|
|
void CG_UpdateCvars( void ) {
|
|
int i;
|
|
cvarTable_t *cv;
|
|
|
|
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
|
|
int j;
|
|
for ( j=0; j<cv->count; j++ )
|
|
trap_Cvar_Update( cv->vmCvar+j );
|
|
}
|
|
|
|
// check for modications here
|
|
|
|
// if force model changed
|
|
if ( forceModelModificationCount != cg_forceModel.modificationCount ) {
|
|
forceModelModificationCount = cg_forceModel.modificationCount;
|
|
CG_ForceModelChange();
|
|
}
|
|
}
|
|
|
|
int CG_CrosshairPlayer( void ) {
|
|
if ( cg.time > ( cg.crosshairClientTime + 1000 ) ) {
|
|
return -1;
|
|
}
|
|
return cg.crosshairClientNum;
|
|
}
|
|
|
|
int CG_LastAttacker( void ) {
|
|
if ( !cg.attackerTime ) {
|
|
return -1;
|
|
}
|
|
return cg.snap->ps.persistant[PERS_ATTACKER];
|
|
}
|
|
|
|
void QDECL CG_Printf( const char *msg, ... ) {
|
|
va_list argptr;
|
|
char text[1024];
|
|
|
|
va_start (argptr, msg);
|
|
vsnprintf (text, sizeof(text), msg, argptr);
|
|
va_end (argptr);
|
|
|
|
trap_Print( text );
|
|
}
|
|
|
|
void QDECL CG_Error( const char *msg, ... ) {
|
|
va_list argptr;
|
|
char text[1024];
|
|
|
|
va_start (argptr, msg);
|
|
vsnprintf (text, sizeof(text), msg, argptr);
|
|
va_end (argptr);
|
|
|
|
trap_Error( text );
|
|
}
|
|
|
|
#ifndef CGAME_HARD_LINKED
|
|
// this is only here so the functions in q_shared.c and bg_*.c can link (FIXME)
|
|
|
|
void Q_EXTERNAL_CALL_VA Com_Error( int level, const char *error, ... )
|
|
{
|
|
va_list argptr;
|
|
char text[1024];
|
|
|
|
REF_PARAM( level );
|
|
|
|
va_start (argptr, error);
|
|
vsnprintf (text, sizeof(text), error, argptr);
|
|
va_end (argptr);
|
|
|
|
CG_Error( "%s", text);
|
|
}
|
|
|
|
void QDECL Com_Printf( const char *msg, ... ) {
|
|
va_list argptr;
|
|
char text[1024];
|
|
|
|
va_start (argptr, msg);
|
|
vsnprintf (text, sizeof(text), msg, argptr);
|
|
va_end (argptr);
|
|
|
|
CG_Printf ("%s", text);
|
|
}
|
|
|
|
#endif
|
|
|
|
/*
|
|
================
|
|
CG_Argv
|
|
================
|
|
*/
|
|
const char *CG_Argv( int arg )
|
|
{
|
|
static char buffer[MAX_STRING_CHARS];
|
|
|
|
trap_Argv( arg, buffer, sizeof( buffer ) );
|
|
|
|
return buffer;
|
|
}
|
|
|
|
|
|
//========================================================================
|
|
|
|
/*
|
|
=================
|
|
CG_RegisterItemSounds
|
|
|
|
The server says this item is used on this level
|
|
=================
|
|
*/
|
|
static void CG_RegisterItemSounds( int itemNum ) {
|
|
gitem_t *item;
|
|
char data[MAX_QPATH];
|
|
char *s, *start;
|
|
int len;
|
|
|
|
item = &bg_itemlist[ itemNum ];
|
|
|
|
if( item->pickup_sound ) {
|
|
trap_S_RegisterSound( item->pickup_sound, qfalse );
|
|
}
|
|
|
|
// parse the space seperated precache string for other media
|
|
s = item->sounds;
|
|
if (!s || !s[0])
|
|
return;
|
|
|
|
while (*s) {
|
|
start = s;
|
|
while (*s && *s != ' ') {
|
|
s++;
|
|
}
|
|
|
|
len = s-start;
|
|
if (len >= MAX_QPATH || len < 5) {
|
|
CG_Error( "PrecacheItem: %s has bad precache string",
|
|
item->classname);
|
|
return;
|
|
}
|
|
memcpy (data, start, len);
|
|
data[len] = 0;
|
|
if ( *s ) {
|
|
s++;
|
|
}
|
|
|
|
if ( !strcmp(data+len-3, "wav" )) {
|
|
trap_S_RegisterSound( data, qfalse );
|
|
}
|
|
}
|
|
}
|
|
|
|
static int find_string( const char * label ) {
|
|
int index = 0;
|
|
if ( sql( "SELECT index FROM strings SEARCH name $;", "t", label ) ) {
|
|
index = sqlint( 0 );
|
|
sqldone();
|
|
}
|
|
return index;
|
|
}
|
|
|
|
/*
|
|
=================
|
|
CG_RegisterSounds
|
|
|
|
called during a precache command
|
|
=================
|
|
*/
|
|
static void CG_RegisterSounds( void ) {
|
|
int i;
|
|
char items[MAX_ITEMS+1];
|
|
char name[MAX_QPATH];
|
|
const char *soundName;
|
|
|
|
cgs.media.tracerSound = trap_S_RegisterSound( "sound/weapons/machinegun/buletby1.ogg", qfalse );
|
|
cgs.media.selectSound = trap_S_RegisterSound( "sound/weapons/change.ogg", qfalse );
|
|
cgs.media.gibSound = trap_S_RegisterSound( "sound/player/gibsplt1.ogg", qfalse );
|
|
cgs.media.gibBounce1Sound = trap_S_RegisterSound( "sound/player/gibimp1.ogg", qfalse );
|
|
cgs.media.gibBounce2Sound = trap_S_RegisterSound( "sound/player/gibimp2.ogg", qfalse );
|
|
cgs.media.gibBounce3Sound = trap_S_RegisterSound( "sound/player/gibimp3.ogg", qfalse );
|
|
cgs.media.brassSound = trap_S_RegisterSound( "sound/player/brass.ogg", qfalse );
|
|
cgs.media.shellSound = trap_S_RegisterSound( "sound/player/shell.ogg", qfalse );
|
|
cgs.media.respawnSound = trap_S_RegisterSound( "sound/items/respawn1.ogg", qfalse );
|
|
|
|
cgs.media.noAmmoSound = trap_S_RegisterSound( "sound/weapons/noammo.ogg", qfalse );
|
|
|
|
cgs.media.talkSound = trap_S_RegisterSound( "sound/player/talk.ogg", qfalse );
|
|
cgs.media.landSound = trap_S_RegisterSound( "sound/player/land1.ogg", qfalse);
|
|
|
|
cgs.media.hitSound = trap_S_RegisterSound( "sound/feedback/hit.ogg", qfalse );
|
|
cgs.media.hitSoundHighArmor = trap_S_RegisterSound( "sound/feedback/hithi.ogg", qfalse );
|
|
cgs.media.hitSoundLowArmor = trap_S_RegisterSound( "sound/feedback/hitlo.ogg", qfalse );
|
|
cgs.media.voteNow = trap_S_RegisterSound( "sound/feedback/vote_now.ogg", qtrue);
|
|
cgs.media.votePassed = trap_S_RegisterSound( "sound/feedback/vote_passed.ogg", qtrue);
|
|
cgs.media.voteFailed = trap_S_RegisterSound( "sound/feedback/vote_failed.ogg", qtrue);
|
|
cgs.media.hitGauntlet = trap_S_RegisterSound( "sound/feedback/hitgauntlet.ogg", qtrue);
|
|
|
|
cgs.media.stash_pickup = trap_S_RegisterSound( "sound/misc/stash_pickup.ogg", qtrue );
|
|
cgs.media.stash_full = trap_S_RegisterSound( "sound/misc/stash_full.ogg", qtrue );
|
|
|
|
cgs.media.watrInSound = trap_S_RegisterSound( "sound/player/watr_in.ogg", qfalse);
|
|
cgs.media.watrOutSound = trap_S_RegisterSound( "sound/player/watr_out.ogg", qfalse);
|
|
cgs.media.watrUnSound = trap_S_RegisterSound( "sound/player/watr_un.ogg", qfalse);
|
|
|
|
//REMOVE SOUND
|
|
// cgs.media.jumpPadSound = trap_S_RegisterSound ("sound/world/jumppad.ogg", qfalse );
|
|
for (i=0 ; i<4 ; i++) {
|
|
//No surface footstep sounds for now
|
|
/*
|
|
Com_sprintf (name, sizeof(name), "sound/player/footsteps/step%i.ogg", i+1);
|
|
cgs.media.footsteps[FOOTSTEP_NORMAL][i] = trap_S_RegisterSound (name, qfalse);
|
|
*/
|
|
Com_sprintf (name, sizeof(name), "sound/player/footsteps/boot%i.ogg", i+1);
|
|
cgs.media.footsteps[FOOTSTEP_BOOT][i] = trap_S_RegisterSound (name, qfalse);
|
|
|
|
/* Com_sprintf (name, sizeof(name), "sound/player/footsteps/flesh%i.ogg", i+1);
|
|
cgs.media.footsteps[FOOTSTEP_FLESH][i] = trap_S_RegisterSound (name, qfalse);
|
|
|
|
Com_sprintf (name, sizeof(name), "sound/player/footsteps/mech%i.ogg", i+1);
|
|
cgs.media.footsteps[FOOTSTEP_MECH][i] = trap_S_RegisterSound (name, qfalse);
|
|
|
|
Com_sprintf (name, sizeof(name), "sound/player/footsteps/energy%i.ogg", i+1);
|
|
cgs.media.footsteps[FOOTSTEP_ENERGY][i] = trap_S_RegisterSound (name, qfalse);*/
|
|
|
|
Com_sprintf (name, sizeof(name), "sound/player/footsteps/splash%i.ogg", i+1);
|
|
cgs.media.footsteps[FOOTSTEP_SPLASH][i] = trap_S_RegisterSound (name, qfalse);
|
|
|
|
/* Com_sprintf (name, sizeof(name), "sound/player/footsteps/clank%i.ogg", i+1);
|
|
cgs.media.footsteps[FOOTSTEP_METAL][i] = trap_S_RegisterSound (name, qfalse);*/
|
|
}
|
|
// only register the items that the server says we need
|
|
strcpy( items, CG_ConfigString( CS_ITEMS ) );
|
|
|
|
for ( i = 1 ; i < bg_numItems ; i++ ) {
|
|
// if ( items[ i ] == '1' || cg_buildScript.integer ) {
|
|
CG_RegisterItemSounds( i );
|
|
// }
|
|
}
|
|
|
|
for ( i = 1 ; i < MAX_SOUNDS ; i++ ) {
|
|
soundName = CG_ConfigString( CS_SOUNDS+i );
|
|
if ( !soundName[0] ) {
|
|
break;
|
|
}
|
|
if ( soundName[0] == '*' ) {
|
|
continue; // custom sound
|
|
}
|
|
cgs.gameSounds[i] = trap_S_RegisterSound( soundName, qfalse );
|
|
}
|
|
|
|
// FIXME: only needed with item
|
|
cgs.media.sfx_ric1 = trap_S_RegisterSound ("sound/weapons/machinegun/ric1.ogg", qfalse);
|
|
cgs.media.sfx_ric2 = trap_S_RegisterSound ("sound/weapons/machinegun/ric2.ogg", qfalse);
|
|
cgs.media.sfx_ric3 = trap_S_RegisterSound ("sound/weapons/machinegun/ric3.ogg", qfalse);
|
|
cgs.media.sfx_rockexp = trap_S_RegisterSound ("sound/weapons/rocket/rocklx1a.ogg", qfalse);
|
|
cgs.media.sfx_grenexp = trap_S_RegisterSound ("sound/weapons/grenade/hgrenexp.ogg", qfalse);
|
|
cgs.media.sfx_proxexp = trap_S_RegisterSound( "sound/weapons/c4/wstbexpl.ogg" , qfalse);
|
|
cgs.media.weaponHoverSound = trap_S_RegisterSound( "sound/weapons/weapon_hover.ogg", qfalse );
|
|
cgs.media.wstbimplSound = trap_S_RegisterSound("sound/weapons/c4/stick_flesh.ogg", qfalse);
|
|
cgs.media.wstbimpmSound = trap_S_RegisterSound("sound/weapons/c4/stick_metal.ogg", qfalse);
|
|
cgs.media.wstbimpdSound = trap_S_RegisterSound("sound/weapons/c4/stick.ogg", qfalse);
|
|
cgs.media.wstbactvSound = trap_S_RegisterSound("sound/weapons/c4/trigger.ogg", qfalse);
|
|
cgs.media.hgrenb1aSound = trap_S_RegisterSound("sound/weapons/grenade/hgrenb1a.ogg", qfalse);
|
|
cgs.media.hgrenb2aSound = trap_S_RegisterSound("sound/weapons/grenade/hgrenb2a.ogg", qfalse);
|
|
|
|
|
|
cgs.media.CG_FUGITIVE_ESCAPE = find_string( "CG_FUGITIVE_ESCAPE" );
|
|
cgs.media.CG_INTERACT_HINT = find_string( "CG_INTERACT_HINT" );
|
|
cgs.media.CG_EXPLORE_HINT = find_string( "CG_EXPLORE_HINT" );
|
|
cgs.media.CG_STASH_PICKUP = find_string( "CG_STASH_PICKUP" );
|
|
cgs.media.CG_STASH_FULL = find_string( "CG_STASH_FULL" );
|
|
cgs.media.CG_NOMORECHANCES = find_string( "CG_NOMORECHANCES" );
|
|
}
|
|
|
|
|
|
//===================================================================================
|
|
|
|
|
|
/*
|
|
=================
|
|
CG_RegisterGraphics
|
|
|
|
This function may execute for a couple of minutes with a slow disk.
|
|
=================
|
|
*/
|
|
static void CG_RegisterGraphics( void ) {
|
|
int i;
|
|
char items[MAX_ITEMS+1];
|
|
|
|
// clear any references to old media
|
|
memset( &cg.refdef, 0, sizeof( cg.refdef ) );
|
|
trap_R_ClearScene();
|
|
|
|
CG_LoadingString( cgs.mapname );
|
|
|
|
trap_R_LoadWorldMap( cgs.mapname );
|
|
|
|
// precache status bar pics
|
|
CG_LoadingString( "game media" );
|
|
|
|
cgs.media.botSkillShaders[0] = trap_R_RegisterShader( "menu/art/skill1.tga" );
|
|
cgs.media.botSkillShaders[1] = trap_R_RegisterShader( "menu/art/skill2.tga" );
|
|
cgs.media.botSkillShaders[2] = trap_R_RegisterShader( "menu/art/skill3.tga" );
|
|
cgs.media.botSkillShaders[3] = trap_R_RegisterShader( "menu/art/skill4.tga" );
|
|
cgs.media.botSkillShaders[4] = trap_R_RegisterShader( "menu/art/skill5.tga" );
|
|
|
|
cgs.media.viewBloodShader = trap_R_RegisterShader( "viewBloodBlend" );
|
|
cgs.media.viewShieldShader = trap_R_RegisterShader( "viewShieldBlend" );
|
|
cgs.media.viewDamagedShader = trap_R_RegisterShader( "viewDamagedShader" );
|
|
cgs.media.viewDamagedShader_vert = trap_R_RegisterShader( "viewDamagedShader_vert" );
|
|
|
|
cgs.media.deferShader = trap_R_RegisterShaderNoMip( "gfx/2d/defer.tga" );
|
|
|
|
cgs.media.scoreboardName = trap_R_RegisterShaderNoMip( "menu/tab/name.tga" );
|
|
cgs.media.scoreboardPing = trap_R_RegisterShaderNoMip( "menu/tab/ping.tga" );
|
|
cgs.media.scoreboardScore = trap_R_RegisterShaderNoMip( "menu/tab/score.tga" );
|
|
cgs.media.scoreboardTime = trap_R_RegisterShaderNoMip( "menu/tab/time.tga" );
|
|
|
|
cgs.media.smokePuffShader = trap_R_RegisterShader( "smokePuff" );
|
|
cgs.media.shotgunSmokePuffShader = trap_R_RegisterShader( "shotgunSmokePuff" );
|
|
cgs.media.nailPuffShader = trap_R_RegisterShader( "nailtrail" );
|
|
cgs.media.bloodTrailShader = trap_R_RegisterShader( "bloodTrail" );
|
|
cgs.media.lagometerShader = trap_R_RegisterShader("lagometer" );
|
|
cgs.media.connectionShader = trap_R_RegisterShader( "disconnected" );
|
|
|
|
cgs.media.waterBubbleShader = trap_R_RegisterShader( "waterBubble" );
|
|
|
|
cgs.media.tracerShader = trap_R_RegisterShader( "gfx/misc/tracer" );
|
|
cgs.media.selectShader = trap_R_RegisterShader( "gfx/2d/select" );
|
|
|
|
for ( i = 0 ; i < NUM_CROSSHAIRS ; i++ ) {
|
|
cgs.media.crosshairShader[i] = trap_R_RegisterShader( va("gfx/2d/crosshair%c", 'a'+i) );
|
|
}
|
|
|
|
cgs.media.crosshairTrade = trap_R_RegisterShader( "ui/assets/crosshairtrade" );
|
|
cgs.media.crosshairTalk = trap_R_RegisterShader( "ui/assets/cursor_talk" );
|
|
|
|
|
|
cgs.media.backTileShader = trap_R_RegisterShader( "gfx/2d/backtile" );
|
|
cgs.media.noammoShader = trap_R_RegisterShader( "icons/noammo" );
|
|
|
|
cgs.media.shieldShader = trap_R_RegisterShader( "shield" );
|
|
|
|
cgs.media.dustPuffShader = trap_R_RegisterShader("dustPuff");
|
|
|
|
cgs.media.armorModel = trap_R_RegisterModel( "models/misc/shieldgenerator.md3" );
|
|
cgs.media.armorIcon = trap_R_RegisterShaderNoMip( "icons/iconr_yellow" );
|
|
|
|
cgs.media.machinegunBrassModel = trap_R_RegisterModel( "models/weapons/shells/brass_shell.md3" );
|
|
cgs.media.shotgunBrassModel = trap_R_RegisterModel( "models/weapons/shells/shotgun_shell.md3" );
|
|
|
|
cgs.media.gibs[0] = trap_R_RegisterModel( "models/gibs/gib1.md3" );
|
|
cgs.media.gibs[1] = trap_R_RegisterModel( "models/gibs/gib2.md3" );
|
|
cgs.media.gibs[2] = trap_R_RegisterModel( "models/gibs/gib3.md3" );
|
|
cgs.media.gibs[3] = trap_R_RegisterModel( "models/gibs/gib4.md3" );
|
|
|
|
cgs.media.balloonShader = trap_R_RegisterShader( "sprites/balloon3" );
|
|
|
|
cgs.media.bloodExplosionShader = trap_R_RegisterShader( "bloodExplosion" );
|
|
cgs.media.shieldExplosionShader = trap_R_RegisterShader( "shieldExplosion" );
|
|
|
|
cgs.media.shrapnelModel = trap_R_RegisterModel( "models/weaphits/shrapnel.md3" );
|
|
|
|
cgs.media.bulletFlashModel = trap_R_RegisterModel("models/weaphits/bullet.md3");
|
|
cgs.media.dishFlashModel = trap_R_RegisterModel("models/weaphits/boom01.md3");
|
|
cgs.media.teleportEffectModel = trap_R_RegisterModel( "models/misc/teleport.md3" );
|
|
cgs.media.teleportEffectShader = trap_R_RegisterShader( "teleportEffect" );
|
|
|
|
cgs.media.medalImpressive = trap_R_RegisterShaderNoMip( "medal_impressive" );
|
|
cgs.media.medalExcellent = trap_R_RegisterShaderNoMip( "medal_excellent" );
|
|
cgs.media.medalGauntlet = trap_R_RegisterShaderNoMip( "medal_gauntlet" );
|
|
cgs.media.medalDefend = trap_R_RegisterShaderNoMip( "medal_defend" );
|
|
cgs.media.medalAssist = trap_R_RegisterShaderNoMip( "medal_assist" );
|
|
cgs.media.medalCapture = trap_R_RegisterShaderNoMip( "medal_capture" );
|
|
|
|
cgs.media.npc_sprites[1] = trap_R_RegisterShader( "sprites/exclaim" );
|
|
cgs.media.npc_sprites[2] = trap_R_RegisterShader( "sprites/question" );
|
|
cgs.media.npc_sprites[3] = trap_R_RegisterShader( "sprites/merchant_good" );
|
|
cgs.media.npc_sprites[4] = trap_R_RegisterShader( "sprites/merchant_bad" );
|
|
cgs.media.npc_sprites[5] = trap_R_RegisterShader( "sprites/wrench" );
|
|
|
|
cgs.media.carModel[0] = trap_R_RegisterModel( "models/misc/shuttle.md3" );
|
|
cgs.media.carModel[1] = trap_R_RegisterModel( "models/misc/funkyshuttle.md3" );
|
|
cgs.media.carModel[2] = trap_R_RegisterModel( "models/misc/jetshuttle.md3" );
|
|
|
|
|
|
memset( cg_items, 0, sizeof( cg_items ) );
|
|
memset( cg_weapons, 0, sizeof( cg_weapons ) );
|
|
|
|
// only register the items that the server says we need
|
|
strcpy( items, CG_ConfigString( CS_ITEMS) );
|
|
|
|
for ( i = 1 ; i < bg_numItems ; i++ ) {
|
|
if ( items[ i ] == '1' || cg_buildScript.integer ) {
|
|
CG_LoadingItem( i );
|
|
CG_RegisterItemVisuals( i );
|
|
}
|
|
}
|
|
|
|
// wall marks
|
|
cgs.media.bulletMarkShader = trap_R_RegisterShader( "gfx/damage/bullet_mrk" );
|
|
cgs.media.burnMarkShader = trap_R_RegisterShader( "gfx/damage/burn_med_mrk" );
|
|
cgs.media.holeMarkShader = trap_R_RegisterShader( "gfx/damage/hole_lg_mrk" );
|
|
cgs.media.shadowMarkShader = trap_R_RegisterShader( "markShadow" );
|
|
cgs.media.wakeMarkShader = trap_R_RegisterShader( "wake" );
|
|
cgs.media.bloodMarkShader = trap_R_RegisterShader( "bloodMark" );
|
|
|
|
// register the inline models
|
|
cgs.numInlineModels = trap_CM_NumInlineModels();
|
|
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] = trap_R_RegisterModel( name );
|
|
trap_R_ModelBounds( cgs.inlineDrawModel[i], mins, maxs );
|
|
for ( j = 0 ; j < 3 ; j++ ) {
|
|
cgs.inlineModelMidpoints[i][j] = mins[j] + 0.5 * ( maxs[j] - mins[j] );
|
|
}
|
|
}
|
|
|
|
// register all the server specified models
|
|
for (i=1 ; i<MAX_MODELS ; i++) {
|
|
const char *modelName;
|
|
|
|
modelName = CG_ConfigString( CS_MODELS+i );
|
|
if ( !modelName[0] ) {
|
|
break;
|
|
}
|
|
cgs.gameModels[i] = trap_R_RegisterModel( modelName );
|
|
}
|
|
|
|
CG_ClearParticles ();
|
|
/*
|
|
for (i=1; i<MAX_PARTICLES_AREAS; i++)
|
|
{
|
|
{
|
|
int rval;
|
|
|
|
rval = CG_NewParticleArea ( CS_PARTICLES + i);
|
|
if (!rval)
|
|
break;
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
=======================
|
|
CG_BuildSpectatorString
|
|
|
|
=======================
|
|
*/
|
|
void CG_BuildSpectatorString() {
|
|
int i;
|
|
cg.spectatorList[0] = 0;
|
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
|
if (cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_SPECTATOR ) {
|
|
Q_strcat(cg.spectatorList, sizeof(cg.spectatorList), va("%s ", cgs.clientinfo[i].name));
|
|
}
|
|
}
|
|
i = strlen(cg.spectatorList);
|
|
if (i != cg.spectatorLen) {
|
|
cg.spectatorLen = i;
|
|
cg.spectatorWidth = -1;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
===================
|
|
CG_RegisterClients
|
|
===================
|
|
*/
|
|
static void CG_RegisterClients( void ) {
|
|
int i;
|
|
|
|
CG_LoadingClient(cg.clientNum);
|
|
CG_NewClientInfo(cg.clientNum);
|
|
|
|
for (i=0 ; i<MAX_CLIENTS ; i++) {
|
|
const char *clientInfo;
|
|
|
|
if (cg.clientNum == i) {
|
|
continue;
|
|
}
|
|
|
|
clientInfo = CG_ConfigString( CS_PLAYERS+i );
|
|
if ( !clientInfo[0]) {
|
|
continue;
|
|
}
|
|
CG_LoadingClient( i );
|
|
CG_NewClientInfo( i );
|
|
}
|
|
CG_BuildSpectatorString();
|
|
}
|
|
|
|
//===========================================================================
|
|
|
|
/*
|
|
=================
|
|
CG_ConfigString
|
|
=================
|
|
*/
|
|
const char *CG_ConfigString( int index ) {
|
|
if ( index < 0 || index >= MAX_CONFIGSTRINGS ) {
|
|
CG_Error( "CG_ConfigString: bad index: %i", index );
|
|
}
|
|
return cgs.gameState.stringData + cgs.gameState.stringOffsets[ index ];
|
|
}
|
|
|
|
//==================================================================
|
|
|
|
/*
|
|
======================
|
|
CG_StartMusic
|
|
|
|
======================
|
|
*/
|
|
void CG_StartMusic( void ) {
|
|
const char *s;
|
|
char parm1[MAX_QPATH], parm2[MAX_QPATH];
|
|
|
|
// start the background music
|
|
s = CG_ConfigString( CS_MUSICTRACK );
|
|
Q_strncpyz( parm1, COM_Parse( &s ), sizeof( parm1 ) );
|
|
Q_strncpyz( parm2, COM_Parse( &s ), sizeof( parm2 ) );
|
|
|
|
trap_S_StartBackgroundTrack( parm1, parm2 );
|
|
}
|
|
|
|
static float CG_Cvar_Get(const char *cvar) {
|
|
char buff[128];
|
|
memset(buff, 0, sizeof(buff));
|
|
trap_Cvar_VariableStringBuffer(cvar, buff, sizeof(buff));
|
|
return atof(buff);
|
|
}
|
|
|
|
static int CG_PlayCinematic(const char *name, float x, float y, float w, float h) {
|
|
return trap_CIN_PlayCinematic(name, x, y, w, h, CIN_loop);
|
|
}
|
|
|
|
static void CG_StopCinematic(int handle) {
|
|
trap_CIN_StopCinematic(handle);
|
|
}
|
|
|
|
static void CG_DrawCinematic(int handle, float x, float y, float w, float h) {
|
|
trap_CIN_SetExtents(handle, x, y, w, h);
|
|
trap_CIN_DrawCinematic(handle);
|
|
}
|
|
|
|
static void CG_RunCinematicFrame(int handle) {
|
|
trap_CIN_RunCinematic(handle);
|
|
}
|
|
|
|
void CG_AssetCache() {
|
|
cgDC.Assets.menu = trap_R_RegisterShaderNoMip( "ui/assets/menubrushed" );
|
|
}
|
|
/*
|
|
=================
|
|
CG_Init
|
|
|
|
Called after every level change or subsystem restart
|
|
Will perform callbacks to make the loading info screen update.
|
|
=================
|
|
*/
|
|
void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {
|
|
const char *s;
|
|
|
|
// clear everything
|
|
memset( &cgs, 0, sizeof( cgs ) );
|
|
memset( &cg, 0, sizeof( cg ) );
|
|
memset( cg_entities, 0, sizeof(cg_entities) );
|
|
memset( cg_weapons, 0, sizeof(cg_weapons) );
|
|
memset( cg_items, 0, sizeof(cg_items) );
|
|
|
|
cg.clientNum = clientNum;
|
|
|
|
cgs.processedSnapshotNum = serverMessageNum;
|
|
cgs.serverCommandSequence = serverCommandSequence;
|
|
|
|
// load a few needed things before we do any screen updates
|
|
cgs.media.whiteShader = trap_R_RegisterShader( "*white" );
|
|
cgs.media.font = trap_R_RegisterFont( "Handel Gothic" );
|
|
|
|
CG_RegisterCvars();
|
|
|
|
CG_InitConsoleCommands();
|
|
|
|
cg.weaponSelect = WP_PISTOL;
|
|
|
|
cgs.redflag = cgs.blueflag = -1; // For compatibily, default to unset for
|
|
cgs.flagStatus = -1;
|
|
// old servers
|
|
|
|
// get the rendering configuration from the client system
|
|
trap_GetGlconfig( &cgDC.glconfig );
|
|
|
|
// get the gamestate from the client system
|
|
trap_GetGameState( &cgs.gameState );
|
|
|
|
// check version
|
|
s = CG_ConfigString( CS_GAME_VERSION );
|
|
if ( strcmp( s, GAME_VERSION ) ) {
|
|
CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s );
|
|
}
|
|
|
|
s = CG_ConfigString( CS_LEVEL_START_TIME );
|
|
cgs.levelStartTime = atoi( s );
|
|
|
|
CG_ParseServerinfo();
|
|
|
|
// load the new map
|
|
CG_LoadingString( "collision map" );
|
|
|
|
trap_CM_LoadMap( cgs.mapname );
|
|
|
|
cg.loading = qtrue; // force players to load instead of defer
|
|
|
|
CG_LoadingString( "sounds" );
|
|
|
|
CG_RegisterSounds();
|
|
|
|
CG_LoadingString( "graphics" );
|
|
|
|
CG_RegisterGraphics();
|
|
|
|
CG_LoadingString( "ads" );
|
|
|
|
CG_LoadingString( "clients" );
|
|
|
|
CG_RegisterClients(); // if low on memory, some clients will be deferred
|
|
|
|
CG_AssetCache();
|
|
|
|
cg.loading = qfalse; // future players will be deferred
|
|
|
|
CG_InitLocalEntities();
|
|
|
|
CG_InitMarkPolys();
|
|
|
|
// remove the last loading update
|
|
cg.infoScreenText[0] = 0;
|
|
|
|
// Make sure we have update values (scores)
|
|
CG_SetConfigValues();
|
|
|
|
CG_LoadingString( "" );
|
|
|
|
CG_ShaderStateChanged();
|
|
|
|
trap_S_ClearLoopingSounds( qtrue );
|
|
|
|
//
|
|
// move the chat stuff under status stuff
|
|
//
|
|
trap_Cvar_Set("cl_conXOffset", "16");
|
|
trap_Cvar_Set("cl_conYOffset", "128");
|
|
trap_Cvar_Set("cl_conWidth", "175");
|
|
trap_Cvar_Set("cl_conHeight", "96");
|
|
trap_Cvar_Set("con_notifytime", "5" );
|
|
|
|
CG_ST_exec( CG_ST_INIT, clientNum );
|
|
//Delay music playing to the end to avoid some hitching
|
|
CG_StartMusic();
|
|
|
|
trap_SendConsoleCommand( cg_loadcomplete.string );
|
|
}
|
|
|
|
/*
|
|
=================
|
|
CG_Shutdown
|
|
|
|
Called before every level change or subsystem restart
|
|
=================
|
|
*/
|
|
void CG_Shutdown( void ) {
|
|
// some mods may need to do cleanup work here,
|
|
// like closing files or archiving session data
|
|
trap_S_StopBackgroundTrack();
|
|
}
|