[General] Attempt to organize functions def per category (#454)

* [General] Attempt to organize functions def per category

* [System] Forgot about sys_exitCmdLine
This commit is contained in:
Edo 2022-08-23 12:58:33 +02:00 committed by GitHub
parent 3246ed1bf5
commit be0e071aba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 1587 additions and 1512 deletions

11
src/Game/BothGames.cpp Normal file
View File

@ -0,0 +1,11 @@
#include <STDInclude.hpp>
namespace Game
{
BG_GetNumWeapons_t BG_GetNumWeapons = BG_GetNumWeapons_t(0x4F5CC0);
BG_GetWeaponName_t BG_GetWeaponName = BG_GetWeaponName_t(0x4E6EC0);
BG_LoadWeaponDef_LoadObj_t BG_LoadWeaponDef_LoadObj = BG_LoadWeaponDef_LoadObj_t(0x57B5F0);
BG_LoadWeaponCompleteDefInternal_t BG_LoadWeaponCompleteDefInternal = BG_LoadWeaponCompleteDefInternal_t(0x4B5F10);
BG_GetWeaponDef_t BG_GetWeaponDef = BG_GetWeaponDef_t(0x440EB0);
BG_GetEntityTypeName_t BG_GetEntityTypeName = BG_GetEntityTypeName_t(0x43A0E0);
}

22
src/Game/BothGames.hpp Normal file
View File

@ -0,0 +1,22 @@
#pragma once
namespace Game
{
typedef unsigned int(*BG_GetNumWeapons_t)();
extern BG_GetNumWeapons_t BG_GetNumWeapons;
typedef const char*(*BG_GetWeaponName_t)(unsigned int index);
extern BG_GetWeaponName_t BG_GetWeaponName;
typedef void*(*BG_LoadWeaponDef_LoadObj_t)(const char* name);
extern BG_LoadWeaponDef_LoadObj_t BG_LoadWeaponDef_LoadObj;
typedef WeaponCompleteDef*(*BG_LoadWeaponCompleteDefInternal_t)(const char* folder, const char* name);
extern BG_LoadWeaponCompleteDefInternal_t BG_LoadWeaponCompleteDefInternal;
typedef WeaponDef*(*BG_GetWeaponDef_t)(unsigned int weaponIndex);
extern BG_GetWeaponDef_t BG_GetWeaponDef;
typedef const char*(*BG_GetEntityTypeName_t)(int eType);
extern BG_GetEntityTypeName_t BG_GetEntityTypeName;
}

61
src/Game/Client.cpp Normal file
View File

@ -0,0 +1,61 @@
#include <STDInclude.hpp>
namespace Game
{
CL_GetClientName_t CL_GetClientName = CL_GetClientName_t(0x4563D0);
CL_IsCgameInitialized_t CL_IsCgameInitialized = CL_IsCgameInitialized_t(0x43EB20);
CL_ConnectFromParty_t CL_ConnectFromParty = CL_ConnectFromParty_t(0x433D30);
CL_DownloadsComplete_t CL_DownloadsComplete = CL_DownloadsComplete_t(0x42CE90);
CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical = CL_DrawStretchPicPhysical_t(0x4FC120);
CL_GetConfigString_t CL_GetConfigString = CL_GetConfigString_t(0x44ADB0);
CL_GetMaxRank_t CL_GetMaxRank = CL_GetMaxRank_t(0x44BA30);
CL_GetRankForXP_t CL_GetRankForXP = CL_GetRankForXP_t(0x4FF8A0);
CL_GetRankIcon_t CL_GetRankIcon = CL_GetRankIcon_t(0x4A7B30);
CL_HandleRelayPacket_t CL_HandleRelayPacket = CL_HandleRelayPacket_t(0x5A8C70);
CL_ResetViewport_t CL_ResetViewport = CL_ResetViewport_t(0x4A8830);
CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f = CL_SelectStringTableEntryInDvar_f_t(0x4A4560);
CL_DrawStretchPic_t CL_DrawStretchPic = CL_DrawStretchPic_t(0x412490);
CL_ConsoleFixPosition_t CL_ConsoleFixPosition = CL_ConsoleFixPosition_t(0x44A430);
CL_GetLocalClientActiveCount_t CL_GetLocalClientActiveCount = CL_GetLocalClientActiveCount_t(0x5BAD90);
CL_ControllerIndexFromClientNum_t CL_ControllerIndexFromClientNum = CL_ControllerIndexFromClientNum_t(0x449E30);
CL_MouseEvent_t CL_MouseEvent = CL_MouseEvent_t(0x4D7C50);
float* cl_angles = reinterpret_cast<float*>(0xB2F8D0);
clientConnection_t* clientConnections = reinterpret_cast<clientConnection_t*>(0xA1E878);
clientStatic_t* cls = reinterpret_cast<clientStatic_t*>(0xA7FE90);
clientUIActive_t* clientUIActives = reinterpret_cast<clientUIActive_t*>(0xB2BB88);
voiceCommunication_t* cl_voiceCommunication = reinterpret_cast<voiceCommunication_t*>(0x1079DA0);
int CL_GetMaxXP()
{
StringTable* rankTable = DB_FindXAssetHeader(ASSET_TYPE_STRINGTABLE, "mp/rankTable.csv").stringTable;
const char* maxrank = StringTable_Lookup(rankTable, 0, "maxrank", 1);
return atoi(StringTable_Lookup(rankTable, 0, maxrank, 7));
}
clientConnection_t* CL_GetLocalClientConnection(const int localClientNum)
{
assert(clientConnections);
AssertIn(localClientNum, MAX_LOCAL_CLIENTS);
return &clientConnections[localClientNum];
}
connstate_t CL_GetLocalClientConnectionState(const int localClientNum)
{
AssertIn(localClientNum, STATIC_MAX_LOCAL_CLIENTS);
return clientUIActives[localClientNum].connectionState;
}
voiceCommunication_t* CL_GetLocalClientVoiceCommunication([[maybe_unused]] const int localClientNum)
{
AssertIn(localClientNum, STATIC_MAX_LOCAL_CLIENTS);
return cl_voiceCommunication;
}
}

70
src/Game/Client.hpp Normal file
View File

@ -0,0 +1,70 @@
#pragma once
namespace Game
{
typedef int(*CL_GetClientName_t)(int localClientNum, int index, char* buf, int size);
extern CL_GetClientName_t CL_GetClientName;
typedef int(*CL_IsCgameInitialized_t)();
extern CL_IsCgameInitialized_t CL_IsCgameInitialized;
typedef void(*CL_ConnectFromParty_t)(int controllerIndex, _XSESSION_INFO* hostInfo, netadr_t addr, int numPublicSlots, int numPrivateSlots, const char* mapname, const char* gametype);
extern CL_ConnectFromParty_t CL_ConnectFromParty;
typedef void(*CL_DownloadsComplete_t)(int controller);
extern CL_DownloadsComplete_t CL_DownloadsComplete;
typedef void(*CL_DrawStretchPicPhysical_t)(float x, float y, float w, float h, float xScale, float yScale, float xay, float yay, const float* color, Material* material);
extern CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical;
typedef const char* (*CL_GetConfigString_t)(int index);
extern CL_GetConfigString_t CL_GetConfigString;
typedef int(*CL_GetMaxRank_t)();
extern CL_GetMaxRank_t CL_GetMaxRank;
typedef int(*CL_GetRankForXP_t)(int xp);
extern CL_GetRankForXP_t CL_GetRankForXP;
typedef void(*CL_GetRankIcon_t)(int level, int prestige, Material** material);
extern CL_GetRankIcon_t CL_GetRankIcon;
typedef void(*CL_HandleRelayPacket_t)(Game::msg_t* msg, int client);
extern CL_HandleRelayPacket_t CL_HandleRelayPacket;
typedef void(*CL_ResetViewport_t)();
extern CL_ResetViewport_t CL_ResetViewport;
typedef void(*CL_SelectStringTableEntryInDvar_f_t)();
extern CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f;
typedef void(*CL_DrawStretchPic_t)(const ScreenPlacement* scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, float s1, float t1, float s2, float t2, const float* color, Material* material);
extern CL_DrawStretchPic_t CL_DrawStretchPic;
typedef void(*CL_ConsoleFixPosition_t)();
extern CL_ConsoleFixPosition_t CL_ConsoleFixPosition;
typedef int(*CL_GetLocalClientActiveCount_t)();
extern CL_GetLocalClientActiveCount_t CL_GetLocalClientActiveCount;
typedef int(*CL_ControllerIndexFromClientNum_t)(int localActiveClientNum);
extern CL_ControllerIndexFromClientNum_t CL_ControllerIndexFromClientNum;
typedef int(*CL_MouseEvent_t)(int x, int y, int dx, int dy);
extern CL_MouseEvent_t CL_MouseEvent;
extern float* cl_angles;
extern clientConnection_t* clientConnections;
extern clientStatic_t* cls;
extern clientUIActive_t* clientUIActives;
extern voiceCommunication_t* cl_voiceCommunication;
extern int CL_GetMaxXP();
extern clientConnection_t* CL_GetLocalClientConnection(int localClientNum);
extern connstate_t CL_GetLocalClientConnectionState(int localClientNum);
extern voiceCommunication_t* CL_GetLocalClientVoiceCommunication(int localClientNum);
}

183
src/Game/Database.cpp Normal file
View File

@ -0,0 +1,183 @@
#include <STDInclude.hpp>
namespace Game
{
DB_BeginRecoverLostDevice_t DB_BeginRecoverLostDevice = DB_BeginRecoverLostDevice_t(0x4BFF90);
DB_EndRecoverLostDevice_t DB_EndRecoverLostDevice = DB_EndRecoverLostDevice_t(0x46B660);
DB_EnumXAssets_t DB_EnumXAssets = DB_EnumXAssets_t(0x4B76D0);
DB_EnumXAssets_Internal_t DB_EnumXAssets_Internal = DB_EnumXAssets_Internal_t(0x5BB0A0);
DB_FindXAssetHeader_t DB_FindXAssetHeader = DB_FindXAssetHeader_t(0x407930);
DB_GetRawBuffer_t DB_GetRawBuffer = DB_GetRawBuffer_t(0x4CDC50);
DB_GetRawFileLen_t DB_GetRawFileLen = DB_GetRawFileLen_t(0x4DAA80);
DB_GetLoadedFraction_t DB_GetLoadedFraction = DB_GetLoadedFraction_t(0x468380);
DB_GetXAssetTypeName_t DB_GetXAssetTypeName = DB_GetXAssetTypeName_t(0x4CFCF0);
DB_IsXAssetDefault_t DB_IsXAssetDefault = DB_IsXAssetDefault_t(0x48E6A0);
DB_LoadXAssets_t DB_LoadXAssets = DB_LoadXAssets_t(0x4E5930);
DB_LoadXFileData_t DB_LoadXFileData = DB_LoadXFileData_t(0x445460);
DB_ReadXFile_t DB_ReadXFile = DB_ReadXFile_t(0x445460);
DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed = DB_ReadXFileUncompressed_t(0x4705E0);
DB_SetXAssetName_t DB_SetXAssetName = DB_SetXAssetName_t(0x453580);
DB_XModelSurfsFixup_t DB_XModelSurfsFixup = DB_XModelSurfsFixup_t(0x5BAC50);
DB_SetXAssetNameHandler_t* DB_SetXAssetNameHandlers = reinterpret_cast<DB_SetXAssetNameHandler_t*>(0x7993D8);
DB_GetXAssetNameHandler_t* DB_GetXAssetNameHandlers = reinterpret_cast<DB_GetXAssetNameHandler_t*>(0x799328);
DB_GetXAssetSizeHandler_t* DB_GetXAssetSizeHandlers = reinterpret_cast<DB_GetXAssetSizeHandler_t*>(0x799488);
DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers = reinterpret_cast<DB_ReleaseXAssetHandler_t*>(0x799AB8);
XAssetHeader* DB_XAssetPool = reinterpret_cast<XAssetHeader*>(0x7998A8);
unsigned int* g_poolSize = reinterpret_cast<unsigned int*>(0x7995E8);
XBlock** g_streamBlocks = reinterpret_cast<XBlock**>(0x16E554C);
int* g_streamPos = reinterpret_cast<int*>(0x16E5554);
int* g_streamPosIndex = reinterpret_cast<int*>(0x16E5578);
FastCriticalSection* db_hashCritSect = reinterpret_cast<FastCriticalSection*>(0x16B8A54);
XZone* g_zones = reinterpret_cast<XZone*>(0x14C0F80);
unsigned short* db_hashTable = reinterpret_cast<unsigned short*>(0x12412B0);
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize)
{
const auto size = DB_GetXAssetSizeHandlers[type]();
XAssetHeader poolEntry = {Utils::Memory::GetAllocator()->allocate(newSize * size)};
DB_XAssetPool[type] = poolEntry;
g_poolSize[type] = newSize;
return poolEntry;
}
const char* DB_GetXAssetName(XAsset* asset)
{
if (!asset) return "";
return DB_GetXAssetNameHandlers[asset->type](&asset->header);
}
XAssetType DB_GetXAssetNameType(const char* name)
{
for (int i = 0; i < ASSET_TYPE_COUNT; ++i)
{
XAssetType type = static_cast<XAssetType>(i);
if (!_stricmp(DB_GetXAssetTypeName(type), name))
{
// Col map workaround!
if (type == Game::ASSET_TYPE_CLIPMAP_SP)
{
return Game::ASSET_TYPE_CLIPMAP_MP;
}
return type;
}
}
return ASSET_TYPE_INVALID;
}
int DB_GetZoneIndex(const std::string& name)
{
for (int i = 0; i < 32; ++i)
{
if (Game::g_zones[i].name == name)
{
return i;
}
}
return -1;
}
bool DB_IsZoneLoaded(const char* zone)
{
auto zoneCount = Utils::Hook::Get<int>(0x1261BCC);
auto* zoneIndices = reinterpret_cast<char*>(0x16B8A34);
auto* zoneData = reinterpret_cast<char*>(0x14C0F80);
for (int i = 0; i < zoneCount; ++i)
{
std::string name = zoneData + 4 + 0xA4 * (zoneIndices[i] & 0xFF);
if (name == zone)
{
return true;
}
}
return false;
}
void DB_EnumXAssetEntries(XAssetType type, std::function<void(XAssetEntry*)> callback, bool overrides)
{
Sys_LockRead(db_hashCritSect);
const auto pool = Components::Maps::GetAssetEntryPool();
for (auto hash = 0; hash < 37000; hash++)
{
auto hashIndex = db_hashTable[hash];
while (hashIndex)
{
auto* assetEntry = &pool[hashIndex];
if (assetEntry->asset.type == type)
{
callback(assetEntry);
if (overrides)
{
auto overrideIndex = assetEntry->nextOverride;
while (overrideIndex)
{
auto* overrideEntry = &pool[overrideIndex];
callback(overrideEntry);
overrideIndex = overrideEntry->nextOverride;
}
}
}
hashIndex = assetEntry->nextHash;
}
}
Sys_UnlockRead(db_hashCritSect);
}
__declspec(naked) XAssetHeader DB_FindXAssetDefaultHeaderInternal(XAssetType /*type*/)
{
__asm
{
push eax
pushad
mov eax, 5BB210h
mov edi, [esp + 28h]
call eax
mov [esp + 20h], eax
popad
pop eax
retn
}
}
__declspec(naked) XAssetEntry* DB_FindXAssetEntry(XAssetType /*type*/, const char* /*name*/)
{
__asm
{
push eax
pushad
mov edi, [esp + 2Ch] // name
push edi
mov edi, [esp + 2Ch] // type
mov eax, 5BB1B0h
call eax
add esp, 4h
mov [esp + 20h], eax
popad
pop eax
retn
}
}
}

