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": [
"${workspaceFolder}/src/",
"${DIRECTX9_SDK_DIR}/Include",
"C:/Program Files (x86)/DirectXSDK/Include",
"${PLUGIN_SDK_DIR}/plugin_sa",
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa",
"${PLUGIN_SDK_DIR}/shared",

View File

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

View File

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

View File

@ -308,7 +308,8 @@ of LS without completing missions"))
Command<Commands::SWITCH_ARREST_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 (!solid_water && solid_water_object != 0)

View File

@ -41,7 +41,7 @@ HRESULT Hook::Reset(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS * pPresent
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();
@ -121,11 +121,18 @@ HRESULT Hook::Present(void *ptr, int u1, int u2, int u3, int u4)
style.WindowTitleAlign = ImVec2(0.5, 0.5);
oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)InputProc);
}
}
if (Globals::renderer == Render_DirectX9)
return oPresent9((IDirect3DDevice9*)ptr, (RECT*)u1, (RECT*)u2, (HWND)u3, (RGNDATA*)u4);
else
return oPresent11((IDXGISwapChain*)ptr, u1, u2);
HRESULT Hook::PresentDx9Handler(IDirect3DDevice9 *pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion)
{
Present(pDevice);
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
@ -164,7 +171,7 @@ Hook::Hook()
{
Globals::renderer = Render_DirectX9;
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;
}
else
@ -173,7 +180,7 @@ Hook::Hook()
if (kiero::init(kiero::RenderType::D3D11) == kiero::Status::Success)
{
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;
}
else

View File

@ -15,7 +15,9 @@ private:
static f_Reset oReset9;
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 LRESULT CALLBACK InputProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void ShowMouse(bool state);

View File

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

View File

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

View File

@ -176,6 +176,7 @@ void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std:
{
json.data["Custom"].erase(key);
CHud::SetHelpMessage("Location removed", false, false, false);
json.WriteToDisk();
}
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);
CStreaming::RequestModel(icomp,eStreamingFlags::PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false);
CStreaming::LoadAllRequestedModels(true);
player->m_pVehicle->AddVehicleUpgrade(icomp);
CStreaming::SetModelIsDeletable(icomp);