Skip to content

Commit

Permalink
Merge branch 'master' into netsplit
Browse files Browse the repository at this point in the history
  • Loading branch information
mittorn committed Feb 8, 2019
2 parents a169f93 + f7c60ea commit 2b1ed2b
Show file tree
Hide file tree
Showing 30 changed files with 3,153 additions and 360 deletions.
9 changes: 8 additions & 1 deletion engine/client/cl_custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ qboolean CL_CheckFile( sizebuf_t *msg, resource_t *pResource )
return true;
}

if( cl.downloadUrl[0] )
{
HTTP_AddDownload( filepath, pResource->nDownloadSize, true );
host.downloadcount++;
return false;
}

MSG_BeginClientCmd( msg, clc_stringcmd );
MSG_WriteString( msg, va( "dlfile %s", filepath ));
host.downloadcount++;
Expand Down Expand Up @@ -140,4 +147,4 @@ void CL_ClearResourceLists( void )
{
CL_ClearResourceList( &cl.resourcesneeded );
CL_ClearResourceList( &cl.resourcesonhand );
}
}
15 changes: 13 additions & 2 deletions engine/client/cl_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,15 @@ void CL_DrawHUD( int state )
}
}

static void CL_ClearUserMessage( char *pszName, int svc_num )
{
int i;

for( i = 0; i < MAX_USER_MESSAGES && clgame.msg[i].name[0]; i++ )
if( ( clgame.msg[i].number == svc_num ) && Q_strcmp( clgame.msg[i].name, pszName ) )
clgame.msg[i].number = 0;
}

void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
{
int i;
Expand All @@ -1067,6 +1076,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
{
clgame.msg[i].number = svc_num;
clgame.msg[i].size = iSize;
CL_ClearUserMessage( pszName, svc_num );
return;
}
}
Expand All @@ -1081,6 +1091,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
Q_strncpy( clgame.msg[i].name, pszName, sizeof( clgame.msg[i].name ));
clgame.msg[i].number = svc_num;
clgame.msg[i].size = iSize;
CL_ClearUserMessage( pszName, svc_num );
}

void CL_FreeEntity( cl_entity_t *pEdict )
Expand Down Expand Up @@ -1215,7 +1226,7 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite,
}
else
{
Con_Reportf( S_ERROR "%s couldn't load\n", szSpriteName );
Con_Reportf( S_ERROR "Could not load HUD sprite %s\n", szSpriteName );
Mod_UnloadSpriteModel( m_pSprite );
return false;
}
Expand Down Expand Up @@ -2341,7 +2352,7 @@ int CL_FindModelIndex( const char *m )
if( lasttimewarn < host.realtime )
{
// tell user about problem (but don't spam console)
Con_Printf( S_ERROR "%s not precached\n", filepath );
Con_Printf( S_ERROR "Could not find index for model %s: not precached\n", filepath );
lasttimewarn = host.realtime + 1.0f;
}

Expand Down
2 changes: 1 addition & 1 deletion engine/client/cl_gameui.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, int ima

if( !szPicName || !*szPicName )
{
Con_Reportf( S_ERROR "CL_LoadImage: bad name!\n" );
Con_Reportf( S_ERROR "CL_LoadImage: refusing to load image with empty name\n" );
return 0;
}

Expand Down
31 changes: 29 additions & 2 deletions engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,7 @@ void CL_ClearState( void )
Cvar_SetValue( "scr_download", -1.0f );
Cvar_SetValue( "scr_loading", 0.0f );
host.allow_console = host.allow_console_init;
HTTP_ClearCustomServers();
}

/*
Expand Down Expand Up @@ -1534,6 +1535,7 @@ void CL_LocalServers_f( void )

Con_Printf( "Scanning for servers on the local network area...\n" );
NET_Config( true ); // allow remote
cls.legacyservercount = 0;

// send a broadcast packet
adr.type = NA_BROADCAST;
Expand Down Expand Up @@ -1561,6 +1563,7 @@ void CL_InternetServers_f( void )
Info_SetValueForKey( info, "gamedir", GI->gamefolder, remaining );
Info_SetValueForKey( info, "clver", XASH_VERSION, remaining ); // let master know about client version
// Info_SetValueForKey( info, "nat", cl_nat->string, remaining );
cls.legacyservercount = 0;

cls.internetservers_wait = NET_SendToMasters( NS_CLIENT, sizeof( MS_SCAN_REQUEST ) + Q_strlen( info ), fullquery );
cls.internetservers_pending = true;
Expand Down Expand Up @@ -1683,13 +1686,16 @@ void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
{
static char infostring[MAX_INFO_STRING+8];
char *s = MSG_ReadString( msg );
int i;

CL_FixupColorStringsForInfoString( s, infostring );

if( Q_strstr( infostring, "wrong version" ) )
{
Netchan_OutOfBandPrint( NS_CLIENT, from, "info %i", PROTOCOL_LEGACY_VERSION );
Con_Printf( "^1Server^7: %s, Info: %s\n", NET_AdrToString( from ), infostring );
if( cls.legacyservercount < MAX_LEGACY_SERVERS )
cls.legacyservers[cls.legacyservercount++] = from;
return;
}

Expand All @@ -1699,6 +1705,16 @@ void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
return; // unsupported proto
}

for( i = 0; i < cls.legacyservercount; i++ )
{
if( NET_CompareAdr( cls.legacyservers[i], from ) )
{
Info_SetValueForKey( infostring, "legacy", "1", sizeof( infostring ) );
Con_Print("Legacy: ");
break;
}
}

// more info about servers
Con_Printf( "^2Server^7: %s, Game: %s\n", NET_AdrToString( from ), Info_ValueForKey( infostring, "gamedir" ));

Expand Down Expand Up @@ -2309,6 +2325,17 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename )
{
Con_Printf( S_ERROR "server failed to transmit file '%s'\n", CL_CleanFileName( filename ));
}
if( cls.legacymode )
{
if( host.downloadcount > 0 )
host.downloadcount--;
if( !host.downloadcount )
{
MSG_WriteByte( &cls.netchan.message, clc_stringcmd );
MSG_WriteString( &cls.netchan.message, "continueloading" );
}
return;
}

pfilename = filename;

Expand Down Expand Up @@ -2358,7 +2385,7 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename )
}
else
{
Con_Printf( "Downloaded %i bytes for purported %i byte file, ignoring download\n",
Con_Printf( "Downloaded %i bytes for purported %i byte file, ignoring download\n",
cls.netchan.tempbuffersize, p->nDownloadSize );
}

Expand Down Expand Up @@ -2553,7 +2580,7 @@ qboolean CL_PrecacheResources( void )
{
if( FBitSet( pRes->ucFlags, RES_WASMISSING ))
{
Con_Printf( S_ERROR "%s%s couldn't load\n", DEFAULT_SOUNDPATH, pRes->szFileName );
Con_Printf( S_ERROR "Could not load sound %s%s\n", DEFAULT_SOUNDPATH, pRes->szFileName );
cl.sound_precache[pRes->nIndex][0] = 0;
cl.sound_index[pRes->nIndex] = 0;
}
Expand Down
94 changes: 78 additions & 16 deletions engine/client/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,11 @@ void CL_BatchResourceRequest( qboolean initialize )

if( cls.state != ca_disconnected )
{
if( !MSG_GetNumBytesWritten( &msg ) && CL_PrecacheResources( ))
if( !cl.downloadUrl[0] && !MSG_GetNumBytesWritten( &msg ) && CL_PrecacheResources( ))
{
CL_RegisterResources( &msg );
}
if( cl.downloadUrl[0] && host.downloadcount == 0 && CL_PrecacheResources( ) )
{
CL_RegisterResources( &msg );
}
Expand Down Expand Up @@ -1702,16 +1706,23 @@ CL_ParseResLocation
*/
void CL_ParseResLocation( sizebuf_t *msg )
{
const char *url = MSG_ReadString( msg );
const char *data = MSG_ReadString( msg );
char token[256];

if( url && ( !Q_strnicmp( "http://", url, 7 ) || !Q_strnicmp( "https://", url, 8 )))
if( Q_strlen( data ) > 256 )
{
const char *lastSlash = Q_strrchr( url, '/' );
Con_Printf( S_ERROR "Resource location too long!\n" );
return;
}

if( lastSlash && lastSlash[1] == '\0' )
Q_strncpy( cl.downloadUrl, url, sizeof( cl.downloadUrl ));
else Q_snprintf( cl.downloadUrl, sizeof( cl.downloadUrl ), "%s/", url );
Con_Reportf( "Using %s as primary download location\n", cl.downloadUrl );
while( ( data = COM_ParseFile( data, token ) ) )
{
Con_Reportf( "Adding %s as download location\n", token );

if( !cl.downloadUrl[0] )
Q_strncpy( cl.downloadUrl, token, sizeof( token ) );

HTTP_AddCustomServer( token );
}
}

Expand Down Expand Up @@ -2716,6 +2727,61 @@ void CL_LegacyUpdateUserinfo( sizebuf_t *msg )
else memset( player, 0, sizeof( *player ));
}

