Crash fix & improvements

1. Fixed crash when modloader.asi was installed but no modloader folder found
2. Code improvements
This commit is contained in:
Grinch_ 2022-02-21 14:33:57 +06:00
parent 3dd96c020f
commit 7c4e7fba14
24 changed files with 95 additions and 127 deletions

13
.github/FUNDING.yml vendored
View File

@ -1,13 +0,0 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ['https://paypal.me/NOTGrinch']

View File

@ -1,20 +0,0 @@
---
name: Bug report
about: Help us improve by reporting a bug
title: ''
labels: bug
assignees: user-grinch
---
**Describe the bug**
A clear and concise description of what the bug is & steps to reproduce it. Screenshots or videos are helpful.
**Info**
Cheat Menu version (with build number):
Game Version (v1.0 required):
Windows Version (7/8/10):
Have you read the installation instructions? (Yes/No):
Have you installed the menu using modloader? (Yes/No) (Provide log if installed):
List of mods you have installed,
...

View File

@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: user-grinch
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -221,10 +221,10 @@ void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string&
#endif
}
Animation::Animation()
void Animation::Init()
{
#ifdef GTASA
Events::processScriptsEvent += [this]
Events::processScriptsEvent += []
{
CPlayerPed* pPlayer = FindPlayerPed();
if (m_Cutscene::m_bRunning)

View File

@ -57,6 +57,9 @@ private:
#endif
public:
Animation();
Animation() = delete;
Animation(const Animation&) = delete;
static void Init();
static void ShowPage();
};

View File

@ -1,5 +1,4 @@
#include "pch.h"
#include "cheatMenu.h"
#include "version.h"
#include "ui.h"
#include "updater.h"
@ -7,6 +6,17 @@
#include "../depend/imgui/imgui_internal.h"
#include "util.h"
#include "animation.h"
#include "cheatmenu.h"
#include "game.h"
#include "menu.h"
#include "ped.h"
#include "player.h"
#include "teleport.h"
#include "vehicle.h"
#include "visual.h"
#include "weapon.h"
void CheatMenu::DrawWindow()
{
ImGuiIO& io = ImGui::GetIO();
@ -24,7 +34,7 @@ void CheatMenu::DrawWindow()
else
{
bRunning = true;
if (m_bShowMenu || BY_GAME(m_Commands::m_bShowMenu, true, true))
if (m_bShowMenu || BY_GAME(Menu::m_Commands::m_bShowMenu, true, true))
{
if (m_bShowMenu)
{
@ -54,12 +64,12 @@ void CheatMenu::DrawWindow()
#ifdef GTASA
else
{
DrawShortcutsWindow();
Menu::DrawShortcutsWindow();
}
#endif
}
}
DrawOverlay();
Menu::DrawOverlay();
}
void CheatMenu::ProcessPages()
@ -164,7 +174,7 @@ void CheatMenu::ProcessPages()
}
}
CheatMenu::CheatMenu()
void CheatMenu::Init()
{
if (!D3dHook::InjectHook(DrawWindow))
{
@ -197,6 +207,17 @@ CheatMenu::CheatMenu()
{"Anniversary", &ShowAnniversaryPage, eMenuPages::ANNIVERSARY, true}
};
// Init menu parts
Animation::Init();
Game::Init();
Menu::Init();
Player::Init();
Ped::Init();
Teleport::Init();
Vehicle::Init();
Visual::Init();
Weapon::Init();
Events::processScriptsEvent += []()
{
if (!BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, FrontEndMenuManager.m_bMenuActive))
@ -208,12 +229,12 @@ CheatMenu::CheatMenu()
if (commandWindow.Pressed())
{
if (m_Commands::m_bShowMenu)
if (Menu::m_Commands::m_bShowMenu)
{
ProcessCommands();
strcpy(m_Commands::m_nInputBuffer, "");
Menu::ProcessCommands();
strcpy(Menu::m_Commands::m_nInputBuffer, "");
}
m_Commands::m_bShowMenu = !m_Commands::m_bShowMenu;
Menu::m_Commands::m_bShowMenu = !Menu::m_Commands::m_bShowMenu;
}
bool mouseState = D3dHook::GetMouseState();
@ -230,11 +251,6 @@ CheatMenu::CheatMenu()
};
}
CheatMenu::~CheatMenu()
{
D3dHook::RemoveHook();
}
/*
* YIKES YOU AREN"T SUPPOSED TO FIND THIS YOU KNOW!!!
* Probably a good easter egg for the upcoming anniversary ;)

View File

@ -9,17 +9,9 @@
*/
#pragma once
#include "animation.h"
#include "game.h"
#include "menu.h"
#include "ped.h"
#include "player.h"
#include "teleport.h"
#include "vehicle.h"
#include "visual.h"
#include "weapon.h"
#include "pch.h"
class CheatMenu : Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon
class CheatMenu
{
private:
enum class eMenuPages
@ -48,8 +40,9 @@ private:
static void ProcessPages();
public:
CheatMenu();
~CheatMenu();
CheatMenu() = delete;
CheatMenu(const CheatMenu&) = delete;
static void Init();
static void ResetMenuSize();
};

