Bug fixes

1. Fixed teleport & animation changes not being saved
2. Fixed crash with renderhook
3. Refactored code
This commit is contained in:
Grinch_ 2021-01-14 00:25:28 +06:00
parent 1ad5b46e0d
commit 3e51f2ff1b
10 changed files with 29 additions and 17 deletions

View File

@ -5,6 +5,7 @@
"includePath": [ "includePath": [
"${workspaceFolder}/src/", "${workspaceFolder}/src/",
"${DIRECTX9_SDK_DIR}/Include", "${DIRECTX9_SDK_DIR}/Include",
"C:/Program Files (x86)/DirectXSDK/Include",
"${PLUGIN_SDK_DIR}/plugin_sa", "${PLUGIN_SDK_DIR}/plugin_sa",
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa", "${PLUGIN_SDK_DIR}/plugin_sa/game_sa",
"${PLUGIN_SDK_DIR}/shared", "${PLUGIN_SDK_DIR}/shared",

View File

@ -138,6 +138,7 @@ void Animation::RemoveAnimation(std::string& ifp, std::string& anim, std::string
if (ifp == "Custom") if (ifp == "Custom")
{ {
json.data["Custom"].erase(anim); json.data["Custom"].erase(anim);
json.WriteToDisk();
CHud::SetHelpMessage("Animation removed", false, false, false); CHud::SetHelpMessage("Animation removed", false, false, false);
}else CHud::SetHelpMessage("You can only remove custom anims", false, false, false); }else CHud::SetHelpMessage("You can only remove custom anims", false, false, false);

View File

@ -39,7 +39,6 @@ public:
Events::initRwEvent += []() Events::initRwEvent += []()
{ {
bool launch = true; bool launch = true;
uint gameVersion = GetGameVersion(); uint gameVersion = GetGameVersion();
if (gameVersion != GAME_10US_HOODLUM && gameVersion != GAME_10US_COMPACT) { if (gameVersion != GAME_10US_HOODLUM && gameVersion != GAME_10US_COMPACT) {
MessageBox(HWND_DESKTOP, "CheatMenu requires v1.0 US of the game.", "CheatMenu", MB_ICONERROR); MessageBox(HWND_DESKTOP, "CheatMenu requires v1.0 US of the game.", "CheatMenu", MB_ICONERROR);

View File

@ -287,7 +287,7 @@ void Game::Main()
Ui::CheckboxAddress("Faster clock", 0x96913B); Ui::CheckboxAddress("Faster clock", 0x96913B);
if (Ui::CheckboxWithHint("Forbidden area wl", &forbidden_area_wl, "Wanted levels that appears outside\ if (Ui::CheckboxWithHint("Forbidden area wl", &forbidden_area_wl, "Wanted levels that appears outside \
of LS without completing missions")) of LS without completing missions"))
{ {
if (forbidden_area_wl) if (forbidden_area_wl)
@ -308,7 +308,8 @@ of LS without completing missions"))
Command<Commands::SWITCH_ARREST_PENALTIES>(keep_stuff); Command<Commands::SWITCH_ARREST_PENALTIES>(keep_stuff);
Command<Commands::SWITCH_DEATH_PENALTIES>(keep_stuff); Command<Commands::SWITCH_DEATH_PENALTIES>(keep_stuff);
} }
Ui::CheckboxWithHint("Screenshot shortcut", &ss_shortcut, (("Take screenshot using ") + Ui::GetHotKeyNameString(Menu::hotkey::quick_ss)).c_str()); Ui::CheckboxWithHint("Screenshot shortcut", &ss_shortcut, (("Take screenshot using ") + Ui::GetHotKeyNameString(Menu::hotkey::quick_ss)
+ "\nSaved inside 'GTA San Andreas User Files\\Gallery'").c_str());
if (Ui::CheckboxWithHint("Solid water", &solid_water, "Player can walk on water")) if (Ui::CheckboxWithHint("Solid water", &solid_water, "Player can walk on water"))
{ {
if (!solid_water && solid_water_object != 0) if (!solid_water && solid_water_object != 0)

View File

@ -41,7 +41,7 @@ HRESULT Hook::Reset(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS * pPresent
return oReset9(pDevice, pPresentationParameters); return oReset9(pDevice, pPresentationParameters);
} }
HRESULT Hook::Present(void *ptr, int u1, int u2, int u3, int u4) void Hook::Present(void *ptr)
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
@ -121,11 +121,18 @@ HRESULT Hook::Present(void *ptr, int u1, int u2, int u3, int u4)
style.WindowTitleAlign = ImVec2(0.5, 0.5); style.WindowTitleAlign = ImVec2(0.5, 0.5);
oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)InputProc); oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)InputProc);
} }
}
if (Globals::renderer == Render_DirectX9) HRESULT Hook::PresentDx9Handler(IDirect3DDevice9 *pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion)
return oPresent9((IDirect3DDevice9*)ptr, (RECT*)u1, (RECT*)u2, (HWND)u3, (RGNDATA*)u4); {
else Present(pDevice);
return oPresent11((IDXGISwapChain*)ptr, u1, u2); return oPresent9(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);;
}
HRESULT Hook::PresentDx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{
Present(pSwapChain);
return oPresent11(pSwapChain, SyncInterval, Flags);
} }
// Thanks imring // Thanks imring
@ -164,7 +171,7 @@ Hook::Hook()
{ {
Globals::renderer = Render_DirectX9; Globals::renderer = Render_DirectX9;
if (kiero::bind(16, (void**)&oReset9, Reset) == kiero::Status::Success if (kiero::bind(16, (void**)&oReset9, Reset) == kiero::Status::Success
&& kiero::bind(17, (void**)&oPresent9, Present) == kiero::Status::Success) && kiero::bind(17, (void**)&oPresent9, PresentDx9Handler) == kiero::Status::Success)
flog << "Successfully hooked dx9 device." << std::endl; flog << "Successfully hooked dx9 device." << std::endl;
} }
else else
@ -173,7 +180,7 @@ Hook::Hook()
if (kiero::init(kiero::RenderType::D3D11) == kiero::Status::Success) if (kiero::init(kiero::RenderType::D3D11) == kiero::Status::Success)
{ {
Globals::renderer = Render_DirectX11; Globals::renderer = Render_DirectX11;
if (kiero::bind(8, (void**)&oPresent11, Present) == kiero::Status::Success) if (kiero::bind(8, (void**)&oPresent11, PresentDx11Handler) == kiero::Status::Success)
flog << "Successfully hooked dx11 device." << std::endl; flog << "Successfully hooked dx11 device." << std::endl;
} }
else else

