Add branding component

This commit is contained in:
Diavolo 2022-04-15 14:50:22 +02:00
parent 0e5af0f514
commit 8a770985d6
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
10 changed files with 198 additions and 73 deletions

View File

@ -69,7 +69,6 @@ namespace Components
Loader::Register(new Renderer()); Loader::Register(new Renderer());
Loader::Register(new UIFeeder()); Loader::Register(new UIFeeder());
Loader::Register(new UIScript()); Loader::Register(new UIScript());
Loader::Register(new AntiCheat());
Loader::Register(new Changelog()); Loader::Register(new Changelog());
Loader::Register(new Dedicated()); Loader::Register(new Dedicated());
Loader::Register(new Discovery()); Loader::Register(new Discovery());
@ -105,6 +104,7 @@ namespace Components
Loader::Register(new Elevators()); Loader::Register(new Elevators());
Loader::Register(new ClientCommand()); Loader::Register(new ClientCommand());
Loader::Register(new ScriptExtension()); Loader::Register(new ScriptExtension());
Loader::Register(new Branding());
Loader::Pregame = false; Loader::Pregame = false;
} }

View File

@ -99,7 +99,6 @@ namespace Components
#include "Modules/RawFiles.hpp" #include "Modules/RawFiles.hpp"
#include "Modules/Renderer.hpp" #include "Modules/Renderer.hpp"
#include "Modules/UIFeeder.hpp" #include "Modules/UIFeeder.hpp"
#include "Modules/AntiCheat.hpp"
#include "Modules/Changelog.hpp" #include "Modules/Changelog.hpp"
#include "Modules/Dedicated.hpp" #include "Modules/Dedicated.hpp"
#include "Modules/Discovery.hpp" #include "Modules/Discovery.hpp"
@ -134,6 +133,6 @@ namespace Components
#include "Modules/Movement.hpp" #include "Modules/Movement.hpp"
#include "Modules/Elevators.hpp" #include "Modules/Elevators.hpp"
#include "Modules/ClientCommand.hpp" #include "Modules/ClientCommand.hpp"
#include "Modules/Gamepad.hpp" #include "Modules/Gamepad.hpp"
#include "Modules/ScriptExtension.hpp" #include "Modules/ScriptExtension.hpp"
#include "Modules/Branding.hpp"

View File

