fixed getgamedir on old hl builds
This commit is contained in:
parent
95d9d4db0c
commit
0fde82af4e
1 changed files with 18 additions and 9 deletions
|
|
@ -241,18 +241,27 @@ const char *Engine::GetModName (void)
|
||||||
// this function returns mod name without path
|
// this function returns mod name without path
|
||||||
|
|
||||||
static char engineModName[256];
|
static char engineModName[256];
|
||||||
g_engfuncs.pfnGetGameDir (engineModName); // ask the engine for the MOD directory path
|
|
||||||
|
|
||||||
String mod (engineModName);
|
g_engfuncs.pfnGetGameDir (engineModName);
|
||||||
int pos = mod.ReverseFind ('\\');
|
int length = strlen (engineModName);
|
||||||
|
|
||||||
if (pos == -1)
|
int stop = length - 1;
|
||||||
pos = mod.ReverseFind ('/');
|
while ((engineModName[stop] == '\\' || engineModName[stop] == '/') && stop > 0)
|
||||||
|
stop--;
|
||||||
|
|
||||||
if (pos == -1)
|
int start = stop;
|
||||||
return &engineModName[0];
|
while (engineModName[start] != '\\' && engineModName[start] != '/' && start > 0)
|
||||||
|
start--;
|
||||||
|
|
||||||
return mod.Mid (pos, -1).GetBuffer ();
|
if (engineModName[start] == '\\' || engineModName[start] == '/')
|
||||||
|
start++;
|
||||||
|
|
||||||
|
for (length = start; length <= stop; length++)
|
||||||
|
engineModName[length - start] = engineModName[length];
|
||||||
|
|
||||||
|
engineModName[length - start] = 0; // terminate the string
|
||||||
|
|
||||||
|
return &engineModName[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Engine::GetMapName (void)
|
const char *Engine::GetMapName (void)
|
||||||
|
|
@ -374,7 +383,7 @@ void Engine::IssueBotCommand (edict_t *ent, const char *fmt, ...)
|
||||||
|
|
||||||
const char *Engine::ExtractSingleField (const char *string, int id, bool terminate)
|
const char *Engine::ExtractSingleField (const char *string, int id, bool terminate)
|
||||||
{
|
{
|
||||||
// this function gets and returns a particuliar field in a string where several strings are concatenated
|
// this function gets and returns a particular field in a string where several strings are concatenated
|
||||||
|
|
||||||
static char field[256];
|
static char field[256];
|
||||||
field[0] = { 0, };
|
field[0] = { 0, };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue