From c9b430eca71ebe133d77a0171ad9b02bfdf59367 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Fri, 22 Oct 2021 04:23:02 +0600 Subject: [PATCH] Setup gta 3 build sys --- .vscode/c_cpp_properties.json | 8 ++- .vscode/launch.json | 11 ++++ .vscode/tasks.json | 56 +++++++++++++++++- resource/VC/CheatMenu/json/teleport.json | 3 - src/animation.h | 2 +- src/cheatmenu.cpp | 6 +- src/cheatmenu.h | 22 ++++++-- src/dllmain.cpp | 8 ++- src/hook.cpp | 35 ++++++++---- src/menu.cpp | 6 +- src/menuinfo.h | 2 +- src/pch.h | 23 +++++--- src/util.cpp | 12 ++-- src/vehicle.h | 2 +- src/visual.h | 2 +- tools/DebugIII.bat | 7 +++ tools/ReleaseIII.bat | 7 +++ tools/premake5.lua | 72 ++++++++++++++++++++++++ 18 files changed, 233 insertions(+), 51 deletions(-) create mode 100644 tools/DebugIII.bat create mode 100644 tools/ReleaseIII.bat diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index aa011ad..f2b4175 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -6,10 +6,12 @@ "${workspaceFolder}/**", "${PLUGIN_SDK_DIR}/*", "${DIRECTX9_SDK_DIR}/Include/*", - "${PLUGIN_SDK_DIR}/plugin_sa/*", - "${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*", + // "${PLUGIN_SDK_DIR}/plugin_sa/*", + // "${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*", // "${PLUGIN_SDK_DIR}/plugin_vc/*", // "${PLUGIN_SDK_DIR}/plugin_vc/game_vc/*", + "${PLUGIN_SDK_DIR}/plugin_III/*", + "${PLUGIN_SDK_DIR}/plugin_III/game_III/*", "${PLUGIN_SDK_DIR}/shared/*", "${PLUGIN_SDK_DIR}/shared/game/*", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\*", @@ -20,7 +22,7 @@ "IS_PLATFORM_WIN", "_CRT_SECURE_NO_WARNINGS", "_CRT_NON_CONFORMING_SWPRINTFS", - "GTASA", + "GTA3", "_DX9_SDK_INSTALLED", "PLUGIN_SGV_10US" ], diff --git a/.vscode/launch.json b/.vscode/launch.json index 34015be..be6a328 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -26,6 +26,17 @@ "environment": [], "console": "internalConsole" }, + { + "name": "Launch III", + "type": "cppvsdbg", + "request": "launch", + "program": "E:/GTA3/Gta3.exe", + "args": [], + "stopAtEntry": false, + "cwd": "F:/GTASanAndreas/", + "environment": [], + "console": "internalConsole" + }, { "name": "Attach", "type": "cppvsdbg", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index dc6a68e..0e8e364 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -110,6 +110,60 @@ } } }, - } + }, + { + "label": "Build DebugIII", + "type": "shell", + "command": "${workspaceFolder}/tools/DebugIII.bat", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + }, + "group": { + "kind": "build", + "isDefault": true + }, + "windows": { + "options": { + "shell": { + "executable": "cmd.exe", + "args": [ + "/d", "/c" + ] + } + } + }, + }, + { + "label": "Build ReleaseIII", + "type": "shell", + "command": "${workspaceFolder}/tools/ReleaseIII.bat", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + }, + "group": { + "kind": "build", + "isDefault": true + }, + "windows": { + "options": { + "shell": { + "executable": "cmd.exe", + "args": [ + "/d", "/c" + ] + } + } + }, + }, ] } \ No newline at end of file diff --git a/resource/VC/CheatMenu/json/teleport.json b/resource/VC/CheatMenu/json/teleport.json index 36df02c..c4192f1 100644 --- a/resource/VC/CheatMenu/json/teleport.json +++ b/resource/VC/CheatMenu/json/teleport.json @@ -3,9 +3,6 @@ "Washington Ammunation": "0, -65, -1479, 10", "Washington Beach Ammunation": "0, 200, -474, 11" }, - "Custom": { - "Test": "0, -825, 1168, 10" - }, "Misc": { "1102 Safe House": "0, 95, -808, 10", "Air Reserve Fort": "0, -1731, -307, 14", diff --git a/src/animation.h b/src/animation.h index 5a0786e..77f40e1 100644 --- a/src/animation.h +++ b/src/animation.h @@ -44,6 +44,6 @@ public: }; #else -// Dummy Class for GTAVC +// Dummy Class for VC & III class Animation{}; #endif \ No newline at end of file diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index 7d9e40c..8a834e2 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -9,7 +9,7 @@ void CheatMenu::DrawWindow() ImGuiIO& io = ImGui::GetIO(); static bool bRunning = true; - if (BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible)) + if (BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, FrontEndMenuManager.m_bMenuActive)) { if (bRunning) { @@ -21,7 +21,7 @@ void CheatMenu::DrawWindow() else { bRunning = true; - if (m_bShowMenu || BY_GAME(m_Commands::m_bShowMenu, true)) + if (m_bShowMenu || BY_GAME(m_Commands::m_bShowMenu, true, true)) { if (m_bShowMenu) { @@ -78,7 +78,7 @@ CheatMenu::CheatMenu() Events::processScriptsEvent += []() { - if (!BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible)) + if (!BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, FrontEndMenuManager.m_bMenuActive)) { if (menuOpen.Pressed()) { diff --git a/src/cheatmenu.h b/src/cheatmenu.h index 414a7ea..443fbcf 100644 --- a/src/cheatmenu.h +++ b/src/cheatmenu.h @@ -9,9 +9,8 @@ */ #pragma once +#ifndef GTA3 #include "animation.h" -#include "hook.h" -#include "menu.h" #include "teleport.h" #include "player.h" #include "ped.h" @@ -19,24 +18,35 @@ #include "weapon.h" #include "game.h" #include "visual.h" +#endif +#include "menu.h" +#include "hook.h" +#ifndef GTA3 class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon +#else +class CheatMenu : Hook, Menu +#endif { private: static inline bool m_bShowMenu = false; static inline ImVec2 m_fMenuSize = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2); - + +#ifdef GTA3 + static inline CallbackTable header + { + {"Menu", &Menu::Draw} + }; +#else static inline CallbackTable header { {"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw}, -#ifdef GTASA {"Animation", &Animation::Draw}, -#elif GTAVC {"Dummy", nullptr}, -#endif {"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw}, {"Game", &Game::Draw}, {"Visual", &Visual::Draw}, {"Menu", &Menu::Draw} }; +#endif static void ApplyStyle(); static void DrawWindow(); diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 36fac0a..d3f25af 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -35,6 +35,7 @@ void MenuThread(void* param) Sleep(1000); } +#ifdef GTASA /* TODO: Find a better way Since you could still name it something else @@ -44,10 +45,11 @@ void MenuThread(void* param) MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR); return; } + CFastman92limitAdjuster::Init(); +#endif gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: " GITHUB_LINK "\n" << std::endl; - CFastman92limitAdjuster::Init(); CheatMenu menu; @@ -79,7 +81,7 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) { uint gameVersion = GetGameVersion(); - if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN)) + if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN)) { CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr); } @@ -89,6 +91,8 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR); #elif GTAVC MessageBox(HWND_DESKTOP, "Unknown game version. GTA VC v1.0 EN is required.", "CheatMenu", MB_ICONERROR); +#else // GTA3 + MessageBox(HWND_DESKTOP, "Unknown game version. GTA III v1.0 EN is required.", "CheatMenu", MB_ICONERROR); #endif } } diff --git a/src/hook.cpp b/src/hook.cpp index 8d21116..415ed1a 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -109,10 +109,7 @@ void Hook::RenderFrame(void* ptr) else { bInit = true; - ImGui::CreateContext(); - ImGuiStyle& style = ImGui::GetStyle(); - ImGui_ImplWin32_Init(RsGlobal.ps->window); #ifdef GTASA @@ -159,16 +156,15 @@ HRESULT Hook::Dx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Fl void Hook::ShowMouse(bool state) { - // Disable player controls for controllers bool bMouseDisabled = false; - if (patch::Get(BY_GAME(0xBA6818, 0x86968B)) && (m_bShowMouse || bMouseDisabled)) + if (patch::Get(BY_GAME(0xBA6818, 0x86968B, 0x5F03D8)) && (m_bShowMouse || bMouseDisabled)) { #ifdef GTASA CPlayerPed *player = FindPlayerPed(); CPad *pad = player ? player->GetPadFromPlayer() : NULL; -#elif GTAVC +#else CPad *pad = CPad::GetPad(0); #endif @@ -177,12 +173,20 @@ void Hook::ShowMouse(bool state) if (m_bShowMouse) { bMouseDisabled = true; +#ifdef GTA3 + pad->m_bDisablePlayerControls = true; +#else //GTAVC & GTASA pad->DisablePlayerControls = true; +#endif } else { bMouseDisabled = false; +#ifdef GTA3 + pad->m_bDisablePlayerControls = false; +#else //GTAVC & GTASA pad->DisablePlayerControls = false; +#endif } } } @@ -193,22 +197,32 @@ void Hook::ShowMouse(bool state) #ifdef GTASA Hook::ApplyMouseFix(); // Reapply the patches -#elif GTAVC +#else if (m_bShowMouse) { - patch::SetUChar(0x6020A0, 0xC3); // psSetMousePos - patch::Nop(0x4AB6CA, 5); // don't call CPad::UpdateMouse() + + patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0xC3); // psSetMousePos + patch::Nop(BY_GAME(0, 0x4AB6CA, 0x49272F), 5); // don't call CPad::UpdateMouse() } else { - patch::SetUChar(0x6020A0, 0x53); + + patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0x53); +#ifdef GTAVC patch::SetRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5); +#else // GTA3 + patch::SetRaw(0x49272F, (char*)"\xE8\x6C\xF5\xFF\xFF", 5); +#endif } #endif CPad::NewMouseControllerState.X = 0; CPad::NewMouseControllerState.Y = 0; +#ifdef GTA3 + CPad::GetPad(0)->ClearMouseHistory(); +#else // GTAVC & GTASA CPad::ClearMouseHistory(); +#endif CPad::UpdatePads(); m_bMouseVisibility = m_bShowMouse; } @@ -322,5 +336,4 @@ void Hook::ApplyMouseFix() patch::SetChar(0x746A08, 32); // diMouseOffset patch::SetChar(0x746A58, 32); // diDeviceoffset } - #endif \ No newline at end of file diff --git a/src/menu.cpp b/src/menu.cpp index 5479d00..bbcc481 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -78,7 +78,7 @@ void Menu::DrawOverlay() if (pPlayer) { bool m_bShowMenu = m_Overlay::bCoord || m_Overlay::bFPS || m_Overlay::bLocName || m_Overlay::bCpuUsage || m_Overlay::bMemUsage || - ((m_Overlay::bVehHealth || m_Overlay::bVehSpeed) && pPlayer && pPlayer->m_pVehicle && pPlayer->m_pVehicle->IsDriver(pPlayer)); + ((m_Overlay::bVehHealth || m_Overlay::bVehSpeed) && pPlayer && pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer); const float offset = 10.0f; ImGuiIO& io = ImGui::GetIO(); @@ -145,7 +145,7 @@ void Menu::DrawOverlay() int mUsedRam = static_cast((memInfo.ullTotalPhys - memInfo.ullAvailPhys) * 1e-6); m_Overlay::fMemUsage = 100.0f * (static_cast(mUsedRam) / static_cast(m_Overlay::mTotalRam)); - m_Overlay::mFPS = static_cast(BY_GAME(CTimer::game_FPS, io.Framerate)); + m_Overlay::mFPS = static_cast(BY_GAME(CTimer::game_FPS, io.Framerate, io.Framerate)); m_Overlay::mLastInterval = game_ms; } @@ -174,7 +174,7 @@ void Menu::DrawOverlay() ImGui::Text("RAM usage: %.2f%%", m_Overlay::fMemUsage); } - if (pPlayer->m_pVehicle && pPlayer->m_pVehicle->IsDriver(pPlayer)) + if (pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer) { if (m_Overlay::bVehHealth) { diff --git a/src/menuinfo.h b/src/menuinfo.h index da99d2a..37b6686 100644 --- a/src/menuinfo.h +++ b/src/menuinfo.h @@ -2,5 +2,5 @@ #define MENU_NAME "Cheat Menu" #define MENU_VERSION_NUMBER "3.0" #define MENU_VERSION MENU_VERSION_NUMBER"-beta" -#define BUILD_NUMBER "20211017" +#define BUILD_NUMBER "20211020" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" diff --git a/src/pch.h b/src/pch.h index 4ea2894..22366f5 100644 --- a/src/pch.h +++ b/src/pch.h @@ -7,9 +7,11 @@ #define GITHUB_LINK "https://github.com/user-grinch/Cheat-Menu" #ifdef GTASA -#define BY_GAME(sa, vc) sa +#define BY_GAME(sa, vc, iii) sa #elif GTAVC -#define BY_GAME(sa, vc) vc +#define BY_GAME(sa, vc, iii) vc +#elif GTA3 +#define BY_GAME(sa, vc, iii) iii #endif #include @@ -25,12 +27,10 @@ #include #include "plugin.h" -#include "CBike.h" #include "CCamera.h" #include "CClock.h" #include "CCivilianPed.h" #include "CGangs.h" -#include "cHandlingDataMgr.h" #include "CHud.h" #include "CMenuManager.h" #include "CModelInfo.h" @@ -38,7 +38,6 @@ #include "CStats.h" #include "CStreaming.h" #include "CTheScripts.h" -#include "CTheZones.h" #include "CTimer.h" #include "CTimeCycle.h" #include "CTrain.h" @@ -48,6 +47,12 @@ #include "extensions/Screen.h" #include "extensions/Paths.h" +#ifndef GTA3 +#include "CBike.h" +#include "cHandlingDataMgr.h" +#include "CTheZones.h" +#endif + #ifdef GTASA #include "CCheat.h" #include "CClothes.h" @@ -85,9 +90,11 @@ extern CJson gConfig; // Fix function clashes static void SetHelpMessage(const char *message, bool b1, bool b2, bool b3) { -#if GTAVC - CHud::SetHelpMessage(message, b1, b2); -#elif GTASA +#if GTASA CHud::SetHelpMessage(message, b1, b2, b3); +#elif GTAVC + CHud::SetHelpMessage(message, b1, b2); +#else // GTA3 + CHud::SetHelpMessage((wchar_t*)message, b1); #endif } \ No newline at end of file diff --git a/src/util.cpp b/src/util.cpp index 2ebc5e5..256b1be 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -45,6 +45,8 @@ std::string Util::GetLocationName(CVector* pos) { return "Vice City"; } +#else + return "Liberty City"; #endif } @@ -141,7 +143,7 @@ CPlayerPed* player = FindPlayerPed(); return veh; } return nullptr; -#elif GTAVC +#else // GTAVC & GTA3 CVehicle *pClosestVeh = nullptr; float distance = 999.0f; @@ -183,18 +185,14 @@ CPlayerPed* player = FindPlayerPed(); return ped; } return nullptr; -#elif GTAVC +#else // GTA3 & GTAVC return player->m_apNearPeds[0]; #endif } bool Util::IsOnCutscene() { -#ifdef GTASA - return CCutsceneMgr::ms_running; -#elif GTAVC - return *(bool*)0xA10AB2; // CCutsceneMgr::ms_running -#endif + return BY_GAME(CCutsceneMgr::ms_running, *(bool*)0xA10AB2, *(bool*)0x95CCF5); } void Util::RainbowValues(int& r, int& g, int& b, float speed) diff --git a/src/vehicle.h b/src/vehicle.h index 3ba6af8..e9ca5e2 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -7,7 +7,7 @@ #ifdef GTASA class Vehicle : public Paint, public Neon -#elif GTAVC +#else // GTA3 & GTAVC class Vehicle #endif { diff --git a/src/visual.h b/src/visual.h index aa51076..bc7435a 100644 --- a/src/visual.h +++ b/src/visual.h @@ -41,7 +41,7 @@ void Visual::TimecycSlider(const char* label, T* ptr, int min, int max) #ifdef GTASA // Compatable with 24h TimeCyc T* arr = static_cast(patch::GetPointer(int(ptr))); -#elif GTAVC +#else // GTA3 & GTAVC T* arr = static_cast(ptr); #endif int a = arr[val]; diff --git a/tools/DebugIII.bat b/tools/DebugIII.bat new file mode 100644 index 0000000..f92e363 --- /dev/null +++ b/tools/DebugIII.bat @@ -0,0 +1,7 @@ +@echo off +cd tools +premake5.exe vs2019 +cd ../build +call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat" +MsBuild CheatMenu.sln /property:Configuration=Debug /t:CheatMenuIII +cd .. diff --git a/tools/ReleaseIII.bat b/tools/ReleaseIII.bat new file mode 100644 index 0000000..c367f02 --- /dev/null +++ b/tools/ReleaseIII.bat @@ -0,0 +1,7 @@ +@echo off +cd tools +premake5.exe vs2019 +cd ../build +call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat" +MsBuild CheatMenu.sln /property:Configuration=Release /t:CheatMenuIII +cd .. diff --git a/tools/premake5.lua b/tools/premake5.lua index 482bdf1..d544d40 100644 --- a/tools/premake5.lua +++ b/tools/premake5.lua @@ -7,6 +7,7 @@ PSDK_DIR = os.getenv("PLUGIN_SDK_DIR") DX9SDK_DIR = os.getenv("DIRECTX9_SDK_DIR") GTASA_DIR = "F:/GTASanAndreas" GTAVC_DIR = "E:/GTA Vice City" +GTA3_DIR = "E:/GTA3" if (DX9SDK_DIR == nil) then error("DIRECTX9_SDK_DIR environment variable not set") @@ -47,6 +48,77 @@ project "Depend" defines { "NDEBUG", "IS_PLATFORM_WIN" } optimize "On" +project "CheatMenuIII" + kind "SharedLib" + targetdir (GTA3_DIR) + targetextension ".asi" + + files { + "../src/cheatmenu.h", + "../src/cheatmenu.cpp", + "../src/pch.h", + "../src/pch.cpp", + "../src/hook.h", + "../src/hook.cpp", + "../src/updater.h", + "../src/updater.cpp", + "../src/json.h", + "../src/json.cpp", + "../src/ui.h", + "../src/ui.cpp", + "../src/util.h", + "../src/util.cpp", + "../src/menu.h", + "../src/menu.cpp", + "../src/hotkeys.h", + "../src/hotkeys.cpp", + "../src/dllmain.cpp" + } + includedirs { + PSDK_DIR .. "/plugin_III/", + PSDK_DIR .. "/plugin_III/game_III/", + PSDK_DIR .. "/shared/", + PSDK_DIR .. "/shared/game/" + } + libdirs (PSDK_DIR .. "/output/lib") + + defines { + "NDEBUG", + "IS_PLATFORM_WIN" , + "_CRT_SECURE_NO_WARNINGS", + "_CRT_NON_CONFORMING_SWPRINTFS", + "GTA3", + "_DX9_SDK_INSTALLED", + "PLUGIN_SGV_10US" + } + + pchheader "pch.h" + pchsource "../src/pch.cpp" + + filter "configurations:Debug" + symbols "On" + links { + "Depend", + "d3d9", + "d3d11", + "XInput9_1_0", + "Pdh", + "urlmon", + "plugin_III_d.lib" + } + + filter "configurations:Release" + optimize "On" + links { + "Depend", + "d3d9", + "d3d11", + "XInput9_1_0", + "Pdh", + "urlmon", + "plugin_III.lib" + } + project "CheatMenuVC" kind "SharedLib" targetdir (GTAVC_DIR)