Code improvements, [III] Fix Set car speed crash

This commit is contained in:
Grinch_ 2022-01-10 23:43:09 +06:00
parent cf4cad18ce
commit b3d4fd10d0
19 changed files with 153 additions and 95 deletions

View File

@ -6,7 +6,6 @@
#ifndef GTASA #ifndef GTASA
#include <CAnimationStyleDescriptor.h> #include <CAnimationStyleDescriptor.h>
#include <CAnimManager.h> #include <CAnimManager.h>
#include "../depend/kiero/minhook/MinHook.h"
#include "eAnimations.h" #include "eAnimations.h"
#include <CAnimBlendAssociation.h> #include <CAnimBlendAssociation.h>
#endif #endif
@ -15,6 +14,10 @@
#include <RpAnimBlend.h> #include <RpAnimBlend.h>
#endif #endif
#ifdef GTAVC
#include "../depend/kiero/minhook/MinHook.h"
#endif
#ifdef GTASA #ifdef GTASA
void Animation::PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior) void Animation::PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior)
{ {

View File

@ -3,6 +3,7 @@
#include "menuinfo.h" #include "menuinfo.h"
#include "ui.h" #include "ui.h"
#include "updater.h" #include "updater.h"
#include "d3dhook.h"
void CheatMenu::DrawWindow() void CheatMenu::DrawWindow()
{ {
@ -15,7 +16,7 @@ void CheatMenu::DrawWindow()
{ {
gConfig.WriteToDisk(); gConfig.WriteToDisk();
bRunning = false; bRunning = false;
m_bShowMouse = false; D3dHook::SetMouseState(false);
} }
} }
else else
@ -76,9 +77,12 @@ void CheatMenu::DrawWindow()
CheatMenu::CheatMenu() CheatMenu::CheatMenu()
{ {
ImGui::CreateContext(); if (!D3dHook::InjectHook(DrawWindow))
{
return;
}
ApplyStyle(); ApplyStyle();
pCallbackFunc = std::bind(&DrawWindow);
// Load menu settings // Load menu settings
Ui::m_HeaderId = gConfig.GetValue("window.idnum", -1); Ui::m_HeaderId = gConfig.GetValue("window.idnum", -1);
@ -105,19 +109,25 @@ CheatMenu::CheatMenu()
m_Commands::m_bShowMenu = !m_Commands::m_bShowMenu; m_Commands::m_bShowMenu = !m_Commands::m_bShowMenu;
} }
if (m_bShowMouse != m_bShowMenu) bool mouseState = D3dHook::GetMouseState();
if (mouseState != m_bShowMenu)
{ {
if (m_bShowMouse) // Only write when the menu closes if (mouseState) // Only write when the menu closes
{ {
gConfig.WriteToDisk(); gConfig.WriteToDisk();
} }
m_bShowMouse = m_bShowMenu; D3dHook::SetMouseState(m_bShowMenu);
} }
} }
}; };
} }
CheatMenu::~CheatMenu()
{
D3dHook::RemoveHook();
}
void CheatMenu::ShowWelcomeScreen() void CheatMenu::ShowWelcomeScreen()
{ {
ImGui::BeginChild("WelcomeScreen"); ImGui::BeginChild("WelcomeScreen");

View File

@ -11,7 +11,6 @@
#pragma once #pragma once
#include "animation.h" #include "animation.h"
#include "game.h" #include "game.h"
#include "hook.h"
#include "menu.h" #include "menu.h"
#include "ped.h" #include "ped.h"
#include "player.h" #include "player.h"
@ -20,7 +19,7 @@
#include "visual.h" #include "visual.h"
#include "weapon.h" #include "weapon.h"
class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon class CheatMenu : Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon
{ {
private: private:
static inline bool m_bShowMenu = false; static inline bool m_bShowMenu = false;
@ -41,6 +40,7 @@ private:
public: public:
CheatMenu(); CheatMenu();
~CheatMenu();
static void ResetMenuSize(); static void ResetMenuSize();
}; };

View File

@ -1,5 +1,5 @@
#include "pch.h" #include "pch.h"
#include "hook.h" #include "d3dhook.h"
#include "../depend/kiero/kiero.h" #include "../depend/kiero/kiero.h"
#include "../depend/kiero/minhook/MinHook.h" #include "../depend/kiero/minhook/MinHook.h"
#include "../depend/imgui/imgui_impl_dx9.h" #include "../depend/imgui/imgui_impl_dx9.h"
@ -8,8 +8,19 @@
#include <dinput.h> #include <dinput.h>
#define DIMOUSE ((LPDIRECTINPUTDEVICE8)(RsGlobal.ps->diMouse)) #define DIMOUSE ((LPDIRECTINPUTDEVICE8)(RsGlobal.ps->diMouse))
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT Hook::WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) bool D3dHook::GetMouseState()
{
return mouseShown;
}
void D3dHook::SetMouseState(bool state)
{
mouseShown = state;
}
LRESULT D3dHook::hkWndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam);
@ -24,14 +35,14 @@ LRESULT Hook::WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam); return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam);
} }
HRESULT Hook::Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters) HRESULT D3dHook::hkReset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{ {
ImGui_ImplDX9_InvalidateDeviceObjects(); ImGui_ImplDX9_InvalidateDeviceObjects();
return oReset(pDevice, pPresentationParameters); return oReset(pDevice, pPresentationParameters);
} }
void Hook::RenderFrame(void* ptr) void D3dHook::ProcessFrame(void* ptr)
{ {
if (!ImGui::GetCurrentContext()) if (!ImGui::GetCurrentContext())
{ {
@ -43,7 +54,7 @@ void Hook::RenderFrame(void* ptr)
if (bInit) if (bInit)
{ {
ShowMouse(m_bShowMouse); ProcessMouse();
// Scale the menu if game resolution changed // Scale the menu if game resolution changed
static ImVec2 fScreenSize = ImVec2(-1, -1); static ImVec2 fScreenSize = ImVec2(-1, -1);
@ -88,7 +99,7 @@ void Hook::RenderFrame(void* ptr)
if (pCallbackFunc != nullptr) if (pCallbackFunc != nullptr)
{ {
pCallbackFunc(); ((void(*)())pCallbackFunc)();
} }
ImGui::EndFrame(); ImGui::EndFrame();
@ -137,23 +148,23 @@ void Hook::RenderFrame(void* ptr)
io.IniFilename = nullptr; io.IniFilename = nullptr;
io.LogFilename = nullptr; io.LogFilename = nullptr;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)WndProc); oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)hkWndProc);
} }
} }
HRESULT Hook::Dx9Handler(IDirect3DDevice9* pDevice) HRESULT D3dHook::hkEndScene(IDirect3DDevice9* pDevice)
{ {
RenderFrame(pDevice); ProcessFrame(pDevice);
return oEndScene(pDevice); return oEndScene(pDevice);
} }
HRESULT Hook::Dx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags) HRESULT D3dHook::hkPresent(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{ {
RenderFrame(pSwapChain); ProcessFrame(pSwapChain);
return oPresent11(pSwapChain, SyncInterval, Flags); return oPresent(pSwapChain, SyncInterval, Flags);
} }
void Hook::ShowMouse(bool state) void D3dHook::ProcessMouse()
{ {
// Disable player controls for controllers // Disable player controls for controllers
bool bMouseDisabled = false; bool bMouseDisabled = false;
@ -163,7 +174,7 @@ void Hook::ShowMouse(bool state)
isController = !isController; isController = !isController;
#endif #endif
if (isController && (state || bMouseDisabled)) if (isController && (mouseShown || bMouseDisabled))
{ {
#ifdef GTASA #ifdef GTASA
@ -175,12 +186,12 @@ void Hook::ShowMouse(bool state)
if (pad) if (pad)
{ {
if (state) if (mouseShown)
{ {
bMouseDisabled = true; bMouseDisabled = true;
#ifdef GTA3 #ifdef GTA3
pad->m_bDisablePlayerControls = true; pad->m_bDisablePlayerControls = true;
#else //GTAVC & GTASA #else
pad->DisablePlayerControls = true; pad->DisablePlayerControls = true;
#endif #endif
} }
@ -189,18 +200,19 @@ void Hook::ShowMouse(bool state)
bMouseDisabled = false; bMouseDisabled = false;
#ifdef GTA3 #ifdef GTA3
pad->m_bDisablePlayerControls = false; pad->m_bDisablePlayerControls = false;
#else //GTAVC & GTASA #else
pad->DisablePlayerControls = false; pad->DisablePlayerControls = false;
#endif #endif
} }
} }
} }
if (m_bMouseVisibility != state) static bool mouseState;
if (mouseState != mouseShown)
{ {
ImGui::GetIO().MouseDrawCursor = state; ImGui::GetIO().MouseDrawCursor = mouseShown;
if (state) if (mouseShown)
{ {
patch::SetUChar(BY_GAME(0x6194A0, 0x6020A0, 0x580D20), 0xC3); // psSetMousePos patch::SetUChar(BY_GAME(0x6194A0, 0x6020A0, 0x580D20), 0xC3); // psSetMousePos
@ -227,19 +239,27 @@ void Hook::ShowMouse(bool state)
CPad::ClearMouseHistory(); CPad::ClearMouseHistory();
#endif #endif
CPad::UpdatePads(); CPad::UpdatePads();
m_bMouseVisibility = state; mouseState = mouseShown;
} }
} }
Hook::Hook() bool D3dHook::InjectHook(void *pCallback)
{ {
ImGui::CreateContext();
// Nvidia Overlay crash fix
/*
Must check for d3d9 first!
Seems to crash with nvidia geforce experience overlay
if anything else is checked before d3d9
*/
if (init(kiero::RenderType::D3D9) == kiero::Status::Success) if (init(kiero::RenderType::D3D9) == kiero::Status::Success)
{ {
gRenderer = Render_DirectX9; gRenderer = Render_DirectX9;
kiero::bind(16, (void**)&oReset, Reset); kiero::bind(16, (void**)&oReset, hkReset);
kiero::bind(42, (void**)&oEndScene, Dx9Handler); kiero::bind(42, (void**)&oEndScene, hkEndScene);
pCallbackFunc = pCallback;
return true;
} }
else else
{ {
@ -247,13 +267,19 @@ Hook::Hook()
if (init(kiero::RenderType::D3D11) == kiero::Status::Success) if (init(kiero::RenderType::D3D11) == kiero::Status::Success)
{ {
gRenderer = Render_DirectX11; gRenderer = Render_DirectX11;
kiero::bind(8, (void**)&oPresent11, Dx11Handler); kiero::bind(8, (void**)&oPresent, hkPresent);
pCallbackFunc = pCallback;
return true;
} }
} }
return false;
} }
Hook::~Hook() void D3dHook::RemoveHook()
{ {
pCallbackFunc = nullptr;
SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)oWndProc); SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)oWndProc);
ImGui_ImplDX9_Shutdown(); ImGui_ImplDX9_Shutdown();
ImGui_ImplWin32_Shutdown(); ImGui_ImplWin32_Shutdown();

