From 8d12fc20055c5486b2565a86abfca55bd6993002 Mon Sep 17 00:00:00 2001 From: rei-2 <174158077+rei-2@users.noreply.github.com> Date: Thu, 27 Mar 2025 19:59:43 -0400 Subject: [PATCH] some more fixes --- .../Aimbot/AimbotHitscan/AimbotHitscan.cpp | 2 - Amalgam/src/Features/ImGui/Menu/Components.h | 135 +++++++++++------- Amalgam/src/Features/ImGui/Menu/Menu.cpp | 6 +- Amalgam/src/Features/Visuals/Visuals.cpp | 2 +- .../src/Hooks/CBasePlayer_ItemPostFrame.cpp | 4 +- Amalgam/src/Hooks/Cbuf_ExecuteCommand.cpp | 109 +++++++------- .../src/SDK/Definitions/Main/CBaseAnimating.h | 9 ++ Amalgam/src/SDK/SDK.cpp | 21 +-- Amalgam/src/Utils/CrashLog/CrashLog.cpp | 1 - 9 files changed, 168 insertions(+), 121 deletions(-) diff --git a/Amalgam/src/Features/Aimbot/AimbotHitscan/AimbotHitscan.cpp b/Amalgam/src/Features/Aimbot/AimbotHitscan/AimbotHitscan.cpp index 11e49032..6122548a 100644 --- a/Amalgam/src/Features/Aimbot/AimbotHitscan/AimbotHitscan.cpp +++ b/Amalgam/src/Features/Aimbot/AimbotHitscan/AimbotHitscan.cpp @@ -335,14 +335,12 @@ int CAimbotHitscan::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase* auto RayToOBB = [&](const Vec3& vOrigin, const Vec3& vDirection, const Vec3& vMins, const Vec3& vMaxs, const matrix3x4& mMatrix, float flScale = 1.f) -> bool { - /* switch (Vars::Aimbot::General::AimType.Value) { case Vars::Aimbot::General::AimTypeEnum::Smooth: case Vars::Aimbot::General::AimTypeEnum::Assistive: return Math::RayToOBB(vOrigin, vDirection, vMins, vMaxs, mMatrix, flScale); } - */ return true; }; diff --git a/Amalgam/src/Features/ImGui/Menu/Components.h b/Amalgam/src/Features/ImGui/Menu/Components.h index d8a3b858..1f9ac644 100644 --- a/Amalgam/src/Features/ImGui/Menu/Components.h +++ b/Amalgam/src/Features/ImGui/Menu/Components.h @@ -614,7 +614,7 @@ namespace ImGui vStoredLabels.pop_back(); float flHeight = GetItemRectMax().y - GetWindowPos().y; if (flHeight > 0.f) - mLastHeights[sLabel] = flHeight + H::Draw.Scale(8); + mLastHeights[sLabel] = flHeight + GetStyle().WindowPadding.y; PopStyleVar(); EndChild(); @@ -895,16 +895,34 @@ namespace ImGui return FSelectable(sLabel, &tColor, flRounding, bSelected, iFlags, vSize); } - static std::vector> vRowSizes; + struct Row_t + { + float m_flPosY; + float m_flSizeY; + }; + static std::vector vRowSizes; inline void AddRowSize(float flPosY, float flSizeY) { + if (GetCurrentWindow()->Flags & ImGuiWindowFlags_Popup) + return; + flPosY += GetDrawPos().y; - if (!vRowSizes.empty() && vRowSizes.back().first != flPosY) + if (!vRowSizes.empty() && vRowSizes.back().m_flPosY != flPosY) vRowSizes.clear(); vRowSizes.emplace_back(flPosY, flSizeY); } - inline float GetRowSize() + inline float GetRowPos(bool bDrawPos = false) { + if (!vRowSizes.empty()) + return vRowSizes.front().m_flPosY - (!bDrawPos ? GetDrawPos().y : 0.f); + else + return GetCursorPosY() + (bDrawPos ? GetDrawPos().y : 0.f); + } + inline float GetRowSize(float flDefault = 0.f) + { + if (GetCurrentWindow()->Flags & ImGuiWindowFlags_Popup) + return flDefault; + float flMax = 0.f; for (auto& [_, flSize] : vRowSizes) flMax = std::max(flMax, flSize); @@ -942,7 +960,7 @@ namespace ImGui vSize.x += H::Draw.Scale(iSizeOffset); vSize.y = H::Draw.Scale(vSize.y); ImVec2 vOriginalPos = GetCursorPos(); - DebugShift({ 0, H::Draw.Scale(8) }); + DebugShift({ 0, GetStyle().WindowPadding.y }); ImVec4 vAccent = F::Render.Accent.Value; ImVec2 vDrawPos = GetCursorPos() + GetDrawPos(); @@ -961,8 +979,8 @@ namespace ImGui PopStyleColor(); SetCursorPos(vOriginalPos); - AddRowSize(vOriginalPos.y, vSize.y + H::Draw.Scale(8)); - DebugDummy({ vSize.x, GetRowSize() }); + AddRowSize(vOriginalPos.y, vSize.y + GetStyle().WindowPadding.y); + DebugDummy({ vSize.x, GetRowSize(vSize.y + GetStyle().WindowPadding.y) }); if (Transparent || Disabled) PopStyleVar(); @@ -1012,7 +1030,7 @@ namespace ImGui SetCursorPos(vOriginalPos); AddRowSize(vOriginalPos.y, vSize.y); - DebugDummy({ vSize.x, GetRowSize() }); + DebugDummy({ vSize.x, GetRowSize(vSize.y) }); if (Transparent || Disabled) PopStyleVar(); @@ -1246,7 +1264,7 @@ namespace ImGui Button("##", { vMaxs.x - vMins.x + 12, 14 }); // don't drag it around SetCursorPos(vOriginalPos); AddRowSize(vOriginalPos.y, vSize.y); - DebugDummy({ vSize.x, GetRowSize() }); + DebugDummy({ vSize.x, GetRowSize(vSize.y) }); if (Transparent || Disabled) PopStyleVar(); @@ -1341,7 +1359,6 @@ namespace ImGui if (sPreview.empty()) sPreview = "None"; - PushStyleVar(ImGuiStyleVar_FramePadding, { 0.f, H::Draw.Scale(bTitle ? 13.5f : 5.5f) }); ImVec2 vSize = { GetWindowWidth(), H::Draw.Scale(bTitle ? 40 : 24) }; if (iFlags & (FDropdown_Left | FDropdown_Right)) vSize.x = vSize.x / 2 - GetStyle().WindowPadding.x * 1.5f; @@ -1351,18 +1368,20 @@ namespace ImGui SameLine(vSize.x + GetStyle().WindowPadding.x * 2.f); iSizeOffset = strstr(sLabel, "## Bind") ? 0 : H::Draw.Scale(iSizeOffset, Scale_Round); vSize.x += iSizeOffset; - PushItemWidth(vSize.x); ImVec2 vOriginalPos = GetCursorPos(); - DebugShift({ 0, H::Draw.Scale(8) }); + DebugShift({ 0, GetStyle().WindowPadding.y }); if (Disabled) { // lol Button("##", vSize); SetCursorPos(vOriginalPos); - DebugShift({ 0, H::Draw.Scale(8) }); + DebugShift({ 0, GetStyle().WindowPadding.y }); } + PushStyleVar(ImGuiStyleVar_FramePadding, { 0.f, H::Draw.Scale(bTitle ? 13.5f : 5.5f) }); + PushItemWidth(vSize.x); + bool bActive = BeginCombo(std::format("##{}", sLabel).c_str(), "", ImGuiComboFlags_CustomPreview | ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_HeightLarge); if (bActive) { @@ -1473,20 +1492,20 @@ namespace ImGui EndComboPreview(); } - SetCursorPos(vOriginalPos); - AddRowSize(vOriginalPos.y, vSize.y + GetStyle().WindowPadding.y); - DebugDummy({ vSize.x, GetRowSize() }); - PopItemWidth(); PopStyleVar(); + SetCursorPos(vOriginalPos); + AddRowSize(vOriginalPos.y, vSize.y + GetStyle().WindowPadding.y); + DebugDummy({ vSize.x, GetRowSize(vSize.y + GetStyle().WindowPadding.y) }); + if (Transparent || Disabled) PopStyleVar(); if (pHovered && IsWindowHovered()) { vOriginalPos += GetDrawPos(); - *pHovered = IsMouseWithin(vOriginalPos.x, vOriginalPos.y + H::Draw.Scale(8), vSize.x, vSize.y); + *pHovered = IsMouseWithin(vOriginalPos.x, vOriginalPos.y + GetStyle().WindowPadding.y, vSize.x, vSize.y); } return bReturn; @@ -1502,12 +1521,6 @@ namespace ImGui bool bTitle = sLabel[0] != '#'; - PushStyleVar(ImGuiStyleVar_FramePadding, { 0.f, H::Draw.Scale(bTitle ? 13.5f : 5.5f) }); - if (vEntries.empty()) - { - PushStyleColor(ImGuiCol_PopupBg, {}); - PushStyleVar(ImGuiStyleVar_WindowPadding, { GetStyle().WindowPadding.x, 0 }); - } ImVec2 vSize = { GetWindowWidth(), H::Draw.Scale(bTitle ? 40 : 24) }; if (iFlags & (FDropdown_Left | FDropdown_Right)) vSize.x = vSize.x / 2 - GetStyle().WindowPadding.x * 1.5f; @@ -1517,18 +1530,25 @@ namespace ImGui SameLine(vSize.x + GetStyle().WindowPadding.x * 2.f); iSizeOffset = strstr(sLabel, "## Bind") ? 0 : H::Draw.Scale(iSizeOffset, Scale_Round); vSize.x += iSizeOffset; - PushItemWidth(vSize.x); ImVec2 vOriginalPos = GetCursorPos(); - DebugShift({ 0, H::Draw.Scale(8) }); + DebugShift({ 0, GetStyle().WindowPadding.y }); if (Disabled) { // lol Button("##", vSize); SetCursorPos(vOriginalPos); - DebugShift({ 0, H::Draw.Scale(8) }); + DebugShift({ 0, GetStyle().WindowPadding.y }); } + PushStyleVar(ImGuiStyleVar_FramePadding, { 0.f, H::Draw.Scale(bTitle ? 13.5f : 5.5f) }); + if (vEntries.empty()) + { + PushStyleColor(ImGuiCol_PopupBg, {}); + PushStyleVar(ImGuiStyleVar_WindowPadding, { GetStyle().WindowPadding.x, 0 }); + } + PushItemWidth(vSize.x); + static std::string sPreview = "", sInput = "", sTab = "\n"; if (BeginCombo(std::format("##{}", sLabel).c_str(), "", ImGuiComboFlags_CustomPreview | ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_HeightLarge)) { @@ -1695,17 +1715,18 @@ namespace ImGui EndComboPreview(); } + PopItemWidth(); - PopStyleVar(); if (vEntries.empty()) { PopStyleColor(); PopStyleVar(); } + PopStyleVar(); SetCursorPos(vOriginalPos); AddRowSize(vOriginalPos.y, vSize.y + GetStyle().WindowPadding.y); - DebugDummy({ vSize.x, GetRowSize() }); + DebugDummy({ vSize.x, GetRowSize(vSize.y + GetStyle().WindowPadding.y) }); if (Transparent || Disabled) PopStyleVar(); @@ -1713,7 +1734,7 @@ namespace ImGui if (pHovered && IsWindowHovered()) { vOriginalPos += GetDrawPos(); - *pHovered = IsMouseWithin(vOriginalPos.x, vOriginalPos.y + H::Draw.Scale(8), vSize.x, vSize.y); + *pHovered = IsMouseWithin(vOriginalPos.x, vOriginalPos.y + GetStyle().WindowPadding.y, vSize.x, vSize.y); } return bReturn; @@ -1744,7 +1765,6 @@ namespace ImGui sPreview.pop_back(); sPreview.pop_back(); } - PushStyleVar(ImGuiStyleVar_FramePadding, { 0.f, H::Draw.Scale(bTitle ? 13.5f : 5.5f) }); ImVec2 vSize = { GetWindowWidth(), H::Draw.Scale(bTitle ? 40 : 24) }; if (iFlags & (FDropdown_Left | FDropdown_Right)) vSize.x = vSize.x / 2 - GetStyle().WindowPadding.x * 1.5f; @@ -1754,18 +1774,20 @@ namespace ImGui SameLine(vSize.x + GetStyle().WindowPadding.x * 2.f); iSizeOffset = strstr(sLabel, "## Bind") ? 0 : H::Draw.Scale(iSizeOffset, Scale_Round); vSize.x += iSizeOffset; - PushItemWidth(vSize.x); ImVec2 vOriginalPos = GetCursorPos(); - DebugShift({ 0, H::Draw.Scale(8) }); + DebugShift({ 0, GetStyle().WindowPadding.y }); if (Disabled) { // lol Button("##", vSize); SetCursorPos(vOriginalPos); - DebugShift({ 0, H::Draw.Scale(8) }); + DebugShift({ 0, GetStyle().WindowPadding.y }); } + PushStyleVar(ImGuiStyleVar_FramePadding, { 0.f, H::Draw.Scale(bTitle ? 13.5f : 5.5f) }); + PushItemWidth(vSize.x); + bool bActive = false; if (BeginCombo(std::format("##{}", sLabel).c_str(), "", ImGuiComboFlags_CustomPreview | ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_HeightLarge)) { @@ -1852,20 +1874,22 @@ namespace ImGui EndComboPreview(); } - SetCursorPos(vOriginalPos); - AddRowSize(vOriginalPos.y, vSize.y + GetStyle().WindowPadding.y); - DebugDummy({ vSize.x, GetRowSize() }); PopItemWidth(); PopStyleVar(); + SetCursorPos(vOriginalPos); + AddRowSize(vOriginalPos.y, vSize.y + GetStyle().WindowPadding.y); + DebugDummy({ vSize.x, GetRowSize(vSize.y + GetStyle().WindowPadding.y) }); + + if (Transparent || Disabled) PopStyleVar(); if (pHovered && IsWindowHovered()) { vOriginalPos += GetDrawPos(); - *pHovered = IsMouseWithin(vOriginalPos.x, vOriginalPos.y + H::Draw.Scale(8), vSize.x, vSize.y); + *pHovered = IsMouseWithin(vOriginalPos.x, vOriginalPos.y + GetStyle().WindowPadding.y, vSize.x, vSize.y); } return bReturn; @@ -1935,7 +1959,7 @@ namespace ImGui SetCursorPos(vOriginalPos); AddRowSize(vOriginalPos.y, vSize.y); - DebugDummy({ vSize.x, GetRowSize() }); + DebugDummy({ vSize.x, GetRowSize(vSize.y) }); } else { @@ -1957,18 +1981,18 @@ namespace ImGui { float flOriginalPosY = GetCursorPosY(); SameLine(); - vSize = { H::Draw.Scale(10), flOriginalPosY - GetCursorPosY() - H::Draw.Scale(8) }; + vSize = { H::Draw.Scale(10), flOriginalPosY - GetCursorPosY() - GetStyle().WindowPadding.y }; - SetCursorPosX(GetCursorPosX() - H::Draw.Scale(8)); + SetCursorPosX(GetCursorPosX() - GetStyle().WindowPadding.y); vOriginalPos = GetCursorPos(); - SetCursorPosY(GetCursorPosY() + H::Draw.Scale(8)); + SetCursorPosY(GetCursorPosY() + GetStyle().WindowPadding.y); bReturn = ColorPicker(sLabel, tColor, iFlags & FColorPicker_Tooltip, iFlags, vSize); SetCursorPos(vOriginalPos); AddRowSize(vOriginalPos.y, vSize.y + GetStyle().WindowPadding.y); - DebugDummy({ vSize.x, GetRowSize() }); + DebugDummy({ vSize.x, GetRowSize(vSize.y + GetStyle().WindowPadding.y) }); - vOriginalPos.y += H::Draw.Scale(8); + vOriginalPos.y += GetStyle().WindowPadding.y; vSize = { H::Draw.Scale(10), H::Draw.Scale(40) }; } if (pHovered && IsWindowHovered()) @@ -2163,7 +2187,6 @@ namespace ImGui sPreview.pop_back(); sPreview.pop_back(); } - PushStyleVar(ImGuiStyleVar_FramePadding, { 0.f, H::Draw.Scale(bTitle ? 13.5f : 5.5f) }); ImVec2 vSize = { GetWindowWidth(), H::Draw.Scale(bTitle ? 40 : 24) }; if (iFlags & (FDropdown_Left | FDropdown_Right)) vSize.x = vSize.x / 2 - GetStyle().WindowPadding.x * 1.5f; @@ -2173,18 +2196,20 @@ namespace ImGui SameLine(vSize.x + GetStyle().WindowPadding.x * 2.f); iSizeOffset = strstr(sLabel, "## Bind") ? 0 : H::Draw.Scale(iSizeOffset, Scale_Round); vSize.x += iSizeOffset; - PushItemWidth(vSize.x); ImVec2 vOriginalPos = GetCursorPos(); - DebugShift({ 0, 8 }); + DebugShift({ 0, GetStyle().WindowPadding.y }); if (Disabled) { // lol Button("##", vSize); SetCursorPos(vOriginalPos); - DebugShift({ 0, 8 }); + DebugShift({ 0, GetStyle().WindowPadding.y }); } + PushStyleVar(ImGuiStyleVar_FramePadding, { 0.f, H::Draw.Scale(bTitle ? 13.5f : 5.5f) }); + PushItemWidth(vSize.x); + bool bActive = false; if (BeginCombo(std::format("##{}", sLabel).c_str(), "", ImGuiComboFlags_CustomPreview | ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_HeightLarge)) { @@ -2280,20 +2305,22 @@ namespace ImGui EndComboPreview(); } - SetCursorPos(vOriginalPos); - AddRowSize(vOriginalPos.y, vSize.y + GetStyle().WindowPadding.y); - DebugDummy({ vSize.x, GetRowSize() }); PopItemWidth(); PopStyleVar(); + SetCursorPos(vOriginalPos); + AddRowSize(vOriginalPos.y, vSize.y + GetStyle().WindowPadding.y); + DebugDummy({ vSize.x, GetRowSize(vSize.y + GetStyle().WindowPadding.y) }); + + if (Transparent || Disabled) PopStyleVar(); if (pHovered && IsWindowHovered()) { vOriginalPos += GetDrawPos(); - *pHovered = IsMouseWithin(vOriginalPos.x, vOriginalPos.y + H::Draw.Scale(8), vSize.x, vSize.y); + *pHovered = IsMouseWithin(vOriginalPos.x, vOriginalPos.y + GetStyle().WindowPadding.y, vSize.x, vSize.y); } return bReturn; @@ -2510,11 +2537,11 @@ namespace ImGui _tBind.m_bNot = tBind.m_bNot; } - DebugDummy({ 0, H::Draw.Scale(8) }); + DebugDummy({ 0, GetStyle().WindowPadding.y }); } #define WRAPPER(function, type, parameters, arguments)\ - inline bool function(const char* sLabel, ConfigVar& var, parameters, bool* pHovered = nullptr, std::string sBindOverride = "")\ + inline bool function(const char* sLabel, ConfigVar& var, parameters, bool* pHovered = nullptr, const std::string& sBindOverride = "")\ {\ auto val = FGet(var, true);\ bool bHovered = false;\ diff --git a/Amalgam/src/Features/ImGui/Menu/Menu.cpp b/Amalgam/src/Features/ImGui/Menu/Menu.cpp index 70e1b6e0..302ce837 100644 --- a/Amalgam/src/Features/ImGui/Menu/Menu.cpp +++ b/Amalgam/src/Features/ImGui/Menu/Menu.cpp @@ -370,7 +370,7 @@ void CMenu::MenuAimbot(int iTab) FSlider("Spin speed", Vars::AntiHack::AntiAim::SpinSpeed, -30.f, 30.f, 1.f, "%g", FSlider_Left | FSlider_Precision); } PopTransparent(); - SetCursorPos({ GetWindowWidth() / 2 + GetStyle().WindowPadding.x / 2, GetCursorPosY() - H::Draw.Scale(24) }); + SetCursorPos({ GetWindowWidth() / 2 + GetStyle().WindowPadding.x / 2, GetRowPos() + H::Draw.Scale(8) }); FToggle("Minwalk", Vars::AntiHack::AntiAim::MinWalk, FToggle_Left); FToggle("Anti-overlap", Vars::AntiHack::AntiAim::AntiOverlap, FToggle_Left); FToggle("Hide pitch on shot", Vars::AntiHack::AntiAim::InvalidShootPitch, FToggle_Right); @@ -2861,7 +2861,7 @@ void CMenu::MenuSettings(int iTab) PopDisabled(); if (FButton("Folder", FButton_Fit | FButton_SameLine)) - ShellExecuteA(nullptr, "open", F::Configs.m_sCorePath.c_str(), nullptr, nullptr, SW_SHOWDEFAULT); + ShellExecuteA(NULL, NULL, F::Configs.m_sCorePath.c_str(), NULL, NULL, SW_SHOWNORMAL); } break; // Materials @@ -2949,7 +2949,7 @@ void CMenu::MenuSettings(int iTab) } EndSection(); SetCursorPosY(GetCursorPosY() - 8); if (FButton("Folder", FButton_Fit)) - ShellExecuteA(nullptr, "open", F::Configs.m_sMaterialsPath.c_str(), nullptr, nullptr, SW_SHOWDEFAULT); + ShellExecuteA(NULL, NULL, F::Configs.m_sMaterialsPath.c_str(), NULL, NULL, SW_SHOWNORMAL); /* Column 2 */ TableNextColumn(); diff --git a/Amalgam/src/Features/Visuals/Visuals.cpp b/Amalgam/src/Features/Visuals/Visuals.cpp index ea45c5bd..b382ab72 100644 --- a/Amalgam/src/Features/Visuals/Visuals.cpp +++ b/Amalgam/src/Features/Visuals/Visuals.cpp @@ -806,7 +806,7 @@ void CVisuals::ThirdPerson(CTFPlayer* pLocal, CViewSetup* pView) cam_ideallag->SetValue(0.f); if (I::Input->CAM_IsThirdPerson()) - { // Thirdperson offset + { // thirdperson offset Vec3 vForward, vRight, vUp; Math::AngleVectors(pView->angles, &vForward, &vRight, &vUp); Vec3 vOffset; diff --git a/Amalgam/src/Hooks/CBasePlayer_ItemPostFrame.cpp b/Amalgam/src/Hooks/CBasePlayer_ItemPostFrame.cpp index dc42e3d4..1e234e46 100644 --- a/Amalgam/src/Hooks/CBasePlayer_ItemPostFrame.cpp +++ b/Amalgam/src/Hooks/CBasePlayer_ItemPostFrame.cpp @@ -107,10 +107,10 @@ MAKE_HOOK(CBasePlayer_ItemPostFrame, S::CBasePlayer_ItemPostFrame(), void, if (!pStudio) return CALL_ORIGINAL(rcx); - float flReloadTime = pWeapon->SequenceDuration(); + float flReloadTime = pViewmodel->SequenceDuration(); float flReloadSpeed = 1.f / pViewmodel->m_flPlaybackRate(); - float flLastCycle = (I::GlobalVars->curtime - pWeapon->m_flReloadPriorNextFire() - 0.015f) / (flReloadTime * flReloadSpeed); + float flLastCycle = (I::GlobalVars->curtime - pWeapon->m_flReloadPriorNextFire() - TICK_INTERVAL) / (flReloadTime * flReloadSpeed); float flCurrCycle = (I::GlobalVars->curtime - pWeapon->m_flReloadPriorNextFire()) / (flReloadTime * flReloadSpeed); animevent_t event; int index = 0; diff --git a/Amalgam/src/Hooks/Cbuf_ExecuteCommand.cpp b/Amalgam/src/Hooks/Cbuf_ExecuteCommand.cpp index 8846774c..9e174f5a 100644 --- a/Amalgam/src/Hooks/Cbuf_ExecuteCommand.cpp +++ b/Amalgam/src/Hooks/Cbuf_ExecuteCommand.cpp @@ -13,7 +13,7 @@ enum cmd_source_t static std::string sCmdString; #define PRE_STR "\x07\x07\x07\x07\x07\x07\x07" -static std::vector> vReplace = { +static std::vector> vStatic = { { "\\x1", "\x1" }, { "\\x01", "\x1" }, { "\\x2", PRE_STR"\x2" }, @@ -31,10 +31,6 @@ static std::vector> vReplace = { { "\\x8", PRE_STR"\x8" }, { "\\x08", PRE_STR"\x8" }, - { "\\t", "\t" }, - //{ "\\n", "\n" }, - //{ "\\0", "0" }, - { "\\{default}", "\x1" }, { "\\{clear}", PRE_STR"\x8""00000000" }, { "\\{red}", PRE_STR"\x7""ff0000" }, @@ -66,8 +62,55 @@ static std::vector> vReplace = { { "\\{assassin}", PRE_STR"\x7""d32ce6" }, { "\\{commando}", PRE_STR"\x7""8847ff" }, { "\\{mercenary}", PRE_STR"\x7""4b69ff" }, + + { "\\t", "\t" }, }; -static std::vector> vRegex = { +static std::vector> vDynamic = { + [&]() + { + auto pResource = H::Entities.GetPR(); + if (!pResource) + return; + + std::string sFind = "\\{self}"; + std::string sReplace = pResource->GetPlayerName(I::EngineClient->GetLocalPlayer()); + + size_t iPos = 0; + while (true) + { + auto iFind = sCmdString.find(sFind, iPos); + if (iFind == std::string::npos) + break; + + iPos = iFind + sReplace.length(); + sCmdString = sCmdString.replace(iFind, sFind.length(), sReplace); + } + }, + [&]() + { + auto pResource = H::Entities.GetPR(); + if (!pResource) + return; + + std::string sFind = "\\{team}"; + std::string sReplace = PRE_STR"\x7""cccccc"; + switch (pResource->GetTeam(I::EngineClient->GetLocalPlayer())) + { + case TF_TEAM_BLUE: sReplace = PRE_STR"\x7""99ccff"; break; + case TF_TEAM_RED: sReplace = PRE_STR"\x7""ff4040"; break; + } + + size_t iPos = 0; + while (true) + { + auto iFind = sCmdString.find(sFind, iPos); + if (iFind == std::string::npos) + break; + + iPos = iFind + sReplace.length(); + sCmdString = sCmdString.replace(iFind, sFind.length(), sReplace); + } + }, [&]() { auto sRegex = R"(\\\{rgb:(\d+),(\d+),(\d+)\})"; @@ -164,51 +207,24 @@ static std::vector> vRegex = { }, [&]() { - auto sRegex = R"(\\\{(\d+)(?:s| )\})"; + auto sRegex = R"(\\\{(\d+):(.+)\})"; while (true) { std::smatch match; std::regex_search(sCmdString, match, std::regex(sRegex)); - if (match.size() != 2) + if (match.size() != 3) break; int n = std::stoi(match[1]); + auto str = match[2].str(); - sCmdString = sCmdString.replace(match.position(), match.length(), std::string(n, ' ')); + std::ostringstream sStream; + for (int i = 0; i < n; i++) + sStream << str; + + sCmdString = sCmdString.replace(match.position(), match.length(), sStream.str()); } }, - [&]() - { - auto sRegex = R"(\\\{(\d+)t\})"; - - while (true) - { - std::smatch match; std::regex_search(sCmdString, match, std::regex(sRegex)); - if (match.size() != 2) - break; - - int n = std::stoi(match[1]); - - sCmdString = sCmdString.replace(match.position(), match.length(), std::string(n, '\t')); - } - }, - /* - [&]() - { - auto sRegex = R"(\\\{(\d+)n\})"; - - while (true) - { - std::smatch match; std::regex_search(sCmdString, match, std::regex(sRegex)); - if (match.size() != 2) - break; - - int n = std::stoi(match[1]); - - sCmdString = sCmdString.replace(match.position(), match.length(), std::string(n, '\n')); - } - }, - */ }; MAKE_HOOK(Cbuf_ExecuteCommand, S::Cbuf_ExecuteCommand(), void, @@ -229,28 +245,23 @@ MAKE_HOOK(Cbuf_ExecuteCommand, S::Cbuf_ExecuteCommand(), void, sCmdString = args.m_pArgSBuffer; sCmdString = sCmdString.replace(0, args.m_nArgv0Size, ""); - for (auto& pReplace : vReplace) + for (auto& [sFind, sReplace] : vStatic) { size_t iPos = 0; while (true) { - std::string sFind = pReplace.first; - std::string sReplace = pReplace.second; - auto iFind = sCmdString.find(sFind, iPos); if (iFind == std::string::npos) break; iPos = iFind + sReplace.length(); sCmdString = sCmdString.replace(iFind, sFind.length(), sReplace); - //if (FNV1A::Hash32(sFind.c_str()) == FNV1A::Hash32Const("\\0")) - // sCmdString[iFind + 1] = '\0'; } } - for (auto& fRegex : vRegex) + for (auto& fRegex : vDynamic) fRegex(); - sCmdString = std::format("{} {}", sCommand, sCmdString); + sCmdString = std::format("{} {}", sCommand, sCmdString).substr(0, COMMAND_MAX_LENGTH - 1); strncpy_s(args.m_pArgSBuffer, sCmdString.c_str(), COMMAND_MAX_LENGTH); args.m_nArgv0Size = int(sCommand.length() + 1); } diff --git a/Amalgam/src/SDK/Definitions/Main/CBaseAnimating.h b/Amalgam/src/SDK/Definitions/Main/CBaseAnimating.h index f30c5360..cba66ed8 100644 --- a/Amalgam/src/SDK/Definitions/Main/CBaseAnimating.h +++ b/Amalgam/src/SDK/Definitions/Main/CBaseAnimating.h @@ -160,6 +160,15 @@ public: { return S::CBaseAnimating_SequenceDuration.Call(this); } + + inline float SequenceDuration(int iSequence) + { + int iOriginalSequence = m_nSequence(); + m_nSequence() = iSequence; + bool bReturn = S::CBaseAnimating_SequenceDuration.Call(this); + m_nSequence() = iOriginalSequence; + return bReturn; + } }; class CBaseAnimatingOverlay : public CBaseAnimating diff --git a/Amalgam/src/SDK/SDK.cpp b/Amalgam/src/SDK/SDK.cpp index 302fbba2..cea0338c 100644 --- a/Amalgam/src/SDK/SDK.cpp +++ b/Amalgam/src/SDK/SDK.cpp @@ -67,19 +67,22 @@ void SDK::Output(const char* cFunction, const char* cLog, Color_t tColor, } } -#pragma warning (push) -#pragma warning (disable : 4996) void SDK::SetClipboard(std::string sString) { if (OpenClipboard(nullptr)) { EmptyClipboard(); - HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, sString.length() + 1); - char* buffer = (char*)GlobalLock(clipbuffer); - strncpy(buffer, sString.c_str(), sString.length()); - GlobalUnlock(clipbuffer); - SetClipboardData(CF_TEXT, clipbuffer); + if (HGLOBAL hMemory = GlobalAlloc(GMEM_DDESHARE, sString.length() + 1)) + { + if (void* pData = GlobalLock(hMemory)) + { + memset(pData, 0, sString.length() + 1); + memcpy(pData, sString.c_str(), sString.length()); + GlobalUnlock(hMemory); + SetClipboardData(CF_TEXT, hMemory); + } + } CloseClipboard(); } @@ -90,13 +93,13 @@ std::string SDK::GetClipboard() std::string sString = ""; if (OpenClipboard(nullptr)) { - sString = (char*)GetClipboardData(CF_TEXT); + if (void* pData = GetClipboardData(CF_TEXT)) + sString = (char*)(pData); CloseClipboard(); } return sString; } -#pragma warning (pop) HWND SDK::GetTeamFortressWindow() { diff --git a/Amalgam/src/Utils/CrashLog/CrashLog.cpp b/Amalgam/src/Utils/CrashLog/CrashLog.cpp index e2cbd50b..4c5fafa1 100644 --- a/Amalgam/src/Utils/CrashLog/CrashLog.cpp +++ b/Amalgam/src/Utils/CrashLog/CrashLog.cpp @@ -99,7 +99,6 @@ static LONG APIENTRY ExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo) static std::unordered_map mAddresses = {}; static bool bException = false; - // unsure of a way to filter nonfatal exceptions if (ExceptionInfo->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION || !ExceptionInfo->ExceptionRecord->ExceptionAddress || mAddresses.contains(ExceptionInfo->ExceptionRecord->ExceptionAddress) || !Vars::Debug::CrashLogging.Value