mirror of
https://github.com/rehlds/rehlds.git
synced 2024-12-27 23:25:45 +03:00
Restructuring of rehlds for HLTV project.
Improved hooks stuff: Removed wrappers for virtual functions hooks.
This commit is contained in:
parent
7efc256c7c
commit
6bda5ecbba
@ -1,51 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<Filter Include="src">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\blocksort.c">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\bzlib.c">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\compress.c">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\crctable.c">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\decompress.c">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\huffman.c">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\randtable.c">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\precompiled.c">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\bzlib_private.h">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -176,7 +176,7 @@ void setupToolchain(NativeBinarySpec b) {
|
||||
if (!unitTestExecutable && !swdsLib) {
|
||||
cfg.singleDefines 'HOOK_ENGINE'
|
||||
}
|
||||
|
||||
|
||||
if (unitTestExecutable) {
|
||||
cfg.singleDefines 'REHLDS_UNIT_TESTS'
|
||||
}
|
||||
@ -194,22 +194,26 @@ void setupToolchain(NativeBinarySpec b) {
|
||||
|
||||
class RehldsSrc {
|
||||
static void rehlds_src(def h) {
|
||||
h.rehlds_src(CppSourceSet) {
|
||||
h.rehlds_engine(CppSourceSet) {
|
||||
source {
|
||||
srcDirs "engine", "rehlds", "public", "version"
|
||||
srcDirs "engine", "rehlds", "version"
|
||||
if (GradleCppUtils.windows) srcDirs "testsuite"
|
||||
|
||||
include "**/*.cpp"
|
||||
exclude "precompiled.cpp"
|
||||
exclude GradleCppUtils.windows ? "tier0/platform_linux.cpp" : "tier0/platform_win32.cpp"
|
||||
exclude "interface.cpp", "rehlds/crc32c.cpp", "rehlds/sys_shared.cpp"
|
||||
}
|
||||
|
||||
}
|
||||
h.rehlds_public(CppSourceSet) {
|
||||
source {
|
||||
srcDirs "public"
|
||||
include "registry.cpp", "steamid.cpp", "utlbuffer.cpp", "tier0/dbg.cpp"
|
||||
}
|
||||
}
|
||||
h.rehlds_memory(CppSourceSet) {
|
||||
source {
|
||||
srcDirs "hookers"
|
||||
include "**/*.cpp"
|
||||
exclude "6132_hooker.cpp", "hooker.cpp", "main.cpp", "main_swds.cpp"
|
||||
if (!GradleCppUtils.windows) exclude "rehlds_debug.cpp"
|
||||
include "memory.cpp"
|
||||
if (GradleCppUtils.windows) include "rehlds_debug.cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -227,7 +231,7 @@ class RehldsSrc {
|
||||
h.rehlds_hooker_src(CppSourceSet) {
|
||||
source {
|
||||
srcDirs "hookers"
|
||||
include "6132_hooker.cpp", "hooker.cpp"
|
||||
include "engine/hooklist.cpp", "hooker.cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,7 +240,7 @@ class RehldsSrc {
|
||||
h.rehlds_hooker_main_src(CppSourceSet) {
|
||||
source {
|
||||
srcDirs "hookers"
|
||||
include "main.cpp"
|
||||
include "engine/main.cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -244,8 +248,8 @@ class RehldsSrc {
|
||||
static void rehlds_swds_main_src(def h) {
|
||||
h.rehlds_swds_main_src(CppSourceSet) {
|
||||
source {
|
||||
srcDirs "hookers"
|
||||
include "main_swds.cpp"
|
||||
srcDir "hookers"
|
||||
include "engine/main_swds.cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,32 @@
|
||||
#include "BaseSystemModule.h"
|
||||
#include <string.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.
|
||||
*
|
||||
*/
|
||||
|
||||
BaseSystemModule::BaseSystemModule()
|
||||
{
|
||||
m_State = MODULE_INACTIVE;
|
||||
}
|
||||
|
||||
BaseSystemModule::~BaseSystemModule()
|
||||
{
|
||||
;
|
||||
}
|
||||
#include "precompiled.h"
|
||||
|
||||
char *BaseSystemModule::GetName()
|
||||
{
|
||||
@ -53,15 +70,13 @@ bool BaseSystemModule::Init(IBaseSystem *system, int serial, char *name)
|
||||
if (!system)
|
||||
return false;
|
||||
|
||||
m_State = MODULE_PENDING;
|
||||
m_State = MODULE_INITIALIZING;
|
||||
m_System = system;
|
||||
m_Serial = serial;
|
||||
m_SystemTime = 0;
|
||||
|
||||
if (name)
|
||||
{
|
||||
strncpy(m_Name, name, sizeof m_Name - 1);
|
||||
m_Name[sizeof m_Name - 1] = '\0';
|
||||
if (name) {
|
||||
strcopy(m_Name, name);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -74,13 +89,12 @@ void BaseSystemModule::RunFrame(double time)
|
||||
|
||||
void BaseSystemModule::ShutDown()
|
||||
{
|
||||
if (m_State == MODULE_UNLOAD)
|
||||
if (m_State == MODULE_DISCONNECTED)
|
||||
return;
|
||||
|
||||
m_Listener.Clear();
|
||||
m_State = MODULE_UNLOAD;
|
||||
m_State = MODULE_DISCONNECTED;
|
||||
|
||||
// TODO: Check me!
|
||||
if (!m_System->RemoveModule(this))
|
||||
{
|
||||
m_System->DPrintf("ERROR! BaseSystemModule::ShutDown: faild to remove module %s.\n", m_Name);
|
||||
|
@ -1,30 +1,43 @@
|
||||
#ifndef BASESYSTEMMODULE_H
|
||||
#define BASESYSTEMMODULE_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 "ObjectList.h"
|
||||
#include "IBaseSystem.h"
|
||||
|
||||
#define SIGNAL_MODULE_CLOSE 8 // closing down module
|
||||
|
||||
enum ModuleState
|
||||
{
|
||||
MODULE_INACTIVE,
|
||||
MODULE_PENDING,
|
||||
MODULE_RUNNING,
|
||||
MODULE_LOAD,
|
||||
MODULE_UNLOAD
|
||||
};
|
||||
|
||||
// C4250 - 'class1' : inherits 'BaseSystemModule::member' via dominance
|
||||
#pragma warning(disable:4250)
|
||||
|
||||
class BaseSystemModule: virtual public ISystemModule {
|
||||
public:
|
||||
BaseSystemModule();
|
||||
virtual ~BaseSystemModule();
|
||||
BaseSystemModule() : m_State(MODULE_UNDEFINED) {}
|
||||
virtual ~BaseSystemModule() {}
|
||||
|
||||
virtual bool Init(IBaseSystem *system, int serial, char *name);
|
||||
virtual void RunFrame(double time);
|
||||
@ -37,11 +50,20 @@ public:
|
||||
virtual char *GetStatusLine();
|
||||
virtual char *GetType();
|
||||
virtual char *GetName();
|
||||
|
||||
enum ModuleState {
|
||||
MODULE_UNDEFINED = 0,
|
||||
MODULE_INITIALIZING,
|
||||
MODULE_CONNECTING,
|
||||
MODULE_RUNNING,
|
||||
MODULE_DISCONNECTED
|
||||
};
|
||||
|
||||
virtual int GetState();
|
||||
virtual int GetVersion();
|
||||
virtual void ShutDown();
|
||||
virtual char *COM_GetBaseDir() { return ""; }
|
||||
void FireSignal(unsigned int signal, void *data);
|
||||
void FireSignal(unsigned int signal, void *data = nullptr);
|
||||
|
||||
protected:
|
||||
IBaseSystem *m_System;
|
||||
@ -51,5 +73,3 @@ protected:
|
||||
unsigned int m_Serial;
|
||||
double m_SystemTime;
|
||||
};
|
||||
|
||||
#endif // BASESYSTEMMODULE_H
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef IADMINSERVER_H
|
||||
#define IADMINSERVER_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 "interface.h"
|
||||
|
||||
@ -28,6 +52,3 @@ public:
|
||||
};
|
||||
|
||||
#define ADMINSERVER_INTERFACE_VERSION "AdminServer002"
|
||||
|
||||
|
||||
#endif // IAdminServer_H
|
||||
|
@ -1,15 +1,39 @@
|
||||
#ifndef IBASESYSTEM_H
|
||||
#define IBASESYSTEM_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 "ISystemModule.h"
|
||||
#include "IVGuiModule.h"
|
||||
|
||||
class Panel;
|
||||
class ObjectList;
|
||||
class IFileSystem;
|
||||
class IVGuiModule;
|
||||
|
||||
class IBaseSystem: virtual public ISystemModule {
|
||||
public:
|
||||
@ -22,10 +46,10 @@ public:
|
||||
virtual void Printf(char *fmt, ...) = 0;
|
||||
virtual void DPrintf(char *fmt, ...) = 0;
|
||||
|
||||
virtual void RedirectOutput(char *buffer, int maxSize) = 0;
|
||||
virtual void RedirectOutput(char *buffer = nullptr, int maxSize = 0) = 0;
|
||||
|
||||
virtual IFileSystem *GetFileSystem() = 0;
|
||||
virtual unsigned char *LoadFile(const char *name, int *length) = 0;
|
||||
virtual unsigned char *LoadFile(const char *name, int *length = nullptr) = 0;
|
||||
virtual void FreeFile(unsigned char *fileHandle) = 0;
|
||||
|
||||
virtual void SetTitle(char *text) = 0;
|
||||
@ -55,5 +79,3 @@ public:
|
||||
virtual void Stop() = 0;
|
||||
virtual char *COM_GetBaseDir() = 0;
|
||||
};
|
||||
|
||||
#endif // IBASESYSTEM_H
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef IOBJECTCONTAINER_H
|
||||
#define IOBJECTCONTAINER_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 IObjectContainer {
|
||||
public:
|
||||
@ -21,5 +45,3 @@ public:
|
||||
virtual bool Contains(void *object) = 0;
|
||||
virtual bool IsEmpty() = 0;
|
||||
};
|
||||
|
||||
#endif // IOBJECTCONTAINER_H
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef ISYSTEMMODULE_H
|
||||
#define ISYSTEMMODULE_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 "interface.h"
|
||||
|
||||
@ -15,7 +39,7 @@ public:
|
||||
virtual bool Init(IBaseSystem *system, int serial, char *name) = 0;
|
||||
|
||||
virtual void RunFrame(double time) = 0;
|
||||
virtual void ReceiveSignal(ISystemModule *module, unsigned int signal, void *data) = 0;
|
||||
virtual void ReceiveSignal(ISystemModule *module, unsigned int signal, void *data = nullptr) = 0;
|
||||
virtual void ExecuteCommand(int commandID, char *commandLine) = 0;
|
||||
virtual void RegisterListener(ISystemModule *module) = 0;
|
||||
virtual void RemoveListener(ISystemModule *module) = 0;
|
||||
@ -31,5 +55,3 @@ public:
|
||||
virtual int GetVersion() = 0;
|
||||
virtual void ShutDown() = 0;
|
||||
};
|
||||
|
||||
#endif // ISYSTEMMODULE_H
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef IVGUIMODULE_H
|
||||
#define IVGUIMODULE_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 <vgui/VGUI.h>
|
||||
#include "interface.h"
|
||||
@ -50,5 +74,3 @@ public:
|
||||
};
|
||||
|
||||
#define VGUIMODULE_INTERFACE_VERSION "VGuiModuleAdminServer001"
|
||||
|
||||
#endif // IVGUIMODULE_H
|
||||
|
@ -1,17 +1,50 @@
|
||||
#include "ObjectDictionary.h"
|
||||
#include "maintypes.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.
|
||||
*
|
||||
*/
|
||||
|
||||
ObjectDictionary::ObjectDictionary() :
|
||||
maxSize(0),
|
||||
size(0),
|
||||
entries(nullptr)
|
||||
#include "precompiled.h"
|
||||
|
||||
ObjectDictionary::ObjectDictionary()
|
||||
{
|
||||
m_currentEntry = 0;
|
||||
m_findKey = 0;
|
||||
m_entries = nullptr;
|
||||
|
||||
memset(m_cache, 0, sizeof(m_cache));
|
||||
|
||||
m_cacheIndex = 0;
|
||||
m_size = 0;
|
||||
m_maxSize = 0;
|
||||
}
|
||||
|
||||
ObjectDictionary::~ObjectDictionary()
|
||||
{
|
||||
if (entries) {
|
||||
free(entries);
|
||||
if (m_entries) {
|
||||
free(m_entries);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,32 +52,32 @@ void ObjectDictionary::Clear(bool freeObjectssMemory)
|
||||
{
|
||||
if (freeObjectssMemory)
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
for (int i = 0; i < m_size; i++)
|
||||
{
|
||||
void *obj = entries[i].object;
|
||||
void *obj = m_entries[i].object;
|
||||
if (obj) {
|
||||
free(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size = 0;
|
||||
m_size = 0;
|
||||
CheckSize();
|
||||
ClearCache();
|
||||
}
|
||||
|
||||
bool ObjectDictionary::Add(void *object, float key)
|
||||
{
|
||||
if (size == maxSize && !CheckSize())
|
||||
if (m_size == m_maxSize && !CheckSize())
|
||||
return false;
|
||||
|
||||
entry_t *p;
|
||||
if (size && key < entries[size - 1].key)
|
||||
if (m_size && key < m_entries[m_size - 1].key)
|
||||
{
|
||||
p = &entries[FindClosestAsIndex(key)];
|
||||
p = &m_entries[FindClosestAsIndex(key)];
|
||||
|
||||
entry_t *e1 = &entries[size];
|
||||
entry_t *e2 = &entries[size - 1];
|
||||
entry_t *e1 = &m_entries[m_size];
|
||||
entry_t *e2 = &m_entries[m_size - 1];
|
||||
|
||||
while (p->key <= key) { p++; }
|
||||
while (p != e1)
|
||||
@ -57,11 +90,11 @@ bool ObjectDictionary::Add(void *object, float key)
|
||||
}
|
||||
}
|
||||
else
|
||||
p = &entries[size];
|
||||
p = &m_entries[m_size];
|
||||
|
||||
p->key = key;
|
||||
p->object = object;
|
||||
size++;
|
||||
m_size++;
|
||||
|
||||
ClearCache();
|
||||
AddToCache(p);
|
||||
@ -71,38 +104,37 @@ bool ObjectDictionary::Add(void *object, float key)
|
||||
|
||||
int ObjectDictionary::FindClosestAsIndex(float key)
|
||||
{
|
||||
UNTESTED
|
||||
|
||||
if (size <= 0)
|
||||
if (m_size <= 0)
|
||||
return -1;
|
||||
|
||||
if (key <= entries->key)
|
||||
if (key <= m_entries->key)
|
||||
return 0;
|
||||
|
||||
int index = FindKeyInCache(key);
|
||||
if (index >= 0)
|
||||
if (index >= 0) {
|
||||
return index;
|
||||
}
|
||||
|
||||
int middle;
|
||||
int first = 0;
|
||||
int last = size - 1;
|
||||
int last = m_size - 1;
|
||||
float keyMiddle, keyNext;
|
||||
|
||||
if (key == entries[last].key)
|
||||
if (key < m_entries[last].key)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
middle = (last + first) >> 1;
|
||||
keyMiddle = entries[middle].key;
|
||||
keyMiddle = m_entries[middle].key;
|
||||
|
||||
if (keyMiddle == key)
|
||||
break;
|
||||
|
||||
if (keyMiddle < key)
|
||||
{
|
||||
if (entries[middle + 1].key != key)
|
||||
if (m_entries[middle + 1].key >= key)
|
||||
{
|
||||
if (entries[middle + 1].key - key < key - keyMiddle)
|
||||
if (m_entries[middle + 1].key - key < key - keyMiddle)
|
||||
++middle;
|
||||
break;
|
||||
}
|
||||
@ -120,29 +152,29 @@ int ObjectDictionary::FindClosestAsIndex(float key)
|
||||
middle = last;
|
||||
}
|
||||
|
||||
keyNext = entries[middle - 1].key;
|
||||
keyNext = m_entries[middle - 1].key;
|
||||
while (keyNext == key) {
|
||||
keyNext = entries[middle--].key;
|
||||
keyNext = m_entries[middle--].key;
|
||||
}
|
||||
|
||||
AddToCache(&entries[middle], key);
|
||||
AddToCache(&m_entries[middle], key);
|
||||
return middle;
|
||||
}
|
||||
|
||||
void ObjectDictionary::ClearCache()
|
||||
{
|
||||
memset(cache, 0, sizeof(cache));
|
||||
cacheIndex = 0;
|
||||
memset(m_cache, 0, sizeof(m_cache));
|
||||
m_cacheIndex = 0;
|
||||
}
|
||||
|
||||
bool ObjectDictionary::RemoveIndex(int index, bool freeObjectMemory)
|
||||
{
|
||||
if (index < 0 || index >= size)
|
||||
if (index < 0 || index >= m_size)
|
||||
return false;
|
||||
|
||||
entry_t *p = &entries[size - 1];
|
||||
entry_t *e1 = &entries[size];
|
||||
entry_t *e2 = &entries[size + 1];
|
||||
entry_t *p = &m_entries[m_size - 1];
|
||||
entry_t *e1 = &m_entries[index];
|
||||
entry_t *e2 = &m_entries[index + 1];
|
||||
|
||||
if (freeObjectMemory && e1->object)
|
||||
free(e1->object);
|
||||
@ -158,7 +190,7 @@ bool ObjectDictionary::RemoveIndex(int index, bool freeObjectMemory)
|
||||
|
||||
p->object = nullptr;
|
||||
p->key = 0;
|
||||
size--;
|
||||
m_size--;
|
||||
|
||||
CheckSize();
|
||||
ClearCache();
|
||||
@ -173,20 +205,20 @@ bool ObjectDictionary::RemoveIndexRange(int minIndex, int maxIndex)
|
||||
if (maxIndex < 0)
|
||||
maxIndex = 0;
|
||||
|
||||
if (minIndex >= size)
|
||||
minIndex = size - 1;
|
||||
if (minIndex >= m_size)
|
||||
minIndex = m_size - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (minIndex < 0)
|
||||
minIndex = 0;
|
||||
|
||||
if (maxIndex >= size)
|
||||
maxIndex = size - 1;
|
||||
if (maxIndex >= m_size)
|
||||
maxIndex = m_size - 1;
|
||||
}
|
||||
|
||||
int offset = minIndex + maxIndex - 1;
|
||||
size -= offset;
|
||||
m_size -= offset;
|
||||
CheckSize();
|
||||
return true;
|
||||
}
|
||||
@ -194,9 +226,9 @@ bool ObjectDictionary::RemoveIndexRange(int minIndex, int maxIndex)
|
||||
bool ObjectDictionary::Remove(void *object)
|
||||
{
|
||||
bool found = false;
|
||||
for (int i = 0; i < size; ++i)
|
||||
for (int i = 0; i < m_size; i++)
|
||||
{
|
||||
if (entries[i].object == object) {
|
||||
if (m_entries[i].object == object) {
|
||||
RemoveIndex(i);
|
||||
found = true;
|
||||
}
|
||||
@ -207,9 +239,9 @@ bool ObjectDictionary::Remove(void *object)
|
||||
|
||||
bool ObjectDictionary::RemoveSingle(void *object)
|
||||
{
|
||||
for (int i = 0; i < size; ++i)
|
||||
for (int i = 0; i < m_size; i++)
|
||||
{
|
||||
if (entries[i].object == object) {
|
||||
if (m_entries[i].object == object) {
|
||||
RemoveIndex(i);
|
||||
return true;
|
||||
}
|
||||
@ -221,13 +253,13 @@ bool ObjectDictionary::RemoveSingle(void *object)
|
||||
bool ObjectDictionary::RemoveKey(float key)
|
||||
{
|
||||
int i = FindClosestAsIndex(key);
|
||||
if (entries[i].key == key)
|
||||
if (m_entries[i].key == key)
|
||||
{
|
||||
int j = i;
|
||||
do {
|
||||
++j;
|
||||
}
|
||||
while (key == entries[j + 1].key);
|
||||
while (key == m_entries[j + 1].key);
|
||||
|
||||
return RemoveIndexRange(i, j);
|
||||
}
|
||||
@ -237,32 +269,32 @@ bool ObjectDictionary::RemoveKey(float key)
|
||||
|
||||
bool ObjectDictionary::CheckSize()
|
||||
{
|
||||
int newSize = maxSize;
|
||||
if (size == maxSize)
|
||||
int newSize = m_maxSize;
|
||||
if (m_size == m_maxSize)
|
||||
{
|
||||
newSize = 1 - (int)(maxSize * -1.25f);
|
||||
newSize = 1 - (int)(m_maxSize * -1.25f);
|
||||
}
|
||||
else if (maxSize * 0.5f >size)
|
||||
else if (m_maxSize * 0.5f > m_size)
|
||||
{
|
||||
newSize = (int)(maxSize * 0.75f);
|
||||
newSize = (int)(m_maxSize * 0.75f);
|
||||
}
|
||||
|
||||
if (newSize != maxSize)
|
||||
if (newSize != m_maxSize)
|
||||
{
|
||||
entry_t *newEntries = (entry_t *)malloc(sizeof(entry_t));
|
||||
entry_t *newEntries = (entry_t *)malloc(sizeof(entry_t) * newSize);
|
||||
if (!newEntries)
|
||||
return false;
|
||||
|
||||
memset(&newEntries[size], 0, sizeof(entry_t) * (newSize - size));
|
||||
memset(&newEntries[m_size], 0, sizeof(entry_t) * (newSize - m_size));
|
||||
|
||||
if (entries && size)
|
||||
if (m_entries && m_size)
|
||||
{
|
||||
memcpy(newEntries, entries, sizeof(entry_t) * size);
|
||||
free(entries);
|
||||
memcpy(newEntries, m_entries, sizeof(entry_t) * m_size);
|
||||
free(m_entries);
|
||||
}
|
||||
|
||||
entries = newEntries;
|
||||
maxSize = newSize;
|
||||
m_entries = newEntries;
|
||||
m_maxSize = newSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -270,9 +302,9 @@ bool ObjectDictionary::CheckSize()
|
||||
|
||||
void ObjectDictionary::Init()
|
||||
{
|
||||
size = 0;
|
||||
maxSize = 0;
|
||||
entries = nullptr;
|
||||
m_size = 0;
|
||||
m_maxSize = 0;
|
||||
m_entries = nullptr;
|
||||
|
||||
CheckSize();
|
||||
ClearCache();
|
||||
@ -280,12 +312,12 @@ void ObjectDictionary::Init()
|
||||
|
||||
void ObjectDictionary::Init(int baseSize)
|
||||
{
|
||||
size = 0;
|
||||
maxSize = 0;
|
||||
entries = (entry_t *)Mem_ZeroMalloc(sizeof(entry_t) * baseSize);
|
||||
m_size = 0;
|
||||
m_maxSize = 0;
|
||||
m_entries = (entry_t *)Mem_ZeroMalloc(sizeof(entry_t) * baseSize);
|
||||
|
||||
if (entries) {
|
||||
maxSize = baseSize;
|
||||
if (m_entries) {
|
||||
m_maxSize = baseSize;
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,12 +328,12 @@ bool ObjectDictionary::Add(void *object)
|
||||
|
||||
int ObjectDictionary::CountElements()
|
||||
{
|
||||
return size;
|
||||
return m_size;
|
||||
}
|
||||
|
||||
bool ObjectDictionary::IsEmpty()
|
||||
{
|
||||
return (size == 0) ? true : false;
|
||||
return (m_size == 0) ? true : false;
|
||||
}
|
||||
|
||||
bool ObjectDictionary::Contains(void *object)
|
||||
@ -309,9 +341,9 @@ bool ObjectDictionary::Contains(void *object)
|
||||
if (FindObjectInCache(object) >= 0)
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
for (int i = 0; i < m_size; i++)
|
||||
{
|
||||
entry_t *e = &entries[i];
|
||||
entry_t *e = &m_entries[i];
|
||||
if (e->object == object) {
|
||||
AddToCache(e);
|
||||
return true;
|
||||
@ -323,13 +355,13 @@ bool ObjectDictionary::Contains(void *object)
|
||||
|
||||
void *ObjectDictionary::GetFirst()
|
||||
{
|
||||
currentEntry = 0;
|
||||
m_currentEntry = 0;
|
||||
return GetNext();
|
||||
}
|
||||
|
||||
void *ObjectDictionary::GetLast()
|
||||
{
|
||||
return (size > 0) ? entries[size - 1].object : nullptr;
|
||||
return (m_size > 0) ? m_entries[m_size - 1].object : nullptr;
|
||||
}
|
||||
|
||||
bool ObjectDictionary::ChangeKey(void *object, float newKey)
|
||||
@ -337,33 +369,33 @@ bool ObjectDictionary::ChangeKey(void *object, float newKey)
|
||||
int pos = FindObjectInCache(object);
|
||||
if (pos < 0)
|
||||
{
|
||||
for (pos = 0; pos < size; pos++)
|
||||
for (pos = 0; pos < m_size; pos++)
|
||||
{
|
||||
if (entries[pos].object == object) {
|
||||
AddToCache(&entries[pos]);
|
||||
if (m_entries[pos].object == object) {
|
||||
AddToCache(&m_entries[pos]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos == size) {
|
||||
if (pos == m_size) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
entry_t *p, *e;
|
||||
|
||||
p = &entries[pos];
|
||||
p = &m_entries[pos];
|
||||
if (p->key == newKey)
|
||||
return false;
|
||||
|
||||
int newpos = FindClosestAsIndex(newKey);
|
||||
e = &entries[newpos];
|
||||
e = &m_entries[newpos];
|
||||
if (pos < newpos)
|
||||
{
|
||||
if (e->key > newKey)
|
||||
e--;
|
||||
|
||||
entry_t *e2 = &entries[pos + 1];
|
||||
entry_t *e2 = &m_entries[pos + 1];
|
||||
while (p < e)
|
||||
{
|
||||
p->object = e2->object;
|
||||
@ -378,7 +410,7 @@ bool ObjectDictionary::ChangeKey(void *object, float newKey)
|
||||
if (e->key > newKey)
|
||||
e++;
|
||||
|
||||
entry_t *e2 = &entries[pos - 1];
|
||||
entry_t *e2 = &m_entries[pos - 1];
|
||||
while (p > e)
|
||||
{
|
||||
p->object = e2->object;
|
||||
@ -401,47 +433,47 @@ bool ObjectDictionary::UnsafeChangeKey(void *object, float newKey)
|
||||
int pos = FindObjectInCache(object);
|
||||
if (pos < 0)
|
||||
{
|
||||
for (pos = 0; pos < size; pos++)
|
||||
for (pos = 0; pos < m_size; pos++)
|
||||
{
|
||||
if (entries[pos].object == object) {
|
||||
if (m_entries[pos].object == object) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos == size) {
|
||||
if (pos == m_size) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
entries[pos].key = newKey;
|
||||
m_entries[pos].key = newKey;
|
||||
ClearCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ObjectDictionary::AddToCache(entry_t *entry)
|
||||
{
|
||||
int i = (cacheIndex % 32);
|
||||
int i = (m_cacheIndex % MAX_OBJECT_CACHE);
|
||||
|
||||
cache[i].object = entry;
|
||||
cache[i].key = entry->key;
|
||||
cacheIndex++;
|
||||
m_cache[i].object = entry;
|
||||
m_cache[i].key = entry->key;
|
||||
m_cacheIndex++;
|
||||
}
|
||||
|
||||
void ObjectDictionary::AddToCache(entry_t *entry, float key)
|
||||
{
|
||||
int i = (cacheIndex % 32);
|
||||
int i = (m_cacheIndex % MAX_OBJECT_CACHE);
|
||||
|
||||
cache[i].object = entry;
|
||||
cache[i].key = key;
|
||||
cacheIndex++;
|
||||
m_cache[i].object = entry;
|
||||
m_cache[i].key = key;
|
||||
m_cacheIndex++;
|
||||
}
|
||||
|
||||
int ObjectDictionary::FindKeyInCache(float key)
|
||||
{
|
||||
for (auto& ch : cache)
|
||||
for (auto& ch : m_cache)
|
||||
{
|
||||
if (ch.object && ch.key == key) {
|
||||
return (entry_t *)ch.object - entries;
|
||||
return (entry_t *)ch.object - m_entries;
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,10 +482,10 @@ int ObjectDictionary::FindKeyInCache(float key)
|
||||
|
||||
int ObjectDictionary::FindObjectInCache(void *object)
|
||||
{
|
||||
for (auto& ch : cache)
|
||||
for (auto& ch : m_cache)
|
||||
{
|
||||
if (ch.object && ch.object == object) {
|
||||
return (entry_t *)ch.object - entries;
|
||||
return (entry_t *)ch.object - m_entries;
|
||||
}
|
||||
}
|
||||
|
||||
@ -462,22 +494,22 @@ int ObjectDictionary::FindObjectInCache(void *object)
|
||||
|
||||
void *ObjectDictionary::FindClosestKey(float key)
|
||||
{
|
||||
currentEntry = FindClosestAsIndex(key);
|
||||
m_currentEntry = FindClosestAsIndex(key);
|
||||
return GetNext();
|
||||
}
|
||||
|
||||
void *ObjectDictionary::GetNext()
|
||||
{
|
||||
if (currentEntry < 0 || currentEntry >= size)
|
||||
if (m_currentEntry < 0 || m_currentEntry >= m_size)
|
||||
return nullptr;
|
||||
|
||||
return &entries[currentEntry++];
|
||||
return m_entries[m_currentEntry++].object;
|
||||
}
|
||||
|
||||
void *ObjectDictionary::FindExactKey(float key)
|
||||
{
|
||||
if ((currentEntry = FindClosestAsIndex(key)) < 0)
|
||||
if ((m_currentEntry = FindClosestAsIndex(key)) < 0)
|
||||
return nullptr;
|
||||
|
||||
return (entries[currentEntry].key == key) ? GetNext() : nullptr;
|
||||
return (m_entries[m_currentEntry].key == key) ? GetNext() : nullptr;
|
||||
}
|
||||
|
@ -1,16 +1,35 @@
|
||||
#ifndef OBJECTDICTIONARY_H
|
||||
#define OBJECTDICTIONARY_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 "IObjectContainer.h"
|
||||
|
||||
typedef struct entry_s {
|
||||
void *object;
|
||||
float key;
|
||||
} entry_t;
|
||||
|
||||
class ObjectDictionary: public IObjectContainer {
|
||||
public:
|
||||
ObjectDictionary();
|
||||
@ -48,6 +67,11 @@ public:
|
||||
void ClearCache();
|
||||
bool CheckSize();
|
||||
|
||||
typedef struct entry_s {
|
||||
void *object;
|
||||
float key;
|
||||
} entry_t;
|
||||
|
||||
void AddToCache(entry_t *entry);
|
||||
void AddToCache(entry_t *entry, float key);
|
||||
|
||||
@ -56,18 +80,15 @@ public:
|
||||
int FindClosestAsIndex(float key);
|
||||
|
||||
protected:
|
||||
|
||||
int currentEntry;
|
||||
float findKey;
|
||||
int m_currentEntry;
|
||||
float m_findKey;
|
||||
|
||||
enum { MAX_OBJECT_CACHE = 32 };
|
||||
|
||||
entry_t *entries;
|
||||
entry_t cache[MAX_OBJECT_CACHE];
|
||||
entry_t *m_entries;
|
||||
entry_t m_cache[MAX_OBJECT_CACHE];
|
||||
|
||||
int cacheIndex;
|
||||
int size;
|
||||
int maxSize;
|
||||
int m_cacheIndex;
|
||||
int m_size;
|
||||
int m_maxSize;
|
||||
};
|
||||
|
||||
#endif // OBJECTDICTIONARY_H
|
||||
|
@ -1,14 +1,42 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
ObjectList::ObjectList()
|
||||
{
|
||||
head = tail = current = nullptr;
|
||||
number = 0;
|
||||
m_head = m_tail = m_current = nullptr;
|
||||
m_number = 0;
|
||||
}
|
||||
|
||||
ObjectList::~ObjectList()
|
||||
{
|
||||
ObjectList::Clear(false);
|
||||
Clear(false);
|
||||
}
|
||||
|
||||
bool ObjectList::AddHead(void *newObject)
|
||||
@ -23,20 +51,19 @@ bool ObjectList::AddHead(void *newObject)
|
||||
// insert element
|
||||
newElement->object = newObject;
|
||||
|
||||
if (head)
|
||||
if (m_head)
|
||||
{
|
||||
newElement->next = head;
|
||||
head->prev = newElement;
|
||||
newElement->next = m_head;
|
||||
m_head->prev = newElement;
|
||||
}
|
||||
|
||||
head = newElement;
|
||||
m_head = newElement;
|
||||
|
||||
// if list was empty set new tail
|
||||
if (!tail)
|
||||
tail = head;
|
||||
|
||||
number++;
|
||||
// if list was empty set new m_tail
|
||||
if (!m_tail)
|
||||
m_tail = m_head;
|
||||
|
||||
m_number++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -44,23 +71,23 @@ void *ObjectList::RemoveHead()
|
||||
{
|
||||
void *retObj;
|
||||
|
||||
// check head is present
|
||||
if (head)
|
||||
// check m_head is present
|
||||
if (m_head)
|
||||
{
|
||||
retObj = head->object;
|
||||
element_t *newHead = head->next;
|
||||
retObj = m_head->object;
|
||||
element_t *newHead = m_head->next;
|
||||
if (newHead)
|
||||
newHead->prev = nullptr;
|
||||
|
||||
// if only one element is in list also update tail
|
||||
// if only one element is in list also update m_tail
|
||||
// if we remove this prev element
|
||||
if (tail == head)
|
||||
tail = nullptr;
|
||||
if (m_tail == m_head)
|
||||
m_tail = nullptr;
|
||||
|
||||
free(head);
|
||||
head = newHead;
|
||||
free(m_head);
|
||||
m_head = newHead;
|
||||
|
||||
number--;
|
||||
m_number--;
|
||||
}
|
||||
else
|
||||
retObj = nullptr;
|
||||
@ -80,19 +107,19 @@ bool ObjectList::AddTail(void *newObject)
|
||||
// insert element
|
||||
newElement->object = newObject;
|
||||
|
||||
if (tail)
|
||||
if (m_tail)
|
||||
{
|
||||
newElement->prev = tail;
|
||||
tail->next = newElement;
|
||||
newElement->prev = m_tail;
|
||||
m_tail->next = newElement;
|
||||
}
|
||||
|
||||
tail = newElement;
|
||||
m_tail = newElement;
|
||||
|
||||
// if list was empty set new tail
|
||||
if (!head)
|
||||
head = tail;
|
||||
// if list was empty set new m_tail
|
||||
if (!m_head)
|
||||
m_head = m_tail;
|
||||
|
||||
number++;
|
||||
m_number++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -100,23 +127,23 @@ void *ObjectList::RemoveTail()
|
||||
{
|
||||
void *retObj;
|
||||
|
||||
// check tail is present
|
||||
if (tail)
|
||||
// check m_tail is present
|
||||
if (m_tail)
|
||||
{
|
||||
retObj = tail->object;
|
||||
element_t *newTail = tail->prev;
|
||||
retObj = m_tail->object;
|
||||
element_t *newTail = m_tail->prev;
|
||||
if (newTail)
|
||||
newTail->next = nullptr;
|
||||
|
||||
// if only one element is in list also update tail
|
||||
// if only one element is in list also update m_tail
|
||||
// if we remove this prev element
|
||||
if (head == tail)
|
||||
head = nullptr;
|
||||
if (m_head == m_tail)
|
||||
m_head = nullptr;
|
||||
|
||||
free(tail);
|
||||
tail = newTail;
|
||||
free(m_tail);
|
||||
m_tail = newTail;
|
||||
|
||||
number--;
|
||||
m_number--;
|
||||
|
||||
}
|
||||
else
|
||||
@ -127,23 +154,23 @@ void *ObjectList::RemoveTail()
|
||||
|
||||
bool ObjectList::IsEmpty()
|
||||
{
|
||||
return (head == nullptr);
|
||||
return (m_head == nullptr);
|
||||
}
|
||||
|
||||
int ObjectList::CountElements()
|
||||
{
|
||||
return number;
|
||||
return m_number;
|
||||
}
|
||||
|
||||
bool ObjectList::Contains(void *object)
|
||||
{
|
||||
element_t *e = head;
|
||||
element_t *e = m_head;
|
||||
|
||||
while (e && e->object != object) { e = e->next; }
|
||||
|
||||
if (e)
|
||||
{
|
||||
current = e;
|
||||
m_current = e;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -155,7 +182,7 @@ bool ObjectList::Contains(void *object)
|
||||
void ObjectList::Clear(bool freeElementsMemory)
|
||||
{
|
||||
element_t *ne;
|
||||
element_t *e = head;
|
||||
element_t *e = m_head;
|
||||
|
||||
while (e)
|
||||
{
|
||||
@ -168,13 +195,13 @@ void ObjectList::Clear(bool freeElementsMemory)
|
||||
e = ne;
|
||||
}
|
||||
|
||||
head = tail = current = nullptr;
|
||||
number = 0;
|
||||
m_head = m_tail = m_current = nullptr;
|
||||
m_number = 0;
|
||||
}
|
||||
|
||||
bool ObjectList::Remove(void *object)
|
||||
{
|
||||
element_t *e = head;
|
||||
element_t *e = m_head;
|
||||
|
||||
while (e && e->object != object) { e = e->next; }
|
||||
|
||||
@ -183,12 +210,12 @@ bool ObjectList::Remove(void *object)
|
||||
if (e->prev) e->prev->next = e->next;
|
||||
if (e->next) e->next->prev = e->prev;
|
||||
|
||||
if (head == e) head = e->next;
|
||||
if (tail == e) tail = e->prev;
|
||||
if (current == e) current= e->next;
|
||||
if (m_head == e) m_head = e->next;
|
||||
if (m_tail == e) m_tail = e->prev;
|
||||
if (m_current == e) m_current= e->next;
|
||||
|
||||
free(e);
|
||||
number--;
|
||||
m_number--;
|
||||
}
|
||||
|
||||
return (e != nullptr);
|
||||
@ -196,20 +223,20 @@ bool ObjectList::Remove(void *object)
|
||||
|
||||
void ObjectList::Init()
|
||||
{
|
||||
head = tail = current = nullptr;
|
||||
number = 0;
|
||||
m_head = m_tail = m_current = nullptr;
|
||||
m_number = 0;
|
||||
}
|
||||
|
||||
void *ObjectList::GetFirst()
|
||||
{
|
||||
if (head)
|
||||
if (m_head)
|
||||
{
|
||||
current = head->next;
|
||||
return head->object;
|
||||
m_current = m_head->next;
|
||||
return m_head->object;
|
||||
}
|
||||
else
|
||||
{
|
||||
current = nullptr;
|
||||
m_current = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -217,10 +244,10 @@ void *ObjectList::GetFirst()
|
||||
void *ObjectList::GetNext()
|
||||
{
|
||||
void *retObj = nullptr;
|
||||
if (current)
|
||||
if (m_current)
|
||||
{
|
||||
retObj = current->object;
|
||||
current = current->next;
|
||||
retObj = m_current->object;
|
||||
m_current = m_current->next;
|
||||
}
|
||||
|
||||
return retObj;
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef OBJECTLIST_H
|
||||
#define OBJECTLIST_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 "IObjectContainer.h"
|
||||
|
||||
@ -28,16 +52,14 @@ public:
|
||||
bool IsEmpty();
|
||||
|
||||
typedef struct element_s {
|
||||
element_s *prev; // pointer to the last element or NULL
|
||||
element_s *next; // pointer to the next elemnet or NULL
|
||||
struct element_s *prev; // pointer to the last element or NULL
|
||||
struct element_s *next; // pointer to the next elemnet or NULL
|
||||
void *object; // the element's object
|
||||
} element_t;
|
||||
|
||||
protected:
|
||||
element_t *head; // first element in list
|
||||
element_t *tail; // last element in list
|
||||
element_t *current; // current element in list
|
||||
int number;
|
||||
element_t *m_head; // first element in list
|
||||
element_t *m_tail; // last element in list
|
||||
element_t *m_current; // current element in list
|
||||
int m_number;
|
||||
};
|
||||
|
||||
#endif // OBJECTLIST_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"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef STEAMAPPSTARTUP_H
|
||||
#define STEAMAPPSTARTUP_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
|
||||
|
||||
// Call this first thing at startup
|
||||
// Works out if the app is a steam app that is being ran outside of steam,
|
||||
@ -11,5 +35,3 @@
|
||||
// if it returns true, then exit
|
||||
// if it ruturns false, then continue with normal startup
|
||||
bool ShouldLaunchAppViaSteam(const char *cmdLine, const char *steamFilesystemDllName, const char *stdioFilesystemDllName);
|
||||
|
||||
#endif // STEAMAPPSTARTUP_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"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef TEXTCONSOLE_UNIX_H
|
||||
#define TEXTCONSOLE_UNIX_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 <termios.h>
|
||||
#include "textconsole.h"
|
||||
@ -33,5 +57,3 @@ private:
|
||||
};
|
||||
|
||||
extern CTextConsoleUnix console;
|
||||
|
||||
#endif // TEXTCONSOLE_UNIX_H
|
||||
|
@ -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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
CTextConsoleWin32 console;
|
||||
#pragma comment(lib, "user32.lib")
|
||||
|
||||
BOOL WINAPI ConsoleHandlerRoutine(DWORD CtrlType)
|
||||
{
|
||||
@ -217,7 +246,7 @@ int CTextConsoleWin32::GetWidth()
|
||||
void CTextConsoleWin32::SetStatusLine(char *pszStatus)
|
||||
{
|
||||
strncpy(statusline, pszStatus, sizeof(statusline) - 1);
|
||||
statusline[sizeof statusline - 2] = '\0';
|
||||
statusline[sizeof(statusline) - 2] = '\0';
|
||||
UpdateStatus();
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef TEXTCONSOLE_WIN32_H
|
||||
#define TEXTCONSOLE_WIN32_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 <windows.h>
|
||||
#include "TextConsole.h"
|
||||
@ -35,5 +59,3 @@ private:
|
||||
};
|
||||
|
||||
extern CTextConsoleWin32 console;
|
||||
|
||||
#endif // TEXTCONSOLE_WIN32_H
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include "TokenLine.h"
|
||||
#include <string.h>
|
||||
#include "precompiled.h"
|
||||
|
||||
TokenLine::TokenLine()
|
||||
{
|
||||
memset(m_token, 0, sizeof(m_token));
|
||||
memset(m_fullLine, 0, sizeof(m_fullLine));
|
||||
memset(m_tokenBuffer, 0, sizeof(m_tokenBuffer));
|
||||
|
||||
m_tokenNumber = 0;
|
||||
}
|
||||
|
||||
TokenLine::TokenLine(char *string)
|
||||
@ -22,22 +25,20 @@ bool TokenLine::SetLine(const char *newLine)
|
||||
|
||||
if (!newLine || (strlen(newLine) >= (MAX_LINE_CHARS - 1)))
|
||||
{
|
||||
memset(m_fullLine, 0, MAX_LINE_CHARS);
|
||||
memset(m_tokenBuffer, 0, MAX_LINE_CHARS);
|
||||
memset(m_fullLine, 0, sizeof(m_fullLine));
|
||||
memset(m_tokenBuffer, 0, sizeof(m_tokenBuffer));
|
||||
return false;
|
||||
}
|
||||
|
||||
strncpy(m_fullLine, newLine, MAX_LINE_CHARS - 1);
|
||||
m_fullLine[MAX_LINE_CHARS - 1] = '\0';
|
||||
|
||||
strncpy(m_tokenBuffer, newLine, MAX_LINE_CHARS - 1);
|
||||
m_tokenBuffer[MAX_LINE_CHARS - 1] = '\0';
|
||||
strcopy(m_fullLine, newLine);
|
||||
strcopy(m_tokenBuffer, newLine);
|
||||
|
||||
// parse tokens
|
||||
char *charPointer = m_tokenBuffer;
|
||||
while (*charPointer && (m_tokenNumber < MAX_LINE_TOKENS))
|
||||
{
|
||||
while (*charPointer && ((*charPointer <= 32) || (*charPointer > 126)))
|
||||
// skip nonprintable chars
|
||||
while (*charPointer && ((*charPointer <= ' ') || (*charPointer > '~')))
|
||||
charPointer++;
|
||||
|
||||
if (*charPointer)
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef TOKENLINE_H
|
||||
#define TOKENLINE_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 TokenLine {
|
||||
public:
|
||||
@ -10,11 +34,11 @@ public:
|
||||
TokenLine(char *string);
|
||||
virtual ~TokenLine();
|
||||
|
||||
char *GetRestOfLine(int i); // returns all chars after token i
|
||||
int CountToken(); // returns number of token
|
||||
char *GetRestOfLine(int i); // returns all chars after token i
|
||||
int CountToken(); // returns number of token
|
||||
char *CheckToken(char *parm); // returns token after token parm or ""
|
||||
char *GetToken(int i); // returns token i
|
||||
char *GetLine(); // returns full line
|
||||
char *GetToken(int i); // returns token i
|
||||
char *GetLine(); // returns full line
|
||||
bool SetLine(const char *newLine); // set new token line and parses it
|
||||
|
||||
private:
|
||||
@ -25,5 +49,3 @@ private:
|
||||
char *m_token[MAX_LINE_TOKENS];
|
||||
int m_tokenNumber;
|
||||
};
|
||||
|
||||
#endif // TOKENLINE_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
@ -13,12 +13,13 @@
|
||||
|
||||
#define TYPE_CLIENT 0 // client is a normal HL client (default)
|
||||
#define TYPE_PROXY 1 // client is another proxy
|
||||
#define TYPE_DIRECTOR 2
|
||||
#define TYPE_COMMENTATOR 3 // client is a commentator
|
||||
#define TYPE_DEMO 4 // client is a demo file
|
||||
|
||||
// sub commands of svc_hltv:
|
||||
#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands
|
||||
#define HLTV_STATUS 1 // send status infos about proxy
|
||||
#define HLTV_STATUS 1 // send status infos about proxy
|
||||
#define HLTV_LISTEN 2 // tell client to listen to a multicast stream
|
||||
|
||||
// director command types:
|
||||
@ -44,7 +45,7 @@
|
||||
|
||||
// DRC_CMD_EVENT event flags
|
||||
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
|
||||
#define DRC_FLAG_SIDE (1<<4) //
|
||||
#define DRC_FLAG_SIDE (1<<4) //
|
||||
#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene
|
||||
#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo
|
||||
#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc)
|
||||
|
@ -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"
|
||||
|
||||
bool CTextConsole::Init(IBaseSystem *system)
|
||||
{
|
||||
@ -223,7 +251,7 @@ void CTextConsole::ReceiveTab()
|
||||
if (Q_strcmp(szCommonCmd, m_szConsoleText))
|
||||
{
|
||||
Q_strcpy(m_szConsoleText, szCommonCmd);
|
||||
m_nConsoleTextLen = Q_strlen(szCommonCmd);
|
||||
m_nConsoleTextLen = Q_strlen(szCommonCmd);
|
||||
}
|
||||
|
||||
Echo(m_szConsoleText);
|
||||
|
@ -1,8 +1,32 @@
|
||||
#ifndef TEXTCONSOLE_H
|
||||
#define TEXTCONSOLE_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 "IBaseSystem.h"
|
||||
|
||||
@ -67,5 +91,3 @@ protected:
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
void Sys_Printf(char *fmt, ...);
|
||||
|
||||
#endif // TEXTCONSOLE_H
|
||||
|
@ -59,9 +59,8 @@ void setupToolchain(NativeBinarySpec b) {
|
||||
} else {
|
||||
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti'
|
||||
}
|
||||
|
||||
cfg.compilerOptions.args '-fno-exceptions'
|
||||
cfg.linkerOptions.stripSymbolTable = false;
|
||||
cfg.linkerOptions.staticLibStdCpp = false;
|
||||
cfg.extraLibs 'dl'
|
||||
}
|
||||
|
||||
|
@ -1,137 +1,5 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
class CPerformanceCounter
|
||||
{
|
||||
public:
|
||||
CPerformanceCounter();
|
||||
|
||||
void InitializePerformanceCounter();
|
||||
double GetCurTime();
|
||||
|
||||
private:
|
||||
int m_iLowShift;
|
||||
double m_flPerfCounterFreq;
|
||||
double m_flCurrentTime;
|
||||
double m_flLastCurrentTime;
|
||||
};
|
||||
|
||||
inline CPerformanceCounter::CPerformanceCounter() :
|
||||
m_iLowShift(0),
|
||||
m_flPerfCounterFreq(0),
|
||||
m_flCurrentTime(0),
|
||||
m_flLastCurrentTime(0)
|
||||
{
|
||||
InitializePerformanceCounter();
|
||||
}
|
||||
|
||||
inline void CPerformanceCounter::InitializePerformanceCounter()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
LARGE_INTEGER performanceFreq;
|
||||
QueryPerformanceFrequency(&performanceFreq);
|
||||
|
||||
// get 32 out of the 64 time bits such that we have around
|
||||
// 1 microsecond resolution
|
||||
unsigned int lowpart, highpart;
|
||||
lowpart = (unsigned int)performanceFreq.LowPart;
|
||||
highpart = (unsigned int)performanceFreq.HighPart;
|
||||
m_iLowShift = 0;
|
||||
|
||||
while (highpart || (lowpart > 2000000.0))
|
||||
{
|
||||
m_iLowShift++;
|
||||
lowpart >>= 1;
|
||||
lowpart |= (highpart & 1) << 31;
|
||||
highpart >>= 1;
|
||||
}
|
||||
|
||||
m_flPerfCounterFreq = 1.0 / (double)lowpart;
|
||||
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
inline double CPerformanceCounter::GetCurTime()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
static int sametimecount;
|
||||
static unsigned int oldtime;
|
||||
static int first = 1;
|
||||
LARGE_INTEGER PerformanceCount;
|
||||
unsigned int temp, t2;
|
||||
double time;
|
||||
|
||||
QueryPerformanceCounter(&PerformanceCount);
|
||||
if (m_iLowShift == 0)
|
||||
{
|
||||
temp = (unsigned int)PerformanceCount.LowPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = ((unsigned int)PerformanceCount.LowPart >> m_iLowShift) |
|
||||
((unsigned int)PerformanceCount.HighPart << (32 - m_iLowShift));
|
||||
}
|
||||
|
||||
if (first)
|
||||
{
|
||||
oldtime = temp;
|
||||
first = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// check for turnover or backward time
|
||||
if ((temp <= oldtime) && ((oldtime - temp) < 0x10000000))
|
||||
{
|
||||
// so we can't get stuck
|
||||
oldtime = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
t2 = temp - oldtime;
|
||||
|
||||
time = (double)t2 * m_flPerfCounterFreq;
|
||||
oldtime = temp;
|
||||
|
||||
m_flCurrentTime += time;
|
||||
|
||||
if (m_flCurrentTime == m_flLastCurrentTime)
|
||||
{
|
||||
if (++sametimecount > 100000)
|
||||
{
|
||||
m_flCurrentTime += 1.0;
|
||||
sametimecount = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sametimecount = 0;
|
||||
}
|
||||
|
||||
m_flLastCurrentTime = m_flCurrentTime;
|
||||
}
|
||||
}
|
||||
|
||||
return m_flCurrentTime;
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
struct timeval tp;
|
||||
static int secbase = 0;
|
||||
|
||||
gettimeofday(&tp, NULL);
|
||||
|
||||
if (!secbase)
|
||||
{
|
||||
secbase = tp.tv_sec;
|
||||
return (tp.tv_usec / 1000000.0);
|
||||
}
|
||||
|
||||
return ((tp.tv_sec - secbase) + tp.tv_usec / 1000000.0);
|
||||
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
void _LogFunctionTrace(const char *pFunctionName, const char *param)
|
||||
{
|
||||
//{
|
||||
@ -141,7 +9,7 @@ void _LogFunctionTrace(const char *pFunctionName, const char *param)
|
||||
|
||||
double _StartFunctionTimer()
|
||||
{
|
||||
//CPerformanceCounter::GetCurTime();
|
||||
//CCounter::GetCurTime();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -149,7 +17,7 @@ void _LogFunctionTraceMaxTime(const char *pFunctionName, double startTime, doubl
|
||||
{
|
||||
//{
|
||||
// double timeDiff;
|
||||
// CPerformanceCounter::GetCurTime();
|
||||
// CCounter::GetCurTime();
|
||||
// _LogFunctionTrace(const char *pFunctionName, const char *param);
|
||||
//}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
#ifndef ICOMMANDLINE_H
|
||||
#define ICOMMANDLINE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Interface to engine command line
|
||||
class ICommandLine {
|
||||
public:
|
||||
virtual void CreateCmdLine(const char *commandline) = 0;
|
||||
virtual void CreateCmdLine(int argc, const char **argv) = 0;
|
||||
virtual const char *GetCmdLine() const = 0;
|
||||
|
||||
// Check whether a particular parameter exists
|
||||
virtual const char *CheckParm(const char *psz, char **ppszValue = nullptr) const = 0;
|
||||
virtual void RemoveParm(const char *pszParm) = 0;
|
||||
virtual void AppendParm(const char *pszParm, const char *pszValues) = 0;
|
||||
|
||||
virtual void SetParm(const char *pszParm, const char *pszValues) = 0;
|
||||
virtual void SetParm(const char *pszParm, int iValue) = 0;
|
||||
};
|
||||
|
||||
ICommandLine *CommandLine();
|
||||
|
||||
#endif // ICOMMANDLINE_H
|
@ -19,7 +19,6 @@ struct DLL_FUNCTIONS;
|
||||
#endif
|
||||
|
||||
#include "sys_ded.h"
|
||||
#include "icommandline.h"
|
||||
#include "textconsole.h"
|
||||
#include "vgui/vguihelpers.h"
|
||||
|
||||
|
@ -33,12 +33,6 @@ char serverinfo[MAX_INFO_STRING];
|
||||
char gpszVersionString[32];
|
||||
char gpszProductString[32];
|
||||
|
||||
char* strcpy_safe(char* dst, char* src) {
|
||||
int len = Q_strlen(src);
|
||||
Q_memmove(dst, src, len + 1);
|
||||
return dst;
|
||||
}
|
||||
|
||||
char *Info_Serverinfo(void)
|
||||
{
|
||||
return serverinfo;
|
||||
|
@ -220,8 +220,25 @@ NOBODY uint64 Q_strtoull(char *str);
|
||||
|
||||
#endif // Q_functions
|
||||
|
||||
//strcpy that works correctly with overlapping src and dst buffers
|
||||
char* strcpy_safe(char* dst, char* src);
|
||||
template <size_t N>
|
||||
char *strcopy(char (&dest)[N], const char *src) {
|
||||
Q_strncpy(dest, src, N - 1);
|
||||
dest[N - 1] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
inline char *strncopy(char *dest, const char *src, size_t n) {
|
||||
Q_strncpy(dest, src, n - 1);
|
||||
dest[n - 1] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
// strcpy that works correctly with overlapping src and dst buffers
|
||||
inline char *strcpy_safe(char *dst, char *src) {
|
||||
int len = Q_strlen(src);
|
||||
Q_memmove(dst, src, len + 1);
|
||||
return dst;
|
||||
}
|
||||
|
||||
int build_number(void);
|
||||
char *Info_Serverinfo(void);
|
||||
|
@ -86,7 +86,7 @@ enum
|
||||
{
|
||||
FRAG_NORMAL_STREAM = 0,
|
||||
FRAG_FILE_STREAM,
|
||||
|
||||
|
||||
MAX_STREAMS
|
||||
};
|
||||
|
||||
@ -224,7 +224,7 @@ enum
|
||||
{
|
||||
FLOW_OUTGOING = 0,
|
||||
FLOW_INCOMING,
|
||||
|
||||
|
||||
MAX_FLOWS
|
||||
};
|
||||
|
||||
|
@ -1408,7 +1408,7 @@ void SV_WriteClientdataToMessage(client_t *client, sizebuf_t *msg)
|
||||
#ifdef REHLDS_FIXES
|
||||
// So, HL and CS games send absolute gametime in these vars, DMC and Ricochet games don't send absolute gametime
|
||||
// TODO: idk about other games
|
||||
// FIXME: there is a loss of precision, because gamedll has already written float gametime in them
|
||||
// FIXME: there is a loss of precision, because gamedll has already written float gametime in them
|
||||
if (sv_rehlds_local_gametime.value != 0.0f)
|
||||
{
|
||||
auto convertGlobalGameTimeToLocal =
|
||||
@ -5255,7 +5255,7 @@ void SV_CreateGenericResources(void)
|
||||
Con_Printf("Can't precache .dll files: %s\n", com_token);
|
||||
else
|
||||
successful = true;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
successful = true;
|
||||
@ -5642,7 +5642,7 @@ void SetCStrikeFlags(void)
|
||||
g_eGameType = GT_CZero;
|
||||
#else
|
||||
g_bIsCZero = 1;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else if (!Q_stricmp(com_gamedir, "czeror"))
|
||||
{
|
||||
@ -5650,7 +5650,7 @@ void SetCStrikeFlags(void)
|
||||
g_eGameType = GT_CZeroRitual;
|
||||
#else
|
||||
g_bIsCZeroRitual = 1;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else if (!Q_stricmp(com_gamedir, "terror"))
|
||||
{
|
||||
@ -5658,7 +5658,7 @@ void SetCStrikeFlags(void)
|
||||
g_eGameType = GT_TerrorStrike;
|
||||
#else
|
||||
g_bIsTerrorStrike = 1;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else if (!Q_stricmp(com_gamedir, "tfc"))
|
||||
{
|
||||
@ -5666,7 +5666,7 @@ void SetCStrikeFlags(void)
|
||||
g_eGameType = GT_TFC;
|
||||
#else
|
||||
g_bIsTFC = 1;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef REHLDS_FIXES
|
||||
|
@ -36,16 +36,6 @@ CServerRemoteAccess::CServerRemoteAccess() {
|
||||
}
|
||||
|
||||
void CServerRemoteAccess::WriteDataRequest(const void *buffer, int bufferSize)
|
||||
{
|
||||
WriteDataRequest_noVirt(buffer, bufferSize);
|
||||
}
|
||||
|
||||
int CServerRemoteAccess::ReadDataResponse(void *data, int len)
|
||||
{
|
||||
return ReadDataResponse_noVirt(data, len);
|
||||
}
|
||||
|
||||
void CServerRemoteAccess::WriteDataRequest_noVirt(const void *buffer, int bufferSize)
|
||||
{
|
||||
int requestID;
|
||||
int requestType;
|
||||
@ -78,7 +68,7 @@ void CServerRemoteAccess::WriteDataRequest_noVirt(const void *buffer, int buffer
|
||||
}
|
||||
}
|
||||
|
||||
int CServerRemoteAccess::ReadDataResponse_noVirt(void *data, int len)
|
||||
int CServerRemoteAccess::ReadDataResponse(void *data, int len)
|
||||
{
|
||||
int i = m_ResponsePackets.Head();
|
||||
if (!m_ResponsePackets.IsValidIndex(i))
|
||||
|
@ -52,9 +52,6 @@ public:
|
||||
virtual void WriteDataRequest(const void *buffer, int bufferSize);
|
||||
virtual int ReadDataResponse(void *data, int len);
|
||||
|
||||
void WriteDataRequest_noVirt(const void *buffer, int bufferSize);
|
||||
int ReadDataResponse_noVirt(void *data, int len);
|
||||
|
||||
void SendMessageToAdminUI(const char *message);
|
||||
void RequestValue(int requestID, const char *variable);
|
||||
void SetValue(const char *variable, const char *value);
|
||||
|
@ -28,8 +28,6 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
bool (CSteam3Server::*pNotifyClientConnect)(client_t *client, const void *pvSteam2Key, uint32 ucbSteam2Key) = &CSteam3Server::NotifyClientConnect;
|
||||
|
||||
void CSteam3Server::OnGSPolicyResponse(GSPolicyResponse_t *pPolicyResponse)
|
||||
{
|
||||
if (CRehldsPlatformHolder::get()->SteamGameServer()->BSecure())
|
||||
@ -47,7 +45,7 @@ void CSteam3Server::OnLogonSuccess(SteamServersConnected_t *pLogonSuccess)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bLogOnResult = 1;
|
||||
m_bLogOnResult = true;
|
||||
if (!m_bLanOnly)
|
||||
Con_Printf("Connection to Steam servers successful.\n");
|
||||
}
|
||||
@ -107,12 +105,12 @@ void CSteam3Server::OnGSClientDenyHelper(client_t *cl, EDenyReason eDenyReason,
|
||||
break;
|
||||
|
||||
case k_EDenyNotLoggedOn:
|
||||
if (!this->m_bLanOnly)
|
||||
if (!m_bLanOnly)
|
||||
SV_DropClient(cl, 0, "No Steam logon\n");
|
||||
break;
|
||||
|
||||
case k_EDenyLoggedInElseWhere:
|
||||
if (!this->m_bLanOnly)
|
||||
if (!m_bLanOnly)
|
||||
SV_DropClient(cl, 0, "This Steam account is being used in another location\n");
|
||||
break;
|
||||
|
||||
@ -144,12 +142,12 @@ void CSteam3Server::OnGSClientDenyHelper(client_t *cl, EDenyReason eDenyReason,
|
||||
break;
|
||||
|
||||
case k_EDenySteamConnectionLost:
|
||||
if (!this->m_bLanOnly)
|
||||
if (!m_bLanOnly)
|
||||
SV_DropClient(cl, 0, "Steam connection lost\n");
|
||||
break;
|
||||
|
||||
case k_EDenySteamConnectionError:
|
||||
if (!this->m_bLanOnly)
|
||||
if (!m_bLanOnly)
|
||||
SV_DropClient(cl, 0, "Unable to connect to Steam\n");
|
||||
break;
|
||||
|
||||
@ -158,7 +156,7 @@ void CSteam3Server::OnGSClientDenyHelper(client_t *cl, EDenyReason eDenyReason,
|
||||
break;
|
||||
|
||||
case k_EDenySteamValidationStalled:
|
||||
if (this->m_bLanOnly)
|
||||
if (m_bLanOnly)
|
||||
cl->network_userid.m_SteamID = 1;
|
||||
break;
|
||||
|
||||
@ -253,7 +251,7 @@ void CSteam3Server::Activate()
|
||||
if (m_bLoggedOn)
|
||||
{
|
||||
bLanOnly = sv_lan.value != 0.0;
|
||||
if (this->m_bLanOnly != bLanOnly)
|
||||
if (m_bLanOnly != bLanOnly)
|
||||
{
|
||||
m_bLanOnly = bLanOnly;
|
||||
m_bWantToBeSecure = !COM_CheckParm("-insecure") && !bLanOnly;
|
||||
@ -261,7 +259,7 @@ void CSteam3Server::Activate()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bLoggedOn = 1;
|
||||
m_bLoggedOn = true;
|
||||
unIP = 0;
|
||||
usSteamPort = 26900;
|
||||
argSteamPort = COM_CheckParm("-sport");
|
||||
@ -333,13 +331,13 @@ void CSteam3Server::Activate()
|
||||
|
||||
void CSteam3Server::Shutdown()
|
||||
{
|
||||
if (this->m_bLoggedOn)
|
||||
if (m_bLoggedOn)
|
||||
{
|
||||
SteamGameServer()->EnableHeartbeats(0);
|
||||
SteamGameServer()->LogOff();
|
||||
|
||||
SteamGameServer_Shutdown();
|
||||
this->m_bLoggedOn = false;
|
||||
m_bLoggedOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,10 +522,10 @@ void CSteam3Server::SendUpdatedServerDetails()
|
||||
|
||||
void CSteam3Client::Shutdown()
|
||||
{
|
||||
if (this->m_bLoggedOn)
|
||||
if (m_bLoggedOn)
|
||||
{
|
||||
SteamAPI_Shutdown();
|
||||
this->m_bLoggedOn = false;
|
||||
m_bLoggedOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -879,7 +877,6 @@ void Master_SetMaster_f()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pszCmd = Cmd_Argv(1);
|
||||
if (!pszCmd || !pszCmd[0])
|
||||
return;
|
||||
@ -890,14 +887,14 @@ void Master_SetMaster_f()
|
||||
{
|
||||
if (gfNoMasterServer)
|
||||
{
|
||||
gfNoMasterServer = 0;
|
||||
gfNoMasterServer = FALSE;
|
||||
CRehldsPlatformHolder::get()->SteamGameServer()->EnableHeartbeats(gfNoMasterServer != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gfNoMasterServer = 1;
|
||||
gfNoMasterServer = TRUE;
|
||||
CRehldsPlatformHolder::get()->SteamGameServer()->EnableHeartbeats(gfNoMasterServer != 0);
|
||||
}
|
||||
}
|
||||
|
@ -127,8 +127,6 @@ public:
|
||||
extern CSteam3Server *s_Steam3Server;
|
||||
extern CSteam3Client s_Steam3Client;
|
||||
|
||||
extern bool (CSteam3Server::*pNotifyClientConnect)(client_t *client, const void *pvSteam2Key, uint32 ucbSteam2Key);
|
||||
|
||||
uint64 ISteamGameServer_CreateUnauthenticatedUserConnection();
|
||||
bool ISteamGameServer_BUpdateUserData(uint64 steamid, const char *netname, uint32 score);
|
||||
bool ISteamApps_BIsSubscribedApp(uint32 appid);
|
||||
|
@ -33,28 +33,12 @@
|
||||
#include "FileSystem.h"
|
||||
#include "pr_dlls.h"
|
||||
|
||||
//vmodes.h must be included before cdll_int.h (wrect_t declaration)
|
||||
// vmodes.h must be included before cdll_int.h (wrect_t declaration)
|
||||
#include "vmodes.h"
|
||||
#include "cdll_int.h"
|
||||
|
||||
|
||||
#define CONST_INTEGER_AS_STRING(x) #x //Wraps the integer in quotes, allowing us to form constant strings with it
|
||||
#define __HACK_LINE_AS_STRING__(x) CONST_INTEGER_AS_STRING(x) //__LINE__ can only be converted to an actual number by going through this, otherwise the output is literally "__LINE__"
|
||||
#define __LINE__AS_STRING __HACK_LINE_AS_STRING__(__LINE__) //Gives you the line number in constant string form
|
||||
|
||||
#if defined _MSC_VER || defined __INTEL_COMPILER
|
||||
#define NOXREFCHECK int __retAddr; __asm { __asm mov eax, [ebp + 4] __asm mov __retAddr, eax }; Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr)
|
||||
#else
|
||||
// For EBP based stack (older gcc) (uncomment version apropriate for your compiler)
|
||||
//#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 4(%%ebp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr);
|
||||
// For ESP based stack (newer gcc) (uncomment version apropriate for your compiler)
|
||||
#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 16(%%esp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr);
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_DISCONNECT_REASON 256
|
||||
|
||||
|
||||
#ifdef HOOK_ENGINE
|
||||
#define g_hfind (*pg_hfind)
|
||||
|
||||
|
@ -92,7 +92,7 @@ void EXPORT F(IEngineAPI **api)
|
||||
{
|
||||
CreateInterfaceFn fn;
|
||||
fn = Sys_GetFactoryThis();
|
||||
*api = (IEngineAPI *)fn("VENGINE_LAUNCHER_API_VERSION002", NULL);
|
||||
*api = (IEngineAPI *)fn(VENGINE_LAUNCHER_API_VERSION, NULL);
|
||||
}
|
||||
|
||||
void Sys_GetCDKey(char *pszCDKey, int *nLength, int *bDedicated)
|
||||
@ -574,25 +574,18 @@ void ClearIOStates(void)
|
||||
#endif // SWDS
|
||||
}
|
||||
|
||||
|
||||
class CEngineAPI : public IEngineAPI
|
||||
class CEngineAPI: public IEngineAPI
|
||||
{
|
||||
public:
|
||||
|
||||
int Run(void *instance, char *basedir, char *cmdline, char *postRestartCmdLineArgs, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
CEngineAPI g_CEngineAPI;
|
||||
|
||||
IBaseInterface *CreateCEngineAPI(void)
|
||||
{
|
||||
return &g_CEngineAPI;
|
||||
};
|
||||
|
||||
InterfaceReg g_CreateCEngineAPI = InterfaceReg(CreateCEngineAPI, "VENGINE_LAUNCHER_API_VERSION002");
|
||||
#ifndef HOOK_ENGINE
|
||||
EXPOSE_SINGLE_INTERFACE(CEngineAPI, IEngineAPI, VENGINE_LAUNCHER_API_VERSION);
|
||||
#endif // HOOK_ENGINE
|
||||
|
||||
// TODO: Needs rechecking
|
||||
/*
|
||||
@ -666,11 +659,6 @@ NOXREF int BuildMapCycleListHints(char **hints)
|
||||
*/
|
||||
|
||||
bool CDedicatedServerAPI::Init(char *basedir, char *cmdline, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory)
|
||||
{
|
||||
return Init_noVirt(basedir, cmdline, launcherFactory, filesystemFactory);
|
||||
}
|
||||
|
||||
bool CDedicatedServerAPI::Init_noVirt(char *basedir, char *cmdline, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory)
|
||||
{
|
||||
dedicated_ = (IDedicatedExports *)launcherFactory(VENGINE_DEDICATEDEXPORTS_API_VERSION, NULL);
|
||||
if (!dedicated_)
|
||||
@ -709,12 +697,7 @@ bool CDedicatedServerAPI::Init_noVirt(char *basedir, char *cmdline, CreateInterf
|
||||
return false;
|
||||
}
|
||||
|
||||
int CDedicatedServerAPI::Shutdown(void)
|
||||
{
|
||||
return Shutdown_noVirt();
|
||||
}
|
||||
|
||||
int CDedicatedServerAPI::Shutdown_noVirt(void)
|
||||
int CDedicatedServerAPI::Shutdown()
|
||||
{
|
||||
eng->Unload();
|
||||
game->Shutdown();
|
||||
@ -729,12 +712,7 @@ int CDedicatedServerAPI::Shutdown_noVirt(void)
|
||||
return giActive;
|
||||
}
|
||||
|
||||
bool CDedicatedServerAPI::RunFrame(void)
|
||||
{
|
||||
return RunFrame_noVirt();
|
||||
}
|
||||
|
||||
bool CDedicatedServerAPI::RunFrame_noVirt(void)
|
||||
bool CDedicatedServerAPI::RunFrame()
|
||||
{
|
||||
if (eng->GetQuitting())
|
||||
return false;
|
||||
@ -744,28 +722,15 @@ bool CDedicatedServerAPI::RunFrame_noVirt(void)
|
||||
}
|
||||
|
||||
void CDedicatedServerAPI::AddConsoleText(char *text)
|
||||
{
|
||||
AddConsoleText_noVirt(text);
|
||||
}
|
||||
|
||||
void CDedicatedServerAPI::AddConsoleText_noVirt(char *text)
|
||||
{
|
||||
Cbuf_AddText(text);
|
||||
}
|
||||
|
||||
void CDedicatedServerAPI::UpdateStatus(float *fps, int *nActive, int *nMaxPlayers, char *pszMap)
|
||||
{
|
||||
UpdateStatus_noVirt(fps, nActive, nMaxPlayers, pszMap);
|
||||
}
|
||||
|
||||
void CDedicatedServerAPI::UpdateStatus_noVirt(float *fps, int *nActive, int *nMaxPlayers, char *pszMap)
|
||||
{
|
||||
Host_GetHostInfo(fps, nActive, NULL, nMaxPlayers, pszMap);
|
||||
}
|
||||
|
||||
#ifndef HOOK_ENGINE
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE(CDedicatedServerAPI, IDedicatedServerAPI, VENGINE_HLDS_API_VERSION);
|
||||
|
||||
#endif // HOOK_ENGINE
|
||||
|
||||
|
@ -72,14 +72,6 @@ public:
|
||||
virtual bool RunFrame();
|
||||
virtual void AddConsoleText(char *text);
|
||||
virtual void UpdateStatus(float *fps, int *nActive, int *nMaxPlayers, char *pszMap);
|
||||
|
||||
// non-virtual function's of wrap for hooks a virtual
|
||||
// Only need to HOOK_ENGINE
|
||||
bool Init_noVirt(char *basedir, char *cmdline, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory);
|
||||
int Shutdown_noVirt();
|
||||
bool RunFrame_noVirt();
|
||||
void AddConsoleText_noVirt(char *text);
|
||||
void UpdateStatus_noVirt(float *fps, int *nActive, int *nMaxPlayers, char *pszMap);
|
||||
};
|
||||
|
||||
const char *GetCurrentSteamAppName();
|
||||
|
@ -64,11 +64,6 @@ CEngine::~CEngine()
|
||||
}
|
||||
|
||||
void CEngine::Unload()
|
||||
{
|
||||
Unload_noVirt();
|
||||
}
|
||||
|
||||
void CEngine::Unload_noVirt()
|
||||
{
|
||||
Sys_ShutdownGame();
|
||||
m_nDLLState = DLL_INACTIVE;
|
||||
@ -98,11 +93,6 @@ void ForceReloadProfile()
|
||||
}
|
||||
|
||||
bool CEngine::Load(bool dedicated, char *basedir, char *cmdline)
|
||||
{
|
||||
return Load_noVirt(dedicated, basedir, cmdline);
|
||||
}
|
||||
|
||||
bool CEngine::Load_noVirt(bool dedicated, char *basedir, char *cmdline)
|
||||
{
|
||||
bool success = false;
|
||||
SetState(DLL_ACTIVE);
|
||||
@ -117,11 +107,6 @@ bool CEngine::Load_noVirt(bool dedicated, char *basedir, char *cmdline)
|
||||
}
|
||||
|
||||
int CEngine::Frame()
|
||||
{
|
||||
return Frame_noVirt();
|
||||
}
|
||||
|
||||
int CEngine::Frame_noVirt()
|
||||
{
|
||||
#ifndef SWDS
|
||||
(*(void(**)(void))(*(_DWORD *)cdaudio + 24))();
|
||||
@ -160,82 +145,42 @@ int CEngine::Frame_noVirt()
|
||||
}
|
||||
|
||||
void CEngine::SetSubState(int iSubState)
|
||||
{
|
||||
SetSubState_noVirt(iSubState);
|
||||
}
|
||||
|
||||
void CEngine::SetSubState_noVirt(int iSubState)
|
||||
{
|
||||
if (iSubState != 1)
|
||||
GameSetSubState(iSubState);
|
||||
}
|
||||
|
||||
void CEngine::SetState(int iState)
|
||||
{
|
||||
SetState_noVirt(iState);
|
||||
}
|
||||
|
||||
void CEngine::SetState_noVirt(int iState)
|
||||
{
|
||||
m_nDLLState = iState;
|
||||
GameSetState(iState);
|
||||
}
|
||||
|
||||
int CEngine::GetState()
|
||||
{
|
||||
return GetState_noVirt();
|
||||
}
|
||||
|
||||
int CEngine::GetState_noVirt()
|
||||
{
|
||||
return m_nDLLState;
|
||||
}
|
||||
|
||||
int CEngine::GetSubState()
|
||||
{
|
||||
return GetSubState_noVirt();
|
||||
}
|
||||
|
||||
int CEngine::GetSubState_noVirt()
|
||||
{
|
||||
return m_nSubState;
|
||||
}
|
||||
|
||||
double CEngine::GetFrameTime()
|
||||
{
|
||||
return GetFrameTime_noVirt();
|
||||
}
|
||||
|
||||
double CEngine::GetFrameTime_noVirt()
|
||||
{
|
||||
return m_fFrameTime;
|
||||
}
|
||||
|
||||
double CEngine::GetCurTime()
|
||||
{
|
||||
return GetCurTime_noVirt();
|
||||
}
|
||||
|
||||
double CEngine::GetCurTime_noVirt()
|
||||
{
|
||||
return m_fCurTime;
|
||||
}
|
||||
|
||||
void CEngine::TrapKey_Event(int key, bool down)
|
||||
{
|
||||
TrapKey_Event_noVirt(key, down);
|
||||
}
|
||||
|
||||
void CEngine::TrapKey_Event_noVirt(int key, bool down)
|
||||
{
|
||||
}
|
||||
|
||||
void CEngine::TrapMouse_Event(int buttons, bool down)
|
||||
{
|
||||
TrapMouse_Event_noVirt(buttons, down);
|
||||
}
|
||||
|
||||
void CEngine::TrapMouse_Event_noVirt(int buttons, bool down)
|
||||
{
|
||||
if (m_bTrapMode && buttons && !down)
|
||||
{
|
||||
@ -251,11 +196,6 @@ void CEngine::TrapMouse_Event_noVirt(int buttons, bool down)
|
||||
}
|
||||
|
||||
void CEngine::StartTrapMode()
|
||||
{
|
||||
StartTrapMode_noVirt();
|
||||
}
|
||||
|
||||
void CEngine::StartTrapMode_noVirt()
|
||||
{
|
||||
if (!m_bTrapMode)
|
||||
{
|
||||
@ -265,21 +205,11 @@ void CEngine::StartTrapMode_noVirt()
|
||||
}
|
||||
|
||||
bool CEngine::IsTrapping()
|
||||
{
|
||||
return IsTrapping_noVirt();
|
||||
}
|
||||
|
||||
bool CEngine::IsTrapping_noVirt()
|
||||
{
|
||||
return m_bTrapMode;
|
||||
}
|
||||
|
||||
bool CEngine::CheckDoneTrapping(int & buttons, int & key)
|
||||
{
|
||||
return CheckDoneTrapping_noVirt(buttons, key);
|
||||
}
|
||||
|
||||
bool CEngine::CheckDoneTrapping_noVirt(int & buttons, int & key)
|
||||
{
|
||||
if (m_bTrapMode)
|
||||
{
|
||||
@ -299,21 +229,11 @@ bool CEngine::CheckDoneTrapping_noVirt(int & buttons, int & key)
|
||||
}
|
||||
|
||||
void CEngine::SetQuitting(int quittype)
|
||||
{
|
||||
SetQuitting_noVirt(quittype);
|
||||
}
|
||||
|
||||
void CEngine::SetQuitting_noVirt(int quittype)
|
||||
{
|
||||
m_nQuitting = quittype;
|
||||
}
|
||||
|
||||
int CEngine::GetQuitting()
|
||||
{
|
||||
return GetQuitting_noVirt();
|
||||
}
|
||||
|
||||
int CEngine::GetQuitting_noVirt()
|
||||
{
|
||||
return m_nQuitting;
|
||||
}
|
||||
|
@ -77,23 +77,4 @@ public:
|
||||
virtual bool CheckDoneTrapping(int& buttons, int& keys);
|
||||
virtual int GetQuitting();
|
||||
virtual void SetQuitting(int quittype);
|
||||
|
||||
// non-virtual function's of wrap for hooks a virtual
|
||||
// Only need to HOOK_ENGINE
|
||||
bool Load_noVirt(bool dedicated, char *rootDir, char *cmdLine);
|
||||
void Unload_noVirt();
|
||||
void SetState_noVirt(int iState);
|
||||
int GetState_noVirt();
|
||||
void SetSubState_noVirt(int iSubstate);
|
||||
int GetSubState_noVirt();
|
||||
int Frame_noVirt();
|
||||
double GetFrameTime_noVirt();
|
||||
double GetCurTime_noVirt();
|
||||
void TrapKey_Event_noVirt(int key, bool down);
|
||||
void TrapMouse_Event_noVirt(int buttons, bool down);
|
||||
void StartTrapMode_noVirt();
|
||||
bool IsTrapping_noVirt();
|
||||
bool CheckDoneTrapping_noVirt(int& buttons, int& keys);
|
||||
int GetQuitting_noVirt();
|
||||
void SetQuitting_noVirt(int quittype);
|
||||
};
|
||||
|
@ -52,41 +52,21 @@ CGame::~CGame()
|
||||
}
|
||||
|
||||
bool CGame::Init(void *pvInstance)
|
||||
{
|
||||
return Init_noVirt(pvInstance);
|
||||
}
|
||||
|
||||
bool CGame::Init_noVirt(void *pvInstance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGame::Shutdown()
|
||||
{
|
||||
return Shutdown_noVirt();
|
||||
}
|
||||
|
||||
bool CGame::Shutdown_noVirt()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGame::CreateGameWindow()
|
||||
{
|
||||
return CreateGameWindow_noVirt();
|
||||
}
|
||||
|
||||
bool CGame::CreateGameWindow_noVirt()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGame::SleepUntilInput(int time)
|
||||
{
|
||||
SleepUntilInput_noVirt(time);
|
||||
}
|
||||
|
||||
void CGame::SleepUntilInput_noVirt(int time)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Sleep(time * 1000);
|
||||
@ -96,49 +76,24 @@ void CGame::SleepUntilInput_noVirt(int time)
|
||||
}
|
||||
|
||||
HWND CGame::GetMainWindow()
|
||||
{
|
||||
return GetMainWindow_noVirt();
|
||||
}
|
||||
|
||||
HWND CGame::GetMainWindow_noVirt()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HWND * CGame::GetMainWindowAddress()
|
||||
{
|
||||
return GetMainWindowAddress_noVirt();
|
||||
}
|
||||
|
||||
HWND * CGame::GetMainWindowAddress_noVirt()
|
||||
HWND *CGame::GetMainWindowAddress()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CGame::SetWindowXY(int x, int y)
|
||||
{
|
||||
SetWindowXY_noVirt(x, y);
|
||||
}
|
||||
|
||||
void CGame::SetWindowXY_noVirt(int x, int y)
|
||||
{
|
||||
}
|
||||
|
||||
void CGame::SetWindowSize(int w, int h)
|
||||
{
|
||||
SetWindowSize_noVirt(w, h);
|
||||
}
|
||||
|
||||
void CGame::SetWindowSize_noVirt(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
void CGame::GetWindowRect(int *x, int *y, int *w, int *h)
|
||||
{
|
||||
GetWindowRect_noVirt(x, y, w, h);
|
||||
}
|
||||
|
||||
void CGame::GetWindowRect_noVirt(int *x, int *y, int *w, int *h)
|
||||
{
|
||||
if (x) *x = 0;
|
||||
if (y) *y = 0;
|
||||
@ -147,48 +102,23 @@ void CGame::GetWindowRect_noVirt(int *x, int *y, int *w, int *h)
|
||||
}
|
||||
|
||||
bool CGame::IsActiveApp()
|
||||
{
|
||||
return IsActiveApp_noVirt();
|
||||
}
|
||||
|
||||
bool CGame::IsActiveApp_noVirt()
|
||||
{
|
||||
return m_bActiveApp;
|
||||
}
|
||||
|
||||
bool CGame::IsMultiplayer()
|
||||
{
|
||||
return IsMultiplayer_noVirt();
|
||||
}
|
||||
|
||||
bool CGame::IsMultiplayer_noVirt()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGame::PlayStartupVideos()
|
||||
{
|
||||
return PlayStartupVideos_noVirt();
|
||||
}
|
||||
|
||||
void CGame::PlayStartupVideos_noVirt()
|
||||
{
|
||||
}
|
||||
|
||||
void CGame::PlayAVIAndWait(const char *aviFile)
|
||||
{
|
||||
PlayAVIAndWait_noVirt(aviFile);
|
||||
}
|
||||
|
||||
void CGame::PlayAVIAndWait_noVirt(const char *aviFile)
|
||||
{
|
||||
}
|
||||
|
||||
void CGame::SetCursorVisible(bool bState)
|
||||
{
|
||||
SetCursorVisible_noVirt(bState);
|
||||
}
|
||||
|
||||
void CGame::SetCursorVisible_noVirt(bool bState)
|
||||
{
|
||||
}
|
||||
|
@ -31,43 +31,26 @@
|
||||
#include "maintypes.h"
|
||||
#include "igame.h"
|
||||
|
||||
class CGame: public IGame {
|
||||
private:
|
||||
bool m_bActiveApp;
|
||||
|
||||
public:
|
||||
CGame();
|
||||
virtual ~CGame();
|
||||
|
||||
virtual bool Init(void *pvInstance);
|
||||
virtual bool Shutdown();
|
||||
virtual bool CreateGameWindow();
|
||||
virtual void SleepUntilInput(int time);
|
||||
virtual HWND GetMainWindow();
|
||||
virtual HWND * GetMainWindowAddress();
|
||||
virtual void SetWindowXY(int x, int y);
|
||||
virtual void SetWindowSize(int w, int h);
|
||||
virtual void GetWindowRect(int *x, int *y, int *w, int *h);
|
||||
virtual bool IsActiveApp();
|
||||
virtual bool IsMultiplayer();
|
||||
virtual void PlayStartupVideos();
|
||||
virtual void PlayAVIAndWait(const char *aviFile);
|
||||
virtual void SetCursorVisible(bool bState);
|
||||
class CGame: public IGame {
|
||||
private:
|
||||
bool m_bActiveApp;
|
||||
|
||||
// non-virtual function's of wrap for hooks a virtual
|
||||
// Only need to HOOK_ENGINE
|
||||
bool Init_noVirt(void *pvInstance);
|
||||
bool Shutdown_noVirt();
|
||||
bool CreateGameWindow_noVirt();
|
||||
void SleepUntilInput_noVirt(int time);
|
||||
HWND GetMainWindow_noVirt();
|
||||
HWND * GetMainWindowAddress_noVirt();
|
||||
void SetWindowXY_noVirt(int x, int y);
|
||||
void SetWindowSize_noVirt(int w, int h);
|
||||
void GetWindowRect_noVirt(int *x, int *y, int *w, int *h);
|
||||
bool IsActiveApp_noVirt();
|
||||
bool IsMultiplayer_noVirt();
|
||||
void PlayStartupVideos_noVirt();
|
||||
void PlayAVIAndWait_noVirt(const char *aviFile);
|
||||
void SetCursorVisible_noVirt(bool bState);
|
||||
public:
|
||||
CGame();
|
||||
virtual ~CGame();
|
||||
|
||||
virtual bool Init(void *pvInstance);
|
||||
virtual bool Shutdown();
|
||||
virtual bool CreateGameWindow();
|
||||
virtual void SleepUntilInput(int time);
|
||||
virtual HWND GetMainWindow();
|
||||
virtual HWND * GetMainWindowAddress();
|
||||
virtual void SetWindowXY(int x, int y);
|
||||
virtual void SetWindowSize(int w, int h);
|
||||
virtual void GetWindowRect(int *x, int *y, int *w, int *h);
|
||||
virtual bool IsActiveApp();
|
||||
virtual bool IsMultiplayer();
|
||||
virtual void PlayStartupVideos();
|
||||
virtual void PlayAVIAndWait(const char *aviFile);
|
||||
virtual void SetCursorVisible(bool bState);
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
2431
rehlds/hookers/engine/hooklist.cpp
Normal file
2431
rehlds/hookers/engine/hooklist.cpp
Normal file
File diff suppressed because it is too large
Load Diff
5
rehlds/hookers/engine/hooklist.h
Normal file
5
rehlds/hookers/engine/hooklist.h
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "hookers/memory.h"
|
||||
#include "hookers/helper.h"
|
||||
#include "hookers/hooker.h"
|
@ -1,120 +1,115 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
|
||||
int HookEngine(size_t addr);
|
||||
|
||||
|
||||
IBaseInterface* CreateFileSystemInterface(void);
|
||||
InterfaceReg iface = InterfaceReg(CreateFileSystemInterface, "VFileSystem009");
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ORIGINAL_ENGINE_DLL_NAME "swds.dll"
|
||||
#define ORIGINAL_FILESYSTEM_DLL_NAME "filesystem_stdio2.dll"
|
||||
#else
|
||||
#define ORIGINAL_ENGINE_DLL_NAME "engine_i486.so"
|
||||
#define ORIGINAL_FILESYSTEM_DLL_NAME "filesystem_stdio2.so"
|
||||
#endif
|
||||
|
||||
CSysModule *g_pOriginalFileSystemModule = NULL;
|
||||
CreateInterfaceFn g_OriginalFileSystemFactory = NULL;
|
||||
IFileSystem *g_pOriginalFileSystem = NULL;
|
||||
|
||||
|
||||
IBaseInterface *CreateFileSystemInterface(void)
|
||||
{
|
||||
if (g_pOriginalFileSystem)
|
||||
return g_pOriginalFileSystem;
|
||||
|
||||
if (g_pOriginalFileSystemModule)
|
||||
{
|
||||
g_OriginalFileSystemFactory = Sys_GetFactory(g_pOriginalFileSystemModule);
|
||||
if (g_OriginalFileSystemFactory)
|
||||
{
|
||||
int returnCode = 0;
|
||||
g_pOriginalFileSystem = reinterpret_cast<IBaseFileSystem *>(g_OriginalFileSystemFactory(FILESYSTEM_INTERFACE_VERSION, &returnCode));
|
||||
return g_pOriginalFileSystem;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// DLL entry point
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_RehldsRuntimeConfig.parseFromCommandLine(GetCommandLineA());
|
||||
|
||||
#ifdef HOOK_ENGINE
|
||||
size_t addr = (size_t)Sys_GetProcAddress(ORIGINAL_ENGINE_DLL_NAME, CREATEINTERFACE_PROCNAME);
|
||||
HookEngine(addr);
|
||||
|
||||
g_pOriginalFileSystemModule = Sys_LoadModule(ORIGINAL_FILESYSTEM_DLL_NAME);
|
||||
#endif // HOOK_ENGINE
|
||||
}
|
||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
if (g_pOriginalFileSystemModule)
|
||||
{
|
||||
Sys_UnloadModule(g_pOriginalFileSystemModule);
|
||||
g_pOriginalFileSystemModule = NULL;
|
||||
g_OriginalFileSystemFactory = NULL;
|
||||
g_pOriginalFileSystem = NULL;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
void __attribute__((constructor)) DllMainLoad()
|
||||
{
|
||||
size_t addr = (size_t)Sys_GetProcAddress(ORIGINAL_ENGINE_DLL_NAME, CREATEINTERFACE_PROCNAME);
|
||||
HookEngine(addr);
|
||||
|
||||
g_pOriginalFileSystemModule = Sys_LoadModule(ORIGINAL_FILESYSTEM_DLL_NAME);
|
||||
}
|
||||
|
||||
void __attribute__((destructor)) DllMainUnload()
|
||||
{
|
||||
if (g_pOriginalFileSystemModule)
|
||||
{
|
||||
Sys_UnloadModule(g_pOriginalFileSystemModule);
|
||||
g_pOriginalFileSystemModule = NULL;
|
||||
g_OriginalFileSystemFactory = NULL;
|
||||
g_pOriginalFileSystem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
IBaseInterface *CreateFileSystemInterface();
|
||||
InterfaceReg iface = InterfaceReg(CreateFileSystemInterface, "VFileSystem009");
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ORIGINAL_ENGINE_DLL_NAME "swds.dll"
|
||||
#define ORIGINAL_FILESYSTEM_DLL_NAME "filesystem_stdio2.dll"
|
||||
#else
|
||||
#define ORIGINAL_ENGINE_DLL_NAME "engine_i486.so"
|
||||
#define ORIGINAL_FILESYSTEM_DLL_NAME "filesystem_stdio2.so"
|
||||
#endif
|
||||
|
||||
CSysModule *g_pOriginalFileSystemModule = NULL;
|
||||
CreateInterfaceFn g_OriginalFileSystemFactory = NULL;
|
||||
IFileSystem *g_pOriginalFileSystem = NULL;
|
||||
|
||||
IBaseInterface *CreateFileSystemInterface()
|
||||
{
|
||||
if (g_pOriginalFileSystem)
|
||||
return g_pOriginalFileSystem;
|
||||
|
||||
if (g_pOriginalFileSystemModule)
|
||||
{
|
||||
g_OriginalFileSystemFactory = Sys_GetFactory(g_pOriginalFileSystemModule);
|
||||
if (g_OriginalFileSystemFactory)
|
||||
{
|
||||
int returnCode = 0;
|
||||
g_pOriginalFileSystem = reinterpret_cast<IBaseFileSystem *>(g_OriginalFileSystemFactory(FILESYSTEM_INTERFACE_VERSION, &returnCode));
|
||||
return g_pOriginalFileSystem;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// DLL entry point
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_RehldsRuntimeConfig.parseFromCommandLine(GetCommandLineA());
|
||||
|
||||
#ifdef HOOK_ENGINE
|
||||
size_t addr = (size_t)Sys_GetProcAddress(ORIGINAL_ENGINE_DLL_NAME, CREATEINTERFACE_PROCNAME);
|
||||
HookModule("hlds.exe", addr);
|
||||
|
||||
g_pOriginalFileSystemModule = Sys_LoadModule(ORIGINAL_FILESYSTEM_DLL_NAME);
|
||||
#endif // HOOK_ENGINE
|
||||
}
|
||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
if (g_pOriginalFileSystemModule)
|
||||
{
|
||||
Sys_UnloadModule(g_pOriginalFileSystemModule);
|
||||
g_pOriginalFileSystemModule = NULL;
|
||||
g_OriginalFileSystemFactory = NULL;
|
||||
g_pOriginalFileSystem = NULL;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
void __attribute__((constructor)) DllMainLoad()
|
||||
{
|
||||
size_t addr = (size_t)Sys_GetProcAddress(ORIGINAL_ENGINE_DLL_NAME, CREATEINTERFACE_PROCNAME);
|
||||
HookModule("hlds.exe", addr);
|
||||
|
||||
g_pOriginalFileSystemModule = Sys_LoadModule(ORIGINAL_FILESYSTEM_DLL_NAME);
|
||||
}
|
||||
|
||||
void __attribute__((destructor)) DllMainUnload()
|
||||
{
|
||||
if (g_pOriginalFileSystemModule)
|
||||
{
|
||||
Sys_UnloadModule(g_pOriginalFileSystemModule);
|
||||
g_pOriginalFileSystemModule = NULL;
|
||||
g_OriginalFileSystemFactory = NULL;
|
||||
g_pOriginalFileSystem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _WIN32
|
@ -1,70 +1,70 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// DLL entry point
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_RehldsRuntimeConfig.parseFromCommandLine(GetCommandLineA());
|
||||
|
||||
#ifdef _WIN32
|
||||
Module hlds_exe;
|
||||
if (!FindModuleByName("hlds.exe", &hlds_exe))
|
||||
printf("%s: launcher is not hlds.exe, tests playing/recording disabled!\n", __FUNCTION__);
|
||||
else
|
||||
TestSuite_Init(NULL, &hlds_exe, NULL);
|
||||
|
||||
Rehlds_Debug_Init(NULL);
|
||||
#endif
|
||||
|
||||
}
|
||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
void __attribute__((constructor)) DllMainLoad()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((destructor)) DllMainUnload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif // _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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// DLL entry point
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_RehldsRuntimeConfig.parseFromCommandLine(GetCommandLineA());
|
||||
|
||||
#ifdef _WIN32
|
||||
Module hlds_exe;
|
||||
if (!FindModuleByName("hlds.exe", &hlds_exe))
|
||||
printf("%s: launcher is not hlds.exe, tests playing/recording disabled!\n", __func__);
|
||||
else
|
||||
TestSuite_Init(NULL, &hlds_exe, NULL);
|
||||
|
||||
Rehlds_Debug_Init(NULL);
|
||||
#endif
|
||||
|
||||
}
|
||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
void __attribute__((constructor)) DllMainLoad()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((destructor)) DllMainUnload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif // _WIN32
|
159
rehlds/hookers/helper.h
Normal file
159
rehlds/hookers/helper.h
Normal file
@ -0,0 +1,159 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <utility>
|
||||
|
||||
#if defined(HOOK_ENGINE) || defined(HOOK_HLTV)
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
|
||||
template <typename T, typename ... TArgs>
|
||||
class MethodThunk {
|
||||
public:
|
||||
void Constructor(TArgs ... args) {
|
||||
new(this) T(args ...);
|
||||
}
|
||||
|
||||
void Destructor() {
|
||||
(*(T *)this).~T();
|
||||
}
|
||||
};
|
||||
|
||||
namespace MsvcMethod {
|
||||
namespace Detail {
|
||||
using Counter = std::size_t(*)();
|
||||
|
||||
template <std::size_t N>
|
||||
std::size_t GetIndex() {
|
||||
return N;
|
||||
}
|
||||
|
||||
template <std::size_t ... TIndices>
|
||||
constexpr auto GenerateCounters_Helper(std::index_sequence<TIndices ...>) {
|
||||
// There is no make_array (and/or deduction guides), so we need to explicitly define array template params
|
||||
return std::array<Counter, sizeof ... (TIndices)> { &GetIndex<TIndices> ... };
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
auto counters = GenerateCounters_Helper(std::make_index_sequence<N>{});
|
||||
|
||||
struct VIndexGetter {};
|
||||
struct ThisGetter {
|
||||
decltype(auto) GetThis() const {
|
||||
return this;
|
||||
}
|
||||
|
||||
decltype(auto) GetThis(...) const {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class Singleton {
|
||||
public:
|
||||
static T &GetInstance() {
|
||||
static T instance = {};
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
|
||||
// primary template
|
||||
template<class>
|
||||
struct is_variadic_function : std::false_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...)> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) const> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) volatile> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) const volatile> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) &> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) const &> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) volatile &> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) const volatile &> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) &&> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) const &&> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) volatile &&> : std::true_type {};
|
||||
template<class R, class ... TArgs>
|
||||
struct is_variadic_function<R (TArgs ..., ...) const volatile &&> : std::true_type {};
|
||||
|
||||
template<class T>
|
||||
constexpr bool is_variadic_function_v = is_variadic_function<T>::value;
|
||||
|
||||
template<class T>
|
||||
constexpr bool is_function_v = std::is_function<T>::value;
|
||||
} // namespace Detail
|
||||
|
||||
static constexpr auto& counters = Detail::counters<256>;
|
||||
|
||||
template <typename TMethod, typename T>
|
||||
std::enable_if_t<Detail::is_function_v<TMethod>, std::uintptr_t>
|
||||
GetVirtualIndex(TMethod T::*method)
|
||||
{
|
||||
decltype(auto) pcounters = counters.data();
|
||||
decltype(auto) vIndexGetter = (Detail::VIndexGetter *)&pcounters;
|
||||
|
||||
using VIndexGetterFunction = std::conditional_t<Detail::is_variadic_function_v<TMethod>, std::size_t (Detail::VIndexGetter::*)(...) const, std::size_t(Detail::VIndexGetter::*)() const>;
|
||||
VIndexGetterFunction vIndexGetterFunction;
|
||||
{
|
||||
*(std::uintptr_t *)&vIndexGetterFunction = *(std::uintptr_t *)&method;
|
||||
}
|
||||
|
||||
return (vIndexGetter->*vIndexGetterFunction)();
|
||||
}
|
||||
|
||||
template <typename TMethod, typename T>
|
||||
std::enable_if_t<Detail::is_function_v<TMethod>, std::uintptr_t>
|
||||
GetVirtualAddress(TMethod T::*method)
|
||||
{
|
||||
using ThisGetterFunction = std::conditional_t<Detail::is_variadic_function_v<TMethod>, const T *(T::*)(...) const, const T *(T::*)() const>;
|
||||
ThisGetterFunction thisGetterFunction = *(ThisGetterFunction *)&method;
|
||||
{
|
||||
decltype(auto) m = static_cast<std::conditional_t<Detail::is_variadic_function_v<TMethod>, const Detail::ThisGetter *(Detail::ThisGetter::*)(...) const, const Detail::ThisGetter *(Detail::ThisGetter::*)() const>>(&Detail::ThisGetter::GetThis);
|
||||
*(std::uintptr_t *)&thisGetterFunction = *(std::uintptr_t *)&m;
|
||||
}
|
||||
|
||||
return *(*(std::uintptr_t **)(Detail::Singleton<T>::GetInstance().*thisGetterFunction)() + GetVirtualIndex(method));
|
||||
}
|
||||
|
||||
template <typename TMethod, typename T>
|
||||
std::enable_if_t<Detail::is_function_v<TMethod>, std::uintptr_t>
|
||||
GetAddress(TMethod (T::*method)) {
|
||||
return (std::uintptr_t &)method;
|
||||
}
|
||||
|
||||
template <typename TMethod>
|
||||
std::enable_if_t<Detail::is_function_v<TMethod>, std::uintptr_t>
|
||||
GetAddress(TMethod (*method)) {
|
||||
return (std::uintptr_t &)method;
|
||||
}
|
||||
|
||||
} // namespace MsvcMethod
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define GLOBALVAR_LINK(offset, symbol, var, ...) { offset, #symbol, (size_t)&##var, __VA_ARGS__ }
|
||||
#define HOOK_SYMBOLDEF(offset, symbol, func, ...) { offset, #symbol, MsvcMethod::GetAddress<__VA_ARGS__>(&func) }
|
||||
#define HOOK_SYMBOL_VIRTUAL_DEF(offset, symbol, func, ...) { offset, #symbol, MsvcMethod::GetVirtualAddress<__VA_ARGS__>(&func) }
|
||||
|
||||
#define HOOK_DEF(offset, func, ...) HOOK_SYMBOLDEF(offset, func, func, __VA_ARGS__)
|
||||
#define HOOK_VIRTUAL_DEF(offset, func, ...) HOOK_SYMBOL_VIRTUAL_DEF(offset, func, func, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
#error Hooking stuff is only available using MSVC compiler.
|
||||
#endif // _MSC_VER
|
||||
|
||||
#endif // #if defined(HOOK_ENGINE) || defined(HOOK_HLTV)
|
@ -28,13 +28,14 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
Module g_Module = { NULL, NULL, NULL, NULL };
|
||||
|
||||
HIDDEN Module g_EngineModule = { NULL, NULL, NULL, NULL };
|
||||
|
||||
extern const size_t g_BaseOffset;
|
||||
extern FunctionHook g_FunctionHooks[];
|
||||
extern AddressRef g_FunctionRefs[];
|
||||
extern AddressRef g_DataRefs[];
|
||||
// Offset where module assumed be loaded to ajust hooks offsets. NULL for the Linux to trigger symbols searching.
|
||||
#ifdef _WIN32
|
||||
const size_t g_BaseOffset = 0x01D00000;
|
||||
#else
|
||||
const size_t g_BaseOffset = NULL;
|
||||
#endif
|
||||
|
||||
void *GetOriginalFuncAddrOrDie(const char *funcName)
|
||||
{
|
||||
@ -80,10 +81,9 @@ void *GetFuncRefAddrOrDefault(const char *funcName, void *def)
|
||||
return def;
|
||||
}
|
||||
|
||||
int HookEngine(size_t addr)
|
||||
int HookModule(const char *pszAppName, size_t addr)
|
||||
{
|
||||
if (addr == NULL || !FindModuleByAddress(addr, &g_EngineModule))
|
||||
{
|
||||
if (addr == NULL || !FindModuleByAddress(addr, &g_Module)) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ int HookEngine(size_t addr)
|
||||
AddressRef *refData = g_DataRefs;
|
||||
while (refData->symbolName != NULL)
|
||||
{
|
||||
if (!GetAddress(&g_EngineModule, (Address*)refData, g_BaseOffset))
|
||||
if (!GetAddress(&g_Module, (Address*)refData, g_BaseOffset))
|
||||
{
|
||||
#if _DEBUG
|
||||
printf("%s: symbol not found \"%s\", symbol index: %i\n", __func__, refData->symbolName, refData->symbolIndex);
|
||||
@ -106,7 +106,7 @@ int HookEngine(size_t addr)
|
||||
AddressRef *refFunc = g_FunctionRefs;
|
||||
while (refFunc->symbolName != NULL)
|
||||
{
|
||||
if (!GetAddress(&g_EngineModule, (Address*)refFunc, g_BaseOffset))
|
||||
if (!GetAddress(&g_Module, (Address*)refFunc, g_BaseOffset))
|
||||
{
|
||||
#if _DEBUG
|
||||
printf("%s: symbol not found \"%s\", symbol index: %i\n", __func__, refData->symbolName, refData->symbolIndex);
|
||||
@ -119,7 +119,7 @@ int HookEngine(size_t addr)
|
||||
FunctionHook *hookFunc = g_FunctionHooks;
|
||||
while (hookFunc->handlerFunc != NULL)
|
||||
{
|
||||
if (!GetAddress(&g_EngineModule, (Address*)hookFunc, g_BaseOffset))
|
||||
if (!GetAddress(&g_Module, (Address*)hookFunc, g_BaseOffset))
|
||||
{
|
||||
#if _DEBUG
|
||||
printf("%s: symbol not found \"%s\", symbol index: %i\n", __func__, refData->symbolName, refData->symbolIndex);
|
||||
@ -132,24 +132,23 @@ int HookEngine(size_t addr)
|
||||
if (!success)
|
||||
{
|
||||
#if _DEBUG
|
||||
printf("%s: failed to hook engine!\n", __func__);
|
||||
printf("%s: failed to hook module!\n", __func__);
|
||||
#endif
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
Module hlds_exe;
|
||||
if (!FindModuleByName("hlds.exe", &hlds_exe))
|
||||
printf("%s: launcher is not hlds.exe, tests playing/recording is disabled!\n", __FUNCTION__);
|
||||
#if defined(_WIN32) && defined(HOOK_ENGINE)
|
||||
Module application;
|
||||
if (!FindModuleByName(pszAppName, &application))
|
||||
printf("%s: launcher is not %s, tests playing/recording is disabled!\n", __func__, pszAppName);
|
||||
else
|
||||
TestSuite_Init(&g_EngineModule, &hlds_exe, g_FunctionRefs);
|
||||
TestSuite_Init(&g_Module, &application, g_FunctionRefs);
|
||||
#endif
|
||||
|
||||
|
||||
refData = g_DataRefs;
|
||||
while (refData->addressRef != NULL)
|
||||
{
|
||||
if (!FindDataRef(&g_EngineModule, refData))
|
||||
if (!FindDataRef(&g_Module, refData))
|
||||
return (FALSE);
|
||||
refData++;
|
||||
}
|
||||
@ -157,26 +156,89 @@ int HookEngine(size_t addr)
|
||||
refFunc = g_FunctionRefs;
|
||||
while (refFunc->addressRef != NULL)
|
||||
{
|
||||
if (!FindDataRef(&g_EngineModule, refFunc))
|
||||
if (!FindDataRef(&g_Module, refFunc))
|
||||
return (FALSE);
|
||||
refFunc++;
|
||||
}
|
||||
|
||||
#ifdef HOOK_ENGINE
|
||||
// Actually hook all things
|
||||
if (!g_RehldsRuntimeConfig.disableAllHooks)
|
||||
#endif // SWDS
|
||||
{
|
||||
hookFunc = g_FunctionHooks;
|
||||
while (hookFunc->handlerFunc != NULL)
|
||||
{
|
||||
if (!HookFunction(&g_EngineModule, hookFunc))
|
||||
if (!HookFunction(&g_Module, hookFunc))
|
||||
return (FALSE);
|
||||
hookFunc++;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
Rehlds_Debug_Init(&g_EngineModule);
|
||||
#endif
|
||||
#if defined(_WIN32) && defined(HOOK_ENGINE)
|
||||
Rehlds_Debug_Init(&g_Module);
|
||||
#endif // _WIN32
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void *malloc_wrapper(size_t size) {
|
||||
void *res = malloc(size);
|
||||
#ifdef HOOK_ENGINE
|
||||
//Rehlds_Debug_logAlloc(size, res);
|
||||
#endif // HOOK_ENGINE
|
||||
return res;
|
||||
}
|
||||
|
||||
void *realloc_wrapper(void *orig, size_t newSize) {
|
||||
void *res = realloc(orig, newSize);
|
||||
#ifdef HOOK_ENGINE
|
||||
//Rehlds_Debug_logRealloc(newSize, orig, res);
|
||||
#endif // HOOK_ENGINE
|
||||
return res;
|
||||
}
|
||||
|
||||
void free_wrapper(void *mem) {
|
||||
#ifdef HOOK_ENGINE
|
||||
//Rehlds_Debug_logFree(mem);
|
||||
#endif // HOOK_ENGINE
|
||||
free(mem);
|
||||
}
|
||||
|
||||
void *calloc_wrapper(size_t count, size_t size) {
|
||||
void *res = calloc(count, size);
|
||||
#ifdef HOOK_ENGINE
|
||||
//Rehlds_Debug_logAlloc(size * count, res);
|
||||
#endif // HOOK_ENGINE
|
||||
return res;
|
||||
}
|
||||
|
||||
void *__nh_malloc_wrapper(size_t sz, int unk) {
|
||||
void *res = malloc(sz);
|
||||
#ifdef HOOK_ENGINE
|
||||
//Rehlds_Debug_logAlloc(sz, res);
|
||||
#endif // HOOK_ENGINE
|
||||
return res;
|
||||
}
|
||||
|
||||
char *strdup_wrapper(const char *s) {
|
||||
return _strdup(s);
|
||||
}
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
void logf(const char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[8192];
|
||||
|
||||
va_start(argptr, fmt);
|
||||
_vsnprintf(string, sizeof(string), fmt, argptr);
|
||||
string[sizeof(string) - 1] = 0;
|
||||
|
||||
FILE *fl = fopen("hooker.log", "a");
|
||||
fprintf(fl, "%s\n", string);
|
||||
fclose(fl);
|
||||
}
|
||||
|
@ -2,7 +2,24 @@
|
||||
|
||||
#include "osconfig.h"
|
||||
|
||||
extern int HookModule(const char *pszAppName, size_t addr);
|
||||
extern void *GetOriginalFuncAddrOrDie(const char *funcName);
|
||||
extern void *GetOriginalFuncAddrOrDefault(const char *funcName, void *def);
|
||||
extern void *GetFuncRefAddrOrDie(const char *funcName);
|
||||
extern void *GetFuncRefAddrOrDefault(const char *funcName, void *def);
|
||||
extern void logf(const char *fmt, ...);
|
||||
|
||||
extern FunctionHook g_FunctionHooks[];
|
||||
extern AddressRef g_FunctionRefs[];
|
||||
extern AddressRef g_DataRefs[];
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void *malloc_wrapper(size_t size);
|
||||
void *realloc_wrapper(void *orig, size_t newSize);
|
||||
void free_wrapper(void *mem);
|
||||
void *calloc_wrapper(size_t count, size_t size);
|
||||
void *__nh_malloc_wrapper(size_t sz, int unk);
|
||||
char *strdup_wrapper(const char *s);
|
||||
|
||||
#endif // _WIN32
|
||||
|
@ -31,10 +31,8 @@
|
||||
|
||||
#include "osconfig.h"
|
||||
|
||||
|
||||
#define MAX_PATTERN 128
|
||||
|
||||
|
||||
struct Section;
|
||||
struct Section
|
||||
{
|
||||
@ -62,7 +60,7 @@ struct Module
|
||||
|
||||
struct Address
|
||||
{
|
||||
// Keeps offset for SWDS on application start; during HookEngine() an real address is written here.
|
||||
// Keeps offset for SWDS on application start; during HookModule() an real address is written here.
|
||||
size_t originalAddress;
|
||||
const char *symbolName;
|
||||
size_t address;
|
||||
@ -71,7 +69,7 @@ struct Address
|
||||
|
||||
struct FunctionHook
|
||||
{
|
||||
// Keeps offset for SWDS on application start; during HookEngine() an real address is written here.
|
||||
// Keeps offset for SWDS on application start; during HookModule() an real address is written here.
|
||||
size_t originalAddress;
|
||||
const char *symbolName;
|
||||
size_t handlerFunc;
|
||||
@ -80,7 +78,7 @@ struct FunctionHook
|
||||
|
||||
struct AddressRef
|
||||
{
|
||||
// Keeps offset for SWDS on application start; during HookEngine() an real address is written here.
|
||||
// Keeps offset for SWDS on application start; during HookModule() an real address is written here.
|
||||
size_t originalAddress;
|
||||
const char *symbolName;
|
||||
size_t addressRef;
|
||||
|
@ -100,39 +100,28 @@
|
||||
<ClCompile Include="..\engine\wad.cpp" />
|
||||
<ClCompile Include="..\engine\world.cpp" />
|
||||
<ClCompile Include="..\engine\zone.cpp" />
|
||||
<ClCompile Include="..\hookers\6132_hooker.cpp">
|
||||
<ClCompile Include="..\hookers\engine\hooklist.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Test Fixes|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Swds Play|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Swds|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Swds Play|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\hooker.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Test Fixes|Win32'">true</ExcludedFromBuild>
|
||||
<ClCompile Include="..\hookers\engine\main.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Swds Play|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Swds|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Swds Play|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\main.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Swds Play|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Swds|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Swds Play|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\main_swds.cpp">
|
||||
<ClCompile Include="..\hookers\engine\main_swds.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Play|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Record|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Play|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Swds Play|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Test Fixes|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Swds|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\memory.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Swds Play|Win32'">false</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\memory.cpp" />
|
||||
<ClCompile Include="..\hookers\rehlds_debug.cpp" />
|
||||
<ClCompile Include="..\public\interface.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
@ -471,8 +460,7 @@
|
||||
<ClInclude Include="..\engine\wad.h" />
|
||||
<ClInclude Include="..\engine\world.h" />
|
||||
<ClInclude Include="..\engine\zone.h" />
|
||||
<ClInclude Include="..\hookers\engine.h" />
|
||||
<ClInclude Include="..\hookers\hooker.h" />
|
||||
<ClInclude Include="..\hookers\engine\hooklist.h" />
|
||||
<ClInclude Include="..\hookers\memory.h" />
|
||||
<ClInclude Include="..\hookers\rehlds_debug.h" />
|
||||
<ClInclude Include="..\public\basetypes.h" />
|
||||
@ -548,6 +536,7 @@
|
||||
<ClInclude Include="..\public\utlmemory.h" />
|
||||
<ClInclude Include="..\public\utlrbtree.h" />
|
||||
<ClInclude Include="..\public\utlvector.h" />
|
||||
<ClInclude Include="..\rehlds\engine.h" />
|
||||
<ClInclude Include="..\rehlds\FlightRecorderImpl.h" />
|
||||
<ClInclude Include="..\rehlds\flight_recorder.h" />
|
||||
<ClInclude Include="..\rehlds\hookchains_impl.h" />
|
||||
@ -745,7 +734,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;HOOK_ENGINE;REHLDS_FIXES;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>REHLDS_OPT_PEDANTIC;REHLDS_SELF;HOOK_ENGINE;REHLDS_FIXES;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
@ -820,7 +809,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
@ -895,7 +884,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_SELF;HOOK_ENGINE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>REHLDS_SELF;HOOK_ENGINE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
@ -1004,7 +993,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>REHLDS_OPT_PEDANTIC;REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
@ -1043,7 +1032,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
|
@ -1,11 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
<ParseFiles>false</ParseFiles>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
@ -61,15 +56,6 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\hookers\memory.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\hooker.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\6132_hooker.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\engine\common.cpp">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClCompile>
|
||||
@ -106,9 +92,6 @@
|
||||
<ClCompile Include="..\engine\cvar.cpp">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\main.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\public\interface.cpp">
|
||||
<Filter>public</Filter>
|
||||
</ClCompile>
|
||||
@ -202,9 +185,6 @@
|
||||
<ClCompile Include="..\engine\hashpak.cpp">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\rehlds_debug.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\unittests\TestRunner.cpp">
|
||||
<Filter>unittests</Filter>
|
||||
</ClCompile>
|
||||
@ -289,9 +269,6 @@
|
||||
<ClCompile Include="..\engine\traceinit.cpp">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\main_swds.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\rehlds\hookchains_impl.cpp">
|
||||
<Filter>rehlds</Filter>
|
||||
</ClCompile>
|
||||
@ -355,20 +332,29 @@
|
||||
<ClCompile Include="..\engine\md5.cpp">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\engine\hooklist.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\engine\main.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\engine\main_swds.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\memory.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\hookers\rehlds_debug.cpp">
|
||||
<Filter>hookers</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\hookers\memory.h">
|
||||
<Filter>hookers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\version\version.h">
|
||||
<Filter>version</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\engine\common.h">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\hookers\engine.h">
|
||||
<Filter>hookers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\engine\sys_dll.h">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClInclude>
|
||||
@ -738,15 +724,9 @@
|
||||
<ClInclude Include="..\engine\hashpak.h">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\hookers\rehlds_debug.h">
|
||||
<Filter>hookers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\rehlds\precompiled.h">
|
||||
<Filter>rehlds</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\hookers\hooker.h">
|
||||
<Filter>hookers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\engine\tmessage.h">
|
||||
<Filter>engine\common</Filter>
|
||||
</ClInclude>
|
||||
@ -1092,6 +1072,18 @@
|
||||
<ClInclude Include="..\public\rehlds\studio.h">
|
||||
<Filter>public\rehlds</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\hookers\engine\hooklist.h">
|
||||
<Filter>hookers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\rehlds\engine.h">
|
||||
<Filter>rehlds</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\hookers\memory.h">
|
||||
<Filter>hookers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\hookers\rehlds_debug.h">
|
||||
<Filter>hookers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\linux\appversion.sh">
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "maintypes.h"
|
||||
#include "interface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -26,19 +26,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ENGINE_LAUNCHER_API_H
|
||||
#define ENGINE_LAUNCHER_API_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "maintypes.h"
|
||||
#include "interface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ENGINE_CLIENT_LIB "hw.dll" // OpenGL/D3D video mode
|
||||
#define ENGINE_CLIENT_SOFT_LIB "sw.dll" // Software video mode
|
||||
#else
|
||||
#define ENGINE_CLIENT_LIB "hw.so"
|
||||
#endif // _WIN32
|
||||
|
||||
class IEngineAPI : public IBaseInterface
|
||||
{
|
||||
public:
|
||||
virtual int Run(void *instance, char *basedir, char *cmdline, char *postRestartCmdLineArgs, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory) = 0;
|
||||
};
|
||||
|
||||
#endif // ENGINE_LAUNCHER_API_H
|
||||
#define VENGINE_LAUNCHER_API_VERSION "VENGINE_LAUNCHER_API_VERSION002"
|
||||
|
47
rehlds/public/icommandline.h
Normal file
47
rehlds/public/icommandline.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
*
|
||||
* 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
|
||||
|
||||
// Interface to engine command line
|
||||
class ICommandLine {
|
||||
public:
|
||||
virtual void CreateCmdLine(const char *commandline) = 0;
|
||||
virtual void CreateCmdLine(int argc, const char **argv) = 0;
|
||||
virtual const char *GetCmdLine() const = 0;
|
||||
|
||||
// Check whether a particular parameter exists
|
||||
virtual const char *CheckParm(const char *psz, char **ppszValue = nullptr) const = 0;
|
||||
virtual void RemoveParm(const char *pszParm) = 0;
|
||||
virtual void AppendParm(const char *pszParm, const char *pszValues) = 0;
|
||||
|
||||
virtual void SetParm(const char *pszParm, const char *pszValues) = 0;
|
||||
virtual void SetParm(const char *pszParm, int iValue) = 0;
|
||||
};
|
||||
|
||||
ICommandLine *CommandLine();
|
@ -133,48 +133,55 @@ void *Sys_GetProcAddress( void *pModuleHandle, const char *pName )
|
||||
// Input : *pModuleName - filename of the component
|
||||
// Output : opaque handle to the module (hides system dependency)
|
||||
//-----------------------------------------------------------------------------
|
||||
CSysModule *Sys_LoadModule( const char *pModuleName )
|
||||
CSysModule *Sys_LoadModule(const char *pModuleName)
|
||||
{
|
||||
#if defined ( _WIN32 )
|
||||
HMODULE hDLL = LoadLibrary( pModuleName );
|
||||
#if defined (_WIN32)
|
||||
HMODULE hDLL = LoadLibrary(pModuleName);
|
||||
#else
|
||||
HMODULE hDLL = NULL;
|
||||
char szAbsoluteModuleName[1024];
|
||||
szAbsoluteModuleName[0] = 0;
|
||||
if ( pModuleName[0] != '/' )
|
||||
if (pModuleName[0] != '/')
|
||||
{
|
||||
char szCwd[1024];
|
||||
char szAbsoluteModuleName[1024];
|
||||
|
||||
getcwd( szCwd, sizeof( szCwd ) );
|
||||
if ( szCwd[ strlen( szCwd ) - 1 ] == '/' )
|
||||
szCwd[ strlen( szCwd ) - 1 ] = 0;
|
||||
getcwd(szCwd, sizeof(szCwd));
|
||||
if (szCwd[strlen(szCwd) - 1] == '/')
|
||||
szCwd[strlen(szCwd) - 1] = '\0';
|
||||
|
||||
_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName );
|
||||
|
||||
hDLL = dlopen( szAbsoluteModuleName, RTLD_NOW );
|
||||
_snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName);
|
||||
hDLL = dlopen(szAbsoluteModuleName, RTLD_NOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s", pModuleName );
|
||||
hDLL = dlopen( pModuleName, RTLD_NOW );
|
||||
hDLL = dlopen(pModuleName, RTLD_NOW);
|
||||
}
|
||||
#endif
|
||||
|
||||
if( !hDLL )
|
||||
if(!hDLL)
|
||||
{
|
||||
char str[512];
|
||||
#if defined ( _WIN32 )
|
||||
_snprintf( str, sizeof(str), "%s.dll", pModuleName );
|
||||
hDLL = LoadLibrary( str );
|
||||
char szPathModule[MAX_PATH];
|
||||
char szModuleName[64];
|
||||
|
||||
strncpy(szModuleName, pModuleName, sizeof szModuleName - 1);
|
||||
szModuleName[sizeof szModuleName - 1] = '\0';
|
||||
|
||||
// remove extension if provided.
|
||||
char *ext = strrchr(szModuleName, '.');
|
||||
if (ext) {
|
||||
*ext = '\0';
|
||||
}
|
||||
|
||||
#if defined (_WIN32)
|
||||
_snprintf(szPathModule, sizeof(szPathModule), "%s.dll", szModuleName);
|
||||
hDLL = LoadLibrary(szPathModule);
|
||||
#elif defined(OSX)
|
||||
printf("Error:%s\n",dlerror());
|
||||
_snprintf( str, sizeof(str), "%s.dylib", szAbsoluteModuleName );
|
||||
hDLL = dlopen(str, RTLD_NOW);
|
||||
printf("Error: %s\n", dlerror());
|
||||
_snprintf(szPathModule, sizeof(szPathModule), "%s.dylib", szModuleName);
|
||||
hDLL = dlopen(szPathModule, RTLD_NOW);
|
||||
#else
|
||||
printf("Error:%s\n",dlerror());
|
||||
_snprintf( str, sizeof(str), "%s.so", szAbsoluteModuleName );
|
||||
hDLL = dlopen(str, RTLD_NOW);
|
||||
printf("Error: %s\n", dlerror());
|
||||
_snprintf(szPathModule, sizeof(szPathModule), "%s.so", szModuleName);
|
||||
hDLL = dlopen(szPathModule, RTLD_NOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
// Versioning
|
||||
// There are two versioning cases that are handled by this:
|
||||
// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case,
|
||||
// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case,
|
||||
// you need two EXPOSE_INTERFACEs: one to expose your class as the old interface and one to expose it as the new interface.
|
||||
// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface
|
||||
// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and
|
||||
// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface
|
||||
// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and
|
||||
// expose it for the old interface.
|
||||
|
||||
//#if _MSC_VER >= 1300 // VC7
|
||||
@ -108,7 +108,7 @@ public:
|
||||
// This function is automatically exported and allows you to access any interfaces exposed with the above macros.
|
||||
// if pReturnCode is set, it will return one of the following values
|
||||
// extend this for other error conditions/code
|
||||
enum
|
||||
enum
|
||||
{
|
||||
IFACE_OK = 0,
|
||||
IFACE_FAILED
|
||||
|
@ -1,9 +1,9 @@
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
@ -75,14 +75,19 @@ typedef struct resource_s
|
||||
|
||||
unsigned char rguc_reserved[ 32 ]; // For future expansion
|
||||
struct resource_s *pNext; // Next in chain.
|
||||
|
||||
#if !defined(HLTV)
|
||||
struct resource_s *pPrev;
|
||||
#else
|
||||
unsigned char *data;
|
||||
#endif // !defined(HLTV)
|
||||
} resource_t;
|
||||
|
||||
typedef struct customization_s
|
||||
{
|
||||
qboolean bInUse; // Is this customization in use;
|
||||
resource_t resource; // The resource_t for this customization
|
||||
qboolean bTranslated; // Has the raw data been translated into a useable format?
|
||||
qboolean bTranslated; // Has the raw data been translated into a useable format?
|
||||
// (e.g., raw decal .wad make into texture_t *)
|
||||
int nUserData1; // Customization specific data
|
||||
int nUserData2; // Customization specific data
|
||||
|
@ -32,11 +32,9 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "osconfig.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
|
||||
// Has no references on server side.
|
||||
#define NOXREF
|
||||
// Function body is not implemented.
|
||||
@ -44,13 +42,24 @@
|
||||
// Function is not tested at all.
|
||||
#define UNTESTED
|
||||
|
||||
#define BIT(n) (1<<(n))
|
||||
#define CONST_INTEGER_AS_STRING(x) #x //Wraps the integer in quotes, allowing us to form constant strings with it
|
||||
#define __HACK_LINE_AS_STRING__(x) CONST_INTEGER_AS_STRING(x) //__LINE__ can only be converted to an actual number by going through this, otherwise the output is literally "__LINE__"
|
||||
#define __LINE__AS_STRING __HACK_LINE_AS_STRING__(__LINE__) //Gives you the line number in constant string form
|
||||
|
||||
#if defined _MSC_VER || defined __INTEL_COMPILER
|
||||
#define NOXREFCHECK int __retAddr; __asm { __asm mov eax, [ebp + 4] __asm mov __retAddr, eax }; Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr)
|
||||
#else
|
||||
// For EBP based stack (older gcc) (uncomment version apropriate for your compiler)
|
||||
//#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 4(%%ebp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr);
|
||||
// For ESP based stack (newer gcc) (uncomment version apropriate for your compiler)
|
||||
#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 16(%%esp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr);
|
||||
#endif
|
||||
|
||||
#define BIT(n) (1<<(n))
|
||||
|
||||
// From engine/pr_comp.h;
|
||||
typedef unsigned int string_t;
|
||||
|
||||
|
||||
// From engine/server.h
|
||||
typedef enum sv_delta_s
|
||||
{
|
||||
@ -58,5 +67,4 @@ typedef enum sv_delta_s
|
||||
sv_packet_delta,
|
||||
} sv_delta_t;
|
||||
|
||||
|
||||
#endif // MAINTYPES_H
|
||||
|
@ -74,7 +74,7 @@ typedef struct texture_s
|
||||
char name[16];
|
||||
unsigned width, height;
|
||||
|
||||
#ifndef SWDS
|
||||
#if !defined(SWDS) && !defined(HLTV)
|
||||
int gl_texturenum;
|
||||
struct msurface_s * texturechain;
|
||||
#endif
|
||||
@ -85,7 +85,7 @@ typedef struct texture_s
|
||||
struct texture_s *alternate_anims; // bmodels in frame 1 use these
|
||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||
|
||||
#ifdef SWDS
|
||||
#if defined(SWDS) || defined(HLTV)
|
||||
unsigned paloffset;
|
||||
#else
|
||||
byte *pPal;
|
||||
|
@ -172,6 +172,10 @@
|
||||
#define SOCKET_AGAIN() (errno == EAGAIN)
|
||||
#define SOCKET_ERROR -1
|
||||
|
||||
inline int ioctlsocket(int fd, int cmd, unsigned int *argp) { return ioctl(fd, cmd, argp); }
|
||||
inline int closesocket(int fd) { return close(fd); }
|
||||
inline int WSAGetLastError() { return errno; }
|
||||
|
||||
inline void* sys_allocmem(unsigned int size) {
|
||||
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
}
|
||||
|
@ -1,83 +1,83 @@
|
||||
/*
|
||||
*
|
||||
* 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 "common.h"
|
||||
#include "keys.h"
|
||||
#include "decal.h"
|
||||
#include "delta.h"
|
||||
#include "delta_jit.h"
|
||||
#include "server.h"
|
||||
#include "sys_dll.h"
|
||||
#include "sys_dll2.h"
|
||||
#include "sys_engine.h"
|
||||
#include "zone.h"
|
||||
#include "client.h"
|
||||
#include "cmd.h"
|
||||
#include "cvar.h"
|
||||
#include "filesystem_internal.h"
|
||||
#include "mem.h"
|
||||
#include "unicode_strtools.h"
|
||||
#include "host.h"
|
||||
#include "filesystem_.h"
|
||||
#include "info.h"
|
||||
#include "iregistry.h"
|
||||
#include "cmodel.h"
|
||||
#include "model_rehlds.h"
|
||||
#include "sv_log.h"
|
||||
#include "sv_steam3.h"
|
||||
#include "host_cmd.h"
|
||||
#include "sv_user.h"
|
||||
#include "pmove.h"
|
||||
#include "pmovetst.h"
|
||||
#include "pr_edict.h"
|
||||
#include "pr_cmds.h"
|
||||
#include "mathlib_e.h"
|
||||
#include "world.h"
|
||||
#include "sv_phys.h"
|
||||
#include "sv_move.h"
|
||||
#include "sv_pmove.h"
|
||||
#include "studio_rehlds.h"
|
||||
#include "net_ws.h"
|
||||
#include "net_chan.h"
|
||||
|
||||
#include "tmessage.h"
|
||||
#include "traceinit.h"
|
||||
#include "wad.h"
|
||||
#include "textures.h"
|
||||
#include "vid_null.h"
|
||||
#include "l_studio.h"
|
||||
#include "crc.h"
|
||||
#include "md5.h"
|
||||
#include "sv_remoteaccess.h"
|
||||
#include "sv_upld.h"
|
||||
#include "com_custom.h"
|
||||
#include "hashpak.h"
|
||||
#include "ipratelimit.h"
|
||||
#include "ipratelimitWrapper.h"
|
||||
#include "savegame_version.h"
|
||||
#include "sys_linuxwnd.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 "common.h"
|
||||
#include "keys.h"
|
||||
#include "decal.h"
|
||||
#include "delta.h"
|
||||
#include "delta_jit.h"
|
||||
#include "server.h"
|
||||
#include "sys_dll.h"
|
||||
#include "sys_dll2.h"
|
||||
#include "sys_engine.h"
|
||||
#include "zone.h"
|
||||
#include "client.h"
|
||||
#include "cmd.h"
|
||||
#include "cvar.h"
|
||||
#include "filesystem_internal.h"
|
||||
#include "mem.h"
|
||||
#include "unicode_strtools.h"
|
||||
#include "host.h"
|
||||
#include "filesystem_.h"
|
||||
#include "info.h"
|
||||
#include "iregistry.h"
|
||||
#include "cmodel.h"
|
||||
#include "model_rehlds.h"
|
||||
#include "sv_log.h"
|
||||
#include "sv_steam3.h"
|
||||
#include "host_cmd.h"
|
||||
#include "sv_user.h"
|
||||
#include "pmove.h"
|
||||
#include "pmovetst.h"
|
||||
#include "pr_edict.h"
|
||||
#include "pr_cmds.h"
|
||||
#include "mathlib_e.h"
|
||||
#include "world.h"
|
||||
#include "sv_phys.h"
|
||||
#include "sv_move.h"
|
||||
#include "sv_pmove.h"
|
||||
#include "studio_rehlds.h"
|
||||
#include "net_ws.h"
|
||||
#include "net_chan.h"
|
||||
|
||||
#include "tmessage.h"
|
||||
#include "traceinit.h"
|
||||
#include "wad.h"
|
||||
#include "textures.h"
|
||||
#include "vid_null.h"
|
||||
#include "l_studio.h"
|
||||
#include "crc.h"
|
||||
#include "md5.h"
|
||||
#include "sv_remoteaccess.h"
|
||||
#include "sv_upld.h"
|
||||
#include "com_custom.h"
|
||||
#include "hashpak.h"
|
||||
#include "ipratelimit.h"
|
||||
#include "ipratelimitWrapper.h"
|
||||
#include "savegame_version.h"
|
||||
#include "sys_linuxwnd.h"
|
@ -21,11 +21,10 @@
|
||||
#include "RehldsRuntimeConfig.h"
|
||||
#include "rehlds_debug.h"
|
||||
|
||||
#ifdef HOOK_ENGINE
|
||||
#include "hooker.h"
|
||||
#endif
|
||||
// Hook stuff
|
||||
#include "hookers/engine/hooklist.h"
|
||||
|
||||
//valve libs stuff
|
||||
// Valve libs stuff
|
||||
#include "tier0/platform.h"
|
||||
#include "tier0/dbg.h"
|
||||
|
||||
@ -37,7 +36,7 @@
|
||||
|
||||
#include "iosutil.h"
|
||||
|
||||
//testsuite
|
||||
// Testsuite
|
||||
#include "testsuite.h"
|
||||
#include "funccalls.h"
|
||||
#include "recorder.h"
|
||||
|
@ -7,51 +7,51 @@ TEST(IsSafeFileExtension, SecurityChecks, 1000)
|
||||
struct testdata_t
|
||||
{
|
||||
const char* filename;
|
||||
bool safe;
|
||||
qboolean safe;
|
||||
};
|
||||
|
||||
testdata_t testdata[] = {
|
||||
{"radio/go.wav", true},
|
||||
{"radio/go.WAV", true},
|
||||
{"textures.wad", true},
|
||||
{"radio/go.wav", TRUE},
|
||||
{"radio/go.WAV", TRUE},
|
||||
{"textures.wad", TRUE},
|
||||
#ifdef REHLDS_FIXES
|
||||
{"!QWERTY", true},
|
||||
{"!QWERTY", TRUE},
|
||||
// TODO:
|
||||
//{"file.dll2", true},
|
||||
//{"noext", false},
|
||||
//{".hidden", false},
|
||||
//{"subdir/.hidden", false},
|
||||
//{"file.dll2", TRUE},
|
||||
//{"noext", FALSE},
|
||||
//{".hidden", FALSE},
|
||||
//{"subdir/.hidden", FALSE},
|
||||
#else
|
||||
{"file.dll2", false},
|
||||
{"file.dll2", FALSE},
|
||||
#endif
|
||||
{"../file.txt", false},
|
||||
{"/home/file.txt", false},
|
||||
{"C:/Windows/file.txt", false},
|
||||
{"models\\terror.mdl", false},
|
||||
{"file~.mdl", false},
|
||||
{"file.wav.", false},
|
||||
{"file.dll.txt", false},
|
||||
{"halflife.wad", false},
|
||||
{"pak0.pak", false},
|
||||
{"xeno.wad", false},
|
||||
{"file.cfg", false},
|
||||
{"file.lst", false},
|
||||
{"file.exe", false},
|
||||
{"file.vbs", false},
|
||||
{"file.com", false},
|
||||
{"file.bat", false},
|
||||
{"file.dll", false},
|
||||
{"file.ini", false},
|
||||
{"file.log", false},
|
||||
{"file.so", false},
|
||||
{"file.dylib", false},
|
||||
{"file.sys", false},
|
||||
{"file.SYS", false},
|
||||
{"../file.txt", FALSE},
|
||||
{"/home/file.txt", FALSE},
|
||||
{"C:/Windows/file.txt", FALSE},
|
||||
{"models\\terror.mdl", FALSE},
|
||||
{"file~.mdl", FALSE},
|
||||
{"file.wav.", FALSE},
|
||||
{"file.dll.txt", FALSE},
|
||||
{"halflife.wad", FALSE},
|
||||
{"pak0.pak", FALSE},
|
||||
{"xeno.wad", FALSE},
|
||||
{"file.cfg", FALSE},
|
||||
{"file.lst", FALSE},
|
||||
{"file.exe", FALSE},
|
||||
{"file.vbs", FALSE},
|
||||
{"file.com", FALSE},
|
||||
{"file.bat", FALSE},
|
||||
{"file.dll", FALSE},
|
||||
{"file.ini", FALSE},
|
||||
{"file.log", FALSE},
|
||||
{"file.so", FALSE},
|
||||
{"file.dylib", FALSE},
|
||||
{"file.sys", FALSE},
|
||||
{"file.SYS", FALSE},
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(testdata); i++) {
|
||||
testdata_t* d = &testdata[i];
|
||||
bool result = IsSafeFileToDownload(d->filename);
|
||||
qboolean result = IsSafeFileToDownload(d->filename);
|
||||
|
||||
char msg[256];
|
||||
Q_snprintf(msg, sizeof msg, "IsSafeFileToDownload(%s) check", d->filename);
|
||||
|
@ -120,7 +120,7 @@ rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind ->
|
||||
}
|
||||
|
||||
// Detect and setup UCRT paths
|
||||
def ucrtInfo = "getucrtinfo.bat".execute().text
|
||||
def ucrtInfo = "getucrtinfo.bat".execute().text
|
||||
def m = ucrtInfo =~ /^(.*)\r\n(.*)?$/
|
||||
if (!m.find()) {
|
||||
return cfg
|
||||
|
Loading…
Reference in New Issue
Block a user