114
src/Game/Database.hpp Normal file
View File

@ -0,0 +1,114 @@
#pragma once
namespace Game
{
template <typename T> static void DB_ConvertOffsetToPointer(T* pointer)
{
Utils::Hook::Call<void(T*)>(0x4A82B0)(pointer);
}
template <typename T> static T** DB_InsertPointer()
{
static auto DB_InsertPointer_t = 0x43B290;
T** result = nullptr;
__asm
{
call DB_InsertPointer_t;
mov result, eax;
}
return result;
}
typedef char*(*DB_AllocStreamPos_t)(int alignment);
extern DB_AllocStreamPos_t DB_AllocStreamPos;
typedef void(*DB_PushStreamPos_t)(unsigned int index);
extern DB_PushStreamPos_t DB_PushStreamPos;
typedef void(*DB_PopStreamPos_t)();
extern DB_PopStreamPos_t DB_PopStreamPos;
typedef void(*DB_BeginRecoverLostDevice_t)();
extern DB_BeginRecoverLostDevice_t DB_BeginRecoverLostDevice;
typedef void(*DB_EndRecoverLostDevice_t)();
extern DB_EndRecoverLostDevice_t DB_EndRecoverLostDevice;
typedef void(*DB_EnumXAssets_t)(XAssetType type, void(*)(XAssetHeader, void*), void* userdata, bool overrides);
extern DB_EnumXAssets_t DB_EnumXAssets;
typedef void(*DB_EnumXAssets_Internal_t)(XAssetType type, void(*)(XAssetHeader, void*), void* userdata, bool overrides);
extern DB_EnumXAssets_Internal_t DB_EnumXAssets_Internal;
typedef XAssetHeader(*DB_FindXAssetHeader_t)(XAssetType type, const char* name);
extern DB_FindXAssetHeader_t DB_FindXAssetHeader;
typedef float(*DB_GetLoadedFraction_t)();
extern DB_GetLoadedFraction_t DB_GetLoadedFraction;
typedef const char*(*DB_GetXAssetTypeName_t)(XAssetType type);
extern DB_GetXAssetTypeName_t DB_GetXAssetTypeName;
typedef int(*DB_IsXAssetDefault_t)(XAssetType type, const char* name);
extern DB_IsXAssetDefault_t DB_IsXAssetDefault;
typedef void(*DB_GetRawBuffer_t)(RawFile* rawfile, char* buffer, int size);
extern DB_GetRawBuffer_t DB_GetRawBuffer;
typedef int(*DB_GetRawFileLen_t)(RawFile* rawfile);
extern DB_GetRawFileLen_t DB_GetRawFileLen;
typedef void(*DB_LoadXAssets_t)(XZoneInfo* zoneInfo, unsigned int zoneCount, int sync);
extern DB_LoadXAssets_t DB_LoadXAssets;
typedef void(*DB_LoadXFileData_t)(char* pos, int size);
extern DB_LoadXFileData_t DB_LoadXFileData;
typedef void(*DB_ReadXFileUncompressed_t)(void* buffer, int size);
extern DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed;
typedef void(*DB_ReadXFile_t)(void* buffer, int size);
extern DB_ReadXFile_t DB_ReadXFile;
typedef void(*DB_SetXAssetName_t)(XAsset* asset, const char* name);
extern DB_SetXAssetName_t DB_SetXAssetName;
typedef void(*DB_XModelSurfsFixup_t)(XModel* model);
extern DB_XModelSurfsFixup_t DB_XModelSurfsFixup;
typedef void(*DB_SetXAssetNameHandler_t)(XAssetHeader* header, const char* name);
extern DB_SetXAssetNameHandler_t* DB_SetXAssetNameHandlers;
typedef int(*DB_GetXAssetSizeHandler_t)();
extern DB_GetXAssetSizeHandler_t* DB_GetXAssetSizeHandlers;
typedef const char* (*DB_GetXAssetNameHandler_t)(XAssetHeader* asset);
extern DB_GetXAssetNameHandler_t* DB_GetXAssetNameHandlers;
typedef void(*DB_ReleaseXAssetHandler_t)(XAssetHeader header);
extern DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers;
extern XAssetHeader* DB_XAssetPool;
extern unsigned int* g_poolSize;
extern XBlock** g_streamBlocks;
extern int* g_streamPos;
extern int* g_streamPosIndex;
extern FastCriticalSection* db_hashCritSect;
extern XZone* g_zones;
extern unsigned short* db_hashTable;
extern XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize);
extern const char* DB_GetXAssetName(XAsset* asset);
extern XAssetType DB_GetXAssetNameType(const char* name);
extern int DB_GetZoneIndex(const std::string& name);
extern bool DB_IsZoneLoaded(const char* zone);
extern void DB_EnumXAssetEntries(XAssetType type, std::function<void(XAssetEntry*)> callback, bool overrides);
extern XAssetHeader DB_FindXAssetDefaultHeaderInternal(XAssetType type);
extern XAssetEntry* DB_FindXAssetEntry(XAssetType type, const char* name);
}

View File

@ -2,6 +2,26 @@
namespace Game
{
Dvar_RegisterBool_t Dvar_RegisterBool = Dvar_RegisterBool_t(0x4CE1A0);
Dvar_RegisterFloat_t Dvar_RegisterFloat = Dvar_RegisterFloat_t(0x648440);
Dvar_RegisterVec2_t Dvar_RegisterVec2 = Dvar_RegisterVec2_t(0x4F6070);
Dvar_RegisterVec3_t Dvar_RegisterVec3 = Dvar_RegisterVec3_t(0x4EF8E0);
Dvar_RegisterVec4_t Dvar_RegisterVec4 = Dvar_RegisterVec4_t(0x471500);
Dvar_RegisterInt_t Dvar_RegisterInt = Dvar_RegisterInt_t(0x479830);
Dvar_RegisterEnum_t Dvar_RegisterEnum = Dvar_RegisterEnum_t(0x412E40);
Dvar_RegisterString_t Dvar_RegisterString = Dvar_RegisterString_t(0x4FC7E0);
Dvar_RegisterColor_t Dvar_RegisterColor = Dvar_RegisterColor_t(0x4F28E0);
Dvar_RegisterVec3Color_t Dvar_RegisterVec3Color = Dvar_RegisterVec3Color_t(0x4918B0);
Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName = Dvar_GetUnpackedColorByName_t(0x406530);
Dvar_GetString_t Dvar_GetString = Dvar_GetString_t(0x4EC6B0);
Dvar_GetVariantString_t Dvar_GetVariantString = Dvar_GetVariantString_t(0x4C47E0);
Dvar_FindVar_t Dvar_FindVar = Dvar_FindVar_t(0x4D5390);
Dvar_InfoString_Big_t Dvar_InfoString_Big = Dvar_InfoString_Big_t(0x4D98A0);
Dvar_SetCommand_t Dvar_SetCommand = Dvar_SetCommand_t(0x4EE430);
Dvar_DisplayableValue_t Dvar_DisplayableValue = Dvar_DisplayableValue_t(0x4B5530);
Dvar_Reset_t Dvar_Reset = Dvar_Reset_t(0x4FEFD0);
const dvar_t** com_developer = reinterpret_cast<const dvar_t**>(0x1AD78E8);
const dvar_t** com_developer_script = reinterpret_cast<const dvar_t**>(0x1AD8F10);
const dvar_t** com_timescale = reinterpret_cast<const dvar_t**>(0x1AD7920);
@ -32,4 +52,44 @@ namespace Game
const dvar_t** g_gametype = reinterpret_cast<const dvar_t**>(0x1A45DC8);
const dvar_t** version = reinterpret_cast<const dvar_t**>(0x1AD7930);
__declspec(naked) void Dvar_SetVariant(dvar_t*, DvarValue, DvarSetSource)
{
static DWORD Dvar_SetVariant_t = 0x647400;
__asm
{
pushad
mov eax, [esp + 0x4 + 0x20] // dvar
push [esp + 0x18 + 0x20] // source
push [esp + 0x18 + 0x20] // value
push [esp + 0x18 + 0x20] // value
push [esp + 0x18 + 0x20] // value
push [esp + 0x18 + 0x20] // value
call Dvar_SetVariant_t
add esp, 0x14
popad
retn
}
}
void Dvar_SetFromStringFromSource(const dvar_t* dvar, const char* string, DvarSetSource source)
{
static DWORD Dvar_SetFromStringFromSource_t = 0x648580;
__asm
{
pushad
mov esi, dvar
mov eax, string
push source
call Dvar_SetFromStringFromSource_t
add esp, 0x4
popad
}
}
}

View File

@ -3,6 +3,81 @@
// Put game dvars here
namespace Game
{
typedef dvar_t*(*Dvar_RegisterBool_t)(const char* dvarName, bool value, unsigned __int16 flags, const char* description);
extern Dvar_RegisterBool_t Dvar_RegisterBool;
typedef dvar_t*(*Dvar_RegisterFloat_t)(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description);
extern Dvar_RegisterFloat_t Dvar_RegisterFloat;
typedef dvar_t*(*Dvar_RegisterVec2_t)(const char* dvarName, float x, float y, float min, float max, unsigned __int16 flags, const char* description);
extern Dvar_RegisterVec2_t Dvar_RegisterVec2;
typedef dvar_t*(*Dvar_RegisterVec3_t)(const char* dvarName, float x, float y, float z, float min, float max, unsigned __int16 flags, const char* description);
extern Dvar_RegisterVec3_t Dvar_RegisterVec3;
typedef dvar_t*(*Dvar_RegisterVec4_t)(const char* dvarName, float x, float y, float z, float w, float min, float max, unsigned __int16 flags, const char* description);
extern Dvar_RegisterVec4_t Dvar_RegisterVec4;
typedef dvar_t*(*Dvar_RegisterInt_t)(const char* dvarName, int value, int min, int max, unsigned __int16 flags, const char* description);
extern Dvar_RegisterInt_t Dvar_RegisterInt;
typedef dvar_t*(*Dvar_RegisterEnum_t)(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description);
extern Dvar_RegisterEnum_t Dvar_RegisterEnum;
typedef dvar_t*(*Dvar_RegisterString_t)(const char* dvarName, const char* value, unsigned __int16 flags, const char* description);
extern Dvar_RegisterString_t Dvar_RegisterString;
typedef dvar_t*(*Dvar_RegisterColor_t)(const char* dvarName, float r, float g, float b, float a, unsigned __int16 flags, const char* description);
extern Dvar_RegisterColor_t Dvar_RegisterColor;
typedef dvar_t*(*Dvar_RegisterVec3Color_t)(const char* dvarName, float x, float y, float z, float max, unsigned __int16 flags, const char* description);
extern Dvar_RegisterVec3Color_t Dvar_RegisterVec3Color;
typedef void(*Dvar_SetFromStringByName_t)(const char* dvarName, const char* string);
extern Dvar_SetFromStringByName_t Dvar_SetFromStringByName;
typedef const dvar_t*(*Dvar_SetFromStringByNameFromSource_t)(const char* dvarName, const char* string, DvarSetSource source);
extern Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource;
typedef void(*Dvar_SetStringByName_t)(const char* dvarName, const char* value);
extern Dvar_SetStringByName_t Dvar_SetStringByName;
typedef void(*Dvar_SetString_t)(const dvar_t* dvar, const char* value);
extern Dvar_SetString_t Dvar_SetString;
typedef void(*Dvar_SetBool_t)(const dvar_t* dvar, bool enabled);
extern Dvar_SetBool_t Dvar_SetBool;
typedef void(*Dvar_SetFloat_t)(const dvar_t* dvar, float value);
extern Dvar_SetFloat_t Dvar_SetFloat;
typedef void(*Dvar_SetInt_t)(const dvar_t* dvar, int integer);
extern Dvar_SetInt_t Dvar_SetInt;
typedef void(*Dvar_GetUnpackedColorByName_t)(const char* dvarName, float* expandedColor);
extern Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName;
typedef char*(*Dvar_GetString_t)(const char* dvarName);
extern Dvar_GetString_t Dvar_GetString;
typedef char*(*Dvar_GetVariantString_t)(const char* dvarName);
extern Dvar_GetVariantString_t Dvar_GetVariantString;
typedef dvar_t*(*Dvar_FindVar_t)(const char* dvarName);
extern Dvar_FindVar_t Dvar_FindVar;
typedef char*(*Dvar_InfoString_Big_t)(int bit);
extern Dvar_InfoString_Big_t Dvar_InfoString_Big;
typedef void(*Dvar_SetCommand_t)(const char* dvarName, const char* string);
extern Dvar_SetCommand_t Dvar_SetCommand;
typedef const char*(*Dvar_DisplayableValue_t)(const dvar_t* dvar);
extern Dvar_DisplayableValue_t Dvar_DisplayableValue;
typedef void(*Dvar_Reset_t)(const dvar_t* dvar, DvarSetSource setSource);
extern Dvar_Reset_t Dvar_Reset;
extern const dvar_t** com_developer;
extern const dvar_t** com_developer_script;
extern const dvar_t** com_timescale;
@ -33,4 +108,7 @@ namespace Game
extern const dvar_t** g_gametype;
extern const dvar_t** version;
extern void Dvar_SetVariant(dvar_t* var, DvarValue value, DvarSetSource source);
extern void Dvar_SetFromStringFromSource(const dvar_t* dvar, const char* string, DvarSetSource source);
}