@ -0,0 +1,118 @@
#include <STDInclude.hpp>
namespace Components
{
Dvar::Var Branding::CGDrawVersion;
Dvar::Var Branding::CGDrawVersionX;
Dvar::Var Branding::CGDrawVersionY;
Game::dvar_t** Branding::Version = reinterpret_cast<Game::dvar_t**>(0x1AD7930);
void Branding::CG_DrawVersion()
{
// Default values
constexpr auto fontScale = 0.25f;
constexpr auto maxChars = std::numeric_limits<int>::max();
// Default colours
constexpr Game::vec4_t shadowColor = {0.0f, 0.0f, 0.0f, 0.7f};
constexpr Game::vec4_t color = {0.4f, 0.7f, 1.0f, 0.7f};
auto* const placement = Game::ScrPlace_GetUnsafeFullPlacement();
auto* const font = Game::UI_GetFontHandle(placement, 0, 0.5f);
const auto width = Game::UI_TextWidth((*Version)->current.string, 0, font, fontScale);
const auto height = Game::UI_TextHeight(font, fontScale);
Game::UI_DrawText(placement, (*Version)->current.string, maxChars, font, 1.0f - (CGDrawVersionX.get<float>() + width),
1.0f - (CGDrawVersionY.get<float>() + height), 3, 3, fontScale, shadowColor, 0);
Game::UI_DrawText(placement, (*Version)->current.string, maxChars, font, (0.0f - width) - CGDrawVersionX.get<float>(),
(0.0f - height) - CGDrawVersionY.get<float>(), 3, 3, fontScale, color, 0);
}
void Branding::CG_DrawVersion_Hk(int localClientNum)
{
Utils::Hook::Call<void(int)>(0x4EFF80)(localClientNum);
if (Branding::CGDrawVersion.get<bool>())
{
Branding::CG_DrawVersion();
}
}
const char* Branding::GetBuildNumber()
{
static char buf[128]; // Length the game uses
const auto* data = "latest " __DATE__ " " __TIME__;
sprintf_s(buf, sizeof(buf), "%s %s", SHORTVERSION, data);
return buf;
}
// Use IW4x Branding
void Branding::Dvar_SetVersionString(const Game::dvar_t* dvar, const char* /*value*/)
{
#ifdef _DEBUG
const auto* buildType = "IW4x_DEV MP";
#else
const auto* buildType = "IW4x MP";
#endif
// IW4x is technically a beta
const auto* result = Utils::String::VA("%s %s build %s %s",
buildType, "(Beta)", Branding::GetBuildNumber(), reinterpret_cast<const char*>(0x7170A0));
Utils::Hook::Call<void(const Game::dvar_t*, const char*)>(0x4A9580)(dvar, result);
}
Game::dvar_t* Branding::Dvar_RegisterUIBuildLocation(const char* dvarName,
float /*x*/, float /*y*/, float min, float max, int /*flags*/, const char* description)
{
#ifdef _DEBUG
constexpr auto flag = Game::dvar_flag::DVAR_NONE;
#else
constexpr auto flag = Game::dvar_flag::DVAR_READONLY;
#endif
return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, flag, description);
}
void Branding::RegisterBrandingDvars()
{
#ifdef _DEBUG
constexpr auto value = true;
#else
constexpr auto value = false;
#endif
Branding::CGDrawVersion = Dvar::Register<bool>("cg_drawVersion", value,
Game::dvar_flag::DVAR_NONE, "Draw the game version");
Branding::CGDrawVersionX = Dvar::Register<float>("cg_drawVersionX", 50.0f,
0.0f, 512.0f, Game::dvar_flag::DVAR_NONE, "X offset for the version string");
Branding::CGDrawVersionY = Dvar::Register<float>("cg_drawVersionY", 18.0f,
0.0f, 512.0f, Game::dvar_flag::DVAR_NONE, "Y offset for the version string");
}
Branding::Branding()
{
Dvar::OnInit(Branding::RegisterBrandingDvars);
// UI version string
Utils::Hook::Set<const char*>(0x43F73B, "IW4x: " VERSION);
// Short version dvar
Utils::Hook::Set<const char*>(0x60BD91, SHORTVERSION);
// Console version string
Utils::Hook::Set<const char*>(0x4B12BB, "IW4x " VERSION " (built " __DATE__ " " __TIME__ ")");
// Version string color
static Game::vec4_t buildLocColor = {1.0f, 1.0f, 1.0f, 0.8f};
Utils::Hook::Set<float*>(0x43F710, buildLocColor);
// Shift ui version string to the left (ui_buildlocation)
Utils::Hook(0x6310A0, Branding::Dvar_RegisterUIBuildLocation, HOOK_CALL).install()->quick(); // Dvar_RegisterVec2
Utils::Hook(0x60BD81, Branding::Dvar_SetVersionString, HOOK_CALL).install()->quick();
// Hook CG_DrawFullScreenDebugOverlays so we may render the version when it's appropriate
Utils::Hook(0x5AC975, Branding::CG_DrawVersion_Hk, HOOK_CALL).install()->quick();
}
}

View File

@ -0,0 +1,26 @@
#pragma once
namespace Components
{
class Branding : public Component
{
public:
Branding();
private:
static Dvar::Var CGDrawVersion;
static Dvar::Var CGDrawVersionX;
static Dvar::Var CGDrawVersionY;
static Game::dvar_t** Version;
static void CG_DrawVersion();
static void CG_DrawVersion_Hk(int localClientNum);
static const char* GetBuildNumber();
static void Dvar_SetVersionString(const Game::dvar_t* dvar, const char* value);
static Game::dvar_t* Dvar_RegisterUIBuildLocation(const char* dvarName, float x, float y, float min, float max, int flags, const char* description);
static void RegisterBrandingDvars();
};
}

