mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-02-10 22:08:47 +03:00
bot chatter: use filesystem to check exists filename instead of _access, cuz filesystem uses search paths such as cstrike_downloads, cstrike_german, cstrike_russian etc
This commit is contained in:
parent
5d2b1ac703
commit
9b4def6e3f
@ -426,11 +426,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex)
|
|||||||
char compositeFilename[RadioPathLen];
|
char compositeFilename[RadioPathLen];
|
||||||
|
|
||||||
#ifdef REGAMEDLL_ADD
|
#ifdef REGAMEDLL_ADD
|
||||||
char soundDir[MAX_PATH];
|
|
||||||
char filePath[MAX_PATH];
|
char filePath[MAX_PATH];
|
||||||
|
|
||||||
GET_GAME_DIR(soundDir);
|
|
||||||
Q_strcat(soundDir, "\\sound\\");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Parse the BotChatter.db into BotPhrase collections
|
// Parse the BotChatter.db into BotPhrase collections
|
||||||
@ -607,9 +603,9 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef REGAMEDLL_ADD
|
#ifdef REGAMEDLL_ADD
|
||||||
Q_snprintf(filePath, sizeof(filePath), "%s%s%s", soundDir, baseDir, token);
|
Q_snprintf(filePath, sizeof(filePath), "sound\\%s%s", baseDir, token);
|
||||||
|
|
||||||
if (_access(filePath, 0) != 0)
|
if (!g_pFileSystem->FileExists(filePath))
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ DLL_FUNCTIONS gFunctionTable =
|
|||||||
NEW_DLL_FUNCTIONS gNewDLLFunctions =
|
NEW_DLL_FUNCTIONS gNewDLLFunctions =
|
||||||
{
|
{
|
||||||
&OnFreeEntPrivateData,
|
&OnFreeEntPrivateData,
|
||||||
nullptr,
|
&OnGameShutdown,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr
|
nullptr
|
||||||
@ -1527,6 +1527,11 @@ void CBaseEntity::SUB_FadeOut()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnGameShutdown()
|
||||||
|
{
|
||||||
|
FileSystem_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
void OnFreeEntPrivateData(edict_t *pEnt)
|
void OnFreeEntPrivateData(edict_t *pEnt)
|
||||||
{
|
{
|
||||||
CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pEnt);
|
CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pEnt);
|
||||||
|
@ -610,6 +610,7 @@ EXT_FUNC void DispatchObjectCollsionBox(edict_t *pent);
|
|||||||
EXT_FUNC void SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount);
|
EXT_FUNC void SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount);
|
||||||
EXT_FUNC void SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount);
|
EXT_FUNC void SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount);
|
||||||
EXT_FUNC void OnFreeEntPrivateData(edict_t *pEnt);
|
EXT_FUNC void OnFreeEntPrivateData(edict_t *pEnt);
|
||||||
|
EXT_FUNC void OnGameShutdown();
|
||||||
|
|
||||||
void SetObjectCollisionBox(entvars_t *pev);
|
void SetObjectCollisionBox(entvars_t *pev);
|
||||||
CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname);
|
CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname);
|
||||||
|
@ -990,17 +990,23 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
|
|||||||
|
|
||||||
MESSAGE_END();
|
MESSAGE_END();
|
||||||
|
|
||||||
// echo to server console
|
#ifdef REGAMEDLL_FIXES
|
||||||
if (pszConsoleFormat)
|
// don't to type for listenserver
|
||||||
|
if (IS_DEDICATED_SERVER())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (placeName && consoleUsesPlaceName)
|
// echo to server console
|
||||||
SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(pPlayer->pev->netname), placeName, text));
|
if (pszConsoleFormat)
|
||||||
|
{
|
||||||
|
if (placeName && consoleUsesPlaceName)
|
||||||
|
SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(pPlayer->pev->netname), placeName, text));
|
||||||
|
else
|
||||||
|
SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(pPlayer->pev->netname), text));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(pPlayer->pev->netname), text));
|
{
|
||||||
}
|
SERVER_PRINT(text);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
SERVER_PRINT(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logmessages.value)
|
if (logmessages.value)
|
||||||
|
@ -12,6 +12,7 @@ C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable, global
|
|||||||
Q_memcpy(&g_engfuncs, pEnginefuncsTable, sizeof(enginefuncs_t));
|
Q_memcpy(&g_engfuncs, pEnginefuncsTable, sizeof(enginefuncs_t));
|
||||||
gpGlobals = pGlobals;
|
gpGlobals = pGlobals;
|
||||||
|
|
||||||
|
FileSystem_Init();
|
||||||
Regamedll_Game_Init();
|
Regamedll_Game_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,6 +521,7 @@
|
|||||||
<ClCompile Include="..\pm_shared\pm_debug.cpp" />
|
<ClCompile Include="..\pm_shared\pm_debug.cpp" />
|
||||||
<ClCompile Include="..\pm_shared\pm_math.cpp" />
|
<ClCompile Include="..\pm_shared\pm_math.cpp" />
|
||||||
<ClCompile Include="..\pm_shared\pm_shared.cpp" />
|
<ClCompile Include="..\pm_shared\pm_shared.cpp" />
|
||||||
|
<ClCompile Include="..\public\FileSystem.cpp" />
|
||||||
<ClCompile Include="..\public\interface.cpp" />
|
<ClCompile Include="..\public\interface.cpp" />
|
||||||
<ClCompile Include="..\public\MemPool.cpp" />
|
<ClCompile Include="..\public\MemPool.cpp" />
|
||||||
<ClCompile Include="..\public\tier0\dbg.cpp">
|
<ClCompile Include="..\public\tier0\dbg.cpp">
|
||||||
|
@ -556,6 +556,9 @@
|
|||||||
<ClCompile Include="..\dlls\addons\point_command.cpp">
|
<ClCompile Include="..\dlls\addons\point_command.cpp">
|
||||||
<Filter>dlls\addons</Filter>
|
<Filter>dlls\addons</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\public\FileSystem.cpp">
|
||||||
|
<Filter>public</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\version\version.h">
|
<ClInclude Include="..\version\version.h">
|
||||||
|
65
regamedll/public/FileSystem.cpp
Normal file
65
regamedll/public/FileSystem.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the author gives permission to
|
||||||
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
|
* you do not wish to do so, delete this exception statement from your
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "precompiled.h"
|
||||||
|
|
||||||
|
IFileSystem *g_pFileSystem = nullptr;
|
||||||
|
CSysModule *g_pFileSystemModule = nullptr;
|
||||||
|
|
||||||
|
bool FileSystem_Init()
|
||||||
|
{
|
||||||
|
g_pFileSystemModule = Sys_LoadModule(STDIO_FILESYSTEM_LIB);
|
||||||
|
if (!g_pFileSystemModule)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get FileSystem interface
|
||||||
|
CreateInterfaceFn filesystemFactoryFn = Sys_GetFactory(g_pFileSystemModule);
|
||||||
|
if (!filesystemFactoryFn)
|
||||||
|
{
|
||||||
|
Sys_Error("Unable to get filesystem factory.");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pFileSystem = (IFileSystem *)filesystemFactoryFn(FILESYSTEM_INTERFACE_VERSION, nullptr);
|
||||||
|
if (!g_pFileSystem)
|
||||||
|
{
|
||||||
|
Sys_Error("Can not retrive filesystem interface version '" FILESYSTEM_INTERFACE_VERSION "'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSystem_Shutdown()
|
||||||
|
{
|
||||||
|
if (g_pFileSystemModule)
|
||||||
|
{
|
||||||
|
Sys_UnloadModule(g_pFileSystemModule);
|
||||||
|
g_pFileSystemModule = nullptr;
|
||||||
|
}
|
||||||
|
}
|
@ -199,3 +199,8 @@ public:
|
|||||||
#define IBaseFileSystem IFileSystem
|
#define IBaseFileSystem IFileSystem
|
||||||
|
|
||||||
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009"
|
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009"
|
||||||
|
|
||||||
|
bool FileSystem_Init();
|
||||||
|
void FileSystem_Shutdown();
|
||||||
|
|
||||||
|
extern IBaseFileSystem *g_pFileSystem;
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "hookchains_impl.h"
|
#include "hookchains_impl.h"
|
||||||
#include "regamedll.h"
|
#include "regamedll.h"
|
||||||
|
#include "FileSystem.h"
|
||||||
|
|
||||||
// API
|
// API
|
||||||
#include "API/CSInterfaces.h"
|
#include "API/CSInterfaces.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user