61
src/Game/FileSystem.cpp Normal file
View File

@ -0,0 +1,61 @@
#include <STDInclude.hpp>
namespace Game
{
FS_FileExists_t FS_FileExists = FS_FileExists_t(0x4DEFA0);
FS_FreeFile_t FS_FreeFile = FS_FreeFile_t(0x4416B0);
FS_ReadFile_t FS_ReadFile = FS_ReadFile_t(0x4F4B90);
FS_ListFiles_t FS_ListFiles = FS_ListFiles_t(0x441BB0);
FS_FreeFileList_t FS_FreeFileList = FS_FreeFileList_t(0x4A5DE0);
FS_FOpenFileAppend_t FS_FOpenFileAppend = FS_FOpenFileAppend_t(0x410BB0);
FS_FOpenFileWrite_t FS_FOpenFileWrite = FS_FOpenFileWrite_t(0x4BA530);
FS_FOpenFileRead_t FS_FOpenFileRead = FS_FOpenFileRead_t(0x46CBF0);
FS_FOpenFileReadDatabase_t FS_FOpenFileReadDatabase = FS_FOpenFileReadDatabase_t(0x42ECA0);
FS_FOpenFileReadForThread_t FS_FOpenFileReadForThread = FS_FOpenFileReadForThread_t(0x643270);
FS_FCloseFile_t FS_FCloseFile = FS_FCloseFile_t(0x462000);
FS_WriteFile_t FS_WriteFile = FS_WriteFile_t(0x426450);
FS_WriteToDemo_t FS_WriteToDemo = FS_WriteToDemo_t(0x4C06E0);
FS_Write_t FS_Write = FS_Write_t(0x4576C0);
FS_Printf_t FS_Printf = FS_Printf_t(0x459320);
FS_Read_t FS_Read = FS_Read_t(0x4A04C0);
FS_Seek_t FS_Seek = FS_Seek_t(0x4A63D0);
FS_FTell_t FS_FTell = FS_FTell_t(0x4E6760);
FS_Remove_t FS_Remove = FS_Remove_t(0x4660F0);
FS_Restart_t FS_Restart = FS_Restart_t(0x461A50);
FS_BuildPathToFile_t FS_BuildPathToFile = FS_BuildPathToFile_t(0x4702C0);
FS_IsShippedIWD_t FS_IsShippedIWD = FS_IsShippedIWD_t(0x642440);
FS_Delete_t FS_Delete = FS_Delete_t(0x48A5B0);
FS_BuildOSPath_t FS_BuildOSPath = FS_BuildOSPath_t(0x4702C0);
searchpath_t** fs_searchpaths = reinterpret_cast<searchpath_t**>(0x63D96E0);
int FS_FOpenFileReadCurrentThread(const char* filename, int* file)
{
if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE7FC))
{
return FS_FOpenFileRead(filename, file);
}
if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE814))
{
return FS_FOpenFileReadDatabase(filename, file);
}
*file = 0;
return -1;
}
void FS_AddLocalizedGameDirectory(const char* path, const char* dir)
{
static DWORD FS_AddLocalizedGameDirectory_t = 0x642EF0;
__asm
{
pushad
mov ebx, path
mov eax, dir
call FS_AddLocalizedGameDirectory_t
popad
}
}
}

82
src/Game/FileSystem.hpp Normal file
View File

@ -0,0 +1,82 @@
#pragma once
namespace Game
{
typedef void(*FS_FreeFile_t)(void* buffer);
extern FS_FreeFile_t FS_FreeFile;
typedef int(*FS_ReadFile_t)(const char* path, char** buffer);
extern FS_ReadFile_t FS_ReadFile;
typedef const char**(*FS_ListFiles_t)(const char* path, const char* extension, FsListBehavior_e behavior, int* numfiles, int allocTrackType);
extern FS_ListFiles_t FS_ListFiles;
typedef void(*FS_FreeFileList_t)(const char** list, int allocTrackType);
extern FS_FreeFileList_t FS_FreeFileList;
typedef int(*FS_FOpenFileAppend_t)(const char* file);
extern FS_FOpenFileAppend_t FS_FOpenFileAppend;
typedef int(*FS_FOpenFileWrite_t)(const char* file);
extern FS_FOpenFileWrite_t FS_FOpenFileWrite;
typedef int(*FS_FOpenFileRead_t)(const char* filename, int* file);
extern FS_FOpenFileRead_t FS_FOpenFileRead;
typedef int(*FS_FOpenFileReadDatabase_t)(const char* filename, int* file);
extern FS_FOpenFileReadDatabase_t FS_FOpenFileReadDatabase;
typedef int(*FS_FOpenFileReadForThread_t)(const char* filename, int* file, int thread);
extern FS_FOpenFileReadForThread_t FS_FOpenFileReadForThread;
typedef int(*FS_FCloseFile_t)(int stream);
extern FS_FCloseFile_t FS_FCloseFile;
typedef bool(*FS_FileExists_t)(const char* file);
extern FS_FileExists_t FS_FileExists;
typedef bool(*FS_WriteFile_t)(const char* filename, const char* folder, const void* buffer, int size);
extern FS_WriteFile_t FS_WriteFile;
typedef int(*FS_WriteToDemo_t)(const void* buffer, int size, int file);
extern FS_WriteToDemo_t FS_WriteToDemo;
typedef int(*FS_Write_t)(const void* buffer, int len, int h);
extern FS_Write_t FS_Write;
typedef int(*FS_Printf_t)(int file, const char* fmt, ...);
extern FS_Printf_t FS_Printf;
typedef int(*FS_Read_t)(void* buffer, size_t size, int file);
extern FS_Read_t FS_Read;
typedef int(*FS_Seek_t)(int fileHandle, int seekPosition, int seekOrigin);
extern FS_Seek_t FS_Seek;
typedef int(*FS_FTell_t)(int fileHandle);
extern FS_FTell_t FS_FTell;
typedef int(*FS_Remove_t)(char*);
extern FS_Remove_t FS_Remove;
typedef int(*FS_Restart_t)(int localClientNum, int checksumFeed);
extern FS_Restart_t FS_Restart;
typedef int(*FS_BuildPathToFile_t)(const char*, const char*, const char*, char**);
extern FS_BuildPathToFile_t FS_BuildPathToFile;
typedef iwd_t* (*FS_IsShippedIWD_t)(const char* fullpath, const char* iwd);
extern FS_IsShippedIWD_t FS_IsShippedIWD;
typedef int(__cdecl* FS_Delete_t)(const char* fileName);
extern FS_Delete_t FS_Delete;
typedef void(*FS_BuildOSPath_t)(const char* base, const char* game, const char* qpath, char* ospath);
extern FS_BuildOSPath_t FS_BuildOSPath;
extern searchpath_t** fs_searchpaths;
extern int FS_FOpenFileReadCurrentThread(const char* filename, int* file);
extern void FS_AddLocalizedGameDirectory(const char* path, const char* dir);
}

View File

