diff --git a/src/Components/Modules/Weapons.cpp b/src/Components/Modules/Weapons.cpp index f2f058f..f12f880 100644 --- a/src/Components/Modules/Weapons.cpp +++ b/src/Components/Modules/Weapons.cpp @@ -100,10 +100,11 @@ namespace Components unsigned int weaponIndex = Game::ps->weapon; const auto weaponDef = Game::bg_weaponDefs[weaponIndex]; - Game::CG_PlayBoltedEffect(Game::cgs->localClientNum, - Game::cgsArray->fxs[fxId], + + Game::CG_PlayBoltedEffect(Game::cgs->localClientNum, + Game::scr_const->tag_flash, weaponIndex + 2176, - Game::scr_const->tag_flash); + Game::cgsArray->fxs[fxId]); Game::Scr_AddInt(true); }, false); diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 638dbc0..0182d62 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -13,6 +13,7 @@ namespace Game Game::cgs_t* cgsArray = reinterpret_cast(0x6FA130); Game::clientActive_t* clients = reinterpret_cast(0x85BD98); Game::clientUIActive_t* clientUIActive = reinterpret_cast(0x85BD70); + Game::CinematicGlob* cinematicGlob = reinterpret_cast(0x1621600); Game::clipMap_t* cm = reinterpret_cast(0xF788C8); Game::game_hudelem_field_t* fields_0 = reinterpret_cast(0x6814B8); Game::game_hudelem_s* g_hudelems = reinterpret_cast(0xC74818); @@ -36,6 +37,7 @@ namespace Game Game::uiInfo_s* uiInfo = reinterpret_cast(0x1290F50); Game::weaponInfo_s* cg_weaponsArray = reinterpret_cast(0x6F7C88); Game::WinMouseVars_t* s_wmv = reinterpret_cast(0x13E06F0); + int* g_currentMenuType = reinterpret_cast(0x1E209B4); longjmp_internal_t longjmp_internal = longjmp_internal_t(0x64285C); @@ -143,7 +145,7 @@ namespace Game bool Key_IsCatcherActive(int mask) { - return (mask & Game::clientUIActive->keyCatchers); + return (mask & Game::clientUIActive->keyCatchers) != 0; } const char* SEH_GetCurrentLanguage() @@ -262,65 +264,19 @@ namespace Game } } - //Something changed function, but anyway functionally. - const char* UI_GetFontHandle(const ScreenPlacement* ScrPlace, float fontscale) + Game::Font_s* UI_GetFontHandle(int fontEnum, const ScreenPlacement* ScrPlace, float scale) { - const char* font; - float fontscalea = ScrPlace->scaleVirtualToReal[1] * fontscale; - - const auto ui_smallFont = Dvars::Functions::Dvar_FindVar("ui_smallFont"); - const auto ui_extraBigFont = Dvars::Functions::Dvar_FindVar("ui_extraBigFont"); - const auto ui_bigFont = Dvars::Functions::Dvar_FindVar("ui_bigFont"); - - if (ui_smallFont && ui_smallFont->current.value < fontscalea) - { - if (ui_extraBigFont && ui_extraBigFont->current.value > fontscalea) - { - return font = "fonts/bigFont"; - - if (ui_bigFont && ui_bigFont->current.value > fontscalea) - { - return font = "fonts/normalFont"; - } - } - else - { - return font = "fonts/extraBigFont"; - } - } - else - { - return font = "fonts/extraBigFont"; - } - } - - Game::Font_s* UI_GetFontHandleStock(int fontEnum, const ScreenPlacement* ScrPlace, float scale) - { - Game::Font_s* bigFont = Game::R_RegisterFont("fonts/bigFont", sizeof("fonts/bigFont")); - Game::Font_s* boldFont = Game::R_RegisterFont("fonts/boldFont", sizeof("fonts/boldFont")); - Game::Font_s* consoleFont = Game::R_RegisterFont("fonts/consoleFont", sizeof("fonts/consoleFont")); - Game::Font_s* extraBigFont = Game::R_RegisterFont("fonts/extraBigFont", sizeof("fonts/extraBigFont")); - Game::Font_s* normalFont = Game::R_RegisterFont("fonts/normalFont", sizeof("fonts/normalFont")); - Game::Font_s* objectiveFont = Game::R_RegisterFont("fonts/objectiveFont", sizeof("fonts/objectiveFont")); - Game::Font_s* smallFont = Game::R_RegisterFont("fonts/smallFont", sizeof("fonts/smallFont")); - switch (fontEnum) { - case 1: - return normalFont; - case 2: - return bigFont; case 3: - return smallFont; - case 4: - return boldFont; + return Game::sharedUiInfo->assets.smallFont; case 5: - return consoleFont; + return Game::sharedUiInfo->assets.consoleFont; case 6: - return objectiveFont; + return Game::sharedUiInfo->assets.objectiveFont; } - double fontscalea = ScrPlace->scaleVirtualToReal[1] * scale; + float fontscalea = (Dvars::console_menu_style->current.enabled) ? fontscalea = 1.5 * scale : fontscalea = scrPlace->scaleVirtualToReal[1] * scale; const auto ui_smallFont = Dvars::Functions::Dvar_FindVar("ui_smallFont"); const auto ui_extraBigFont = Dvars::Functions::Dvar_FindVar("ui_extraBigFont"); @@ -328,19 +284,35 @@ namespace Game if (fontEnum == 4) { - if (ui_smallFont->current.value >= fontscalea) - return smallFont; - if (ui_bigFont->current.value <= fontscalea) - return boldFont; - return normalFont; + if (fontscalea >= ui_smallFont->current.value) + { + if (fontscalea >= ui_bigFont->current.value) + return Game::sharedUiInfo->assets.boldFont; + return Game::sharedUiInfo->assets.textFont; + } + return Game::sharedUiInfo->assets.smallFont; + } + + if (Dvars::console_menu_style->current.enabled) + { + if (fontscalea <= 0.563) + return Game::sharedUiInfo->assets.smallFont; + if (fontscalea >= 1.0) + return Game::sharedUiInfo->assets.extraBigFont; + if (fontscalea >= 0.688) + return Game::sharedUiInfo->assets.bigFont; + return Game::sharedUiInfo->assets.textFont; + } + else + { + if (fontscalea <= ui_smallFont->current.value) + return Game::sharedUiInfo->assets.smallFont; + if (fontscalea >= ui_extraBigFont->current.value) + return Game::sharedUiInfo->assets.extraBigFont; + if (fontscalea >= ui_bigFont->current.value) + return Game::sharedUiInfo->assets.bigFont; + return Game::sharedUiInfo->assets.textFont; } - if (ui_smallFont->current.value >= fontscalea) - return smallFont; - if (ui_extraBigFont->current.value <= fontscalea) - return extraBigFont; - if (ui_bigFont->current.value > fontscalea) - return normalFont; - return bigFont; } int R_TextHeight(Font_s* font) @@ -1186,7 +1158,7 @@ namespace Game SV_SetConfigstring_t SV_SetConfigstring = SV_SetConfigstring_t(0x5C6780); - void CG_PlayBoltedEffect(int localClientNum/*eax*/, Game::FxEffectDef* fxDef, int dobjHandle/*edi*/, unsigned int boneName/*edx*/) + void CG_PlayBoltedEffect(int localClientNum/*eax*/, unsigned int boneName/*edx*/, int dobjHandle/*edi*/, const Game::FxEffectDef* fxDef) { const static uint32_t CG_PlayBoltedEffect_func = 0x418690; __asm @@ -1374,4 +1346,69 @@ namespace Game popad; } } + + void CL_StopLogoOrCinematic(int localClientNum /*edi*/) + { + const uint32_t CL_StopLogoOrCinematic_func = 0x445CE0; + __asm + { + pushad; + mov edi, localClientNum; + call CL_StopLogoOrCinematic_func; + popad; + } + } + + bool R_Cinematic_IsStarted() + { + return !Game::cinematicGlob->cinematicFinished && Game::cinematicGlob->currentCinematicName[0]; + } + + Game::FxEffect* FX_SpawnOrientedEffect/*eax*/(int axis/*edx*/, int markEntnum/*ecx*/, const Game::FxEffectDef* def, int msecBegin, const float* origin) + { + Game::FxEffect* result; + const uint32_t FX_SpawnOrientedEffect_func = 0x471E30; + __asm + { + mov edx, [axis]; + mov ecx, markEntnum; + push [origin]; + push msecBegin; + push def; + call FX_SpawnOrientedEffect_func; + add esp, 0xC; + mov result, eax; + } + return result; + } + + int CG_PlayClientSoundAlias/*eax*/(Game::snd_alias_list_t* aliasList/*eax*/, int localClientNum, float* origin) + { + int result; + const uint32_t CG_PlayClientSoundAlias_func = 0x4208A0; + __asm + { + mov eax, aliasList; + push [origin]; + push localClientNum; + call CG_PlayClientSoundAlias_func; + add esp, 8; + mov result, eax; + } + return result; + } + + void DynEntCl_PlayEventFx(const float* origin/*edx*/, int axis/*ecx*/, const Game::FxEffectDef* def, int time) + { + const uint32_t DynEntCl_PlayEventFx_func = 0x471EA0; + __asm + { + mov edx, [origin]; + mov ecx, [axis]; + push time; + push def; + call DynEntCl_PlayEventFx_func; + add esp, 8; + } + } } \ No newline at end of file diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index dca1b62..04c7199 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -20,6 +20,7 @@ namespace Game extern Game::cgs_t* cgsArray; extern Game::clientActive_t* clients; extern Game::clientUIActive_t* clientUIActive; + extern Game::CinematicGlob* cinematicGlob; extern Game::clipMap_t* cm; extern Game::gclient_s* g_clients; extern Game::gentity_s* g_entities; @@ -41,6 +42,7 @@ namespace Game extern Game::WeaponDef_s** bg_weaponDefs; extern Game::weaponInfo_s* cg_weaponsArray; extern Game::WinMouseVars_t* s_wmv; + extern int* g_currentMenuType; extern int* g_waitingForKey; extern bool* isDvarSystemActive; @@ -90,7 +92,7 @@ namespace Game Game::ScreenPlacement* ScrPlace_GetUnsafeFullPlacement(); void R_AddCmdDrawTextASM(const char* text, int max_chars, void* font, float x, float y, float x_scale, float y_scale, float rotation, const float* color, int style); void R_AddCmdDrawStretchPic(Game::Material* material, float x, float y, float w, float h, float null1, float null2, float null3, float null4, float* color); // ASM - const char* UI_GetFontHandle(const ScreenPlacement* ScrPlace, float fontscale); + Game::Font_s* UI_GetFontHandle(int fontEnum, const ScreenPlacement* scrPlace, float scale); int R_TextHeight(Font_s* font); long double R_NormalizedTextScale(Font_s* font, float scale); @@ -154,8 +156,6 @@ namespace Game void StartWeaponAnim(int weaponIndex /*eax*/, Game::DObj_s* obj /*edi*/, int animIndex, float transitionTime); - Game::Font_s* UI_GetFontHandleStock(int fontEnum, const ScreenPlacement* scrPlace, float scale); - bool ShotLimitReached(Game::WeaponDef_s* weaponDef, Game::playerState_s* playerState); void PM_Weapon_BeginWeaponRaise(Game::playerState_s* playerState, int time, int anim, float aim, int altSwitch); @@ -236,7 +236,7 @@ namespace Game typedef void(*SV_SetConfigstring_t)(int index, const char* string); extern SV_SetConfigstring_t SV_SetConfigstring; - void CG_PlayBoltedEffect(int localClientNum/*eax*/, Game::FxEffectDef* fxDef, int dobjHandle/*edi*/, unsigned int boneName/*edx*/); + void CG_PlayBoltedEffect(int localClientNum/*eax*/, unsigned int boneName/*edx*/, int dobjHandle/*edi*/, const Game::FxEffectDef* fxDef); void FX_ThroughWithEffect(Game::FxEffectDef* fxDef /*esi*/); typedef void(*IN_RecenterMouse_t)(); @@ -262,4 +262,11 @@ namespace Game int UI_GetKeyBindingLocalizedString/*eax*/(int localClientNum/*eax*/, const char* command/*ecx*/, char* keys, int bindNum); void DrawWrappedText(const rectDef_s* rect /*edi*/, Game::Font_s* font /*esi*/, const Game::ScreenPlacement* ScrPlace, const char* text, float x, float y, float scale, const float* color, int style, int textAlignMode, Game::rectDef_s* textRect, const float* glowColor, int subtitle, int cinematic); + void CL_StopLogoOrCinematic(int localClientNum /*edi*/); + + bool R_Cinematic_IsStarted(); + Game::FxEffect* FX_SpawnOrientedEffect/*eax*/(int axis/*edx*/, int markEntnum/*ecx*/, const Game::FxEffectDef* def, int msecBegin, const float* origin); + + int CG_PlayClientSoundAlias/*eax*/(Game::snd_alias_list_t* aliasList/*eax*/, int localClientNum, float* origin); + void DynEntCl_PlayEventFx(const float* origin/*edx*/, int axis/*ecx*/, const Game::FxEffectDef* def, int time); } \ No newline at end of file diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 2bba34f..4f77185 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -3,4 +3,10 @@ namespace Game { Game::gui_t gui = {}; + + bool HasLoadedMod() + { + std::string modDir = Dvars::Functions::Dvar_FindVar("fs_game")->current.string; + return !modDir.empty(); + } } \ No newline at end of file diff --git a/src/Game/Game.hpp b/src/Game/Game.hpp index acae09e..1a44997 100644 --- a/src/Game/Game.hpp +++ b/src/Game/Game.hpp @@ -10,4 +10,6 @@ namespace Game { extern Game::gui_t gui; + + bool HasLoadedMod(); } \ No newline at end of file diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 8ac5e68..4dbe033 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -1462,6 +1462,8 @@ namespace Game statement_s forecolorAExp; }; + struct FxEffectDef; + union XAssetHeader { void* data; @@ -1474,6 +1476,7 @@ namespace Game StringTable* stringTable; GfxImage* image; menuDef_t* menu; + FxEffectDef* fx; }; struct XAsset @@ -3636,6 +3639,40 @@ namespace Game FxImpactEntry* table; }; + struct FxBoltAndSortOrder + { + unsigned __int32 sortOrder : 8; + unsigned __int32 boneIndex : 10; + unsigned __int32 temporalBits : 2; + unsigned __int32 dobjHandle : 12; + }; + + struct FxSpatialFrame + { + float quat[4]; + float origin[3]; + }; + + struct FxEffect + { + const FxEffectDef* def; + volatile int status; + unsigned __int16 firstElemHandle[3]; + unsigned __int16 firstSortedElemHandle; + unsigned __int16 firstTrailHandle; + unsigned __int16 randomSeed; + unsigned __int16 owner; + unsigned __int16 packedLighting; + FxBoltAndSortOrder boltAndSortOrder; + volatile int frameCount; + int msecBegin; + int msecLastUpdate; + FxSpatialFrame frameAtSpawn; + FxSpatialFrame frameNow; + FxSpatialFrame framePrev; + float distanceTraveled; + }; + enum weaponstate_t { WEAPON_READY = 0x0, @@ -5860,7 +5897,7 @@ namespace Game enum uiMenuCommand_t { - UIMENU_BACKTOGAME = 0x0, + UIMENU_NONE = 0x0, UIMENU_ERROR = 0x1, UIMENU_PAUSED = 0x2, UIMENU_NEEDCD = 0x3, @@ -6332,4 +6369,17 @@ namespace Game bool include; unsigned int sourcePos; }; + + //not fully reversed :( + struct __declspec(align(4)) CinematicGlob + { + char currentCinematicName[256]; + char targetCinematicName[256]; + char nextCinematicName[256]; + unsigned int nextCinematicPlaybackFlags; + unsigned int playbackFlags; + bool targetCinematicChanged; + bool cinematicFinished; + char gap0[1788]; + }; }