40
src/d3dhook.h Normal file
View File

@ -0,0 +1,40 @@
#pragma once
#include "pch.h"
class D3dHook
{
private:
using f_EndScene = HRESULT(CALLBACK*)(IDirect3DDevice9*);
using f_Present11 = 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_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();
// DirectX9
static HRESULT CALLBACK hkEndScene(IDirect3DDevice9* pDevice);
static HRESULT CALLBACK hkReset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
// DirectX11, Renderhook
static HRESULT CALLBACK hkPresent(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
public:
D3dHook() = delete;
D3dHook(D3dHook const&) = delete;
void operator=(D3dHook const&) = delete;
static bool GetMouseState();
static bool InjectHook(void *pCallback);
static void RemoveHook();
static void SetMouseState(bool state);
};

View File

@ -1,8 +1,8 @@
#include "pch.h" #include "pch.h"
#include "hook.h"
#include "cheatmenu.h" #include "cheatmenu.h"
#include "updater.h" #include "updater.h"
#include "menuinfo.h" #include "menuinfo.h"
#include "d3dhook.h"
void MenuThread(void* param) void MenuThread(void* param)
{ {
@ -62,6 +62,7 @@ void MenuThread(void* param)
gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: " gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: "
GITHUB_LINK "\n" << std::endl; GITHUB_LINK "\n" << std::endl;
CheatMenu menu; CheatMenu menu;

View File

@ -1,32 +0,0 @@
#pragma once
#include "pch.h"
using f_EndScene = HRESULT(CALLBACK*)(IDirect3DDevice9*);
using f_Present11 = HRESULT(CALLBACK*)(IDXGISwapChain*, UINT, UINT);
using f_Reset = HRESULT(CALLBACK*)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*);
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
class Hook
{
private:
static inline WNDPROC oWndProc;
static inline f_Present11 oPresent11;
static inline f_EndScene oEndScene;
static inline f_Reset oReset;
static inline bool m_bMouseVisibility;
static void CALLBACK RenderFrame(void* ptr);
static HRESULT CALLBACK Dx9Handler(IDirect3DDevice9* pDevice);
static HRESULT CALLBACK Dx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
static HRESULT CALLBACK Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void ShowMouse(bool state);
public:
static inline bool m_bShowMouse = false;
static inline std::function<void()> pCallbackFunc = nullptr;
Hook();
~Hook();
};

View File

@ -17,7 +17,7 @@ Hotkey vehInstantStop;
bool Hotkey::DrawUI(const char* label) bool Hotkey::DrawUI(const char* label)
{ {
bool active = m_CurrentHotkey == label; bool active = (m_CurrentHotkey == label);
bool state = false; bool state = false;
if (active) if (active)

View File

@ -12,8 +12,7 @@ private:
bool m_bPressed; bool m_bPressed;
public: public:
int m_key1; int m_key1, m_key2;
int m_key2;
Hotkey(int key1 = -1, int key2 = -1) Hotkey(int key1 = -1, int key2 = -1)
: m_key1(key1), m_key2(key2) : m_key1(key1), m_key2(key2)

View File

@ -2,5 +2,5 @@
#define MENU_NAME "Cheat Menu" #define MENU_NAME "Cheat Menu"
#define MENU_VERSION_NUMBER "3.1" #define MENU_VERSION_NUMBER "3.1"
#define MENU_VERSION MENU_VERSION_NUMBER"-beta" #define MENU_VERSION MENU_VERSION_NUMBER"-beta"
#define BUILD_NUMBER "20220103" #define BUILD_NUMBER "20220110"
#define MENU_TITLE MENU_NAME " v" MENU_VERSION #define MENU_TITLE MENU_NAME " v" MENU_VERSION

View File

@ -178,7 +178,7 @@ static RwTexture* LoadTextureFromMemory(char* data, unsigned int size)
return RwTextureCreate(raster); return RwTextureCreate(raster);
} }
void Neon::InitHooks() void Neon::InjectHooks()
{ {
static bool init; static bool init;
if (init) if (init)

View File

@ -35,7 +35,7 @@ public:
Neon() = delete; Neon() = delete;
Neon(Neon&) = delete; Neon(Neon&) = delete;
static void InitHooks(); static void InjectHooks();
static void Install(CVehicle* veh, int red, int green, int blue); static void Install(CVehicle* veh, int red, int green, int blue);
static bool IsInstalled(CVehicle* veh); static bool IsInstalled(CVehicle* veh);
static bool IsPulsingEnabled(CVehicle* veh); static bool IsPulsingEnabled(CVehicle* veh);

View File

@ -27,7 +27,7 @@
#include "NodeName.h" #include "NodeName.h"
#include "util.h" #include "util.h"
void Paint::InitHooks() void Paint::InjectHooks()
{ {
static bool init; static bool init;

View File

@ -76,7 +76,7 @@ private:
public: public:
static inline ResourceStore m_TextureData { "textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80) }; static inline ResourceStore m_TextureData { "textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80) };
static void InitHooks(); static void InjectHooks();
static void GenerateNodeList(CVehicle* pVeh, std::vector<std::string>& names_vec); static void GenerateNodeList(CVehicle* pVeh, std::vector<std::string>& names_vec);
static void SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat = false); static void SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat = false);
static void SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat = false); static void SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat = false);

View File

@ -70,7 +70,7 @@
#include "json.h" #include "json.h"
#include "hotkeys.h" #include "hotkeys.h"
#include "vKeys.h" #include "vkeys.h"
#include "resourcestore.h" #include "resourcestore.h"
#include "fontmgr.h" #include "fontmgr.h"

View File

@ -2,9 +2,21 @@
#include "util.h" #include "util.h"
#include "psapi.h" #include "psapi.h"
void Util::SetCarForwardSpeed(CVehicle *pVeh, float speed)
{
#ifdef GTA3
CVector inVec = pVeh->m_matrix.up;
double speedFactor = speed * 0.016766668;
pVeh->m_vecMoveSpeed.x = speedFactor * inVec.x;
pVeh->m_vecMoveSpeed.y = speedFactor * inVec.y;
pVeh->m_vecMoveSpeed.z = speedFactor * inVec.z;
#else
Command<Commands::SET_CAR_FORWARD_SPEED>(CPools::GetVehicleRef(pVeh), 0);
#endif
}
std::string Util::GetLocationName(CVector* pos) std::string Util::GetLocationName(CVector* pos)
{ {
#ifdef GTASA #ifdef GTASA
CPlayerPed *pPlayer = FindPlayerPed(); CPlayerPed *pPlayer = FindPlayerPed();
int hplayer = CPools::GetPedRef(pPlayer); int hplayer = CPools::GetPedRef(pPlayer);

View File

@ -20,6 +20,7 @@ public:
static int GetLargestGangInZone(); static int GetLargestGangInZone();
#endif #endif
static void SetCarForwardSpeed(CVehicle *pVeh, float speed);
static CPed* GetClosestPed(); static CPed* GetClosestPed();
static CVehicle* GetClosestVehicle(); static CVehicle* GetClosestVehicle();
static void GetCPUUsageInit(); static void GetCPUUsageInit();

View File

@ -73,8 +73,8 @@ Vehicle::Vehicle()
{ {
#ifdef GTASA #ifdef GTASA
FileHandler::FetchHandlingID(m_VehicleIDE); FileHandler::FetchHandlingID(m_VehicleIDE);
Neon::InitHooks(); Neon::InjectHooks();
Paint::InitHooks(); Paint::InjectHooks();
#endif #endif
FileHandler::FetchColorData(m_CarcolsColorData); FileHandler::FetchColorData(m_CarcolsColorData);
@ -120,12 +120,12 @@ Vehicle::Vehicle()
if (vehInstantStart.Pressed()) if (vehInstantStart.Pressed())
{ {
Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, 40.0f); Util::SetCarForwardSpeed(pVeh, 40.0f);
} }
if (vehInstantStop.Pressed()) if (vehInstantStop.Pressed())
{ {
Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, 0); Util::SetCarForwardSpeed(pVeh, 0.0f);
} }
if (m_bNoDamage) if (m_bNoDamage)
@ -157,7 +157,7 @@ Vehicle::Vehicle()
if (m_bLockSpeed) if (m_bLockSpeed)
{ {
Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, m_fLockSpeed); Util::SetCarForwardSpeed(pVeh, m_fLockSpeed);
} }
#ifdef GTASA #ifdef GTASA
@ -457,7 +457,7 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri
if (m_Spawner::m_bSpawnInside) if (m_Spawner::m_bSpawnInside)
{ {
Command<Commands::WARP_CHAR_INTO_CAR>(hplayer, hveh); Command<Commands::WARP_CHAR_INTO_CAR>(hplayer, hveh);
Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, speed); Util::SetCarForwardSpeed(veh, speed);
} }
Command<Commands::MARK_MISSION_TRAIN_AS_NO_LONGER_NEEDED>(hveh); Command<Commands::MARK_MISSION_TRAIN_AS_NO_LONGER_NEEDED>(hveh);
Command<Commands::MARK_CAR_AS_NO_LONGER_NEEDED>(hveh); Command<Commands::MARK_CAR_AS_NO_LONGER_NEEDED>(hveh);
@ -497,9 +497,7 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri
#endif #endif
Command<Commands::WARP_CHAR_INTO_CAR>(hplayer, hveh); Command<Commands::WARP_CHAR_INTO_CAR>(hplayer, hveh);
#ifndef GTA3 Util::SetCarForwardSpeed(veh, speed);
Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, speed);
#endif
} }
else else
{ {
@ -1025,14 +1023,14 @@ void Vehicle::Draw()
if (ImGui::Button("Set speed##brn", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("Set speed##brn", ImVec2(Ui::GetSize(2))))
{ {
Command<Commands::SET_CAR_FORWARD_SPEED>(hVeh, m_fLockSpeed); Util::SetCarForwardSpeed(pVeh, m_fLockSpeed);
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Instant stop##brn", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("Instant stop##brn", ImVec2(Ui::GetSize(2))))
{ {
Command<Commands::SET_CAR_FORWARD_SPEED>(hVeh, 0); Util::SetCarForwardSpeed(pVeh, 0.0f);
} }
} }
} }

View File

@ -58,8 +58,8 @@ project "CheatMenuIII"
"../src/cheatmenu.cpp", "../src/cheatmenu.cpp",
"../src/pch.h", "../src/pch.h",
"../src/pch.cpp", "../src/pch.cpp",
"../src/hook.h", "../src/d3dhook.h",
"../src/hook.cpp", "../src/d3dhook.cpp",
"../src/updater.h", "../src/updater.h",
"../src/updater.cpp", "../src/updater.cpp",
"../src/json.h", "../src/json.h",
@ -151,8 +151,8 @@ project "CheatMenuVC"
"../src/cheatmenu.cpp", "../src/cheatmenu.cpp",
"../src/pch.h", "../src/pch.h",
"../src/pch.cpp", "../src/pch.cpp",
"../src/hook.h", "../src/d3dhook.h",
"../src/hook.cpp", "../src/d3dhook.cpp",
"../src/updater.h", "../src/updater.h",
"../src/updater.cpp", "../src/updater.cpp",
"../src/json.h", "../src/json.h",