@ -1,30 +1,18 @@
#include <STDInclude.hpp>
// Unsorted function definitions
namespace Game
{
AddRefToObject_t AddRefToObject = AddRefToObject_t(0x61C360);
AllocObject_t AllocObject = AllocObject_t(0x434320);
AddRefToValue_t AddRefToValue = AddRefToValue_t(0x482740);
AllocThread_t AllocThread = AllocThread_t(0x4F78C0);
VM_Execute_0_t VM_Execute_0 = VM_Execute_0_t(0x6222A0);
AngleVectors_t AngleVectors = AngleVectors_t(0x4691A0);
BG_GetNumWeapons_t BG_GetNumWeapons = BG_GetNumWeapons_t(0x4F5CC0);
BG_GetWeaponName_t BG_GetWeaponName = BG_GetWeaponName_t(0x4E6EC0);
BG_LoadWeaponDef_LoadObj_t BG_LoadWeaponDef_LoadObj = BG_LoadWeaponDef_LoadObj_t(0x57B5F0);
BG_LoadWeaponCompleteDefInternal_t BG_LoadWeaponCompleteDefInternal = BG_LoadWeaponCompleteDefInternal_t(0x4B5F10);
BG_GetWeaponDef_t BG_GetWeaponDef = BG_GetWeaponDef_t(0x440EB0);
BG_GetEntityTypeName_t BG_GetEntityTypeName = BG_GetEntityTypeName_t(0x43A0E0);
Cbuf_AddServerText_t Cbuf_AddServerText = Cbuf_AddServerText_t(0x4BB9B0);
Cbuf_AddText_t Cbuf_AddText = Cbuf_AddText_t(0x404B20);
Cbuf_InsertText_t Cbuf_InsertText = Cbuf_InsertText_t(0x4940B0);
CG_NextWeapon_f_t CG_NextWeapon_f = CG_NextWeapon_f_t(0x449DE0);
CG_GetClientNum_t CG_GetClientNum = CG_GetClientNum_t(0x433700);
CG_PlayBoltedEffect_t CG_PlayBoltedEffect = CG_PlayBoltedEffect_t(0x00430E10);
CG_GetBoneIndex_t CG_GetBoneIndex = CG_GetBoneIndex_t(0x00504F20);
CG_PlayBoltedEffect_t CG_PlayBoltedEffect = CG_PlayBoltedEffect_t(0x430E10);
CG_GetBoneIndex_t CG_GetBoneIndex = CG_GetBoneIndex_t(0x504F20);
CG_ScoresDown_f_t CG_ScoresDown_f = CG_ScoresDown_f_t(0x580370);
CG_ScoresUp_f_t CG_ScoresUp_f = CG_ScoresUp_f_t(0x5802C0);
CG_ScrollScoreboardUp_t CG_ScrollScoreboardUp = CG_ScrollScoreboardUp_t(0x47A5C0);
@ -32,24 +20,6 @@ namespace Game
CG_GetTeamName_t CG_GetTeamName = CG_GetTeamName_t(0x4B6210);
CG_SetupWeaponDef_t CG_SetupWeaponDef = CG_SetupWeaponDef_t(0x4BD520);
CL_GetClientName_t CL_GetClientName = CL_GetClientName_t(0x4563D0);
CL_IsCgameInitialized_t CL_IsCgameInitialized = CL_IsCgameInitialized_t(0x43EB20);
CL_ConnectFromParty_t CL_ConnectFromParty = CL_ConnectFromParty_t(0x433D30);
CL_DownloadsComplete_t CL_DownloadsComplete = CL_DownloadsComplete_t(0x42CE90);
CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical = CL_DrawStretchPicPhysical_t(0x4FC120);
CL_GetConfigString_t CL_GetConfigString = CL_GetConfigString_t(0x44ADB0);
CL_GetMaxRank_t CL_GetMaxRank = CL_GetMaxRank_t(0x44BA30);
CL_GetRankForXP_t CL_GetRankForXP = CL_GetRankForXP_t(0x4FF8A0);
CL_GetRankIcon_t CL_GetRankIcon = CL_GetRankIcon_t(0x4A7B30);
CL_HandleRelayPacket_t CL_HandleRelayPacket = CL_HandleRelayPacket_t(0x5A8C70);
CL_ResetViewport_t CL_ResetViewport = CL_ResetViewport_t(0x4A8830);
CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f = CL_SelectStringTableEntryInDvar_f_t(0x4A4560);
CL_DrawStretchPic_t CL_DrawStretchPic = CL_DrawStretchPic_t(0x412490);
CL_ConsoleFixPosition_t CL_ConsoleFixPosition = CL_ConsoleFixPosition_t(0x44A430);
CL_GetLocalClientActiveCount_t CL_GetLocalClientActiveCount = CL_GetLocalClientActiveCount_t(0x5BAD90);
CL_ControllerIndexFromClientNum_t CL_ControllerIndexFromClientNum = CL_ControllerIndexFromClientNum_t(0x449E30);
CL_MouseEvent_t CL_MouseEvent = CL_MouseEvent_t(0x4D7C50);
Cmd_AddCommand_t Cmd_AddCommand = Cmd_AddCommand_t(0x470090);
Cmd_AddServerCommand_t Cmd_AddServerCommand = Cmd_AddServerCommand_t(0x4DCE00);
Cmd_ExecuteSingleCommand_t Cmd_ExecuteSingleCommand = Cmd_ExecuteSingleCommand_t(0x609540);
@ -79,47 +49,6 @@ namespace Game
DB_PushStreamPos_t DB_PushStreamPos = DB_PushStreamPos_t(0x458A20);
DB_PopStreamPos_t DB_PopStreamPos = DB_PopStreamPos_t(0x4D1D60);
DB_BeginRecoverLostDevice_t DB_BeginRecoverLostDevice = DB_BeginRecoverLostDevice_t(0x4BFF90);
DB_EndRecoverLostDevice_t DB_EndRecoverLostDevice = DB_EndRecoverLostDevice_t(0x46B660);
DB_EnumXAssets_t DB_EnumXAssets = DB_EnumXAssets_t(0x4B76D0);
DB_EnumXAssets_Internal_t DB_EnumXAssets_Internal = DB_EnumXAssets_Internal_t(0x5BB0A0);
DB_FindXAssetHeader_t DB_FindXAssetHeader = DB_FindXAssetHeader_t(0x407930);
DB_GetRawBuffer_t DB_GetRawBuffer = DB_GetRawBuffer_t(0x4CDC50);
DB_GetRawFileLen_t DB_GetRawFileLen = DB_GetRawFileLen_t(0x4DAA80);
DB_GetLoadedFraction_t DB_GetLoadedFraction = DB_GetLoadedFraction_t(0x468380);
DB_GetXAssetNameHandler_t* DB_GetXAssetNameHandlers = reinterpret_cast<DB_GetXAssetNameHandler_t*>(0x799328);
DB_GetXAssetSizeHandler_t* DB_GetXAssetSizeHandlers = reinterpret_cast<DB_GetXAssetSizeHandler_t*>(0x799488);
DB_GetXAssetTypeName_t DB_GetXAssetTypeName = DB_GetXAssetTypeName_t(0x4CFCF0);
DB_IsXAssetDefault_t DB_IsXAssetDefault = DB_IsXAssetDefault_t(0x48E6A0);
DB_LoadXAssets_t DB_LoadXAssets = DB_LoadXAssets_t(0x4E5930);
DB_LoadXFileData_t DB_LoadXFileData = DB_LoadXFileData_t(0x445460);
DB_ReadXFile_t DB_ReadXFile = DB_ReadXFile_t(0x445460);
DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed = DB_ReadXFileUncompressed_t(0x4705E0);
DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers = reinterpret_cast<DB_ReleaseXAssetHandler_t*>(0x799AB8);
DB_SetXAssetName_t DB_SetXAssetName = DB_SetXAssetName_t(0x453580);
DB_SetXAssetNameHandler_t* DB_SetXAssetNameHandlers = reinterpret_cast<DB_SetXAssetNameHandler_t*>(0x7993D8);
DB_XModelSurfsFixup_t DB_XModelSurfsFixup = DB_XModelSurfsFixup_t(0x5BAC50);
Dvar_RegisterBool_t Dvar_RegisterBool = Dvar_RegisterBool_t(0x4CE1A0);
Dvar_RegisterFloat_t Dvar_RegisterFloat = Dvar_RegisterFloat_t(0x648440);
Dvar_RegisterVec2_t Dvar_RegisterVec2 = Dvar_RegisterVec2_t(0x4F6070);
Dvar_RegisterVec3_t Dvar_RegisterVec3 = Dvar_RegisterVec3_t(0x4EF8E0);
Dvar_RegisterVec4_t Dvar_RegisterVec4 = Dvar_RegisterVec4_t(0x471500);
Dvar_RegisterInt_t Dvar_RegisterInt = Dvar_RegisterInt_t(0x479830);
Dvar_RegisterEnum_t Dvar_RegisterEnum = Dvar_RegisterEnum_t(0x412E40);
Dvar_RegisterString_t Dvar_RegisterString = Dvar_RegisterString_t(0x4FC7E0);
Dvar_RegisterColor_t Dvar_RegisterColor = Dvar_RegisterColor_t(0x4F28E0);
Dvar_RegisterVec3Color_t Dvar_RegisterVec3Color = Dvar_RegisterVec3Color_t(0x4918B0);
Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName = Dvar_GetUnpackedColorByName_t(0x406530);
Dvar_GetString_t Dvar_GetString = Dvar_GetString_t(0x4EC6B0);
Dvar_GetVariantString_t Dvar_GetVariantString = Dvar_GetVariantString_t(0x4C47E0);
Dvar_FindVar_t Dvar_FindVar = Dvar_FindVar_t(0x4D5390);
Dvar_InfoString_Big_t Dvar_InfoString_Big = Dvar_InfoString_Big_t(0x4D98A0);
Dvar_SetCommand_t Dvar_SetCommand = Dvar_SetCommand_t(0x4EE430);
Dvar_DisplayableValue_t Dvar_DisplayableValue = Dvar_DisplayableValue_t(0x4B5530);
Dvar_Reset_t Dvar_Reset = Dvar_Reset_t(0x4FEFD0);
Encode_Init_t Encode_Init = Encode_Init_t(0x462AB0);
Field_Clear_t Field_Clear = Field_Clear_t(0x437EB0);
@ -127,41 +56,6 @@ namespace Game
FreeMemory_t FreeMemory = FreeMemory_t(0x4D6640);
Free_String_t Free_String = Free_String_t(0x470E80);
FS_FileExists_t FS_FileExists = FS_FileExists_t(0x4DEFA0);
FS_FreeFile_t FS_FreeFile = FS_FreeFile_t(0x4416B0);
FS_ReadFile_t FS_ReadFile = FS_ReadFile_t(0x4F4B90);
FS_ListFiles_t FS_ListFiles = FS_ListFiles_t(0x441BB0);
FS_FreeFileList_t FS_FreeFileList = FS_FreeFileList_t(0x4A5DE0);
FS_FOpenFileAppend_t FS_FOpenFileAppend = FS_FOpenFileAppend_t(0x410BB0);
FS_FOpenFileAppend_t FS_FOpenFileWrite = FS_FOpenFileAppend_t(0x4BA530);
FS_FOpenFileRead_t FS_FOpenFileRead = FS_FOpenFileRead_t(0x46CBF0);
FS_FOpenFileRead_t FS_FOpenFileReadDatabase = FS_FOpenFileRead_t(0x42ECA0);
FS_FOpenFileReadForThread_t FS_FOpenFileReadForThread = FS_FOpenFileReadForThread_t(0x643270);
FS_FCloseFile_t FS_FCloseFile = FS_FCloseFile_t(0x462000);
FS_WriteFile_t FS_WriteFile = FS_WriteFile_t(0x426450);
FS_WriteToDemo_t FS_WriteToDemo = FS_WriteToDemo_t(0x4C06E0);
FS_Write_t FS_Write = FS_Write_t(0x4576C0);
FS_Printf_t FS_Printf = FS_Printf_t(0x459320);
FS_Read_t FS_Read = FS_Read_t(0x4A04C0);
FS_Seek_t FS_Seek = FS_Seek_t(0x4A63D0);
FS_FTell_t FS_FTell = FS_FTell_t(0x4E6760);
FS_Remove_t FS_Remove = FS_Remove_t(0x4660F0);
FS_Restart_t FS_Restart = FS_Restart_t(0x461A50);
FS_BuildPathToFile_t FS_BuildPathToFile = FS_BuildPathToFile_t(0x4702C0);
FS_IsShippedIWD_t FS_IsShippedIWD = FS_IsShippedIWD_t(0x642440);
FS_Delete_t FS_Delete = FS_Delete_t(0x48A5B0);
FS_BuildOSPath_t FS_BuildOSPath = FS_BuildOSPath_t(0x4702C0);
G_LogPrintf_t G_LogPrintf = G_LogPrintf_t(0x4B0150);
G_GetWeaponIndexForName_t G_GetWeaponIndexForName = G_GetWeaponIndexForName_t(0x49E540);
G_SpawnEntitiesFromString_t G_SpawnEntitiesFromString = G_SpawnEntitiesFromString_t(0x4D8840);
G_Spawn_t G_Spawn = G_Spawn_t(0x4226F0);
G_FreeEntity_t G_FreeEntity = G_FreeEntity_t(0x44C9D0);
G_SpawnItem_t G_SpawnItem = G_SpawnItem_t(0x403770);
G_GetItemClassname_t G_GetItemClassname = G_GetItemClassname_t(0x492630);
G_PrintEntities_t G_PrintEntities = G_PrintEntities_t(0x4E6A50);
G_GetEntityTypeName_t G_GetEntityTypeName = G_GetEntityTypeName_t(0x4EB810);
Svcmd_EntityList_f_t Svcmd_EntityList_f = Svcmd_EntityList_f_t(0x4B6A70);
GScr_LoadGameTypeScript_t GScr_LoadGameTypeScript = GScr_LoadGameTypeScript_t(0x4ED9A0);
@ -270,61 +164,6 @@ namespace Game
R_FlushSun_t R_FlushSun = R_FlushSun_t(0x53FB50);
R_SortWorldSurfaces_t R_SortWorldSurfaces = R_SortWorldSurfaces_t(0x53DC10);
RemoveRefToObject_t RemoveRefToObject = RemoveRefToObject_t(0x437190);
Scr_GetGameTypeNameForScript_t Scr_GetGameTypeNameForScript = Scr_GetGameTypeNameForScript_t(0x462460);
Scr_IsValidGameType_t Scr_IsValidGameType = Scr_IsValidGameType_t(0x4F1B60);
Scr_LoadGameType_t Scr_LoadGameType = Scr_LoadGameType_t(0x4D9520);
Scr_StartupGameType_t Scr_StartupGameType = Scr_StartupGameType_t(0x438720);
Scr_LoadScript_t Scr_LoadScript = Scr_LoadScript_t(0x45D940);
Scr_GetFunctionHandle_t Scr_GetFunctionHandle = Scr_GetFunctionHandle_t(0x4234F0);
Scr_GetString_t Scr_GetString = Scr_GetString_t(0x425900);
Scr_GetConstString_t Scr_GetConstString = Scr_GetConstString_t(0x494830);
Scr_GetDebugString_t Scr_GetDebugString = Scr_GetDebugString_t(0x4EBF50);
Scr_GetFloat_t Scr_GetFloat = Scr_GetFloat_t(0x443140);
Scr_GetInt_t Scr_GetInt = Scr_GetInt_t(0x4F31D0);
Scr_GetObject_t Scr_GetObject = Scr_GetObject_t(0x462100);
Scr_GetTypeName_t Scr_GetTypeName = Scr_GetTypeName_t(0x4EFF10);
Scr_GetNumParam_t Scr_GetNumParam = Scr_GetNumParam_t(0x4B0E90);
Scr_GetEntityId_t Scr_GetEntityId = Scr_GetEntityId_t(0x4165E0);
Scr_ExecThread_t Scr_ExecThread = Scr_ExecThread_t(0x4AD0B0);
Scr_FreeThread_t Scr_FreeThread = Scr_FreeThread_t(0x4BD320);
Scr_AddEntity_t Scr_AddEntity = Scr_AddEntity_t(0x4BFB40);
Scr_AddString_t Scr_AddString = Scr_AddString_t(0x412310);
Scr_AddConstString_t Scr_AddConstString = Scr_AddConstString_t(0x488860);
Scr_AddIString_t Scr_AddIString = Scr_AddIString_t(0x455F20);
Scr_AddInt_t Scr_AddInt = Scr_AddInt_t(0x41D7D0);
Scr_AddFloat_t Scr_AddFloat = Scr_AddFloat_t(0x61E860);
Scr_AddObject_t Scr_AddObject = Scr_AddObject_t(0x430F40);
Scr_Notify_t Scr_Notify = Scr_Notify_t(0x4A4750);
Scr_NotifyLevel_t Scr_NotifyLevel = Scr_NotifyLevel_t(0x4D9C30);
Scr_Error_t Scr_Error = Scr_Error_t(0x61E8B0);
Scr_ObjectError_t Scr_ObjectError = Scr_ObjectError_t(0x42EF40);
Scr_ParamError_t Scr_ParamError = Scr_ParamError_t(0x4FBC70);
Scr_GetType_t Scr_GetType = Scr_GetType_t(0x422900);
Scr_GetPointerType_t Scr_GetPointerType = Scr_GetPointerType_t(0x4828E0);
Scr_ClearOutParams_t Scr_ClearOutParams = Scr_ClearOutParams_t(0x4386E0);
Scr_GetObjectField_t Scr_GetObjectField = Scr_GetObjectField_t(0x4FF3D0);
Scr_SetObjectField_t Scr_SetObjectField = Scr_SetObjectField_t(0x4F20F0);
Scr_GetEntityField_t Scr_GetEntityField = Scr_GetEntityField_t(0x4E8390);
Scr_SetClientField_t Scr_SetClientField = Scr_SetClientField_t(0x4A6DF0);
Scr_AddClassField_t Scr_AddClassField = Scr_AddClassField_t(0x4C0E70);
GetEntity_t GetEntity = GetEntity_t(0x4BC270);
GetPlayerEntity_t GetPlayerEntity = GetPlayerEntity_t(0x49C4A0);
Scr_RegisterFunction_t Scr_RegisterFunction = Scr_RegisterFunction_t(0x492D50);
Scr_ShutdownAllocNode_t Scr_ShutdownAllocNode = Scr_ShutdownAllocNode_t(0x441650);
Scr_IsSystemActive_t Scr_IsSystemActive = Scr_IsSystemActive_t(0x4B24E0);
Script_Alloc_t Script_Alloc = Script_Alloc_t(0x422E70);
Script_SetupTokens_t Script_SetupTokens = Script_SetupTokens_t(0x4E6950);
Script_CleanString_t Script_CleanString = Script_CleanString_t(0x498220);
@ -359,42 +198,6 @@ namespace Game
StringTable_GetColumnValueForRow_t StringTable_GetColumnValueForRow = StringTable_GetColumnValueForRow_t(0x4F2C80);
StringTable_HashString_t StringTable_HashString = StringTable_HashString_t(0x475EB0);
SV_AddTestClient_t SV_AddTestClient = SV_AddTestClient_t(0x48AD30);
SV_IsTestClient_t SV_IsTestClient = SV_IsTestClient_t(0x4D6E40);
SV_GameClientNum_Score_t SV_GameClientNum_Score = SV_GameClientNum_Score_t(0x469AC0);
SV_GameSendServerCommand_t SV_GameSendServerCommand = SV_GameSendServerCommand_t(0x4BC3A0);
SV_Cmd_TokenizeString_t SV_Cmd_TokenizeString = SV_Cmd_TokenizeString_t(0x4B5780);
SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString = SV_Cmd_EndTokenizedString_t(0x464750);
SV_Cmd_ArgvBuffer_t SV_Cmd_ArgvBuffer = SV_Cmd_ArgvBuffer_t(0x40BB60);
SV_DirectConnect_t SV_DirectConnect = SV_DirectConnect_t(0x460480);
SV_SetConfigstring_t SV_SetConfigstring = SV_SetConfigstring_t(0x4982E0);
SV_Loaded_t SV_Loaded = SV_Loaded_t(0x4EE3E0);
SV_ClientThink_t SV_ClientThink = SV_ClientThink_t(0x44ADD0);
SV_DropClient_t SV_DropClient = SV_DropClient_t(0x4D1600);
SV_GetPlayerByName_t SV_GetPlayerByName = SV_GetPlayerByName_t(0x6242B0);
SV_GetPlayerByNum_t SV_GetPlayerByNum = SV_GetPlayerByNum_t(0x624390);
SV_FindClientByAddress_t SV_FindClientByAddress = SV_FindClientByAddress_t(0x44F450);
Sys_FreeFileList_t Sys_FreeFileList = Sys_FreeFileList_t(0x4D8580);
Sys_IsDatabaseReady_t Sys_IsDatabaseReady = Sys_IsDatabaseReady_t(0x4CA4A0);
Sys_IsDatabaseReady2_t Sys_IsDatabaseReady2 = Sys_IsDatabaseReady2_t(0x441280);
Sys_IsMainThread_t Sys_IsMainThread = Sys_IsMainThread_t(0x4C37D0);
Sys_IsRenderThread_t Sys_IsRenderThread = Sys_IsRenderThread_t(0x4B20E0);
Sys_IsServerThread_t Sys_IsServerThread = Sys_IsServerThread_t(0x4B0270);
Sys_IsDatabaseThread_t Sys_IsDatabaseThread = Sys_IsDatabaseThread_t(0x4C6020);
Sys_SendPacket_t Sys_SendPacket = Sys_SendPacket_t(0x60FDC0);
Sys_ShowConsole_t Sys_ShowConsole = Sys_ShowConsole_t(0x4305E0);
Sys_SuspendOtherThreads_t Sys_SuspendOtherThreads = Sys_SuspendOtherThreads_t(0x45A190);
Sys_ListFiles_t Sys_ListFiles = Sys_ListFiles_t(0x45A660);
Sys_Milliseconds_t Sys_Milliseconds = Sys_Milliseconds_t(0x42A660);
Sys_Error_t Sys_Error = Sys_Error_t(0x43D570);
Sys_LockWrite_t Sys_LockWrite = Sys_LockWrite_t(0x435880);
Sys_TempPriorityAtLeastNormalBegin_t Sys_TempPriorityAtLeastNormalBegin = Sys_TempPriorityAtLeastNormalBegin_t(0x478680);
Sys_TempPriorityEnd_t Sys_TempPriorityEnd = Sys_TempPriorityEnd_t(0x4DCF00);
Sys_EnterCriticalSection_t Sys_EnterCriticalSection = Sys_EnterCriticalSection_t(0x4FC200);
Sys_LeaveCriticalSection_t Sys_LeaveCriticalSection = Sys_LeaveCriticalSection_t(0x41B8C0);
Sys_DefaultInstallPath_t Sys_DefaultInstallPath = Sys_DefaultInstallPath_t(0x4326E0);
TeleportPlayer_t TeleportPlayer = TeleportPlayer_t(0x496850);
UI_AddMenuList_t UI_AddMenuList = UI_AddMenuList_t(0x4533C0);
@ -476,9 +279,6 @@ namespace Game
LargeLocalBegin_t LargeLocalBegin = LargeLocalBegin_t(0x4127A0);
LargeLocalBeginRight_t LargeLocalBeginRight = LargeLocalBeginRight_t(0x644140);
XAssetHeader* DB_XAssetPool = reinterpret_cast<XAssetHeader*>(0x7998A8);
unsigned int* g_poolSize = reinterpret_cast<unsigned int*>(0x7995E8);
CmdArgs* cmd_args = reinterpret_cast<CmdArgs*>(0x1AAC5D0);
CmdArgs* sv_cmd_args = reinterpret_cast<CmdArgs*>(0x1ACF8A0);
@ -487,14 +287,8 @@ namespace Game
source_t **sourceFiles = reinterpret_cast<source_t **>(0x7C4A98);
keywordHash_t **menuParseKeywordHash = reinterpret_cast<keywordHash_t **>(0x63AE928);
float* cl_angles = reinterpret_cast<float*>(0xB2F8D0);
float* cgameFOVSensitivityScale = reinterpret_cast<float*>(0xB2F884);
int* svs_time = reinterpret_cast<int*>(0x31D9384);
int* sv_serverId_value = reinterpret_cast<int*>(0x2089DC0);
int* svs_clientCount = reinterpret_cast<int*>(0x31D938C);
client_t* svs_clients = reinterpret_cast<client_t*>(0x31D9390);
UiContext* uiContext = reinterpret_cast<UiContext*>(0x62E2858);
int* arenaCount = reinterpret_cast<int*>(0x62E6930);
@ -503,12 +297,6 @@ namespace Game
int* gameTypeCount = reinterpret_cast<int*>(0x62E50A0);
gameTypeName_t* gameTypes = reinterpret_cast<gameTypeName_t*>(0x62E50A4);
searchpath_t** fs_searchpaths = reinterpret_cast<searchpath_t**>(0x63D96E0);
XBlock** g_streamBlocks = reinterpret_cast<XBlock**>(0x16E554C);
int* g_streamPos = reinterpret_cast<int*>(0x16E5554);
int* g_streamPosIndex = reinterpret_cast<int*>(0x16E5578);
bool* g_lobbyCreateInProgress = reinterpret_cast<bool*>(0x66C9BC2);
PartyData* g_lobbyData = reinterpret_cast<PartyData*>(0x1081C00);
PartyData* g_partyData = reinterpret_cast<PartyData*>(0x107E500);
@ -523,8 +311,6 @@ namespace Game
int* demoRecording = reinterpret_cast<int*>(0xA5EA08);
int* serverMessageSequence = reinterpret_cast<int*>(0xA3E9B4);
gentity_t* g_entities = reinterpret_cast<gentity_t*>(0x18835D8);
netadr_t* connectedHost = reinterpret_cast<netadr_t*>(0xA1E888);
SOCKET* ip_socket = reinterpret_cast<SOCKET*>(0x64A3008);
@ -560,12 +346,6 @@ namespace Game
infoParm_t* infoParams = reinterpret_cast<infoParm_t*>(0x79D260); // Count 0x1E
XZone* g_zones = reinterpret_cast<XZone*>(0x14C0F80);
unsigned short* db_hashTable = reinterpret_cast<unsigned short*>(0x12412B0);
scrVmPub_t* scrVmPub = reinterpret_cast<scrVmPub_t*>(0x2040CF0);
scrVarPub_t* scrVarPub = reinterpret_cast<scrVarPub_t*>(0x201A408);
clientState_t* clcState = reinterpret_cast<clientState_t*>(0xB2C540);
GfxScene* scene = reinterpret_cast<GfxScene*>(0x6944914);
@ -577,9 +357,6 @@ namespace Game
float* g_console_char_height = reinterpret_cast<float*>(0x798550);
field_t* g_consoleField = reinterpret_cast<field_t*>(0xA1B6B0);
clientStatic_t* cls = reinterpret_cast<clientStatic_t*>(0xA7FE90);
clientUIActive_t* clientUIActives = reinterpret_cast<clientUIActive_t*>(0xB2BB88);
sharedUiInfo_t* sharedUiInfo = reinterpret_cast<sharedUiInfo_t*>(0x62E4B78);
ScreenPlacement* scrPlaceFull = reinterpret_cast<ScreenPlacement*>(0x10843F0);
ScreenPlacement* scrPlaceFullUnsafe = reinterpret_cast<ScreenPlacement*>(0x1084460);
@ -603,8 +380,6 @@ namespace Game
XModel** cached_models = reinterpret_cast<XModel**>(0x1AA20C8);
FastCriticalSection* db_hashCritSect = reinterpret_cast<FastCriticalSection*>(0x16B8A54);
float (*CorrectSolidDeltas)[26][3] = reinterpret_cast<float(*)[26][3]>(0x739BB8); // Count 26
level_locals_t* level = reinterpret_cast<level_locals_t*>(0x1A831A8);
@ -630,55 +405,17 @@ namespace Game
int* com_errorPrintsCount = reinterpret_cast<int*>(0x1AD7910);
scr_const_t* scr_const = reinterpret_cast<scr_const_t*>(0x1AA2E00);
clientConnection_t* clientConnections = reinterpret_cast<clientConnection_t*>(0xA1E878);
unsigned int* playerCardUIStringIndex = reinterpret_cast<unsigned int*>(0x62CD7A8);
char (*playerCardUIStringBuf)[PLAYER_CARD_UI_STRING_COUNT][38] = reinterpret_cast<char(*)[PLAYER_CARD_UI_STRING_COUNT][38]>(0x62CB4F8);
char (*sys_exitCmdLine)[1024] = reinterpret_cast<char(*)[1024]>(0x649FB68);
int* logfile = reinterpret_cast<int*>(0x1AD8F28);
GamerSettingState* gamerSettings = reinterpret_cast<GamerSettingState*>(0x107D3E8);
voiceCommunication_t* cl_voiceCommunication = reinterpret_cast<voiceCommunication_t*>(0x1079DA0);
volatile long* sv_thread_owns_game = reinterpret_cast<volatile long*>(0x2089DB8);
unsigned char* g_largeLocalBuf = reinterpret_cast<unsigned char*>(0x63D9790);
int* g_largeLocalPos = reinterpret_cast<int*>(0x63D97B4);
int* g_largeLocalRightPos = reinterpret_cast<int*>(0x63D9780);
void Sys_LockRead(FastCriticalSection* critSect)
{
InterlockedIncrement(&critSect->readCount);
while (critSect->writeCount) std::this_thread::sleep_for(1ms);
}
void Sys_UnlockRead(FastCriticalSection* critSect)
{
assert(critSect->readCount > 0);
InterlockedDecrement(&critSect->readCount);
}
XModel* G_GetModel(const int index)
{
assert(index > 0);
assert(index < MAX_MODELS);
return cached_models[index];
}
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize)
{
int elSize = DB_GetXAssetSizeHandlers[type]();
XAssetHeader poolEntry = { Utils::Memory::GetAllocator()->allocate(newSize * elSize) };
DB_XAssetPool[type] = poolEntry;
g_poolSize[type] = newSize;
return poolEntry;
}
const char* TableLookup(StringTable* stringtable, int row, int column)
{
if (!stringtable || !stringtable->values || row >= stringtable->rowCount || column >= stringtable->columnCount) return "";
@ -726,102 +463,10 @@ namespace Game
return gameType;
}
const char *DB_GetXAssetName(XAsset *asset)
{
if (!asset) return "";
return DB_GetXAssetNameHandlers[asset->type](&asset->header);
}
XAssetType DB_GetXAssetNameType(const char* name)
{
for (int i = 0; i < ASSET_TYPE_COUNT; ++i)
{
XAssetType type = static_cast<XAssetType>(i);
if (!_stricmp(DB_GetXAssetTypeName(type), name))
{
// Col map workaround!
if (type == Game::XAssetType::ASSET_TYPE_CLIPMAP_SP)
{
return Game::XAssetType::ASSET_TYPE_CLIPMAP_MP;
}
return type;
}
}
return ASSET_TYPE_INVALID;
}
int DB_GetZoneIndex(const std::string& name)
{
for (int i = 0; i < 32; ++i)
{
if (Game::g_zones[i].name == name)
{
return i;
}
}
return -1;
}
bool DB_IsZoneLoaded(const char* zone)
{
int zoneCount = Utils::Hook::Get<int>(0x1261BCC);
char* zoneIndices = reinterpret_cast<char*>(0x16B8A34);
char* zoneData = reinterpret_cast<char*>(0x14C0F80);
for (int i = 0; i < zoneCount; ++i)
{
std::string name = zoneData + 4 + 0xA4 * (zoneIndices[i] & 0xFF);
if (name == zone)
{
return true;
}
}
return false;
}
void DB_EnumXAssetEntries(XAssetType type, std::function<void(XAssetEntry*)> callback, bool overrides)
{
Sys_LockRead(db_hashCritSect);
const auto pool = Components::Maps::GetAssetEntryPool();
for(auto hash = 0; hash < 37000; hash++)
{
auto hashIndex = db_hashTable[hash];
while(hashIndex)
{
auto* assetEntry = &pool[hashIndex];
if(assetEntry->asset.type == type)
{
callback(assetEntry);
if (overrides)
{
auto overrideIndex = assetEntry->nextOverride;
while (overrideIndex)
{
auto* overrideEntry = &pool[overrideIndex];
callback(overrideEntry);
overrideIndex = overrideEntry->nextOverride;
}
}
}
hashIndex = assetEntry->nextHash;
}
}
Sys_UnlockRead(db_hashCritSect);
}
// this cant be MessageBox because windows.h has a define that converts it to MessageBoxW. which is just stupid
void ShowMessageBox(const std::string& message, const std::string& title)
{
if (!Game::CL_IsCgameInitialized())
if (!CL_IsCgameInitialized())
{
Dvar_SetStringByName("com_errorMessage", message.data());
Dvar_SetStringByName("com_errorTitle", title.data());
@ -856,72 +501,6 @@ namespace Game
return hash;
}
int SV_GetServerThreadOwnsGame()
{
return *sv_thread_owns_game;
}
void SV_GameDropClient(int clientNum, const char* reason)
{
assert((*sv_maxclients)->current.integer >= 1 && (*sv_maxclients)->current.integer <= 18);
if (clientNum >= 0 && clientNum < (*sv_maxclients)->current.integer)
{
SV_DropClient(&svs_clients[clientNum], reason, true);
}
}
void SV_DropAllBots()
{
for (auto i = 0; i < *svs_clientCount; ++i)
{
if (svs_clients[i].header.state != CS_FREE
&& svs_clients[i].header.netchan.remoteAddress.type == NA_BOT)
{
SV_GameDropClient(i, "GAME_GET_TO_COVER");
}
}
}
void IncInParam()
{
Scr_ClearOutParams();
if (scrVmPub->top == scrVmPub->maxStack)
{
Sys_Error("Internal script stack overflow");
}
scrVmPub->top++;
scrVmPub->inparamcount++;
}
void Scr_AddBool(int value)
{
assert(value == 0 || value == 1);
IncInParam();
scrVmPub->top->type = VAR_INTEGER;
scrVmPub->top->u.intValue = value;
}
int FS_FOpenFileReadCurrentThread(const char* file, int* fh)
{
if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE7FC))
{
return FS_FOpenFileRead(file, fh);
}
else if (GetCurrentThreadId() == *reinterpret_cast<DWORD*>(0x1CDE814))
{
return FS_FOpenFileReadDatabase(file, fh);
}
else
{
*fh = NULL;
return -1;
}
}
void Load_IndexBuffer(void* data, IDirect3DIndexBuffer9** storeHere, int count)
{
if (Components::Dvar::Var("r_loadForRenderer").get<bool>())
@ -938,19 +517,19 @@ namespace Game
char* Com_GetParseThreadInfo()
{
if (Game::Sys_IsMainThread())
if (Sys_IsMainThread())
{
return reinterpret_cast<char*>(0x6466628);
}
if (Game::Sys_IsRenderThread())
if (Sys_IsRenderThread())
{
return reinterpret_cast<char*>(0x646AC34);
}
if (Game::Sys_IsServerThread())
if (Sys_IsServerThread())
{
return reinterpret_cast<char*>(0x646F240);
}
if (Game::Sys_IsDatabaseThread())
if (Sys_IsDatabaseThread())
{
return reinterpret_cast<char*>(0x647384C);
}
@ -968,35 +547,6 @@ namespace Game
}
}
int CL_GetMaxXP()
{
StringTable* rankTable = DB_FindXAssetHeader(ASSET_TYPE_STRINGTABLE, "mp/rankTable.csv").stringTable;
const char* maxrank = StringTable_Lookup(rankTable, 0, "maxrank", 1);
return atoi(StringTable_Lookup(rankTable, 0, maxrank, 7));
}
clientConnection_t* CL_GetLocalClientConnection(const int localClientNum)
{
assert(clientConnections);
AssertIn(localClientNum, MAX_LOCAL_CLIENTS);
return &clientConnections[localClientNum];
}
connstate_t CL_GetLocalClientConnectionState(const int localClientNum)
{
AssertIn(localClientNum, STATIC_MAX_LOCAL_CLIENTS);
return clientUIActives[localClientNum].connectionState;
}
voiceCommunication_t* CL_GetLocalClientVoiceCommunication([[maybe_unused]] const int localClientNum)
{
AssertIn(localClientNum, STATIC_MAX_LOCAL_CLIENTS);
return cl_voiceCommunication;
}
void Vec2UnpackTexCoords(const PackedTexCoords in, vec2_t* out)
{
unsigned int v3; // xmm1_4
@ -1072,7 +622,7 @@ namespace Game
void R_AddDebugBounds(float* color, Bounds* b)
{
Game::vec3_t v1, v2, v3, v4, v5, v6, v7, v8;
vec3_t v1, v2, v3, v4, v5, v6, v7, v8;
float* center = b->midPoint;
float* halfSize = b->halfSize;
@ -1109,22 +659,22 @@ namespace Game
v8[2] = center[2] + halfSize[2];
// bottom
Game::R_AddDebugLine(color, v1, v2);
Game::R_AddDebugLine(color, v2, v4);
Game::R_AddDebugLine(color, v4, v3);
Game::R_AddDebugLine(color, v3, v1);
R_AddDebugLine(color, v1, v2);
R_AddDebugLine(color, v2, v4);
R_AddDebugLine(color, v4, v3);
R_AddDebugLine(color, v3, v1);
// top
Game::R_AddDebugLine(color, v5, v6);
Game::R_AddDebugLine(color, v6, v8);
Game::R_AddDebugLine(color, v8, v7);
Game::R_AddDebugLine(color, v7, v5);
R_AddDebugLine(color, v5, v6);
R_AddDebugLine(color, v6, v8);
R_AddDebugLine(color, v8, v7);
R_AddDebugLine(color, v7, v5);
// verticals
Game::R_AddDebugLine(color, v1, v5);
Game::R_AddDebugLine(color, v2, v6);
Game::R_AddDebugLine(color, v3, v7);
Game::R_AddDebugLine(color, v4, v8);
R_AddDebugLine(color, v1, v5);
R_AddDebugLine(color, v2, v6);
R_AddDebugLine(color, v3, v7);
R_AddDebugLine(color, v4, v8);
}
void R_AddDebugBounds(float* color, Bounds* b, const float(*quat)[4])
@ -1174,22 +724,22 @@ namespace Game
}
// bottom
Game::R_AddDebugLine(color, v[0], v[1]);
Game::R_AddDebugLine(color, v[1], v[3]);
Game::R_AddDebugLine(color, v[3], v[2]);
Game::R_AddDebugLine(color, v[2], v[0]);
R_AddDebugLine(color, v[0], v[1]);
R_AddDebugLine(color, v[1], v[3]);
R_AddDebugLine(color, v[3], v[2]);
R_AddDebugLine(color, v[2], v[0]);
// top
Game::R_AddDebugLine(color, v[4], v[5]);
Game::R_AddDebugLine(color, v[5], v[7]);
Game::R_AddDebugLine(color, v[7], v[6]);
Game::R_AddDebugLine(color, v[6], v[4]);
R_AddDebugLine(color, v[4], v[5]);
R_AddDebugLine(color, v[5], v[7]);
R_AddDebugLine(color, v[7], v[6]);
R_AddDebugLine(color, v[6], v[4]);
// verticals
Game::R_AddDebugLine(color, v[0], v[4]);
Game::R_AddDebugLine(color, v[1], v[5]);
Game::R_AddDebugLine(color, v[2], v[6]);
Game::R_AddDebugLine(color, v[3], v[7]);
R_AddDebugLine(color, v[0], v[4]);
R_AddDebugLine(color, v[1], v[5]);
R_AddDebugLine(color, v[2], v[6]);
R_AddDebugLine(color, v[3], v[7]);
}
float GraphGetValueFromFraction(const int knotCount, const float(*knots)[2], const float fraction)
@ -1267,50 +817,6 @@ namespace Game
}
}
__declspec(naked) XAssetHeader DB_FindXAssetDefaultHeaderInternal(XAssetType /*type*/)
{
__asm
{
push eax
pushad
mov eax, 5BB210h
mov edi, [esp + 28h]
call eax
mov [esp + 20h], eax
popad
pop eax
retn
}
}
__declspec(naked) XAssetEntry* DB_FindXAssetEntry(XAssetType /*type*/, const char* /*name*/)
{
__asm
{
push eax
pushad
mov edi, [esp + 2Ch] // name
push edi
mov edi, [esp + 2Ch] // type
mov eax, 5BB1B0h
call eax
add esp, 4h
mov [esp + 20h], eax
popad
pop eax
retn
}
}
__declspec(naked) bool PM_IsAdsAllowed(playerState_s* /*ps*/)
{
__asm
@ -1330,23 +836,6 @@ namespace Game
}
}
__declspec(naked) void FS_AddLocalizedGameDirectory(const char* /*path*/, const char* /*dir*/)
{
__asm
{
pushad
mov ebx, [esp + 24h]
mov eax, [esp + 28h]
mov ecx, 642EF0h
call ecx
popad
retn
}
}
__declspec(naked) void R_LoadSunThroughDvars(const char* /*mapname*/, sunflare_t* /*sun*/)
{
__asm
@ -1379,48 +868,6 @@ namespace Game
}
}
__declspec(naked) void Scr_NotifyId(unsigned int /*id*/, unsigned __int16 /*stringValue*/, unsigned int /*paramcount*/)
{
__asm
{
pushad
mov eax, [esp + 2Ch] // paramcount
push [esp + 28h] // stringValue
push [esp + 28h] // id
mov edx, 61E670h // Scr_NotifyId
call edx
add esp, 8h
popad
retn
}
}
__declspec(naked) void RuntimeErrorInternal(int /*channel*/, const char* /*codePos*/, unsigned int /*index*/, const char* /*msg*/)
{
__asm
{
pushad
mov eax, [esp + 0x10 + 0x20] // msg
mov edi, [esp + 0x4 + 0x20] // channel
push [esp + 0xC + 0x20] // index
push [esp + 0xC + 0x20] // codePos
mov edx, 0x61ABE0
call edx
add esp, 0x8
popad
ret
}
}
__declspec(naked) void IN_KeyUp(kbutton_t* /*button*/)
{
__asm
@ -1503,7 +950,7 @@ namespace Game
}
}
void Menu_SetNextCursorItem(Game::UiContext* a1, Game::menuDef_t* a2, int unk)
void Menu_SetNextCursorItem(UiContext* a1, menuDef_t* a2, int unk)
{
__asm
{
@ -1516,7 +963,7 @@ namespace Game
}
}
void Menu_SetPrevCursorItem(Game::UiContext* a1, Game::menuDef_t* a2, int unk)
void Menu_SetPrevCursorItem(UiContext* a1, menuDef_t* a2, int unk)
{
__asm
{
@ -1591,8 +1038,8 @@ namespace Game
Glyph* R_GetCharacterGlyph(Font_s* font, unsigned int letter)
{
static auto R_GetCharacterGlyph_Func = 0x5055C0;
Glyph* returnValue;
static auto R_GetCharacterGlyph_t = 0x5055C0;
Glyph* result;
__asm
{
@ -1600,14 +1047,14 @@ namespace Game
mov edi, letter
push font
call R_GetCharacterGlyph_Func
call R_GetCharacterGlyph_t
add esp, 4
mov returnValue, eax
mov result, eax
popad
}
return returnValue;
return result;
}
__declspec(naked) bool SetupPulseFXVars(const char* /*text*/, int /*maxLength*/, int /*fxBirthTime*/, int /*fxLetterTime*/, int /*fxDecayStartTime*/, int /*fxDecayDuration*/, bool* /*resultDrawRandChar*/, int* /*resultRandSeed*/, int* /*resultMaxLength*/, bool* /*resultDecaying*/, int* /*resultDecayTimeElapsed*/)
@ -1732,48 +1179,6 @@ namespace Game
}
}
__declspec(naked) void Dvar_SetVariant(dvar_t*, DvarValue, DvarSetSource)
{
__asm
{
pushad
mov eax, [esp + 0x4 + 0x20] // dvar
push [esp + 0x18 + 0x20] // source
push [esp + 0x18 + 0x20] // value
push [esp + 0x18 + 0x20] // value
push [esp + 0x18 + 0x20] // value
push [esp + 0x18 + 0x20] // value
mov ebx, 0x647400
call ebx
add esp, 0x14
popad
retn
}
}
constexpr auto Dvar_SetFromStringFromSource_Func = 0x648580;
__declspec(naked) void Dvar_SetFromStringFromSource(const dvar_t* /*dvar*/, const char* /*string*/, DvarSetSource /*source*/)
{
__asm
{
pushad
mov esi, [esp + 0x20 + 0x4] // dvar
mov eax, [esp + 0x20 + 0x8] // string
push [esp + 0x20 + 0xC] // source
call Dvar_SetFromStringFromSource_Func
add esp, 0x4
popad
ret
}
}
constexpr auto ApplyTokenToField_Func = 0x59A760;
__declspec(naked) bool ApplyTokenToField(unsigned int /*fieldNum*/, const char* /*token*/, visionSetVars_t* /*settings*/)
{
@ -1796,20 +1201,5 @@ namespace Game
ret
}
}
constexpr auto SV_BotUserMove_Addr = 0x626E50;
__declspec(naked) void SV_BotUserMove(client_t* /*client*/)
{
__asm
{
pushad
mov edi, [esp + 0x20 + 0x4]
call SV_BotUserMove_Addr
popad
ret
}
}
#pragma optimize("", on)
}