View File

@ -15,7 +15,9 @@ private:
static f_Reset oReset9; static f_Reset oReset9;
static bool mouse_visibility; static bool mouse_visibility;
static HRESULT CALLBACK Present(void *ptr, int u1, int u2, int u3 = NULL, int u4 = NULL); static void CALLBACK Present(void *ptr);
static HRESULT CALLBACK PresentDx9Handler(IDirect3DDevice9 *pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion);
static HRESULT CALLBACK PresentDx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
static HRESULT CALLBACK Reset(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS * pPresentationParameters); static HRESULT CALLBACK Reset(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS * pPresentationParameters);
static LRESULT CALLBACK InputProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK InputProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void ShowMouse(bool state); static void ShowMouse(bool state);

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#define MENU_NAME "Cheat Menu" #define MENU_NAME "Cheat Menu"
#define MENU_VERSION "2.5-beta" #define MENU_VERSION "2.5-beta"
#define BUILD_NUMBER "20210110" #define BUILD_NUMBER "20210114"
#define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")"

View File

@ -303,13 +303,14 @@ void Player::Main()
if (ImGui::CollapsingHeader("Wanted level")) if (ImGui::CollapsingHeader("Wanted level"))
{ {
int val = player->m_pPlayerData->m_pWanted->m_nWantedLevel; int val = player->m_pPlayerData->m_pWanted->m_nWantedLevel;
int max_wl = player->m_pPlayerData->m_pWanted->MaximumWantedLevel;
ImGui::Columns(3, 0, false); ImGui::Columns(3, 0, false);
ImGui::Text("Min: 0"); ImGui::Text("Min: 0");
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text("Def: 0"); ImGui::Text("Def: 0");
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text("Max: 6"); ImGui::Text("Max: %d",max_wl);
ImGui::Columns(1); ImGui::Columns(1);
ImGui::Spacing(); ImGui::Spacing();
@ -318,7 +319,6 @@ void Player::Main()
player->CheatWantedLevel(val); player->CheatWantedLevel(val);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Minimum##Wanted level", Ui::GetSize(3))) if (ImGui::Button("Minimum##Wanted level", Ui::GetSize(3)))
player->CheatWantedLevel(0); player->CheatWantedLevel(0);
@ -330,7 +330,7 @@ void Player::Main()
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Maximum##Wanted level", Ui::GetSize(3))) if (ImGui::Button("Maximum##Wanted level", Ui::GetSize(3)))
player->CheatWantedLevel(6); player->CheatWantedLevel(max_wl);
ImGui::Spacing(); ImGui::Spacing();
ImGui::Separator(); ImGui::Separator();

View File

@ -176,6 +176,7 @@ void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std:
{ {
json.data["Custom"].erase(key); json.data["Custom"].erase(key);
CHud::SetHelpMessage("Location removed", false, false, false); CHud::SetHelpMessage("Location removed", false, false, false);
json.WriteToDisk();
} }
else CHud::SetHelpMessage("You can only remove custom location", false, false, false); else CHud::SetHelpMessage("You can only remove custom location", false, false, false);
} }

View File

@ -187,7 +187,7 @@ void Vehicle::AddComponent(const std::string& component, const bool display_mess
int hveh = CPools::GetVehicleRef(player->m_pVehicle); int hveh = CPools::GetVehicleRef(player->m_pVehicle);
CStreaming::RequestModel(icomp,eStreamingFlags::PRIORITY_REQUEST); CStreaming::RequestModel(icomp,eStreamingFlags::PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(true);
player->m_pVehicle->AddVehicleUpgrade(icomp); player->m_pVehicle->AddVehicleUpgrade(icomp);
CStreaming::SetModelIsDeletable(icomp); CStreaming::SetModelIsDeletable(icomp);