View File

@ -348,12 +348,6 @@ namespace Components
} }
} }
Game::dvar_t* QuickPatch::Dvar_RegisterUIBuildLocation(const char* dvarName,
float /*x*/, float /*y*/, float min, float max, int /*flags*/, const char* description)
{
return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, Game::DVAR_READONLY, description);
}
QuickPatch::QuickPatch() QuickPatch::QuickPatch()
{ {
// quitHard // quitHard
@ -426,22 +420,6 @@ namespace Components
// fs_basegame // fs_basegame
Utils::Hook::Set<const char*>(0x6431D1, BASEGAME); Utils::Hook::Set<const char*>(0x6431D1, BASEGAME);
// UI version string
Utils::Hook::Set<const char*>(0x43F73B, "IW4x: " VERSION);
// console version string
Utils::Hook::Set<const char*>(0x4B12BB, "IW4x " VERSION " (built " __DATE__ " " __TIME__ ")");
// version string
Utils::Hook::Set<const char*>(0x60BD56, "IW4x (" VERSION ")");
// version string color
static Game::vec4_t buildLocColor = { 1.0f, 1.0f, 1.0f, 0.8f };
Utils::Hook::Set<float*>(0x43F710, buildLocColor);
// Shift ui version string to the left (ui_buildlocation)
Utils::Hook(0x6310A0, QuickPatch::Dvar_RegisterUIBuildLocation, HOOK_CALL).install()->quick();
// console title // console title
if (ZoneBuilder::IsEnabled()) if (ZoneBuilder::IsEnabled())
{ {
@ -462,9 +440,6 @@ namespace Components
// sv_hostname // sv_hostname
Utils::Hook::Set<const char*>(0x4D378B, "IW4Host"); Utils::Hook::Set<const char*>(0x4D378B, "IW4Host");
// shortversion
Utils::Hook::Set<const char*>(0x60BD91, SHORTVERSION);
// console logo // console logo
Utils::Hook::Set<const char*>(0x428A66, BASEGAME "/images/logo.bmp"); Utils::Hook::Set<const char*>(0x428A66, BASEGAME "/images/logo.bmp");

View File

@ -40,7 +40,5 @@ namespace Components
static void CL_KeyEvent_OnEscape(); static void CL_KeyEvent_OnEscape();
static void CL_KeyEvent_ConsoleEscape_Stub(); static void CL_KeyEvent_ConsoleEscape_Stub();
static Game::dvar_t* Dvar_RegisterUIBuildLocation(const char* dvarName, float x, float y, float min, float max, int flags, const char* description);
}; };
} }

View File