File diff suppressed because it is too large Load Diff

23
src/Game/Game.cpp Normal file
View File

@ -0,0 +1,23 @@
#include <STDInclude.hpp>
namespace Game
{
G_LogPrintf_t G_LogPrintf = G_LogPrintf_t(0x4B0150);
G_GetWeaponIndexForName_t G_GetWeaponIndexForName = G_GetWeaponIndexForName_t(0x49E540);
G_SpawnEntitiesFromString_t G_SpawnEntitiesFromString = G_SpawnEntitiesFromString_t(0x4D8840);
G_Spawn_t G_Spawn = G_Spawn_t(0x4226F0);
G_FreeEntity_t G_FreeEntity = G_FreeEntity_t(0x44C9D0);
G_SpawnItem_t G_SpawnItem = G_SpawnItem_t(0x403770);
G_GetItemClassname_t G_GetItemClassname = G_GetItemClassname_t(0x492630);
G_PrintEntities_t G_PrintEntities = G_PrintEntities_t(0x4E6A50);
G_GetEntityTypeName_t G_GetEntityTypeName = G_GetEntityTypeName_t(0x4EB810);
gentity_t* g_entities = reinterpret_cast<gentity_t*>(0x18835D8);
XModel* G_GetModel(const int index)
{
assert(index > 0);
assert(index < MAX_MODELS);
return cached_models[index];
}
}