/*
==============
CL_ParseResourceList
==============
*/
void CL_LegacyParseResourceList( sizebuf_t *msg )
{
int i = 0;

static struct
{
int rescount;
int restype[MAX_RESOURCES];
char resnames[MAX_RESOURCES][CS_SIZE];
} reslist;
memset( &reslist, 0, sizeof( reslist ));

reslist.rescount = MSG_ReadWord( msg ) - 1;

for( i = 0; i < reslist.rescount; i++ )
{
reslist.restype[i] = MSG_ReadWord( msg );
Q_strncpy( reslist.resnames[i], MSG_ReadString( msg ), CS_SIZE );
}

if( CL_IsPlaybackDemo() )
{
return;
}

host.downloadcount = 0;

for( i = 0; i < reslist.rescount; i++ )
{
const char *path;

if( reslist.restype[i] == t_sound )
path = va( "sound/%s", reslist.resnames[i] );
else path = reslist.resnames[i];

if( FS_FileExists( path, false ))
continue; // already exists

host.downloadcount++;
HTTP_AddDownload( path, -1, true );
}

if( !host.downloadcount )
{
MSG_WriteByte( &cls.netchan.message, clc_stringcmd );
MSG_WriteString( &cls.netchan.message, "continueloading" );
}
}

/*
=====================
CL_ParseLegacyServerMessage
Expand Down Expand Up @@ -2845,13 +2911,9 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
break; // too early
#endif
if( !Q_strcmp(s, "cmd getresourcelist\n") )
Cbuf_AddText("cmd continueloading\n");
else
{
Con_Reportf( "Stufftext: %s", s );
Cbuf_AddText( s );
}

Con_Reportf( "Stufftext: %s", s );
Cbuf_AddText( s );
break;
case svc_setangle:
CL_ParseSetAngle( msg );
Expand Down Expand Up @@ -2981,7 +3043,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
//cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].receivedtime = -2.0;
break;
case svc_resourcelist:
CL_ParseResourceList( msg );
CL_LegacyParseResourceList( msg );
break;
case svc_deltamovevars:
CL_ParseMovevars( msg );
Expand Down
2 changes: 2 additions & 0 deletions engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ typedef struct
qboolean internetservers_pending; // internetservers is waiting for dns request
qboolean legacymode; // one-way 48 protocol compatibility
netadr_t legacyserver;
netadr_t legacyservers[MAX_LEGACY_SERVERS];
int legacyservercount;
int extensions;
} client_static_t;

Expand Down
5 changes: 3 additions & 2 deletions engine/client/gl_decals.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef struct
static float g_DecalClipVerts[MAX_DECALCLIPVERT][VERTEXSIZE];
static float g_DecalClipVerts2[MAX_DECALCLIPVERT][VERTEXSIZE];

static decal_t gDecalPool[MAX_RENDER_DECALS];
decal_t gDecalPool[MAX_RENDER_DECALS];
static int gDecalCount;

void R_ClearDecals( void )
Expand Down Expand Up @@ -570,6 +570,7 @@ static void R_AddDecalToSurface( decal_t *pdecal, msurface_t *surf, decalinfo_t

// alloc clipped poly for decal
R_DecalCreatePoly( decalinfo, pdecal, surf );
R_AddDecalVBO( pdecal, surf );
}

static void R_DecalCreate( decalinfo_t *decalinfo, msurface_t *surf, float x, float y )
Expand Down Expand Up @@ -1282,4 +1283,4 @@ void R_ClearAllDecals( void )
{
clgame.drawFuncs.R_ClearStudioDecals();
}
}
}
6 changes: 6 additions & 0 deletions engine/client/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ void GL_RebuildLightmaps( void );
void GL_InitRandomTable( void );
void GL_BuildLightmaps( void );
void GL_ResetFogColor( void );
void R_GenerateVBO();
void R_ClearVBO();
void R_AddDecalVBO( decal_t *pdecal, msurface_t *surf );

//
// gl_sprite.c
Expand Down Expand Up @@ -523,6 +526,7 @@ enum
GL_EXT_GPU_SHADER4, // shaders only
GL_DEPTH_TEXTURE,
GL_DEBUG_OUTPUT,
GL_ARB_VERTEX_BUFFER_OBJECT_EXT,
GL_EXTCOUNT, // must be last
};

Expand Down Expand Up @@ -678,6 +682,8 @@ extern convar_t *r_lockfrustum;
extern convar_t *r_traceglow;
extern convar_t *r_dynamic;
extern convar_t *r_lightmap;
extern convar_t *r_vbo;
extern convar_t *r_vbo_dlightmode;

extern convar_t *vid_displayfrequency;
extern convar_t *vid_fullscreen;
Expand Down
3 changes: 2 additions & 1 deletion engine/client/gl_rmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,5 @@ void R_NewMap( void )
R_SetupSky( clgame.movevars.skyName );

GL_BuildLightmaps ();
}
R_GenerateVBO();
}

0 comments on commit 2b1ed2b

Please sign in to comment.