diff --git a/src/animation.cpp b/src/animation.cpp index 1d170e8..f60bf50 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -295,7 +295,7 @@ void Animation::Draw() ImGui::EndChild(); } } - + ImGui::EndTabItem(); } if (ImGui::BeginTabItem("Custom")) diff --git a/src/animation.h b/src/animation.h index 7cce83a..f402de9 100644 --- a/src/animation.h +++ b/src/animation.h @@ -4,7 +4,6 @@ class Animation { private: - // Animation player static inline ResourceStore m_AnimData{ "animation", eResourceType::TYPE_TEXT }; static inline char m_nAnimBuffer[INPUT_BUFFER_SIZE]; @@ -13,7 +12,7 @@ private: static inline bool m_bSecondary; // play animation as secondary static inline bool m_PedAnim; static inline CPed *m_pTarget = nullptr; - + #ifdef GTASA // Cutscene player struct m_Cutscene @@ -36,21 +35,18 @@ private: }; #endif -protected: - Animation(); - -public: - static void Draw(); static void PlayAnimation(std::string& rootKey, std::string& anim, std::string& ifp); static void RemoveAnimation(std::string& rootKey, std::string& anim, std::string& ifp); - #ifdef GTASA static void PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior); #elif GTAVC static bool _LoadAnimationBlock(const char* szBlockName); #endif - #ifndef GTASA static void _PlayAnimation(RpClump* pClump, int animGroup, int animID, float blend); #endif + +public: + Animation(); + static void Draw(); }; \ No newline at end of file diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index a5ab878..6ffbf1e 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -1,6 +1,6 @@ #include "pch.h" #include "cheatMenu.h" -#include "menuinfo.h" +#include "version.h" #include "ui.h" #include "updater.h" #include "d3dhook.h" @@ -81,7 +81,7 @@ CheatMenu::CheatMenu() { return; } - + ApplyStyle(); // Load menu settings diff --git a/src/d3dhook.cpp b/src/d3dhook.cpp index 7c310bc..1adb4f3 100644 --- a/src/d3dhook.cpp +++ b/src/d3dhook.cpp @@ -50,9 +50,8 @@ void D3dHook::ProcessFrame(void* ptr) } ImGuiIO& io = ImGui::GetIO(); - static bool bInit = false; - - if (bInit) + static bool init; + if (init) { ProcessMouse(); @@ -116,12 +115,11 @@ void D3dHook::ProcessFrame(void* ptr) } else { - bInit = true; + init = true; ImGui_ImplWin32_Init(RsGlobal.ps->window); #ifdef GTASA - // shift trigger fix - patch::Nop(0x00531155, 5); + patch::Nop(0x00531155, 5); // shift trigger fix #endif if (gRenderer == Render_DirectX9) @@ -191,7 +189,7 @@ void D3dHook::ProcessMouse() bMouseDisabled = true; #ifdef GTA3 pad->m_bDisablePlayerControls = true; -#else +#else pad->DisablePlayerControls = true; #endif } @@ -200,7 +198,7 @@ void D3dHook::ProcessMouse() bMouseDisabled = false; #ifdef GTA3 pad->m_bDisablePlayerControls = false; -#else +#else pad->DisablePlayerControls = false; #endif } @@ -245,8 +243,14 @@ void D3dHook::ProcessMouse() bool D3dHook::InjectHook(void *pCallback) { + static bool hookInjected; + if (hookInjected) + { + return false; + } + ImGui::CreateContext(); - + /* Must check for d3d9 first! Seems to crash with nvidia geforce experience overlay @@ -258,8 +262,7 @@ bool D3dHook::InjectHook(void *pCallback) kiero::bind(16, (void**)&oReset, hkReset); kiero::bind(42, (void**)&oEndScene, hkEndScene); pCallbackFunc = pCallback; - - return true; + hookInjected = true; } else { @@ -269,12 +272,11 @@ bool D3dHook::InjectHook(void *pCallback) gRenderer = Render_DirectX11; kiero::bind(8, (void**)&oPresent, hkPresent); pCallbackFunc = pCallback; - - return true; + hookInjected = true; } } - return false; + return hookInjected; } void D3dHook::RemoveHook() diff --git a/src/d3dhook.h b/src/d3dhook.h index 3a3ccf9..5fefd5c 100644 --- a/src/d3dhook.h +++ b/src/d3dhook.h @@ -5,17 +5,17 @@ class D3dHook { private: using f_EndScene = HRESULT(CALLBACK*)(IDirect3DDevice9*); - using f_Present11 = HRESULT(CALLBACK*)(IDXGISwapChain*, UINT, UINT); + using f_Present = HRESULT(CALLBACK*)(IDXGISwapChain*, UINT, UINT); using f_Reset = HRESULT(CALLBACK*)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*); static inline WNDPROC oWndProc; - static inline f_Present11 oPresent; + static inline f_Present oPresent; static inline f_EndScene oEndScene; static inline f_Reset oReset; static inline bool mouseShown; static inline void* pCallbackFunc = nullptr; - + static void CALLBACK ProcessFrame(void* ptr); static LRESULT CALLBACK hkWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static void ProcessMouse(); @@ -28,13 +28,13 @@ private: static HRESULT CALLBACK hkPresent(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags); public: - + D3dHook() = delete; - D3dHook(D3dHook const&) = delete; - void operator=(D3dHook const&) = delete; + D3dHook(D3dHook const&) = delete; + void operator=(D3dHook const&) = delete; static bool GetMouseState(); - static bool InjectHook(void *pCallback); - static void RemoveHook(); + static bool InjectHook(void *pCallback); + static void RemoveHook(); static void SetMouseState(bool state); }; diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 98ec276..c76b436 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -1,23 +1,12 @@ #include "pch.h" #include "cheatmenu.h" #include "updater.h" -#include "menuinfo.h" -#include "d3dhook.h" +#include "version.h" void MenuThread(void* param) { - static bool gameInit; - - // Wait till game init - Events::initRwEvent += [] - { - gameInit = true; - }; - - while (!gameInit) - { - Sleep(1000); - } + // wait for game init + Sleep(3000); /* Had to put this in place since some people put the folder in root @@ -46,11 +35,11 @@ void MenuThread(void* param) return; } -#ifdef GTASA /* TODO: Find a better way Since you could still name it something else */ +#ifdef GTASA if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi")) { gLog << "Error: CheatMenu doesn't support SAMP" << std::endl; @@ -58,6 +47,13 @@ void MenuThread(void* param) return; } CFastman92limitAdjuster::Init(); +#elif GTAVC + if (GetModuleHandle("vcmp-proxy.dll") || GetModuleHandle("vcmp-proxy.asi")) + { + gLog << "Error: CheatMenu doesn't support VCMP" << std::endl; + MessageBox(RsGlobal.ps->window, "VCMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR); + return; + } #endif gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: " @@ -69,12 +65,10 @@ void MenuThread(void* param) // Checking for updates once a day time_t now = time(0); struct tm tstruct = *localtime(&now); - int lastCheckDate = gConfig.GetValue("config.last_update_checked", 0); - - if (lastCheckDate != tstruct.tm_mday) + if (gConfig.GetValue("config.update_date", 0) != tstruct.tm_mday) { Updater::CheckUpdate(); - gConfig.SetValue("config.last_update_checked", tstruct.tm_mday); + gConfig.SetValue("config.update_date", tstruct.tm_mday); } while (true) diff --git a/src/game.h b/src/game.h index 1ab5d23..f386c84 100644 --- a/src/game.h +++ b/src/game.h @@ -3,14 +3,12 @@ class Game { -public: +private: static inline ResourceStore m_MissionData{ "mission", eResourceType::TYPE_TEXT }; - static inline bool m_bDisableCheats; static inline bool m_bDisableReplay; static inline bool m_bMissionTimer; - static inline bool m_bFreezeTime; - static inline bool m_bSyncTime; + #ifdef GTASA static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea static inline bool m_bSolidWater; // walk on water hack @@ -56,13 +54,18 @@ public: #endif - Game(); - static void Draw(); static void RealTimeClock(); - #ifdef GTASA // TODO: Update freecam with aap's code static void FreeCam(); static void ClearFreecamStuff(); #endif + +public: + static inline bool m_bFreezeTime; + static inline bool m_bSyncTime; + + Game(); + static void Draw(); + }; diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 9b787f6..dca3a75 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -1,20 +1,6 @@ #include "pch.h" #include "hotkeys.h" -Hotkey aimSkinChanger; -Hotkey freeCam; -Hotkey commandWindow; -Hotkey fixVeh; -Hotkey flipVeh; -Hotkey freeCamTeleportPlayer; -Hotkey godMode; -Hotkey menuOpen; -Hotkey quickSceenShot; -Hotkey quickTeleport; -Hotkey vehEngine; -Hotkey vehInstantStart; -Hotkey vehInstantStop; - bool Hotkey::DrawUI(const char* label) { bool active = (m_CurrentHotkey == label); diff --git a/src/hotkeys.h b/src/hotkeys.h index 986c9bb..b98b3d7 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -23,17 +23,3 @@ public: bool Pressed(); std::string GetNameString(); }; - -extern Hotkey aimSkinChanger; -extern Hotkey freeCam; -extern Hotkey commandWindow; -extern Hotkey fixVeh; -extern Hotkey flipVeh; -extern Hotkey freeCamTeleportPlayer; -extern Hotkey godMode; -extern Hotkey menuOpen; -extern Hotkey quickSceenShot; -extern Hotkey quickTeleport; -extern Hotkey vehEngine; -extern Hotkey vehInstantStart; -extern Hotkey vehInstantStop; diff --git a/src/menu.cpp b/src/menu.cpp index 073c137..ef77850 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -1,5 +1,5 @@ #include "pch.h" -#include "menuinfo.h" +#include "version.h" #include "menu.h" #include "ui.h" #include "util.h" diff --git a/src/pch.cpp b/src/pch.cpp index 4cf4fc9..6bc32aa 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -1,2 +1,16 @@ #include "pch.h" -CJson gConfig = CJson("config"); \ No newline at end of file +CJson gConfig = CJson("config"); + +Hotkey aimSkinChanger; +Hotkey freeCam; +Hotkey commandWindow; +Hotkey fixVeh; +Hotkey flipVeh; +Hotkey freeCamTeleportPlayer; +Hotkey godMode; +Hotkey menuOpen; +Hotkey quickSceenShot; +Hotkey quickTeleport; +Hotkey vehEngine; +Hotkey vehInstantStart; +Hotkey vehInstantStop; \ No newline at end of file diff --git a/src/pch.h b/src/pch.h index e367a67..132a938 100644 --- a/src/pch.h +++ b/src/pch.h @@ -104,4 +104,18 @@ static void SetHelpMessage(const char *message, bool b1, bool b2, bool b3) CHud::SetHelpMessage(wc, b1); delete wc; #endif -} \ No newline at end of file +} + +extern Hotkey aimSkinChanger; +extern Hotkey freeCam; +extern Hotkey commandWindow; +extern Hotkey fixVeh; +extern Hotkey flipVeh; +extern Hotkey freeCamTeleportPlayer; +extern Hotkey godMode; +extern Hotkey menuOpen; +extern Hotkey quickSceenShot; +extern Hotkey quickTeleport; +extern Hotkey vehEngine; +extern Hotkey vehInstantStart; +extern Hotkey vehInstantStop; \ No newline at end of file diff --git a/src/ped.h b/src/ped.h index 57a1c7a..d3a286f 100644 --- a/src/ped.h +++ b/src/ped.h @@ -41,8 +41,15 @@ private: #endif }; }; -public: +#ifdef GTASA + static void SpawnPed(std::string& model); + static void BigHeadEffect(CPed *ped); +#else + static void SpawnPed(std::string& cat, std::string& name, std::string& model); +#endif + +public: #ifdef GTASA static inline CJson m_SpecialPedJson = CJson("ped special"); static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)}; @@ -53,11 +60,4 @@ public: Ped(); ~Ped(); static void Draw(); - -#ifdef GTASA - static void SpawnPed(std::string& model); - static void BigHeadEffect(CPed *ped); -#else - static void SpawnPed(std::string& cat, std::string& name, std::string& model); -#endif }; diff --git a/src/player.cpp b/src/player.cpp index 66e7c04..a2ba252 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -7,29 +7,6 @@ #ifdef GTASA #include "ped.h" -// hardcoded cloth category names -const char* cloth_category[18] = -{ - "Shirts", - "Heads", - "Trousers", - "Shoes", - "Tattoos left lower arm", - "Tattoos left upper arm", - "Tattoos right upper arm", - "Tattoos right lower arm", - "Tattoos back", - "Tattoos left chest", - "Tattoos right chest", - "Tattoos stomach", - "Tattoos lower back", - "Necklaces", - "Watches", - "Glasses", - "Hats", - "Extras" -}; - static inline void PlayerModelBrokenFix() { CPlayerPed* pPlayer = FindPlayerPed(); @@ -147,7 +124,7 @@ Player::Player() CPlayerPed* player = FindPlayerPed(); int hplayer = CPools::GetPedRef(player); - if (m_bAutoHeal) + if (m_bHealthRegen) { static uint lastDmgTimer = 0; static uint lastHealTimer = 0; @@ -417,7 +394,6 @@ void Player::Draw() ImGui::BeginChild("CheckboxesChild"); ImGui::Columns(2, 0, false); - Ui::CheckboxWithHint("Auto heal", &m_bAutoHeal, "Player will heal when not taken damage for 5 seconds"); #ifdef GTASA Ui::CheckboxAddress("Bounty on yourself", 0x96913F); @@ -469,6 +445,7 @@ void Player::Draw() pPlayer->m_nEntityFlags.bMeleeProof = m_bGodMode; #endif } + Ui::CheckboxWithHint("Health regeneration", &m_bHealthRegen, "Player heals if not taken damage for 5 seconds"); #ifdef GTASA Ui::CheckboxAddress("Higher cycle jumps", 0x969161); Ui::CheckboxAddress("Infinite oxygen", 0x96916E); @@ -759,7 +736,7 @@ void Player::Draw() getline(ss, temp, '$'); return temp; - }, nullptr, cloth_category, sizeof(cloth_category) / sizeof(const char*)); + }, nullptr, clothNameList, sizeof(clothNameList) / sizeof(const char*)); } else { @@ -792,7 +769,7 @@ void Player::Draw() CClothes::RebuildPlayer(player, false); } ImGui::SameLine(); - for (const char* clothName : cloth_category) + for (const char* clothName : clothNameList) { if (ImGui::Button(clothName, ImVec2(Ui::GetSize(2)))) { diff --git a/src/player.h b/src/player.h index a5846c3..44c6e17 100644 --- a/src/player.h +++ b/src/player.h @@ -4,7 +4,7 @@ class Player { private: - static inline bool m_bAutoHeal; + static inline bool m_bHealthRegen; static inline bool m_bGodMode; static inline bool m_bModloaderInstalled; struct m_KeepPosition @@ -31,14 +31,18 @@ private: static inline bool m_bEnabled = false; static inline float m_fOffset = 40.0f; }; + + static inline const char* clothNameList[18] = + { + "Shirts", "Heads", "Trousers", "Shoes", "Tattoos left lower arm", "Tattoos left upper arm", + "Tattoos right upper arm", "Tattoos right lower arm", "Tattoos back", "Tattoos left chest", + "Tattoos right chest", "Tattoos stomach", "Tattoos lower back", "Necklaces", "Watches", + "Glasses", "Hats", "Extras" + }; #else static inline ResourceStore skinData { BY_GAME(NULL, "skin", "ped"), eResourceType::TYPE_TEXT }; #endif -public: - Player(); - static void Draw(); - #ifdef GTASA static void ChangePlayerModel(std::string& model); static void ChangePlayerCloth(std::string& model); @@ -46,4 +50,8 @@ public: #else static void ChangePlayerModel(std::string& cat, std::string& name, std::string& id); #endif + +public: + Player(); + static void Draw(); }; diff --git a/src/teleport.h b/src/teleport.h index af9497f..0d032d2 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -32,11 +32,12 @@ private: static void FetchRadarSpriteData(); #endif -protected: - Teleport(); -public: - static void Draw(); - static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0); static void TeleportToLocation(std::string& rootkey, std::string& bLocName, std::string& loc); static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val); + +public: + Teleport(); + + static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0); + static void Draw(); }; diff --git a/src/ui.cpp b/src/ui.cpp index 86ed619..05b1df9 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -2,7 +2,7 @@ #include "util.h" #include "ui.h" #include "../depend/imgui/imgui_internal.h" -#include "menuinfo.h" +#include "version.h" // Really messy code, cleanup someday bool Ui::DrawTitleBar() diff --git a/src/updater.cpp b/src/updater.cpp index 619039c..1d03bae 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -1,6 +1,6 @@ #include "pch.h" #include "updater.h" -#include "menuinfo.h" +#include "version.h" bool Updater::IsUpdateAvailable() { diff --git a/src/util.cpp b/src/util.cpp index ec0a9d3..d76ffb2 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -10,7 +10,7 @@ void Util::SetCarForwardSpeed(CVehicle *pVeh, float speed) pVeh->m_vecMoveSpeed.x = speedFactor * inVec.x; pVeh->m_vecMoveSpeed.y = speedFactor * inVec.y; pVeh->m_vecMoveSpeed.z = speedFactor * inVec.z; -#else +#else Command(CPools::GetVehicleRef(pVeh), 0); #endif } diff --git a/src/vehicle.h b/src/vehicle.h index 18e3f87..f313ec6 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -91,6 +91,8 @@ private: #endif public: + Vehicle(); + ~Vehicle(); #ifdef GTASA static void SpawnVehicle(std::string& name); #else @@ -99,6 +101,4 @@ public: static std::string GetNameFromModel(int model); static int GetModelFromName(const char* name); static void Draw(); - Vehicle(); - ~Vehicle(); }; diff --git a/src/menuinfo.h b/src/version.h similarity index 100% rename from src/menuinfo.h rename to src/version.h diff --git a/src/visual.h b/src/visual.h index be8047c..8cf7243 100644 --- a/src/visual.h +++ b/src/visual.h @@ -38,6 +38,7 @@ private: static bool TimeCycColorEdit4(const char* label, T* r, T* g, T* b, T* a, ImGuiColorEditFlags flags = 0); template static void TimecycSlider(const char* label, T* data, int min, int max); + public: Visual(); static void Draw(); diff --git a/src/weapon.h b/src/weapon.h index 942856d..81043cf 100644 --- a/src/weapon.h +++ b/src/weapon.h @@ -3,10 +3,8 @@ class Weapon { -public: +private: #ifdef GTASA - static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65) }; - static inline bool m_bAutoAim; static inline bool m_bRapidFire; static inline bool m_bDualWeild; @@ -33,7 +31,6 @@ public: "Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10" }; #else - static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_TEXT }; static inline bool m_bInfiniteAmmo; #endif static inline bool m_bFastReload; @@ -43,13 +40,18 @@ public: static inline uchar m_nCurrentWeaponSlot = -1; static inline int m_nSelectedWeapon; - Weapon(); - static void Draw(); - +public: #ifdef GTASA + static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65) }; + static void GiveWeaponToPlayer(std::string& weapon_type); static void SetGangWeapon(std::string& weapon_type); #else + static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_TEXT }; + static void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name); #endif + + Weapon(); + static void Draw(); };