mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-27 14:08:00 +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];
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
char soundDir[MAX_PATH];
|
||||
char filePath[MAX_PATH];
|
||||
|
||||
GET_GAME_DIR(soundDir);
|
||||
Q_strcat(soundDir, "\\sound\\");
|
||||
#endif
|
||||
|
||||
// Parse the BotChatter.db into BotPhrase collections
|
||||
@ -607,9 +603,9 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex)
|
||||
break;
|
||||
|
||||
#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;
|
||||
#endif
|
||||
|
||||
|
@ -57,7 +57,7 @@ DLL_FUNCTIONS gFunctionTable =
|
||||
NEW_DLL_FUNCTIONS gNewDLLFunctions =
|
||||
{
|
||||
&OnFreeEntPrivateData,
|
||||
nullptr,
|
||||
&OnGameShutdown,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr
|
||||
@ -1135,27 +1135,27 @@ void CBaseEntity::FireBuckshots(ULONG cShots, Vector vecSrc, Vector vecDirShooti
|
||||
{
|
||||
static int tracerCount;
|
||||
int tracer;
|
||||
|
||||
|
||||
TraceResult tr;
|
||||
Vector vecRight, vecUp;
|
||||
|
||||
|
||||
vecRight = gpGlobals->v_right;
|
||||
vecUp = gpGlobals->v_up;
|
||||
|
||||
|
||||
if (!pevAttacker)
|
||||
{
|
||||
// the default attacker is ourselves
|
||||
pevAttacker = pev;
|
||||
}
|
||||
|
||||
|
||||
ClearMultiDamage();
|
||||
gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB);
|
||||
|
||||
|
||||
for (ULONG iShot = 1; iShot <= cShots; iShot++)
|
||||
{
|
||||
// get circular gaussian spread
|
||||
float x, y, z;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5);
|
||||
@ -1163,19 +1163,19 @@ void CBaseEntity::FireBuckshots(ULONG cShots, Vector vecSrc, Vector vecDirShooti
|
||||
z = x * x + y * y;
|
||||
}
|
||||
while (z > 1);
|
||||
|
||||
|
||||
Vector vecDir, vecEnd;
|
||||
|
||||
|
||||
vecDir = vecDirShooting + x * vecSpread.x * vecRight + y * vecSpread.y * vecUp;
|
||||
vecEnd = vecSrc + vecDir * flDistance;
|
||||
|
||||
|
||||
UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr);
|
||||
tracer = 0;
|
||||
|
||||
|
||||
if (iTracerFreq != 0 && !(tracerCount++ % iTracerFreq))
|
||||
{
|
||||
Vector vecTracerSrc;
|
||||
|
||||
|
||||
if (IsPlayer())
|
||||
{
|
||||
// adjust tracer position for player
|
||||
@ -1185,11 +1185,11 @@ void CBaseEntity::FireBuckshots(ULONG cShots, Vector vecSrc, Vector vecDirShooti
|
||||
{
|
||||
vecTracerSrc = vecSrc;
|
||||
}
|
||||
|
||||
|
||||
// guns that always trace also always decal
|
||||
if (iTracerFreq != 1)
|
||||
tracer = 1;
|
||||
|
||||
|
||||
MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, vecTracerSrc);
|
||||
WRITE_BYTE(TE_TRACER);
|
||||
WRITE_COORD(vecTracerSrc.x);
|
||||
@ -1200,7 +1200,7 @@ void CBaseEntity::FireBuckshots(ULONG cShots, Vector vecSrc, Vector vecDirShooti
|
||||
WRITE_COORD(tr.vecEndPos.z);
|
||||
MESSAGE_END();
|
||||
}
|
||||
|
||||
|
||||
// do damage, paint decals
|
||||
if (tr.flFraction != 1.0f)
|
||||
{
|
||||
@ -1208,11 +1208,11 @@ void CBaseEntity::FireBuckshots(ULONG cShots, Vector vecSrc, Vector vecDirShooti
|
||||
float flDamage = ((1 - tr.flFraction) * iDamage);
|
||||
pEntity->TraceAttack(pevAttacker, int(flDamage), vecDir, &tr, DMG_BULLET);
|
||||
}
|
||||
|
||||
|
||||
// make bullet trails
|
||||
UTIL_BubbleTrail(vecSrc, tr.vecEndPos, int((flDistance * tr.flFraction) / 64));
|
||||
}
|
||||
|
||||
|
||||
ApplyMultiDamage(pev, pevAttacker);
|
||||
}
|
||||
|
||||
@ -1527,6 +1527,11 @@ void CBaseEntity::SUB_FadeOut()
|
||||
}
|
||||
}
|
||||
|
||||
void OnGameShutdown()
|
||||
{
|
||||
FileSystem_Shutdown();
|
||||
}
|
||||
|
||||
void OnFreeEntPrivateData(edict_t *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 SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount);
|
||||
EXT_FUNC void OnFreeEntPrivateData(edict_t *pEnt);
|
||||
EXT_FUNC void OnGameShutdown();
|
||||
|
||||
void SetObjectCollisionBox(entvars_t *pev);
|
||||
CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname);
|
||||
|
@ -990,17 +990,23 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
|
||||
|
||||
MESSAGE_END();
|
||||
|
||||
// echo to server console
|
||||
if (pszConsoleFormat)
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
// don't to type for listenserver
|
||||
if (IS_DEDICATED_SERVER())
|
||||
#endif
|
||||
{
|
||||
if (placeName && consoleUsesPlaceName)
|
||||
SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(pPlayer->pev->netname), placeName, text));
|
||||
// echo to server console
|
||||
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
|
||||
SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(pPlayer->pev->netname), text));
|
||||
}
|
||||
else
|
||||
{
|
||||
SERVER_PRINT(text);
|
||||
{
|
||||
SERVER_PRINT(text);
|
||||
}
|
||||
}
|
||||
|
||||
if (logmessages.value)
|
||||
|
@ -12,6 +12,7 @@ C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable, global
|
||||
Q_memcpy(&g_engfuncs, pEnginefuncsTable, sizeof(enginefuncs_t));
|
||||
gpGlobals = pGlobals;
|
||||
|
||||
FileSystem_Init();
|
||||
Regamedll_Game_Init();
|
||||
}
|
||||
|
||||
|
@ -521,6 +521,7 @@
|
||||
<ClCompile Include="..\pm_shared\pm_debug.cpp" />
|
||||
<ClCompile Include="..\pm_shared\pm_math.cpp" />
|
||||
<ClCompile Include="..\pm_shared\pm_shared.cpp" />
|
||||
<ClCompile Include="..\public\FileSystem.cpp" />
|
||||
<ClCompile Include="..\public\interface.cpp" />
|
||||
<ClCompile Include="..\public\MemPool.cpp" />
|
||||
<ClCompile Include="..\public\tier0\dbg.cpp">
|
||||
|
@ -556,6 +556,9 @@
|
||||
<ClCompile Include="..\dlls\addons\point_command.cpp">
|
||||
<Filter>dlls\addons</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\FileSystem.cpp">
|
||||
<Filter>public</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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 FILESYSTEM_INTERFACE_VERSION "VFileSystem009"
|
||||
|
||||
bool FileSystem_Init();
|
||||
void FileSystem_Shutdown();
|
||||
|
||||
extern IBaseFileSystem *g_pFileSystem;
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "interface.h"
|
||||
#include "hookchains_impl.h"
|
||||
#include "regamedll.h"
|
||||
#include "FileSystem.h"
|
||||
|
||||
// API
|
||||
#include "API/CSInterfaces.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user