diff --git a/regamedll/dlls/bot/cs_bot_chatter.cpp b/regamedll/dlls/bot/cs_bot_chatter.cpp index 0fc17012..31bd03bb 100644 --- a/regamedll/dlls/bot/cs_bot_chatter.cpp +++ b/regamedll/dlls/bot/cs_bot_chatter.cpp @@ -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 diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index f64aca2e..fcf542d4 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -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(pEnt); diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index 51b5254f..ed6911cc 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -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); diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 3c688dc8..cac77a97 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -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) diff --git a/regamedll/dlls/h_export.cpp b/regamedll/dlls/h_export.cpp index ea3ed562..9fe93151 100644 --- a/regamedll/dlls/h_export.cpp +++ b/regamedll/dlls/h_export.cpp @@ -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(); } diff --git a/regamedll/msvc/ReGameDLL.vcxproj b/regamedll/msvc/ReGameDLL.vcxproj index 899a1031..e8b98c70 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj +++ b/regamedll/msvc/ReGameDLL.vcxproj @@ -521,6 +521,7 @@ + diff --git a/regamedll/msvc/ReGameDLL.vcxproj.filters b/regamedll/msvc/ReGameDLL.vcxproj.filters index 11d1fbea..f500892d 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj.filters +++ b/regamedll/msvc/ReGameDLL.vcxproj.filters @@ -556,6 +556,9 @@ dlls\addons + + public + diff --git a/regamedll/public/FileSystem.cpp b/regamedll/public/FileSystem.cpp new file mode 100644 index 00000000..3b0f0331 --- /dev/null +++ b/regamedll/public/FileSystem.cpp @@ -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; + } +} diff --git a/regamedll/public/FileSystem.h b/regamedll/public/FileSystem.h index 8e202baa..fcd7d57c 100644 --- a/regamedll/public/FileSystem.h +++ b/regamedll/public/FileSystem.h @@ -199,3 +199,8 @@ public: #define IBaseFileSystem IFileSystem #define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" + +bool FileSystem_Init(); +void FileSystem_Shutdown(); + +extern IBaseFileSystem *g_pFileSystem; diff --git a/regamedll/regamedll/precompiled.h b/regamedll/regamedll/precompiled.h index 2b9aa3df..0008e218 100644 --- a/regamedll/regamedll/precompiled.h +++ b/regamedll/regamedll/precompiled.h @@ -51,6 +51,7 @@ #include "interface.h" #include "hookchains_impl.h" #include "regamedll.h" +#include "FileSystem.h" // API #include "API/CSInterfaces.h"