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
|
||||
|
||||
static char engineModName[256];
|
||||
g_engfuncs.pfnGetGameDir (engineModName); // ask the engine for the MOD directory path
|
||||
|
||||
String mod (engineModName);
|
||||
int pos = mod.ReverseFind ('\\');
|
||||
g_engfuncs.pfnGetGameDir (engineModName);
|
||||
int length = strlen (engineModName);
|
||||
|
||||
if (pos == -1)
|
||||
pos = mod.ReverseFind ('/');
|
||||
int stop = length - 1;
|
||||
while ((engineModName[stop] == '\\' || engineModName[stop] == '/') && stop > 0)
|
||||
stop--;
|
||||
|
||||
int start = stop;
|
||||
while (engineModName[start] != '\\' && engineModName[start] != '/' && start > 0)
|
||||
start--;
|
||||
|
||||
if (engineModName[start] == '\\' || engineModName[start] == '/')
|
||||
start++;
|
||||
|
||||
for (length = start; length <= stop; length++)
|
||||
engineModName[length - start] = engineModName[length];
|
||||
|
||||
engineModName[length - start] = 0; // terminate the string
|
||||
|
||||
if (pos == -1)
|
||||
return &engineModName[0];
|
||||
|
||||
return mod.Mid (pos, -1).GetBuffer ();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// 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];
|
||||
field[0] = { 0, };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue