Support all file search paths when finding mapcycle file (bug 5839, r=asherkin).
--HG-- extra : rebase_source : 997dedcbac4a9249111c7424723f5b386baee77d
This commit is contained in:
parent
876ba3bef5
commit
17212616d7
@ -51,7 +51,7 @@ using namespace SourceHook;
|
|||||||
* Add 1 to the RHS of this expression to bump the intercom file
|
* Add 1 to the RHS of this expression to bump the intercom file
|
||||||
* This is to prevent mismatching core/logic binaries
|
* This is to prevent mismatching core/logic binaries
|
||||||
*/
|
*/
|
||||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 25)
|
#define SM_LOGIC_MAGIC (0x0F47C0DE - 26)
|
||||||
|
|
||||||
#if defined SM_LOGIC
|
#if defined SM_LOGIC
|
||||||
class IVEngineServer
|
class IVEngineServer
|
||||||
@ -64,6 +64,7 @@ public:
|
|||||||
virtual void ServerCommand(const char *cmd) = 0;
|
virtual void ServerCommand(const char *cmd) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void * FileHandle_t;
|
||||||
typedef int FileFindHandle_t;
|
typedef int FileFindHandle_t;
|
||||||
|
|
||||||
#if defined SM_LOGIC
|
#if defined SM_LOGIC
|
||||||
@ -76,6 +77,11 @@ public:
|
|||||||
virtual const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle) = 0;
|
virtual const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle) = 0;
|
||||||
virtual const char *FindNext(FileFindHandle_t handle) = 0;
|
virtual const char *FindNext(FileFindHandle_t handle) = 0;
|
||||||
virtual void FindClose(FileFindHandle_t handle) = 0;
|
virtual void FindClose(FileFindHandle_t handle) = 0;
|
||||||
|
virtual FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0) = 0;
|
||||||
|
virtual void Close(FileHandle_t file) = 0;
|
||||||
|
virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0;
|
||||||
|
virtual bool EndOfFile(FileHandle_t file) = 0;
|
||||||
|
virtual bool FileExists(const char *pFileName, const char *pPathID = 0) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace SourceMod
|
namespace SourceMod
|
||||||
|
@ -94,36 +94,21 @@ public:
|
|||||||
|| strcmp(pEngineName, "dods") == 0 || strcmp(pEngineName, "hl2dm") == 0)
|
|| strcmp(pEngineName, "dods") == 0 || strcmp(pEngineName, "hl2dm") == 0)
|
||||||
{
|
{
|
||||||
// These four games and Source SDK 2013 do a lookup in this order; so shall we.
|
// These four games and Source SDK 2013 do a lookup in this order; so shall we.
|
||||||
g_pSM->BuildPath(Path_Game,
|
g_pSM->Format(pBuffer, maxlen, "cfg/%s", pMapCycleFileName);
|
||||||
pBuffer,
|
|
||||||
maxlen,
|
|
||||||
"cfg/%s",
|
|
||||||
pMapCycleFileName);
|
|
||||||
|
|
||||||
if (!libsys->PathExists(pBuffer))
|
if (!smcore.filesystem->FileExists(pBuffer, "GAME"))
|
||||||
{
|
{
|
||||||
g_pSM->BuildPath(Path_Game,
|
g_pSM->Format(pBuffer, maxlen, "%s", pMapCycleFileName);
|
||||||
pBuffer,
|
|
||||||
maxlen,
|
|
||||||
"%s",
|
|
||||||
pMapCycleFileName);
|
|
||||||
|
|
||||||
if (!libsys->PathExists(pBuffer))
|
if (!smcore.filesystem->FileExists(pBuffer, "GAME"))
|
||||||
{
|
{
|
||||||
g_pSM->BuildPath(Path_Game,
|
g_pSM->Format(pBuffer, maxlen, "cfg/mapcycle_default.txt");
|
||||||
pBuffer,
|
|
||||||
maxlen,
|
|
||||||
"cfg/mapcycle_default.txt");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_pSM->BuildPath(Path_Game,
|
g_pSM->Format(pBuffer, maxlen, "%s", pMapCycleFileName);
|
||||||
pBuffer,
|
|
||||||
maxlen,
|
|
||||||
"%s",
|
|
||||||
pMapCycleFileName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void AddOrUpdateDefault(const char *name, const char *file)
|
void AddOrUpdateDefault(const char *name, const char *file)
|
||||||
@ -139,7 +124,7 @@ public:
|
|||||||
pMapList->last_modified_time = 0;
|
pMapList->last_modified_time = 0;
|
||||||
smcore.strncopy(pMapList->name, name, sizeof(pMapList->name));
|
smcore.strncopy(pMapList->name, name, sizeof(pMapList->name));
|
||||||
pMapList->pArray = NULL;
|
pMapList->pArray = NULL;
|
||||||
g_pSM->BuildPath(Path_Game, pMapList->path, sizeof(pMapList->path), "%s", file);
|
smcore.strncopy(pMapList->path, file, sizeof(pMapList->path));
|
||||||
pMapList->serial = 0;
|
pMapList->serial = 0;
|
||||||
m_ListLookup.insert(name, pMapList);
|
m_ListLookup.insert(name, pMapList);
|
||||||
m_MapLists.push_back(pMapList);
|
m_MapLists.push_back(pMapList);
|
||||||
@ -150,7 +135,7 @@ public:
|
|||||||
if (!pMapList->bIsCompat)
|
if (!pMapList->bIsCompat)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file);
|
smcore.strncopy(path, file, sizeof(path));
|
||||||
|
|
||||||
/* If the path matches, don't reset the serial/time */
|
/* If the path matches, don't reset the serial/time */
|
||||||
if (strcmp(path, pMapList->path) == 0)
|
if (strcmp(path, pMapList->path) == 0)
|
||||||
@ -293,11 +278,7 @@ public:
|
|||||||
|
|
||||||
if (strcmp(key, "file") == 0)
|
if (strcmp(key, "file") == 0)
|
||||||
{
|
{
|
||||||
g_pSM->BuildPath(Path_Game,
|
smcore.strncopy(m_pCurMapList->path, value, sizeof(m_pCurMapList->path));
|
||||||
m_pCurMapList->path,
|
|
||||||
sizeof(m_pCurMapList->path),
|
|
||||||
"%s",
|
|
||||||
value);
|
|
||||||
m_pCurMapList->bIsPath = true;
|
m_pCurMapList->bIsPath = true;
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "target") == 0)
|
else if (strcmp(key, "target") == 0)
|
||||||
@ -520,11 +501,11 @@ private:
|
|||||||
|| last_time > pMapList->last_modified_time)
|
|| last_time > pMapList->last_modified_time)
|
||||||
{
|
{
|
||||||
/* Reparse */
|
/* Reparse */
|
||||||
FILE *fp;
|
FileHandle_t fp;
|
||||||
cell_t *blk;
|
cell_t *blk;
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
|
|
||||||
if ((fp = fopen(pMapList->path, "rt")) == NULL)
|
if ((fp = smcore.filesystem->Open(pMapList->path, "rt", "GAME")) == NULL)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -532,7 +513,7 @@ private:
|
|||||||
delete pMapList->pArray;
|
delete pMapList->pArray;
|
||||||
pMapList->pArray = new CellArray(64);
|
pMapList->pArray = new CellArray(64);
|
||||||
|
|
||||||
while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL)
|
while (!smcore.filesystem->EndOfFile(fp) && smcore.filesystem->ReadLine(buffer, sizeof(buffer), fp) != NULL)
|
||||||
{
|
{
|
||||||
size_t len = strlen(buffer);
|
size_t len = strlen(buffer);
|
||||||
char *ptr = smcore.TrimWhitespace(buffer, len);
|
char *ptr = smcore.TrimWhitespace(buffer, len);
|
||||||
@ -552,7 +533,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
smcore.filesystem->Close(fp);
|
||||||
|
|
||||||
pMapList->last_modified_time = last_time;
|
pMapList->last_modified_time = last_time;
|
||||||
pMapList->serial = ++m_nSerialChange;
|
pMapList->serial = ++m_nSerialChange;
|
||||||
|
@ -118,6 +118,26 @@ public:
|
|||||||
{
|
{
|
||||||
filesystem->FindClose(handle);
|
filesystem->FindClose(handle);
|
||||||
}
|
}
|
||||||
|
FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0)
|
||||||
|
{
|
||||||
|
return filesystem->Open(pFileName, pOptions, pathID);
|
||||||
|
}
|
||||||
|
void Close(FileHandle_t file)
|
||||||
|
{
|
||||||
|
filesystem->Close(file);
|
||||||
|
}
|
||||||
|
char *ReadLine(char *pOutput, int maxChars, FileHandle_t file)
|
||||||
|
{
|
||||||
|
return filesystem->ReadLine(pOutput, maxChars, file);
|
||||||
|
}
|
||||||
|
bool EndOfFile(FileHandle_t file)
|
||||||
|
{
|
||||||
|
return filesystem->EndOfFile(file);
|
||||||
|
}
|
||||||
|
bool FileExists(const char *pFileName, const char *pPathID = 0)
|
||||||
|
{
|
||||||
|
return filesystem->FileExists(pFileName, pPathID);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static VFileSystem_Logic logic_filesystem;
|
static VFileSystem_Logic logic_filesystem;
|
||||||
|
Loading…
Reference in New Issue
Block a user