From a539384a76672bbf682643fa23f30f58f638573f Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 12 Jun 2018 12:14:56 +0300 Subject: [PATCH] Apply 4143 update --- engine/client/cl_game.c | 4 +++- engine/client/cl_main.c | 7 ++++--- engine/client/cl_pmove.c | 6 +++--- engine/client/cl_scrn.c | 10 +++++----- engine/client/gl_beams.c | 8 ++++---- engine/client/gl_rlight.c | 4 ++-- engine/client/gl_vidnt.c | 2 +- engine/client/s_backend.c | 3 --- engine/common/build.c | 2 +- engine/common/com_strings.h | 4 ++++ engine/common/host.c | 4 ++++ engine/common/host_state.c | 2 +- engine/common/mod_bmodel.c | 35 ++++++++++++++++++++++++++++------- engine/common/mod_dbghulls.c | 1 + engine/common/pm_trace.c | 2 +- engine/server/sv_client.c | 4 ++-- engine/server/sv_cmds.c | 2 +- engine/server/sv_game.c | 13 +++++++++---- engine/server/sv_init.c | 2 +- 19 files changed, 75 insertions(+), 40 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index cda41ad0..1f701166 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -1211,6 +1211,7 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite, } else { + Con_Printf( S_ERROR "%s couldn't load\n", szSpriteName ); Mod_UnloadSpriteModel( m_pSprite ); return false; } @@ -1865,7 +1866,8 @@ int pfnDrawConsoleString( int x, int y, char *string ) { int drawLen; - if( !string || !*string ) return 0; // silent ignore + if( !COM_CheckString( string )) + return 0; // silent ignore Con_SetFont( con_fontsize->value ); clgame.ds.adjust_size = true; diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 0de9f5b6..21901591 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -208,7 +208,7 @@ An svc_signonnum has been received, perform a client side setup void CL_SignonReply( void ) { // g-cont. my favorite message :-) - Con_DPrintf( "CL_SignonReply: %i\n", cls.signon ); + Con_Reportf( "CL_SignonReply: %i\n", cls.signon ); switch( cls.signon ) { @@ -1745,7 +1745,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) Cmd_TokenizeString( args ); c = Cmd_Argv( 0 ); - MsgDev( D_NOTE, "CL_ConnectionlessPacket: %s : %s\n", NET_AdrToString( from ), c ); + Con_Reportf( "CL_ConnectionlessPacket: %s : %s\n", NET_AdrToString( from ), c ); // server connection if( !Q_strcmp( c, "client_connect" )) @@ -2387,7 +2387,7 @@ qboolean CL_PrecacheResources( void ) if( cl.models[pRes->nIndex] == NULL ) { - MsgDev( D_ERROR, "submodel %s not found\n", pRes->szFileName ); + Con_Printf( S_ERROR "submodel %s not found\n", pRes->szFileName ); if( FBitSet( pRes->ucFlags, RES_FATALIFMISSING )) { @@ -2414,6 +2414,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 ); cl.sound_precache[pRes->nIndex][0] = 0; cl.sound_index[pRes->nIndex] = 0; } diff --git a/engine/client/cl_pmove.c b/engine/client/cl_pmove.c index 5dcbdb17..8afa0df2 100644 --- a/engine/client/cl_pmove.c +++ b/engine/client/cl_pmove.c @@ -481,9 +481,6 @@ void CL_AddLinksToPmove( frame_t *frame ) if( VectorIsNull( state->mins ) && VectorIsNull( state->maxs )) continue; - if ( !model->hulls[1].lastclipnode && model->type != mod_studio ) - continue; - if( state->solid == SOLID_NOT && state->skin < CONTENTS_EMPTY ) { if( clgame.pmove->nummoveent >= MAX_MOVEENTS ) @@ -495,6 +492,9 @@ void CL_AddLinksToPmove( frame_t *frame ) } else { + if( !model->hulls[1].lastclipnode && model->type != mod_studio ) + continue; + // reserve slots for all the clients if( clgame.pmove->numphysent >= ( MAX_PHYSENTS - cl.maxclients )) continue; diff --git a/engine/client/cl_scrn.c b/engine/client/cl_scrn.c index 41f9c88e..4f067930 100644 --- a/engine/client/cl_scrn.c +++ b/engine/client/cl_scrn.c @@ -586,8 +586,8 @@ void SCR_InstallParticlePalette( void ) int i; // first check 'palette.lmp' then 'palette.pal' - pic = FS_LoadImage( "gfx/palette.lmp", NULL, 0 ); - if( !pic ) pic = FS_LoadImage( "gfx/palette.pal", NULL, 0 ); + pic = FS_LoadImage( DEFAULT_INTERNAL_PALETTE, NULL, 0 ); + if( !pic ) pic = FS_LoadImage( DEFAULT_EXTERNAL_PALETTE, NULL, 0 ); // NOTE: imagelib required this fakebuffer for loading internal palette if( !pic ) pic = FS_LoadImage( "#valve.pal", (byte *)&i, 768 ); @@ -604,13 +604,13 @@ void SCR_InstallParticlePalette( void ) } else { + // someone deleted internal palette from code... for( i = 0; i < 256; i++ ) { clgame.palette[i].r = i; clgame.palette[i].g = i; clgame.palette[i].b = i; } - MsgDev( D_WARN, "CL_InstallParticlePalette: failed. Force to grayscale\n" ); } } @@ -731,12 +731,12 @@ void SCR_Init( void ) host.allow_console = true; // we need console, because menu is missing } + SCR_VidInit(); SCR_LoadCreditsFont (); - SCR_InstallParticlePalette (); SCR_RegisterTextures (); + SCR_InstallParticlePalette (); SCR_InitCinematic(); CL_InitNetgraph(); - SCR_VidInit(); if( host.allow_console && Sys_CheckParm( "-toconsole" )) Cbuf_AddText( "toggleconsole\n" ); diff --git a/engine/client/gl_beams.c b/engine/client/gl_beams.c index d88a5714..f73b53d7 100644 --- a/engine/client/gl_beams.c +++ b/engine/client/gl_beams.c @@ -1897,14 +1897,14 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType ) startFrame = MSG_ReadByte( msg ); frameRate = (float)(MSG_ReadByte( msg )); life = (float)(MSG_ReadByte( msg ) * 0.1f); - width = (float)(MSG_ReadByte( msg ) * 0.1f); - noise = (float)(MSG_ReadByte( msg ) * 0.01f); + width = (float)(MSG_ReadByte( msg )); + noise = (float)(MSG_ReadByte( msg ) * 0.1f); r = (float)MSG_ReadByte( msg ) / 255.0f; g = (float)MSG_ReadByte( msg ) / 255.0f; b = (float)MSG_ReadByte( msg ) / 255.0f; a = (float)MSG_ReadByte( msg ) / 255.0f; - speed = (float)MSG_ReadByte( msg ); - R_BeamCirclePoints( beamType, start, end, modelIndex, life, width, noise, a, speed / 10.0f, startFrame, frameRate, r, g, b ); + speed = (float)(MSG_ReadByte( msg ) / 0.1f); + R_BeamCirclePoints( beamType, start, end, modelIndex, life, width, noise, a, speed, startFrame, frameRate, r, g, b ); break; case TE_BEAMFOLLOW: startEnt = MSG_ReadShort( msg ); diff --git a/engine/client/gl_rlight.c b/engine/client/gl_rlight.c index 91fe10e7..223abdf9 100644 --- a/engine/client/gl_rlight.c +++ b/engine/client/gl_rlight.c @@ -355,9 +355,9 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f, if( dm != NULL ) { vec3_t srcNormal, lightNormal; - float f = (1.0f / 255.0f); + float f = (1.0f / 128.0f); - VectorSet( srcNormal, (dm->r * f) * 2.0f - 1.0f, (dm->g * f) * 2.0f - 1.0f, (dm->b * f) * 2.0f - 1.0f ); + VectorSet( srcNormal, ((float)dm->r - 128.0f) * f, ((float)dm->g - 128.0f) * f, ((float)dm->b - 128.0f) * f ); Matrix3x4_VectorIRotate( tbn, srcNormal, lightNormal ); // turn to world space VectorScale( lightNormal, (float)scale * -1.0f, lightNormal ); // turn direction from light VectorAdd( g_trace_lightvec, lightNormal, g_trace_lightvec ); diff --git a/engine/client/gl_vidnt.c b/engine/client/gl_vidnt.c index 59cd2c52..41c3a9e3 100644 --- a/engine/client/gl_vidnt.c +++ b/engine/client/gl_vidnt.c @@ -1657,7 +1657,7 @@ void GL_InitExtensions( void ) glConfig.renderer_string = pglGetString( GL_RENDERER ); glConfig.version_string = pglGetString( GL_VERSION ); glConfig.extensions_string = pglGetString( GL_EXTENSIONS ); - Con_Printf( "Video: %s\n", glConfig.renderer_string ); + Con_Printf( "^3Video:^7 %s\n", glConfig.renderer_string ); // intialize wrapper type glConfig.context = CONTEXT_TYPE_GL; diff --git a/engine/client/s_backend.c b/engine/client/s_backend.c index d234be55..73061669 100644 --- a/engine/client/s_backend.c +++ b/engine/client/s_backend.c @@ -311,9 +311,6 @@ int SNDDMA_Init( void *hInst ) // init DirectSound if( SNDDMA_InitDirect( hInst ) != SIS_SUCCESS ) return false; - - if( snd_firsttime ) - Con_Printf( "Audio: DirectSound\n" ); dma.initialized = true; snd_firsttime = false; diff --git a/engine/common/build.c b/engine/common/build.c index 0bd5ad9a..04ffdb2e 100644 --- a/engine/common/build.c +++ b/engine/common/build.c @@ -48,6 +48,6 @@ int Q_buildnum( void ) return b; #else - return 4140; + return 4143; #endif } diff --git a/engine/common/com_strings.h b/engine/common/com_strings.h index 1817fb8a..50a92d4a 100644 --- a/engine/common/com_strings.h +++ b/engine/common/com_strings.h @@ -41,6 +41,10 @@ GNU General Public License for more details. // debug beams #define DEFAULT_LASERBEAM_PATH "sprites/laserbeam.spr" +#define DEFAULT_INTERNAL_PALETTE "gfx/palette.lmp" + +#define DEFAULT_EXTERNAL_PALETTE "gfx/palette.pal" + // path to folders where placed all sounds #define DEFAULT_SOUNDPATH "sound/" diff --git a/engine/common/host.c b/engine/common/host.c index 4d7f45e8..82048720 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -346,6 +346,10 @@ void Host_InitDecals( void ) int i, num_decals = 0; search_t *t; + // NOTE: only once resource without which engine can't continue work + if( !FS_FileExists( "gfx/conchars", false )) + Sys_Error( "W_LoadWadFile: couldn't load gfx.wad\n" ); + memset( host.draw_decals, 0, sizeof( host.draw_decals )); // lookup all the decals in decals.wad (basedir, gamedir, falldir) diff --git a/engine/common/host_state.c b/engine/common/host_state.c index dfbc7ed2..d76551a6 100644 --- a/engine/common/host_state.c +++ b/engine/common/host_state.c @@ -149,7 +149,7 @@ void COM_Frame( float time ) { int oldState = GameState->curstate; - // execute the current state (and transition to the next state if not in HS_RUN) + // execute the current state (and transition to the next state if not in STATE_RUNFRAME) switch( GameState->curstate ) { case STATE_LOAD_LEVEL: diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index 782ebacd..3bf58bc7 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -28,6 +28,7 @@ GNU General Public License for more details. typedef struct wadlist_s { char wadnames[MAX_MAP_WADS][32]; + int wadusage[MAX_MAP_WADS]; int count; } wadlist_t; @@ -334,11 +335,10 @@ static void Mod_LoadLump( const byte *in, mlumpinfo_t *info, mlumpstat_t *stat, loadstat.numerrors++; return; } - else + else if( !FBitSet( flags, LUMP_SILENT )) { // just throw warning - if( !FBitSet( flags, LUMP_SILENT )) - MsgDev( D_WARN, "map ^2%s^7 has too many %s\n", loadstat.name, msg1 ); + MsgDev( D_WARN, "map ^2%s^7 has too many %s\n", loadstat.name, msg1 ); loadstat.numwarnings++; } } @@ -1595,6 +1595,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod ) { int num = bmod->wadlist.count++; Q_strncpy( bmod->wadlist.wadnames[num], token, sizeof( bmod->wadlist.wadnames[0] )); + bmod->wadlist.wadusage[num] = 0; } if( bmod->wadlist.count >= MAX_MAP_WADS ) @@ -1886,6 +1887,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) if( FS_FileExists( texpath, false )) { tx->gl_texturenum = GL_LoadTexture( texpath, NULL, 0, 0, filter ); + bmod->wadlist.wadusage[j]++; // this wad are really used break; } } @@ -1942,6 +1944,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) if( FS_FileExists( texpath, false )) { src = FS_LoadFile( texpath, &srcSize, false ); + bmod->wadlist.wadusage[j]++; // this wad are really used break; } } @@ -2694,11 +2697,15 @@ qboolean Mod_LoadBmodelLumps( const byte *mod_base, qboolean isworld ) } for( i = 0; i < bmod->wadlist.count; i++ ) + { + if( !bmod->wadlist.wadusage[i] ) + continue; Q_strncat( wadvalue, va( "%s.wad; ", bmod->wadlist.wadnames[i] ), sizeof( wadvalue )); + } if( COM_CheckString( wadvalue )) { - wadvalue[Q_strlen( wadvalue ) - 2] = '\0'; + wadvalue[Q_strlen( wadvalue ) - 2] = '\0'; // kill the last semicolon Con_DPrintf( "Wad files required to run the map: \"%s\"\n", wadvalue ); } @@ -2974,17 +2981,30 @@ only empty lumps is allows */ int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize ) { - file_t *f = FS_Open( filename, "e+b", true ); byte buffer[sizeof( dheader_t ) + sizeof( dextrahdr_t )]; size_t prefetch_size = sizeof( buffer ); + int result, dummy = lumpsize; dextrahdr_t *extrahdr; dheader_t *header; - - if( !f ) return LUMP_SAVE_COULDNT_OPEN; + file_t *f; if( !lumpdata || lumpsize <= 0 ) return LUMP_SAVE_NO_DATA; + // make sure what .bsp is placed into gamedir and not in pak + if( !FS_GetDiskPath( filename, true )) + return LUMP_SAVE_COULDNT_OPEN; + + // first we should sure what we allow to rewrite this .bsp + result = Mod_CheckLump( filename, lump, &dummy ); + + if( result != LUMP_LOAD_NOT_EXIST ) + return result; + + f = FS_Open( filename, "e+b", true ); + + if( !f ) return LUMP_SAVE_COULDNT_OPEN; + if( FS_Read( f, buffer, prefetch_size ) != prefetch_size ) { FS_Close( f ); @@ -2993,6 +3013,7 @@ int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lump header = (dheader_t *)buffer; + // these checks below are redundant if( header->version != HLBSP_VERSION ) { FS_Close( f ); diff --git a/engine/common/mod_dbghulls.c b/engine/common/mod_dbghulls.c index 2c57b3f5..ffa96a1e 100644 --- a/engine/common/mod_dbghulls.c +++ b/engine/common/mod_dbghulls.c @@ -711,6 +711,7 @@ void Mod_ReleaseHullPolygons( void ) hull_model_t *model = &world.hull_models[i]; free_hull_polys( &model->polys ); } + world.num_hull_models = 0; } void R_DrawWorldHull( void ) diff --git a/engine/common/pm_trace.c b/engine/common/pm_trace.c index 6820b2b8..d3afdcda 100644 --- a/engine/common/pm_trace.c +++ b/engine/common/pm_trace.c @@ -299,7 +299,7 @@ loc0: { trace->fraction = midf; VectorCopy( mid, trace->endpos ); - MsgDev( D_WARN, "trace backed up past 0.0\n" ); + Con_Reportf( S_WARN "trace backed up past 0.0\n" ); return false; } diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 17640ebd..f305c8b2 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -329,7 +329,7 @@ void SV_ConnectClient( netadr_t from ) } else { - MsgDev( D_INFO, "%s:reconnect\n", NET_AdrToString( from )); + Con_Reportf( S_NOTE "%s:reconnect\n", NET_AdrToString( from )); } // find a client slot @@ -2077,7 +2077,7 @@ void SV_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) Cmd_TokenizeString( args ); pcmd = Cmd_Argv( 0 ); - Con_DPrintf( "SV_ConnectionlessPacket: %s : %s\n", NET_AdrToString( from ), pcmd ); + Con_Reportf( "SV_ConnectionlessPacket: %s : %s\n", NET_AdrToString( from ), pcmd ); if( !Q_strcmp( pcmd, "ping" )) SV_Ping( from ); else if( !Q_strcmp( pcmd, "ack" )) SV_Ack( from ); diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index e9a18b28..5498c279 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -315,7 +315,7 @@ SV_Load_f */ void SV_Load_f( void ) { - string path; + char path[MAX_QPATH]; if( Cmd_Argc() != 2 ) { diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 0de8d171..a49a752b 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -1318,6 +1318,7 @@ void pfnChangeLevel( const char *level, const char *landmark ) COM_StripExtension( mapname ); landname[0] ='\0'; +#ifdef HACKS_RELATED_HLMODS // g-cont. some level-designers wrote landmark name with space // and Cmd_TokenizeString separating all the after space as next argument // emulate this bug for compatibility @@ -1326,9 +1327,13 @@ void pfnChangeLevel( const char *level, const char *landmark ) text = (char *)landname; while( *landmark && ((byte)*landmark) != ' ' ) *text++ = *landmark++; - smooth = true; *text = '\0'; } +#else + Q_strncpy( landname, landmark, sizeof( landname )); +#endif + if( COM_CheckString( landname )) + smooth = true; // determine spawn entity classname if( svs.maxclients == 1 ) @@ -2399,7 +2404,7 @@ void pfnServerExecute( void ) Cbuf_Execute(); if( host.sv_cvars_restored > 0 ) - Con_DPrintf( "server executing ^2config.cfg^7 (%i cvars)\n", host.sv_cvars_restored ); + Con_Reportf( "server executing ^2config.cfg^7 (%i cvars)\n", host.sv_cvars_restored ); host.apply_game_config = false; svgame.config_executed = true; @@ -3406,7 +3411,7 @@ OBSOLETE, UNUSED */ uint pfnGetPlayerWONId( edict_t *e ) { - return -1; + return (uint)-1; } /* @@ -4841,7 +4846,7 @@ qboolean SV_LoadProgs( const char *name ) return false; } } - else Con_DPrintf( "SV_LoadProgs: ^2initailized extended EntityAPI ^7ver. %i\n", version ); + else Con_Reportf( "SV_LoadProgs: ^2initailized extended EntityAPI ^7ver. %i\n", version ); } else if( !GetEntityAPI( &svgame.dllFuncs, version )) { diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index 92d8c683..a76bc358 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -725,7 +725,7 @@ void SV_SetupClients( void ) svs.clients = Z_Realloc( svs.clients, sizeof( sv_client_t ) * svs.maxclients ); svs.num_client_entities = svs.maxclients * SV_UPDATE_BACKUP * NUM_PACKET_ENTITIES; svs.packet_entities = Z_Realloc( svs.packet_entities, sizeof( entity_state_t ) * svs.num_client_entities ); - Con_DPrintf( "%s alloced by server packet entities\n", Q_memprint( sizeof( entity_state_t ) * svs.num_client_entities )); + Con_Reportf( "%s alloced by server packet entities\n", Q_memprint( sizeof( entity_state_t ) * svs.num_client_entities )); // init network stuff NET_Config(( svs.maxclients > 1 ));