@ -88,7 +88,7 @@ namespace Components
} }
} }
void Window::DrawCursorStub(void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Game::Material *material) void Window::DrawCursorStub(Game::ScreenPlacement* scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float* color, Game::Material* material)
{ {
if (Window::NativeCursor.get<bool>()) if (Window::NativeCursor.get<bool>())
{ {

View File

@ -32,7 +32,7 @@ namespace Components
static BOOL WINAPI MessageHandler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); static BOOL WINAPI MessageHandler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
static int WINAPI ShowCursorHook(BOOL show); static int WINAPI ShowCursorHook(BOOL show);
static void DrawCursorStub(void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Game::Material *material); static void DrawCursorStub(Game::ScreenPlacement* scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float* color, Game::Material* material);
static void StyleHookStub(); static void StyleHookStub();
static HWND WINAPI CreateMainWindow(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); static HWND WINAPI CreateMainWindow(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);

View File

@ -378,6 +378,7 @@ namespace Game
UI_DrawHandlePic_t UI_DrawHandlePic = UI_DrawHandlePic_t(0x4D0EA0); UI_DrawHandlePic_t UI_DrawHandlePic = UI_DrawHandlePic_t(0x4D0EA0);
ScrPlace_GetActivePlacement_t ScrPlace_GetActivePlacement = ScrPlace_GetActivePlacement_t(0x4F8940); ScrPlace_GetActivePlacement_t ScrPlace_GetActivePlacement = ScrPlace_GetActivePlacement_t(0x4F8940);
UI_TextWidth_t UI_TextWidth = UI_TextWidth_t(0x6315C0); UI_TextWidth_t UI_TextWidth = UI_TextWidth_t(0x6315C0);
UI_TextHeight_t UI_TextHeight = UI_TextHeight_t(0x4C8630);
UI_DrawText_t UI_DrawText = UI_DrawText_t(0x49C0D0); UI_DrawText_t UI_DrawText = UI_DrawText_t(0x49C0D0);
UI_GetFontHandle_t UI_GetFontHandle = UI_GetFontHandle_t(0x4AEA60); UI_GetFontHandle_t UI_GetFontHandle = UI_GetFontHandle_t(0x4AEA60);
ScrPlace_ApplyRect_t ScrPlace_ApplyRect = ScrPlace_ApplyRect_t(0x454E20); ScrPlace_ApplyRect_t ScrPlace_ApplyRect = ScrPlace_ApplyRect_t(0x454E20);
@ -432,7 +433,7 @@ namespace Game
int* svs_clientCount = reinterpret_cast<int*>(0x31D938C); int* svs_clientCount = reinterpret_cast<int*>(0x31D938C);
client_t* svs_clients = reinterpret_cast<client_t*>(0x31D9390); client_t* svs_clients = reinterpret_cast<client_t*>(0x31D9390);
UiContext *uiContext = reinterpret_cast<UiContext *>(0x62E2858); UiContext* uiContext = reinterpret_cast<UiContext*>(0x62E2858);
int* arenaCount = reinterpret_cast<int*>(0x62E6930); int* arenaCount = reinterpret_cast<int*>(0x62E6930);
mapArena_t* arenas = reinterpret_cast<mapArena_t*>(0x62E6934); mapArena_t* arenas = reinterpret_cast<mapArena_t*>(0x62E6934);
@ -460,10 +461,6 @@ namespace Game
gentity_t* g_entities = reinterpret_cast<gentity_t*>(0x18835D8); gentity_t* g_entities = reinterpret_cast<gentity_t*>(0x18835D8);
int* level_num_entities = reinterpret_cast<int*>(0x1A831B0);
int* level_time = reinterpret_cast<int*>(0x1A83554);
int* level_scriptPrintChannel = reinterpret_cast<int*>(0x1A860FC);
netadr_t* connectedHost = reinterpret_cast<netadr_t*>(0xA1E888); netadr_t* connectedHost = reinterpret_cast<netadr_t*>(0xA1E888);
SOCKET* ip_socket = reinterpret_cast<SOCKET*>(0x64A3008); SOCKET* ip_socket = reinterpret_cast<SOCKET*>(0x64A3008);
@ -534,9 +531,11 @@ namespace Game
XModel** cached_models = reinterpret_cast<XModel**>(0x1AA20C8); XModel** cached_models = reinterpret_cast<XModel**>(0x1AA20C8);
vec3_t* CorrectSolidDeltas = reinterpret_cast<vec3_t*>(0x739BB8); // Count 26
FastCriticalSection* db_hashCritSect = reinterpret_cast<FastCriticalSection*>(0x16B8A54); FastCriticalSection* db_hashCritSect = reinterpret_cast<FastCriticalSection*>(0x16B8A54);
vec3_t* CorrectSolidDeltas = reinterpret_cast<vec3_t*>(0x739BB8); // Count 26 ScreenPlacement* scrPlaceFullUnsafe = reinterpret_cast<ScreenPlacement*>(0x1084460);
void Sys_LockRead(FastCriticalSection* critSect) void Sys_LockRead(FastCriticalSection* critSect)
{ {
@ -1102,6 +1101,11 @@ namespace Game
return GraphGetValueFromFraction(graph->knotCount, graph->knots, fraction) * graph->scale; return GraphGetValueFromFraction(graph->knotCount, graph->knots, fraction) * graph->scale;
} }
ScreenPlacement* ScrPlace_GetUnsafeFullPlacement()
{
return scrPlaceFullUnsafe;
}
#pragma optimize("", off) #pragma optimize("", off)
__declspec(naked) float UI_GetScoreboardLeft(void* /*a1*/) __declspec(naked) float UI_GetScoreboardLeft(void* /*a1*/)
{ {

View File

@ -420,7 +420,7 @@ namespace Game
typedef void(__cdecl * LargeLocalInit_t)(); typedef void(__cdecl * LargeLocalInit_t)();
extern LargeLocalInit_t LargeLocalInit; extern LargeLocalInit_t LargeLocalInit;
typedef bool(__cdecl * Load_Stream_t)(bool atStreamStart, const void *ptr, unsigned int size); typedef bool(__cdecl * Load_Stream_t)(bool atStreamStart, const void* ptr, unsigned int size);
extern Load_Stream_t Load_Stream; extern Load_Stream_t Load_Stream;
typedef void(__cdecl * Load_XString_t)(bool atStreamStart); typedef void(__cdecl * Load_XString_t)(bool atStreamStart);
@ -429,64 +429,64 @@ namespace Game
typedef void(__cdecl * Load_XModelPtr_t)(bool atStreamStart); typedef void(__cdecl * Load_XModelPtr_t)(bool atStreamStart);
extern Load_XModelPtr_t Load_XModelPtr; extern Load_XModelPtr_t Load_XModelPtr;
typedef void(__cdecl * Load_XModelSurfsFixup_t)(XModelSurfs **, XModelLodInfo *); typedef void(__cdecl * Load_XModelSurfsFixup_t)(XModelSurfs**, XModelLodInfo*);
extern Load_XModelSurfsFixup_t Load_XModelSurfsFixup; extern Load_XModelSurfsFixup_t Load_XModelSurfsFixup;
typedef void(__cdecl * Load_XStringArray_t)(bool atStreamStart, int count); typedef void(__cdecl * Load_XStringArray_t)(bool atStreamStart, int count);
extern Load_XStringArray_t Load_XStringArray; extern Load_XStringArray_t Load_XStringArray;
typedef void(__cdecl * Load_XStringCustom_t)(const char **str); typedef void(__cdecl * Load_XStringCustom_t)(const char** str);
extern Load_XStringCustom_t Load_XStringCustom; extern Load_XStringCustom_t Load_XStringCustom;
typedef void(__cdecl *Load_FxEffectDefHandle_t)(bool atStreamStart); typedef void(__cdecl * Load_FxEffectDefHandle_t)(bool atStreamStart);
extern Load_FxEffectDefHandle_t Load_FxEffectDefHandle; extern Load_FxEffectDefHandle_t Load_FxEffectDefHandle;
typedef void(__cdecl *Load_FxElemDef_t)(bool atStreamStart); typedef void(__cdecl * Load_FxElemDef_t)(bool atStreamStart);
extern Load_FxElemDef_t Load_FxElemDef; extern Load_FxElemDef_t Load_FxElemDef;
typedef void(__cdecl *Load_GfxImagePtr_t)(bool atStreamStart); typedef void(__cdecl * Load_GfxImagePtr_t)(bool atStreamStart);
extern Load_GfxImagePtr_t Load_GfxImagePtr; extern Load_GfxImagePtr_t Load_GfxImagePtr;
typedef void(__cdecl *Load_GfxTextureLoad_t)(bool atStreamStart); typedef void(__cdecl * Load_GfxTextureLoad_t)(bool atStreamStart);
extern Load_GfxTextureLoad_t Load_GfxTextureLoad; extern Load_GfxTextureLoad_t Load_GfxTextureLoad;
typedef int(__cdecl *Load_Texture_t)(GfxImageLoadDef **loadDef, GfxImage *image); typedef int(__cdecl * Load_Texture_t)(GfxImageLoadDef** loadDef, GfxImage* image);
extern Load_Texture_t Load_Texture; extern Load_Texture_t Load_Texture;
typedef void(__cdecl * Load_SndAliasCustom_t)(snd_alias_list_t** var); typedef void(__cdecl * Load_SndAliasCustom_t)(snd_alias_list_t** var);
extern Load_SndAliasCustom_t Load_SndAliasCustom; extern Load_SndAliasCustom_t Load_SndAliasCustom;
typedef void(__cdecl *Load_MaterialHandle_t)(bool atStreamStart); typedef void(__cdecl * Load_MaterialHandle_t)(bool atStreamStart);
extern Load_MaterialHandle_t Load_MaterialHandle; extern Load_MaterialHandle_t Load_MaterialHandle;
typedef void(__cdecl *Load_PhysCollmapPtr_t)(bool atStreamStart); typedef void(__cdecl * Load_PhysCollmapPtr_t)(bool atStreamStart);
extern Load_PhysCollmapPtr_t Load_PhysCollmapPtr; extern Load_PhysCollmapPtr_t Load_PhysCollmapPtr;
typedef void(__cdecl *Load_PhysPresetPtr_t)(bool atStreamStart); typedef void(__cdecl * Load_PhysPresetPtr_t)(bool atStreamStart);
extern Load_PhysPresetPtr_t Load_PhysPresetPtr; extern Load_PhysPresetPtr_t Load_PhysPresetPtr;
typedef void(__cdecl *Load_TracerDefPtr_t)(bool atStreamStart); typedef void(__cdecl * Load_TracerDefPtr_t)(bool atStreamStart);
extern Load_TracerDefPtr_t Load_TracerDefPtr; extern Load_TracerDefPtr_t Load_TracerDefPtr;
typedef void(__cdecl *Load_snd_alias_list_nameArray_t)(bool atStreamStart, int count); typedef void(__cdecl * Load_snd_alias_list_nameArray_t)(bool atStreamStart, int count);
extern Load_snd_alias_list_nameArray_t Load_snd_alias_list_nameArray; extern Load_snd_alias_list_nameArray_t Load_snd_alias_list_nameArray;
typedef void(__cdecl * Menus_CloseAll_t)(UiContext *dc); typedef void(__cdecl * Menus_CloseAll_t)(UiContext* dc);
extern Menus_CloseAll_t Menus_CloseAll; extern Menus_CloseAll_t Menus_CloseAll;
typedef void(__cdecl * Menus_CloseRequest_t)(UiContext *dc, menuDef_t* menu); typedef void(__cdecl * Menus_CloseRequest_t)(UiContext *dc, menuDef_t* menu);
extern Menus_CloseRequest_t Menus_CloseRequest; extern Menus_CloseRequest_t Menus_CloseRequest;
typedef int(__cdecl * Menus_OpenByName_t)(UiContext *dc, const char *p); typedef int(__cdecl * Menus_OpenByName_t)(UiContext* dc, const char* p);
extern Menus_OpenByName_t Menus_OpenByName; extern Menus_OpenByName_t Menus_OpenByName;
typedef menuDef_t *(__cdecl * Menus_FindByName_t)(UiContext *dc, const char *name); typedef menuDef_t *(__cdecl * Menus_FindByName_t)(UiContext* dc, const char* name);
extern Menus_FindByName_t Menus_FindByName; extern Menus_FindByName_t Menus_FindByName;
typedef bool(__cdecl * Menu_IsVisible_t)(UiContext *dc, menuDef_t *menu); typedef bool(__cdecl * Menu_IsVisible_t)(UiContext* dc, menuDef_t* menu);
extern Menu_IsVisible_t Menu_IsVisible; extern Menu_IsVisible_t Menu_IsVisible;
typedef bool(__cdecl * Menus_MenuIsInStack_t)(UiContext *dc, menuDef_t *menu); typedef bool(__cdecl * Menus_MenuIsInStack_t)(UiContext* dc, menuDef_t* menu);
extern Menus_MenuIsInStack_t Menus_MenuIsInStack; extern Menus_MenuIsInStack_t Menus_MenuIsInStack;
typedef menuDef_t*(__cdecl * Menu_GetFocused_t)(UiContext* ctx); typedef menuDef_t*(__cdecl * Menu_GetFocused_t)(UiContext* ctx);
@ -498,16 +498,16 @@ namespace Game
typedef bool(__cdecl * UI_KeyEvent_t)(int clientNum, int key, int down); typedef bool(__cdecl * UI_KeyEvent_t)(int clientNum, int key, int down);
extern UI_KeyEvent_t UI_KeyEvent; extern UI_KeyEvent_t UI_KeyEvent;
typedef const char* (__cdecl * UI_SafeTranslateString_t)(const char* reference); typedef const char*(__cdecl * UI_SafeTranslateString_t)(const char* reference);
extern UI_SafeTranslateString_t UI_SafeTranslateString; extern UI_SafeTranslateString_t UI_SafeTranslateString;
typedef void(__cdecl * UI_ReplaceConversions_t)(const char* sourceString, ConversionArguments* arguments, char* outputString, size_t outputStringSize); typedef void(__cdecl * UI_ReplaceConversions_t)(const char* sourceString, ConversionArguments* arguments, char* outputString, size_t outputStringSize);
extern UI_ReplaceConversions_t UI_ReplaceConversions; extern UI_ReplaceConversions_t UI_ReplaceConversions;
typedef void(__cdecl * MSG_Init_t)(msg_t *buf, char *data, int length); typedef void(__cdecl * MSG_Init_t)(msg_t* buf, char* data, int length);
extern MSG_Init_t MSG_Init; extern MSG_Init_t MSG_Init;
typedef void(__cdecl * MSG_ReadData_t)(msg_t *msg, void *data, int len); typedef void(__cdecl * MSG_ReadData_t)(msg_t* msg, void* data, int len);
extern MSG_ReadData_t MSG_ReadData; extern MSG_ReadData_t MSG_ReadData;
typedef int(__cdecl * MSG_ReadLong_t)(msg_t* msg); typedef int(__cdecl * MSG_ReadLong_t)(msg_t* msg);
@ -894,16 +894,16 @@ namespace Game
typedef void(__cdecl * Sys_SuspendOtherThreads_t)(); typedef void(__cdecl * Sys_SuspendOtherThreads_t)();
extern Sys_SuspendOtherThreads_t Sys_SuspendOtherThreads; extern Sys_SuspendOtherThreads_t Sys_SuspendOtherThreads;
typedef void(__cdecl * UI_AddMenuList_t)(UiContext *dc, MenuList *menuList, int close); typedef void(__cdecl * UI_AddMenuList_t)(UiContext* dc, MenuList* menuList, int close);
extern UI_AddMenuList_t UI_AddMenuList; extern UI_AddMenuList_t UI_AddMenuList;
typedef uiMenuCommand_t(__cdecl * UI_GetActiveMenu_t)(int localClientNum); typedef uiMenuCommand_t(__cdecl * UI_GetActiveMenu_t)(int localClientNum);
extern UI_GetActiveMenu_t UI_GetActiveMenu; extern UI_GetActiveMenu_t UI_GetActiveMenu;
typedef char* (__cdecl * UI_CheckStringTranslation_t)(char*, char*); typedef char*(__cdecl * UI_CheckStringTranslation_t)(char*, char*);
extern UI_CheckStringTranslation_t UI_CheckStringTranslation; extern UI_CheckStringTranslation_t UI_CheckStringTranslation;
typedef MenuList *(__cdecl * UI_LoadMenus_t)(const char *menuFile, int imageTrack); typedef MenuList*(__cdecl * UI_LoadMenus_t)(const char* menuFile, int imageTrack);
extern UI_LoadMenus_t UI_LoadMenus; extern UI_LoadMenus_t UI_LoadMenus;
typedef void(__cdecl * UI_UpdateArenas_t)(); typedef void(__cdecl * UI_UpdateArenas_t)();
@ -912,15 +912,18 @@ namespace Game
typedef void(__cdecl * UI_SortArenas_t)(); typedef void(__cdecl * UI_SortArenas_t)();
extern UI_SortArenas_t UI_SortArenas; extern UI_SortArenas_t UI_SortArenas;
typedef void(__cdecl * UI_DrawHandlePic_t)(/*ScreenPlacement*/void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Material *material); typedef void(__cdecl * UI_DrawHandlePic_t)(ScreenPlacement* scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float* color, Material* material);
extern UI_DrawHandlePic_t UI_DrawHandlePic; extern UI_DrawHandlePic_t UI_DrawHandlePic;
typedef ScreenPlacement*(__cdecl * ScrPlace_GetActivePlacement_t)(int localClientNum); typedef ScreenPlacement*(__cdecl * ScrPlace_GetActivePlacement_t)(int localClientNum);
extern ScrPlace_GetActivePlacement_t ScrPlace_GetActivePlacement; extern ScrPlace_GetActivePlacement_t ScrPlace_GetActivePlacement;
typedef int(__cdecl * UI_TextWidth_t)(const char *text, int maxChars, Font_s *font, float scale); typedef int(__cdecl * UI_TextWidth_t)(const char* text, int maxChars, Font_s *font, float scale);
extern UI_TextWidth_t UI_TextWidth; extern UI_TextWidth_t UI_TextWidth;
typedef int(__cdecl * UI_TextHeight_t)(Font_s* font, float scale);
extern UI_TextHeight_t UI_TextHeight;
typedef void(__cdecl * UI_DrawText_t)(const ScreenPlacement* scrPlace, const char* text, int maxChars, Font_s* font, float x, float y, int horzAlign, int vertAlign, float scale, const float* color, int style); typedef void(__cdecl * UI_DrawText_t)(const ScreenPlacement* scrPlace, const char* text, int maxChars, Font_s* font, float x, float y, int horzAlign, int vertAlign, float scale, const float* color, int style);
extern UI_DrawText_t UI_DrawText; extern UI_DrawText_t UI_DrawText;
@ -1006,7 +1009,7 @@ namespace Game
extern source_t **sourceFiles; extern source_t **sourceFiles;
extern keywordHash_t **menuParseKeywordHash; extern keywordHash_t **menuParseKeywordHash;
extern UiContext *uiContext; extern UiContext* uiContext;
extern int* arenaCount; extern int* arenaCount;
extern mapArena_t* arenas; extern mapArena_t* arenas;
@ -1036,10 +1039,6 @@ namespace Game
constexpr auto ENTITYNUM_NONE = MAX_GENTITIES - 1; constexpr auto ENTITYNUM_NONE = MAX_GENTITIES - 1;
extern gentity_t* g_entities; extern gentity_t* g_entities;
extern int* level_num_entities;
extern int* level_time;
extern int* level_scriptPrintChannel;
extern netadr_t* connectedHost; extern netadr_t* connectedHost;
extern SOCKET* ip_socket; extern SOCKET* ip_socket;
@ -1117,11 +1116,17 @@ namespace Game
extern FastCriticalSection* db_hashCritSect; extern FastCriticalSection* db_hashCritSect;
extern ScreenPlacement* scrPlaceFullUnsafe;
extern level_locals_t* level;
void Sys_LockRead(FastCriticalSection* critSect); void Sys_LockRead(FastCriticalSection* critSect);
void Sys_UnlockRead(FastCriticalSection* critSect); void Sys_UnlockRead(FastCriticalSection* critSect);
XModel* G_GetModel(int index); XModel* G_GetModel(int index);
ScreenPlacement* ScrPlace_GetUnsafeFullPlacement();
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize); XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize);
void Menu_FreeItemMemory(Game::itemDef_s* item); void Menu_FreeItemMemory(Game::itemDef_s* item);
void Menu_SetNextCursorItem(Game::UiContext* ctx, Game::menuDef_t* currentMenu, int unk = 1); void Menu_SetNextCursorItem(Game::UiContext* ctx, Game::menuDef_t* currentMenu, int unk = 1);