Fixes the getModDirectory to use the valve mechanism

git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@169 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
puzl 2005-06-08 18:56:45 +00:00
parent f44f16d59a
commit 39710b46ee
9 changed files with 46 additions and 36 deletions

View File

@ -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

View File

@ -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;

View File

@ -36,7 +36,7 @@
#include <string.h>
static int tracerCount[ 32 ];
extern AvHHud gHUD;
//extern AvHHud gHUD;
#include "r_studioint.h"
#include "com_model.h"

View File

@ -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"

View File

@ -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

View File

@ -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)

View File

@ -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 = <blah>/[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 = <blah>/[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)

View File

@ -818,4 +818,7 @@ private:
};
AvHHud& getHUD();
#define gHUD (getHUD())
#endif

View File

@ -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));