From b98e6d5cc07ceffd0e1068ee1ba887b61eef3c8e Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Mon, 10 Mar 2014 15:54:52 -0500 Subject: [PATCH 01/12] Fix error handling in R_ParseSpawnVars When R_GetEntityToken returns qfalse it resets pointer for parsing, by R_ParseSpawnVars not returning qfalse it could cause an infinite loop. Also add newlines to printfs. --- code/renderergl2/tr_bsp.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/code/renderergl2/tr_bsp.c b/code/renderergl2/tr_bsp.c index d9fdb4ab..9402c4e5 100644 --- a/code/renderergl2/tr_bsp.c +++ b/code/renderergl2/tr_bsp.c @@ -2749,7 +2749,8 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp return qfalse; } if ( com_token[0] != '{' ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {",com_token ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {\n",com_token ); + return qfalse; } // go through all the key / value pairs @@ -2758,7 +2759,8 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp // parse key if ( !R_GetEntityToken( keyname, sizeof( keyname ) ) ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); + return qfalse; } if ( keyname[0] == '}' ) { @@ -2767,18 +2769,18 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp // parse value if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" ); - break; + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); + return qfalse; } if ( com_token[0] == '}' ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data" ); - break; + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data\n" ); + return qfalse; } if ( *numSpawnVars == MAX_SPAWN_VARS ) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS" ); - break; + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS\n" ); + return qfalse; } keyLength = strlen(keyname) + 1; @@ -2786,8 +2788,8 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp if (numSpawnVarChars + keyLength + tokenLength > maxSpawnVarChars) { - ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS" ); - break; + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS\n" ); + return qfalse; } strcpy(spawnVarChars + numSpawnVarChars, keyname); From 5a3e10d716cd6ff3d47256142b0a1d162ae54311 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Mon, 10 Mar 2014 16:12:14 -0500 Subject: [PATCH 02/12] Don't say cubemap is outside lightgrid 6 times --- code/renderergl2/tr_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/renderergl2/tr_main.c b/code/renderergl2/tr_main.c index df1f8e60..d37dbc35 100644 --- a/code/renderergl2/tr_main.c +++ b/code/renderergl2/tr_main.c @@ -2863,7 +2863,8 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) vec3_t ambient, directed, lightDir; R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir); tr.refdef.colorScale = 766.0f / (directed[0] + directed[1] + directed[2] + 1.0f); - if (directed[0] + directed[1] + directed[2] == 0) + // only print message for first side + if (directed[0] + directed[1] + directed[2] == 0 && cubemapSide == 0) { ri.Printf(PRINT_ALL, "cubemap %d (%f, %f, %f) is outside the lightgrid!\n", cubemapIndex, tr.refdef.vieworg[0], tr.refdef.vieworg[1], tr.refdef.vieworg[2]); } @@ -2910,4 +2911,4 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) { RE_EndScene(); } -} \ No newline at end of file +} From c8c7bb1dc3562723473e2eabaca30e7a9e0ecb28 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Mon, 10 Mar 2014 16:19:02 -0500 Subject: [PATCH 03/12] Fix R_GetEntityToken ending prematurely If spawn var key or value is "" it caused R_GetEntityToken (available to cgame, used by opengl2) to stop parsing, whereas game VM would continue. Changed it to match parsing used for game VM (see G_GET_ENTITY_TOKEN in code/server/sv_game.c). The map poq3dm5 has a "wait" key with value "". --- code/renderergl1/tr_bsp.c | 2 +- code/renderergl2/tr_bsp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/renderergl1/tr_bsp.c b/code/renderergl1/tr_bsp.c index 7ca4d977..b5eac338 100644 --- a/code/renderergl1/tr_bsp.c +++ b/code/renderergl1/tr_bsp.c @@ -1776,7 +1776,7 @@ qboolean R_GetEntityToken( char *buffer, int size ) { s = COM_Parse( &s_worldData.entityParsePoint ); Q_strncpyz( buffer, s, size ); - if ( !s_worldData.entityParsePoint || !s[0] ) { + if ( !s_worldData.entityParsePoint && !s[0] ) { s_worldData.entityParsePoint = s_worldData.entityString; return qfalse; } else { diff --git a/code/renderergl2/tr_bsp.c b/code/renderergl2/tr_bsp.c index 9402c4e5..2198646e 100644 --- a/code/renderergl2/tr_bsp.c +++ b/code/renderergl2/tr_bsp.c @@ -2722,7 +2722,7 @@ qboolean R_GetEntityToken( char *buffer, int size ) { s = COM_Parse( &s_worldData.entityParsePoint ); Q_strncpyz( buffer, s, size ); - if ( !s_worldData.entityParsePoint || !s[0] ) { + if ( !s_worldData.entityParsePoint && !s[0] ) { s_worldData.entityParsePoint = s_worldData.entityString; return qfalse; } else { From 07290a7d5205bc267ba7c1b30a2c93c9afdceee8 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Mon, 10 Mar 2014 19:58:55 -0500 Subject: [PATCH 04/12] Fix typo in animMap and videoMap warnings --- code/renderergl1/tr_shader.c | 4 ++-- code/renderergl2/tr_shader.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/renderergl1/tr_shader.c b/code/renderergl1/tr_shader.c index 877c6191..2776100b 100644 --- a/code/renderergl1/tr_shader.c +++ b/code/renderergl1/tr_shader.c @@ -690,7 +690,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMmap' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMap' keyword in shader '%s'\n", shader.name ); return qfalse; } stage->bundle[0].imageAnimationSpeed = atof( token ); @@ -728,7 +728,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMmap' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMap' keyword in shader '%s'\n", shader.name ); return qfalse; } stage->bundle[0].videoMapHandle = ri.CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader)); diff --git a/code/renderergl2/tr_shader.c b/code/renderergl2/tr_shader.c index b90030c0..4f689195 100644 --- a/code/renderergl2/tr_shader.c +++ b/code/renderergl2/tr_shader.c @@ -753,7 +753,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMmap' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMap' keyword in shader '%s'\n", shader.name ); return qfalse; } stage->bundle[0].imageAnimationSpeed = atof( token ); @@ -794,7 +794,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMmap' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMap' keyword in shader '%s'\n", shader.name ); return qfalse; } stage->bundle[0].videoMapHandle = ri.CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader)); From 63d1911c18ea2f814da19cec7d89fe4439be6f90 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Tue, 11 Mar 2014 12:38:53 -0500 Subject: [PATCH 05/12] Parse q3map_sunExt in OpenGL1 too Used for drawing sun, which is supported by both OpenGL1 and OpenGL2. OpenGL2 already parses it. --- code/renderergl1/tr_shader.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/renderergl1/tr_shader.c b/code/renderergl1/tr_shader.c index 2776100b..de3a45c4 100644 --- a/code/renderergl1/tr_shader.c +++ b/code/renderergl1/tr_shader.c @@ -1476,7 +1476,7 @@ static qboolean ParseShader( char **text ) continue; } // sun parms - else if ( !Q_stricmp( token, "q3map_sun" ) ) { + else if ( !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) ) { float a, b; token = COM_ParseExt( text, qfalse ); @@ -1503,6 +1503,9 @@ static qboolean ParseShader( char **text ) tr.sunDirection[0] = cos( a ) * cos( b ); tr.sunDirection[1] = sin( a ) * cos( b ); tr.sunDirection[2] = sin( b ); + + SkipRestOfLine( text ); + continue; } else if ( !Q_stricmp( token, "deformVertexes" ) ) { ParseDeform( text ); From a167110f43c7c606c24aacb68d63240f2ee9fe66 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Tue, 11 Mar 2014 16:44:50 -0500 Subject: [PATCH 06/12] Don't mix sfx with NULL soundData Caused a crash. Already done for looping sounds. --- code/client/snd_mix.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/client/snd_mix.c b/code/client/snd_mix.c index 38bd0aae..f4fa01a4 100644 --- a/code/client/snd_mix.c +++ b/code/client/snd_mix.c @@ -711,6 +711,10 @@ void S_PaintChannels( int endtime ) { ltime = s_paintedtime; sc = ch->thesfx; + if (sc->soundData==NULL || sc->soundLength==0) { + continue; + } + sampleOffset = ltime - ch->startSample; count = end - ltime; if ( sampleOffset + count > sc->soundLength ) { From 0e6632f464c08dcb76f26a52f33d97228e64fda1 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Tue, 11 Mar 2014 17:15:55 -0500 Subject: [PATCH 07/12] DMA 44100Hz needs more memory for sound buffers It doubles the size of the data compared to the default (22050), so increase the buffer automatically. Likewise, decreasing speed doesn't need as much (though that doesn't really matter). --- code/client/snd_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/client/snd_mem.c b/code/client/snd_mem.c index 655ae420..39615d83 100644 --- a/code/client/snd_mem.c +++ b/code/client/snd_mem.c @@ -81,7 +81,7 @@ void SND_setup(void) { cv = Cvar_Get( "com_soundMegs", DEF_COMSOUNDMEGS, CVAR_LATCH | CVAR_ARCHIVE ); - scs = (cv->integer*1536); + scs = (cv->integer*1536*dma.speed/22050.0f); buffer = malloc(scs*sizeof(sndBuffer) ); // allocate the stack based hunk allocator From baca82d64e86c276b16694cc9230002774007fce Mon Sep 17 00:00:00 2001 From: Tequila Date: Thu, 13 Mar 2014 02:20:54 +0100 Subject: [PATCH 08/12] Bunch of comment fixes --- code/cgame/cg_effects.c | 4 ++-- code/cgame/cg_localents.c | 2 +- code/cgame/cg_players.c | 2 +- code/cgame/cg_playerstate.c | 2 +- code/cgame/cg_view.c | 2 +- code/cgame/cg_weapons.c | 2 +- code/client/snd_openal.c | 2 +- code/game/ai_main.c | 2 +- code/game/bg_pmove.c | 2 +- code/game/g_client.c | 2 +- code/game/g_cmds.c | 6 +++--- code/game/g_combat.c | 2 +- code/game/g_items.c | 2 +- code/qcommon/common.c | 4 ++-- code/qcommon/q_shared.h | 2 +- code/renderercommon/tr_types.h | 1 + code/renderergl1/tr_bsp.c | 2 +- 17 files changed, 21 insertions(+), 20 deletions(-) diff --git a/code/cgame/cg_effects.c b/code/cgame/cg_effects.c index 99f64995..9b2d0f7a 100644 --- a/code/cgame/cg_effects.c +++ b/code/cgame/cg_effects.c @@ -640,7 +640,7 @@ void CG_GibPlayer( vec3_t playerOrigin ) { /* ================== -CG_LaunchGib +CG_LaunchExplode ================== */ void CG_LaunchExplode( vec3_t origin, vec3_t velocity, qhandle_t hModel ) { @@ -673,7 +673,7 @@ void CG_LaunchExplode( vec3_t origin, vec3_t velocity, qhandle_t hModel ) { #define EXP_JUMP 150 /* =================== -CG_GibPlayer +CG_BigExplode Generated a bunch of gibs launching out from the bodies location =================== diff --git a/code/cgame/cg_localents.c b/code/cgame/cg_localents.c index 8a85621e..be61ce31 100644 --- a/code/cgame/cg_localents.c +++ b/code/cgame/cg_localents.c @@ -74,7 +74,7 @@ void CG_FreeLocalEntity( localEntity_t *le ) { =================== CG_AllocLocalEntity -Will allways succeed, even if it requires freeing an old active entity +Will always succeed, even if it requires freeing an old active entity =================== */ localEntity_t *CG_AllocLocalEntity( void ) { diff --git a/code/cgame/cg_players.c b/code/cgame/cg_players.c index 425a2faa..59f52320 100644 --- a/code/cgame/cg_players.c +++ b/code/cgame/cg_players.c @@ -83,7 +83,7 @@ CLIENT INFO ====================== CG_ParseAnimationFile -Read a configuration file containing animation coutns and rates +Read a configuration file containing animation counts and rates models/players/visor/animation.cfg, etc ====================== */ diff --git a/code/cgame/cg_playerstate.c b/code/cgame/cg_playerstate.c index 4954b330..c696a91f 100644 --- a/code/cgame/cg_playerstate.c +++ b/code/cgame/cg_playerstate.c @@ -385,7 +385,7 @@ void CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops ) { #endif pushReward(sfx, cgs.media.medalGauntlet, ps->persistant[PERS_GAUNTLET_FRAG_COUNT]); reward = qtrue; - //Com_Printf("guantlet frag\n"); + //Com_Printf("gauntlet frag\n"); } if (ps->persistant[PERS_DEFEND_COUNT] != ops->persistant[PERS_DEFEND_COUNT]) { pushReward(cgs.media.defendSound, cgs.media.medalDefend, ps->persistant[PERS_DEFEND_COUNT]); diff --git a/code/cgame/cg_view.c b/code/cgame/cg_view.c index 0fc763a9..1131841f 100644 --- a/code/cgame/cg_view.c +++ b/code/cgame/cg_view.c @@ -269,7 +269,7 @@ static void CG_OffsetThirdPersonView( void ) { VectorCopy( trace.endpos, view ); view[2] += (1.0 - trace.fraction) * 32; // try another trace to this position, because a tunnel may have the ceiling - // close enogh that this is poking out + // close enough that this is poking out CG_Trace( &trace, cg.refdef.vieworg, mins, maxs, view, cg.predictedPlayerState.clientNum, MASK_SOLID ); VectorCopy( trace.endpos, view ); diff --git a/code/cgame/cg_weapons.c b/code/cgame/cg_weapons.c index 64452411..a2b83252 100644 --- a/code/cgame/cg_weapons.c +++ b/code/cgame/cg_weapons.c @@ -460,7 +460,7 @@ static void CG_NailTrail( centity_t *ent, const weaponInfo_t *wi ) { /* ========================== -CG_NailTrail +CG_PlasmaTrail ========================== */ static void CG_PlasmaTrail( centity_t *cent, const weaponInfo_t *wi ) { diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c index f0a5f4f2..36f5deb7 100644 --- a/code/client/snd_openal.c +++ b/code/client/snd_openal.c @@ -841,7 +841,7 @@ static void S_AL_SrcSetup(srcHandle_t src, sfxHandle_t sfx, alSrcPriority_t prio /* ================= -S_AL_NewLoopMaster +S_AL_SaveLoopPos Remove given source as loop master if it is the master and hand off master status to another source in this case. ================= */ diff --git a/code/game/ai_main.c b/code/game/ai_main.c index bbf5fd57..9b3d7220 100644 --- a/code/game/ai_main.c +++ b/code/game/ai_main.c @@ -1280,7 +1280,7 @@ int BotAIShutdownClient(int client, qboolean restart) { } trap_BotFreeMoveState(bs->ms); - //free the goal state` + //free the goal state trap_BotFreeGoalState(bs->gs); //free the chat file trap_BotFreeChatState(bs->cs); diff --git a/code/game/bg_pmove.c b/code/game/bg_pmove.c index 4dd5d38a..976a78ed 100644 --- a/code/game/bg_pmove.c +++ b/code/game/bg_pmove.c @@ -1790,7 +1790,7 @@ static void PM_DropTimers( void ) { PM_UpdateViewAngles This can be used as another entry point when only the viewangles -are being updated isntead of a full move +are being updated instead of a full move ================ */ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) { diff --git a/code/game/g_client.c b/code/game/g_client.c index ee88fac5..d1dcbc3c 100644 --- a/code/game/g_client.c +++ b/code/game/g_client.c @@ -630,7 +630,7 @@ static void ForceClientSkin( gclient_t *client, char *model, const char *skin ) /* =========== -ClientCheckName +ClientCleanName ============ */ static void ClientCleanName(const char *in, char *out, int outSize) diff --git a/code/game/g_cmds.c b/code/game/g_cmds.c index aaa1f8f6..fe2a53c1 100644 --- a/code/game/g_cmds.c +++ b/code/game/g_cmds.c @@ -476,7 +476,7 @@ void Cmd_Kill_f( gentity_t *ent ) { /* ================= -BroadCastTeamChange +BroadcastTeamChange Let everyone know about a team change ================= @@ -1348,7 +1348,7 @@ void Cmd_CallVote_f( gentity_t *ent ) { trap_SendServerCommand( -1, va("print \"%s called a vote.\n\"", ent->client->pers.netname ) ); - // start the voting, the caller autoamtically votes yes + // start the voting, the caller automatically votes yes level.voteTime = level.time; level.voteYes = 1; level.voteNo = 0; @@ -1513,7 +1513,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) { trap_SendServerCommand( i, va("print \"%s called a team vote.\n\"", ent->client->pers.netname ) ); } - // start the voting, the caller autoamtically votes yes + // start the voting, the caller automatically votes yes level.teamVoteTime[cs_offset] = level.time; level.teamVoteYes[cs_offset] = 1; level.teamVoteNo[cs_offset] = 0; diff --git a/code/game/g_combat.c b/code/game/g_combat.c index 2fbd3170..b981c581 100644 --- a/code/game/g_combat.c +++ b/code/game/g_combat.c @@ -778,7 +778,7 @@ int G_InvulnerabilityEffect( gentity_t *targ, vec3_t dir, vec3_t point, vec3_t i #endif /* ============ -T_Damage +G_Damage targ entity that is being damaged inflictor entity that is causing the damage diff --git a/code/game/g_items.c b/code/game/g_items.c index f6d84cf7..3e36e382 100644 --- a/code/game/g_items.c +++ b/code/game/g_items.c @@ -660,7 +660,7 @@ void FinishSpawningItem( gentity_t *ent ) { ent->r.contents = CONTENTS_TRIGGER; ent->touch = Touch_Item; - // useing an item causes it to respawn + // using an item causes it to respawn ent->use = Use_Item; if ( ent->spawnflags & 1 ) { diff --git a/code/qcommon/common.c b/code/qcommon/common.c index 3c8c25d0..36cb4ce6 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -1519,7 +1519,7 @@ void Hunk_SmallLog( void) { /* ================= -Com_InitZoneMemory +Com_InitHunkZoneMemory ================= */ void Com_InitHunkMemory( void ) { @@ -3539,7 +3539,7 @@ void Field_AutoComplete( field_t *field ) ================== Com_RandomBytes -fills string array with len radom bytes, peferably from the OS randomizer +fills string array with len random bytes, preferably from the OS randomizer ================== */ void Com_RandomBytes( byte *string, int len ) diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 48647f1d..64247a89 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -562,7 +562,7 @@ typedef struct { #define Byte4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) #define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));} -// just in case you do't want to use the macros +// just in case you don't want to use the macros vec_t _DotProduct( const vec3_t v1, const vec3_t v2 ); void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ); void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out ); diff --git a/code/renderercommon/tr_types.h b/code/renderercommon/tr_types.h index 70596434..dd55e2e7 100644 --- a/code/renderercommon/tr_types.h +++ b/code/renderercommon/tr_types.h @@ -53,6 +53,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define RF_SHADOW_PLANE 0x0100 // use refEntity->shadowPlane #define RF_WRAP_FRAMES 0x0200 // mod the model frames by the maxframes to allow continuous + // animation without needing to know the frame count // refdef flags #define RDF_NOWORLDMODEL 0x0001 // used for player configuration screen diff --git a/code/renderergl1/tr_bsp.c b/code/renderergl1/tr_bsp.c index b5eac338..64f6a565 100644 --- a/code/renderergl1/tr_bsp.c +++ b/code/renderergl1/tr_bsp.c @@ -1550,7 +1550,7 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { } count = l->filelen / sizeof(*fogs); - // create fog strucutres for them + // create fog structures for them s_worldData.numfogs = count + 1; s_worldData.fogs = ri.Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low); out = s_worldData.fogs + 1; From 375f6247d4faf4a2a4d14885213d1cf7516b453d Mon Sep 17 00:00:00 2001 From: SmileTheory Date: Sun, 16 Mar 2014 16:29:38 -0700 Subject: [PATCH 09/12] OpenGL2: Parallax corrected cubemap (cheaper trick) --- code/renderergl2/glsl/lightall_fp.glsl | 17 ++++++++++++++--- code/renderergl2/tr_glsl.c | 4 +++- code/renderergl2/tr_local.h | 2 ++ code/renderergl2/tr_shade.c | 13 +++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/code/renderergl2/glsl/lightall_fp.glsl b/code/renderergl2/glsl/lightall_fp.glsl index c74d6844..0f50a038 100644 --- a/code/renderergl2/glsl/lightall_fp.glsl +++ b/code/renderergl2/glsl/lightall_fp.glsl @@ -44,6 +44,12 @@ uniform vec4 u_NormalScale; uniform vec4 u_SpecularScale; #endif +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(USE_CUBEMAP) +uniform vec4 u_CubeMapInfo; +#endif +#endif + varying vec4 var_TexCoords; varying vec4 var_Color; @@ -323,19 +329,20 @@ mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv ) void main() { + vec3 viewDir; vec3 L, N, E, H; float NL, NH, NE, EH; #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_VERT_TANGENT_SPACE) mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); - E = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w); + viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w); #else mat3 tangentToWorld = cotangent_frame(var_Normal, -var_ViewDir, var_TexCoords.xy); - E = var_ViewDir; + viewDir = var_ViewDir; #endif - E = normalize(E); + E = normalize(viewDir); L = var_LightDir.xyz; #if defined(USE_DELUXEMAP) @@ -497,6 +504,10 @@ void main() vec3 R = reflect(E, N); + // parallax corrected cubemap (cheaper trick) + // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ + R += u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; + vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; #if defined(USE_LIGHTMAP) diff --git a/code/renderergl2/tr_glsl.c b/code/renderergl2/tr_glsl.c index c4a30b60..33dd0497 100644 --- a/code/renderergl2/tr_glsl.c +++ b/code/renderergl2/tr_glsl.c @@ -142,7 +142,9 @@ static uniformInfo_t uniformsInfo[] = { "u_PrimaryLightOrigin", GLSL_VEC4 }, { "u_PrimaryLightColor", GLSL_VEC3 }, { "u_PrimaryLightAmbient", GLSL_VEC3 }, - { "u_PrimaryLightRadius", GLSL_FLOAT } + { "u_PrimaryLightRadius", GLSL_FLOAT }, + + { "u_CubeMapInfo", GLSL_VEC4 }, }; diff --git a/code/renderergl2/tr_local.h b/code/renderergl2/tr_local.h index 1f7c6fd6..2e4b3e5e 100644 --- a/code/renderergl2/tr_local.h +++ b/code/renderergl2/tr_local.h @@ -698,6 +698,8 @@ typedef enum UNIFORM_PRIMARYLIGHTAMBIENT, UNIFORM_PRIMARYLIGHTRADIUS, + UNIFORM_CUBEMAPINFO, + UNIFORM_COUNT } uniform_t; diff --git a/code/renderergl2/tr_shade.c b/code/renderergl2/tr_shade.c index 349f7e2e..5285e28e 100644 --- a/code/renderergl2/tr_shade.c +++ b/code/renderergl2/tr_shade.c @@ -1378,8 +1378,21 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) // testing cube map // if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex && r_cubeMapping->integer) + { + vec4_t vec; + GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); + vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] - backEnd.viewParms.or.origin[0]; + vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] - backEnd.viewParms.or.origin[1]; + vec[2] = tr.cubemapOrigins[input->cubemapIndex - 1][2] - backEnd.viewParms.or.origin[2]; + vec[3] = 1.0f; + + VectorScale4(vec, 1.0f / 1000.0f, vec); + + GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec); + } + // // draw // From 0861d3c58352af59376b1a31b362b4371fd02ecd Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Mon, 17 Mar 2014 12:55:38 -0500 Subject: [PATCH 10/12] Revert "DMA 44100Hz needs more memory for sound buffers" This reverts commit 0e6632f464c08dcb76f26a52f33d97228e64fda1. Cause crashes if com_soundMegs is 32. --- code/client/snd_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/client/snd_mem.c b/code/client/snd_mem.c index 39615d83..655ae420 100644 --- a/code/client/snd_mem.c +++ b/code/client/snd_mem.c @@ -81,7 +81,7 @@ void SND_setup(void) { cv = Cvar_Get( "com_soundMegs", DEF_COMSOUNDMEGS, CVAR_LATCH | CVAR_ARCHIVE ); - scs = (cv->integer*1536*dma.speed/22050.0f); + scs = (cv->integer*1536); buffer = malloc(scs*sizeof(sndBuffer) ); // allocate the stack based hunk allocator From 67d9ecd0704f661a6d0cffa2b9cf0a6ddaeaec3a Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Tue, 18 Mar 2014 20:37:33 -0500 Subject: [PATCH 11/12] Fix FS_FOpenFileReadDir non-zero file handle when file not found in pk3 If a pk3 search path is passed to FS_FOpenFileReadDir, a non-zero file handle is returned if file is not found. This causes incorrect behavior in FS_ReadFileDir (when a pk3 search path is passed in) which only checks file handle, not length, for seeing if file exists. I don't know of any issues in ioq3 caused by this. --- code/qcommon/files.c | 1 + 1 file changed, 1 insertion(+) diff --git a/code/qcommon/files.c b/code/qcommon/files.c index 1e66cff2..eb51faa9 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -1326,6 +1326,7 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ return FS_fplength(filep); } + *file = 0; return -1; } From b099255748edaec547242e7f165c4016a8bad69b Mon Sep 17 00:00:00 2001 From: SmileTheory Date: Wed, 19 Mar 2014 17:59:07 -0700 Subject: [PATCH 12/12] #6095: OpenGL2: Use areamask and leaf cluster for PVS when VIS is missing. --- code/renderergl2/tr_bsp.c | 2 -- code/renderergl2/tr_local.h | 2 -- code/renderergl2/tr_world.c | 45 +++++++++++-------------------------- 3 files changed, 13 insertions(+), 36 deletions(-) diff --git a/code/renderergl2/tr_bsp.c b/code/renderergl2/tr_bsp.c index 2198646e..63824284 100644 --- a/code/renderergl2/tr_bsp.c +++ b/code/renderergl2/tr_bsp.c @@ -600,8 +600,6 @@ static void R_LoadVisibility( lump_t *l ) { byte *buf; len = ( s_worldData.numClusters + 63 ) & ~63; - s_worldData.novis = ri.Hunk_Alloc( len, h_low ); - Com_Memset( s_worldData.novis, 0xff, len ); len = l->filelen; if ( !len ) { diff --git a/code/renderergl2/tr_local.h b/code/renderergl2/tr_local.h index 2e4b3e5e..d5ebe544 100644 --- a/code/renderergl2/tr_local.h +++ b/code/renderergl2/tr_local.h @@ -1181,8 +1181,6 @@ typedef struct { int clusterBytes; const byte *vis; // may be passed in by CM_LoadMap to save space - byte *novis; // clusterBytes of 0xff - char *entityString; char *entityParsePoint; } world_t; diff --git a/code/renderergl2/tr_world.c b/code/renderergl2/tr_world.c index dba15c45..f4edbb03 100644 --- a/code/renderergl2/tr_world.c +++ b/code/renderergl2/tr_world.c @@ -644,7 +644,7 @@ R_ClusterPVS */ static const byte *R_ClusterPVS (int cluster) { if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { - return tr.world->novis; + return NULL; } return tr.world->vis + cluster * tr.world->clusterBytes; @@ -698,29 +698,21 @@ static void R_MarkLeaves (void) { for(i = 0; i < MAX_VISCOUNTS; i++) { - if(tr.visClusters[i] == cluster) + // if the areamask or r_showcluster was modified, invalidate all visclusters + // this caused doors to open into undrawn areas + if (tr.refdef.areamaskModified || r_showcluster->modified) { - //tr.visIndex = i; - break; + tr.visClusters[i] = -2; } - } - - // if r_showcluster was just turned on, remark everything - if(i != MAX_VISCOUNTS && !tr.refdef.areamaskModified && !r_showcluster->modified)// && !r_dynamicBspOcclusionCulling->modified) - { - if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) + else if(tr.visClusters[i] == cluster) { - ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); + if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) + { + ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); + } + tr.visIndex = i; + return; } - tr.visIndex = i; - return; - } - - // if the areamask was modified, invalidate all visclusters - // this caused doors to open into undrawn areas - if (tr.refdef.areamaskModified) - { - memset(tr.visClusters, -2, sizeof(tr.visClusters)); } tr.visIndex = (tr.visIndex + 1) % MAX_VISCOUNTS; @@ -734,17 +726,6 @@ static void R_MarkLeaves (void) { } } - // set all nodes to visible if there is no vis - // this caused some levels to simply not render - if (r_novis->integer || !tr.world->vis || tr.visClusters[tr.visIndex] == -1) { - for (i=0 ; inumnodes ; i++) { - if (tr.world->nodes[i].contents != CONTENTS_SOLID) { - tr.world->nodes[i].visCounts[tr.visIndex] = tr.visCounts[tr.visIndex]; - } - } - return; - } - vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); for (i=0,leaf=tr.world->nodes ; inumnodes ; i++, leaf++) { @@ -754,7 +735,7 @@ static void R_MarkLeaves (void) { } // check general pvs - if ( !(vis[cluster>>3] & (1<<(cluster&7))) ) { + if ( vis && !(vis[cluster>>3] & (1<<(cluster&7))) ) { continue; }