47
src/Game/Game.hpp Normal file
View File

@ -0,0 +1,47 @@
#pragma once
#include "BothGames.hpp"
#include "Client.hpp"
#include "Database.hpp"
#include "FileSystem.hpp"
#include "Functions.hpp"
#include "Dvars.hpp"
#include "Script.hpp"
#include "Server.hpp"
#include "System.hpp"
namespace Game
{
typedef void(*G_LogPrintf_t)(const char* fmt, ...);
extern G_LogPrintf_t G_LogPrintf;
typedef unsigned int(*G_GetWeaponIndexForName_t)(const char*);
extern G_GetWeaponIndexForName_t G_GetWeaponIndexForName;
typedef void(*G_SpawnEntitiesFromString_t)();
extern G_SpawnEntitiesFromString_t G_SpawnEntitiesFromString;
typedef gentity_s* (*G_Spawn_t)();
extern G_Spawn_t G_Spawn;
typedef void(*G_FreeEntity_t)(gentity_s* ed);
extern G_FreeEntity_t G_FreeEntity;
typedef void(*G_SpawnItem_t)(gentity_s* ent, int item);
extern G_SpawnItem_t G_SpawnItem;
typedef void(*G_GetItemClassname_t)(int item, gentity_s* ent);
extern G_GetItemClassname_t G_GetItemClassname;
typedef void(*G_PrintEntities_t)();
extern G_PrintEntities_t G_PrintEntities;
typedef const char*(*G_GetEntityTypeName_t)(const gentity_s* ent);
extern G_GetEntityTypeName_t G_GetEntityTypeName;
constexpr std::size_t MAX_GENTITIES = 2048;
constexpr std::size_t ENTITYNUM_NONE = MAX_GENTITIES - 1;
extern gentity_t* g_entities;
extern XModel* G_GetModel(int index);
}