View File

@ -71,7 +71,7 @@ void MenuThread(void* param)
gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: "
GITHUB_LINK "\n" << std::endl;
CheatMenu menu;
CheatMenu::Init();
// Checking for updates once a day
SYSTEMTIME st;

View File

@ -34,7 +34,7 @@ void Game::RealTimeClock()
CClock::ms_nGameClockSeconds = now->tm_sec;
}
Game::Game()
void Game::Init()
{
#ifdef GTASA
// Generate enabled cheats vector

View File

@ -62,7 +62,9 @@ public:
static inline bool m_bFreezeTime;
static inline bool m_bSyncTime;
Game();
static void ShowPage();
Game() = delete;
Game(const Game&) = delete;
static void Init();
static void ShowPage();
};

View File

@ -12,7 +12,7 @@
#include "vehicle.h"
#endif
Menu::Menu()
void Menu::Init()
{
// TODO: use structs
// Load config data

View File

@ -45,7 +45,10 @@ public:
static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = "";
};
Menu();
Menu() = delete;
Menu(const Menu&) = delete;
static void Init();
static void ShowPage();
static void DrawOverlay();
static void DrawShortcutsWindow();

View File

@ -9,7 +9,7 @@
#include <ePedBones.h>
#endif
Ped::Ped()
void Ped::Init()
{
#ifdef GTASA
if (GetModuleHandle("ExGangWars.asi"))
@ -52,15 +52,6 @@ Ped::Ped()
#endif
}
Ped::~Ped()
{
for (CPed* ped : m_SpawnPed::m_List)
{
CWorld::Remove(ped);
ped->Remove();
}
}
#ifdef GTASA
void Ped::SpawnPed(std::string& model)
#else

View File

@ -57,7 +57,9 @@ public:
static inline ResourceStore m_PedData {"ped", eResourceType::TYPE_TEXT};
#endif
Ped();
~Ped();
Ped() = delete;
Ped(const Ped&) = delete;
static void Init();
static void ShowPage();
};

View File

