mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-16 00:28:20 +03:00
Implemented SystemWrapper.cpp (#467)
Launcher Refactoring Simplified code #393
This commit is contained in:
parent
18f75dadf4
commit
4663183f7a
@ -216,6 +216,12 @@ class RehldsSrc {
|
||||
if (GradleCppUtils.windows) include "rehlds_debug.cpp"
|
||||
}
|
||||
}
|
||||
h.rehlds_common(CppSourceSet) {
|
||||
source {
|
||||
srcDirs "common"
|
||||
include "BaseSystemModule.cpp", "ObjectList.cpp", "TokenLine.cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rehlds_pch(def h) {
|
||||
|
@ -29,9 +29,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "event_args.h"
|
||||
#include "vmodes.h"
|
||||
#include "cdll_int.h"
|
||||
|
||||
class IBaseSystem;
|
||||
class ISystemModule;
|
||||
|
||||
class IEngineWrapper {
|
||||
public:
|
||||
virtual ~IEngineWrapper() {}
|
||||
@ -64,7 +67,7 @@ public:
|
||||
virtual void DemoUpdateClientData(client_data_t *cdat) = 0;
|
||||
virtual void CL_QueueEvent(int flags, int index, float delay, event_args_t *pargs) = 0;
|
||||
virtual void HudWeaponAnim(int iAnim, int body) = 0;
|
||||
virtual void CL_DemoPlaySound(int channel, char* sample, float attenuation, float volume, int flags, int pitch) = 0;
|
||||
virtual void CL_DemoPlaySound(int channel, char *sample, float attenuation, float volume, int flags, int pitch) = 0;
|
||||
virtual void ClientDLL_ReadDemoBuffer(int size, unsigned char *buffer) = 0;
|
||||
};
|
||||
|
||||
|
@ -99,7 +99,7 @@ bool CTextConsoleUnix::Init(IBaseSystem *system)
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &termNew);
|
||||
sigprocmask(SIG_UNBLOCK, &block_ttou, NULL);
|
||||
|
||||
return CTextConsole::Init();
|
||||
return CTextConsole::Init(system);
|
||||
}
|
||||
|
||||
void CTextConsoleUnix::ShutDown()
|
||||
|
@ -89,8 +89,7 @@ bool CTextConsoleWin32::Init(IBaseSystem *system)
|
||||
hinput = GetStdHandle(STD_INPUT_HANDLE);
|
||||
houtput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
if (!SetConsoleCtrlHandler(&ConsoleHandlerRoutine, TRUE))
|
||||
{
|
||||
if (!SetConsoleCtrlHandler(&ConsoleHandlerRoutine, TRUE)) {
|
||||
Print("WARNING! TextConsole::Init: Could not attach console hook.\n");
|
||||
}
|
||||
|
||||
@ -122,8 +121,9 @@ char *CTextConsoleWin32::GetLine()
|
||||
|
||||
if (!GetNumberOfConsoleInputEvents(hinput, &numevents))
|
||||
{
|
||||
if (m_System)
|
||||
m_System->Errorf("CTextConsoleWin32::GetLine: !GetNumberOfConsoleInputEvents");
|
||||
if (m_System) {
|
||||
m_System->Errorf("CTextConsoleWin32::GetLine: !GetNumberOfConsoleInputEvents\n");
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -133,8 +133,10 @@ char *CTextConsoleWin32::GetLine()
|
||||
|
||||
if (!ReadConsoleInput(hinput, recs, ARRAYSIZE(recs), &numread))
|
||||
{
|
||||
if (m_System)
|
||||
m_System->Errorf("CTextConsoleWin32::GetLine: !ReadConsoleInput");
|
||||
if (m_System) {
|
||||
m_System->Errorf("CTextConsoleWin32::GetLine: !ReadConsoleInput\n");
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,11 @@ bool CTextConsole::Init(IBaseSystem *system)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CTextConsole::InitSystem(IBaseSystem *system)
|
||||
{
|
||||
m_System = system;
|
||||
}
|
||||
|
||||
void CTextConsole::SetVisible(bool visible)
|
||||
{
|
||||
m_ConsoleVisible = visible;
|
||||
@ -158,22 +163,13 @@ void CTextConsole::ReceiveBackspace()
|
||||
|
||||
void CTextConsole::ReceiveTab()
|
||||
{
|
||||
#ifndef LAUNCHER_FIXES
|
||||
if (!m_System)
|
||||
return;
|
||||
#else
|
||||
if (!rehldsFuncs || !m_nConsoleTextLen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
ObjectList matches;
|
||||
m_szConsoleText[ m_nConsoleTextLen ] = '\0';
|
||||
#ifndef LAUNCHER_FIXES
|
||||
m_System->GetCommandMatches(m_szConsoleText, &matches);
|
||||
#else
|
||||
rehldsFuncs->GetCommandMatches(m_szConsoleText, &matches);
|
||||
#endif
|
||||
|
||||
if (matches.IsEmpty())
|
||||
return;
|
||||
|
||||
@ -199,7 +195,7 @@ void CTextConsole::ReceiveTab()
|
||||
int nSmallestCmd = 0;
|
||||
int nCurrentColumn;
|
||||
int nTotalColumns;
|
||||
char szCommonCmd[256];//Should be enough.
|
||||
char szCommonCmd[256]; // Should be enough.
|
||||
char szFormatCmd[256];
|
||||
char *pszSmallestCmd;
|
||||
char *pszCurrentCmd = (char *)matches.GetFirst();
|
||||
@ -224,6 +220,7 @@ void CTextConsole::ReceiveTab()
|
||||
|
||||
Echo("\n");
|
||||
Q_strcpy(szCommonCmd, pszSmallestCmd);
|
||||
|
||||
// Would be nice if these were sorted, but not that big a deal
|
||||
pszCurrentCmd = (char *)matches.GetFirst();
|
||||
while (pszCurrentCmd)
|
||||
@ -236,7 +233,7 @@ void CTextConsole::ReceiveTab()
|
||||
|
||||
_snprintf(szFormatCmd, sizeof(szFormatCmd), "%-*s ", nLongestCmd, pszCurrentCmd);
|
||||
Echo(szFormatCmd);
|
||||
for (char *pCur = pszCurrentCmd, *pCommon = szCommonCmd; (*pCur&&*pCommon); pCur++, pCommon++)
|
||||
for (char *pCur = pszCurrentCmd, *pCommon = szCommonCmd; (*pCur && *pCommon); pCur++, pCommon++)
|
||||
{
|
||||
if (*pCur != *pCommon)
|
||||
{
|
||||
@ -244,6 +241,7 @@ void CTextConsole::ReceiveTab()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pszCurrentCmd = (char *)matches.GetNext();
|
||||
}
|
||||
|
||||
|
@ -54,14 +54,16 @@ public:
|
||||
virtual void SetVisible(bool visible);
|
||||
virtual bool IsVisible();
|
||||
|
||||
void InitSystem(IBaseSystem *system);
|
||||
|
||||
protected:
|
||||
char m_szConsoleText[MAX_CONSOLE_TEXTLEN]; // console text buffer
|
||||
int m_nConsoleTextLen; // console textbuffer length
|
||||
int m_nCursorPosition; // position in the current input line
|
||||
int m_nConsoleTextLen; // console textbuffer length
|
||||
int m_nCursorPosition; // position in the current input line
|
||||
|
||||
// Saved input data when scrolling back through command history
|
||||
char m_szSavedConsoleText[MAX_CONSOLE_TEXTLEN]; // console text buffer
|
||||
int m_nSavedConsoleTextLen; // console textbuffer length
|
||||
char m_szSavedConsoleText[MAX_CONSOLE_TEXTLEN]; // console text buffer
|
||||
int m_nSavedConsoleTextLen; // console textbuffer length
|
||||
|
||||
char m_aszLineBuffer[MAX_BUFFER_LINES][MAX_CONSOLE_TEXTLEN]; // command buffer last MAX_BUFFER_LINES commands
|
||||
int m_nInputLine; // Current line being entered
|
||||
|
@ -59,7 +59,7 @@
|
||||
<PreprocessorDefinitions>WIN32;LAUNCHER_FIXES;_DEBUG;DEDICATED;_CRT_SECURE_NO_WARNINGS;USE_BREAKPAD_HANDLER;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\;$(ProjectDir)..\src\;$(ProjectDir)..\..\common;$(ProjectDir)..\..\engine;$(ProjectDir)..\..\public;$(ProjectDir)..\..\public\rehlds;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\src;$(ProjectDir)..\..\;$(ProjectDir)..\..\common;$(ProjectDir)..\..\engine;$(ProjectDir)..\..\public;$(ProjectDir)..\..\public\rehlds;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -100,7 +100,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;LAUNCHER_FIXES;NDEBUG;DEDICATED;_CRT_SECURE_NO_WARNINGS;USE_BREAKPAD_HANDLER;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\;$(ProjectDir)..\..\common;$(ProjectDir)..\..\engine;$(ProjectDir)..\..\public;$(ProjectDir)..\..\public\rehlds;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\src;$(ProjectDir)..\..\;$(ProjectDir)..\..\common;$(ProjectDir)..\..\engine;$(ProjectDir)..\..\public;$(ProjectDir)..\..\public\rehlds;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
@ -142,8 +142,15 @@
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\common\ObjectList.h" />
|
||||
<ClInclude Include="..\..\common\SteamAppStartUp.h" />
|
||||
<ClInclude Include="..\..\common\textconsole.h" />
|
||||
<ClInclude Include="..\..\common\TextConsoleUnix.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\common\TextConsoleWin32.h" />
|
||||
<ClInclude Include="..\src\conproc.h" />
|
||||
<ClInclude Include="..\src\dbg.h" />
|
||||
<ClInclude Include="..\src\dedicated.h" />
|
||||
<ClInclude Include="..\src\precompiled.h" />
|
||||
<ClInclude Include="..\src\sys_ded.h" />
|
||||
@ -165,7 +172,6 @@
|
||||
<ClCompile Include="..\..\common\TextConsoleWin32.cpp" />
|
||||
<ClCompile Include="..\..\engine\mem.cpp" />
|
||||
<ClCompile Include="..\src\conproc.cpp" />
|
||||
<ClCompile Include="..\src\dbg.cpp" />
|
||||
<ClCompile Include="..\src\dedicated_exports.cpp" />
|
||||
<ClCompile Include="..\src\precompiled.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
|
@ -8,10 +8,10 @@
|
||||
<Filter Include="src\vgui">
|
||||
<UniqueIdentifier>{711de26d-f116-48c0-96c0-5d4189574ad1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\common">
|
||||
<Filter Include="common">
|
||||
<UniqueIdentifier>{c464f3ce-2fb5-4a0e-bda1-388b49b46871}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\engine">
|
||||
<Filter Include="engine">
|
||||
<UniqueIdentifier>{565e56ff-60b6-4708-9749-010284e122a1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
@ -20,9 +20,6 @@
|
||||
<ClInclude Include="..\src\precompiled.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\dbg.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\sys_ded.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
@ -35,11 +32,23 @@
|
||||
<ClInclude Include="..\src\vgui\vguihelpers.h">
|
||||
<Filter>src\vgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\common\ObjectList.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\common\textconsole.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\common\TextConsoleUnix.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\common\TextConsoleWin32.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\common\SteamAppStartUp.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\dbg.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\sys_ded.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
@ -65,22 +74,22 @@
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\common\ObjectList.cpp">
|
||||
<Filter>src\common</Filter>
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\common\TextConsoleUnix.cpp">
|
||||
<Filter>src\common</Filter>
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\common\TextConsoleWin32.cpp">
|
||||
<Filter>src\common</Filter>
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\common\textconsole.cpp">
|
||||
<Filter>src\common</Filter>
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\common\SteamAppStartUp.cpp">
|
||||
<Filter>src\common</Filter>
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\engine\mem.cpp">
|
||||
<Filter>src\engine</Filter>
|
||||
<Filter>engine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\common\commandline.cpp">
|
||||
<Filter>src</Filter>
|
||||
|
@ -1,18 +1,44 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
static HANDLE heventDone;
|
||||
static HANDLE hfileBuffer;
|
||||
static HANDLE heventChildSend;
|
||||
static HANDLE heventParentSend;
|
||||
static HANDLE hStdout;
|
||||
static HANDLE hStdin;
|
||||
HANDLE heventDone;
|
||||
HANDLE hfileBuffer;
|
||||
HANDLE heventChildSend;
|
||||
HANDLE heventParentSend;
|
||||
HANDLE hStdout;
|
||||
HANDLE hStdin;
|
||||
|
||||
BOOL SetConsoleCXCY(HANDLE hStdout, int cx, int cy)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
||||
COORD coordMax;
|
||||
|
||||
coordMax = GetLargestConsoleWindowSize(hStdout);
|
||||
COORD coordMax = GetLargestConsoleWindowSize(hStdout);
|
||||
|
||||
if (cy > coordMax.Y)
|
||||
cy = coordMax.Y;
|
||||
@ -113,12 +139,11 @@ BOOL ReadText(LPTSTR pszText, int iBeginLine, int iEndLine)
|
||||
{
|
||||
COORD coord;
|
||||
DWORD dwRead;
|
||||
BOOL bRet;
|
||||
|
||||
coord.X = 0;
|
||||
coord.Y = iBeginLine;
|
||||
|
||||
bRet = ReadConsoleOutputCharacter(hStdout, pszText, 80 * (iEndLine - iBeginLine + 1), coord, &dwRead);
|
||||
BOOL bRet = ReadConsoleOutputCharacter(hStdout, pszText, 80 * (iEndLine - iBeginLine + 1), coord, &dwRead);
|
||||
|
||||
// Make sure it's null terminated.
|
||||
if (bRet)
|
||||
@ -183,23 +208,21 @@ BOOL WriteText(LPCTSTR szText)
|
||||
|
||||
unsigned __stdcall RequestProc(void *arg)
|
||||
{
|
||||
int *pBuffer;
|
||||
DWORD dwRet;
|
||||
HANDLE heventWait[2];
|
||||
int iBeginLine, iEndLine;
|
||||
|
||||
heventWait[0] = heventParentSend;
|
||||
heventWait[1] = heventDone;
|
||||
|
||||
while (1)
|
||||
while (true)
|
||||
{
|
||||
dwRet = WaitForMultipleObjects(2, heventWait, FALSE, INFINITE);
|
||||
DWORD dwRet = WaitForMultipleObjects(2, heventWait, FALSE, INFINITE);
|
||||
|
||||
// heventDone fired, so we're exiting.
|
||||
if (dwRet == WAIT_OBJECT_0 + 1)
|
||||
break;
|
||||
|
||||
pBuffer = (int *)GetMappedBuffer(hfileBuffer);
|
||||
int *pBuffer = (int *)GetMappedBuffer(hfileBuffer);
|
||||
|
||||
// hfileBuffer is invalid. Just leave.
|
||||
if (!pBuffer)
|
||||
@ -284,14 +307,14 @@ void InitConProc()
|
||||
heventChildSend = heventChild;
|
||||
|
||||
// So we'll know when to go away.
|
||||
heventDone = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
heventDone = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
if (!heventDone)
|
||||
{
|
||||
sys->Printf("InitConProc: Couldn't create heventDone\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_beginthreadex(NULL, 0, RequestProc, NULL, 0, &threadAddr))
|
||||
if (!_beginthreadex(nullptr, 0, RequestProc, nullptr, 0, &threadAddr))
|
||||
{
|
||||
CloseHandle(heventDone);
|
||||
sys->Printf("InitConProc: Couldn't create third party thread\n");
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef CONPROC_H
|
||||
#define CONPROC_H
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <process.h>
|
||||
|
||||
@ -13,5 +37,3 @@
|
||||
|
||||
void InitConProc();
|
||||
void DeinitConProc();
|
||||
|
||||
#endif // CONPROC_H
|
||||
|
@ -1,3 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -13,11 +41,6 @@ typedef void (*SleepType)(int msec);
|
||||
extern bool g_bVGui;
|
||||
extern IDedicatedServerAPI *engineAPI;
|
||||
|
||||
#ifdef LAUNCHER_FIXES
|
||||
extern IRehldsApi *rehldsApi;
|
||||
extern const RehldsFuncs_t* rehldsFuncs;
|
||||
#endif
|
||||
|
||||
bool Sys_SetupConsole();
|
||||
void Sys_PrepareConsoleInput();
|
||||
void Sys_InitPingboost();
|
||||
|
@ -1,3 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
class CDedicatedExports: public IDedicatedExports {
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef ISYS_H
|
||||
#define ISYS_H
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class ISys {
|
||||
public:
|
||||
@ -27,5 +51,3 @@ public:
|
||||
};
|
||||
|
||||
extern ISys *sys;
|
||||
|
||||
#endif // ISYS_H
|
||||
|
@ -13,13 +13,6 @@
|
||||
#include "icommandline.h"
|
||||
#include "isys.h"
|
||||
#include "dll_state.h"
|
||||
|
||||
#ifdef LAUNCHER_FIXES
|
||||
struct DLL_FUNCTIONS;
|
||||
#include "cvardef.h"
|
||||
#include "rehlds_api.h"
|
||||
#endif
|
||||
|
||||
#include "dedicated.h"
|
||||
|
||||
#include "sys_ded.h"
|
||||
|
@ -1,3 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
bool g_bVGui = false;
|
||||
@ -6,10 +34,6 @@ bool g_bAppHasBeenTerminated = false;
|
||||
|
||||
CSysModule *g_pEngineModule = nullptr;
|
||||
IDedicatedServerAPI *engineAPI = nullptr;
|
||||
#ifdef LAUNCHER_FIXES
|
||||
IRehldsApi *rehldsApi = nullptr;
|
||||
const RehldsFuncs_t* rehldsFuncs = nullptr;
|
||||
#endif
|
||||
|
||||
IFileSystem *g_pFileSystemInterface = nullptr;
|
||||
CSysModule *g_pFileSystemModule = nullptr;
|
||||
@ -79,29 +103,25 @@ int RunEngine()
|
||||
CreateInterfaceFn engineFactory = Sys_GetFactory(g_pEngineModule);
|
||||
RunVGUIFrame();
|
||||
|
||||
if (engineFactory)
|
||||
{
|
||||
if (engineFactory) {
|
||||
engineAPI = (IDedicatedServerAPI *)engineFactory(VENGINE_HLDS_API_VERSION, nullptr);
|
||||
#ifdef LAUNCHER_FIXES
|
||||
rehldsApi = (IRehldsApi *)engineFactory(VREHLDS_HLDS_API_VERSION, NULL);
|
||||
if (rehldsApi)
|
||||
{
|
||||
if (rehldsApi->GetMajorVersion() != REHLDS_API_VERSION_MAJOR || rehldsApi->GetMinorVersion() < REHLDS_API_VERSION_MINOR)
|
||||
{
|
||||
rehldsApi = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
rehldsFuncs = rehldsApi->GetFuncs();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
RunVGUIFrame();
|
||||
if (!engineAPI || !engineAPI->Init(UTIL_GetBaseDir(), (char *)CommandLine()->GetCmdLine(), Sys_GetFactoryThis(), g_FilesystemFactoryFn)) {
|
||||
return LAUNCHER_ERROR;
|
||||
}
|
||||
|
||||
#ifdef LAUNCHER_FIXES
|
||||
if (engineFactory)
|
||||
{
|
||||
ISystemModule *pSystemWrapper = (ISystemModule *)engineFactory(BASESYSTEM_INTERFACE_VERSION, nullptr);
|
||||
if (pSystemWrapper) {
|
||||
console.InitSystem(pSystemWrapper->GetSystem());
|
||||
}
|
||||
}
|
||||
#endif // LANUCHER_FIXES
|
||||
|
||||
RunVGUIFrame();
|
||||
|
||||
#ifdef VGUI
|
||||
@ -256,7 +276,6 @@ int StartServer(char* cmdline)
|
||||
#endif
|
||||
{
|
||||
int ret = RunEngine();
|
||||
|
||||
if (ret == LAUNCHER_ERROR) {
|
||||
sys->ErrorMessage(0, "Failed to launch engine.\n");
|
||||
return LAUNCHER_ERROR;
|
||||
|
@ -1,9 +1,32 @@
|
||||
#pragma once
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
void Load3rdParty();
|
||||
void Sys_Printf_Safe(char *text);
|
||||
void Sys_Printf(char *fmt, ...);
|
||||
void _log(const char *fmt, ...);
|
||||
#pragma once
|
||||
|
||||
extern char *gpszCvars;
|
||||
extern bool g_bAppHasBeenTerminated;
|
||||
@ -12,9 +35,8 @@ extern CSysModule *g_pEngineModule;
|
||||
extern CSysModule *g_pFileSystemModule;
|
||||
extern CreateInterfaceFn g_FilesystemFactoryFn;
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOL WINAPI MyHandlerRoutine(DWORD CtrlType);
|
||||
#endif // _WIN32
|
||||
|
||||
int RunEngine();
|
||||
int StartServer(char* cmdline);
|
||||
|
||||
void Sys_Printf_Safe(char *text);
|
||||
void Sys_Printf(char *fmt, ...);
|
||||
|
@ -1,3 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
class CSys: public ISys {
|
||||
@ -5,22 +33,22 @@ public:
|
||||
CSys();
|
||||
virtual ~CSys();
|
||||
|
||||
void Sleep(int msec);
|
||||
bool GetExecutableName(char *out);
|
||||
NORETURN void ErrorMessage(int level, const char *msg);
|
||||
void Sleep(int msec) override;
|
||||
bool GetExecutableName(char *out) override;
|
||||
NORETURN void ErrorMessage(int level, const char *msg) override;
|
||||
|
||||
void WriteStatusText(char *szText);
|
||||
void UpdateStatus(int force);
|
||||
void WriteStatusText(char *szText) override;
|
||||
void UpdateStatus(int force) override;
|
||||
|
||||
long LoadLibrary(char *lib);
|
||||
void FreeLibrary(long library);
|
||||
long LoadLibrary(char *lib) override;
|
||||
void FreeLibrary(long library) override;
|
||||
|
||||
bool CreateConsoleWindow();
|
||||
void DestroyConsoleWindow();
|
||||
bool CreateConsoleWindow() override;
|
||||
void DestroyConsoleWindow() override;
|
||||
|
||||
void ConsoleOutput(char *string);
|
||||
char *ConsoleInput();
|
||||
void Printf(char *fmt, ...);
|
||||
void ConsoleOutput(char *string) override;
|
||||
char *ConsoleInput() override;
|
||||
void Printf(char *fmt, ...) override;
|
||||
};
|
||||
|
||||
CSys g_Sys;
|
||||
@ -71,13 +99,13 @@ void Sleep_Select(int msec)
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 1000 * msec;
|
||||
|
||||
select(1, NULL, NULL, NULL, &tv);
|
||||
select(1, nullptr, nullptr, nullptr, &tv);
|
||||
}
|
||||
|
||||
void Sleep_Net(int msec)
|
||||
{
|
||||
NET_Sleep_Timeout();
|
||||
}
|
||||
}
|
||||
|
||||
// linux runs on a 100Hz scheduling clock, so the minimum latency from
|
||||
// usleep is 10msec. However, people want lower latency than this..
|
||||
@ -102,7 +130,7 @@ void Sleep_Timer(int msec)
|
||||
g_bPaused = false;
|
||||
|
||||
// set the timer to trigger
|
||||
if (!setitimer(ITIMER_REAL, &tm, NULL)) {
|
||||
if (!setitimer(ITIMER_REAL, &tm, nullptr)) {
|
||||
// wait for the signal
|
||||
pause();
|
||||
}
|
||||
@ -133,28 +161,27 @@ void Sys_InitPingboost()
|
||||
Sys_Sleep = Sleep_Old;
|
||||
|
||||
char *pPingType;
|
||||
int type;
|
||||
if (CommandLine()->CheckParm("-pingboost", &pPingType) && pPingType) {
|
||||
type = atoi(pPingType);
|
||||
int type = atoi(pPingType);
|
||||
switch (type) {
|
||||
case 1:
|
||||
signal(SIGALRM, alarmFunc);
|
||||
Sys_Sleep = Sleep_Timer;
|
||||
break;
|
||||
signal(SIGALRM, alarmFunc);
|
||||
Sys_Sleep = Sleep_Timer;
|
||||
break;
|
||||
case 2:
|
||||
Sys_Sleep = Sleep_Select;
|
||||
break;
|
||||
Sys_Sleep = Sleep_Select;
|
||||
break;
|
||||
case 3:
|
||||
Sys_Sleep = Sleep_Net;
|
||||
Sys_Sleep = Sleep_Net;
|
||||
|
||||
// we Sys_GetProcAddress NET_Sleep() from
|
||||
//engine_i486.so later in this function
|
||||
NET_Sleep_Timeout = (NET_Sleep_t)Sys_GetProcAddress(g_pEngineModule, "NET_Sleep_Timeout");
|
||||
break;
|
||||
// we Sys_GetProcAddress NET_Sleep() from
|
||||
//engine_i486.so later in this function
|
||||
NET_Sleep_Timeout = (NET_Sleep_t)Sys_GetProcAddress(g_pEngineModule, "NET_Sleep_Timeout");
|
||||
break;
|
||||
// just in case
|
||||
default:
|
||||
Sys_Sleep = Sleep_Old;
|
||||
break;
|
||||
Sys_Sleep = Sleep_Old;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,32 @@
|
||||
#include "precompiled.h"
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
class CSys: public ISys {
|
||||
public:
|
||||
@ -47,7 +75,7 @@ void CSys::Sleep(int msec)
|
||||
|
||||
bool CSys::GetExecutableName(char *out)
|
||||
{
|
||||
if (!::GetModuleFileName((HINSTANCE)GetModuleHandle(NULL), out, 256))
|
||||
if (!::GetModuleFileName((HINSTANCE)GetModuleHandle(nullptr), out, 256))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -55,7 +83,7 @@ bool CSys::GetExecutableName(char *out)
|
||||
|
||||
void CSys::ErrorMessage(int level, const char *msg)
|
||||
{
|
||||
MessageBox(NULL, msg, "Half-Life Dedicated Server Error", MB_OK);
|
||||
MessageBox(nullptr, msg, "Half-Life Dedicated Server Error", MB_OK);
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
@ -67,7 +95,6 @@ void CSys::WriteStatusText(char *szText)
|
||||
void CSys::UpdateStatus(int force)
|
||||
{
|
||||
static double tLast = 0.0;
|
||||
double tCurrent;
|
||||
char szStatus[256];
|
||||
int n, nMax;
|
||||
char szMap[32];
|
||||
@ -76,7 +103,7 @@ void CSys::UpdateStatus(int force)
|
||||
if (!engineAPI)
|
||||
return;
|
||||
|
||||
tCurrent = (double)timeGetTime() * 0.001;
|
||||
double tCurrent = timeGetTime() * 0.001;
|
||||
engineAPI->UpdateStatus(&fps, &n, &nMax, szMap);
|
||||
|
||||
if (!force)
|
||||
@ -190,8 +217,8 @@ bool Sys_SetupConsole()
|
||||
void Sys_PrepareConsoleInput()
|
||||
{
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
|
||||
if (!GetMessage(&msg, NULL, 0, 0)) {
|
||||
while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) {
|
||||
if (!GetMessage(&msg, nullptr, 0, 0)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -202,7 +229,7 @@ void Sys_PrepareConsoleInput()
|
||||
|
||||
void Sys_InitPingboost()
|
||||
{
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||
|
@ -1,3 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
CSysModule *g_pVGUIModule = nullptr;
|
||||
|
@ -1,8 +1,37 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
int StartVGUI();
|
||||
void StopVGUI();
|
||||
void RunVGUIFrame();
|
||||
|
||||
bool VGUIIsRunning();
|
||||
bool VGUIIsStopping();
|
||||
bool VGUIIsInConfig();
|
||||
|
749
rehlds/engine/SystemWrapper.cpp
Normal file
749
rehlds/engine/SystemWrapper.cpp
Normal file
@ -0,0 +1,749 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
SystemWrapper gSystemWrapper;
|
||||
|
||||
void SystemWrapper_Init()
|
||||
{
|
||||
gSystemWrapper.Init(&gSystemWrapper, 0, "SystemWrapper");
|
||||
}
|
||||
|
||||
void SystemWrapper_RunFrame(double time)
|
||||
{
|
||||
gSystemWrapper.RunFrame(time);
|
||||
}
|
||||
|
||||
void SystemWrapper_ShutDown()
|
||||
{
|
||||
gSystemWrapper.ShutDown();
|
||||
}
|
||||
|
||||
BOOL SystemWrapper_LoadModule(char *interfacename, char *library, char *instancename)
|
||||
{
|
||||
if (gSystemWrapper.GetModule(interfacename, library, instancename)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void SystemWrapper_ExecuteString(char *command)
|
||||
{
|
||||
gSystemWrapper.ExecuteString(command);
|
||||
}
|
||||
|
||||
void SystemWrapper_CommandForwarder()
|
||||
{
|
||||
char cmd[MAX_CMD_LINE];
|
||||
Q_strcpy(cmd, Cmd_Argv(0));
|
||||
|
||||
if (Cmd_Argc() > 1)
|
||||
{
|
||||
Q_strcat(cmd, " ");
|
||||
Q_strcat(cmd, Cmd_Args());
|
||||
}
|
||||
|
||||
cmd[sizeof(cmd) - 1] = '\0';
|
||||
|
||||
if (cmd[0]) {
|
||||
SystemWrapper_ExecuteString(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
char *SystemWrapper::CheckParam(char *param)
|
||||
{
|
||||
int pos = COM_CheckParm(param);
|
||||
if (pos)
|
||||
{
|
||||
if ((pos + 1) >= com_argc) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return com_argv[pos + 1];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SystemWrapper::Errorf(char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
va_start(argptr, fmt);
|
||||
Q_vsnprintf(string, sizeof(string), fmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
Printf("***** FATAL ERROR *****\n");
|
||||
Printf("%s", string);
|
||||
Printf("*** STOPPING SYSTEM ***\n");
|
||||
|
||||
Stop();
|
||||
}
|
||||
|
||||
char *SystemWrapper::GetStatusLine()
|
||||
{
|
||||
return "No status available.\n";
|
||||
}
|
||||
|
||||
bool SystemWrapper::Init(IBaseSystem *system, int serial, char *name)
|
||||
{
|
||||
BaseSystemModule::Init(system, serial, name);
|
||||
|
||||
m_Commands.Init();
|
||||
m_Modules.Init();
|
||||
m_Libraries.Init();
|
||||
m_Listener.Init();
|
||||
|
||||
m_EngineWrapper = new EngineWrapper;
|
||||
|
||||
AddModule((ISystemModule *)m_EngineWrapper, ENGINEWRAPPER_INTERFACE_VERSION);
|
||||
m_State = MODULE_RUNNING;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SystemWrapper::Stop()
|
||||
{
|
||||
m_State = MODULE_DISCONNECTED;
|
||||
}
|
||||
|
||||
void SystemWrapper::ShutDown()
|
||||
{
|
||||
m_Listener.Clear();
|
||||
m_Commands.Clear(true);
|
||||
|
||||
ISystemModule *module = (ISystemModule *)m_Modules.GetFirst();
|
||||
while (module)
|
||||
{
|
||||
module->ShutDown();
|
||||
module = (ISystemModule *)m_Modules.GetNext();
|
||||
}
|
||||
|
||||
library_t *lib = (library_t *)m_Libraries.RemoveTail();
|
||||
while (lib)
|
||||
{
|
||||
if (lib->handle) {
|
||||
Sys_UnloadModule(lib->handle);
|
||||
}
|
||||
|
||||
Mem_Free(lib);
|
||||
lib = (library_t *)m_Libraries.RemoveTail();
|
||||
}
|
||||
|
||||
if (m_EngineWrapper) {
|
||||
delete m_EngineWrapper;
|
||||
m_EngineWrapper = nullptr;
|
||||
}
|
||||
|
||||
Cmd_RemoveWrapperCmds();
|
||||
m_State = MODULE_DISCONNECTED;
|
||||
}
|
||||
|
||||
void SystemWrapper::ExecuteCommand(int commandID, char *commandLine)
|
||||
{
|
||||
switch (commandID)
|
||||
{
|
||||
case CMD_ID_MODULES:
|
||||
CMD_Modules(commandLine);
|
||||
break;
|
||||
case CMD_ID_LOADMODULE:
|
||||
CMD_LoadModule(commandLine);
|
||||
break;
|
||||
case CMD_ID_UNLOADMODULE:
|
||||
CMD_UnloadModule(commandLine);
|
||||
break;
|
||||
default:
|
||||
Printf("SystemWrapper::ExecuteCommand: unknown command ID %i.\n", commandID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SystemWrapper::CMD_LoadModule(char *cmdLine)
|
||||
{
|
||||
TokenLine params(cmdLine);
|
||||
if (params.CountToken() < 2) {
|
||||
Printf("Syntax: loadmodule <module> [<library>] [<name>]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (params.CountToken()) {
|
||||
case 2:
|
||||
GetModule(params.GetToken(1), params.GetToken(1));
|
||||
break;
|
||||
case 3:
|
||||
GetModule(params.GetToken(1), params.GetToken(2));
|
||||
break;
|
||||
default:
|
||||
GetModule(params.GetToken(1), params.GetToken(2), params.GetToken(3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SystemWrapper::CMD_UnloadModule(char *cmdLine)
|
||||
{
|
||||
TokenLine params(cmdLine);
|
||||
if (params.CountToken() < 2) {
|
||||
Printf("Syntax: unloadmodule <module> [<name>]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ISystemModule *module = nullptr;
|
||||
switch (params.CountToken()) {
|
||||
case 2:
|
||||
module = FindModule(params.GetToken(1));
|
||||
break;
|
||||
case 3:
|
||||
module = FindModule(params.GetToken(1), params.GetToken(2));
|
||||
break;
|
||||
}
|
||||
|
||||
if (!module) {
|
||||
Printf("Module not found.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveModule(module);
|
||||
}
|
||||
|
||||
SystemWrapper::library_t *SystemWrapper::GetLibrary(char *name)
|
||||
{
|
||||
char fixedname[MAX_PATH];
|
||||
strcopy(fixedname, name);
|
||||
COM_FixSlashes(fixedname);
|
||||
|
||||
library_t *lib = (library_t *)m_Libraries.GetFirst();
|
||||
while (lib)
|
||||
{
|
||||
if (Q_stricmp(lib->name, name) == 0) {
|
||||
return lib;
|
||||
}
|
||||
|
||||
lib = (library_t *)m_Libraries.GetNext();
|
||||
}
|
||||
|
||||
lib = (library_t *)Mem_Malloc(sizeof(library_t));
|
||||
if (!lib) {
|
||||
DPrintf("ERROR! System::GetLibrary: out of memory (%s).\n", name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Q_snprintf(lib->name, sizeof(lib->name), "%s." LIBRARY_PREFIX, fixedname);
|
||||
FS_GetLocalCopy(lib->name);
|
||||
|
||||
lib->handle = (CSysModule *)Sys_LoadModule(lib->name);
|
||||
if (!lib->handle) {
|
||||
DPrintf("ERROR! System::GetLibrary: coulnd't load library (%s).\n", lib->name);
|
||||
Mem_Free(lib);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
lib->createInterfaceFn = (CreateInterfaceFn)Sys_GetFactory(lib->handle);
|
||||
if (!lib->createInterfaceFn) {
|
||||
DPrintf("ERROR! System::GetLibrary: coulnd't get object factory(%s).\n", lib->name);
|
||||
Mem_Free(lib);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_Libraries.Add(lib);
|
||||
DPrintf("Loaded library %s.\n", lib->name);
|
||||
|
||||
return lib;
|
||||
}
|
||||
|
||||
void SystemWrapper::SetTitle(char *text)
|
||||
{
|
||||
Con_Printf("TODO: SystemWrapper::SetTitle ?\n");
|
||||
}
|
||||
|
||||
void SystemWrapper::SetStatusLine(char *text)
|
||||
{
|
||||
Con_Printf("TODO: SystemWrapper::SetStatusLine ?\n");
|
||||
}
|
||||
|
||||
double SystemWrapper::GetTime()
|
||||
{
|
||||
return m_SystemTime;
|
||||
}
|
||||
|
||||
void SystemWrapper::RedirectOutput(char *buffer, int maxSize)
|
||||
{
|
||||
Con_Printf("WARNIG! SystemWrapper::RedirectOutput: not implemented.\n");
|
||||
}
|
||||
|
||||
void SystemWrapper::Printf(char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[8192];
|
||||
|
||||
va_start(argptr, fmt);
|
||||
Q_vsnprintf(string, sizeof(string), fmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
Con_Printf("%s", string);
|
||||
}
|
||||
|
||||
void SystemWrapper::DPrintf(char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[8192];
|
||||
va_start(argptr, fmt);
|
||||
Q_vsnprintf(string, sizeof(string), fmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
Con_DPrintf(string);
|
||||
}
|
||||
|
||||
void SystemWrapper::RunFrame(double time)
|
||||
{
|
||||
m_Tick++;
|
||||
m_SystemTime += time;
|
||||
|
||||
if (m_State != MODULE_RUNNING) {
|
||||
return;
|
||||
}
|
||||
|
||||
ISystemModule *module = (ISystemModule *)m_Modules.GetFirst();
|
||||
while (module)
|
||||
{
|
||||
if (m_State == MODULE_DISCONNECTED)
|
||||
break;
|
||||
|
||||
module->RunFrame(m_SystemTime);
|
||||
module = (ISystemModule *)m_Modules.GetNext();
|
||||
}
|
||||
|
||||
m_LastTime = m_SystemTime;
|
||||
}
|
||||
|
||||
void SystemWrapper::ExecuteFile(char *filename)
|
||||
{
|
||||
char cmd[1024];
|
||||
Q_snprintf(cmd, sizeof(cmd), "exec %s\n", filename);
|
||||
Cmd_ExecuteString(cmd, src_command);
|
||||
}
|
||||
|
||||
bool SystemWrapper::RegisterCommand(char *name, ISystemModule *module, int commandID)
|
||||
{
|
||||
command_t *cmd = (command_t *)m_Commands.GetFirst();
|
||||
while (cmd)
|
||||
{
|
||||
if (Q_stricmp(cmd->name, name) == 0) {
|
||||
Printf("WARNING! System::RegisterCommand: command \"%s\" already exists.\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd = (command_t *)m_Commands.GetNext();
|
||||
}
|
||||
|
||||
cmd = (command_t *)Mem_ZeroMalloc(sizeof(command_t));
|
||||
|
||||
strcopy(cmd->name, name);
|
||||
cmd->module = module;
|
||||
cmd->commandID = commandID;
|
||||
|
||||
m_Commands.Add(cmd);
|
||||
Cmd_AddWrapperCommand(cmd->name, SystemWrapper_CommandForwarder);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
IFileSystem *SystemWrapper::GetFileSystem()
|
||||
{
|
||||
return g_pFileSystem;
|
||||
}
|
||||
|
||||
unsigned char *SystemWrapper::LoadFile(const char *name, int *length)
|
||||
{
|
||||
return COM_LoadFile(name, 5, length);
|
||||
}
|
||||
|
||||
void SystemWrapper::FreeFile(unsigned char *fileHandle)
|
||||
{
|
||||
COM_FreeFile(fileHandle);
|
||||
}
|
||||
|
||||
unsigned int SystemWrapper::GetTick()
|
||||
{
|
||||
return m_Tick;
|
||||
}
|
||||
|
||||
void SystemWrapper::CMD_Modules(char *cmdLine)
|
||||
{
|
||||
ISystemModule *module = (ISystemModule *)m_Modules.GetFirst();
|
||||
while (module)
|
||||
{
|
||||
Printf("%s(%s):%s\n",
|
||||
module->GetName(),
|
||||
module->GetType(),
|
||||
module->GetVersion());
|
||||
|
||||
module = (ISystemModule *)m_Modules.GetNext();
|
||||
}
|
||||
|
||||
Printf("--- %i modules in total ---\n", m_Modules.CountElements());
|
||||
}
|
||||
|
||||
char *SystemWrapper::GetType()
|
||||
{
|
||||
return BASESYSTEM_INTERFACE_VERSION;
|
||||
}
|
||||
|
||||
void SystemWrapper::GetCommandMatches(char *string, ObjectList *pMatchList)
|
||||
{
|
||||
#ifdef REHLDS_FIXES
|
||||
if (!string || !string[0])
|
||||
return;
|
||||
|
||||
int len = Q_strlen(string);
|
||||
for (auto cmd = Cmd_GetFirstCmd(); cmd; cmd = cmd->next)
|
||||
{
|
||||
if (!Q_strnicmp(cmd->name, string, len)) {
|
||||
pMatchList->Add((void *)cmd->name);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto var = cvar_vars; var; var = var->next)
|
||||
{
|
||||
if (!Q_strnicmp(var->name, string, len)) {
|
||||
pMatchList->Add((void *)var->name);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
pMatchList->Clear(true);
|
||||
#endif // REHLDS_FIXES
|
||||
}
|
||||
|
||||
ISystemModule *SystemWrapper::FindModule(char *type, char *name)
|
||||
{
|
||||
if (!type || !type[0])
|
||||
return nullptr;
|
||||
|
||||
ISystemModule *module = (ISystemModule *)m_Modules.GetFirst();
|
||||
while (module)
|
||||
{
|
||||
if (Q_stricmp(type, module->GetType()) == 0
|
||||
&& (!name || Q_stricmp(name, module->GetType()) == 0)) {
|
||||
return module;
|
||||
}
|
||||
|
||||
module = (ISystemModule *)m_Modules.GetNext();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SystemWrapper::LogConsole(char *filename)
|
||||
{
|
||||
if (filename) {
|
||||
Cmd_ExecuteString("log on", src_command);
|
||||
} else {
|
||||
Cmd_ExecuteString("log off", src_command);
|
||||
}
|
||||
}
|
||||
|
||||
Panel *SystemWrapper::GetPanel()
|
||||
{
|
||||
return (Panel *)VGuiWrap2_GetPanel();
|
||||
}
|
||||
|
||||
bool SystemWrapper::InitVGUI(IVGuiModule *module)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SystemWrapper::AddModule(ISystemModule *module, char *name)
|
||||
{
|
||||
if (!module)
|
||||
return false;
|
||||
|
||||
if (!module->Init(this, m_SerialCounter, name))
|
||||
{
|
||||
Printf("ERROR! System::AddModule: couldn't initialize module %s.\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Modules.AddHead(module);
|
||||
m_SerialCounter++;
|
||||
return true;
|
||||
}
|
||||
|
||||
ISystemModule *SystemWrapper::GetModule(char *interfacename, char *library, char *instancename)
|
||||
{
|
||||
ISystemModule *module = FindModule(interfacename, instancename);
|
||||
if (module) {
|
||||
return module;
|
||||
}
|
||||
|
||||
library_t *lib = GetLibrary(library);
|
||||
if (!lib) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
module = (ISystemModule *)lib->createInterfaceFn(interfacename, nullptr);
|
||||
if (!module) {
|
||||
DPrintf("ERROR! System::GetModule: interface \"%s\" not found in library %s.\n", interfacename, lib->name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AddModule(module, instancename);
|
||||
return module;
|
||||
}
|
||||
|
||||
bool SystemWrapper::RemoveModule(ISystemModule *module)
|
||||
{
|
||||
if (!module) {
|
||||
return true;
|
||||
}
|
||||
|
||||
module->ShutDown();
|
||||
|
||||
command_t *cmd = (command_t *)m_Commands.GetFirst();
|
||||
while (cmd)
|
||||
{
|
||||
if (cmd->module->GetSerial() == module->GetSerial()) {
|
||||
m_Commands.Remove(cmd);
|
||||
Mem_Free(cmd);
|
||||
}
|
||||
|
||||
cmd = (command_t *)m_Commands.GetNext();
|
||||
}
|
||||
|
||||
ISystemModule *mod = (ISystemModule *)m_Modules.GetFirst();
|
||||
while (mod)
|
||||
{
|
||||
if (mod->GetSerial() == module->GetSerial()) {
|
||||
m_Modules.Remove(mod);
|
||||
return true;
|
||||
}
|
||||
|
||||
mod = (ISystemModule *)m_Modules.GetNext();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SystemWrapper::ExecuteString(char *commands)
|
||||
{
|
||||
if (!commands || !commands[0])
|
||||
return;
|
||||
|
||||
int size = 0;
|
||||
char singleCmd[256] = "";
|
||||
bool quotes = false;
|
||||
char *p = singleCmd;
|
||||
char *c = commands;
|
||||
|
||||
COM_RemoveEvilChars(c);
|
||||
while (true)
|
||||
{
|
||||
*p = *c;
|
||||
|
||||
if (++size >= sizeof(singleCmd))
|
||||
{
|
||||
DPrintf("WARNING! System::ExecuteString: Command token too long.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (*c == '"')
|
||||
quotes = !quotes;
|
||||
|
||||
if ((*c != ';' || quotes) && *c)
|
||||
{
|
||||
++p;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p = '\0';
|
||||
|
||||
char *cmd = singleCmd;
|
||||
while (*cmd == ' ') { cmd++; }
|
||||
|
||||
DispatchCommand(cmd);
|
||||
p = singleCmd;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
if (!*c++)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool SystemWrapper::DispatchCommand(char *command)
|
||||
{
|
||||
if (!command || !command[0])
|
||||
return true;
|
||||
|
||||
TokenLine params(command);
|
||||
command_t *cmd = (command_t *)m_Commands.GetFirst();
|
||||
while (cmd)
|
||||
{
|
||||
if (Q_stricmp(cmd->name, params.GetToken(0)) == 0) {
|
||||
cmd->module->ExecuteCommand(cmd->commandID, command);
|
||||
return true;
|
||||
}
|
||||
|
||||
cmd = (command_t *)m_Commands.GetNext();
|
||||
}
|
||||
|
||||
Cmd_ExecuteString(command, src_command);
|
||||
return true;
|
||||
}
|
||||
|
||||
int COM_BuildNumber()
|
||||
{
|
||||
return build_number();
|
||||
}
|
||||
|
||||
void COM_RemoveEvilChars(char *string)
|
||||
{
|
||||
char *c = string;
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (*c)
|
||||
{
|
||||
if (*c < ' ' || *c == '%') {
|
||||
*c = ' ';
|
||||
}
|
||||
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
bool EngineWrapper::GetViewOrigin(float *origin)
|
||||
{
|
||||
#ifndef SWDS
|
||||
origin[0] = r_refdef.vieworg[0];
|
||||
origin[1] = r_refdef.vieworg[1];
|
||||
origin[2] = r_refdef.vieworg[2];
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif // SWDS
|
||||
}
|
||||
|
||||
bool EngineWrapper::GetViewAngles(float *angles)
|
||||
{
|
||||
#ifndef SWDS
|
||||
angles[0] = r_refdef.viewangles[0];
|
||||
angles[1] = r_refdef.viewangles[1];
|
||||
angles[2] = r_refdef.viewangles[2];
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif // SWDS
|
||||
}
|
||||
|
||||
float EngineWrapper::GetCvarFloat(char *szName)
|
||||
{
|
||||
cvar_t *cv = Cvar_FindVar(szName);
|
||||
if (cv) {
|
||||
return cv->value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *EngineWrapper::GetCvarString(char *szName)
|
||||
{
|
||||
cvar_t *cv = Cvar_FindVar(szName);
|
||||
if (cv) {
|
||||
return cv->string;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EngineWrapper::SetCvar(char *szName, char *szValue)
|
||||
{
|
||||
Cvar_Set(szName, szValue);
|
||||
}
|
||||
|
||||
void EngineWrapper::DemoUpdateClientData(client_data_t *cdat)
|
||||
{
|
||||
#ifndef SWDS
|
||||
ClientDLL_DemoUpdateClientData(cdat);
|
||||
scr_fov_value = cdat->fov;
|
||||
#endif // SWDS
|
||||
}
|
||||
|
||||
void EngineWrapper::CL_QueueEvent(int flags, int index, float delay, event_args_t *pargs)
|
||||
{
|
||||
#ifndef SWDS
|
||||
CL_QueueEvent(flags, index, delay, pargs);
|
||||
#endif // SWDS
|
||||
}
|
||||
|
||||
void EngineWrapper::HudWeaponAnim(int iAnim, int body)
|
||||
{
|
||||
#ifndef SWDS
|
||||
hudWeaponAnim(iAnim, body);
|
||||
#endif // SWDS
|
||||
}
|
||||
|
||||
void EngineWrapper::CL_DemoPlaySound(int channel, char *sample, float attenuation, float volume, int flags, int pitch)
|
||||
{
|
||||
#ifndef SWDS
|
||||
CL_DemoPlaySound(channel, sample, attenuation, volume, flags, pitch);
|
||||
#endif // SWDS
|
||||
}
|
||||
|
||||
void EngineWrapper::ClientDLL_ReadDemoBuffer(int size, unsigned char *buffer)
|
||||
{
|
||||
#ifndef SWDS
|
||||
ClientDLL_ReadDemoBuffer();
|
||||
#endif // SWDS
|
||||
}
|
||||
|
||||
int EngineWrapper::GetTraceEntity()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *EngineWrapper::GetType()
|
||||
{
|
||||
return ENGINEWRAPPER_INTERFACE_VERSION;
|
||||
}
|
||||
|
||||
char *EngineWrapper::GetStatusLine()
|
||||
{
|
||||
return "No status available.\n";
|
||||
}
|
||||
|
||||
void EngineWrapper::Cbuf_AddText(char *text)
|
||||
{
|
||||
Cbuf_AddText(text);
|
||||
}
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(SystemWrapper, IBaseSystem, BASESYSTEM_INTERFACE_VERSION, gSystemWrapper);
|
||||
#endif // REHLDS_FIXES
|
157
rehlds/engine/SystemWrapper.h
Normal file
157
rehlds/engine/SystemWrapper.h
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef HOOK_ENGINE
|
||||
#define gSystemWrapper (*pgSystemWrapper)
|
||||
#endif // HOOK_ENGINE
|
||||
|
||||
#include "ObjectList.h"
|
||||
#include "TokenLine.h"
|
||||
#include "BaseSystemModule.h"
|
||||
#include "IEngineWrapper.h"
|
||||
|
||||
class EngineWrapper: public IEngineWrapper, public BaseSystemModule {
|
||||
public:
|
||||
bool Init(IBaseSystem *system, int serial, char *name) { return BaseSystemModule::Init(system, serial, name); }
|
||||
|
||||
void RunFrame(double time) { BaseSystemModule::RunFrame(time); }
|
||||
void ReceiveSignal(ISystemModule *module, unsigned int signal, void *data) { BaseSystemModule::ReceiveSignal(module, signal, data); }
|
||||
void ExecuteCommand(int commandID, char *commandLine) { BaseSystemModule::ExecuteCommand(commandID, commandLine); }
|
||||
void RegisterListener(ISystemModule *module) { BaseSystemModule::RegisterListener(module); }
|
||||
void RemoveListener(ISystemModule *module) { BaseSystemModule::RemoveListener(module); }
|
||||
|
||||
IBaseSystem *GetSystem() { return BaseSystemModule::GetSystem(); }
|
||||
int GetSerial() { return BaseSystemModule::GetSerial(); }
|
||||
char *GetStatusLine();
|
||||
char *GetType();
|
||||
char *GetName() { return BaseSystemModule::GetName(); }
|
||||
int GetState() { return BaseSystemModule::GetState(); }
|
||||
int GetVersion() { return BaseSystemModule::GetVersion(); }
|
||||
void ShutDown() { BaseSystemModule::ShutDown(); }
|
||||
|
||||
bool GetViewOrigin(float *origin);
|
||||
bool GetViewAngles(float *angles);
|
||||
int GetTraceEntity();
|
||||
float GetCvarFloat(char *szName);
|
||||
char *GetCvarString(char *szName);
|
||||
void SetCvar(char *szName, char *szValue);
|
||||
void Cbuf_AddText(char *text);
|
||||
void DemoUpdateClientData(client_data_t *cdat);
|
||||
void CL_QueueEvent(int flags, int index, float delay, event_args_t *pargs);
|
||||
void HudWeaponAnim(int iAnim, int body);
|
||||
void CL_DemoPlaySound(int channel, char* sample, float attenuation, float volume, int flags, int pitch);
|
||||
void ClientDLL_ReadDemoBuffer(int size, unsigned char *buffer);
|
||||
};
|
||||
|
||||
class Panel;
|
||||
class SystemWrapper: public IBaseSystem, public BaseSystemModule {
|
||||
public:
|
||||
bool Init(IBaseSystem *system, int serial, char *name);
|
||||
void RunFrame(double time);
|
||||
void ExecuteCommand(int commandID, char *commandLine);
|
||||
char *GetStatusLine();
|
||||
char *GetType();
|
||||
void ShutDown();
|
||||
|
||||
double GetTime();
|
||||
unsigned int GetTick();
|
||||
void SetFPS(float fps) {}
|
||||
void Printf(char *fmt, ...);
|
||||
void DPrintf(char *fmt, ...);
|
||||
void RedirectOutput(char *buffer, int maxSize);
|
||||
IFileSystem *GetFileSystem();
|
||||
unsigned char *LoadFile(const char *name, int *length);
|
||||
void FreeFile(unsigned char *fileHandle);
|
||||
void SetTitle(char *pszTitle);
|
||||
void SetStatusLine(char *pszStatus);
|
||||
void ShowConsole(bool visible) {}
|
||||
void LogConsole(char *filename);
|
||||
bool InitVGUI(IVGuiModule *module);
|
||||
Panel *GetPanel();
|
||||
bool RegisterCommand(char *name, ISystemModule *module, int commandID);
|
||||
void GetCommandMatches(char *string, ObjectList *pMatchList);
|
||||
void ExecuteString(char *commands);
|
||||
void ExecuteFile(char *filename);
|
||||
void Errorf(char *fmt, ...);
|
||||
char *CheckParam(char *param);
|
||||
bool AddModule(ISystemModule *module, char *name);
|
||||
ISystemModule *GetModule(char *interfacename, char *library, char *instancename = nullptr);
|
||||
bool RemoveModule(ISystemModule *module);
|
||||
void Stop();
|
||||
char *GetBaseDir() { return BaseSystemModule::GetBaseDir(); }
|
||||
|
||||
protected:
|
||||
struct command_t {
|
||||
char name[32];
|
||||
int commandID;
|
||||
ISystemModule *module;
|
||||
};
|
||||
|
||||
struct library_t {
|
||||
char name[MAX_PATH];
|
||||
CSysModule *handle;
|
||||
CreateInterfaceFn createInterfaceFn;
|
||||
};
|
||||
|
||||
library_t *GetLibrary(char *name);
|
||||
ISystemModule *FindModule(char *type, char *name = nullptr);
|
||||
bool DispatchCommand(char *command);
|
||||
|
||||
enum LocalCommandIDs {
|
||||
CMD_ID_MODULES = 1,
|
||||
CMD_ID_LOADMODULE,
|
||||
CMD_ID_UNLOADMODULE,
|
||||
};
|
||||
|
||||
void CMD_Modules(char *cmdLine);
|
||||
void CMD_UnloadModule(char *cmdLine);
|
||||
void CMD_LoadModule(char *cmdLine);
|
||||
|
||||
private:
|
||||
ObjectList m_Modules;
|
||||
ObjectList m_Libraries;
|
||||
ObjectList m_Commands;
|
||||
unsigned int m_SerialCounter;
|
||||
unsigned int m_Tick;
|
||||
double m_LastTime;
|
||||
IEngineWrapper *m_EngineWrapper;
|
||||
};
|
||||
|
||||
extern SystemWrapper gSystemWrapper;
|
||||
|
||||
void SystemWrapper_Init();
|
||||
void SystemWrapper_ShutDown();
|
||||
void SystemWrapper_RunFrame(double time);
|
||||
BOOL SystemWrapper_LoadModule(char *interfacename, char *library, char *instancename = nullptr);
|
||||
void SystemWrapper_ExecuteString(char *command);
|
||||
void SystemWrapper_CommandForwarder();
|
||||
|
||||
int COM_BuildNumber();
|
||||
void COM_RemoveEvilChars(char *string);
|
@ -106,13 +106,38 @@ void CL_VoiceIdle(void) { }
|
||||
void PollDInputDevices(void) { }
|
||||
void CL_KeepConnectionActive(void) { }
|
||||
void CL_UpdateModuleC(void) { }
|
||||
int EXT_FUNC VGuiWrap2_IsInCareerMatch(void) { return 0; }
|
||||
void VguiWrap2_GetCareerUI(void) { }
|
||||
int EXT_FUNC VGuiWrap2_GetLocalizedStringLength(const char *label) { return 0; }
|
||||
void VGuiWrap2_LoadingStarted(const char *resourceType, const char *resourceName) {}
|
||||
void EXT_FUNC ConstructTutorMessageDecayBuffer(int *buffer, int bufferLength) { }
|
||||
void EXT_FUNC ProcessTutorMessageDecayBuffer(int *buffer, int bufferLength) { }
|
||||
int EXT_FUNC GetTimesTutorMessageShown(int id) { return -1; }
|
||||
void EXT_FUNC RegisterTutorMessageShown(int mid) { }
|
||||
void EXT_FUNC ResetTutorMessageDecayData(void) { }
|
||||
void SetCareerAudioState(int state) { }
|
||||
|
||||
void *VguiWrap2_GetCareerUI() { return NULL; }
|
||||
void VguiWrap2_GetMouseDelta(int *x, int *y) {}
|
||||
int EXT_FUNC VGuiWrap2_GetLocalizedStringLength(const char *label) { return 0; }
|
||||
int EXT_FUNC VGuiWrap2_IsInCareerMatch() { return 0; }
|
||||
int VGuiWrap2_IsConsoleVisible() { return 0; }
|
||||
int VGuiWrap2_Key_Event(int down, int keynum, const char *pszCurrentBinding) { return 0; }
|
||||
int VGuiWrap2_GameUIKeyPressed() { return 0; }
|
||||
int VGuiWrap2_IsGameUIVisible() { return 0; }
|
||||
int VGuiWrap2_CallEngineSurfaceAppHandler(void *event, void *userData) { return 0; }
|
||||
int VGuiWrap2_UseVGUI1() { return 0; }
|
||||
void *VGuiWrap2_GetPanel() { return NULL; }
|
||||
void VGuiWrap2_NotifyOfServerConnect(const char *game, int IP, int port) {}
|
||||
void VGuiWrap2_LoadingFinished(const char *resourceType, const char *resourceName) {}
|
||||
void VGuiWrap2_LoadingStarted(const char *resourceType, const char *resourceName) {}
|
||||
void VGuiWrap2_ConDPrintf(const char *msg) {}
|
||||
void VGuiWrap2_Startup() {}
|
||||
void VGuiWrap2_ConPrintf(const char *msg) {}
|
||||
void VGuiWrap2_ClearConsole() {}
|
||||
void VGuiWrap2_HideConsole() {}
|
||||
void VGuiWrap2_ShowDemoPlayer() {}
|
||||
void VGuiWrap2_ShowConsole() {}
|
||||
void VGuiWrap2_HideGameUI() {}
|
||||
void VGuiWrap2_NotifyOfServerDisconnect() {}
|
||||
void VGuiWrap2_Paint() {}
|
||||
void VGuiWrap2_SetVisible(int state) {}
|
||||
void VGuiWrap2_GetMouse() {}
|
||||
void VGuiWrap2_ReleaseMouse() {}
|
||||
void VGuiWrap2_Shutdown() {}
|
||||
|
@ -148,7 +148,7 @@ typedef struct client_static_s
|
||||
qboolean demorecording;
|
||||
qboolean demoplayback;
|
||||
qboolean timedemo;
|
||||
float demostarttime;
|
||||
float demostarttime;
|
||||
int demostartframe;
|
||||
int forcetrack;
|
||||
FileHandle_t demofile;
|
||||
@ -287,63 +287,91 @@ extern cvar_t console;
|
||||
|
||||
void CL_RecordHUDCommand(const char *cmdname);
|
||||
void R_DecalRemoveAll(int textureIndex);
|
||||
void CL_CheckForResend(void);
|
||||
void CL_CheckForResend();
|
||||
qboolean CL_CheckFile(sizebuf_t *msg, char *filename);
|
||||
void CL_ClearClientState(void);
|
||||
void CL_Connect_f(void);
|
||||
void CL_DecayLights(void);
|
||||
void CL_Disconnect(void);
|
||||
void CL_Disconnect_f(void);
|
||||
void CL_EmitEntities(void);
|
||||
void CL_InitClosest(void);
|
||||
void CL_Init(void);
|
||||
void CL_ClearClientState();
|
||||
void CL_Connect_f();
|
||||
void CL_DecayLights();
|
||||
void CL_Disconnect();
|
||||
void CL_Disconnect_f();
|
||||
void CL_EmitEntities();
|
||||
void CL_InitClosest();
|
||||
void CL_Init();
|
||||
void CL_Particle(vec_t *origin, int color, float life, int zpos, int zvel);
|
||||
void CL_PredictMove(qboolean repredicting);
|
||||
void CL_PrintLogos(void);
|
||||
void CL_ReadPackets(void);
|
||||
qboolean CL_RequestMissingResources(void);
|
||||
void CL_Move(void);
|
||||
void CL_SendConnectPacket(void);
|
||||
void CL_StopPlayback(void);
|
||||
void CL_UpdateSoundFade(void);
|
||||
void CL_AdjustClock(void);
|
||||
void CL_PrintLogos();
|
||||
void CL_ReadPackets();
|
||||
qboolean CL_RequestMissingResources();
|
||||
void CL_Move();
|
||||
void CL_SendConnectPacket();
|
||||
void CL_StopPlayback();
|
||||
void CL_UpdateSoundFade();
|
||||
void CL_AdjustClock();
|
||||
void CL_Save(const char *name);
|
||||
void CL_HudMessage(const char *pMessage);
|
||||
|
||||
int Key_CountBindings(void);
|
||||
int Key_CountBindings();
|
||||
void Key_WriteBindings(FileHandle_t f);
|
||||
extern "C" void ClientDLL_UpdateClientData(void);
|
||||
extern "C" void ClientDLL_HudVidInit(void);
|
||||
void Chase_Init(void);
|
||||
void Key_Init(void);
|
||||
extern "C" void ClientDLL_Init(void);
|
||||
void Con_Shutdown(void);
|
||||
extern "C" void ClientDLL_UpdateClientData();
|
||||
extern "C" void ClientDLL_HudVidInit();
|
||||
void Chase_Init();
|
||||
void Key_Init();
|
||||
extern "C" void ClientDLL_Init();
|
||||
void Con_Shutdown();
|
||||
int DispatchDirectUserMsg(const char *pszName, int iSize, void *pBuf);
|
||||
void CL_ShutDownUsrMessages(void);
|
||||
void CL_ShutDownClientStatic(void);
|
||||
void CL_ShutDownUsrMessages();
|
||||
void CL_ShutDownClientStatic();
|
||||
extern "C" void ClientDLL_MoveClient(struct playermove_s *ppmove);
|
||||
void CL_Shutdown(void);
|
||||
void CL_Shutdown();
|
||||
extern "C" void ClientDLL_Frame(double time);
|
||||
extern "C" void ClientDLL_CAM_Think(void);
|
||||
void CL_InitEventSystem(void);
|
||||
void CL_CheckClientState(void);
|
||||
void CL_RedoPrediction(void);
|
||||
void CL_SetLastUpdate(void);
|
||||
extern "C" void ClientDLL_CAM_Think();
|
||||
void CL_InitEventSystem();
|
||||
void CL_CheckClientState();
|
||||
void CL_RedoPrediction();
|
||||
void CL_SetLastUpdate();
|
||||
void Con_NPrintf(int idx, const char *fmt, ...);
|
||||
void CL_WriteMessageHistory(int starting_count, int cmd);
|
||||
void CL_MoveSpectatorCamera(void);
|
||||
void CL_MoveSpectatorCamera();
|
||||
void CL_AddVoiceToDatagram(qboolean bFinal);
|
||||
void CL_VoiceIdle(void);
|
||||
void PollDInputDevices(void);
|
||||
void CL_KeepConnectionActive(void);
|
||||
void CL_UpdateModuleC(void);
|
||||
int VGuiWrap2_IsInCareerMatch(void);
|
||||
void VguiWrap2_GetCareerUI(void);
|
||||
int VGuiWrap2_GetLocalizedStringLength(const char *label);
|
||||
void VGuiWrap2_LoadingStarted(const char *resourceType, const char *resourceName);
|
||||
void CL_VoiceIdle();
|
||||
void PollDInputDevices();
|
||||
void CL_KeepConnectionActive();
|
||||
void CL_UpdateModuleC();
|
||||
void ConstructTutorMessageDecayBuffer(int *buffer, int bufferLength);
|
||||
void ProcessTutorMessageDecayBuffer(int *buffer, int bufferLength);
|
||||
int GetTimesTutorMessageShown(int id);
|
||||
void RegisterTutorMessageShown(int mid);
|
||||
void ResetTutorMessageDecayData(void);
|
||||
void ResetTutorMessageDecayData();
|
||||
void SetCareerAudioState(int state);
|
||||
|
||||
int EXT_FUNC VGuiWrap2_IsInCareerMatch();
|
||||
int EXT_FUNC VGuiWrap2_GetLocalizedStringLength(const char *label);
|
||||
void VGuiWrap2_LoadingStarted(const char *resourceType, const char *resourceName);
|
||||
void *VguiWrap2_GetCareerUI();
|
||||
void VguiWrap2_GetMouseDelta(int *x, int *y);
|
||||
int EXT_FUNC VGuiWrap2_GetLocalizedStringLength(const char *label);
|
||||
int EXT_FUNC VGuiWrap2_IsInCareerMatch();
|
||||
int VGuiWrap2_IsConsoleVisible();
|
||||
int VGuiWrap2_Key_Event(int down, int keynum, const char *pszCurrentBinding);
|
||||
int VGuiWrap2_GameUIKeyPressed();
|
||||
int VGuiWrap2_IsGameUIVisible();
|
||||
int VGuiWrap2_CallEngineSurfaceAppHandler(void *event, void *userData);
|
||||
int VGuiWrap2_UseVGUI1();
|
||||
void *VGuiWrap2_GetPanel();
|
||||
void VGuiWrap2_NotifyOfServerConnect(const char *game, int IP, int port);
|
||||
void VGuiWrap2_LoadingFinished(const char *resourceType, const char *resourceName);
|
||||
void VGuiWrap2_LoadingStarted(const char *resourceType, const char *resourceName);
|
||||
void VGuiWrap2_ConDPrintf(const char *msg);
|
||||
void VGuiWrap2_Startup();
|
||||
void VGuiWrap2_ConPrintf(const char *msg);
|
||||
void VGuiWrap2_ClearConsole();
|
||||
void VGuiWrap2_HideConsole();
|
||||
void VGuiWrap2_ShowDemoPlayer();
|
||||
void VGuiWrap2_ShowConsole();
|
||||
void VGuiWrap2_HideGameUI();
|
||||
void VGuiWrap2_NotifyOfServerDisconnect();
|
||||
void VGuiWrap2_Paint();
|
||||
void VGuiWrap2_SetVisible(int state);
|
||||
void VGuiWrap2_GetMouse();
|
||||
void VGuiWrap2_ReleaseMouse();
|
||||
void VGuiWrap2_Shutdown();
|
||||
|
@ -782,10 +782,8 @@ NOXREF void Cmd_AddHUDCommand(const char *cmd_name, xcommand_t function)
|
||||
Cmd_AddMallocCommand(cmd_name, function, FCMD_HUD_COMMAND);
|
||||
}
|
||||
|
||||
NOXREF void Cmd_AddWrapperCommand(const char *cmd_name, xcommand_t function)
|
||||
void Cmd_AddWrapperCommand(const char *cmd_name, xcommand_t function)
|
||||
{
|
||||
NOXREFCHECK;
|
||||
|
||||
Cmd_AddMallocCommand(cmd_name, function, FCMD_WRAPPER_COMMAND);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ cmd_function_t *Cmd_FindCmdPrev(const char *cmd_name);
|
||||
void Cmd_AddCommand(const char *cmd_name, xcommand_t function);
|
||||
void Cmd_AddMallocCommand(const char *cmd_name, xcommand_t function, int flag);
|
||||
NOXREF void Cmd_AddHUDCommand(const char *cmd_name, xcommand_t function);
|
||||
NOXREF void Cmd_AddWrapperCommand(const char *cmd_name, xcommand_t function);
|
||||
void Cmd_AddWrapperCommand(const char *cmd_name, xcommand_t function);
|
||||
void Cmd_AddGameCommand(const char *cmd_name, xcommand_t function);
|
||||
void Cmd_RemoveCmd(const char *cmd_name);
|
||||
void Cmd_RemoveMallocedCmds(int flag);
|
||||
|
@ -893,7 +893,7 @@ void _Host_Frame(float time)
|
||||
}
|
||||
#endif //REHLDS_FLIGHT_REC
|
||||
|
||||
//SystemWrapper_RunFrame(host_frametime);
|
||||
SystemWrapper_RunFrame(host_frametime);
|
||||
|
||||
if (g_modfuncs.m_pfnFrameBegin)
|
||||
g_modfuncs.m_pfnFrameBegin();
|
||||
@ -1019,7 +1019,7 @@ int Host_Frame(float time, int iState, int *stateInfo)
|
||||
void CheckGore(void)
|
||||
{
|
||||
float fValue = bLowViolenceBuild ? 0.0f : 1.0f;
|
||||
|
||||
|
||||
Cvar_SetValue("violence_hblood", fValue);
|
||||
Cvar_SetValue("violence_hgibs", fValue);
|
||||
Cvar_SetValue("violence_ablood", fValue);
|
||||
@ -1156,7 +1156,7 @@ int Host_Init(quakeparms_t *parms)
|
||||
Netchan_Init();
|
||||
DELTA_Init();
|
||||
SV_Init();
|
||||
//SystemWrapper_Init();
|
||||
SystemWrapper_Init();
|
||||
Host_Version();
|
||||
|
||||
//Rehlds Security
|
||||
@ -1263,7 +1263,7 @@ void Host_Shutdown(void)
|
||||
SV_ClearFrames(&pclient->frames);
|
||||
|
||||
SV_Shutdown();
|
||||
//SystemWrapper_ShutDown();
|
||||
SystemWrapper_ShutDown();
|
||||
NET_Shutdown();
|
||||
S_Shutdown();
|
||||
Con_Shutdown();
|
||||
|
@ -101,6 +101,7 @@
|
||||
#define IpratelimitWrapper_region
|
||||
#define Sys_engine
|
||||
#define Sys_linuxwind
|
||||
//#define SystemWrapper_region
|
||||
|
||||
//#define Function_References_region
|
||||
//#define Data_References_region
|
||||
@ -1930,6 +1931,89 @@ FunctionHook g_FunctionHooks[] =
|
||||
|
||||
#endif // Sys_linuxwind
|
||||
|
||||
#ifndef SystemWrapper_region
|
||||
|
||||
HOOK_DEF(0x01DA5CB0, SystemWrapper_Init),
|
||||
HOOK_DEF(0x01DA5CD0, SystemWrapper_RunFrame),
|
||||
HOOK_DEF(0x01DA5CF0, SystemWrapper_ShutDown),
|
||||
HOOK_DEF(0x01DA5D00, SystemWrapper_LoadModule), // NOXREF
|
||||
HOOK_DEF(0x01DA5D30, SystemWrapper_ExecuteString),
|
||||
HOOK_DEF(0x01DA5D50, SystemWrapper_CommandForwarder),
|
||||
|
||||
// virtual functions
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA7120, "_ZN13SystemWrapper4InitEP11IBaseSystemiPc", SystemWrapper::Init),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA7130, "_ZN13SystemWrapper8RunFrameEd", SystemWrapper::RunFrame),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA7150, "_ZN13SystemWrapper14ExecuteCommandEiPc", SystemWrapper::ExecuteCommand),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA71A0, "_ZN13SystemWrapper13GetStatusLineEv", SystemWrapper::GetStatusLine),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA71B0, "_ZN13SystemWrapper7GetTypeEv", SystemWrapper::GetType),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA71E0, "_ZN13SystemWrapper8ShutDownEv", SystemWrapper::ShutDown),
|
||||
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6730, "_ZN13SystemWrapper7GetTimeEv", SystemWrapper::GetTime),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6950, "_ZN13SystemWrapper7GetTickEv", SystemWrapper::GetTick),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6FA0, "_ZN13SystemWrapper6SetFPSEf", SystemWrapper::SetFPS),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6750, "_ZN13SystemWrapper6PrintfEPcz", SystemWrapper::Printf),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6820, "_ZN13SystemWrapper7DPrintfEPcz", SystemWrapper::DPrintf),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6740, "_ZN13SystemWrapper14RedirectOutputEPci", SystemWrapper::RedirectOutput),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6900, "_ZN13SystemWrapper13GetFileSystemEv", SystemWrapper::GetFileSystem),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6910, "_ZN13SystemWrapper8LoadFileEPKcPi", SystemWrapper::LoadFile),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6930, "_ZN13SystemWrapper8FreeFileEPh", SystemWrapper::FreeFile),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6710, "_ZN13SystemWrapper8SetTitleEPc", SystemWrapper::SetTitle),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6720, "_ZN13SystemWrapper13SetStatusLineEPc", SystemWrapper::SetStatusLine),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6FB0, "_ZN13SystemWrapper11ShowConsoleEb", SystemWrapper::ShowConsole),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6A90, "_ZN13SystemWrapper10LogConsoleEPc", SystemWrapper::LogConsole),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6AD0, "_ZN13SystemWrapper8InitVGUIEP11IVGuiModule", SystemWrapper::InitVGUI),
|
||||
#ifdef _WIN32
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6AC0, "_ZN13SystemWrapper8GetPanelEv", SystemWrapper::GetPanel),
|
||||
#endif // _WIN32
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6850, "_ZN13SystemWrapper15RegisterCommandEPcP13ISystemModulei", SystemWrapper::RegisterCommand),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA69F0, "_ZN13SystemWrapper17GetCommandMatchesEPcP10ObjectList", SystemWrapper::GetCommandMatches),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6CA0, "_ZN13SystemWrapper13ExecuteStringEPc", SystemWrapper::ExecuteString),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA67E0, "_ZN13SystemWrapper11ExecuteFileEPc", SystemWrapper::ExecuteFile),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6200, "_ZN13SystemWrapper6ErrorfEPcz", SystemWrapper::Errorf),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA61C0, "_ZN13SystemWrapper10CheckParamEPc", SystemWrapper::CheckParam),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6AE0, "_ZN13SystemWrapper9AddModuleEP13ISystemModulePc", SystemWrapper::AddModule),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6B50, "_ZN13SystemWrapper9GetModuleEPcS0_S0_", SystemWrapper::GetModule),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6BD0, "_ZN13SystemWrapper12RemoveModuleEP13ISystemModule", SystemWrapper::RemoveModule),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6300, "_ZN13SystemWrapper4StopEv", SystemWrapper::Stop),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6FC0, "_ZN13SystemWrapper14COM_GetBaseDirEv", SystemWrapper::GetBaseDir),
|
||||
|
||||
HOOK_SYMBOLDEF(0x01DA6D60, "_ZN13SystemWrapper15DispatchCommandEPc", SystemWrapper::DispatchCommand),
|
||||
HOOK_SYMBOLDEF(0x01DA65C0, "_ZN13SystemWrapper10GetLibraryEPc", SystemWrapper::GetLibrary),
|
||||
HOOK_SYMBOLDEF(0x01DA6A10, "_ZN13SystemWrapper10FindModuleEPcS0_", SystemWrapper::FindModule),
|
||||
HOOK_SYMBOLDEF(0x01DA6960, "_ZN13SystemWrapper11CMD_ModulesEPc", SystemWrapper::CMD_Modules),
|
||||
HOOK_SYMBOLDEF(0x01DA6420, "_ZN13SystemWrapper14CMD_LoadModuleEPc", SystemWrapper::CMD_LoadModule),
|
||||
HOOK_SYMBOLDEF(0x01DA64E0, "_ZN13SystemWrapper16CMD_UnloadModuleEPc", SystemWrapper::CMD_UnloadModule),
|
||||
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6E40, "_ZN13EngineWrapper4InitEP11IBaseSystemiPc", EngineWrapper::Init),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6E70, "_ZN13EngineWrapper8RunFrameEd", EngineWrapper::RunFrame),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6EF0, "_ZN13EngineWrapper13ReceiveSignalEP13ISystemModulejPv", EngineWrapper::ReceiveSignal),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6E90, "_ZN13EngineWrapper14ExecuteCommandEiPc", EngineWrapper::ExecuteCommand),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6F10, "_ZN13EngineWrapper16RegisterListenerEP13ISystemModule", EngineWrapper::RegisterListener),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6F30, "_ZN13EngineWrapper14RemoveListenerEP13ISystemModule", EngineWrapper::RemoveListener),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6F50, "_ZN13EngineWrapper9GetSystemEv", EngineWrapper::GetSystem),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6F60, "_ZN13EngineWrapper9GetSerialEv", EngineWrapper::GetSerial),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5EC0, "_ZN13EngineWrapper13GetStatusLineEv", EngineWrapper::GetStatusLine),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5EB0, "_ZN13EngineWrapper7GetTypeEv", EngineWrapper::GetType),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6F70, "_ZN13EngineWrapper7GetNameEv", EngineWrapper::GetName),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6F80, "_ZN13EngineWrapper8GetStateEv", EngineWrapper::GetState),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6F90, "_ZN13EngineWrapper10GetVersionEv", EngineWrapper::GetVersion),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6E60, "_ZN13EngineWrapper8ShutDownEv", EngineWrapper::ShutDown),
|
||||
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5ED0, "_ZN13EngineWrapper13GetViewOriginEPf", EngineWrapper::GetViewOrigin),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5F00, "_ZN13EngineWrapper13GetViewAnglesEPf", EngineWrapper::GetViewAngles),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6070, "_ZN13EngineWrapper14GetTraceEntityEv", EngineWrapper::GetTraceEntity),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5F30, "_ZN13EngineWrapper12GetCvarFloatEPc", EngineWrapper::GetCvarFloat),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5F60, "_ZN13EngineWrapper13GetCvarStringEPc", EngineWrapper::GetCvarString),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5F80, "_ZN13EngineWrapper7SetCvarEPcS0_", EngineWrapper::SetCvar),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5FA0, "_ZN13EngineWrapper12Cbuf_AddTextEPc", EngineWrapper::Cbuf_AddText),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5FC0, "_ZN13EngineWrapper20DemoUpdateClientDataEP13client_data_s", EngineWrapper::DemoUpdateClientData),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA5FE0, "_ZN13EngineWrapper13CL_QueueEventEiifP12event_args_s", EngineWrapper::CL_QueueEvent),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6000, "_ZN13EngineWrapper13HudWeaponAnimEii", EngineWrapper::HudWeaponAnim),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6020, "_ZN13EngineWrapper16CL_DemoPlaySoundEiPcffii", EngineWrapper::CL_DemoPlaySound),
|
||||
HOOK_SYMBOL_VIRTUAL_DEF(0x01DA6050, "_ZN13EngineWrapper24ClientDLL_ReadDemoBufferEiPh", EngineWrapper::ClientDLL_ReadDemoBuffer),
|
||||
|
||||
#endif // SystemWrapper_region
|
||||
|
||||
{ NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
@ -2420,6 +2504,7 @@ AddressRef g_DataRefs[] =
|
||||
GLOBALVAR_LINK(0x01E4B3F0, "szReslistsBaseDir", pszReslistsBaseDir),
|
||||
GLOBALVAR_LINK(0x01E4B3FC, "szReslistsExt", pszReslistsExt),
|
||||
GLOBALVAR_LINK(0x02095C98, "g_InitTracker", pg_InitTracker),
|
||||
GLOBALVAR_LINK(0x020935A0, "gSystemWrapper", pgSystemWrapper),
|
||||
|
||||
#ifndef _WIN32
|
||||
//GLOBALVAR_LINK(0x0, "gHasMMXTechnology", pgHasMMXTechnology),
|
||||
|
@ -43,6 +43,9 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\BaseSystemModule.cpp" />
|
||||
<ClCompile Include="..\common\ObjectList.cpp" />
|
||||
<ClCompile Include="..\common\TokenLine.cpp" />
|
||||
<ClCompile Include="..\engine\buildnum.cpp" />
|
||||
<ClCompile Include="..\engine\cl_null.cpp" />
|
||||
<ClCompile Include="..\engine\cmd.cpp" />
|
||||
@ -88,6 +91,7 @@
|
||||
<ClCompile Include="..\engine\sv_steam3.cpp" />
|
||||
<ClCompile Include="..\engine\sv_upld.cpp" />
|
||||
<ClCompile Include="..\engine\sv_user.cpp" />
|
||||
<ClCompile Include="..\engine\SystemWrapper.cpp" />
|
||||
<ClCompile Include="..\engine\sys_dll.cpp" />
|
||||
<ClCompile Include="..\engine\sys_dll2.cpp" />
|
||||
<ClCompile Include="..\engine\sys_engine.cpp" />
|
||||
@ -445,6 +449,7 @@
|
||||
<ClInclude Include="..\engine\sv_steam3.h" />
|
||||
<ClInclude Include="..\engine\sv_upld.h" />
|
||||
<ClInclude Include="..\engine\sv_user.h" />
|
||||
<ClInclude Include="..\engine\SystemWrapper.h" />
|
||||
<ClInclude Include="..\engine\sys_dll.h" />
|
||||
<ClInclude Include="..\engine\sys_dll2.h" />
|
||||
<ClInclude Include="..\engine\iengine.h" />
|
||||
|
@ -347,6 +347,18 @@
|
||||
<ClCompile Include="..\hookers\rehlds_debug.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\BaseSystemModule.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\ObjectList.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\TokenLine.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\engine\SystemWrapper.cpp">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\version\version.h">
|
||||
@ -1084,6 +1096,9 @@
|
||||
<ClInclude Include="..\hookers\rehlds_debug.h">
|
||||
<Filter>hookers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\engine\SystemWrapper.h">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\linux\appversion.sh">
|
||||
|
@ -81,3 +81,4 @@
|
||||
#include "ipratelimitWrapper.h"
|
||||
#include "savegame_version.h"
|
||||
#include "sys_linuxwnd.h"
|
||||
#include "SystemWrapper.h"
|
||||
|
@ -16,14 +16,15 @@
|
||||
#include "ed_strpool.h"
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
// Hook stuff
|
||||
#include "hookers/engine/hooklist.h"
|
||||
|
||||
#include "engine.h"
|
||||
#include "platform.h"
|
||||
#include "RehldsRuntimeConfig.h"
|
||||
#include "rehlds_debug.h"
|
||||
|
||||
// Hook stuff
|
||||
#include "hookers/engine/hooklist.h"
|
||||
|
||||
// Valve libs stuff
|
||||
#include "tier0/platform.h"
|
||||
#include "tier0/dbg.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user