From dd1fd1c5da9ff1c9ddabee4e06fc6c09f73fecd1 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 15 Jan 2017 15:03:19 +0200 Subject: [PATCH] Add ability to change materials.txt and sentences.txt paths --- dlls/game.cpp | 6 ++++++ dlls/game.h | 3 +++ dlls/sound.cpp | 5 +++-- pm_shared/pm_shared.c | 12 ++++++++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/dlls/game.cpp b/dlls/game.cpp index dc27ab40..22197576 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -60,6 +60,9 @@ cvar_t mp_unduck = { "mp_unduck", "0", FCVAR_SERVER }; cvar_t mp_semclip = { "mp_semclip", "0", FCVAR_SERVER }; cvar_t mp_spectator = { "mp_spectator", "0", FCVAR_SERVER }; +cvar_t materials_txt = { "materials_txt", "sound/materials.txt", FCVAR_SERVER }; +cvar_t sentences_txt = { "sentences_txt", "sound/sentences.txt", FCVAR_SERVER }; + // Engine Cvars cvar_t *g_psv_gravity = NULL; cvar_t *g_psv_aim = NULL; @@ -511,6 +514,9 @@ void GameDLLInit( void ) CVAR_REGISTER( &mp_coop_noangry ); CVAR_REGISTER( &mp_spectator ); + CVAR_REGISTER( &sentences_txt ); + CVAR_REGISTER( &materials_txt ); + CVAR_REGISTER( &mp_chattime ); diff --git a/dlls/game.h b/dlls/game.h index c5a61d9a..c0eb3529 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -58,6 +58,9 @@ extern cvar_t mp_coop_reconnect_hack; extern cvar_t mp_coop_noangry; extern cvar_t mp_spectator; +extern cvar_t sentences_txt; +extern cvar_t materials_txt; + extern bool g_fSavedDuck; extern bool g_fPause; diff --git a/dlls/sound.cpp b/dlls/sound.cpp index b97eee12..c9a46f55 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -23,6 +23,7 @@ #include "player.h" #include "talkmonster.h" #include "gamerules.h" +#include "game.h" static char *memfgets( byte *pMemFile, int fileSize, int &filePos, char *pBuffer, int bufferSize ); @@ -1264,7 +1265,7 @@ void SENTENCEG_Init() isentencegs = -1; int filePos = 0, fileSize; - byte *pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/sentences.txt", &fileSize ); + byte *pMemFile = g_engfuncs.pfnLoadFileForMe( sentences_txt.string, &fileSize ); if( !pMemFile ) return; @@ -1528,7 +1529,7 @@ void TEXTURETYPE_Init() gcTextures = 0; - pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/materials.txt", &fileSize ); + pMemFile = g_engfuncs.pfnLoadFileForMe( materials_txt.string, &fileSize ); if( !pMemFile ) return; diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 8f1dd354..db9926b7 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -122,6 +122,14 @@ static char grgchTextureType[CTEXTURESMAX]; int g_onladder = 0; +#ifdef CLIENT_DLL +#define materials_path "sound/materials.txt" +#else +#include "cvardef.h" +extern cvar_t materials_txt; +#define materials_path materials_txt.string +#endif + void PM_SwapTextures( int i, int j ) { char chTemp; @@ -173,8 +181,8 @@ void PM_InitTextureTypes() gcTextures = 0; - fileSize = pmove->COM_FileSize( "sound/materials.txt" ); - pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, NULL ); + fileSize = pmove->COM_FileSize( materials_path ); + pMemFile = pmove->COM_LoadFile( materials_path, 5, NULL ); if( !pMemFile ) return;