diff --git a/releases/valve/source/build.h b/releases/valve/source/build.h index 6dd57dd..0c082d8 100644 --- a/releases/valve/source/build.h +++ b/releases/valve/source/build.h @@ -68,7 +68,7 @@ // Build in code to help playtest. Choose neither, AVH_PLAYTEST_BUILD, or AVH_PLAYTEST_BUILD _and_ AVH_LAN_PLAYTEST_BUILD #ifdef DEBUG -#define AVH_PLAYTEST_BUILD +//#define AVH_PLAYTEST_BUILD //#define AVH_LAN_PLAYTEST_BUILD #endif diff --git a/releases/valve/source/cl_dll/cdll_int.cpp b/releases/valve/source/cl_dll/cdll_int.cpp index 15e3ba6..f9cba9d 100644 --- a/releases/valve/source/cl_dll/cdll_int.cpp +++ b/releases/valve/source/cl_dll/cdll_int.cpp @@ -47,7 +47,11 @@ cl_enginefunc_t gEngfuncs; // Instead of using default Half-life HUD, use more flexible one I've added //CHud gHUD; //UIHud gHUD("StratHL/ui.txt", new AvHUIFactory()); -AvHHud gHUD((string(getModDirectory()) + "/ui.txt").c_str(), new AvHUIFactory()); + +AvHHud& getHUD() { + static AvHHud theGlobalHud( (string(getModDirectory()) + string("/ui.txt")).c_str(), new AvHUIFactory()); + return theGlobalHud; +} TeamFortressViewport *gViewPort = NULL; diff --git a/releases/valve/source/cl_dll/ev_hldm.cpp b/releases/valve/source/cl_dll/ev_hldm.cpp index 45f01f1..7c0c73a 100644 --- a/releases/valve/source/cl_dll/ev_hldm.cpp +++ b/releases/valve/source/cl_dll/ev_hldm.cpp @@ -36,7 +36,7 @@ #include static int tracerCount[ 32 ]; -extern AvHHud gHUD; +//extern AvHHud gHUD; #include "r_studioint.h" #include "com_model.h" diff --git a/releases/valve/source/cl_dll/hud.h b/releases/valve/source/cl_dll/hud.h index 3cb759d..c1a6c96 100644 --- a/releases/valve/source/cl_dll/hud.h +++ b/releases/valve/source/cl_dll/hud.h @@ -29,7 +29,7 @@ class TeamFortressViewport; class AvHHud; #include "mod/AvHHud.h" -extern AvHHud gHUD; +//extern AvHHud gHUD; #include "wrect.h" #include "cl_dll.h" diff --git a/releases/valve/source/mod/AvHBalance.cpp b/releases/valve/source/mod/AvHBalance.cpp index c6aff18..c8e89d2 100644 --- a/releases/valve/source/mod/AvHBalance.cpp +++ b/releases/valve/source/mod/AvHBalance.cpp @@ -166,7 +166,7 @@ void AvHGamerules::BalanceChanged() } #endif -static string theBalanceFileName = string(getModDirectory()) + "/Balance.txt"; + #ifdef AVH_PLAYTEST_BUILD @@ -176,7 +176,8 @@ void AvHGamerules::ReadBalanceData() this->mBalanceFloats.clear(); fstream inFile; - inFile.open(theBalanceFileName.c_str(), ios::in); + static string theBalanceFileName = string(getModDirectory()) + "/Balance.txt"; + inFile.open(theBalanceFileName.c_str(), ios::in); if(inFile.is_open()) { @@ -236,7 +237,8 @@ void AvHGamerules::ReadBalanceData() void AvHGamerules::RecordBalanceData() { fstream theOutfile; - theOutfile.open(theBalanceFileName.c_str(), ios::out); + static string theBalanceFileName = string(getModDirectory()) + "/Balance.txt"; + theOutfile.open(theBalanceFileName.c_str(), ios::out); if(theOutfile.is_open()) { // Write out header diff --git a/releases/valve/source/mod/AvHBalanceAnalysis.cpp b/releases/valve/source/mod/AvHBalanceAnalysis.cpp index a5a11cc..f8195df 100644 --- a/releases/valve/source/mod/AvHBalanceAnalysis.cpp +++ b/releases/valve/source/mod/AvHBalanceAnalysis.cpp @@ -23,7 +23,7 @@ #ifdef AVH_CLIENT #include "mod/AvHHud.h" -extern AvHHud gHUD; +//extern AvHHud gHUD; #endif AvHEconomy::AvHEconomy(const AvHTechNodes& inTechNodes, int inInitialResources, int inInitialTowers, bool inMarine, MessageIDListType inTargetTechList) diff --git a/releases/valve/source/mod/AvHConstants.cpp b/releases/valve/source/mod/AvHConstants.cpp index a8a8ec4..5e0ecc1 100644 --- a/releases/valve/source/mod/AvHConstants.cpp +++ b/releases/valve/source/mod/AvHConstants.cpp @@ -4,36 +4,37 @@ const int slashchr = '\\'; #define kAvHModDir ((const char*)("ns")) +#ifdef AVH_SERVER +#include "common/mathlib.h" +#include "common/const.h" +#include "engine/edict.h" +#include "engine/eiface.h" +#include "dlls/enginecallback.h" +#else +#include "cl_dll/wrect.h" +#include "cl_dll/cl_dll.h" +#include "dlls/extdll.h" +#endif + + const char* getModDirectory(void) { -//#ifdef __linux__ -// return kAvHModDir; -//#else -// static char theModDirectory[512]; -// static bool theIsComputed = false; -// #define thisFileString __FILE__ + static char theModDirectory[512]; + static bool theIsComputed = false; -// if(!theIsComputed) -// { -// const char* thisFileName = thisFileString; -// strcpy(theModDirectory,thisFileName); -// //theModDirectory = /[mod_directory]/source/mod/AvHConstants.cpp -// char* pos = strrchr(theModDirectory,slashchr); -// for(int counter = 0; counter < 3; ++counter) //remove three slahses and everything that comes after -// { -// *pos = '\0'; -// pos = strrchr(theModDirectory,slashchr); //point to next slash -// } - //theModDirectory = /[mod_directory] - //pos+1 = [mod_directory] -// char temp[512]; -// strcpy(temp,pos+1); //use temp so we don't overwrite ourselves on copy. -// strcpy(theModDirectory,temp); //theModDirectory now holds the correct directory name -// theIsComputed = true; //don't compute this again -// } -// return theModDirectory; -//#endif - return "ns"; + if(!theIsComputed) + { + strcpy(theModDirectory, "ns305"); +#ifdef AVH_SERVER + GET_GAME_DIR(theModDirectory); +#else + const char *pchGameDirT = gEngfuncs.pfnGetGameDirectory(); + strcpy(theModDirectory, pchGameDirT); +#endif + + theIsComputed = true; //don't compute this again + } + return theModDirectory; } const char* getModName(void) diff --git a/releases/valve/source/mod/AvHHud.h b/releases/valve/source/mod/AvHHud.h index ae23ea2..89d96e9 100644 --- a/releases/valve/source/mod/AvHHud.h +++ b/releases/valve/source/mod/AvHHud.h @@ -818,4 +818,7 @@ private: }; +AvHHud& getHUD(); +#define gHUD (getHUD()) + #endif diff --git a/releases/valve/source/ui/FadingImageLabel.cpp b/releases/valve/source/ui/FadingImageLabel.cpp index 132a370..70cc465 100644 --- a/releases/valve/source/ui/FadingImageLabel.cpp +++ b/releases/valve/source/ui/FadingImageLabel.cpp @@ -431,7 +431,7 @@ void FadingImageLabel::SetFadeState(bool inNewState) // set fade to state this->mFadeToVisibiltyState = inNewState; - float theCurrentTime = ::gHUD.m_flTime; + float theCurrentTime = gHUD.m_flTime; // set new fade to time in case a change was specified during a change this->mTimeToFade = min(this->mBaseFadeTime, (theCurrentTime - this->mTimeVisChanged));