@ -82,7 +82,7 @@ void Player::TopDownCameraView()
}
#endif
Player::Player()
void Player::Init()
{
#ifdef GTASA
// Fix player model being broken after rebuild
@ -91,27 +91,33 @@ Player::Player()
#endif
// Custom skins setup
if (GetModuleHandle("modloader.asi"))
std::string path = GAME_PATH((char*)"modloader/");
if (GetModuleHandle("modloader.asi") && std::filesystem::is_directory(path))
{
#ifdef GTASA
if (std::filesystem::is_directory(m_CustomSkins::m_Path))
path += "CustomSkins/";
if (std::filesystem::is_directory(path))
{
for (auto& p : std::filesystem::recursive_directory_iterator(m_CustomSkins::m_Path))
for (auto& p : std::filesystem::recursive_directory_iterator(path))
{
if (p.path().extension() == ".dff")
{
std::string file_name = p.path().stem().string();
if (file_name.size() < 9)
{
m_CustomSkins::m_List.push_back(file_name);
}
else
{
gLog << "Custom Skin longer than 8 characters " << file_name << std::endl;
}
}
}
}
else
{
std::filesystem::create_directory(m_CustomSkins::m_Path);
std::filesystem::create_directory(path);
}
#endif
@ -805,7 +811,7 @@ void Player::ShowPage()
Ui::FilterWithHint("Search", m_ClothData.m_Filter,
std::string("Total skins: " + std::to_string(m_CustomSkins::m_List.size()))
.c_str());
Ui::ShowTooltip("Place your dff & txd files inside 'modloader/Custom Skins'");
Ui::ShowTooltip("Place your dff & txd files inside 'modloader/CustomSkins'");
ImGui::Spacing();
ImGui::TextWrapped(
"Note: Your txd & dff names can't exceed 8 characters. Don't change names while the game is running.");
@ -827,7 +833,7 @@ void Player::ShowPage()
"Custom skin allows to change player skins without replacing any existing game ped skins.\n\
Steps to enable 'Custom Skins',\n\n\
1. Download & install modloader\n\
2. Create a folder inside 'modloader' folder with the name 'Custom Skins'\n\
2. Create a folder inside 'modloader' folder with the name 'CustomSkins'\n\
3. Download ped skins online ( .dff & .txd files) and put them inside.\n\
4. Restart your game.\n\n\n\
Limitations:\n\

View File

@ -21,7 +21,6 @@ private:
static inline ResourceStore m_ClothData { "clothes", eResourceType::TYPE_IMAGE, ImVec2(70, 100)};
struct m_CustomSkins
{
static inline std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");;
static inline ImGuiTextFilter m_Filter;
static inline std::vector<std::string> m_List;
};
@ -52,6 +51,9 @@ private:
#endif
public:
Player();
Player() = delete;
Player(const Player&) = delete;
static void Init();
static void ShowPage();
};

View File

@ -40,7 +40,7 @@ void Teleport::FetchRadarSpriteData()
}
#endif
Teleport::Teleport()
void Teleport::Init()
{
m_bQuickTeleport = gConfig.GetValue("quick_teleport", false);

View File

@ -1,5 +1,4 @@
#pragma once
#include <vector>
#include "pch.h"
class Teleport
@ -36,8 +35,10 @@ private:
static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val);
public:
Teleport();
Teleport() = delete;
Teleport(const Teleport&) = delete;
static void Init();
static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0);
static void ShowPage();
};

View File

@ -14,7 +14,7 @@
#include "paint.h"
#endif
Vehicle::Vehicle()
void Vehicle::Init()
{
#ifdef GTASA
FileHandler::FetchHandlingID(m_VehicleIDE);
@ -24,7 +24,7 @@ Vehicle::Vehicle()
FileHandler::FetchColorData(m_CarcolsColorData);
Events::processScriptsEvent += [this]
Events::processScriptsEvent += []
{
uint timer = CTimer::m_snTimeInMilliseconds;
CPlayerPed* pPlayer = FindPlayerPed();
@ -192,13 +192,6 @@ Vehicle::Vehicle()
};
}
Vehicle::~Vehicle()
{
#ifdef GTASA
Neon::RemoveHooks();
#endif
}
#ifdef GTASA
void Vehicle::AddComponent(const std::string& component, const bool display_message)
{

View File

@ -90,13 +90,16 @@ private:
#endif
public:
Vehicle();
~Vehicle();
Vehicle() = delete;
Vehicle(const Vehicle&) = delete;
#ifdef GTASA
static void SpawnVehicle(std::string& name);
#else
static void SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& model);
#endif
static void Init();
static std::string GetNameFromModel(int model);
static int GetModelFromName(const char* name);
static void ShowPage();

View File

@ -17,7 +17,7 @@
#define TOTAL_WEATHERS 4
#endif
Visual::Visual()
void Visual::Init()
{
#ifdef GTASA
if (GetModuleHandle("timecycle24.asi"))

View File

@ -40,6 +40,9 @@ private:
static void TimecycSlider(const char* label, T* data, int min, int max);
public:
Visual();
Visual() = delete;
Visual(const Visual&) = delete;
static void Init();
static void ShowPage();
};

View File

@ -4,7 +4,7 @@
#include "util.h"
#include "CWeaponInfo.h"
Weapon::Weapon()
void Weapon::Init()
{
Events::processScriptsEvent += []
{

View File

@ -52,6 +52,9 @@ public:
static void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name);
#endif
Weapon();
Weapon() = delete;
Weapon(const Weapon&) = delete;
static void Init();
static void ShowPage();
};