Different proactive changes to prevent problems... or make them A LOT more visible.

This commit is contained in:
sago007
2016-11-27 11:24:18 +01:00
parent 6688bf3269
commit 217a26e3c6
3 changed files with 842 additions and 851 deletions

View File

@@ -80,12 +80,10 @@ S_XMP_CodecOpenStream
// FIXME: there's a memory leak here if you start the same song many many many many times.
snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
{
snd_stream_t *rv;
// First let's close whatever song we had....
// Open
rv = S_CodecUtilOpen(filename, &xmp_codec);
snd_stream_t *rv = S_CodecUtilOpen(filename, &xmp_codec);
if(!rv)
return NULL;
@@ -93,7 +91,6 @@ snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
{
fileHandle_t file;
void *buffer;
// Try to open the file
FS_FOpenFileRead(filename, &file, qtrue);
@@ -105,15 +102,14 @@ snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
// Allocate some memory
long thelength = FS_ReadFile(filename, buffer);
long thelength = FS_ReadFile(filename, NULL);
buffer = Hunk_AllocateTempMemory(thelength);
void *buffer = Hunk_AllocateTempMemory(thelength);
if(!buffer)
{
FS_FCloseFile(file);
Com_Printf( S_COLOR_RED "ERROR: Out of memory reading \"%s\"\n",
filename);
Com_Printf( S_COLOR_RED "ERROR: Out of memory reading \"%s\"\n", filename);
return NULL;
}
@@ -136,12 +132,10 @@ snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
itsloaded = xmp_start_player(xmpsong, xmpspeed, 0); // TODO: do sample rate of the mixer.
if (itsloaded == 0){
// Com_Printf("XMP loaded our buffer of the file %s which is %i long \n", filename, thelength);
xmp_get_module_info(xmpsong, &mi);
// Com_Printf("Song Name: %s\n", mi.mod->name);
// Com_Printf("CODECLOAD %s\n", filename);
}
}
@@ -183,9 +177,6 @@ int S_XMP_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
struct xmp_module_info mi;
struct xmp_frame_info fi;
int bytesRead, bytesLeft, c;
char *bufPtr;
// check if input is valid
if(!(stream && buffer))
{
@@ -197,9 +188,9 @@ int S_XMP_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
return 0;
}
bytesRead = 0;
bytesLeft = bytes;
bufPtr = buffer;
int bytesRead = 0;
int bytesLeft = bytes;
char* bufPtr = buffer;
// cycle until we have the requested or all available bytes read
while(-1)
@@ -209,7 +200,7 @@ int S_XMP_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
if (yeah == 0){ // if we can play it...
xmp_get_frame_info(xmpsong, &fi);
c = fi.buffer;
int c = fi.buffer_size;
// no more bytes are left
if(c <= 0)

View File

@@ -751,9 +751,8 @@ static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float t
static void R_Bloom_RestoreScreen_Postprocessed( void ) {
#ifdef GLSL_POSTPROCESSING
glslProgram_t *program;
if (leifxmode)
{
glslProgram_t *program = NULL;
if (leifxmode) {
if (leifxmode == 1){ if (vertexShaders) R_GLSL_UseProgram(tr.leiFXDitherProgram); program=tr.programs[tr.leiFXDitherProgram];}
if (leifxmode == 2){ if (vertexShaders) R_GLSL_UseProgram(tr.leiFXGammaProgram); program=tr.programs[tr.leiFXGammaProgram];}
if (leifxmode == 3){ if (vertexShaders) R_GLSL_UseProgram(tr.leiFXFilterProgram); program=tr.programs[tr.leiFXFilterProgram];}
@@ -770,12 +769,16 @@ static void R_Bloom_RestoreScreen_Postprocessed( void ) {
if (leifxmode == 1997){ if (vertexShaders) R_GLSL_UseProgram(tr.paletteProgram); program=tr.programs[tr.paletteProgram];}
}
else
{
else {
if (vertexShaders) R_GLSL_UseProgram(tr.postprocessingProgram);
// Feed GLSL postprocess program
program=tr.programs[tr.postprocessingProgram];
}
if (!program) {
//If leifsmode has been set to something invalid we have to bail out or we will dereference a null pointer
Com_Printf( S_COLOR_YELLOW"WARNING: 'leifxmode' has an invalid value\n" );
return;
}
if (program->u_ScreenSizeX > -1) R_GLSL_SetUniform_u_ScreenSizeX(program, glConfig.vidWidth);
if (program->u_ScreenSizeY > -1) R_GLSL_SetUniform_u_ScreenSizeY(program, glConfig.vidHeight);
@@ -1133,11 +1136,13 @@ static void R_Postprocess_InitTextures( void )
// postproc.tvwork.height /= intdiv; // interlacey
for (postproc.tveffect.width = 1;postproc.tveffect.width < postproc.tvwork.width;postproc.tveffect.width *= 2);
if (intdiv > 1)
for (postproc.tveffect.height = 1;(postproc.tveffect.height/2) < postproc.tvwork.height;postproc.tveffect.height *= 2);
else
for (postproc.tveffect.height = 1;postproc.tveffect.height < postproc.tvwork.height;postproc.tveffect.height *= 2);
for (postproc.tveffect.width = 1;postproc.tveffect.width < postproc.tvwork.width;postproc.tveffect.width *= 2) {}
if (intdiv > 1) {
for (postproc.tveffect.height = 1;(postproc.tveffect.height/2) < postproc.tvwork.height;postproc.tveffect.height *= 2) {}
}
else {
for (postproc.tveffect.height = 1;postproc.tveffect.height < postproc.tvwork.height;postproc.tveffect.height *= 2) {}
}
postproc.tveffect.readW = postproc.tvwork.width / (float)postproc.tveffect.width;
postproc.tveffect.readH = postproc.tvwork.height / (float)postproc.tveffect.height;
@@ -1365,8 +1370,9 @@ void R_LeiFXPostprocessFilterScreen( void )
return;
}
if ( !backEnd.projection2D )
if ( !backEnd.projection2D ) {
RB_SetGL2D();
}
force32upload = 1;
// postprocess = 1;
@@ -1432,8 +1438,9 @@ void R_NTSCScreen( void )
return;
}
if ( !backEnd.projection2D )
if ( !backEnd.projection2D ) {
RB_SetGL2D();
}
force32upload = 1;
int ntsc_bleed = 0;
@@ -1545,7 +1552,7 @@ void R_BrightItUp (int dst, int src, float intensity)
void R_BrightScreen( void )
{
int mode; // 0 = none; 1 = blend; 2 = shader
int mode = 0; // 0 = none; 1 = blend; 2 = shader
if( !r_alternateBrightness->integer)
return;
if ( backEnd.doneAltBrightness)
@@ -1557,11 +1564,13 @@ void R_BrightScreen( void )
if (r_alternateBrightness->integer == 2)
{
// Automatically determine from capabilities
if ( vertexShaders )
if ( vertexShaders ) {
mode = 2;
else
}
else {
mode = 1;
}
}
// the modern pixel shader way
if (mode == 2)
@@ -1595,14 +1604,12 @@ void R_BrightScreen( void )
else if (mode == 1)
#endif
{
int eh, ah;
if ((r_overBrightBits->integer))
{
if ((r_overBrightBits->integer)) {
ah = r_overBrightBits->integer;
if (ah < 1) ah = 1; if (ah > 2) ah = 2; // clamp so it never looks stupid
if (ah < 1) { ah = 1; }
if (ah > 2) { ah = 2; } // clamp so it never looks stupid
// Blend method
// do a loop for every overbright bit enabled
@@ -1612,7 +1619,6 @@ void R_BrightScreen( void )
backEnd.doneAltBrightness = qtrue;
}
}
}
@@ -1638,7 +1644,6 @@ void R_AltBrightnessInit( void ) {
void R_FilmScreen( void )
{
vec3_t tone, toneinv, tonecont;
vec3_t tonework;
if( !r_film->integer )
return;
@@ -1720,11 +1725,6 @@ void R_FilmScreen( void )
// qglColor4f( 0.866667, 0.847059, 0.776471, 1.0f );
qglColor4f( (0.73f + (toneinv[0] * 0.4)), (0.73f + (toneinv[1] * 0.4)), (0.73f + (toneinv[2] * 0.4)), 1.0f );
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 );
}