125
src/Game/Script.cpp Normal file
View File

@ -0,0 +1,125 @@
#include <STDInclude.hpp>
namespace Game
{
AddRefToObject_t AddRefToObject = AddRefToObject_t(0x61C360);
RemoveRefToObject_t RemoveRefToObject = RemoveRefToObject_t(0x437190);
AllocObject_t AllocObject = AllocObject_t(0x434320);
AddRefToValue_t AddRefToValue = AddRefToValue_t(0x482740);
AllocThread_t AllocThread = AllocThread_t(0x4F78C0);
VM_Execute_0_t VM_Execute_0 = VM_Execute_0_t(0x6222A0);
Scr_GetGameTypeNameForScript_t Scr_GetGameTypeNameForScript = Scr_GetGameTypeNameForScript_t(0x462460);
Scr_IsValidGameType_t Scr_IsValidGameType = Scr_IsValidGameType_t(0x4F1B60);
Scr_LoadGameType_t Scr_LoadGameType = Scr_LoadGameType_t(0x4D9520);
Scr_StartupGameType_t Scr_StartupGameType = Scr_StartupGameType_t(0x438720);
Scr_LoadScript_t Scr_LoadScript = Scr_LoadScript_t(0x45D940);
Scr_GetFunctionHandle_t Scr_GetFunctionHandle = Scr_GetFunctionHandle_t(0x4234F0);
Scr_GetString_t Scr_GetString = Scr_GetString_t(0x425900);
Scr_GetConstString_t Scr_GetConstString = Scr_GetConstString_t(0x494830);
Scr_GetDebugString_t Scr_GetDebugString = Scr_GetDebugString_t(0x4EBF50);
Scr_GetFloat_t Scr_GetFloat = Scr_GetFloat_t(0x443140);
Scr_GetInt_t Scr_GetInt = Scr_GetInt_t(0x4F31D0);
Scr_GetObject_t Scr_GetObject = Scr_GetObject_t(0x462100);
Scr_GetTypeName_t Scr_GetTypeName = Scr_GetTypeName_t(0x4EFF10);
Scr_GetNumParam_t Scr_GetNumParam = Scr_GetNumParam_t(0x4B0E90);
Scr_GetEntityId_t Scr_GetEntityId = Scr_GetEntityId_t(0x4165E0);
Scr_ExecThread_t Scr_ExecThread = Scr_ExecThread_t(0x4AD0B0);
Scr_FreeThread_t Scr_FreeThread = Scr_FreeThread_t(0x4BD320);
Scr_AddEntity_t Scr_AddEntity = Scr_AddEntity_t(0x4BFB40);
Scr_AddString_t Scr_AddString = Scr_AddString_t(0x412310);
Scr_AddConstString_t Scr_AddConstString = Scr_AddConstString_t(0x488860);
Scr_AddIString_t Scr_AddIString = Scr_AddIString_t(0x455F20);
Scr_AddInt_t Scr_AddInt = Scr_AddInt_t(0x41D7D0);
Scr_AddFloat_t Scr_AddFloat = Scr_AddFloat_t(0x61E860);
Scr_AddObject_t Scr_AddObject = Scr_AddObject_t(0x430F40);
Scr_Notify_t Scr_Notify = Scr_Notify_t(0x4A4750);
Scr_NotifyLevel_t Scr_NotifyLevel = Scr_NotifyLevel_t(0x4D9C30);
Scr_Error_t Scr_Error = Scr_Error_t(0x61E8B0);
Scr_ObjectError_t Scr_ObjectError = Scr_ObjectError_t(0x42EF40);
Scr_ParamError_t Scr_ParamError = Scr_ParamError_t(0x4FBC70);
Scr_GetType_t Scr_GetType = Scr_GetType_t(0x422900);
Scr_GetPointerType_t Scr_GetPointerType = Scr_GetPointerType_t(0x4828E0);
Scr_ClearOutParams_t Scr_ClearOutParams = Scr_ClearOutParams_t(0x4386E0);
Scr_GetObjectField_t Scr_GetObjectField = Scr_GetObjectField_t(0x4FF3D0);
Scr_SetObjectField_t Scr_SetObjectField = Scr_SetObjectField_t(0x4F20F0);
Scr_GetEntityField_t Scr_GetEntityField = Scr_GetEntityField_t(0x4E8390);
Scr_SetClientField_t Scr_SetClientField = Scr_SetClientField_t(0x4A6DF0);
Scr_AddClassField_t Scr_AddClassField = Scr_AddClassField_t(0x4C0E70);
GetEntity_t GetEntity = GetEntity_t(0x4BC270);
GetPlayerEntity_t GetPlayerEntity = GetPlayerEntity_t(0x49C4A0);
Scr_RegisterFunction_t Scr_RegisterFunction = Scr_RegisterFunction_t(0x492D50);
Scr_ShutdownAllocNode_t Scr_ShutdownAllocNode = Scr_ShutdownAllocNode_t(0x441650);
Scr_IsSystemActive_t Scr_IsSystemActive = Scr_IsSystemActive_t(0x4B24E0);
scr_const_t* scr_const = reinterpret_cast<scr_const_t*>(0x1AA2E00);
scrVmPub_t* scrVmPub = reinterpret_cast<scrVmPub_t*>(0x2040CF0);
scrVarPub_t* scrVarPub = reinterpret_cast<scrVarPub_t*>(0x201A408);
void IncInParam()
{
Scr_ClearOutParams();
if (scrVmPub->top == scrVmPub->maxStack)
{
Sys_Error("Internal script stack overflow");
}
scrVmPub->top++;
scrVmPub->inparamcount++;
}
void Scr_AddBool(int value)
{
assert(value == 0 || value == 1);
IncInParam();
scrVmPub->top->type = VAR_INTEGER;
scrVmPub->top->u.intValue = value;
}
void RuntimeErrorInternal(int channel, const char* codePos, unsigned int index, const char* msg)
{
static DWORD RuntimeErrorInternal_t = 0x61ABE0;
__asm
{
pushad
mov eax, msg
mov edi, channel
push index
push codePos
call RuntimeErrorInternal_t
add esp, 0x8
popad
}
}
void Scr_NotifyId(unsigned int id, unsigned __int16 stringValue, unsigned int paramcount)
{
static DWORD Scr_NotifyId_t = 0x61E670;
__asm
{
pushad
mov eax, paramcount
push stringValue
push id
call Scr_NotifyId_t
add esp, 8h
popad
}
}
}

164
src/Game/Script.hpp Normal file
View File

@ -0,0 +1,164 @@
#pragma once
namespace Game
{
typedef void(*AddRefToObject_t)(unsigned int id);
extern AddRefToObject_t AddRefToObject;
typedef void(*RemoveRefToObject_t)(unsigned int id);
extern RemoveRefToObject_t RemoveRefToObject;
typedef unsigned int(*AllocObject_t)();
extern AllocObject_t AllocObject;
typedef void(*AddRefToValue_t)(int type, VariableUnion u);
extern AddRefToValue_t AddRefToValue;
typedef unsigned int(*AllocThread_t)(unsigned int self);
extern AllocThread_t AllocThread;
typedef unsigned int(*VM_Execute_0_t)(unsigned int localId, const char* pos, unsigned int paramcount);
extern VM_Execute_0_t VM_Execute_0;
typedef void(*Scr_AddEntity_t)(const gentity_s* ent);
extern Scr_AddEntity_t Scr_AddEntity;
typedef void(*Scr_AddString_t)(const char* value);
extern Scr_AddString_t Scr_AddString;
typedef void(*Scr_AddConstString_t)(unsigned int value);
extern Scr_AddConstString_t Scr_AddConstString;
typedef void(*Scr_AddIString_t)(const char* value);
extern Scr_AddIString_t Scr_AddIString;
typedef void(*Scr_AddInt_t)(int value);
extern Scr_AddInt_t Scr_AddInt;
typedef void(*Scr_AddFloat_t)(float value);
extern Scr_AddFloat_t Scr_AddFloat;
typedef void(*Scr_AddObject_t)(unsigned int id);
extern Scr_AddObject_t Scr_AddObject;
typedef void(*Scr_ShutdownAllocNode_t)();
extern Scr_ShutdownAllocNode_t Scr_ShutdownAllocNode;
typedef char* (*Scr_GetGameTypeNameForScript_t)(const char* pszGameTypeScript);
extern Scr_GetGameTypeNameForScript_t Scr_GetGameTypeNameForScript;
typedef int(*Scr_IsValidGameType_t)(const char* pszGameType);
extern Scr_IsValidGameType_t Scr_IsValidGameType;
typedef void(*Scr_LoadGameType_t)();
extern Scr_LoadGameType_t Scr_LoadGameType;
typedef void(*Scr_StartupGameType_t)();
extern Scr_StartupGameType_t Scr_StartupGameType;
typedef int(*Scr_LoadScript_t)(const char*);
extern Scr_LoadScript_t Scr_LoadScript;
typedef const char*(*Scr_GetString_t)(unsigned int index);
extern Scr_GetString_t Scr_GetString;
typedef scr_string_t(*Scr_GetConstString_t)(unsigned int index);
extern Scr_GetConstString_t Scr_GetConstString;
typedef const char* (*Scr_GetDebugString_t)(unsigned int index);
extern Scr_GetDebugString_t Scr_GetDebugString;
typedef float(*Scr_GetFloat_t)(unsigned int index);
extern Scr_GetFloat_t Scr_GetFloat;
typedef int(*Scr_GetInt_t)(unsigned int index);
extern Scr_GetInt_t Scr_GetInt;
typedef unsigned int(*Scr_GetObject_t)(unsigned int index);
extern Scr_GetObject_t Scr_GetObject;
typedef const char* (*Scr_GetTypeName_t)(unsigned int index);
extern Scr_GetTypeName_t Scr_GetTypeName;
typedef unsigned int(*Scr_GetNumParam_t)();
extern Scr_GetNumParam_t Scr_GetNumParam;
typedef unsigned int(*Scr_GetEntityId_t)(int entnum, unsigned int classnum);
extern Scr_GetEntityId_t Scr_GetEntityId;
typedef int(*Scr_GetFunctionHandle_t)(const char* filename, const char* name);
extern Scr_GetFunctionHandle_t Scr_GetFunctionHandle;
typedef int(*Scr_ExecThread_t)(int handle, unsigned int paramcount);
extern Scr_ExecThread_t Scr_ExecThread;
typedef int(*Scr_ExecEntThread_t)(gentity_s* ent, int handle, unsigned int paramcount);
extern Scr_ExecEntThread_t Scr_ExecEntThread;
typedef void(*Scr_FreeThread_t)(unsigned __int16 handle);
extern Scr_FreeThread_t Scr_FreeThread;
typedef void(*Scr_Notify_t)(gentity_t* ent, unsigned __int16 stringValue, unsigned int paramcount);
extern Scr_Notify_t Scr_Notify;
typedef void(*Scr_NotifyLevel_t)(unsigned __int16 stringValue, unsigned int paramcount);
extern Scr_NotifyLevel_t Scr_NotifyLevel;
typedef void(*Scr_ClearOutParams_t)();
extern Scr_ClearOutParams_t Scr_ClearOutParams;
typedef void(*Scr_RegisterFunction_t)(int func, const char* name);
extern Scr_RegisterFunction_t Scr_RegisterFunction;
typedef bool(*Scr_IsSystemActive_t)();
extern Scr_IsSystemActive_t Scr_IsSystemActive;
typedef int(*Scr_GetType_t)(unsigned int index);
extern Scr_GetType_t Scr_GetType;
typedef int(*Scr_GetPointerType_t)(unsigned int index);
extern Scr_GetPointerType_t Scr_GetPointerType;
typedef void(*Scr_Error_t)(const char*);
extern Scr_Error_t Scr_Error;
typedef void(*Scr_ObjectError_t)(const char*);
extern Scr_ObjectError_t Scr_ObjectError;
typedef void(*Scr_ParamError_t)(unsigned int paramIndex, const char*);
extern Scr_ParamError_t Scr_ParamError;
typedef void(*Scr_GetObjectField_t)(unsigned int classnum, int entnum, int offset);
extern Scr_GetObjectField_t Scr_GetObjectField;
typedef int(*Scr_SetObjectField_t)(unsigned int classnum, int entnum, int offset);
extern Scr_SetObjectField_t Scr_SetObjectField;
typedef void(*Scr_SetClientField_t)(gclient_s* client, int offset);
extern Scr_SetClientField_t Scr_SetClientField;
typedef void(*Scr_GetEntityField_t)(int entnum, int offset);
extern Scr_GetEntityField_t Scr_GetEntityField;
typedef void(*Scr_AddClassField_t)(unsigned int classnum, const char* name, unsigned int offset);
extern Scr_AddClassField_t Scr_AddClassField;
typedef gentity_s*(*GetPlayerEntity_t)(scr_entref_t entref);
extern GetPlayerEntity_t GetPlayerEntity;
typedef gentity_s*(*GetEntity_t)(scr_entref_t entref);
extern GetEntity_t GetEntity;
extern void IncInParam();
extern void Scr_AddBool(int value);
extern void RuntimeErrorInternal(int channel, const char* codePos, unsigned int index, const char* msg);
extern void Scr_NotifyId(unsigned int id, unsigned __int16 stringValue, unsigned int paramcount);
extern scr_const_t* scr_const;
extern scrVmPub_t* scrVmPub;
extern scrVarPub_t* scrVarPub;
}

