From 4ca697bc9b39444847ec639e2db8a9cbcc79ee0c Mon Sep 17 00:00:00 2001 From: Ensiform Date: Tue, 21 Nov 2023 20:05:55 -0600 Subject: [PATCH] Some etmain cgame code cleanup and fixes --- src/cgame/cg_character.c | 51 +-------------- src/cgame/cg_commandmap.c | 16 +++-- src/cgame/cg_consolecmds.c | 101 ++++++++---------------------- src/cgame/cg_draw.c | 6 +- src/cgame/cg_effects.c | 18 ------ src/cgame/cg_ents.c | 6 +- src/cgame/cg_event.c | 20 +++--- src/cgame/cg_fireteamoverlay.c | 2 +- src/cgame/cg_flamethrower.c | 4 +- src/cgame/cg_info.c | 22 +++---- src/cgame/cg_local.h | 34 +++++----- src/cgame/cg_localents.c | 2 +- src/cgame/cg_main.c | 82 +++++++++++++----------- src/cgame/cg_missionbriefing.c | 2 +- src/cgame/cg_multiview.c | 11 +--- src/cgame/cg_newDraw.c | 20 +++--- src/cgame/cg_particles.c | 16 +---- src/cgame/cg_players.c | 8 +-- src/cgame/cg_playerstate.c | 2 +- src/cgame/cg_popupmessages.c | 2 +- src/cgame/cg_servercmds.c | 86 +++++++------------------ src/cgame/cg_snapshot.c | 3 - src/cgame/cg_sound.c | 28 +++++---- src/cgame/cg_spawn.c | 16 ++--- src/cgame/cg_view.c | 38 +++++------ src/cgame/cg_weapons.c | 111 +++++---------------------------- 26 files changed, 228 insertions(+), 479 deletions(-) diff --git a/src/cgame/cg_character.c b/src/cgame/cg_character.c index fe02c022..0a099740 100644 --- a/src/cgame/cg_character.c +++ b/src/cgame/cg_character.c @@ -34,53 +34,6 @@ If you have questions concerning this license or the applicable additional terms char bigTextBuffer[100000]; -// TTimo - defined but not used -#if 0 -/* -====================== -CG_ParseGibModels - -Read a configuration file containing gib models for use with this character -====================== -*/ -static qboolean CG_ParseGibModels( bg_playerclass_t* classInfo ) { - char *text_p; - int len; - int i; - char *token; - fileHandle_t f; - - memset( classInfo->gibModels, 0, sizeof( classInfo->gibModels ) ); - - // load the file - len = trap_FS_FOpenFile( va( "models/players/%s/gibs.cfg", classInfo->modelPath ), &f, FS_READ ); - if ( len <= 0 ) { - return qfalse; - } - if ( len >= sizeof( bigTextBuffer ) - 1 ) { - CG_Printf( "File %s too long\n", va( "models/players/%s/gibs.cfg", classInfo->modelPath ) ); - return qfalse; - } - trap_FS_Read( bigTextBuffer, len, f ); - bigTextBuffer[len] = 0; - trap_FS_FCloseFile( f ); - - // parse the text - text_p = bigTextBuffer; - - for ( i = 0; i < MAX_GIB_MODELS; i++ ) { - token = COM_Parse( &text_p ); - if ( !token ) { - break; - } - // cache this model - classInfo->gibModels[i] = trap_R_RegisterModel( token ); - } - - return qtrue; -} -#endif - /* ====================== CG_ParseHudHeadConfig @@ -107,7 +60,7 @@ static qboolean CG_ParseHudHeadConfig( const char *filename, animation_t* hha ) } trap_FS_Read( bigTextBuffer, len, f ); - bigTextBuffer[len] = 0; + bigTextBuffer[len] = '\0'; trap_FS_FCloseFile( f ); // parse the text @@ -268,7 +221,7 @@ static qboolean CG_ParseAnimationFiles( bg_character_t *character, const char *a return qfalse; } trap_FS_Read( bigTextBuffer, len, f ); - bigTextBuffer[len] = 0; + bigTextBuffer[len] = '\0'; trap_FS_FCloseFile( f ); // parse the text diff --git a/src/cgame/cg_commandmap.c b/src/cgame/cg_commandmap.c index 4f1e5fb0..380f871d 100644 --- a/src/cgame/cg_commandmap.c +++ b/src/cgame/cg_commandmap.c @@ -30,7 +30,6 @@ If you have questions concerning this license or the applicable additional terms static mapEntityData_t mapEntities[MAX_GENTITIES]; static int mapEntityCount = 0; -static int mapEntityTime = 0; static qboolean expanded = qfalse; extern playerInfo_t pi; @@ -145,8 +144,8 @@ void CG_AdjustAutomapZoom( int zoomIn ) { } // END xkan, 9/19/2002 -void CG_ParseMapEntity( int* mapEntityCount, int* offset, team_t team ) { - mapEntityData_t* mEnt = &mapEntities[( *mapEntityCount )]; +void CG_ParseMapEntity( int* _mapEntityCount, int* offset, team_t team ) { + mapEntityData_t* mEnt = &mapEntities[( *_mapEntityCount )]; char buffer[16]; trap_Argv( ( *offset )++, buffer, 16 ); @@ -198,7 +197,7 @@ void CG_ParseMapEntity( int* mapEntityCount, int* offset, team_t team ) { mEnt->team = team; - ( *mapEntityCount )++; + ( *_mapEntityCount )++; } /* @@ -210,7 +209,6 @@ void CG_ParseMapEntityInfo( int axis_number, int allied_number ) { int i, offset; mapEntityCount = 0; - mapEntityTime = cg.time; offset = 3; @@ -468,7 +466,7 @@ void CG_DrawMapEntity( mapEntityData_t *mEnt, float x, float y, float w, float h mEnt->automapTransformed[1] = ( ( cg.predictedPlayerEntity.lerpOrigin[1] - cg.mapcoordsMins[1] ) * cg.mapcoordsScale[1] ) * h * scissor->zoomFactor; } - mEnt->yaw = cg.predictedPlayerState.viewangles[YAW]; + mEnt->yaw = (int)cg.predictedPlayerState.viewangles[YAW]; } else if ( ci->team == snap->ps.persistant[PERS_TEAM] && cent->currentValid ) { if ( !scissor ) { mEnt->transformed[0] = ( ( cent->lerpOrigin[0] - cg.mapcoordsMins[0] ) * cg.mapcoordsScale[0] ) * w; @@ -478,7 +476,7 @@ void CG_DrawMapEntity( mapEntityData_t *mEnt, float x, float y, float w, float h mEnt->automapTransformed[1] = ( ( cent->lerpOrigin[1] - cg.mapcoordsMins[1] ) * cg.mapcoordsScale[1] ) * h * scissor->zoomFactor; } - mEnt->yaw = cent->lerpAngles[YAW]; + mEnt->yaw = (int)cent->lerpAngles[YAW]; } else { // Gordon: only see revivables for own team, duh :) if ( mEnt->type == ME_PLAYER_REVIVE ) { @@ -885,7 +883,7 @@ void CG_DrawMap( float x, float y, float w, float h, int mEntFilter, mapScissor_ } else { trap_R_DrawStretchPic( sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[0] ); } - trap_R_DrawStretchPic( 0, 0, 0, 0, 0, 0, 0, 0, cgs.media.whiteShader ); // HACK : the code above seems to do weird things to + //trap_R_DrawStretchPic( 0, 0, 0, 0, 0, 0, 0, 0, cgs.media.whiteShader ); // HACK : the code above seems to do weird things to // the next trap_R_DrawStretchPic issued. This works // around this. } @@ -1478,7 +1476,7 @@ mapEntityData_t* CG_ScanForCommandCentreEntity( void ) { } typedef enum { - MT_CONSTRUCT, + MT_CONSTRUCT = 0, MT_CONSTRUCT_BARE, MT_DESTRUCT, MT_DESTRUCT_BARE, diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c index 2912eff4..94e2f893 100644 --- a/src/cgame/cg_consolecmds.c +++ b/src/cgame/cg_consolecmds.c @@ -36,7 +36,7 @@ If you have questions concerning this license or the applicable additional terms #include "cg_local.h" -void CG_TargetCommand_f( void ) { +static void CG_TargetCommand_f( void ) { int targetNum; char test[4]; @@ -105,7 +105,7 @@ static void CG_StatsUp_f( void ) { } } -void CG_topshotsDown_f( void ) { +static void CG_topshotsDown_f( void ) { if ( !cg.demoPlayback ) { if ( cgs.topshots.show == SHOW_SHUTDOWN && cg.time < cgs.topshots.fadeTime ) { cgs.topshots.fadeTime = 2 * cg.time + STATS_FADE_TIME - cgs.topshots.fadeTime; @@ -122,7 +122,7 @@ void CG_topshotsDown_f( void ) { } } -void CG_topshotsUp_f( void ) { +static void CG_topshotsUp_f( void ) { if ( cgs.topshots.show == SHOW_ON ) { cgs.topshots.show = SHOW_SHUTDOWN; if ( cg.time < cgs.topshots.fadeTime ) { @@ -166,12 +166,6 @@ void CG_ScoresUp_f( void ) { } } -static void CG_LoadHud_f( void ) { -// String_Init(); -// Menu_Reset(); -// CG_LoadMenus("ui/hud.txt"); -} - static void CG_LoadWeapons_f( void ) { int i; @@ -183,44 +177,29 @@ static void CG_LoadWeapons_f( void ) { } } -/* -static void CG_InventoryDown_f( void ) { - cg.showItems = qtrue; -} - -static void CG_InventoryUp_f( void ) { - cg.showItems = qfalse; - cg.itemFadeTime = cg.time; -} -*/ - static void CG_TellTarget_f( void ) { int clientNum; - char command[128]; - char message[128]; + char command[MAX_SAY_TEXT]; clientNum = CG_CrosshairPlayer(); if ( clientNum == -1 ) { return; } - trap_Args( message, 128 ); - Com_sprintf( command, 128, "tell %i %s", clientNum, message ); + Com_sprintf( command, sizeof(command), "tell %i %s", clientNum, CG_ConcatArgs(1) ); trap_SendClientCommand( command ); } static void CG_TellAttacker_f( void ) { int clientNum; - char command[128]; - char message[128]; + char command[MAX_SAY_TEXT]; clientNum = CG_LastAttacker(); if ( clientNum == -1 ) { return; } - trap_Args( message, 128 ); - Com_sprintf( command, 128, "tell %i %s", clientNum, message ); + Com_sprintf( command, 128, "tell %i %s", clientNum, CG_ConcatArgs(1) ); trap_SendClientCommand( command ); } @@ -274,7 +253,7 @@ void CG_StartCamera( const char *name, qboolean startBlack ) { // return; COM_StripExtension( name, lname, sizeof( lname ) ); //----(SA) added - strcat( lname, ".camera" ); + Q_strcat( lname, sizeof(lname), ".camera" ); if ( trap_loadCamera( CAM_PRIMARY, va( "cameras/%s", lname ) ) ) { cg.cameraMode = qtrue; // camera on in cgame @@ -291,7 +270,7 @@ void CG_StartCamera( const char *name, qboolean startBlack ) { trap_stopCamera( CAM_PRIMARY ); // camera off in client CG_Fade( 0, 0, 0, 0, cg.time, 0 ); // ensure fadeup trap_Cvar_Set( "cg_letterbox", "0" ); - CG_Printf( "Unable to load camera %s\n",lname ); + CG_Printf( "Unable to load camera %s\n", lname ); } } @@ -307,7 +286,7 @@ void CG_StartInitialCamera() { CG_StartCamera( g_initialCamera, g_initialCameraStartBlack ); // Clear it now so we don't get re-entrance problems - g_initialCamera[0] = 0; + g_initialCamera[0] = '\0'; g_initialCameraStartBlack = qfalse; } // if (g_initialCamera[0] != 0)... @@ -376,7 +355,7 @@ void CG_QuickFireteamMessage_f( void ) { } } -void CG_QuickFireteamAdmin_f( void ) { +static void CG_QuickFireteamAdmin_f( void ) { trap_UI_Popup( UIMENU_NONE ); if ( cg.showFireteamMenu ) { @@ -424,7 +403,7 @@ static void CG_FTSayPlayerClass_f( void ) { if ( cg.snap && ( cg.snap->ps.pm_type != PM_INTERMISSION ) ) { if ( cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR || cgs.clientinfo[cg.clientNum].team == TEAM_FREE ) { - CG_Printf( CG_TranslateString( "Can't team voice chat as a spectator.\n" ) ); + CG_Printf( "%s", CG_TranslateString( "Can't team voice chat as a spectator.\n" ) ); return; } } @@ -452,7 +431,7 @@ static void CG_SayPlayerClass_f( void ) { if ( cg.snap && ( cg.snap->ps.pm_type != PM_INTERMISSION ) ) { if ( cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR || cgs.clientinfo[cg.clientNum].team == TEAM_FREE ) { - CG_Printf( CG_TranslateString( "Can't team voice chat as a spectator.\n" ) ); + CG_Printf( "%s", CG_TranslateString( "Can't team voice chat as a spectator.\n" ) ); return; } } @@ -471,7 +450,7 @@ static void CG_VoiceChat_f( void ) { // NOTE - This cg.snap will be the person you are following, but its just for intermission test if ( cg.snap && ( cg.snap->ps.pm_type != PM_INTERMISSION ) ) { if ( cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR || cgs.clientinfo[cg.clientNum].team == TEAM_FREE ) { - CG_Printf( CG_TranslateString( "Can't voice chat as a spectator.\n" ) ); + CG_Printf( "%s", CG_TranslateString( "Can't voice chat as a spectator.\n" ) ); return; } } @@ -492,7 +471,7 @@ static void CG_TeamVoiceChat_f( void ) { // NOTE - This cg.snap will be the person you are following, but its just for intermission test if ( cg.snap && ( cg.snap->ps.pm_type != PM_INTERMISSION ) ) { if ( cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR || cgs.clientinfo[cg.clientNum].team == TEAM_FREE ) { - CG_Printf( CG_TranslateString( "Can't team voice chat as a spectator.\n" ) ); + CG_Printf( "%s", CG_TranslateString( "Can't team voice chat as a spectator.\n" ) ); return; } } @@ -513,7 +492,7 @@ static void CG_BuddyVoiceChat_f( void ) { // NOTE - This cg.snap will be the person you are following, but its just for intermission test if ( cg.snap && ( cg.snap->ps.pm_type != PM_INTERMISSION ) ) { if ( cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR || cgs.clientinfo[cg.clientNum].team == TEAM_FREE ) { - CG_Printf( CG_TranslateString( "Can't buddy voice chat as a spectator.\n" ) ); + CG_Printf( "%s", CG_TranslateString( "Can't buddy voice chat as a spectator.\n" ) ); return; } } @@ -709,7 +688,7 @@ const char *aMonths[12] = { "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -void CG_currentTime_f( void ) { +static void CG_currentTime_f( void ) { qtime_t ct; trap_RealTime( &ct ); @@ -726,14 +705,14 @@ void CG_autoScreenShot_f( void ) { trap_SendConsoleCommand( va( "screenshot%s %s\n", ( ( cg_useScreenshotJPEG.integer ) ? "JPEG" : "" ), CG_generateFilename() ) ); } -void CG_vstrDown_f( void ) { +static void CG_vstrDown_f( void ) { // The engine also passes back the key code and time of the key press if ( trap_Argc() == 5 ) { trap_SendConsoleCommand( va( "vstr %s;", CG_Argv( 1 ) ) ); } else { CG_Printf( "[cgnotify]Usage: +vstr [down_vstr] [up_vstr]\n" );} } -void CG_vstrUp_f( void ) { +static void CG_vstrUp_f( void ) { // The engine also passes back the key code and time of the key press if ( trap_Argc() == 5 ) { trap_SendConsoleCommand( va( "vstr %s;", CG_Argv( 2 ) ) ); @@ -766,29 +745,9 @@ void CG_dumpStats_f( void ) { trap_SendClientCommand( ( cg.mvTotalClients < 1 ) ? "weaponstats" : "statsall" ); } } -void CG_wStatsDown_f( void ) { - int i = ( cg.mvTotalClients > 0 ) ? ( cg.mvCurrentActive->mvInfo & MV_PID ) : cg.snap->ps.clientNum; - - if ( cg.mvTotalClients < 1 && cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) { - Pri( "You must be a player or following a player to use +wstats\n" ); - return; - } - if ( cg.statsRequestTime < cg.time ) { - cg.statsRequestTime = cg.time + 500; - trap_SendClientCommand( va( "wstats %d", i ) ); - } - - cg.showStats = qtrue; -} - -void CG_wStatsUp_f( void ) { - cg.showStats = qfalse; - CG_windowFree( cg.statsWindow ); - cg.statsWindow = NULL; -} - -void CG_toggleSpecHelp_f( void ) { +#ifdef MV_SUPPORT +static void CG_toggleSpecHelp_f( void ) { if ( cg.mvTotalClients > 0 && !cg.demoPlayback ) { if ( cg.spechelpWindow != SHOW_ON && cg_specHelp.integer > 0 ) { CG_ShowHelp_On( &cg.spechelpWindow ); @@ -797,12 +756,9 @@ void CG_toggleSpecHelp_f( void ) { } } } +#endif // -OSP -void CG_Obj_f( void ) { - // Gordon: short circuit this -} - static void CG_EditSpeakers_f( void ) { if ( cg.editingSpeakers ) { CG_DeActivateEditSoundMode(); @@ -945,8 +901,6 @@ typedef struct { static consoleCommand_t commands[] = { -// { "obj", CG_Obj_f }, -// { "setspawnpt", CG_Obj_f }, { "testgun", CG_TestGun_f }, { "testmodel", CG_TestModel_f }, { "nextframe", CG_TestModelNextFrame_f }, @@ -969,8 +923,7 @@ static consoleCommand_t commands[] = { "tell_target", CG_TellTarget_f }, { "tell_attacker", CG_TellAttacker_f }, { "tcmd", CG_TargetCommand_f }, - { "fade", CG_Fade_f }, // duffy - { "loadhud", CG_LoadHud_f }, + { "fade", CG_Fade_f }, { "loadweapons", CG_LoadWeapons_f }, { "mp_QuickMessage", CG_QuickMessage_f }, @@ -978,8 +931,6 @@ static consoleCommand_t commands[] = { "mp_fireteamadmin", CG_QuickFireteamAdmin_f }, { "wm_sayPlayerClass", CG_SayPlayerClass_f }, { "wm_ftsayPlayerClass",CG_FTSayPlayerClass_f }, - - { "VoiceChat", CG_VoiceChat_f }, { "VoiceTeamChat", CG_TeamVoiceChat_f }, @@ -1038,7 +989,7 @@ static consoleCommand_t commands[] = { "modifySpeaker", CG_ModifySpeaker_f }, { "undoSpeaker", CG_UndoSpeaker_f }, { "cpm", CG_CPM_f }, - { "forcetapout", CG_ForceTapOut_f }, + { "forcetapout", CG_ForceTapOut_f } }; static const size_t numCommands = ARRAY_LEN( commands ); @@ -1080,6 +1031,7 @@ static const char *gcmds[] = //"addtt", "addip", "ban", + "bot", "bottomshots", //"buddylist", "callvote", @@ -1101,8 +1053,9 @@ static const char *gcmds[] = "godother", "ignore", "kick", + "kickall", + "kickbots", "kill", - //"listbotgoals", "listcampaigns", "listip", "listmaxlivesip", diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index c5983901..a31e720d 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -2007,7 +2007,7 @@ static void CG_DrawCrosshairNames( void ) { } // NERVE - SMF - if ( cg.crosshairClientNum > MAX_CLIENTS ) { + if ( cg.crosshairClientNum >= MAX_CLIENTS ) { if ( !cg_drawCrosshairNames.integer ) { return; } @@ -4202,13 +4202,13 @@ void CG_DrawDemoRecording( void ) { if ( cg_demorecording.integer ) { Com_sprintf( demostatus, sizeof( demostatus ), " demo %s: %ik ", cg_demofilename.string, cg_demooffset.integer / 1024 ); } else { - strncpy( demostatus, "", sizeof( demostatus ) ); + demostatus[0] = '\0'; } if ( cg_waverecording.integer ) { Com_sprintf( wavestatus, sizeof( demostatus ), " audio %s: %ik ", cg_wavefilename.string, cg_waveoffset.integer / 1024 ); } else { - strncpy( wavestatus, "", sizeof( wavestatus ) ); + demostatus[0] = '\0'; } Com_sprintf( status, sizeof( status ), "RECORDING%s%s", demostatus, wavestatus ); diff --git a/src/cgame/cg_effects.c b/src/cgame/cg_effects.c index 76a535a7..2d753466 100644 --- a/src/cgame/cg_effects.c +++ b/src/cgame/cg_effects.c @@ -164,12 +164,6 @@ localEntity_t *CG_SmokePuff( const vec3_t p, const vec3_t vel, re->shaderRGBA[2] = le->color[2] * 0xff; re->shaderRGBA[3] = 0xff; } -// JPW NERVE - if ( cg_fxflags & 1 ) { - re->customShader = getTestShader(); - re->rotation = 180; - } -// jpw re->reType = RT_SPRITE; re->radius = le->radius; @@ -212,18 +206,6 @@ void CG_SpawnEffect( vec3_t org ) { re->origin[2] -= 24; } -qhandle_t getTestShader( void ) { - switch ( rand() % 2 ) { - case 0: - return cgs.media.nerveTestShader; - break; - case 1: - default: - return cgs.media.idTestShader; - break; - } -} - /* ==================== CG_MakeExplosion diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index 3597e6b5..c34a32c4 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -1341,15 +1341,13 @@ static void CG_SpotlightEfx( centity_t *cent ) { float dist, fov = 90; vec4_t color = {1, 1, 1, .1}; int splinetarget = 0; - char *cs; - VectorCopy( cent->currentState.origin2, targetpos ); splinetarget = cent->overheatTime; if ( !splinetarget ) { - cs = (char *)CG_ConfigString( CS_SPLINES + cent->currentState.density ); + const char *cs = CG_ConfigString( CS_SPLINES + cent->currentState.density ); cent->overheatTime = splinetarget = CG_LoadCamera( va( "cameras/%s.camera", cs ) ); if ( splinetarget != -1 ) { trap_startCamera( splinetarget, cg.time ); @@ -1985,7 +1983,7 @@ static void CG_Prop( centity_t *cent ) { } typedef enum cabinetType_e { - CT_AMMO, + CT_AMMO = 0, CT_HEALTH, CT_MAX, } cabinetType_t; diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c index 3fe4dcb6..76cbf276 100644 --- a/src/cgame/cg_event.c +++ b/src/cgame/cg_event.c @@ -42,10 +42,10 @@ CG_Obituary static void CG_Obituary( entityState_t *ent ) { int mod; int target, attacker; - char *message; - char *message2; - char targetName[32]; - char attackerName[32]; + const char *message; + const char *message2; + char targetName[MAX_NAME_LENGTH]; + char attackerName[MAX_NAME_LENGTH]; clientInfo_t *ci, *ca; // JPW NERVE ca = attacker qhandle_t deathShader = cgs.media.pmImages[PM_DEATH]; @@ -414,7 +414,7 @@ static void CG_Obituary( entityState_t *ent ) { //========================================================================== // from cg_weapons.c -extern int CG_WeaponIndex( int weapnum, int *bank, int *cycle ); +int CG_WeaponIndex( int weapnum, int *bank, int *cycle ); /* @@ -505,7 +505,7 @@ Also called by playerstate transition ================ */ void CG_PainEvent( centity_t *cent, int health, qboolean crouching ) { - char *snd; + const char *snd; // don't do more than two pain sounds a second if ( cg.time - cent->pe.painTime < 500 ) { @@ -576,8 +576,8 @@ void CG_PrecacheFXSounds( void ) { } } -void CG_Explodef( vec3_t origin, vec3_t dir, int mass, int type, qhandle_t sound, int forceLowGrav, qhandle_t shader ); -void CG_RubbleFx( vec3_t origin, vec3_t dir, int mass, int type, qhandle_t sound, int forceLowGrav, qhandle_t shader, float speedscale, float sizescale ); +void CG_Explodef( vec3_t origin, vec3_t dir, int mass, int type, sfxHandle_t sound, int forceLowGrav, qhandle_t shader ); +void CG_RubbleFx( vec3_t origin, vec3_t dir, int mass, int type, sfxHandle_t sound, int forceLowGrav, qhandle_t shader, float speedscale, float sizescale ); /* ============== @@ -1001,7 +1001,7 @@ CG_Explodef made this more generic for spawning hits and breaks without needing a *cent ============== */ -void CG_Explodef( vec3_t origin, vec3_t dir, int mass, int type, qhandle_t sound, int forceLowGrav, qhandle_t shader ) { +void CG_Explodef( vec3_t origin, vec3_t dir, int mass, int type, sfxHandle_t sound, int forceLowGrav, qhandle_t shader ) { int i; localEntity_t *le; refEntity_t *re; @@ -2545,7 +2545,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { break; case EV_FLAMETHROWER_EFFECT: - CG_FireFlameChunks( cent, cent->currentState.origin, cent->currentState.apos.trBase, 0.6, 2 ); + CG_FireFlameChunks( cent, cent->currentState.origin, cent->currentState.apos.trBase, 0.6, qtrue ); break; case EV_DUST: diff --git a/src/cgame/cg_fireteamoverlay.c b/src/cgame/cg_fireteamoverlay.c index fe3c9699..c9d24a77 100644 --- a/src/cgame/cg_fireteamoverlay.c +++ b/src/cgame/cg_fireteamoverlay.c @@ -105,7 +105,7 @@ void CG_SortClientFireteam() { } // Parses fireteam servercommand -void CG_ParseFireteams() { +void CG_ParseFireteams(void) { int i, j; char* s; const char* p; diff --git a/src/cgame/cg_flamethrower.c b/src/cgame/cg_flamethrower.c index 93724965..dd085fd6 100644 --- a/src/cgame/cg_flamethrower.c +++ b/src/cgame/cg_flamethrower.c @@ -732,7 +732,7 @@ void CG_AddFlameSpriteToScene( flameChunk_t *f, float lifeFrac, float alpha ) { frameNum = NUM_FLAME_SPRITES - 1; } - pPolyBuffer = CG_PB_FindFreePolyBuffer( cg_fxflags & 1 ? getTestShader() : flameShaders[frameNum], 4, 6 ); + pPolyBuffer = CG_PB_FindFreePolyBuffer( flameShaders[frameNum], 4, 6 ); pPolyBuffer->color[pPolyBuffer->numVerts + 0][0] = alphaChar; pPolyBuffer->color[pPolyBuffer->numVerts + 0][1] = alphaChar; @@ -756,7 +756,7 @@ void CG_AddFlameSpriteToScene( flameChunk_t *f, float lifeFrac, float alpha ) { } - if ( ( rotatingFlames ) && ( !( cg_fxflags & 1 ) ) ) { // JPW NERVE no rotate for alt flame shaders + if ( ( rotatingFlames ) ) { vectoangles( cg.refdef_current->viewaxis[0], rotate_ang ); rotate_ang[ROLL] += f->rollAngle; AngleVectors( rotate_ang, NULL, rright, rup ); diff --git a/src/cgame/cg_info.c b/src/cgame/cg_info.c index 7c8288a2..946aeb8a 100644 --- a/src/cgame/cg_info.c +++ b/src/cgame/cg_info.c @@ -69,7 +69,7 @@ void CG_LoadingString( const char *s ) { Q_strncpyz( cg.infoScreenText, s, sizeof( cg.infoScreenText ) ); if ( s && *s ) { - CG_Printf( va( "LOADING... %s\n",s ) ); //----(SA) added so you can see from the console what's going on + CG_Printf( "LOADING... %s\n", s ); //----(SA) added so you can see from the console what's going on } // Arnout: no need for this @@ -226,7 +226,7 @@ void CG_DemoClick( int key, qboolean down ) { cgs.thirdpersonUpdate = milli + DEMO_THIRDPERSONUPDATE; range -= ( ( range >= 4 * DEMO_RANGEDELTA ) ? DEMO_RANGEDELTA : ( range - DEMO_RANGEDELTA ) ); - trap_Cvar_Set( "cg_thirdPersonRange", va( "%f", range ) ); + trap_Cvar_Set( "cg_thirdPersonRange", va( "%g", range ) ); } return; case K_DOWNARROW: @@ -235,7 +235,7 @@ void CG_DemoClick( int key, qboolean down ) { cgs.thirdpersonUpdate = milli + DEMO_THIRDPERSONUPDATE; range += ( ( range >= 120 * DEMO_RANGEDELTA ) ? 0 : DEMO_RANGEDELTA ); - trap_Cvar_Set( "cg_thirdPersonRange", va( "%f", range ) ); + trap_Cvar_Set( "cg_thirdPersonRange", va( "%g", range ) ); } return; case K_RIGHTARROW: @@ -246,7 +246,7 @@ void CG_DemoClick( int key, qboolean down ) { if ( angle < 0 ) { angle += 360.0f; } - trap_Cvar_Set( "cg_thirdPersonAngle", va( "%f", angle ) ); + trap_Cvar_Set( "cg_thirdPersonAngle", va( "%g", angle ) ); } return; case K_LEFTARROW: @@ -257,7 +257,7 @@ void CG_DemoClick( int key, qboolean down ) { if ( angle >= 360.0f ) { angle -= 360.0f; } - trap_Cvar_Set( "cg_thirdPersonAngle", va( "%f", angle ) ); + trap_Cvar_Set( "cg_thirdPersonAngle", va( "%g", angle ) ); } return; @@ -279,7 +279,7 @@ void CG_DemoClick( int key, qboolean down ) { tscale -= 0.1f; } } else { tscale -= 1.0;} - trap_Cvar_Set( "timescale", va( "%f", tscale ) ); + trap_Cvar_Set( "timescale", va( "%g", tscale ) ); cgs.timescaleUpdate = cg.time + (int)( 1000.0f * tscale ); } return; @@ -292,13 +292,13 @@ void CG_DemoClick( int key, qboolean down ) { } // Roll over into timescale changes case K_KP_LEFTARROW: if ( !down && cg_timescale.value > 0.1f ) { - trap_Cvar_Set( "timescale", va( "%f", cg_timescale.value - 0.1f ) ); + trap_Cvar_Set( "timescale", va( "%g", cg_timescale.value - 0.1f ) ); cgs.timescaleUpdate = cg.time + (int)( 1000.0f * cg_timescale.value - 0.1f ); } return; case K_KP_UPARROW: if ( !down ) { - trap_Cvar_Set( "timescale", va( "%f", cg_timescale.value + 1.0f ) ); + trap_Cvar_Set( "timescale", va( "%g", cg_timescale.value + 1.0f ) ); cgs.timescaleUpdate = cg.time + (int)( 1000.0f * cg_timescale.value + 1.0f ); } return; @@ -311,7 +311,7 @@ void CG_DemoClick( int key, qboolean down ) { } // Roll over into timescale changes case K_KP_RIGHTARROW: if ( !down ) { - trap_Cvar_Set( "timescale", va( "%f", cg_timescale.value + 0.1f ) ); + trap_Cvar_Set( "timescale", va( "%g", cg_timescale.value + 0.1f ) ); cgs.timescaleUpdate = cg.time + (int)( 1000.0f * cg_timescale.value + 0.1f ); } return; @@ -854,7 +854,7 @@ void CG_DemoHelpDraw() { for ( i = 0; i < sizeof( help ) / sizeof( char * ); i++ ) { y += tSpacing; if ( help[i] != NULL ) { - CG_Text_Paint_Ext( x, y, tScale, tScale, tColor, (char*)help[i], 0.0f, 0, tStyle, tFont ); + CG_Text_Paint_Ext( x, y, tScale, tScale, tColor, help[i], 0.0f, 0, tStyle, tFont ); } } @@ -862,7 +862,7 @@ void CG_DemoHelpDraw() { for ( i = 0; i < sizeof( mvhelp ) / sizeof( char * ); i++ ) { y += tSpacing; if ( mvhelp[i] != NULL ) { - CG_Text_Paint_Ext( x, y, tScale, tScale, tColor, (char*)mvhelp[i], 0.0f, 0, tStyle, tFont ); + CG_Text_Paint_Ext( x, y, tScale, tScale, tColor, mvhelp[i], 0.0f, 0, tStyle, tFont ); } } } diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 85374501..2e5a9deb 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -401,7 +401,7 @@ typedef struct markPoly_s { //----(SA) moved in from cg_view.c typedef enum { - ZOOM_NONE, + ZOOM_NONE = 0, ZOOM_BINOC, ZOOM_SNIPER, ZOOM_SNOOPER, @@ -411,7 +411,7 @@ typedef enum { } EZoom_t; typedef enum { - ZOOM_OUT, // widest angle + ZOOM_OUT = 0, // widest angle ZOOM_IN // tightest angle (approaching 0) } EZoomInOut_t; @@ -420,7 +420,7 @@ extern float zoomTable[ZOOM_MAX_ZOOMS][2]; //----(SA) end typedef enum { - LE_MARK, + LE_MARK = 0, LE_EXPLOSION, LE_SPRITE_EXPLOSION, LE_FRAGMENT, @@ -447,12 +447,12 @@ typedef enum { } leFlag_t; typedef enum { - LEMT_NONE, + LEMT_NONE = 0, LEMT_BLOOD } leMarkType_t; // fragment local entities can leave marks on walls typedef enum { - LEBS_NONE, + LEBS_NONE = 0, LEBS_BLOOD, LEBS_ROCK, LEBS_WOOD, @@ -593,7 +593,7 @@ typedef struct clientInfo_s { } clientInfo_t; typedef enum { - W_PART_1, + W_PART_1 = 0, W_PART_2, W_PART_3, W_PART_4, @@ -604,7 +604,7 @@ typedef enum { } barrelType_t; typedef enum { - W_TP_MODEL, // third person model + W_TP_MODEL = 0, // third person model W_FP_MODEL, // first person model W_PU_MODEL, // pickup model W_NUM_TYPES @@ -761,7 +761,7 @@ typedef struct { // END xkan, 8/29/2002 typedef enum { - SHOW_OFF, + SHOW_OFF = 0, SHOW_SHUTDOWN, SHOW_ON } showView_t; @@ -1282,8 +1282,6 @@ typedef struct { qhandle_t binocShaderSimple; // JPW NERVE qhandle_t fleshSmokePuffShader; // JPW NERVE for bullet hit flesh smoke puffs - qhandle_t nerveTestShader; - qhandle_t idTestShader; qhandle_t hud1Shader; qhandle_t hud2Shader; qhandle_t hud3Shader; @@ -1887,7 +1885,7 @@ typedef struct { float nextTimeLimit; int minclients; gamestate_t gamestate; - char *currentCampaign; + char currentCampaign[256]; int currentCampaignMap; int complaintClient; // DHM - Nerve @@ -2021,6 +2019,8 @@ typedef struct { #ifdef ALLOW_GSYNC qboolean synchronousClients; #endif + + qboolean matchPaused; } cgs_t; //============================================================================== @@ -2112,7 +2112,7 @@ extern vmCvar_t cg_deferPlayers; extern vmCvar_t cg_teamChatsOnly; extern vmCvar_t cg_noVoiceChats; // NERVE - SMF extern vmCvar_t cg_noVoiceText; // NERVE - SMF -extern vmCvar_t cg_enableBreath; +//extern vmCvar_t cg_enableBreath; extern vmCvar_t cg_autoactivate; extern vmCvar_t cg_smoothClients; @@ -2239,6 +2239,7 @@ extern vmCvar_t cg_fovAdjust; const char *CG_ConfigString( int index ); int CG_ConfigStringCopy( int index, char* buff, int buffsize ); const char *CG_Argv( int arg ); +char *CG_ConcatArgs( int start ); float CG_Cvar_Get( const char *cvar ); @@ -2248,8 +2249,8 @@ void CG_printConsoleString( const char *str ); void CG_LoadObjectiveData( void ); -void QDECL CG_Printf( const char *msg, ... ); -void NORETURN QDECL CG_Error( const char *msg, ... ); +void QDECL CG_Printf( const char *msg, ... ) FORMAT_PRINTF(1, 2); +void NORETURN QDECL CG_Error( const char *msg, ... ) FORMAT_PRINTF(1, 2); void CG_StartMusic( void ); void CG_QueueMusic( void ); @@ -2351,7 +2352,6 @@ void CG_ReloadTranslation(); // // cg_draw.c, cg_newDraw.c // -extern char cg_fxflags; // JPW NERVE void CG_InitStatsDebug( void ); void CG_StatsDebugAddText( const char *text ); @@ -2731,7 +2731,7 @@ typedef struct { } playerInfo_t; typedef enum { - ANIM_IDLE, + ANIM_IDLE = 0, ANIM_RAISE, } animType_t; @@ -2762,6 +2762,7 @@ void CG_ExecuteNewServerCommands( int latestSequence ); void CG_ParseServerinfo( void ); void CG_ParseSysteminfo( void ); void CG_ParseWolfinfo( void ); // NERVE - SMF +void CG_ParseServerToggles( void ); void CG_ParseSpawns( void ); void CG_ParseServerVersionInfo( const char *pszVersionInfo ); void CG_ParseReinforcementTimes( const char *pszReinfSeedString ); @@ -3026,7 +3027,6 @@ void trap_SendMoveSpeedsToGame( int entnum, char *movespeeds ); void trap_UI_Popup( int arg0 ); // NERVE - SMF -qhandle_t getTestShader( void ); // JPW NERVE shhh void trap_UI_ClosePopup( const char *arg0 ); void trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ); void trap_Key_SetBinding( int keynum, const char *binding ); diff --git a/src/cgame/cg_localents.c b/src/cgame/cg_localents.c index f37d63f4..bb155481 100644 --- a/src/cgame/cg_localents.c +++ b/src/cgame/cg_localents.c @@ -357,7 +357,7 @@ void CG_AddEmitter( localEntity_t *le ) { //----(SA) end -void CG_Explodef( vec3_t origin, vec3_t dir, int mass, int type, qhandle_t sound, int forceLowGrav, qhandle_t shader ); +void CG_Explodef( vec3_t origin, vec3_t dir, int mass, int type, sfxHandle_t sound, int forceLowGrav, qhandle_t shader ); /* ================ diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 8d11b4d0..83eeb430 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -193,7 +193,7 @@ vmCvar_t cg_blood; vmCvar_t cg_predictItems; vmCvar_t cg_deferPlayers; vmCvar_t cg_drawTeamOverlay; -vmCvar_t cg_enableBreath; +//vmCvar_t cg_enableBreath; vmCvar_t cg_autoactivate; vmCvar_t cg_blinktime; //----(SA) added @@ -445,7 +445,7 @@ static const vmCvarTableItem_t cg_cvars[] = { { &cg_stats, "cg_stats", "0", 0 }, { &cg_blinktime, "cg_blinktime", "100", CVAR_ARCHIVE}, //----(SA) added - { &cg_enableBreath, "cg_enableBreath", "1", CVAR_SERVERINFO}, + //{ &cg_enableBreath, "cg_enableBreath", "1", CVAR_SERVERINFO}, { &cg_cameraOrbit, "cg_cameraOrbit", "0", CVAR_CHEAT}, { &cg_cameraOrbitDelay, "cg_cameraOrbitDelay", "50", CVAR_ARCHIVE}, { &cg_timescaleFadeEnd, "cg_timescaleFadeEnd", "1", 0}, @@ -654,7 +654,7 @@ int CG_LastAttacker( void ) { return( ( !cg.attackerTime ) ? -1 : cg.snap->ps.persistant[PERS_ATTACKER] ); } -void QDECL CG_Printf( const char *msg, ... ) { +void FORMAT_PRINTF(1, 2) QDECL CG_Printf( const char *msg, ... ) { va_list argptr; char text[1024]; @@ -679,7 +679,7 @@ void QDECL CG_Printf( const char *msg, ... ) { trap_Print( text ); } -void NORETURN QDECL CG_Error( const char *msg, ... ) { +void NORETURN FORMAT_PRINTF(1, 2) QDECL CG_Error( const char *msg, ... ) { va_list argptr; char text[1024]; @@ -741,6 +741,39 @@ const char *CG_Argv( int arg ) { } +/* +================== +CG_ConcatArgs +================== +*/ +char *CG_ConcatArgs( int start ) { + int i, c, tlen; + static char line[BIG_INFO_STRING]; + int len; + char arg[MAX_STRING_CHARS]; + + len = 0; + c = trap_Argc(); + for ( i = start ; i < c ; i++ ) { + trap_Argv( i, arg, sizeof( arg ) ); + tlen = (int)strlen( arg ); + if ( len + tlen >= sizeof(line) - 1 ) { + break; + } + memcpy( line + len, arg, tlen ); + len += tlen; + if ( i != c - 1 ) { + line[len] = ' '; + len++; + } + } + + line[len] = '\0'; + + return line; +} + + // Cleans a string for filesystem compatibility void CG_nameCleanFilename( const char *pszIn, char *pszOut, unsigned int dwOutSize ) { unsigned int dwCurrLength = 0; @@ -1019,7 +1052,7 @@ static void CG_RegisterItemSounds( int itemNum ) { return; } memcpy( data, start, len ); - data[len] = 0; + data[len] = '\0'; if ( *s ) { s++; } @@ -1272,7 +1305,7 @@ void WM_RegisterWeaponTypeShaders(); static void CG_RegisterGraphics( void ) { int i; - static char *sb_nums[11] = { + static const char *sb_nums[11] = { "gfx/2d/numbers/zero_32b", "gfx/2d/numbers/one_32b", "gfx/2d/numbers/two_32b", @@ -1342,8 +1375,6 @@ static void CG_RegisterGraphics( void ) { } cgs.media.fleshSmokePuffShader = trap_R_RegisterShader( "fleshimpactsmokepuff" ); // JPW NERVE - cgs.media.nerveTestShader = trap_R_RegisterShader( "jpwtest1" ); - cgs.media.idTestShader = trap_R_RegisterShader( "jpwtest2" ); cgs.media.hud1Shader = trap_R_RegisterShader( "jpwhud1" ); cgs.media.hud2Shader = trap_R_RegisterShader( "jpwhud2" ); cgs.media.hud3Shader = trap_R_RegisterShader( "jpwhud3" ); @@ -2030,30 +2061,6 @@ void CG_QueueMusic( void ) { trap_S_StartBackgroundTrack( parm, "", -2 ); // '-2' for 'queue looping track' (QUEUED_PLAY_LOOPED) } -#if 0 //DAJ unused -char *CG_GetMenuBuffer( const char *filename ) { - int len; - fileHandle_t f; - static char buf[MAX_MENUFILE]; - - len = trap_FS_FOpenFile( filename, &f, FS_READ ); - if ( !f ) { - trap_Print( va( S_COLOR_RED "menu file not found: %s, using default\n", filename ) ); - return NULL; - } - if ( len >= MAX_MENUFILE ) { - trap_Print( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", filename, len, MAX_MENUFILE ) ); - trap_FS_FCloseFile( f ); - return NULL; - } - - trap_FS_Read( buf, len, f ); - buf[len] = 0; - trap_FS_FCloseFile( f ); - - return buf; -} -#endif // // ============================== // new hud stuff ( mission pack ) @@ -2277,21 +2284,21 @@ void CG_LoadMenus( const char *menuFile ) { len = trap_FS_FOpenFile( menuFile, &f, FS_READ ); if ( !f ) { - trap_Error( va( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ) ); + CG_Printf( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ); len = trap_FS_FOpenFile( "ui/hud.txt", &f, FS_READ ); if ( !f ) { - trap_Error( S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n" ); + CG_Error( S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n" ); } } if ( len >= MAX_MENUDEFFILE ) { - trap_Error( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", menuFile, len, MAX_MENUDEFFILE ) ); trap_FS_FCloseFile( f ); + trap_Error( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", menuFile, len, MAX_MENUDEFFILE ) ); return; } trap_FS_Read( buf, len, f ); - buf[len] = 0; + buf[len] = '\0'; trap_FS_FCloseFile( f ); COM_Compress( buf ); @@ -2706,6 +2713,7 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum, qb CG_ParseServerinfo(); CG_ParseSysteminfo(); CG_ParseWolfinfo(); // NERVE - SMF + CG_ParseServerToggles(); cgs.campaignInfoLoaded = qfalse; if ( cgs.gametype == GT_WOLF_CAMPAIGN ) { @@ -2796,7 +2804,7 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum, qb CG_InitMarkPolys(); // remove the last loading update - cg.infoScreenText[0] = 0; + cg.infoScreenText[0] = '\0'; // Make sure we have update values (scores) CG_SetConfigValues(); diff --git a/src/cgame/cg_missionbriefing.c b/src/cgame/cg_missionbriefing.c index 147c57e0..59f3d5d3 100644 --- a/src/cgame/cg_missionbriefing.c +++ b/src/cgame/cg_missionbriefing.c @@ -36,7 +36,7 @@ const char* CG_NameForCampaign( void ) { return cgs.campaignInfoLoaded ? cgs.campaignData.campaignName : NULL; } -qboolean CG_FindCampaignInFile( char *filename, char *campaignShortName, cg_campaignInfo_t *info ) { +qboolean CG_FindCampaignInFile( const char *filename, const char *campaignShortName, cg_campaignInfo_t *info ) { int handle; pc_token_t token; // char* dummy; diff --git a/src/cgame/cg_multiview.c b/src/cgame/cg_multiview.c index 4e7b4a04..f5406542 100644 --- a/src/cgame/cg_multiview.c +++ b/src/cgame/cg_multiview.c @@ -44,11 +44,7 @@ void CG_mvNew_f( void ) { if ( cg.demoPlayback || trap_Argc() < 2 ) { return; } else { - int pID; - char aName[64]; - - trap_Args( aName, sizeof( aName ) ); - pID = CG_findClientNum( aName ); + int pID = CG_findClientNum( CG_ConcatArgs(1) ); if ( pID >= 0 && !CG_mvMergedClientLocate( pID ) ) { trap_SendClientCommand( va( "mvadd %d\n", pID ) ); @@ -64,10 +60,7 @@ void CG_mvDelete_f( void ) { int pID = -1; if ( trap_Argc() > 1 ) { - char aName[64]; - - trap_Args( aName, sizeof( aName ) ); - pID = CG_findClientNum( aName ); + pID = CG_findClientNum( CG_ConcatArgs(1) ); } else { cg_window_t *w = cg.mvCurrentActive; if ( w != NULL ) { diff --git a/src/cgame/cg_newDraw.c b/src/cgame/cg_newDraw.c index 02b9ede4..a2d625d5 100644 --- a/src/cgame/cg_newDraw.c +++ b/src/cgame/cg_newDraw.c @@ -106,7 +106,7 @@ int CG_TrimLeftPixels( char* instr, float scale, float w, int size ) { void CG_FitTextToWidth_Ext( char* instr, float scale, float w, int size, fontInfo_t* font ) { char buffer[1024]; char *s, *p, *c, *ls; - int l; + //int l; Q_strncpyz( buffer, instr, 1024 ); memset( instr, 0, size ); @@ -114,10 +114,10 @@ void CG_FitTextToWidth_Ext( char* instr, float scale, float w, int size, fontInf c = s = instr; p = buffer; ls = NULL; - l = 0; + //l = 0; while ( *p ) { *c = *p++; - l++; + //l++; if ( *c == ' ' ) { ls = c; @@ -127,7 +127,7 @@ void CG_FitTextToWidth_Ext( char* instr, float scale, float w, int size, fontInf if ( *p == '\n' ) { s = c + 1; - l = 0; + //l = 0; } else if ( CG_Text_Width_Ext( s, scale, 0, font ) > w ) { if ( ls ) { *ls = '\n'; @@ -139,7 +139,7 @@ void CG_FitTextToWidth_Ext( char* instr, float scale, float w, int size, fontInf } ls = NULL; - l = 0; + //l = 0; } } @@ -153,7 +153,7 @@ void CG_FitTextToWidth_Ext( char* instr, float scale, float w, int size, fontInf void CG_FitTextToWidth2( char* instr, float scale, float w, int size ) { char buffer[1024]; char *s, *p, *c, *ls; - int l; + //int l; Q_strncpyz( buffer, instr, 1024 ); memset( instr, 0, size ); @@ -161,10 +161,10 @@ void CG_FitTextToWidth2( char* instr, float scale, float w, int size ) { c = s = instr; p = buffer; ls = NULL; - l = 0; + //l = 0; while ( *p ) { *c = *p++; - l++; + //l++; if ( *c == ' ' ) { ls = c; @@ -174,7 +174,7 @@ void CG_FitTextToWidth2( char* instr, float scale, float w, int size ) { if ( *p == '\n' ) { s = c + 1; - l = 0; + //l = 0; } else if ( CG_Text_Width( s, scale, 0 ) > w ) { if ( ls ) { *ls = '\n'; @@ -186,7 +186,7 @@ void CG_FitTextToWidth2( char* instr, float scale, float w, int size ) { } ls = NULL; - l = 0; + //l = 0; } } diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c index cad7c980..1334b813 100644 --- a/src/cgame/cg_particles.c +++ b/src/cgame/cg_particles.c @@ -79,7 +79,7 @@ typedef struct particle_s typedef enum { - P_NONE, + P_NONE = 0, P_WEATHER, P_FLAT, P_SMOKE, @@ -748,14 +748,6 @@ void CG_AddParticleToScene( cparticle_t *p, vec3_t org, float alpha ) { j = (int)floor( ratio * shaderAnimCounts[p->shaderAnim] ); p->pshader = shaderAnims[i][j]; - // JPW NERVE more particle testing - if ( cg_fxflags & 1 ) { - p->roll = 0; - p->pshader = getTestShader(); - rotate_ang[ROLL] = 90; - } - // jpw - if ( p->roll ) { vectoangles( cg.refdef_current->viewaxis[0], rotate_ang ); rotate_ang[ROLL] += p->roll; @@ -1403,12 +1395,6 @@ void CG_ParticleDirtBulletDebris_Core( vec3_t org, vec3_t vel, int duration, flo p->type = P_SMOKE; p->pshader = shader; - if ( cg_fxflags & 1 ) { - p->pshader = getTestShader(); - p->rotate = 0; - p->roll = 0; - p->type = P_SPRITE; - } VectorCopy( org, p->org ); VectorCopy( vel, p->vel ); diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index a21fb487..8a0607fb 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -2836,10 +2836,10 @@ weaponType_t weaponTypes[] = { { WP_LUGER, "LUGER", }, { WP_AKIMBO_COLT, "AKIMBO COLTS", }, { WP_AKIMBO_LUGER, "AKIMBO LUGERS",}, - { WP_SILENCED_COLT, "COLT", }, - { WP_SILENCER, "LUGER", }, - { WP_AKIMBO_SILENCEDCOLT, "AKIMBO COLTS", }, - { WP_AKIMBO_SILENCEDLUGER, "AKIMBO LUGERS",}, + { WP_SILENCED_COLT, "SILENCED COLT", }, + { WP_SILENCER, "SILENCED LUGER", }, + { WP_AKIMBO_SILENCEDCOLT, "AKIMBO SILENCED COLTS", }, + { WP_AKIMBO_SILENCEDLUGER, "AKIMBO SILENCED LUGERS",}, { WP_NONE, NULL, }, { -1, NULL, }, }; diff --git a/src/cgame/cg_playerstate.c b/src/cgame/cg_playerstate.c index 85370c0a..44fdebba 100644 --- a/src/cgame/cg_playerstate.c +++ b/src/cgame/cg_playerstate.c @@ -260,7 +260,7 @@ void CG_Respawn( qboolean revived ) { cg.weaponSelect = cg.snap->ps.weapon; // DHM - Nerve :: Clear even more things on respawn cg.zoomedBinoc = qfalse; - cg.zoomedScope = qfalse; + cg.zoomedScope = 0; cg.zoomTime = 0; cg.zoomval = 0; diff --git a/src/cgame/cg_popupmessages.c b/src/cgame/cg_popupmessages.c index 9c26c823..036ac8f1 100644 --- a/src/cgame/cg_popupmessages.c +++ b/src/cgame/cg_popupmessages.c @@ -291,7 +291,7 @@ void CG_AddPMItem( popupMessageType_t type, const char* message, qhandle_t shade // console deals with newlines perfectly. We do chop off the newline // at the end, if any, though. if ( listItem->message[strlen( listItem->message ) - 1] == '\n' ) { - listItem->message[strlen( listItem->message ) - 1] = 0; + listItem->message[strlen( listItem->message ) - 1] = '\0'; } trap_Print( va( "%s\n", listItem->message ) ); diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index 8d0e53f5..1c3fdd9c 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -305,7 +305,7 @@ void CG_ParseWolfinfo( void ) { cgs.currentRound = atoi( Info_ValueForKey( info, "g_currentRound" ) ); cgs.nextTimeLimit = Q_atof( Info_ValueForKey( info, "g_nextTimeLimit" ) ); cgs.gamestate = atoi( Info_ValueForKey( info, "gamestate" ) ); - cgs.currentCampaign = Info_ValueForKey( info, "g_currentCampaign" ); + Q_strncpyz( cgs.currentCampaign, Info_ValueForKey( info, "g_currentCampaign" ), sizeof( cgs.currentCampaign ) ); cgs.currentCampaignMap = atoi( Info_ValueForKey( info, "g_currentCampaignMap" ) ); // OSP - Announce game in progress if we are really playing @@ -324,6 +324,16 @@ void CG_ParseWolfinfo( void ) { } } +void CG_ParseServerToggles( void ) { + const char *info; + int value; + + info = CG_ConfigString( CS_SERVERTOGGLES ); + value = atoi( info ); + + cgs.matchPaused = (value & CV_SVS_PAUSE) ? qtrue : qfalse; +} + /* ================== CG_ParseSpawns @@ -564,12 +574,12 @@ void CG_ShaderStateChanged( void ) { n = strstr( o, "=" ); if ( n && *n ) { strncpy( originalShader, o, n - o ); - originalShader[n - o] = 0; + originalShader[n - o] = '\0'; n++; t = strstr( n, ":" ); if ( t && *t ) { strncpy( newShader, n, t - n ); - newShader[t - n] = 0; + newShader[t - n] = '\0'; } else { break; } @@ -577,7 +587,7 @@ void CG_ShaderStateChanged( void ) { o = strstr( t, "@" ); if ( o ) { strncpy( timeOffset, t, o - t ); - timeOffset[o - t] = 0; + timeOffset[o - t] = '\0'; o++; trap_R_RemapShader( cgs.gameShaderNames[atoi( originalShader )], cgs.gameShaderNames[atoi( newShader )], @@ -643,6 +653,8 @@ static void CG_ConfigStringModified( void ) { CG_ParseWarmup(); } else if ( num == CS_WOLFINFO ) { // NERVE - SMF CG_ParseWolfinfo(); + } else if ( num == CS_SERVERTOGGLES ) { + CG_ParseServerToggles(); } else if ( num == CS_FIRSTBLOOD ) { cg.teamFirstBlood = atoi( str ); } else if ( num == CS_ROUNDSCORES1 ) { @@ -920,7 +932,7 @@ static void CG_MapRestart( void ) { // (SA) clear zoom (so no warpies) cg.zoomedBinoc = qfalse; - cg.zoomedScope = qfalse; + cg.zoomedScope = 0; cg.zoomTime = 0; cg.zoomval = 0; @@ -991,9 +1003,6 @@ static void CG_MapRestart( void ) { cg.latchAutoActions = qfalse; cg.latchVictorySound = qfalse; // NERVE - SMF -// JPW NERVE -- reset render flags - cg_fxflags = 0; -// jpw // we really should clear more parts of cg here and stop sounds cg.v_dmg_time = 0; @@ -1079,17 +1088,17 @@ int CG_ParseVoiceChats( const char *filename, voiceChatList_t *voiceChatList, in len = trap_FS_FOpenFile( filename, &f, FS_READ ); if ( !f ) { - trap_Print( va( S_COLOR_RED "voice chat file not found: %s\n", filename ) ); + CG_Printf( S_COLOR_RED "voice chat file not found: %s\n", filename ); return qfalse; } if ( len >= MAX_VOICEFILESIZE ) { - trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i", filename, len, MAX_VOICEFILESIZE ) ); + CG_Printf( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i\n", filename, len, MAX_VOICEFILESIZE ); trap_FS_FCloseFile( f ); return qfalse; } trap_FS_Read( buf, len, f ); - buf[len] = 0; + buf[len] = '\0'; trap_FS_FCloseFile( f ); ptr = buf; @@ -1098,7 +1107,7 @@ int CG_ParseVoiceChats( const char *filename, voiceChatList_t *voiceChatList, in Com_sprintf( voiceChatList->name, sizeof( voiceChatList->name ), "%s", filename ); voiceChats = voiceChatList->voiceChats; for ( i = 0; i < maxVoiceChats; i++ ) { - voiceChats[i].id[0] = 0; + voiceChats[i].id[0] = '\0'; } token = COM_ParseExt( p, qtrue ); if ( !token || token[0] == 0 ) { @@ -1111,7 +1120,7 @@ int CG_ParseVoiceChats( const char *filename, voiceChatList_t *voiceChatList, in } else if ( !Q_stricmp( token, "neuter" ) ) { voiceChatList->gender = GENDER_NEUTER; } else { - trap_Print( va( S_COLOR_RED "expected gender not found in voice chat file: %s\n", filename ) ); + CG_Printf( S_COLOR_RED "expected gender not found in voice chat file: %s\n", filename ); return qfalse; } @@ -1129,7 +1138,7 @@ int CG_ParseVoiceChats( const char *filename, voiceChatList_t *voiceChatList, in Com_sprintf( voiceChats[voiceChatList->numVoiceChats].id, sizeof( voiceChats[voiceChatList->numVoiceChats].id ), "%s", token ); token = COM_ParseExt( p, qtrue ); if ( Q_stricmp( token, "{" ) ) { - trap_Print( va( S_COLOR_RED "expected { found %s in voice chat file: %s\n", token, filename ) ); + CG_Printf( S_COLOR_RED "expected { found %s in voice chat file: %s\n", token, filename ); return qfalse; } voiceChats[voiceChatList->numVoiceChats].numSounds = 0; @@ -1197,53 +1206,6 @@ void CG_LoadVoiceChats( void ) { CG_Printf( "voice chat memory size = %d\n", size - trap_MemoryRemaining() ); } -/* -================= -CG_HeadModelVoiceChats -================= -*/ -/*int CG_HeadModelVoiceChats( char *filename ) { - int len, i; - fileHandle_t f; - char buf[MAX_VOICEFILESIZE]; - char **p, *ptr; - char *token; - - len = trap_FS_FOpenFile( filename, &f, FS_READ ); - if ( !f ) { - trap_Print( va( "voice chat file not found: %s\n", filename ) ); - return -1; - } - if ( len >= MAX_VOICEFILESIZE ) { - trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i", filename, len, MAX_VOICEFILESIZE ) ); - trap_FS_FCloseFile( f ); - return -1; - } - - trap_FS_Read( buf, len, f ); - buf[len] = 0; - trap_FS_FCloseFile( f ); - - ptr = buf; - p = &ptr; - - token = COM_ParseExt( p, qtrue ); - if ( !token || token[0] == 0 ) { - return -1; - } - - for ( i = 0; i < MAX_VOICEFILES; i++ ) { - if ( !Q_stricmp( token, voiceChatLists[i].name ) ) { - return i; - } - } - - //FIXME: maybe try to load the .voice file which name is stored in token? - - return -1; -}*/ - - /* ================= CG_GetVoiceChat @@ -1958,7 +1920,7 @@ void CG_scores_cmd( void ) { } static void CG_printFile( const char *str ) { - CG_Printf( str ); + CG_Printf( "%s", str ); if ( cgs.dumpStatsFile > 0 ) { char s[MAX_STRING_CHARS]; diff --git a/src/cgame/cg_snapshot.c b/src/cgame/cg_snapshot.c index 19d992f2..b653e24b 100644 --- a/src/cgame/cg_snapshot.c +++ b/src/cgame/cg_snapshot.c @@ -178,9 +178,6 @@ void CG_SetInitialSnapshot( snapshot_t *snap ) { CG_CheckEvents( cent ); } - cg_fxflags = 0; - - trap_Cvar_VariableStringBuffer( "r_oldMode", buff, sizeof( buff ) ); if ( atoi( buff ) ) { // Arnout: confirmation screen diff --git a/src/cgame/cg_sound.c b/src/cgame/cg_sound.c index a2bd95e0..f8837c75 100644 --- a/src/cgame/cg_sound.c +++ b/src/cgame/cg_sound.c @@ -80,7 +80,6 @@ CG_SoundScriptPrecache int CG_SoundScriptPrecache( const char *name ) { soundScriptSound_t *scriptSound; long hash; - char *s; soundScript_t *sound; // byte buf[1024]; int i; @@ -91,9 +90,8 @@ int CG_SoundScriptPrecache( const char *name ) { hash = generateHashValue( name ); - s = (char *)name; for ( sound = hashTable[hash]; sound; sound = sound->nextHash ) { - if ( !Q_stricmp( s, sound->name ) ) { + if ( !Q_stricmp( name, sound->name ) ) { // found a match, precache these sounds scriptSound = sound->soundList; for ( ; scriptSound; scriptSound = scriptSound->next ) { @@ -266,17 +264,17 @@ static void CG_SoundParseSounds( const char *filename, const char *buffer ) { token = COM_ParseExt( text, qtrue ); if ( !*token ) { if ( inSound ) { - CG_Error( "no concluding '}' in sound %s, file %s\n", sound.name, filename ); + CG_Error( "no concluding '}' in sound %s, file %s", sound.name, filename ); } return; } if ( !Q_stricmp( token, "{" ) ) { if ( inSound ) { - CG_Error( "no concluding '}' in sound %s, file %s\n", sound.name, filename ); + CG_Error( "no concluding '}' in sound %s, file %s", sound.name, filename ); } if ( wantSoundName ) { - CG_Error( "'{' found but not expected, after %s, file %s\n", sound.name, filename ); + CG_Error( "'{' found but not expected, after %s, file %s", sound.name, filename ); } inSound = qtrue; @@ -284,7 +282,7 @@ static void CG_SoundParseSounds( const char *filename, const char *buffer ) { scriptSound = &soundScriptSounds[numSoundScriptSounds++]; if ( numSoundScripts == MAX_SOUND_SCRIPT_SOUNDS ) { - CG_Error( "MAX_SOUND_SCRIPT_SOUNDS exceeded.\nReduce number of sound scripts.\n" ); + CG_Error( "MAX_SOUND_SCRIPT_SOUNDS exceeded.\nReduce number of sound scripts." ); } scriptSound->lastPlayed = 0; @@ -297,7 +295,7 @@ static void CG_SoundParseSounds( const char *filename, const char *buffer ) { if ( !Q_stricmp( token, "}" ) ) { if ( !inSound ) { - CG_Error( "'}' unexpected after sound %s, file %s\n", sound.name, filename ); + CG_Error( "'}' unexpected after sound %s, file %s", sound.name, filename ); } // end of a sound, copy it to the global list and stick it in the hashTable @@ -321,7 +319,7 @@ static void CG_SoundParseSounds( const char *filename, const char *buffer ) { if ( !inSound ) { // this is the identifier for a new sound if ( !wantSoundName ) { - CG_Error( "'%s' unexpected after sound %s, file %s\n", token, sound.name, filename ); + CG_Error( "'%s' unexpected after sound %s, file %s", token, sound.name, filename ); } memset( &sound, 0, sizeof( sound ) ); Q_strncpyz( sound.name, token, sizeof( sound.name ) ); @@ -377,11 +375,14 @@ static void CG_SoundParseSounds( const char *filename, const char *buffer ) { if ( !Q_stricmp( token, "sound" ) ) { if ( scriptSound->numsounds >= MAX_SOUNDSCRIPT_SOUNDS ) { - CG_Error( "Too many sounds for soundscript %s\n" ); + CG_Error( "CG_SoundParseSounds(): Too many sounds for soundscript" ); } token = COM_ParseExt( text, qtrue ); + if ( !token[0] ) { + CG_Error( "CG_SoundParseSounds(): empty sound file name" ); + } Q_strncpyz( scriptSound->sounds[scriptSound->numsounds].filename, token, sizeof( scriptSound->sounds[0].filename ) ); scriptSound->numsounds++; @@ -419,11 +420,11 @@ static void CG_SoundLoadSoundFiles( void ) { } if ( len > sizeof( bigTextBuffer ) ) { trap_FS_FCloseFile( f ); - CG_Error( "%s is too big, make it smaller (max = %i bytes)\n", filename, sizeof( bigTextBuffer ) ); + CG_Error( "%s is too big, make it smaller (max = %u bytes)", filename, (unsigned)sizeof( bigTextBuffer ) ); } // load the file into memory trap_FS_Read( bigTextBuffer, len, f ); - bigTextBuffer[len] = 0; + bigTextBuffer[len] = '\0'; trap_FS_FCloseFile( f ); // parse the list text = bigTextBuffer; @@ -457,10 +458,11 @@ static void CG_SoundLoadSoundFiles( void ) { continue; } if ( len > sizeof( bigTextBuffer ) ) { - CG_Error( "%s is too big, make it smaller (max = %i bytes)\n", filename, sizeof( bigTextBuffer ) ); + CG_Error( "%s is too big, make it smaller (max = %u bytes)", filename, (unsigned)sizeof( bigTextBuffer ) ); } memset( bigTextBuffer, 0, sizeof( bigTextBuffer ) ); trap_FS_Read( bigTextBuffer, len, f ); + bigTextBuffer[len] = '\0'; trap_FS_FCloseFile( f ); CG_SoundParseSounds( filename, bigTextBuffer ); } diff --git a/src/cgame/cg_spawn.c b/src/cgame/cg_spawn.c index 679a52da..3ea1bcaa 100644 --- a/src/cgame/cg_spawn.c +++ b/src/cgame/cg_spawn.c @@ -243,21 +243,20 @@ void SP_trigger_objective_info( void ) { } typedef struct { - char *name; + const char *name; void ( *spawn )( void ); } spawn_t; -spawn_t spawns[] = { - {0, 0}, +static const spawn_t spawns[] = { {"path_corner_2", SP_path_corner_2}, {"info_train_spline_main", SP_info_train_spline_main}, {"info_train_spline_control", SP_path_corner_2}, {"trigger_objective_info", SP_trigger_objective_info}, {"misc_gamemodel", SP_misc_gamemodel}, -}; -#define NUMSPAWNS ( sizeof( spawns ) / sizeof( spawn_t ) ) + { NULL, NULL } +}; /* =================== @@ -278,9 +277,10 @@ void CG_ParseEntityFromSpawnVars( void ) { } if ( CG_SpawnString( "classname", "", &classname ) ) { - for ( i = 0; i < NUMSPAWNS; i++ ) { - if ( !Q_stricmp( spawns[i].name, classname ) ) { - spawns[i].spawn(); + const spawn_t *s; + for ( s = spawns ; s->name ; s++ ) { + if ( !Q_stricmp( s->name, classname ) ) { + s->spawn(); break; } } diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index 89968320..140258f0 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -449,7 +449,7 @@ void CG_KickAngles( void ) { if ( Q_atof( buf ) != cg.recoilPitchAngle ) { // encode the kick angles into a 24bit number, for sending to the client exe - trap_Cvar_Set( "cg_recoilPitch", va( "%f", cg.recoilPitchAngle ) ); + trap_Cvar_Set( "cg_recoilPitch", va( "%g", cg.recoilPitchAngle ) ); } } @@ -1081,7 +1081,6 @@ static void CG_DamageBlendBlob( void ) { refEntity_t ent; qboolean pointDamage; viewDamage_t *vd; - float redFlash; // Gordon: no damage blend blobs if in limbo or spectator, and in the limbo menu if ( ( cg.snap->ps.pm_flags & PMF_LIMBO || cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR ) && cg.showGameView ) { @@ -1093,8 +1092,6 @@ static void CG_DamageBlendBlob( void ) { return; } - redFlash = 0; - for ( i = 0; i < MAX_VIEWDAMAGE; i++ ) { vd = &cg.viewDamage[i]; @@ -1113,7 +1110,6 @@ static void CG_DamageBlendBlob( void ) { // if not point Damage, only do flash blend if ( !pointDamage ) { - redFlash += 10.0 * ( 1.0 - (float)t / maxTime ); continue; } @@ -1135,8 +1131,6 @@ static void CG_DamageBlendBlob( void ) { ( cg_bloodDamageBlend.value < 0.0f ) ? 0.0f : cg_bloodDamageBlend.value ); trap_R_AddRefEntityToScene( &ent ); - - redFlash += ent.radius; } } @@ -1376,10 +1370,10 @@ int CG_CalcViewValues( void ) { //========================================================================= -const char* CG_MustParse( const char** pString, const char* pErrorMsg ) { +static const char* CG_MustParse( const char** pString, const char* pErrorMsg ) { const char* token = COM_Parse( pString ); if ( !*token ) { - CG_Error( pErrorMsg ); + CG_Error( "%s", pErrorMsg ); } return token; } @@ -1396,16 +1390,16 @@ void CG_ParseSkyBox( void ) { return; } - token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring\n" ); + token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring" ); cg.skyboxViewOrg[0] = Q_atof( token ); - token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring\n" ); + token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring" ); cg.skyboxViewOrg[1] = Q_atof( token ); - token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring\n" ); + token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring" ); cg.skyboxViewOrg[2] = Q_atof( token ); - token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring\n" ); + token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring" ); cg.skyboxViewFov = atoi( token ); if ( !cg.skyboxViewFov ) { @@ -1413,15 +1407,15 @@ void CG_ParseSkyBox( void ) { } // setup fog the first time, ignore this part of the configstring after that - token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring. No fog state\n" ); + token = CG_MustParse( &cstr, "CG_ParseSkyBox: error parsing skybox configstring. No fog state" ); if ( atoi( token ) ) { // this camera has fog - token = CG_MustParse( &cstr, "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[0]\n" ); + token = CG_MustParse( &cstr, "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[0]" ); fogColor[0] = Q_atof( token ); - token = CG_MustParse( &cstr, "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[1]\n" ); + token = CG_MustParse( &cstr, "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[1]" ); fogColor[1] = Q_atof( token ); - token = CG_MustParse( &cstr, "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[2]\n" ); + token = CG_MustParse( &cstr, "CG_DrawSkyBoxPortal: error parsing skybox configstring. No fog[2]" ); fogColor[2] = Q_atof( token ); token = COM_ParseExt( &cstr, qfalse ); @@ -1460,21 +1454,21 @@ void CG_ParseTagConnect( int tagNum ) { return; } - token = CG_MustParse( &pString, "Invalid TAGCONNECT configstring\n" ); + token = CG_MustParse( &pString, "Invalid TAGCONNECT configstring" ); entNum = atoi( token ); if ( entNum < 0 || entNum >= MAX_GENTITIES ) { - CG_Error( "Invalid TAGCONNECT entitynum\n" ); + CG_Error( "Invalid TAGCONNECT entitynum" ); } - token = CG_MustParse( &pString, "Invalid TAGCONNECT configstring\n" ); + token = CG_MustParse( &pString, "Invalid TAGCONNECT configstring" ); cg_entities[entNum].tagParent = atoi( token ); if ( cg_entities[entNum].tagParent < 0 || cg_entities[entNum].tagParent >= MAX_GENTITIES ) { - CG_Error( "Invalid TAGCONNECT tagparent\n" ); + CG_Error( "Invalid TAGCONNECT tagparent" ); } - token = CG_MustParse( &pString, "Invalid TAGCONNECT configstring\n" ); + token = CG_MustParse( &pString, "Invalid TAGCONNECT configstring" ); Q_strncpyz( cg_entities[entNum].tagName, token, MAX_QPATH ); } diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index ba2a3140..bfcbbdc6 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -37,18 +37,6 @@ If you have questions concerning this license or the applicable additional terms vec3_t ejectBrassCasingOrigin; -//----(SA) -// forward decs -static int getAltWeapon( int weapnum ); -int getEquivWeapon( int weapnum ); -int CG_WeaponIndex( int weapnum, int *bank, int *cycle ); -static qboolean CG_WeaponHasAmmo( int i ); -char cg_fxflags; -extern int weapBanksMultiPlayer[MAX_WEAP_BANKS_MP][MAX_WEAPS_IN_BANK_MP]; // JPW NERVE moved to bg_misc.c so I can get a droplist -// jpw - -//----(SA) end - /* ============== CG_StartWeaponAnim @@ -146,7 +134,6 @@ void CG_MachineGunEjectBrassNew( centity_t *cent ) { le->leFlags = LEF_TUMBLE; - { int contents; vec3_t end; @@ -555,7 +542,6 @@ void CG_PyroSmokeTrail( centity_t *ent, const weaponInfo_t *wi ) { } // jpw - // Ridah, new trail effects /* ========================== @@ -926,7 +912,7 @@ static qboolean CG_ParseWeaponConfig( const char *filename, weaponInfo_t *wi ) { } trap_FS_Read( text, len, f ); - text[len] = 0; + text[len] = '\0'; trap_FS_FCloseFile( f ); // parse the text @@ -960,7 +946,6 @@ static qboolean CG_ParseWeaponConfig( const char *filename, weaponInfo_t *wi ) { Com_Printf( "unknown token in weapon cfg '%s' is %s\n", token, filename ); } - for ( i = 0 ; i < MAX_WP_ANIMATIONS ; i++ ) { token = COM_Parse( &text_p ); // first frame @@ -998,7 +983,6 @@ static qboolean CG_ParseWeaponConfig( const char *filename, weaponInfo_t *wi ) { wi->weapAnimations[i].loopFrames = 0; } - // store animation/draw bits in '.moveSpeed' wi->weapAnimations[i].moveSpeed = 0; @@ -1024,7 +1008,6 @@ static qboolean CG_ParseWeaponConfig( const char *filename, weaponInfo_t *wi ) { } wi->weapAnimations[i].moveSpeed |= ( ( atoi( token ) ) << 8 ); // use 2nd byte for draw bits } - } if ( i != MAX_WP_ANIMATIONS ) { @@ -1032,12 +1015,11 @@ static qboolean CG_ParseWeaponConfig( const char *filename, weaponInfo_t *wi ) { return qfalse; } - return qtrue; } -static qboolean CG_RW_ParseError( int handle, char *format, ... ) { +static qboolean FORMAT_PRINTF(2,3) CG_RW_ParseError( int handle, const char *format, ... ) { int line; char filename[128]; va_list argptr; @@ -1525,7 +1507,7 @@ CG_RegisterWeapon */ void CG_RegisterWeapon( int weaponNum, qboolean force ) { weaponInfo_t *weaponInfo; - char *filename; + const char *filename; if ( weaponNum <= 0 || weaponNum >= WP_NUM_WEAPONS ) { return; @@ -1655,7 +1637,6 @@ VIEW WEAPON ======================================================================================== */ - // // weapon animations // @@ -1677,6 +1658,11 @@ qboolean CG_GetPartFramesFromWeap( centity_t *cent, refEntity_t *part, refEntity return qtrue; // primary weap model drawn for all frames right now } + if ( !anim ) + { + return qfalse; + } + // check draw bit if ( anim->moveSpeed & ( 1 << ( partid + 8 ) ) ) { // hide bits are in high byte return qfalse; // not drawn for current sequence @@ -2867,18 +2853,6 @@ WEAPON SELECTION ============================================================================== */ -#define WP_ICON_X 38 // new sizes per MK -#define WP_ICON_X_WIDE 72 // new sizes per MK -#define WP_ICON_Y 38 -#define WP_ICON_SPACE_Y 10 -#define WP_DRAW_X 640 - WP_ICON_X - 4 // 4 is 'selected' border width -#define WP_DRAW_X_WIDE 640 - WP_ICON_X_WIDE - 4 -#define WP_DRAW_Y 4 - -// secondary fire icons -#define WP_ICON_SEC_X 18 // new sizes per MK -#define WP_ICON_SEC_Y 18 - /* ============== CG_WeaponHasAmmo @@ -3104,7 +3078,7 @@ static int getPrevBankWeap( int bank, int cycle, qboolean sameBankPosition ) { getAltWeapon ============== */ -static int getAltWeapon( int weapnum ) { +static int CG_GetAltWeapon( int weapnum ) { /* if(weapnum > MAX_WEAP_ALTS) Gordon: seems unneeded return weapnum;*/ @@ -3124,7 +3098,7 @@ getEquivWeapon No equivalent available will return the weapnum passed in. ============== */ -int getEquivWeapon( int weapnum ) { +static int CG_GetEquivWeapon( int weapnum ) { int num = weapnum; switch ( weapnum ) { @@ -3145,9 +3119,6 @@ int getEquivWeapon( int weapnum ) { return num; } - - - /* ============== CG_SetSniperZoom @@ -3229,7 +3200,7 @@ void CG_PlaySwitchSound( int lastweap, int newweap ) { switchsound = cgs.media.selectSound; - if ( getAltWeapon( lastweap ) == newweap ) { // alt switch + if ( CG_GetAltWeapon( lastweap ) == newweap ) { // alt switch switch ( newweap ) { case WP_SILENCER: case WP_LUGER: @@ -3457,7 +3428,7 @@ void CG_AltWeapon_f( void ) { original = cg.weaponSelect; - num = getAltWeapon( original ); + num = CG_GetAltWeapon( original ); if ( original == WP_BINOCULARS ) { /*if(cg.snap->ps.eFlags & EF_ZOOMING) { @@ -3532,7 +3503,7 @@ void CG_NextWeap( qboolean switchBanks ) { // if you're using an alt mode weapon, try switching back to the parent first if ( curweap >= WP_BEGINSECONDARY && curweap <= WP_LASTSECONDARY ) { - num = getAltWeapon( curweap ); // base any further changes on the parent + num = CG_GetAltWeapon( curweap ); // base any further changes on the parent if ( CG_WeaponSelectable( num ) ) { // the parent was selectable, drop back to that CG_FinishWeaponChange( curweap, num ); return; @@ -3711,7 +3682,7 @@ void CG_PrevWeap( qboolean switchBanks ) { // if you're using an alt mode weapon, try switching back to the parent first if ( curweap >= WP_BEGINSECONDARY && curweap <= WP_LASTSECONDARY ) { - num = getAltWeapon( curweap ); // base any further changes on the parent + num = CG_GetAltWeapon( curweap ); // base any further changes on the parent if ( CG_WeaponSelectable( num ) ) { // the parent was selectable, drop back to that CG_FinishWeaponChange( curweap, num ); return; @@ -4110,7 +4081,7 @@ void CG_WeaponBank_f( void ) { bank = atoi( CG_Argv( 1 ) ); - if ( bank <= 0 || bank > MAX_WEAP_BANKS_MP ) { + if ( bank <= 0 || bank >= MAX_WEAP_BANKS_MP ) { return; } @@ -4177,8 +4148,6 @@ CG_Weapon_f */ void CG_Weapon_f( void ) { int num; -// int bank = 0, cycle = 0, newbank = 0, newcycle = 0; -// qboolean banked = qfalse; if ( !cg.snap ) { return; @@ -4205,53 +4174,7 @@ void CG_Weapon_f( void ) { if ( num < MAX_WEAP_BANKS_MP ) { CG_WeaponBank_f(); } - return; // jpw - -/* cg.weaponSelectTime = cg.time; // flash the current weapon icon - - // Don't try to switch when in the middle of reloading. - if ( cg.snap->ps.weaponstate == WEAPON_RELOADING ) - return; - - - if ( num <= WP_NONE || num > WP_NUM_WEAPONS ) { - return; - } - - curweap = cg.weaponSelect; - - CG_WeaponIndex(curweap, &bank, &cycle); // get bank/cycle of current weapon - banked = CG_WeaponIndex(num, &newbank, &newcycle); // get bank/cycle of requested weapon - - // the new weapon was not found in the reglar banks - // assume the player want's to go directly to it if possible - if(!banked) { - if(CG_WeaponSelectable(num)) { - CG_FinishWeaponChange(curweap, num); - return; - } - } - - if(bank != newbank) - cycle = newcycle - 1; // drop down one from the requested weap's cycle so it will - // try to initially cycle up to the requested weapon - - for(i = 0; i < MAX_WEAPS_IN_BANK; i++) { - num = getNextWeapInBank(newbank, cycle+i); - - if(num == curweap) // no other weapons in bank - return; - - if(CG_WeaponSelectable(num)) { - break; - } - } - - if(i == MAX_WEAPS_IN_BANK) - return; - - CG_FinishWeaponChange(curweap, num);*/ } /* @@ -4334,7 +4257,7 @@ void CG_OutOfAmmoChange( qboolean allowforceswitch ) { // if you're using an alt mode weapon, try switching back to the parent // otherwise, switch to the equivalent if you've got it if ( cg.weaponSelect >= WP_BEGINSECONDARY && cg.weaponSelect <= WP_LASTSECONDARY ) { - cg.weaponSelect = equiv = getAltWeapon( cg.weaponSelect ); // base any further changes on the parent + cg.weaponSelect = equiv = CG_GetAltWeapon( cg.weaponSelect ); // base any further changes on the parent if ( CG_WeaponSelectable( equiv ) ) { // the parent was selectable, drop back to that CG_FinishWeaponChange( cg.predictedPlayerState.weapon, cg.weaponSelect ); //----(SA) return; @@ -4343,7 +4266,7 @@ void CG_OutOfAmmoChange( qboolean allowforceswitch ) { // now try the opposite team's equivalent weap - equiv = getEquivWeapon( cg.weaponSelect ); + equiv = CG_GetEquivWeapon( cg.weaponSelect ); if ( equiv != cg.weaponSelect && CG_WeaponSelectable( equiv ) ) { cg.weaponSelect = equiv;