Merge branch 'master' into sdl2

Conflicts:
	code/sdl/sdl_input.c
This commit is contained in:
Tim Angus 2013-08-16 23:34:08 +01:00
commit bde7665462
97 changed files with 6333 additions and 546 deletions

View file

@ -760,14 +760,11 @@ void Characteristic_String(int character, int index, char *buf, int size)
{
strncpy(buf, ch->c[index].value.string, size-1);
buf[size-1] = '\0';
return;
} //end if
else
{
botimport.Print(PRT_ERROR, "characteristic %d is not a string\n", index);
return;
} //end else if
return;
} //end of the function Characteristic_String
//===========================================================================
//

View file

@ -1025,7 +1025,6 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename)
} //end if
while(!PC_CheckTokenString(source, "}"))
{
size_t len;
if (!BotLoadChatMessage(source, chatmessagestring))
{
FreeSource(source);
@ -1507,7 +1506,6 @@ void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size)
{
strcpy(buf, "");
} //end else
return;
} //end of the function BotMatchVariable
//===========================================================================
//

View file

@ -691,7 +691,6 @@ void BotGoalName(int number, char *name, int size)
} //end for
} //end for
strcpy(name, "");
return;
} //end of the function BotGoalName
//===========================================================================
//

View file

@ -3455,8 +3455,6 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
if (result->blocked) ms->reachability_time -= 10 * ms->thinktime;
//copy the last origin
VectorCopy(ms->origin, ms->lastorigin);
//return the movement result
return;
} //end of the function BotMoveToGoal
//===========================================================================
//

View file

@ -636,7 +636,6 @@ void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)
}
else if (p->type == P_FLAT_SCALEUP)
{
float width, height;
float sinR, cosR;
if (p->color == BLOODRED)
@ -1321,7 +1320,6 @@ void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duratio
// Rafael Shrapnel
void CG_AddParticleShrapnel (localEntity_t *le)
{
return;
}
// done.

View file

@ -283,17 +283,17 @@ static void CG_TouchItem( centity_t *cent ) {
// We don't predict touching our own flag
#ifdef MISSIONPACK
if( cgs.gametype == GT_1FCTF ) {
if( item->giTag != PW_NEUTRALFLAG ) {
if( item->giType == IT_TEAM && item->giTag != PW_NEUTRALFLAG ) {
return;
}
}
#endif
if( cgs.gametype == GT_CTF ) {
if (cg.predictedPlayerState.persistant[PERS_TEAM] == TEAM_RED &&
item->giTag == PW_REDFLAG)
item->giType == IT_TEAM && item->giTag == PW_REDFLAG)
return;
if (cg.predictedPlayerState.persistant[PERS_TEAM] == TEAM_BLUE &&
item->giTag == PW_BLUEFLAG)
item->giType == IT_TEAM && item->giTag == PW_BLUEFLAG)
return;
}

View file

@ -186,15 +186,6 @@ void CL_AddCgameCommand( const char *cmdName ) {
Cmd_AddCommand( cmdName, NULL );
}
/*
=====================
CL_CgameError
=====================
*/
void CL_CgameError( const char *string ) {
Com_Error( ERR_DROP, "%s", string );
}
/*
=====================

View file

@ -191,8 +191,6 @@ void Con_Dump_f (void)
Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) );
COM_DefaultExtension( filename, sizeof( filename ), ".txt" );
Com_Printf ("Dumped console text to %s.\n", filename );
f = FS_FOpenFileWrite( filename );
if (!f)
{
@ -200,6 +198,8 @@ void Con_Dump_f (void)
return;
}
Com_Printf ("Dumped console text to %s.\n", filename );
// skip empty lines
for (l = con.current - con.totallines + 1 ; l <= con.current ; l++)
{

View file

@ -1000,7 +1000,7 @@ void Key_Bind_f (void)
if (c == 2)
{
if (keys[b].binding)
if (keys[b].binding && keys[b].binding[0])
Com_Printf ("\"%s\" = \"%s\"\n", Key_KeynumToString(b), keys[b].binding );
else
Com_Printf ("\"%s\" is not bound\n", Key_KeynumToString(b) );
@ -1275,6 +1275,9 @@ void CL_KeyDownEvent( int key, unsigned time )
return;
}
// send the bound action
CL_ParseBinding( key, qtrue, time );
// distribute the key down event to the apropriate handler
if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) {
Console_Key( key );
@ -1291,10 +1294,6 @@ void CL_KeyDownEvent( int key, unsigned time )
} else if ( clc.state == CA_DISCONNECTED ) {
Console_Key( key );
}
// send the bound action
CL_ParseBinding( key, qtrue, time );
return;
}
/*

View file

@ -256,7 +256,7 @@ void CL_Voip_f( void )
reason = "Speex not initialized";
else if (!clc.voipEnabled)
reason = "Server doesn't support VoIP";
else if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive"))
else if (!clc.demoplaying && (Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive")))
reason = "running in single-player mode";
if (reason != NULL) {
@ -3070,11 +3070,18 @@ CL_ShutdownRef
============
*/
void CL_ShutdownRef( void ) {
if ( !re.Shutdown ) {
return;
if ( re.Shutdown ) {
re.Shutdown( qtrue );
}
re.Shutdown( qtrue );
Com_Memset( &re, 0, sizeof( re ) );
#ifdef USE_RENDERER_DLOPEN
if ( rendererLib ) {
Sys_UnloadLibrary( rendererLib );
rendererLib = NULL;
}
#endif
}
/*
@ -4145,6 +4152,9 @@ void CL_GlobalServers_f( void ) {
com_gamename->string, Cmd_Argv(2));
}
}
else if ( !Q_stricmp( com_gamename->string, LEGACY_MASTER_GAMENAME ) )
Com_sprintf(command, sizeof(command), "getservers %s",
Cmd_Argv(2));
else
Com_sprintf(command, sizeof(command), "getservers %s %s",
com_gamename->string, Cmd_Argv(2));

View file

@ -352,11 +352,6 @@ void CL_SystemInfoChanged( void ) {
// in some cases, outdated cp commands might get sent with this news serverId
cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) );
// don't set any vars when playing a demo
if ( clc.demoplaying ) {
return;
}
#ifdef USE_VOIP
#ifdef LEGACY_PROTOCOL
if(clc.compat)
@ -365,13 +360,15 @@ void CL_SystemInfoChanged( void ) {
#endif
{
s = Info_ValueForKey( systemInfo, "sv_voip" );
if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive"))
clc.voipEnabled = qfalse;
else
clc.voipEnabled = atoi(s);
clc.voipEnabled = atoi(s);
}
#endif
// don't set any vars when playing a demo
if ( clc.demoplaying ) {
return;
}
s = Info_ValueForKey( systemInfo, "sv_cheats" );
cl_connectedToCheatServer = atoi( s );
if ( !cl_connectedToCheatServer ) {
@ -789,7 +786,6 @@ void CL_ParseVoip ( msg_t *msg ) {
}
for (i = 0; i < frames; i++) {
char encoded[256];
const int len = MSG_ReadByte(msg);
if (len < 0) {
Com_DPrintf("VoIP: Short packet!\n");

View file

@ -164,7 +164,6 @@ void S_TransferPaintBuffer(int endtime)
if ( s_testsound->integer ) {
int i;
int count;
// write a fixed sine wave
count = (endtime - s_paintedtime);

View file

@ -1876,6 +1876,7 @@ static void S_AL_MusicSourceFree( void )
{
// Release the output musicSource
S_AL_SrcUnlock(musicSourceHandle);
S_AL_SrcKill(musicSourceHandle);
musicSource = 0;
musicSourceHandle = -1;
}
@ -1908,17 +1909,22 @@ S_AL_StopBackgroundTrack
static
void S_AL_StopBackgroundTrack( void )
{
int numBuffers;
if(!musicPlaying)
return;
// Stop playing
qalSourceStop(musicSource);
// De-queue the musicBuffers
qalSourceUnqueueBuffers(musicSource, NUM_MUSIC_BUFFERS, musicBuffers);
// Destroy the musicBuffers
qalDeleteBuffers(NUM_MUSIC_BUFFERS, musicBuffers);
// Un-queue any buffers, and delete them
qalGetSourcei( musicSource, AL_BUFFERS_PROCESSED, &numBuffers );
while( numBuffers-- )
{
ALuint buffer;
qalSourceUnqueueBuffers(musicSource, 1, &buffer);
qalDeleteBuffers(1, &buffer);
}
// Free the musicSource
S_AL_MusicSourceFree();

View file

@ -708,10 +708,10 @@ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int ti
dp_realtime = time;
if ( pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer ) {
if ( pi->pendingWeapon != WP_NUM_WEAPONS && dp_realtime > pi->weaponTimer ) {
pi->weapon = pi->pendingWeapon;
pi->lastWeapon = pi->pendingWeapon;
pi->pendingWeapon = -1;
pi->pendingWeapon = WP_NUM_WEAPONS;
pi->weaponTimer = 0;
if( pi->currentWeapon != pi->weapon ) {
trap_S_StartLocalSound( weaponChangeSound, CHAN_LOCAL );
@ -1136,7 +1136,7 @@ void UI_PlayerInfo_SetModel( playerInfo_t *pi, const char *model ) {
pi->weapon = WP_MACHINEGUN;
pi->currentWeapon = pi->weapon;
pi->lastWeapon = pi->weapon;
pi->pendingWeapon = -1;
pi->pendingWeapon = WP_NUM_WEAPONS;
pi->weaponTimer = 0;
pi->chat = qfalse;
pi->newModel = qtrue;
@ -1202,11 +1202,11 @@ void UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_
pi->torso.yawAngle = viewAngles[YAW];
pi->torso.yawing = qfalse;
if ( weaponNumber != -1 ) {
if ( weaponNumber != WP_NUM_WEAPONS ) {
pi->weapon = weaponNumber;
pi->currentWeapon = weaponNumber;
pi->lastWeapon = weaponNumber;
pi->pendingWeapon = -1;
pi->pendingWeapon = WP_NUM_WEAPONS;
pi->weaponTimer = 0;
UI_PlayerInfo_SetWeapon( pi, pi->weapon );
}
@ -1215,8 +1215,8 @@ void UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_
}
// weapon
if ( weaponNumber == -1 ) {
pi->pendingWeapon = -1;
if ( weaponNumber == WP_NUM_WEAPONS ) {
pi->pendingWeapon = WP_NUM_WEAPONS;
pi->weaponTimer = 0;
}
else if ( weaponNumber != WP_NONE ) {

View file

@ -1411,8 +1411,6 @@ void Com_InitSmallZoneMemory( void ) {
Com_Error( ERR_FATAL, "Small zone data failed to allocate %1.1f megs", (float)s_smallZoneTotal / (1024*1024) );
}
Z_ClearZone( smallzone, s_smallZoneTotal );
return;
}
void Com_InitZoneMemory( void ) {
@ -2248,7 +2246,7 @@ Just throw a fatal error to
test error shutdown procedures
=============
*/
static void Com_Error_f (void) {
static void __attribute__((__noreturn__)) Com_Error_f (void) {
if ( Cmd_Argc() > 1 ) {
Com_Error( ERR_DROP, "Testing drop error" );
} else {
@ -2541,8 +2539,9 @@ static void Com_WriteCDKey( const char *filename, const char *ikey ) {
out:
#ifndef _WIN32
umask(savedumask);
#else
;
#endif
return;
}
#endif

View file

@ -1398,7 +1398,7 @@ Return the searchpath in "startSearch".
=================
*/
vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const char *name, int enableDll)
int FS_FindVM(void **startSearch, char *found, int foundlen, const char *name, int enableDll)
{
searchpath_t *search, *lastSearch;
directory_t *dir;
@ -2810,7 +2810,6 @@ void FS_Which_f( void ) {
}
Com_Printf("File not found: \"%s\"\n", filename);
return;
}

View file

@ -286,15 +286,22 @@ PARSING
static char com_token[MAX_TOKEN_CHARS];
static char com_parsename[MAX_TOKEN_CHARS];
static int com_lines;
static int com_tokenline;
void COM_BeginParseSession( const char *name )
{
com_lines = 0;
com_lines = 1;
com_tokenline = 0;
Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name);
}
int COM_GetCurrentParseLine( void )
{
if ( com_tokenline )
{
return com_tokenline;
}
return com_lines;
}
@ -312,7 +319,7 @@ void COM_ParseError( char *format, ... )
Q_vsnprintf (string, sizeof(string), format, argptr);
va_end (argptr);
Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, com_lines, string);
Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, COM_GetCurrentParseLine(), string);
}
void COM_ParseWarning( char *format, ... )
@ -324,7 +331,7 @@ void COM_ParseWarning( char *format, ... )
Q_vsnprintf (string, sizeof(string), format, argptr);
va_end (argptr);
Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, com_lines, string);
Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, COM_GetCurrentParseLine(), string);
}
/*
@ -434,6 +441,7 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
data = *data_p;
len = 0;
com_token[0] = 0;
com_tokenline = 0;
// make sure incoming data is valid
if ( !data )
@ -473,6 +481,10 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
data += 2;
while ( *data && ( *data != '*' || data[1] != '/' ) )
{
if ( *data == '\n' )
{
com_lines++;
}
data++;
}
if ( *data )
@ -486,6 +498,9 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
}
}
// token starts on this line
com_tokenline = com_lines;
// handle quoted strings
if (c == '\"')
{
@ -499,6 +514,10 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
*data_p = ( char * ) data;
return com_token;
}
if ( c == '\n' )
{
com_lines++;
}
if (len < MAX_TOKEN_CHARS - 1)
{
com_token[len] = c;
@ -517,8 +536,6 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
}
data++;
c = *data;
if ( c == '\n' )
com_lines++;
} while (c>32);
com_token[len] = 0;
@ -546,16 +563,14 @@ void COM_MatchToken( char **buf_p, char *match ) {
=================
SkipBracedSection
The next token should be an open brace.
The next token should be an open brace or set depth to 1 if already parsed it.
Skips until a matching close brace is found.
Internal brace depths are properly skipped.
=================
*/
void SkipBracedSection (char **program) {
qboolean SkipBracedSection (char **program, int depth) {
char *token;
int depth;
depth = 0;
do {
token = COM_ParseExt( program, qtrue );
if( token[1] == 0 ) {
@ -567,6 +582,8 @@ void SkipBracedSection (char **program) {
}
}
} while( depth && *program );
return ( depth == 0 );
}
/*

View file

@ -51,6 +51,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Heartbeat for dpmaster protocol. You shouldn't change this unless you know what you're doing
#define HEARTBEAT_FOR_MASTER "DarkPlaces"
// When com_gamename is LEGACY_MASTER_GAMENAME, use quake3 master protocol.
// You shouldn't change this unless you know what you're doing
#define LEGACY_MASTER_GAMENAME "Quake3Arena"
#define LEGACY_HEARTBEAT_FOR_MASTER "QuakeArena-1"
#define BASETA "missionpack"
#ifndef PRODUCT_VERSION
@ -752,7 +757,7 @@ typedef struct pc_token_s
void COM_MatchToken( char**buf_p, char *match );
void SkipBracedSection (char **program);
qboolean SkipBracedSection (char **program, int depth);
void SkipRestOfLine ( char **data );
void Parse1DMatrix (char **buf_p, int x, float *m);

View file

@ -624,7 +624,7 @@ qboolean FS_FileExists( const char *file );
qboolean FS_CreatePath (char *OSPath);
vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const char *name, int enableDll);
int FS_FindVM(void **startSearch, char *found, int foundlen, const char *name, int enableDll);
char *FS_BuildOSPath( const char *base, const char *game, const char *qpath );
qboolean FS_CompareZipChecksum(const char *zipfile);

View file

@ -45,11 +45,7 @@ static clock_t time_total_vm = 0;
#endif
/* exit() won't be called but use it because it is marked with noreturn */
#define DIE( reason ) \
do { \
Com_Error(ERR_DROP, "vm_powerpc compiler error: " reason); \
exit(1); \
} while(0)
#define DIE( reason ) Com_Error( ERR_DROP, "vm_powerpc compiler error: " reason )
/*
* vm_powerpc uses large quantities of memory during compilation,
@ -1965,8 +1961,6 @@ PPC_ComputeCode( vm_t *vm )
di_now = di_first;
}
}
return;
}
static void

View file

@ -701,7 +701,7 @@ static void dst_insn_append(struct func_info * const fp)
static void ErrJump(void)
{
Com_Error(ERR_DROP, "program tried to execute code outside VM\n");
Com_Error(ERR_DROP, "program tried to execute code outside VM");
exit(1);
}

View file

@ -381,10 +381,9 @@ Error handler for jump/call to invalid instruction number
=================
*/
static void ErrJump(void)
static void __attribute__((__noreturn__)) ErrJump(void)
{
Com_Error(ERR_DROP, "program tried to execute code outside VM");
exit(1);
}
/*

View file

@ -73,10 +73,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifdef BUILD_FREETYPE
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_ERRORS_H
#include FT_SYSTEM_H
#include FT_IMAGE_H
#include FT_FREETYPE_H
#include FT_OUTLINE_H
#define _FLOOR(x) ((x) & -64)
@ -401,6 +401,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
font->glyphs[i].glyph = RE_RegisterShaderNoMip(font->glyphs[i].shaderName);
}
Com_Memcpy(&registeredFont[registeredFontCount++], font, sizeof(fontInfo_t));
ri.FS_FreeFile(faceData);
return;
}
@ -435,12 +436,12 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
// make a 256x256 image buffer, once it is full, register it, clean it and keep going
// until all glyphs are rendered
out = ri.Malloc(1024*1024);
out = ri.Malloc(256*256);
if (out == NULL) {
ri.Printf(PRINT_WARNING, "RE_RegisterFont: ri.Malloc failure during output image creation.\n");
return;
}
Com_Memset(out, 0, 1024*1024);
Com_Memset(out, 0, 256*256);
maxHeight = 0;
@ -499,11 +500,12 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
Q_strncpyz(font->glyphs[j].shaderName, name, sizeof(font->glyphs[j].shaderName));
}
lastStart = i;
Com_Memset(out, 0, 1024*1024);
Com_Memset(out, 0, 256*256);
xOut = 0;
yOut = 0;
ri.Free(imageBuff);
i++;
if(i == GLYPH_END)
i++;
} else {
Com_Memcpy(&font->glyphs[i], glyph, sizeof(glyphInfo_t));
i++;

View file

@ -42,7 +42,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# endif
#endif
static void R_JPGErrorExit(j_common_ptr cinfo)
static void __attribute__((__noreturn__)) R_JPGErrorExit(j_common_ptr cinfo)
{
char buffer[JMSG_LENGTH_MAX];

View file

@ -668,9 +668,10 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
qglDepthRange (0, 1);
}
#if 0
RB_DrawSun();
#endif
if (r_drawSun->integer) {
RB_DrawSun(0.1, tr.sunShader);
}
// darken down any stencil shadows
RB_ShadowFinish();

View file

@ -21,8 +21,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "tr_local.h"
volatile renderCommandList_t *renderCommandList;
/*
=====================
R_PerformanceCounters

View file

@ -352,8 +352,8 @@ void RB_RenderFlare( flare_t *f ) {
VectorScale(f->color, f->drawIntensity * intensity, color);
// Calculations for fogging
if(tr.world && f->fogNum < tr.world->numfogs)
// Calculations for fogging
if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs)
{
tess.numVertexes = 1;
VectorCopy(f->origin, tess.xyz[0]);

View file

@ -1327,7 +1327,7 @@ SKIES
void R_BuildCloudData( shaderCommands_t *shader );
void R_InitSkyTexCoords( float cloudLayerHeight );
void R_DrawSkyBox( shaderCommands_t *shader );
void RB_DrawSun( void );
void RB_DrawSun( float scale, shader_t *shader );
void RB_ClipSkyPolygons( shaderCommands_t *shader );
/*
@ -1594,8 +1594,6 @@ extern int max_polyverts;
extern backEndData_t *backEndData; // the second one may not be allocated
extern volatile renderCommandList_t *renderCommandList;
void *R_GetCommandBuffer( int bytes );
void RB_ExecuteRenderCommands( const void *data );

View file

@ -458,15 +458,15 @@ static qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *mod_
LL(surf->ofsXyzNormals);
LL(surf->ofsEnd);
if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
if ( surf->numVerts >= SHADER_MAX_VERTEXES ) {
ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on %s (%i).\n",
mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface",
mod_name, SHADER_MAX_VERTEXES - 1, surf->name[0] ? surf->name : "a surface",
surf->numVerts );
return qfalse;
}
if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {
if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) {
ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on %s (%i).\n",
mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface",
mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface",
surf->numTriangles );
return qfalse;
}
@ -736,17 +736,17 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char
// numBoneReferences and BoneReferences generally seem to be unused
// now do the checks that may fail.
if ( surf->numVerts > SHADER_MAX_VERTEXES )
if ( surf->numVerts >= SHADER_MAX_VERTEXES )
{
ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n",
mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface",
mod_name, SHADER_MAX_VERTEXES - 1, surf->name[0] ? surf->name : "a surface",
surf->numVerts );
return qfalse;
}
if ( surf->numTriangles*3 > SHADER_MAX_INDEXES )
if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES )
{
ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n",
mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface",
mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface",
surf->numTriangles );
return qfalse;
}
@ -953,15 +953,15 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) {
LL(surf->ofsVerts);
LL(surf->ofsEnd);
if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
if ( surf->numVerts >= SHADER_MAX_VERTEXES ) {
ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on %s (%i).\n",
mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface",
mod_name, SHADER_MAX_VERTEXES - 1, surf->name[0] ? surf->name : "a surface",
surf->numVerts );
return qfalse;
}
if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {
if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) {
ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on %s (%i).\n",
mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface",
mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface",
surf->numTriangles );
return qfalse;
}

View file

@ -206,7 +206,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
}
vertexarray = (iqmVertexArray_t *)((byte *)header + header->ofs_vertexarrays);
for( i = 0; i < header->num_vertexarrays; i++, vertexarray++ ) {
int j, n, *intPtr;
int n, *intPtr;
if( vertexarray->size <= 0 || vertexarray->size > 4 ) {
return qfalse;
@ -318,17 +318,17 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
}
// check ioq3 limits
if ( mesh->num_vertexes > SHADER_MAX_VERTEXES )
if ( mesh->num_vertexes >= SHADER_MAX_VERTEXES )
{
ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n",
mod_name, SHADER_MAX_VERTEXES, meshName[0] ? meshName : "a surface",
mod_name, SHADER_MAX_VERTEXES - 1, meshName[0] ? meshName : "a surface",
mesh->num_vertexes );
return qfalse;
}
if ( mesh->num_triangles*3 > SHADER_MAX_INDEXES )
if ( mesh->num_triangles*3 >= SHADER_MAX_INDEXES )
{
ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n",
mod_name, SHADER_MAX_INDEXES / 3, meshName[0] ? meshName : "a surface",
mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, meshName[0] ? meshName : "a surface",
mesh->num_triangles );
return qfalse;
}
@ -953,10 +953,10 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
float jointMats[IQM_MAX_JOINTS * 12];
int i;
vec4_t *outXYZ = &tess.xyz[tess.numVertexes];
vec4_t *outNormal = &tess.normal[tess.numVertexes];
vec2_t (*outTexCoord)[2] = &tess.texCoords[tess.numVertexes];
color4ub_t *outColor = &tess.vertexColors[tess.numVertexes];
vec4_t *outXYZ;
vec4_t *outNormal;
vec2_t (*outTexCoord)[2];
color4ub_t *outColor;
int frame = data->num_frames ? backEnd.currentEntity->e.frame % data->num_frames : 0;
int oldframe = data->num_frames ? backEnd.currentEntity->e.oldframe % data->num_frames : 0;
@ -968,6 +968,11 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
RB_CHECKOVERFLOW( surf->num_vertexes, surf->num_triangles * 3 );
outXYZ = &tess.xyz[tess.numVertexes];
outNormal = &tess.normal[tess.numVertexes];
outTexCoord = &tess.texCoords[tess.numVertexes];
outColor = &tess.vertexColors[tess.numVertexes];
// compute interpolated joint matrices
if ( data->num_joints > 0 ) {
ComputePoseMats( data, frame, oldframe, backlerp, jointMats );

View file

@ -1668,7 +1668,7 @@ static void ComputeStageIteratorFunc( void )
if ( shader.isSky )
{
shader.optimalStageIteratorFunc = RB_StageIteratorSky;
goto done;
return;
}
if ( r_ignoreFastPath->integer )
@ -1694,7 +1694,7 @@ static void ComputeStageIteratorFunc( void )
if ( !shader.numDeforms )
{
shader.optimalStageIteratorFunc = RB_StageIteratorVertexLitTexture;
goto done;
return;
}
}
}
@ -1720,16 +1720,12 @@ static void ComputeStageIteratorFunc( void )
if ( shader.multitextureEnv )
{
shader.optimalStageIteratorFunc = RB_StageIteratorLightmappedMultitexture;
goto done;
}
}
}
}
}
}
done:
return;
}
typedef struct {
@ -2386,7 +2382,7 @@ static char *FindShaderInShaderText( const char *shadername ) {
}
else {
// skip the definition
SkipBracedSection( &p );
SkipBracedSection( &p, 0 );
}
}
@ -2920,6 +2916,8 @@ static void ScanAndLoadShaderFiles( void )
int i;
char *oldp, *token, *hashMem, *textEnd;
int shaderTextHashTableSizes[MAX_SHADERTEXT_HASH], hash, size;
char shaderName[MAX_QPATH];
int shaderLine;
long sum = 0, summand;
// scan for shader files
@ -2949,26 +2947,40 @@ static void ScanAndLoadShaderFiles( void )
// Do a simple check on the shader structure in that file to make sure one bad shader file cannot fuck up all other shaders.
p = buffers[i];
COM_BeginParseSession(filename);
while(1)
{
token = COM_ParseExt(&p, qtrue);
if(!*token)
break;
oldp = p;
Q_strncpyz(shaderName, token, sizeof(shaderName));
shaderLine = COM_GetCurrentParseLine();
token = COM_ParseExt(&p, qtrue);
if(token[0] != '{' && token[1] != '\0')
if(token[0] != '{' || token[1] != '\0')
{
ri.Printf(PRINT_WARNING, "WARNING: Bad shader file %s has incorrect syntax.\n", filename);
ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing opening brace",
filename, shaderName, shaderLine);
if (token[0])
{
ri.Printf(PRINT_WARNING, " (found \"%s\" on line %d)", token, COM_GetCurrentParseLine());
}
ri.Printf(PRINT_WARNING, ".\n");
ri.FS_FreeFile(buffers[i]);
buffers[i] = NULL;
break;
}
SkipBracedSection(&oldp);
p = oldp;
if(!SkipBracedSection(&p, 1))
{
ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n",
filename, shaderName, shaderLine);
ri.FS_FreeFile(buffers[i]);
buffers[i] = NULL;
break;
}
}
@ -3012,7 +3024,7 @@ static void ScanAndLoadShaderFiles( void )
hash = generateHashValue(token, MAX_SHADERTEXT_HASH);
shaderTextHashTableSizes[hash]++;
size++;
SkipBracedSection(&p);
SkipBracedSection(&p, 0);
}
size += MAX_SHADERTEXT_HASH;
@ -3038,7 +3050,7 @@ static void ScanAndLoadShaderFiles( void )
hash = generateHashValue(token, MAX_SHADERTEXT_HASH);
shaderTextHashTable[hash][shaderTextHashTableSizes[hash]++] = oldp;
SkipBracedSection(&p);
SkipBracedSection(&p, 0);
}
return;

View file

@ -696,23 +696,21 @@ void R_InitSkyTexCoords( float heightCloud )
/*
** RB_DrawSun
*/
void RB_DrawSun( void ) {
void RB_DrawSun( float scale, shader_t *shader ) {
float size;
float dist;
vec3_t origin, vec1, vec2;
vec3_t temp;
byte sunColor[4] = { 255, 255, 255, 255 };
if ( !backEnd.skyRenderedThisView ) {
return;
}
if ( !r_drawSun->integer ) {
return;
}
qglLoadMatrixf( backEnd.viewParms.world.modelMatrix );
qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);
dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
size = dist * 0.4;
size = dist * scale;
VectorScale( tr.sunDirection, dist, origin );
PerpendicularVector( vec1, tr.sunDirection );
@ -724,58 +722,9 @@ void RB_DrawSun( void ) {
// farthest depth range
qglDepthRange( 1.0, 1.0 );
// FIXME: use quad stamp
RB_BeginSurface( tr.sunShader, tess.fogNum );
VectorCopy( origin, temp );
VectorSubtract( temp, vec1, temp );
VectorSubtract( temp, vec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
RB_BeginSurface( shader, 0 );
VectorCopy( origin, temp );
VectorAdd( temp, vec1, temp );
VectorSubtract( temp, vec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
VectorCopy( origin, temp );
VectorAdd( temp, vec1, temp );
VectorAdd( temp, vec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 1;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
VectorCopy( origin, temp );
VectorSubtract( temp, vec1, temp );
VectorAdd( temp, vec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 1;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 1;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 3;
RB_AddQuadStamp(origin, vec1, vec2, sunColor);
RB_EndSurface();

View file

@ -1157,6 +1157,7 @@ Draws x/y/z lines from the origin for orientation debugging
*/
static void RB_SurfaceAxis( void ) {
GL_Bind( tr.whiteImage );
GL_State( GLS_DEFAULT );
qglLineWidth( 3 );
qglBegin( GL_LINES );
qglColor3f( 1,0,0 );
@ -1202,7 +1203,6 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) {
RB_SurfaceAxis();
break;
}
return;
}
static void RB_SurfaceBad( surfaceType_t *surfType ) {

View file

@ -350,7 +350,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
}
if (!size)
ri.Error(ERR_DROP, "Bad header for %s!\n", filename);
ri.Error(ERR_DROP, "Bad header for %s!", filename);
size -= 2;
p += 2;
@ -368,10 +368,10 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
#if 0 // HDRFILE_RGBE
if (size != tr.lightmapSize * tr.lightmapSize * 4)
ri.Error(ERR_DROP, "Bad size for %s (%i)!\n", filename, size);
ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size);
#else // HDRFILE_FLOAT
if (size != tr.lightmapSize * tr.lightmapSize * 12)
ri.Error(ERR_DROP, "Bad size for %s (%i)!\n", filename, size);
ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size);
#endif
}
else
@ -524,11 +524,13 @@ static float FatPackU(float input, int lightmapnum)
if (tr.worldDeluxeMapping)
lightmapnum >>= 1;
lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep);
if(tr.fatLightmapSize > 0)
{
int x = lightmapnum % tr.fatLightmapStep;
int x;
lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep);
x = lightmapnum % tr.fatLightmapStep;
return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)x);
}
@ -544,11 +546,13 @@ static float FatPackV(float input, int lightmapnum)
if (tr.worldDeluxeMapping)
lightmapnum >>= 1;
lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep);
if(tr.fatLightmapSize > 0)
{
int y = lightmapnum / tr.fatLightmapStep;
int y;
lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep);
y = lightmapnum / tr.fatLightmapStep;
return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)y);
}
@ -2184,7 +2188,7 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) {
{
//ri.Printf(PRINT_ALL, "Found!\n");
if (size != sizeof(float) * 3 * (verts->filelen / sizeof(*dv)))
ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!\n", filename, size, (int)((sizeof(float)) * 3 * (verts->filelen / sizeof(*dv))));
ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)((sizeof(float)) * 3 * (verts->filelen / sizeof(*dv))));
}
}
@ -2685,7 +2689,7 @@ void R_LoadLightGrid( lump_t *l ) {
if (size != sizeof(float) * 6 * numGridPoints)
{
ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!\n", filename, size, (int)(sizeof(float)) * 6 * numGridPoints);
ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridPoints);
}
w->hdrLightGrid = ri.Hunk_Alloc(size, h_low);
@ -3352,12 +3356,12 @@ void RE_LoadWorldMap( const char *name ) {
if (0)
{
world_t *w;
w = &s_worldData;
uint8_t *primaryLightGrid, *data;
int lightGridSize;
int i;
w = &s_worldData;
lightGridSize = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2];
primaryLightGrid = ri.Malloc(lightGridSize * sizeof(*primaryLightGrid));
@ -3376,6 +3380,7 @@ void RE_LoadWorldMap( const char *name ) {
gridLightCol[0] = ByteToFloat(data[3]);
gridLightCol[1] = ByteToFloat(data[4]);
gridLightCol[2] = ByteToFloat(data[5]);
(void)gridLightCol; // Suppress unused-but-set-variable warning
lat = data[7];
lng = data[6];

View file

@ -21,8 +21,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "tr_local.h"
volatile renderCommandList_t *renderCommandList;
/*
=====================
R_PerformanceCounters

View file

@ -25,11 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// tr_extratypes.h, for mods that want to extend tr_types.h without losing compatibility with original VMs
// extra renderfx flags start at 0x0400
#define RF_SUNFLARE 0x0400
// extra refdef flags start at 0x0008
#define RDF_NOFOG 0x0008 // don't apply fog
#define RDF_NOFOG 0x0008 // don't apply fog to polys added using RE_AddPolyToScene
#define RDF_EXTRA 0x0010 // Makro - refdefex_t to follow after refdef_t
#define RDF_SUNLIGHT 0x0020 // SmileTheory - render sunlight and shadows

View file

@ -107,7 +107,7 @@ FBO_t *FBO_Create(const char *name, int width, int height)
if(strlen(name) >= MAX_QPATH)
{
ri.Error(ERR_DROP, "FBO_Create: \"%s\" is too long\n", name);
ri.Error(ERR_DROP, "FBO_Create: \"%s\" is too long", name);
}
if(width <= 0 || width > glRefConfig.maxRenderbufferSize)

View file

@ -352,8 +352,8 @@ void RB_RenderFlare( flare_t *f ) {
VectorScale(f->color, f->drawIntensity * intensity, color);
// Calculations for fogging
if(tr.world && f->fogNum < tr.world->numfogs)
// Calculations for fogging
if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs)
{
tess.numVertexes = 1;
VectorCopy(f->origin, tess.xyz[0]);

View file

@ -431,7 +431,8 @@ static void GLSL_LinkProgram(GLhandleARB program)
if(!linked)
{
GLSL_PrintInfoLog(program, qfalse);
ri.Error(ERR_DROP, "\nshaders failed to link");
ri.Printf(PRINT_ALL, "\n");
ri.Error(ERR_DROP, "shaders failed to link");
}
}
@ -445,7 +446,8 @@ static void GLSL_ValidateProgram(GLhandleARB program)
if(!validated)
{
GLSL_PrintInfoLog(program, qfalse);
ri.Error(ERR_DROP, "\nshaders failed to validate");
ri.Printf(PRINT_ALL, "\n");
ri.Error(ERR_DROP, "shaders failed to validate");
}
}

View file

@ -2652,8 +2652,6 @@ extern int max_polyverts;
extern backEndData_t *backEndData; // the second one may not be allocated
extern volatile renderCommandList_t *renderCommandList;
void *R_GetCommandBuffer( int bytes );
void RB_ExecuteRenderCommands( const void *data );

View file

@ -495,17 +495,17 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
LL(md3Surf->ofsXyzNormals);
LL(md3Surf->ofsEnd);
if(md3Surf->numVerts > SHADER_MAX_VERTEXES)
if(md3Surf->numVerts >= SHADER_MAX_VERTEXES)
{
ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on %s (%i).\n",
modName, SHADER_MAX_VERTEXES, md3Surf->name[0] ? md3Surf->name : "a surface",
modName, SHADER_MAX_VERTEXES - 1, md3Surf->name[0] ? md3Surf->name : "a surface",
md3Surf->numVerts );
return qfalse;
}
if(md3Surf->numTriangles * 3 > SHADER_MAX_INDEXES)
if(md3Surf->numTriangles * 3 >= SHADER_MAX_INDEXES)
{
ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on %s (%i).\n",
modName, SHADER_MAX_INDEXES / 3, md3Surf->name[0] ? md3Surf->name : "a surface",
modName, ( SHADER_MAX_INDEXES / 3 ) - 1, md3Surf->name[0] ? md3Surf->name : "a surface",
md3Surf->numTriangles );
return qfalse;
}
@ -996,17 +996,17 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char
// numBoneReferences and BoneReferences generally seem to be unused
// now do the checks that may fail.
if ( surf->numVerts > SHADER_MAX_VERTEXES )
if ( surf->numVerts >= SHADER_MAX_VERTEXES )
{
ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n",
mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface",
mod_name, SHADER_MAX_VERTEXES - 1, surf->name[0] ? surf->name : "a surface",
surf->numVerts );
return qfalse;
}
if ( surf->numTriangles*3 > SHADER_MAX_INDEXES )
if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES )
{
ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n",
mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface",
mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface",
surf->numTriangles );
return qfalse;
}
@ -1213,15 +1213,15 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) {
LL(surf->ofsVerts);
LL(surf->ofsEnd);
if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
if ( surf->numVerts >= SHADER_MAX_VERTEXES ) {
ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on %s (%i).\n",
mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface",
mod_name, SHADER_MAX_VERTEXES - 1, surf->name[0] ? surf->name : "a surface",
surf->numVerts );
return qfalse;
}
if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {
if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) {
ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on %s (%i).\n",
mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface",
mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface",
surf->numTriangles );
return qfalse;
}

View file

@ -206,7 +206,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
}
vertexarray = (iqmVertexArray_t *)((byte *)header + header->ofs_vertexarrays);
for( i = 0; i < header->num_vertexarrays; i++, vertexarray++ ) {
int j, n, *intPtr;
int n, *intPtr;
if( vertexarray->size <= 0 || vertexarray->size > 4 ) {
return qfalse;
@ -318,17 +318,17 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
}
// check ioq3 limits
if ( mesh->num_vertexes > SHADER_MAX_VERTEXES )
if ( mesh->num_vertexes >= SHADER_MAX_VERTEXES )
{
ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n",
mod_name, SHADER_MAX_VERTEXES, meshName[0] ? meshName : "a surface",
mod_name, SHADER_MAX_VERTEXES - 1, meshName[0] ? meshName : "a surface",
mesh->num_vertexes );
return qfalse;
}
if ( mesh->num_triangles*3 > SHADER_MAX_INDEXES )
if ( mesh->num_triangles*3 >= SHADER_MAX_INDEXES )
{
ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n",
mod_name, SHADER_MAX_INDEXES / 3, meshName[0] ? meshName : "a surface",
mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, meshName[0] ? meshName : "a surface",
mesh->num_triangles );
return qfalse;
}
@ -953,10 +953,10 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
float jointMats[IQM_MAX_JOINTS * 12];
int i;
vec4_t *outXYZ = &tess.xyz[tess.numVertexes];
vec4_t *outNormal = &tess.normal[tess.numVertexes];
vec2_t (*outTexCoord)[2] = &tess.texCoords[tess.numVertexes];
vec4_t *outColor = &tess.vertexColors[tess.numVertexes];
vec4_t *outXYZ;
vec4_t *outNormal;
vec2_t (*outTexCoord)[2];
vec4_t *outColor;
int frame = data->num_frames ? backEnd.currentEntity->e.frame % data->num_frames : 0;
int oldframe = data->num_frames ? backEnd.currentEntity->e.oldframe % data->num_frames : 0;
@ -968,6 +968,11 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
RB_CHECKOVERFLOW( surf->num_vertexes, surf->num_triangles * 3 );
outXYZ = &tess.xyz[tess.numVertexes];
outNormal = &tess.normal[tess.numVertexes];
outTexCoord = &tess.texCoords[tess.numVertexes];
outColor = &tess.vertexColors[tess.numVertexes];
// compute interpolated joint matrices
if ( data->num_joints > 0 ) {
ComputePoseMats( data, frame, oldframe, backlerp, jointMats );

View file

@ -415,6 +415,7 @@ static void ProjectDlightTexture( void ) {
backEnd.pc.c_totalIndexes += tess.numIndexes;
backEnd.pc.c_dlightIndexes += tess.numIndexes;
backEnd.pc.c_dlightVertexes += tess.numVertexes;
}
}
@ -874,6 +875,7 @@ static void ForwardDlight( void ) {
backEnd.pc.c_totalIndexes += tess.numIndexes;
backEnd.pc.c_dlightIndexes += tess.numIndexes;
backEnd.pc.c_dlightVertexes += tess.numVertexes;
}
}

View file

@ -456,10 +456,10 @@ static void Autosprite2Deform( void ) {
vec3_t forward;
if ( tess.numVertexes & 3 ) {
ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd vertex count", tess.shader->name );
ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd vertex count\n", tess.shader->name );
}
if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) {
ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd index count", tess.shader->name );
ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd index count\n", tess.shader->name );
}
if ( backEnd.currentEntity != &tr.worldEntity ) {

View file

@ -3018,7 +3018,7 @@ static char *FindShaderInShaderText( const char *shadername ) {
}
else {
// skip the definition
SkipBracedSection( &p );
SkipBracedSection( &p, 0 );
}
}
@ -3542,6 +3542,8 @@ static void ScanAndLoadShaderFiles( void )
int i;
char *oldp, *token, *hashMem, *textEnd;
int shaderTextHashTableSizes[MAX_SHADERTEXT_HASH], hash, size;
char shaderName[MAX_QPATH];
int shaderLine;
long sum = 0, summand;
// scan for shader files
@ -3585,26 +3587,40 @@ static void ScanAndLoadShaderFiles( void )
// Do a simple check on the shader structure in that file to make sure one bad shader file cannot fuck up all other shaders.
p = buffers[i];
COM_BeginParseSession(filename);
while(1)
{
token = COM_ParseExt(&p, qtrue);
if(!*token)
break;
oldp = p;
Q_strncpyz(shaderName, token, sizeof(shaderName));
shaderLine = COM_GetCurrentParseLine();
token = COM_ParseExt(&p, qtrue);
if(token[0] != '{' && token[1] != '\0')
if(token[0] != '{' || token[1] != '\0')
{
ri.Printf(PRINT_WARNING, "WARNING: Bad shader file %s has incorrect syntax.\n", filename);
ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing opening brace",
filename, shaderName, shaderLine);
if (token[0])
{
ri.Printf(PRINT_WARNING, " (found \"%s\" on line %d)", token, COM_GetCurrentParseLine());
}
ri.Printf(PRINT_WARNING, ".\n");
ri.FS_FreeFile(buffers[i]);
buffers[i] = NULL;
break;
}
SkipBracedSection(&oldp);
p = oldp;
if(!SkipBracedSection(&p, 1))
{
ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n",
filename, shaderName, shaderLine);
ri.FS_FreeFile(buffers[i]);
buffers[i] = NULL;
break;
}
}
@ -3648,7 +3664,7 @@ static void ScanAndLoadShaderFiles( void )
hash = generateHashValue(token, MAX_SHADERTEXT_HASH);
shaderTextHashTableSizes[hash]++;
size++;
SkipBracedSection(&p);
SkipBracedSection(&p, 0);
}
size += MAX_SHADERTEXT_HASH;
@ -3674,7 +3690,7 @@ static void ScanAndLoadShaderFiles( void )
hash = generateHashValue(token, MAX_SHADERTEXT_HASH);
shaderTextHashTable[hash][shaderTextHashTableSizes[hash]++] = oldp;
SkipBracedSection(&p);
SkipBracedSection(&p, 0);
}
return;

View file

@ -1515,6 +1515,7 @@ static void RB_SurfaceAxis( void ) {
// FIXME: implement this
#if 0
GL_Bind( tr.whiteImage );
GL_State( GLS_DEFAULT );
qglLineWidth( 3 );
qglBegin( GL_LINES );
qglColor3f( 1,0,0 );
@ -1561,7 +1562,6 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) {
RB_SurfaceAxis();
break;
}
return;
}
static void RB_SurfaceBad( surfaceType_t *surfType ) {

View file

@ -36,6 +36,10 @@ static qboolean R_CullSurface( msurface_t *surf ) {
return qfalse;
}
if ( *surf->data == SF_GRID && r_nocurves->integer ) {
return qtrue;
}
if (surf->cullinfo.type & CULLINFO_PLANE)
{
// Only true for SF_FACE, so treat like its own function
@ -157,7 +161,6 @@ static int R_DlightSurface( msurface_t *surf, int dlightBits ) {
if ( surf->cullinfo.type & CULLINFO_PLANE )
{
int i;
for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) {
if ( ! ( dlightBits & ( 1 << i ) ) ) {
continue;
@ -219,6 +222,8 @@ static int R_DlightSurface( msurface_t *surf, int dlightBits ) {
if ( dlightBits ) {
tr.pc.c_dlightSurfaces++;
} else {
tr.pc.c_dlightSurfacesCulled++;
}
return dlightBits;
@ -238,7 +243,6 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) {
if ( surf->cullinfo.type & CULLINFO_PLANE )
{
int i;
for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) {
if ( ! ( pshadowBits & ( 1 << i ) ) ) {
continue;
@ -554,7 +558,7 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits,
}
// add merged and unmerged surfaces
if (tr.world->viewSurfaces)
if (tr.world->viewSurfaces && !r_nocurves->integer)
view = tr.world->viewSurfaces + node->firstmarksurface;
else
view = tr.world->marksurfaces + node->firstmarksurface;

View file

@ -820,7 +820,7 @@ void GLimp_EndFrame( void )
// SDL_WM_ToggleFullScreen didn't work, so do it the slow way
if( !sdlToggled )
ri.Cmd_ExecuteText(EXEC_APPEND, "vid_restart");
ri.Cmd_ExecuteText(EXEC_APPEND, "vid_restart\n");
ri.IN_Restart( );
}

View file

@ -790,15 +790,15 @@ static void IN_ProcessEvents( void )
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
{
unsigned char b;
int b;
switch( e.button.button )
{
case 1: b = K_MOUSE1; break;
case 2: b = K_MOUSE3; break;
case 3: b = K_MOUSE2; break;
case 4: b = K_MOUSE4; break;
case 5: b = K_MOUSE5; break;
default: b = K_AUX1 + ( e.button.button - 8 ) % 16; break;
case SDL_BUTTON_LEFT: b = K_MOUSE1; break;
case SDL_BUTTON_MIDDLE: b = K_MOUSE3; break;
case SDL_BUTTON_RIGHT: b = K_MOUSE2; break;
case SDL_BUTTON_X1: b = K_MOUSE4; break;
case SDL_BUTTON_X2: b = K_MOUSE5; break;
default: b = K_AUX1 + ( e.button.button - SDL_BUTTON_X2 + 1 ) % 16; break;
}
Com_QueueEvent( 0, SE_KEY, b,
( e.type == SDL_MOUSEBUTTONDOWN ? qtrue : qfalse ), 0, NULL );
@ -885,7 +885,7 @@ void IN_Frame( void )
if( ( vidRestartTime != 0 ) && ( vidRestartTime < Sys_Milliseconds( ) ) )
{
vidRestartTime = 0;
Cbuf_AddText( "vid_restart" );
Cbuf_AddText( "vid_restart\n" );
}
}

View file

@ -78,7 +78,6 @@ typedef struct {
int snapshotCounter; // incremented for each snapshot built
int timeResidual; // <= 1000 / sv_frame->value
int nextFrameTime; // when time > nextFrameTime, process world
struct cmodel_s *models[MAX_MODELS];
char *configstrings[MAX_CONFIGSTRINGS];
svEntity_t svEntities[MAX_GENTITIES];
@ -308,6 +307,28 @@ extern cvar_t *sv_voip;
//
// sv_main.c
//
typedef struct leakyBucket_s leakyBucket_t;
struct leakyBucket_s {
netadrtype_t type;
union {
byte _4[4];
byte _6[16];
} ipv;
int lastTime;
signed char burst;
long hash;
leakyBucket_t *prev, *next;
};
extern leakyBucket_t outboundLeakyBucket;
qboolean SVC_RateLimit( leakyBucket_t *bucket, int burst, int period );
qboolean SVC_RateLimitAddress( netadr_t from, int burst, int period );
void SV_FinalMessage (char *message);
void QDECL SV_SendServerCommand( client_t *cl, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));

View file

@ -67,6 +67,20 @@ void SV_GetChallenge(netadr_t from)
return;
}
// Prevent using getchallenge as an amplifier
if ( SVC_RateLimitAddress( from, 10, 1000 ) ) {
Com_DPrintf( "SV_GetChallenge: rate limit from %s exceeded, dropping request\n",
NET_AdrToString( from ) );
return;
}
// Allow getchallenge to be DoSed relatively easily, but prevent
// excess outbound bandwidth usage when being flooded inbound
if ( SVC_RateLimit( &outboundLeakyBucket, 10, 100 ) ) {
Com_DPrintf( "SV_GetChallenge: rate limit exceeded, dropping request\n" );
return;
}
gameName = Cmd_Argv(2);
#ifdef LEGACY_PROTOCOL

View file

@ -252,6 +252,9 @@ void SV_MasterHeartbeat(const char *message)
if ( svs.time < svs.nextHeartbeatTime )
return;
if ( !Q_stricmp( com_gamename->string, LEGACY_MASTER_GAMENAME ) )
message = LEGACY_HEARTBEAT_FOR_MASTER;
svs.nextHeartbeatTime = svs.time + HEARTBEAT_MSEC;
// send to group masters
@ -354,30 +357,13 @@ CONNECTIONLESS COMMANDS
==============================================================================
*/
typedef struct leakyBucket_s leakyBucket_t;
struct leakyBucket_s {
netadrtype_t type;
union {
byte _4[4];
byte _6[16];
} ipv;
int lastTime;
signed char burst;
long hash;
leakyBucket_t *prev, *next;
};
// This is deliberately quite large to make it more of an effort to DoS
#define MAX_BUCKETS 16384
#define MAX_HASHES 1024
static leakyBucket_t buckets[ MAX_BUCKETS ];
static leakyBucket_t *bucketHashes[ MAX_HASHES ];
static leakyBucket_t outboundLeakyBucket;
leakyBucket_t outboundLeakyBucket;
/*
================
@ -494,7 +480,7 @@ static leakyBucket_t *SVC_BucketForAddress( netadr_t address, int burst, int per
SVC_RateLimit
================
*/
static qboolean SVC_RateLimit( leakyBucket_t *bucket, int burst, int period ) {
qboolean SVC_RateLimit( leakyBucket_t *bucket, int burst, int period ) {
if ( bucket != NULL ) {
int now = Sys_Milliseconds();
int interval = now - bucket->lastTime;
@ -526,7 +512,7 @@ SVC_RateLimitAddress
Rate limit for a particular address
================
*/
static qboolean SVC_RateLimitAddress( netadr_t from, int burst, int period ) {
qboolean SVC_RateLimitAddress( netadr_t from, int burst, int period ) {
leakyBucket_t *bucket = SVC_BucketForAddress( from, burst, period );
return SVC_RateLimit( bucket, burst, period );

View file

@ -257,7 +257,6 @@ void SV_LinkEntity( sharedEntity_t *gEnt ) {
if ( gEnt->r.bmodel && (angles[0] || angles[1] || angles[2]) ) {
// expand for rotation
float max;
int i;
max = RadiusFromBounds( gEnt->r.mins, gEnt->r.maxs );
for (i=0 ; i<3 ; i++) {

View file

@ -37,6 +37,7 @@ static CONSOLE_CURSOR_INFO qconsole_orig_cursorinfo;
// cmd history
static char qconsole_history[ QCONSOLE_HISTORY ][ MAX_EDIT_LINE ];
static int qconsole_history_pos = -1;
static int qconsole_history_lines = 0;
static int qconsole_history_oldest = 0;
// current edit buffer
@ -107,6 +108,9 @@ static void CON_HistAdd( void )
Q_strncpyz( qconsole_history[ qconsole_history_oldest ], qconsole_line,
sizeof( qconsole_history[ qconsole_history_oldest ] ) );
if( qconsole_history_lines < QCONSOLE_HISTORY )
qconsole_history_lines++;
if( qconsole_history_oldest >= QCONSOLE_HISTORY - 1 )
qconsole_history_oldest = 0;
else
@ -128,7 +132,7 @@ static void CON_HistPrev( void )
( QCONSOLE_HISTORY - 1 ) : ( qconsole_history_pos - 1 );
// don' t allow looping through history
if( pos == qconsole_history_oldest )
if( pos == qconsole_history_oldest || pos >= qconsole_history_lines )
return;
qconsole_history_pos = pos;
@ -146,12 +150,17 @@ static void CON_HistNext( void )
{
int pos;
// don' t allow looping through history
if( qconsole_history_pos == qconsole_history_oldest )
return;
pos = ( qconsole_history_pos >= QCONSOLE_HISTORY - 1 ) ?
0 : ( qconsole_history_pos + 1 );
// clear the edit buffer if they try to advance to a future command
if( pos == qconsole_history_oldest )
{
qconsole_history_pos = pos;
qconsole_line[ 0 ] = '\0';
qconsole_linelen = 0;
return;

View file

@ -123,7 +123,7 @@ qboolean Sys_RandomBytes( byte *string, int len )
if( !fp )
return qfalse;
if( !fread( string, sizeof( byte ), len, fp ) )
if( fread( string, sizeof( byte ), len, fp ) != len )
{
fclose( fp );
return qfalse;

View file

@ -250,7 +250,6 @@ static void hashtable_init (hashtable_t *H, int buckets)
{
H->buckets = buckets;
H->table = calloc(H->buckets, sizeof(*(H->table)));
return;
}
static hashtable_t *hashtable_new (int buckets)
@ -285,7 +284,6 @@ static void hashtable_add (hashtable_t *H, int hashvalue, void *datum)
}
hc->data = datum;
hc->next = 0;
return;
}
static hashchain_t *hashtable_get (hashtable_t *H, int hashvalue)

View file

@ -250,7 +250,6 @@ control(Tokenrow *trp)
break;
}
setempty(trp);
return;
}
void *

View file

@ -108,7 +108,6 @@ doinclude(Tokenrow *trp)
return;
syntax:
error(ERROR, "Syntax error in #include");
return;
}
/*

View file

@ -218,7 +218,6 @@ expand(Tokenrow *trp, Nlist *np)
insertrow(trp, ntokc, &ntr);
trp->tp -= rowlen(&ntr);
dofree(ntr.bp);
return;
}
/*

View file

@ -118,7 +118,7 @@ static void UI_StartServerRefresh(qboolean full);
static void UI_StopServerRefresh( void );
static void UI_DoServerRefresh( void );
static void UI_FeederSelection(float feederID, int index);
static void UI_BuildServerDisplayList(qboolean force);
static void UI_BuildServerDisplayList(int force);
static void UI_BuildServerStatus(qboolean force);
static void UI_BuildFindPlayerList(qboolean force);
static int QDECL UI_ServersQsortCompare( const void *arg1, const void *arg2 );
@ -3762,7 +3762,7 @@ static void UI_BinaryServerInsertion(int num) {
UI_BuildServerDisplayList
==================
*/
static void UI_BuildServerDisplayList(qboolean force) {
static void UI_BuildServerDisplayList(int force) {
int i, count, clients, maxClients, ping, game, len, visible;
char info[MAX_STRING_CHARS];
// qboolean startRefresh = qtrue; TTimo: unused

View file

@ -714,10 +714,10 @@ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int ti
dp_realtime = time;
if ( pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer ) {
if ( pi->pendingWeapon != WP_NUM_WEAPONS && dp_realtime > pi->weaponTimer ) {
pi->weapon = pi->pendingWeapon;
pi->lastWeapon = pi->pendingWeapon;
pi->pendingWeapon = -1;
pi->pendingWeapon = WP_NUM_WEAPONS;
pi->weaponTimer = 0;
if( pi->currentWeapon != pi->weapon ) {
trap_S_StartLocalSound( weaponChangeSound, CHAN_LOCAL );
@ -1254,7 +1254,7 @@ void UI_PlayerInfo_SetModel( playerInfo_t *pi, const char *model, const char *he
pi->weapon = WP_MACHINEGUN;
pi->currentWeapon = pi->weapon;
pi->lastWeapon = pi->weapon;
pi->pendingWeapon = -1;
pi->pendingWeapon = WP_NUM_WEAPONS;
pi->weaponTimer = 0;
pi->chat = qfalse;
pi->newModel = qtrue;
@ -1293,11 +1293,11 @@ void UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_
pi->torso.yawAngle = viewAngles[YAW];
pi->torso.yawing = qfalse;
if ( weaponNumber != -1 ) {
if ( weaponNumber != WP_NUM_WEAPONS ) {
pi->weapon = weaponNumber;
pi->currentWeapon = weaponNumber;
pi->lastWeapon = weaponNumber;
pi->pendingWeapon = -1;
pi->pendingWeapon = WP_NUM_WEAPONS;
pi->weaponTimer = 0;
UI_PlayerInfo_SetWeapon( pi, pi->weapon );
}
@ -1306,8 +1306,8 @@ void UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_
}
// weapon
if ( weaponNumber == -1 ) {
pi->pendingWeapon = -1;
if ( weaponNumber == WP_NUM_WEAPONS ) {
pi->pendingWeapon = WP_NUM_WEAPONS;
pi->weaponTimer = 0;
}
else if ( weaponNumber != WP_NONE ) {

View file

@ -298,7 +298,6 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
257 + (end - out) : 257 - (out - end));
state->hold = hold;
state->bits = bits;
return;
}
/*