67
src/Game/Server.cpp Normal file
View File

@ -0,0 +1,67 @@
#include <STDInclude.hpp>
namespace Game
{
SV_AddTestClient_t SV_AddTestClient = SV_AddTestClient_t(0x48AD30);
SV_IsTestClient_t SV_IsTestClient = SV_IsTestClient_t(0x4D6E40);
SV_GameClientNum_Score_t SV_GameClientNum_Score = SV_GameClientNum_Score_t(0x469AC0);
SV_GameSendServerCommand_t SV_GameSendServerCommand = SV_GameSendServerCommand_t(0x4BC3A0);
SV_Cmd_TokenizeString_t SV_Cmd_TokenizeString = SV_Cmd_TokenizeString_t(0x4B5780);
SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString = SV_Cmd_EndTokenizedString_t(0x464750);
SV_Cmd_ArgvBuffer_t SV_Cmd_ArgvBuffer = SV_Cmd_ArgvBuffer_t(0x40BB60);
SV_DirectConnect_t SV_DirectConnect = SV_DirectConnect_t(0x460480);
SV_SetConfigstring_t SV_SetConfigstring = SV_SetConfigstring_t(0x4982E0);
SV_Loaded_t SV_Loaded = SV_Loaded_t(0x4EE3E0);
SV_ClientThink_t SV_ClientThink = SV_ClientThink_t(0x44ADD0);
SV_DropClient_t SV_DropClient = SV_DropClient_t(0x4D1600);
SV_GetPlayerByName_t SV_GetPlayerByName = SV_GetPlayerByName_t(0x6242B0);
SV_GetPlayerByNum_t SV_GetPlayerByNum = SV_GetPlayerByNum_t(0x624390);
SV_FindClientByAddress_t SV_FindClientByAddress = SV_FindClientByAddress_t(0x44F450);
int* svs_time = reinterpret_cast<int*>(0x31D9384);
int* sv_serverId_value = reinterpret_cast<int*>(0x2089DC0);
int* svs_clientCount = reinterpret_cast<int*>(0x31D938C);
client_t* svs_clients = reinterpret_cast<client_t*>(0x31D9390);
volatile long* sv_thread_owns_game = reinterpret_cast<volatile long*>(0x2089DB8);
int SV_GetServerThreadOwnsGame()
{
return *sv_thread_owns_game;
}
void SV_GameDropClient(int clientNum, const char* reason)
{
assert((*sv_maxclients)->current.integer >= 1 && (*sv_maxclients)->current.integer <= 18);
if (clientNum >= 0 && clientNum < (*sv_maxclients)->current.integer)
{
SV_DropClient(&svs_clients[clientNum], reason, true);
}
}
void SV_DropAllBots()
{
for (auto i = 0; i < *svs_clientCount; ++i)
{
if (svs_clients[i].header.state != CS_FREE
&& svs_clients[i].header.netchan.remoteAddress.type == NA_BOT)
{
SV_GameDropClient(i, "GAME_GET_TO_COVER");
}
}
}
void SV_BotUserMove(client_t* client)
{
static DWORD SV_BotUserMove_t = 0x626E50;
__asm
{
pushad
mov edi, client
call SV_BotUserMove_t
popad
}
}
}

61
src/Game/Server.hpp Normal file
View File

@ -0,0 +1,61 @@
#pragma once
namespace Game
{
typedef gentity_t*(*SV_AddTestClient_t)();
extern SV_AddTestClient_t SV_AddTestClient;
typedef int(*SV_IsTestClient_t)(int clientNum);
extern SV_IsTestClient_t SV_IsTestClient;
typedef int(*SV_GameClientNum_Score_t)(int clientID);
extern SV_GameClientNum_Score_t SV_GameClientNum_Score;
typedef void(*SV_GameSendServerCommand_t)(int clientNum, svscmd_type type, const char* text);
extern SV_GameSendServerCommand_t SV_GameSendServerCommand;
typedef void(*SV_Cmd_TokenizeString_t)(const char* string);
extern SV_Cmd_TokenizeString_t SV_Cmd_TokenizeString;
typedef void(*SV_Cmd_EndTokenizedString_t)();
extern SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString;
typedef void(*SV_Cmd_ArgvBuffer_t)(int arg, char* buf, int size);
extern SV_Cmd_ArgvBuffer_t SV_Cmd_ArgvBuffer;
typedef void(*SV_SetConfigstring_t)(int index, const char* string);
extern SV_SetConfigstring_t SV_SetConfigstring;
typedef void(*SV_DirectConnect_t)(netadr_t adr);
extern SV_DirectConnect_t SV_DirectConnect;
typedef bool(*SV_Loaded_t)();
extern SV_Loaded_t SV_Loaded;
typedef void(*SV_ClientThink_t)(client_t* cl, usercmd_s* cmd);
extern SV_ClientThink_t SV_ClientThink;
typedef void(*SV_DropClient_t)(client_t* drop, const char* reason, bool tellThem);
extern SV_DropClient_t SV_DropClient;
typedef client_t* (*SV_GetPlayerByName_t)();
extern SV_GetPlayerByName_t SV_GetPlayerByName;
typedef client_t* (*SV_GetPlayerByNum_t)();
extern SV_GetPlayerByNum_t SV_GetPlayerByNum;
typedef client_t* (*SV_FindClientByAddress_t)(netadr_t from, int qport, int remoteClientIndex);
extern SV_FindClientByAddress_t SV_FindClientByAddress;
extern int* svs_time;
extern int* sv_serverId_value;
extern int* svs_clientCount;
extern client_t* svs_clients;
extern volatile long* sv_thread_owns_game;
extern int SV_GetServerThreadOwnsGame();
extern void SV_GameDropClient(int clientNum, const char* reason);
extern void SV_DropAllBots();
extern void SV_BotUserMove(client_t* client);
}

38
src/Game/System.cpp Normal file
View File

@ -0,0 +1,38 @@
#include <STDInclude.hpp>
namespace Game
{
Sys_FreeFileList_t Sys_FreeFileList = Sys_FreeFileList_t(0x4D8580);
Sys_IsDatabaseReady_t Sys_IsDatabaseReady = Sys_IsDatabaseReady_t(0x4CA4A0);
Sys_IsDatabaseReady2_t Sys_IsDatabaseReady2 = Sys_IsDatabaseReady2_t(0x441280);
Sys_IsMainThread_t Sys_IsMainThread = Sys_IsMainThread_t(0x4C37D0);
Sys_IsRenderThread_t Sys_IsRenderThread = Sys_IsRenderThread_t(0x4B20E0);
Sys_IsServerThread_t Sys_IsServerThread = Sys_IsServerThread_t(0x4B0270);
Sys_IsDatabaseThread_t Sys_IsDatabaseThread = Sys_IsDatabaseThread_t(0x4C6020);
Sys_ListFiles_t Sys_ListFiles = Sys_ListFiles_t(0x45A660);
Sys_Milliseconds_t Sys_Milliseconds = Sys_Milliseconds_t(0x42A660);
Sys_Error_t Sys_Error = Sys_Error_t(0x43D570);
Sys_LockWrite_t Sys_LockWrite = Sys_LockWrite_t(0x435880);
Sys_TempPriorityAtLeastNormalBegin_t Sys_TempPriorityAtLeastNormalBegin = Sys_TempPriorityAtLeastNormalBegin_t(0x478680);
Sys_TempPriorityEnd_t Sys_TempPriorityEnd = Sys_TempPriorityEnd_t(0x4DCF00);
Sys_EnterCriticalSection_t Sys_EnterCriticalSection = Sys_EnterCriticalSection_t(0x4FC200);
Sys_LeaveCriticalSection_t Sys_LeaveCriticalSection = Sys_LeaveCriticalSection_t(0x41B8C0);
Sys_DefaultInstallPath_t Sys_DefaultInstallPath = Sys_DefaultInstallPath_t(0x4326E0);
Sys_SendPacket_t Sys_SendPacket = Sys_SendPacket_t(0x60FDC0);
Sys_ShowConsole_t Sys_ShowConsole = Sys_ShowConsole_t(0x4305E0);
Sys_SuspendOtherThreads_t Sys_SuspendOtherThreads = Sys_SuspendOtherThreads_t(0x45A190);
char(*sys_exitCmdLine)[1024] = reinterpret_cast<char(*)[1024]>(0x649FB68);
void Sys_LockRead(FastCriticalSection* critSect)
{
InterlockedIncrement(&critSect->readCount);
while (critSect->writeCount) std::this_thread::sleep_for(1ms);
}
void Sys_UnlockRead(FastCriticalSection* critSect)
{
assert(critSect->readCount > 0);
InterlockedDecrement(&critSect->readCount);
}
}

67
src/Game/System.hpp Normal file
View File

@ -0,0 +1,67 @@
#pragma once
namespace Game
{
typedef void(*Sys_Error_t)(const char* error, ...);
extern Sys_Error_t Sys_Error;
typedef void(*Sys_FreeFileList_t)(const char** list);
extern Sys_FreeFileList_t Sys_FreeFileList;
typedef int(*Sys_IsDatabaseReady_t)();
extern Sys_IsDatabaseReady_t Sys_IsDatabaseReady;
typedef int(*Sys_IsDatabaseReady2_t)();
extern Sys_IsDatabaseReady2_t Sys_IsDatabaseReady2;
typedef bool(*Sys_IsMainThread_t)();
extern Sys_IsMainThread_t Sys_IsMainThread;
typedef bool(*Sys_IsRenderThread_t)();
extern Sys_IsRenderThread_t Sys_IsRenderThread;
typedef bool(*Sys_IsServerThread_t)();
extern Sys_IsServerThread_t Sys_IsServerThread;
typedef bool(*Sys_IsDatabaseThread_t)();
extern Sys_IsDatabaseThread_t Sys_IsDatabaseThread;
typedef const char**(*Sys_ListFiles_t)(const char* directory, const char* extension, const char* filter, int* numfiles, int wantsubs);
extern Sys_ListFiles_t Sys_ListFiles;
typedef int(*Sys_Milliseconds_t)();
extern Sys_Milliseconds_t Sys_Milliseconds;
typedef void(*Sys_LockWrite_t)(FastCriticalSection* critSect);
extern Sys_LockWrite_t Sys_LockWrite;
typedef void(*Sys_TempPriorityAtLeastNormalBegin_t)(TempPriority*);
extern Sys_TempPriorityAtLeastNormalBegin_t Sys_TempPriorityAtLeastNormalBegin;
typedef void(*Sys_TempPriorityEnd_t)(TempPriority*);
extern Sys_TempPriorityEnd_t Sys_TempPriorityEnd;
typedef void(*Sys_EnterCriticalSection_t)(CriticalSection critSect);
extern Sys_EnterCriticalSection_t Sys_EnterCriticalSection;
typedef void(*Sys_LeaveCriticalSection_t)(CriticalSection critSect);
extern Sys_LeaveCriticalSection_t Sys_LeaveCriticalSection;
typedef char*(*Sys_DefaultInstallPath_t)();
extern Sys_DefaultInstallPath_t Sys_DefaultInstallPath;
typedef bool(*Sys_SendPacket_t)(netsrc_t sock, size_t len, const char* format, netadr_t adr);
extern Sys_SendPacket_t Sys_SendPacket;
typedef void(*Sys_ShowConsole_t)();
extern Sys_ShowConsole_t Sys_ShowConsole;
typedef void(*Sys_SuspendOtherThreads_t)();
extern Sys_SuspendOtherThreads_t Sys_SuspendOtherThreads;
extern char(*sys_exitCmdLine)[1024];
extern void Sys_LockRead(FastCriticalSection* critSect);
extern void Sys_UnlockRead(FastCriticalSection* critSect);
}

View File

@ -147,8 +147,8 @@ using namespace std::literals;
#include "Steam/Steam.hpp" // Some definitions are used in functions and structs
#include "Game/Structs.hpp"
#include "Game/Dvars.hpp"
#include "Game/Functions.hpp"
#include "Game/Game.hpp"
#include <Game/Scripting/Function.hpp>
#include <Game/Scripting/StackIsolation.hpp>