Fix compile errors on Clang by implementing own enum.
This commit is contained in:
parent
f107ff9cd2
commit
c383f1dc43
@ -1208,17 +1208,7 @@ const char *CHalfLife2::GetEntityClassname(CBaseEntity *pEntity)
|
|||||||
return *(const char **)(((unsigned char *)pEntity) + offset);
|
return *(const char **)(((unsigned char *)pEntity) + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE != SE_TF2
|
SMFindMapResult CHalfLife2::FindMap(char *pMapName, int nMapNameMax)
|
||||||
enum eFindMapResult {
|
|
||||||
eFindMap_Found,
|
|
||||||
eFindMap_NotFound,
|
|
||||||
eFindMap_FuzzyMatch,
|
|
||||||
eFindMap_NonCanonical,
|
|
||||||
eFindMap_PossiblyAvailable
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
eFindMapResult CHalfLife2::FindMap(char *pMapName, int nMapNameMax)
|
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE >= SE_LEFT4DEAD
|
#if SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||||
static char mapNameTmp[PLATFORM_MAX_PATH];
|
static char mapNameTmp[PLATFORM_MAX_PATH];
|
||||||
@ -1228,7 +1218,7 @@ eFindMapResult CHalfLife2::FindMap(char *pMapName, int nMapNameMax)
|
|||||||
// If this is already an exact match, don't attempt to autocomplete it further (de_dust -> de_dust2).
|
// If this is already an exact match, don't attempt to autocomplete it further (de_dust -> de_dust2).
|
||||||
// ... but still check that map file is actually valid.
|
// ... but still check that map file is actually valid.
|
||||||
// We check FileExists first to avoid console message about IsMapValid with invalid map.
|
// We check FileExists first to avoid console message about IsMapValid with invalid map.
|
||||||
return engine->IsMapValid(pMapName) == 0 ? eFindMap_NotFound : eFindMap_Found;
|
return engine->IsMapValid(pMapName) == 0 ? SMFindMapResult::NotFound : SMFindMapResult::Found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConCommand *pHelperCmd = g_pCVar->FindCommand("changelevel");
|
static ConCommand *pHelperCmd = g_pCVar->FindCommand("changelevel");
|
||||||
@ -1236,7 +1226,7 @@ eFindMapResult CHalfLife2::FindMap(char *pMapName, int nMapNameMax)
|
|||||||
// This shouldn't happen.
|
// This shouldn't happen.
|
||||||
if (!pHelperCmd || !pHelperCmd->CanAutoComplete())
|
if (!pHelperCmd || !pHelperCmd->CanAutoComplete())
|
||||||
{
|
{
|
||||||
return engine->IsMapValid(pMapName) == 0 ? eFindMap_NotFound : eFindMap_Found;
|
return engine->IsMapValid(pMapName) == 0 ? SMFindMapResult::NotFound : SMFindMapResult::Found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t helperCmdLen = strlen(pHelperCmd->GetName());
|
static size_t helperCmdLen = strlen(pHelperCmd->GetName());
|
||||||
@ -1244,7 +1234,7 @@ eFindMapResult CHalfLife2::FindMap(char *pMapName, int nMapNameMax)
|
|||||||
CUtlVector<CUtlString> results;
|
CUtlVector<CUtlString> results;
|
||||||
pHelperCmd->AutoCompleteSuggest(pMapName, results);
|
pHelperCmd->AutoCompleteSuggest(pMapName, results);
|
||||||
if (results.Count() == 0)
|
if (results.Count() == 0)
|
||||||
return eFindMap_NotFound;
|
return SMFindMapResult::NotFound;
|
||||||
|
|
||||||
// Results come back as you'd see in autocomplete. (ie. "changelevel fullmapnamehere"),
|
// Results come back as you'd see in autocomplete. (ie. "changelevel fullmapnamehere"),
|
||||||
// so skip ahead to start of map path/name
|
// so skip ahead to start of map path/name
|
||||||
@ -1254,17 +1244,17 @@ eFindMapResult CHalfLife2::FindMap(char *pMapName, int nMapNameMax)
|
|||||||
bool bExactMatch = Q_strcmp(pMapName, &results[0][helperCmdLen + 1]) == 0;
|
bool bExactMatch = Q_strcmp(pMapName, &results[0][helperCmdLen + 1]) == 0;
|
||||||
if (bExactMatch)
|
if (bExactMatch)
|
||||||
{
|
{
|
||||||
return eFindMap_Found;
|
return SMFindMapResult::Found;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncopy(pMapName, &results[0][helperCmdLen + 1], nMapNameMax);
|
strncopy(pMapName, &results[0][helperCmdLen + 1], nMapNameMax);
|
||||||
return eFindMap_FuzzyMatch;
|
return SMFindMapResult::FuzzyMatch;
|
||||||
}
|
}
|
||||||
#elif SOURCE_ENGINE == SE_TF2
|
#elif SOURCE_ENGINE == SE_TF2
|
||||||
return engine->FindMap(pMapName, nMapNameMax);
|
return static_cast<SMFindMapResult>(engine->FindMap(pMapName, nMapNameMax));
|
||||||
#else
|
#else
|
||||||
return engine->IsMapValid(pMapName) == 0 ? eFindMap_NotFound : eFindMap_Found;
|
return engine->IsMapValid(pMapName) == 0 ? SMFindMapResult::NotFound : SMFindMapResult::Found;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,5 +1266,5 @@ bool CHalfLife2::IsMapValid(const char *map)
|
|||||||
static char szTmp[PLATFORM_MAX_PATH];
|
static char szTmp[PLATFORM_MAX_PATH];
|
||||||
strncopy(szTmp, map, sizeof(szTmp));
|
strncopy(szTmp, map, sizeof(szTmp));
|
||||||
|
|
||||||
return FindMap(szTmp, sizeof(szTmp)) != eFindMap_NotFound;
|
return FindMap(szTmp, sizeof(szTmp)) != SMFindMapResult::NotFound;
|
||||||
}
|
}
|
||||||
|
@ -129,9 +129,15 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// See TF2 eiface.h for description.
|
// Corresponds to TF2's eFindMapResult in eiface.h
|
||||||
// Not yet in other games, but eventually in others on same branch.
|
// Not yet in other games, but eventually in others on same branch.
|
||||||
enum eFindMapResult : int;
|
enum class SMFindMapResult : cell_t {
|
||||||
|
Found,
|
||||||
|
NotFound,
|
||||||
|
FuzzyMatch,
|
||||||
|
NonCanonical,
|
||||||
|
PossiblyAvailable
|
||||||
|
};
|
||||||
|
|
||||||
class CHalfLife2 :
|
class CHalfLife2 :
|
||||||
public SMGlobalClass,
|
public SMGlobalClass,
|
||||||
@ -178,7 +184,7 @@ public: //IGameHelpers
|
|||||||
const char *GetEntityClassname(edict_t *pEdict);
|
const char *GetEntityClassname(edict_t *pEdict);
|
||||||
const char *GetEntityClassname(CBaseEntity *pEntity);
|
const char *GetEntityClassname(CBaseEntity *pEntity);
|
||||||
bool IsMapValid(const char *map);
|
bool IsMapValid(const char *map);
|
||||||
eFindMapResult FindMap(char *pMapName, int nMapNameMax);
|
SMFindMapResult FindMap(char *pMapName, int nMapNameMax);
|
||||||
public:
|
public:
|
||||||
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
|
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
|
||||||
void ProcessFakeCliCmdQueue();
|
void ProcessFakeCliCmdQueue();
|
||||||
|
@ -74,7 +74,7 @@ static cell_t FindMap(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
cell_t size = params[2];
|
cell_t size = params[2];
|
||||||
|
|
||||||
return g_HL2.FindMap(pMapname, size);
|
return static_cast<cell_t>(g_HL2.FindMap(pMapname, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell_t IsDedicatedServer(IPluginContext *pContext, const cell_t *params)
|
static cell_t IsDedicatedServer(IPluginContext *pContext, const cell_t *params)
|
||||||
|
Loading…
Reference in New Issue
Block a user