Skip to content

Commit

Permalink
Merge branch 'ioq3': Bugfixes since January 2015
Browse files Browse the repository at this point in the history
  • Loading branch information
aufau committed Jan 4, 2018
2 parents 6932f49 + fd3eeee commit 750c050
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 89 deletions.
1 change: 1 addition & 0 deletions src/botlib/be_aas_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,4 +757,5 @@ void AAS_FloodAreas(vec3_t origin)
areanum = AAS_PointAreaNum(origin);
cluster = AAS_AreaCluster(areanum);
AAS_FloodAreas_r(areanum, cluster, done);
FreeMemory(done);
}
4 changes: 2 additions & 2 deletions src/botlib/be_aas_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ void AAS_SwapAASData(void)
aasworld.bboxes[i].flags = LittleLong(aasworld.bboxes[i].flags);
for (j = 0; j < 3; j++)
{
aasworld.bboxes[i].mins[j] = LittleLong(aasworld.bboxes[i].mins[j]);
aasworld.bboxes[i].maxs[j] = LittleLong(aasworld.bboxes[i].maxs[j]);
aasworld.bboxes[i].mins[j] = LittleFloat(aasworld.bboxes[i].mins[j]);
aasworld.bboxes[i].maxs[j] = LittleFloat(aasworld.bboxes[i].maxs[j]);
} //end for
} //end for
//vertexes
Expand Down
2 changes: 1 addition & 1 deletion src/botlib/be_aas_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ int AAS_ClientMovementPrediction(struct aas_clientmove_s *move,
//if on the ground or swimming
if (onground || swimming)
{
friction = swimming ? phys_friction : phys_waterfriction;
friction = swimming ? phys_waterfriction : phys_friction;
//apply friction
VectorScale(frame_test_vel, 1/frametime, frame_test_vel);
AAS_ApplyFriction(frame_test_vel, friction, phys_stopspeed, frametime);
Expand Down
1 change: 1 addition & 0 deletions src/client/cl_cin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,7 @@ e_status CIN_RunCinematic(int handle)
RoQReset();
} else {
RoQShutdown();
return FMV_EOF;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/client/cl_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,12 @@ void CL_CreateNewCommands( void ) {

frame_msec = com_frameTime - old_com_frameTime;

// if running over 1000fps, act as if each frame is 1ms
// prevents division by zero
if ( frame_msec < 1 ) {
frame_msec = 1;
}

// if running less than 5fps, truncate the extra time to prevent
// unexpected moves after a hitch
if ( frame_msec > 200 ) {
Expand Down
18 changes: 9 additions & 9 deletions src/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,15 @@ qboolean CL_ServerVersionIs103 (const char *versionstr) {

void CL_PlayDemo_f( void ) {
char name[MAX_OSPATH]/*, extension[32]*/;
char *arg;
char arg[MAX_OSPATH];

if (Cmd_Argc() != 2) {
Com_Printf ("demo <demoname>\n");
return;
}

Q_strncpyz(arg, Cmd_Argv(1), sizeof(arg));

// make sure a local server is killed
Cvar_Set( "sv_killserver", "1" );
SV_Frame( 0 );
Expand All @@ -579,8 +581,6 @@ void CL_PlayDemo_f( void ) {
*/

// open the demo file
arg = Cmd_Argv(1);

if ( !Q_stricmp( arg + strlen(arg) - strlen(".dm_15"), ".dm_15" ) || !Q_stricmp( arg + strlen(arg) - strlen(".dm_16"), ".dm_16" ) )
{ // Load "dm_15" and "dm_16" demos.
Com_sprintf (name, sizeof(name), "demos/%s", arg);
Expand Down Expand Up @@ -622,15 +622,15 @@ void CL_PlayDemo_f( void ) {
}
}
}
Q_strncpyz( clc.demoName, Cmd_Argv(1), sizeof( clc.demoName ) );
Q_strncpyz( clc.demoName, arg, sizeof( clc.demoName ) );

Con_Close();

cls.state = CA_CONNECTED;
clc.demoplaying = qtrue;
com_demoplaying = qtrue;

Q_strncpyz( cls.servername, Cmd_Argv(1), sizeof( cls.servername ) );
Q_strncpyz( cls.servername, arg, sizeof( cls.servername ) );

// Set the protocol according to the the demo-file.
if ( !Q_stricmp( name + strlen(name) - strlen(".dm_15"), ".dm_15" ) ) {
Expand Down Expand Up @@ -1056,7 +1056,7 @@ CL_Connect_f
================
*/
void CL_Connect_f( void ) {
char *server;
char server[MAX_OSPATH];

if ( Cmd_Argc() != 2 ) {
Com_Printf( "usage: connect [server]\n");
Expand All @@ -1073,7 +1073,7 @@ void CL_Connect_f( void ) {
// clear any previous "server full" type messages
clc.serverMessage[0] = 0;

server = Cmd_Argv (1);
Q_strncpyz(server, Cmd_Argv(1), sizeof(server));

if ( com_sv_running->integer && !strcmp( server, "localhost" ) ) {
// if running a local server, kill it
Expand Down Expand Up @@ -1749,7 +1749,7 @@ Resend a connect message if the last one has timed out
void CL_CheckForResend( void ) {
int port;
char info[MAX_INFO_STRING];
char data[MAX_INFO_STRING];
char data[MAX_INFO_STRING + 10];

// don't send anything if playing back a demo
if ( clc.demoplaying ) {
Expand Down Expand Up @@ -1794,7 +1794,7 @@ void CL_CheckForResend( void ) {
Info_SetValueForKey( info, "protocol", va("%i", MV_GetCurrentProtocol() ) );
Info_SetValueForKey( info, "qport", va("%i", port ) );
Info_SetValueForKey( info, "challenge", va("%i", clc.challenge ) );
sprintf(data, "connect \"%s\"", info );
Com_sprintf(data, sizeof(data), "connect \"%s\"", info );
NET_OutOfBandData( NS_CLIENT, clc.serverAddress, (unsigned char *)data, (int)strlen(data) );

// the most current userinfo has been sent, so watch for any
Expand Down
16 changes: 13 additions & 3 deletions src/qcommon/cm_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static int numPlanes;
static patchPlane_t planes[MAX_PATCH_PLANES];

static int numFacets;
static facet_t facets[MAX_PATCH_PLANES]; //maybe MAX_FACETS ??
static facet_t facets[MAX_FACETS];

#define NORMAL_EPSILON 0.0001f
#define DIST_EPSILON 0.02f
Expand Down Expand Up @@ -843,7 +843,10 @@ void CM_AddFacetBevels( facet_t *facet ) {
}

if ( i == facet->numBorders ) {
if (facet->numBorders > 4 + 6 + 16) Com_Printf("ERROR: too many bevels\n");
if (facet->numBorders > 4 + 6 + 16) {
Com_Printf("ERROR: too many bevels\n");
continue;
}
facet->borderPlanes[facet->numBorders] = CM_FindPlane2(plane, &flipped);
facet->borderNoAdjust[facet->numBorders] = qfalse;
facet->borderInward[facet->numBorders] = flipped;
Expand Down Expand Up @@ -905,7 +908,10 @@ void CM_AddFacetBevels( facet_t *facet ) {
}

if ( i == facet->numBorders ) {
if (facet->numBorders > 4 + 6 + 16) Com_Printf("ERROR: too many bevels\n");
if (facet->numBorders > 4 + 6 + 16) {
Com_Printf("ERROR: too many bevels\n");
continue;
}
facet->borderPlanes[facet->numBorders] = CM_FindPlane2(plane, &flipped);

for ( k = 0 ; k < facet->numBorders ; k++ ) {
Expand Down Expand Up @@ -943,6 +949,10 @@ void CM_AddFacetBevels( facet_t *facet ) {

#ifndef BSPC
//add opposite plane
if (facet->numBorders > 4 + 6 + 16) {
Com_Printf("ERROR: too many bevels\n");
return;
}
facet->borderPlanes[facet->numBorders] = facet->surfacePlane;
facet->borderNoAdjust[facet->numBorders] = qfalse;
facet->borderInward[facet->numBorders] = qtrue;
Expand Down
12 changes: 9 additions & 3 deletions src/qcommon/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,12 @@ Cmd_CompleteArgument
*/
void Cmd_CompleteArgument( const char *command, char *args, int argNum ) {
for ( cmd_function_t *cmd=cmd_functions; cmd; cmd=cmd->next ) {
if ( !Q_stricmp( command, cmd->name ) && cmd->complete )
cmd->complete( args, argNum );
if ( !Q_stricmp( command, cmd->name ) ) {
if ( cmd->complete ) {
cmd->complete( args, argNum );
}
return;
}
}
}

Expand All @@ -785,8 +789,10 @@ Cmd_SetCommandCompletionFunc
*/
void Cmd_SetCommandCompletionFunc( const char *command, completionFunc_t complete ) {
for ( cmd_function_t *cmd=cmd_functions; cmd; cmd=cmd->next ) {
if ( !Q_stricmp( command, cmd->name ) )
if ( !Q_stricmp( command, cmd->name ) ) {
cmd->complete = complete;
return;
}
}
}

4 changes: 2 additions & 2 deletions src/qcommon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void Com_StartupVariable( const char *match ) {

s = Cmd_Argv(1);
if ( !match || !strcmp( s, match ) ) {
Cvar_Set( s, Cmd_Argv(2) );
Cvar_Set( s, Cmd_ArgsFrom(2) );
cv = Cvar_Get( s, "", 0 );
cv->flags |= CVAR_USER_CREATED;
// com_consoleLines[i] = 0;
Expand Down Expand Up @@ -519,7 +519,7 @@ qboolean Com_AddStartupCommands( void ) {
}

// set commands won't override menu startup
if ( Q_stricmpn( com_consoleLines[i], "set", 3 ) ) {
if ( Q_stricmpn( com_consoleLines[i], "set ", 4 ) ) {
added = qtrue;
}
Cbuf_AddText( com_consoleLines[i] );
Expand Down
19 changes: 15 additions & 4 deletions src/renderer/tr_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,20 @@ void R_SyncRenderThread( void ) {

/*
============
R_GetCommandBuffer
R_GetCommandBufferReserved
make sure there is enough command space, waiting on the
render thread if needed.
============
*/
void *R_GetCommandBuffer( unsigned int bytes ) {
void *R_GetCommandBufferReserved( unsigned int bytes, int reservedBytes ) {
renderCommandList_t *cmdList;

cmdList = &backEndData->commands;
bytes = PAD( bytes, sizeof( void * ) );

// always leave room for the end of list command
if ( cmdList->used + bytes + sizeof( int ) > MAX_RENDER_COMMANDS ) {
if ( cmdList->used + bytes + sizeof( int ) + reservedBytes > MAX_RENDER_COMMANDS ) {
if ( bytes > MAX_RENDER_COMMANDS - sizeof( int ) ) {
ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes );
}
Expand All @@ -138,6 +138,17 @@ void *R_GetCommandBuffer( unsigned int bytes ) {
return cmdList->cmds + cmdList->used - bytes;
}

/*
============
R_GetCommandBuffer
returns NULL if there is not enough space for important commands
============
*/
void *R_GetCommandBuffer( unsigned int bytes ) {
return R_GetCommandBufferReserved( bytes, PAD( sizeof ( swapBuffersCommand_t ), sizeof( void * ) ) );
}


/*
=============
Expand Down Expand Up @@ -443,7 +454,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) {
if ( !tr.registered ) {
return;
}
cmd = (swapBuffersCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) );
cmd = (swapBuffersCommand_t *)R_GetCommandBufferReserved( sizeof( *cmd ), 0 );
if (!cmd) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
// If not a .skin file, load as a single shader
if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) {
skin->numSurfaces = 1;
skin->surfaces[0] = (skinSurface_t *)ri.Hunk_Alloc( sizeof(skin->surfaces[0]), h_low );
skin->surfaces[0] = (skinSurface_t *)ri.Hunk_Alloc( sizeof(*skin->surfaces[0]), h_low );
skin->surfaces[0]->shader = R_FindShader( name, lightmapsNone, stylesDefault, qtrue );
return hSkin;
}
Expand Down Expand Up @@ -3157,7 +3157,7 @@ void R_InitSkins( void ) {
skin = tr.skins[0] = (struct skin_s *)ri.Hunk_Alloc( sizeof( skin_t ), h_low );
Q_strncpyz( skin->name, "<default skin>", sizeof( skin->name ) );
skin->numSurfaces = 1;
skin->surfaces[0] = (skinSurface_t *)ri.Hunk_Alloc( sizeof( *skin->surfaces ), h_low );
skin->surfaces[0] = (skinSurface_t *)ri.Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low );
skin->surfaces[0]->shader = tr.defaultShader;
}

Expand Down
6 changes: 3 additions & 3 deletions src/renderer/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static void GLimp_InitExtensions(void) {

// GL_EXT_texture_env_add
glConfig.textureEnvAddAvailable = qfalse;
if (GL_CheckForExtension("EXT_texture_env_add")) {
if (GL_CheckForExtension("GL_EXT_texture_env_add")) {
if (r_ext_texture_env_add->integer) {
glConfig.textureEnvAddAvailable = qtrue;
Com_Printf("...using GL_EXT_texture_env_add\n");
Expand All @@ -393,7 +393,7 @@ static void GLimp_InitExtensions(void) {

// GL_EXT_texture_filter_anisotropic
glConfig.textureFilterAnisotropicMax = 1.0f;
if ( GL_CheckForExtension( "EXT_texture_filter_anisotropic" ) )
if ( GL_CheckForExtension( "GL_EXT_texture_filter_anisotropic" ) )
{
qglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.textureFilterAnisotropicMax );
Com_Printf ("...GL_EXT_texture_filter_anisotropic available\n" );
Expand Down Expand Up @@ -610,7 +610,7 @@ static void GLimp_InitExtensions(void) {

// GL_EXT_texture_lod_bias
glConfig.textureLODBiasAvailable = qfalse;
if (GL_CheckForExtension("EXT_texture_lod_bias")) {
if (GL_CheckForExtension("GL_EXT_texture_lod_bias")) {
glConfig.textureLODBiasAvailable = qtrue;
Com_Printf ("...GL_EXT_texture_lod_bias available\n" );
} else {
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/tr_light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,20 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
gridPos = startGridPos;
for ( j = 0 ; j < 3 ; j++ ) {
if ( i & (1<<j) ) {
if ( pos[j] + 1 > tr.world->lightGridBounds[j] - 1 ) {
break; // ignore values outside lightgrid
}
factor *= frac[j];
gridPos += gridStep[j];
} else {
factor *= (1.0f - frac[j]);
}
}

if (j != 3)
{
continue;
}
if (gridPos >= tr.world->lightGridArray + tr.world->numGridArrayElements)
{//we've gone off the array somehow
continue;
Expand Down
18 changes: 10 additions & 8 deletions src/renderer/tr_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,13 +1118,6 @@ void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) {
return;
}

// if we overflowed MAX_DRAWSURFS, the drawsurfs
// wrapped around in the buffer and we will be missing
// the first surfaces, not the last ones
if ( numDrawSurfs > MAX_DRAWSURFS ) {
numDrawSurfs = MAX_DRAWSURFS;
}

// sort the drawsurfs by sort type, then orientation, then shader
R_RadixSort(drawSurfs, numDrawSurfs);

Expand Down Expand Up @@ -1356,6 +1349,7 @@ or a mirror / remote location
*/
void R_RenderView (viewParms_t *parms) {
int firstDrawSurf;
int numDrawSurfs;

if ( parms->viewportWidth <= 0 || parms->viewportHeight <= 0 ) {
return;
Expand All @@ -1378,7 +1372,15 @@ void R_RenderView (viewParms_t *parms) {

R_GenerateDrawSurfs();

R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf );
// if we overflowed MAX_DRAWSURFS, the drawsurfs
// wrapped around in the buffer and we will be missing
// the first surfaces, not the last ones
numDrawSurfs = tr.refdef.numDrawSurfs;
if ( numDrawSurfs > MAX_DRAWSURFS ) {
numDrawSurfs = MAX_DRAWSURFS;
}

R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, numDrawSurfs - firstDrawSurf );

// draw main system development information (surface outlines, etc)
R_DebugGraphics();
Expand Down
1 change: 1 addition & 0 deletions src/renderer/tr_sky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ void RB_StageIteratorSky( void ) {

qglPushMatrix ();
GL_State( 0 );
GL_Cull( CT_FRONT_SIDED );
qglTranslatef (backEnd.viewParms.ori.origin[0], backEnd.viewParms.ori.origin[1], backEnd.viewParms.ori.origin[2]);

DrawSkyBox( tess.shader );
Expand Down
Loading

0 comments on commit 750c050

Please sign in to comment.