Refactor code, fixes

This commit is contained in:
Grinch_ 2022-01-07 14:18:00 +06:00
parent 6044deb156
commit 2b58d9488d
47 changed files with 7569 additions and 7495 deletions

27
.vscode/tasks.json vendored
View File

@ -246,5 +246,32 @@
} }
}, },
}, },
{
"label": "Format Code",
"type": "shell",
"command": "${workspaceFolder}/tools/FormatCode.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"
]
}
}
},
},
] ]
} }

View File

@ -113,7 +113,7 @@ bool Animation::_LoadAnimationBlock(const char* szBlockName)
} }
return false; return false;
} }
#else // GTA III #else
void Animation::_PlayAnimation(RpClump* pClump, int animGroup, int animID, float blend) void Animation::_PlayAnimation(RpClump* pClump, int animGroup, int animID, float blend)
{ {
@ -178,7 +178,7 @@ void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string&
Command<Commands::REMOVE_ANIMATION>(ifp.c_str()); Command<Commands::REMOVE_ANIMATION>(ifp.c_str());
} }
#else // GTA VC & III #else
if (pPlayer) if (pPlayer)
{ {
int groupID, animID; int groupID, animID;

View File

@ -34,7 +34,7 @@ void MenuThread(void* param)
Need SilentPatch since all gta games have issues with mouse input Need SilentPatch since all gta games have issues with mouse input
Implementing mouse fix is a headache anyway Implementing mouse fix is a headache anyway
*/ */
if (!GetModuleHandle(BY_GAME("SilentPatchSA.asi" ,"SilentPatchVC.asi" ,"SilentPatchIII.asi"))) if (!GetModuleHandle(BY_GAME("SilentPatchSA.asi","SilentPatchVC.asi","SilentPatchIII.asi")))
{ {
gLog << "Error: SilentPatch not found. Please install it from here https://gtaforums.com/topic/669045-silentpatch/" << std::endl; gLog << "Error: SilentPatch not found. Please install it from here https://gtaforums.com/topic/669045-silentpatch/" << std::endl;
int msgID = MessageBox(RsGlobal.ps->window, "SilentPatch not found. Do you want to install Silent Patch? (Game restart required)", "CheatMenu", MB_OKCANCEL | MB_DEFBUTTON1); int msgID = MessageBox(RsGlobal.ps->window, "SilentPatch not found. Do you want to install Silent Patch? (Game restart required)", "CheatMenu", MB_OKCANCEL | MB_DEFBUTTON1);

View File

@ -405,7 +405,7 @@ void Game::Draw()
#elif GTAVC #elif GTAVC
patch::Nop(0x602BD8, 5); patch::Nop(0x602BD8, 5);
patch::Nop(0x602BE7, 5); patch::Nop(0x602BE7, 5);
#else // GTA3 #else
patch::Nop(0x5841B8, 5); patch::Nop(0x5841B8, 5);
patch::Nop(0x5841C7, 5); patch::Nop(0x5841C7, 5);
#endif #endif
@ -419,7 +419,7 @@ void Game::Draw()
#elif GTAVC #elif GTAVC
patch::SetRaw(0x602BD8, (char*)"\x88\xD8\x89\xF1\x50", 5); patch::SetRaw(0x602BD8, (char*)"\x88\xD8\x89\xF1\x50", 5);
patch::SetRaw(0x602BE7, (char*)"\xE8\x34\x91\xEA\xFF", 5); patch::SetRaw(0x602BE7, (char*)"\xE8\x34\x91\xEA\xFF", 5);
#else // GTA3 #else
patch::SetRaw(0x5841B8, (char*)"\x88\xD8\x89\xF1\x50", 5); patch::SetRaw(0x5841B8, (char*)"\x88\xD8\x89\xF1\x50", 5);
patch::SetRaw(0x5841C7, (char*)"\xE8\x84\xE2\xF0\xFF", 5); patch::SetRaw(0x5841C7, (char*)"\xE8\x84\xE2\xF0\xFF", 5);
#endif #endif
@ -592,7 +592,8 @@ Lowers armour, health, stamina etc."))
ImGui::Separator(); ImGui::Separator();
} }
#ifdef GTASA #ifdef GTASA
static std::vector<Ui::NamedMemory> themes{ static std::vector<Ui::NamedMemory> themes
{
{"Beach", 0x969159}, {"Country", 0x96917D}, {"Fun house", 0x969176}, {"Ninja", 0x96915C} {"Beach", 0x969159}, {"Country", 0x96917D}, {"Fun house", 0x969176}, {"Ninja", 0x96915C}
}; };
Ui::EditRadioButtonAddress("Themes", themes); Ui::EditRadioButtonAddress("Themes", themes);
@ -633,7 +634,7 @@ Lowers armour, health, stamina etc."))
{ {
Call<0x438F50>(); Call<0x438F50>();
} }
#else // GTA3 & GTAVC #else
if (ImGui::Button("Sunny", Ui::GetSize(3))) if (ImGui::Button("Sunny", Ui::GetSize(3)))
{ {
CWeather::ForceWeatherNow(0); CWeather::ForceWeatherNow(0);

View File

@ -214,7 +214,7 @@ void Hook::ShowMouse(bool state)
patch::SetRaw(0x541DD7, (char*)"\xE8\xE4\xD5\xFF\xFF", 5); patch::SetRaw(0x541DD7, (char*)"\xE8\xE4\xD5\xFF\xFF", 5);
#elif GTAVC #elif GTAVC
patch::SetRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5); patch::SetRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5);
#else // GTA3 #else
patch::SetRaw(0x49272F, (char*)"\xE8\x6C\xF5\xFF\xFF", 5); patch::SetRaw(0x49272F, (char*)"\xE8\x6C\xF5\xFF\xFF", 5);
#endif #endif
} }
@ -223,7 +223,7 @@ void Hook::ShowMouse(bool state)
CPad::NewMouseControllerState.Y = 0; CPad::NewMouseControllerState.Y = 0;
#ifdef GTA3 #ifdef GTA3
CPad::GetPad(0)->ClearMouseHistory(); CPad::GetPad(0)->ClearMouseHistory();
#else // GTAVC & GTASA #else
CPad::ClearMouseHistory(); CPad::ClearMouseHistory();
#endif #endif
CPad::UpdatePads(); CPad::UpdatePads();
@ -243,7 +243,7 @@ Hook::Hook()
} }
else else
{ {
// gtaRenderHook
if (init(kiero::RenderType::D3D11) == kiero::Status::Success) if (init(kiero::RenderType::D3D11) == kiero::Status::Success)
{ {
gRenderer = Render_DirectX11; gRenderer = Render_DirectX11;

View File

@ -277,7 +277,7 @@ void Menu::ProcessCommands()
} }
} }
#ifdef GTASA #ifdef GTASA
if (command == "tp") if (command == "tp")
{ {
try try
@ -345,7 +345,7 @@ void Menu::ProcessCommands()
else else
SetHelpMessage("Invalid command", false, false, false); SetHelpMessage("Invalid command", false, false, false);
} }
#endif #endif
} }
void Menu::Draw() void Menu::Draw()
@ -360,7 +360,6 @@ void Menu::Draw()
if (ImGui::Button("Reset size", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("Reset size", ImVec2(Ui::GetSize(2))))
{ {
CheatMenu::ResetMenuSize(); CheatMenu::ResetMenuSize();
SetHelpMessage("Menu size reset", false, false, false);
} }
ImGui::Spacing(); ImGui::Spacing();

View File

@ -4,7 +4,7 @@ class Menu
{ {
private: private:
enum class DisplayPos enum DisplayPos
{ {
CUSTOM, CUSTOM,
TOP_LEFT, TOP_LEFT,

View File

@ -180,7 +180,8 @@ static RwTexture* LoadTextureFromMemory(char* data, unsigned int size)
void Neon::InitHooks() void Neon::InitHooks()
{ {
if (m_bInit) static bool init;
if (init)
{ {
return; return;
} }
@ -231,7 +232,7 @@ void Neon::InitHooks()
} }
}; };
m_bInit = true; init = true;
} }
void Neon::RemoveHooks() void Neon::RemoveHooks()

View File

@ -30,7 +30,6 @@ private:
static inline RwTexture* m_pNeonTexture = nullptr; // pointer to the neon mask texture static inline RwTexture* m_pNeonTexture = nullptr; // pointer to the neon mask texture
static inline VehicleExtendedData<NeonData> m_VehNeon; static inline VehicleExtendedData<NeonData> m_VehNeon;
static inline bool m_bInit;
public: public:
Neon() = delete; Neon() = delete;

View File

@ -29,6 +29,13 @@
void Paint::InitHooks() void Paint::InitHooks()
{ {
static bool init;
if (init)
{
return;
}
Events::vehicleRenderEvent.before += [](CVehicle* pVeh) Events::vehicleRenderEvent.before += [](CVehicle* pVeh)
{ {
VehData& data = m_VehData.Get(pVeh); VehData& data = m_VehData.Get(pVeh);
@ -85,6 +92,7 @@ void Paint::InitHooks()
} }
} }
}; };
init = true;
} }
void Paint::VehData::setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat) void Paint::VehData::setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat)

View File

@ -97,7 +97,7 @@ static void SetHelpMessage(const char *message, bool b1, bool b2, bool b3)
CHud::SetHelpMessage(message, b1, b2, b3); CHud::SetHelpMessage(message, b1, b2, b3);
#elif GTAVC #elif GTAVC
CHud::SetHelpMessage(message, b1, b2); CHud::SetHelpMessage(message, b1, b2);
#else // GTA3 #else
const size_t size = strlen(message)+1; const size_t size = strlen(message)+1;
wchar_t* wc = new wchar_t[size]; wchar_t* wc = new wchar_t[size];
mbstowcs(wc, message, size); mbstowcs(wc, message, size);

View File

@ -63,7 +63,7 @@ Ped::~Ped()
#ifdef GTASA #ifdef GTASA
void Ped::SpawnPed(std::string& model) void Ped::SpawnPed(std::string& model)
#else // GTA3 & GTAVC #else
void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model) void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model)
#endif #endif
{ {
@ -105,13 +105,13 @@ void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model)
currentSlot = 1; currentSlot = 1;
} }
} }
#else // GTA3 & GTAVC #else
if (cat == "Special") // Special model if (cat == "Special") // Special model
{ {
#ifdef GTA3 #ifdef GTA3
SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false); SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false);
return; return;
#else // GTAVC #else
Command<Commands::LOAD_SPECIAL_CHARACTER>(currentSlot, model.c_str()); Command<Commands::LOAD_SPECIAL_CHARACTER>(currentSlot, model.c_str());
Command<Commands::LOAD_ALL_MODELS_NOW>(); Command<Commands::LOAD_ALL_MODELS_NOW>();
@ -195,7 +195,7 @@ void Ped::Draw()
Ui::CheckboxAddress("Slut magnet", 0xA10B5F); Ui::CheckboxAddress("Slut magnet", 0xA10B5F);
ImGui::NextColumn(); ImGui::NextColumn();
Ui::CheckboxAddress("Weapons for all", 0xA10AB3); Ui::CheckboxAddress("Weapons for all", 0xA10AB3);
#else // GTA3 #else
// Bad idea lol // Bad idea lol
static bool pedsMayhem; static bool pedsMayhem;
if (Ui::CheckboxWithHint("Peds mayhem", &pedsMayhem)) if (Ui::CheckboxWithHint("Peds mayhem", &pedsMayhem))
@ -256,7 +256,7 @@ void Ped::Draw()
CZoneInfo* zoneInfo = CTheZones::GetZoneInfo(&pos, &pZone); CZoneInfo* zoneInfo = CTheZones::GetZoneInfo(&pos, &pZone);
int density = zoneInfo->m_nGangDensity[i]; int density = zoneInfo->m_nGangDensity[i];
if (ImGui::SliderInt(m_GangNames[i].c_str(), &density, 0, 127)) if (ImGui::SliderInt(m_GangList[i].c_str(), &density, 0, 127))
{ {
zoneInfo->m_nGangDensity[i] = static_cast<char>(density); zoneInfo->m_nGangDensity[i] = static_cast<char>(density);
Command<Commands::CLEAR_SPECIFIC_ZONES_TO_TRIGGER_GANG_WAR>(); Command<Commands::CLEAR_SPECIFIC_ZONES_TO_TRIGGER_GANG_WAR>();
@ -285,7 +285,8 @@ void Ped::Draw()
#ifdef GTASA #ifdef GTASA
if (ImGui::CollapsingHeader("Recruit anyone")) if (ImGui::CollapsingHeader("Recruit anyone"))
{ {
static std::vector<Ui::NamedMemory> selectWeapon{ static std::vector<Ui::NamedMemory> selectWeapon
{
{"9mm", 0x96917C}, {"AK47", 0x96917D}, {"Rockets", 0x96917E} {"9mm", 0x96917C}, {"AK47", 0x96917D}, {"Rockets", 0x96917E}
}; };
Ui::RadioButtonAddress("Select weapon", selectWeapon); Ui::RadioButtonAddress("Select weapon", selectWeapon);
@ -296,14 +297,15 @@ void Ped::Draw()
if (ImGui::CollapsingHeader("Remove peds in radius")) if (ImGui::CollapsingHeader("Remove peds in radius"))
{ {
ImGui::InputInt("Radius", &m_nPedRemoveRadius); static int removeRadius = 5;
ImGui::InputInt("Radius", &removeRadius);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Remove peds", Ui::GetSize(1))) if (ImGui::Button("Remove peds", Ui::GetSize(1)))
{ {
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
for (CPed* ped : CPools::ms_pPedPool) for (CPed* ped : CPools::ms_pPedPool)
{ {
if (DistanceBetweenPoints(ped->GetPosition(), player->GetPosition()) < m_nPedRemoveRadius if (DistanceBetweenPoints(ped->GetPosition(), player->GetPosition()) < removeRadius
&& ped->m_pVehicle == nullptr && ped != player) && ped->m_pVehicle == nullptr && ped != player)
{ {
Command<Commands::DELETE_CHAR>(CPools::GetPedRef(ped)); Command<Commands::DELETE_CHAR>(CPools::GetPedRef(ped));
@ -338,8 +340,11 @@ void Ped::Draw()
ImGui::Spacing(); ImGui::Spacing();
#ifdef GTASA #ifdef GTASA
Ui::DrawImages(m_PedData, SpawnPed, nullptr, Ui::DrawImages(m_PedData, SpawnPed, nullptr,
[](std::string str) { return m_PedData.m_pJson->m_Data[str].get<std::string>(); }); [](std::string str)
#else // GTA3 & GTAVC {
return m_PedData.m_pJson->m_Data[str].get<std::string>();
});
#else
Ui::DrawJSON(m_PedData, SpawnPed, nullptr); Ui::DrawJSON(m_PedData, SpawnPed, nullptr);
#endif #endif
ImGui::EndTabItem(); ImGui::EndTabItem();
@ -375,16 +380,22 @@ void Ped::Draw()
ImGui::Spacing(); ImGui::Spacing();
#ifdef GTASA #ifdef GTASA
Ui::DrawImages(Weapon::m_WeaponData, Ui::DrawImages(Weapon::m_WeaponData,
[](std::string str) { m_SpawnPed::m_nWeaponId = std::stoi(str); }, [](std::string str)
{
m_SpawnPed::m_nWeaponId = std::stoi(str);
},
nullptr, nullptr,
[](std::string str) [](std::string str)
{ {
m_SpawnPed::m_nWeaponName = Weapon::m_WeaponData.m_pJson->m_Data[str].get<std::string>(); m_SpawnPed::m_nWeaponName = Weapon::m_WeaponData.m_pJson->m_Data[str].get<std::string>();
return m_SpawnPed::m_nWeaponName; return m_SpawnPed::m_nWeaponName;
}, },
[](std::string str) { return str != "-1"; /*Jetpack*/ } [](std::string str)
{
return str != "-1"; /*Jetpack*/
}
); );
#else // GTA3 & GTAVC #else
Ui::DrawJSON(Weapon::m_WeaponData, Ui::DrawJSON(Weapon::m_WeaponData,
[](std::string& root, std::string& key, std::string& id) [](std::string& root, std::string& key, std::string& id)
{ {

View File

@ -5,21 +5,16 @@ class Ped
{ {
private: private:
#ifdef GTASA #ifdef GTASA
static inline bool m_bExGangWarsInstalled;
static inline bool m_bBigHead; static inline bool m_bBigHead;
static inline bool m_bThinBody; static inline bool m_bThinBody;
static inline CJson m_SpecialPedJson = CJson("ped special"); static inline std::vector<std::string> m_GangList =
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)};
static inline std::vector<std::string> m_GangNames =
{ {
"Ballas", "Grove street families", "Los santos vagos", "San fierro rifa", "Ballas", "Grove street families", "Los santos vagos", "San fierro rifa",
"Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10" "Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10"
}; };
#else // GTA3 & GTAVC
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT};
#endif #endif
static inline bool m_bExGangWarsInstalled;
static inline int m_nPedRemoveRadius = 5;
struct m_SpawnPed struct m_SpawnPed
{ {
static inline std::vector<CPed*> m_List; static inline std::vector<CPed*> m_List;
@ -40,19 +35,21 @@ private:
"Civ Male", "Civ Female", "Cop (crash)", "Cubans", "Haitians", "Streetwannabe's", "Diaz' Gang", "Civ Male", "Civ Female", "Cop (crash)", "Cubans", "Haitians", "Streetwannabe's", "Diaz' Gang",
"Security Guards", "Biker Gang", "Vercetti Gang", "Golfers", "Gang 9", "Emergency", "Security Guards", "Biker Gang", "Vercetti Gang", "Golfers", "Gang 9", "Emergency",
"Fireman", "Criminal", "Unused", "Prostitute", "Special" "Fireman", "Criminal", "Unused", "Prostitute", "Special"
#else // GTA3 #else
"Civ Male", "Civ Female", "Cop", "Leones", "Triads", "Diablos", "Yakuza", "Yardies", "Colombians", "Civ Male", "Civ Female", "Cop", "Leones", "Triads", "Diablos", "Yakuza", "Yardies", "Colombians",
"Hoods", "unused", "unused", "Emergency", "Fireman", "Criminal", "unused", "Prostitute", "Special" "Hoods", "unused", "unused", "Emergency", "Fireman", "Criminal", "unused", "Prostitute", "Special"
#endif #endif
}; };
}; };
public:
friend class Player;
#ifdef GTASA #ifdef GTASA
friend class Weapon; static inline CJson m_SpecialPedJson = CJson("ped special");
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)};
#else
static inline ResourceStore m_PedData {"ped", eResourceType::TYPE_TEXT};
#endif #endif
public:
Ped(); Ped();
~Ped(); ~Ped();
static void Draw(); static void Draw();
@ -60,7 +57,7 @@ public:
#ifdef GTASA #ifdef GTASA
static void SpawnPed(std::string& model); static void SpawnPed(std::string& model);
static void BigHeadEffect(CPed *ped); static void BigHeadEffect(CPed *ped);
#else // GTA3 & GTAVC #else
static void SpawnPed(std::string& cat, std::string& name, std::string& model); static void SpawnPed(std::string& cat, std::string& name, std::string& model);
#endif #endif
}; };

View File

@ -3,6 +3,7 @@
#include "menu.h" #include "menu.h"
#include "ui.h" #include "ui.h"
#include "util.h" #include "util.h"
#ifdef GTASA #ifdef GTASA
#include "ped.h" #include "ped.h"
@ -205,7 +206,7 @@ Player::Player()
player->m_nFlags.bExplosionProof = 1; player->m_nFlags.bExplosionProof = 1;
player->m_nFlags.bFireProof = 1; player->m_nFlags.bFireProof = 1;
player->m_nFlags.bMeleeProof = 1; player->m_nFlags.bMeleeProof = 1;
#else // GTA3 #else
player->m_nEntityFlags.bBulletProof = m_bGodMode; player->m_nEntityFlags.bBulletProof = m_bGodMode;
player->m_nEntityFlags.bCollisionProof = m_bGodMode; player->m_nEntityFlags.bCollisionProof = m_bGodMode;
player->m_nEntityFlags.bExplosionProof = m_bGodMode; player->m_nEntityFlags.bExplosionProof = m_bGodMode;
@ -254,7 +255,7 @@ Player::Player()
player->m_nFlags.bExplosionProof = 0; player->m_nFlags.bExplosionProof = 0;
player->m_nFlags.bFireProof = 0; player->m_nFlags.bFireProof = 0;
player->m_nFlags.bMeleeProof = 0; player->m_nFlags.bMeleeProof = 0;
#else // GTA3 #else
player->m_nEntityFlags.bBulletProof = m_bGodMode; player->m_nEntityFlags.bBulletProof = m_bGodMode;
player->m_nEntityFlags.bCollisionProof = m_bGodMode; player->m_nEntityFlags.bCollisionProof = m_bGodMode;
player->m_nEntityFlags.bExplosionProof = m_bGodMode; player->m_nEntityFlags.bExplosionProof = m_bGodMode;
@ -351,7 +352,7 @@ void Player::ChangePlayerModel(std::string& model)
Util::ClearCharTasksVehCheck(player); Util::ClearCharTasksVehCheck(player);
} }
} }
#else // GTA3 & GTAVC #else
void Player::ChangePlayerModel(std::string& cat, std::string& key, std::string& val) void Player::ChangePlayerModel(std::string& cat, std::string& key, std::string& val)
{ {
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
@ -360,7 +361,7 @@ void Player::ChangePlayerModel(std::string& cat, std::string& key, std::string&
player->Undress(val.c_str()); player->Undress(val.c_str());
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(false);
player->Dress(); player->Dress();
#else // GTA3 #else
if (cat == "Special") if (cat == "Special")
{ {
// CStreaming::RequestSpecialChar(109, val.c_str(), PRIORITY_REQUEST); // CStreaming::RequestSpecialChar(109, val.c_str(), PRIORITY_REQUEST);
@ -460,7 +461,7 @@ void Player::Draw()
pPlayer->m_nFlags.bExplosionProof = m_bGodMode; pPlayer->m_nFlags.bExplosionProof = m_bGodMode;
pPlayer->m_nFlags.bFireProof = m_bGodMode; pPlayer->m_nFlags.bFireProof = m_bGodMode;
pPlayer->m_nFlags.bMeleeProof = m_bGodMode; pPlayer->m_nFlags.bMeleeProof = m_bGodMode;
#else // GTA3 #else
pPlayer->m_nEntityFlags.bBulletProof = m_bGodMode; pPlayer->m_nEntityFlags.bBulletProof = m_bGodMode;
pPlayer->m_nEntityFlags.bCollisionProof = m_bGodMode; pPlayer->m_nEntityFlags.bCollisionProof = m_bGodMode;
pPlayer->m_nEntityFlags.bExplosionProof = m_bGodMode; pPlayer->m_nEntityFlags.bExplosionProof = m_bGodMode;
@ -476,7 +477,7 @@ void Player::Draw()
pPlayer->m_nPedFlags.bDontRender = (pPlayer->m_nPedFlags.bDontRender == 1) ? 0 : 1; pPlayer->m_nPedFlags.bDontRender = (pPlayer->m_nPedFlags.bDontRender == 1) ? 0 : 1;
} }
Ui::CheckboxAddress("Infinite sprint", 0xB7CEE4); Ui::CheckboxAddress("Infinite sprint", 0xB7CEE4);
#else // GTA3 & GTAVC #else
Ui::CheckboxAddress("Infinite sprint", BY_GAME(NULL, (int)&pInfo->m_bNeverGetsTired, (int)&pInfo->m_bInfiniteSprint)); Ui::CheckboxAddress("Infinite sprint", BY_GAME(NULL, (int)&pInfo->m_bNeverGetsTired, (int)&pInfo->m_bInfiniteSprint));
#endif #endif
@ -497,7 +498,7 @@ void Player::Draw()
{ {
CCheat::NotWantedCheat(); CCheat::NotWantedCheat();
} }
#else // GTA3 & GTAVC #else
static bool neverWanted = false; static bool neverWanted = false;
if (Ui::CheckboxWithHint("Never wanted", &neverWanted)) if (Ui::CheckboxWithHint("Never wanted", &neverWanted))
{ {
@ -632,7 +633,7 @@ void Player::Draw()
Ui::EditStat("Lung capacity", STAT_LUNG_CAPACITY); Ui::EditStat("Lung capacity", STAT_LUNG_CAPACITY);
Ui::EditStat("Max health", STAT_MAX_HEALTH, 0, 569, 1450); Ui::EditStat("Max health", STAT_MAX_HEALTH, 0, 569, 1450);
Ui::EditAddress<int>("Money", 0xB7CE50, -99999999, 0, 99999999); Ui::EditAddress<int>("Money", 0xB7CE50, -99999999, 0, 99999999);
#else // GTA3 & GTAVC #else
int money = pInfo->m_nMoney; int money = pInfo->m_nMoney;
Ui::EditAddress<int>("Money", (int)&money, -9999999, 0, 99999999); Ui::EditAddress<int>("Money", (int)&money, -9999999, 0, 99999999);
pInfo->m_nMoney = money; pInfo->m_nMoney = money;
@ -662,7 +663,7 @@ void Player::Draw()
int val = pPlayer->m_pPlayerData->m_pWanted->m_nWantedLevel; int val = pPlayer->m_pPlayerData->m_pWanted->m_nWantedLevel;
int max_wl = pPlayer->m_pPlayerData->m_pWanted->MaximumWantedLevel; int max_wl = pPlayer->m_pPlayerData->m_pWanted->MaximumWantedLevel;
max_wl = max_wl < 6 ? 6 : max_wl; max_wl = max_wl < 6 ? 6 : max_wl;
#else // GTA3 & GTAVC #else
int val = pPlayer->m_pWanted->m_nWantedLevel; int val = pPlayer->m_pWanted->m_nWantedLevel;
int max_wl = 6; int max_wl = 6;
#endif #endif
@ -683,7 +684,7 @@ void Player::Draw()
pPlayer->CheatWantedLevel(val); pPlayer->CheatWantedLevel(val);
#elif GTAVC #elif GTAVC
pPlayer->m_pWanted->CheatWantedLevel(val); pPlayer->m_pWanted->CheatWantedLevel(val);
#else // GTA3 #else
pPlayer->m_pWanted->SetWantedLevel(val); pPlayer->m_pWanted->SetWantedLevel(val);
#endif #endif
} }
@ -695,7 +696,7 @@ void Player::Draw()
pPlayer->CheatWantedLevel(0); pPlayer->CheatWantedLevel(0);
#elif GTAVC #elif GTAVC
pPlayer->m_pWanted->CheatWantedLevel(0); pPlayer->m_pWanted->CheatWantedLevel(0);
#else // GTA3 #else
pPlayer->m_pWanted->SetWantedLevel(0); pPlayer->m_pWanted->SetWantedLevel(0);
#endif #endif
} }
@ -708,7 +709,7 @@ void Player::Draw()
pPlayer->CheatWantedLevel(0); pPlayer->CheatWantedLevel(0);
#elif GTAVC #elif GTAVC
pPlayer->m_pWanted->CheatWantedLevel(0); pPlayer->m_pWanted->CheatWantedLevel(0);
#else // GTA3 #else
pPlayer->m_pWanted->SetWantedLevel(0); pPlayer->m_pWanted->SetWantedLevel(0);
#endif #endif
} }
@ -721,7 +722,7 @@ void Player::Draw()
pPlayer->CheatWantedLevel(max_wl); pPlayer->CheatWantedLevel(max_wl);
#elif GTAVC #elif GTAVC
pPlayer->m_pWanted->CheatWantedLevel(max_wl); pPlayer->m_pWanted->CheatWantedLevel(max_wl);
#else // GTA3 #else
pPlayer->m_pWanted->SetWantedLevel(max_wl); pPlayer->m_pWanted->SetWantedLevel(max_wl);
#endif #endif
} }
@ -746,15 +747,7 @@ void Player::Draw()
{ {
if (ImGui::BeginTabItem("Clothes")) if (ImGui::BeginTabItem("Clothes"))
{ {
static int bClothOption = 0;
ImGui::RadioButton("Add", &bClothOption, 0);
ImGui::SameLine();
ImGui::RadioButton("Remove", &bClothOption, 1);
ImGui::Spacing();
if (pPlayer->m_nModelIndex == 0) if (pPlayer->m_nModelIndex == 0)
{
if (bClothOption == 0)
{ {
Ui::DrawImages(m_ClothData, ChangePlayerCloth, nullptr, Ui::DrawImages(m_ClothData, ChangePlayerCloth, nullptr,
[](std::string str) [](std::string str)
@ -770,8 +763,25 @@ void Player::Draw()
} }
else else
{ {
size_t count = 0; ImGui::TextWrapped("You need to be in CJ skin.");
ImGui::Spacing();
if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1))))
{
pPlayer->SetModelIndex(0);
Util::ClearCharTasksVehCheck(pPlayer);
}
}
ImGui::EndTabItem();
}
if (pPlayer->m_nModelIndex == 0
&& ImGui::BeginTabItem("Remove Clothes"))
{
ImGui::TextWrapped("If CJ is wearing a full suit, click 'Extras' or 'Remove all' to remove it.");
ImGui::Spacing();
ImGui::BeginChild("ClothesRemove");
size_t count = 0;
if (ImGui::Button("Remove all", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("Remove all", ImVec2(Ui::GetSize(2))))
{ {
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
@ -797,28 +807,16 @@ void Player::Draw()
} }
++count; ++count;
} }
ImGui::EndChild();
ImGui::Spacing();
ImGui::TextWrapped("If CJ is wearing a full suit, click 'Extras/ Remove all' to remove it.");
}
}
else
{
ImGui::TextWrapped("You need to be in CJ skin.");
ImGui::Spacing();
if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1))))
{
pPlayer->SetModelIndex(0);
Util::ClearCharTasksVehCheck(pPlayer);
}
}
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Ped skins")) if (ImGui::BeginTabItem("Ped skins"))
{ {
Ui::DrawImages(Ped::m_PedData, ChangePlayerModel, nullptr, Ui::DrawImages(Ped::m_PedData, ChangePlayerModel, nullptr,
[](std::string str) { return Ped::m_PedData.m_pJson->m_Data[str].get<std::string>(); }); [](std::string str)
{
return Ped::m_PedData.m_pJson->m_Data[str].get<std::string>();
});
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Custom skins")) if (ImGui::BeginTabItem("Custom skins"))
@ -870,7 +868,7 @@ Limitations:\n\
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
#else // GTA3 & GTA #else
if (ImGui::BeginTabItem("Skins")) if (ImGui::BeginTabItem("Skins"))
{ {
ImGui::Spacing(); ImGui::Spacing();

View File

@ -18,7 +18,7 @@ private:
static inline bool m_bDrunkEffect; static inline bool m_bDrunkEffect;
static inline bool m_bFastSprint; static inline bool m_bFastSprint;
static inline int m_nUiBodyState; static inline int m_nUiBodyState;
static inline ResourceStore m_ClothData { "clothes" , eResourceType::TYPE_IMAGE, ImVec2(70, 100)}; static inline ResourceStore m_ClothData { "clothes", eResourceType::TYPE_IMAGE, ImVec2(70, 100)};
struct m_CustomSkins struct m_CustomSkins
{ {
static inline std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");; static inline std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");;
@ -31,8 +31,8 @@ private:
static inline bool m_bEnabled = false; static inline bool m_bEnabled = false;
static inline float m_fOffset = 40.0f; static inline float m_fOffset = 40.0f;
}; };
#else // GTA3 & GTAVC #else
static inline ResourceStore skinData{ BY_GAME(NULL, "skin", "ped"), eResourceType::TYPE_TEXT }; static inline ResourceStore skinData { BY_GAME(NULL, "skin", "ped"), eResourceType::TYPE_TEXT };
#endif #endif
public: public:
@ -43,7 +43,7 @@ public:
static void ChangePlayerModel(std::string& model); static void ChangePlayerModel(std::string& model);
static void ChangePlayerCloth(std::string& model); static void ChangePlayerCloth(std::string& model);
static void TopDownCameraView(); static void TopDownCameraView();
#else // GTA3 & GTAVC #else
static void ChangePlayerModel(std::string& cat, std::string& name, std::string& id); static void ChangePlayerModel(std::string& cat, std::string& name, std::string& id);
#endif #endif
}; };

View File

@ -3,7 +3,7 @@
#include "extensions/Paths.h" #include "extensions/Paths.h"
ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageSize) ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageSize)
: m_ImageSize(imageSize) : m_ImageSize(imageSize)
{ {
if (type == eResourceType::TYPE_TEXT if (type == eResourceType::TYPE_TEXT
|| type == eResourceType::TYPE_BOTH) || type == eResourceType::TYPE_BOTH)

View File

@ -55,7 +55,7 @@ Teleport::Teleport()
CEntity* player_entity = FindPlayerEntity(-1); CEntity* player_entity = FindPlayerEntity(-1);
m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y, m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y,
m_Teleport::m_fPos.z + 100.0f, nullptr, &player_entity) + 1.0f; m_Teleport::m_fPos.z + 100.0f, nullptr, &player_entity) + 1.0f;
#else // GTA3 & GTAVC #else
m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y, m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y,
m_Teleport::m_fPos.z + 100.0f, nullptr) + 1.0f; m_Teleport::m_fPos.z + 100.0f, nullptr) + 1.0f;
#endif #endif
@ -139,7 +139,7 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id)
{ {
pPlayer->Teleport(pos, false); pPlayer->Teleport(pos, false);
} }
#else // GTA3 & GTAVC #else
if (pVeh && pPlayer->m_pVehicle) if (pVeh && pPlayer->m_pVehicle)
{ {
#ifndef GTA3 #ifndef GTA3

View File

@ -25,10 +25,10 @@ private:
#ifdef GTASA #ifdef GTASA
/* /*
Generates radar sprite coordinates on the fly. Generates radar sprite coordinates on the fly.
Shouldn't get saved in 'teleport.json', needs to be cleared at game shutdown. Shouldn't get saved in 'teleport.json', needs to be cleared at game shutdown.
*/ */
static void FetchRadarSpriteData(); static void FetchRadarSpriteData();
#endif #endif

View File

@ -130,7 +130,7 @@ uchar *m_nBlurRed = (uchar *)0x94B790;
uchar *m_nBlurGreen = (uchar *)0x8621A0; uchar *m_nBlurGreen = (uchar *)0x8621A0;
uchar *m_nBlurBlue = (uchar *)0x945728; uchar *m_nBlurBlue = (uchar *)0x945728;
#else // GTA3 #else
int *m_nAmbientRed = (int *)0x86AF78; int *m_nAmbientRed = (int *)0x86AF78;
int *m_nAmbientGreen = (int *)0x665308; int *m_nAmbientGreen = (int *)0x665308;

View File

@ -101,7 +101,7 @@ int Util::GetLargestGangInZone()
// https://github.com/cleolibrary/CLEO4/blob/916d400f4a731ba1dd0ff16e52bdb056f42b7038/source/CCustomOpcodeSystem.cpp#L1671 // https://github.com/cleolibrary/CLEO4/blob/916d400f4a731ba1dd0ff16e52bdb056f42b7038/source/CCustomOpcodeSystem.cpp#L1671
CVehicle* Util::GetClosestVehicle() CVehicle* Util::GetClosestVehicle()
{ {
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
#ifdef GTASA #ifdef GTASA
CPedIntelligence* pedintel; CPedIntelligence* pedintel;
@ -119,7 +119,7 @@ CPlayerPed* player = FindPlayerPed();
return veh; return veh;
} }
return nullptr; return nullptr;
#else // GTAVC & GTA3 #else
CVehicle *pClosestVeh = nullptr; CVehicle *pClosestVeh = nullptr;
float distance = 999.0f; float distance = 999.0f;
@ -143,7 +143,7 @@ CPlayerPed* player = FindPlayerPed();
CPed* Util::GetClosestPed() CPed* Util::GetClosestPed()
{ {
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
#ifdef GTASA #ifdef GTASA
CPedIntelligence* pedintel; CPedIntelligence* pedintel;
if (player && (pedintel = player->m_pIntelligence)) if (player && (pedintel = player->m_pIntelligence))
@ -161,7 +161,7 @@ CPlayerPed* player = FindPlayerPed();
return ped; return ped;
} }
return nullptr; return nullptr;
#else // GTA3 & GTAVC #else
return player->m_apNearPeds[0]; return player->m_apNearPeds[0];
#endif #endif
} }

View File

@ -16,7 +16,7 @@ void Vehicle::FixVehicle(CVehicle *pVeh)
{ {
#ifdef GTASA #ifdef GTASA
pVeh->Fix(); pVeh->Fix();
#else // GTA3 & GTAVC #else
switch (pVeh->m_nVehicleClass) switch (pVeh->m_nVehicleClass)
{ {
case VEHICLE_AUTOMOBILE: case VEHICLE_AUTOMOBILE:
@ -58,7 +58,7 @@ void FlipVehicle()
y += 135.0f; y += 135.0f;
pPlayer->m_pVehicle->m_placement.SetOrientation(x, y, z); pPlayer->m_pVehicle->m_placement.SetOrientation(x, y, z);
} }
#else // GTA3 #else
if (pPlayer->m_bInVehicle) if (pPlayer->m_bInVehicle)
{ {
float x,y,z; float x,y,z;
@ -302,7 +302,8 @@ void Vehicle::RemoveComponent(const std::string& component, const bool display_m
// hardcoded for now // hardcoded for now
int Vehicle::GetRandomTrainIdForModel(int model) int Vehicle::GetRandomTrainIdForModel(int model)
{ {
static int train_ids[] = { static int train_ids[] =
{
8, 9, // model 449 8, 9, // model 449
0, 3, 6, 10, 12, 13, // model 537 0, 3, 6, 10, 12, 13, // model 537
1, 5, 15 // model 538 1, 5, 15 // model 538
@ -369,7 +370,7 @@ void WarpPlayerIntoVehicle(CVehicle *pVeh, int seatId)
#ifdef GTASA #ifdef GTASA
void Vehicle::SpawnVehicle(std::string& smodel) void Vehicle::SpawnVehicle(std::string& smodel)
#else // GTA3 & GTAVC #else
void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& smodel) void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& smodel)
#endif #endif
{ {
@ -404,7 +405,7 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri
{ {
Command<Commands::DELETE_CAR>(hveh); Command<Commands::DELETE_CAR>(hveh);
} }
#else // GTA3 & GTAVC #else
Command<Commands::DELETE_CAR>(hveh); Command<Commands::DELETE_CAR>(hveh);
#endif #endif
} }
@ -489,7 +490,7 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri
float x,y,z; float x,y,z;
player->m_placement.GetOrientation(x, y, z); player->m_placement.GetOrientation(x, y, z);
veh->m_placement.SetOrientation(x, y, z); veh->m_placement.SetOrientation(x, y, z);
#else // GTA3 #else
float x,y,z; float x,y,z;
player->GetOrientation(x, y, z); player->GetOrientation(x, y, z);
veh->SetOrientation(x, y, z); veh->SetOrientation(x, y, z);
@ -504,7 +505,7 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri
{ {
#ifdef GTASA #ifdef GTASA
player->TransformFromObjectSpace(pos, CVector(0, 10, 0)); player->TransformFromObjectSpace(pos, CVector(0, 10, 0));
#else // GTA3 & GTAVC #else
player->TransformFromObjectSpace(pos); player->TransformFromObjectSpace(pos);
#endif #endif
Command<Commands::CREATE_CAR>(imodel, pos.x, pos.y, pos.z + 3.0f, &hveh); Command<Commands::CREATE_CAR>(imodel, pos.x, pos.y, pos.z + 3.0f, &hveh);
@ -515,7 +516,7 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri
float x,y,z; float x,y,z;
player->m_placement.GetOrientation(x, y, z); player->m_placement.GetOrientation(x, y, z);
veh->m_placement.SetOrientation(x, y, z); veh->m_placement.SetOrientation(x, y, z);
#else // GTA3 #else
float x,y,z; float x,y,z;
player->GetOrientation(x, y, z); player->GetOrientation(x, y, z);
veh->SetOrientation(x, y, z); veh->SetOrientation(x, y, z);
@ -530,7 +531,7 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri
#ifdef GTASA #ifdef GTASA
} }
veh->m_nVehicleFlags.bHasBeenOwnedByPlayer = true; veh->m_nVehicleFlags.bHasBeenOwnedByPlayer = true;
#else // GTA3 & GTAVC #else
Command<Commands::RESTORE_CAMERA_JUMPCUT>(); Command<Commands::RESTORE_CAMERA_JUMPCUT>();
#endif #endif
} }
@ -636,7 +637,7 @@ void Vehicle::Draw()
pVeh->m_nFlags.bFireProof = false; pVeh->m_nFlags.bFireProof = false;
pVeh->m_nFlags.bCollisionProof = false; pVeh->m_nFlags.bCollisionProof = false;
pVeh->m_nFlags.bMeleeProof = false; pVeh->m_nFlags.bMeleeProof = false;
#else // GTA3 #else
pVeh->m_nEntityFlags.bBulletProof = false; pVeh->m_nEntityFlags.bBulletProof = false;
pVeh->m_nEntityFlags.bExplosionProof = false; pVeh->m_nEntityFlags.bExplosionProof = false;
pVeh->m_nEntityFlags.bFireProof = false; pVeh->m_nEntityFlags.bFireProof = false;
@ -923,7 +924,8 @@ void Vehicle::Draw()
Ui::RadioButtonAddress("Color", color); Ui::RadioButtonAddress("Color", color);
ImGui::Spacing(); ImGui::Spacing();
#ifdef GTASA #ifdef GTASA
static std::vector<Ui::NamedMemory> type{ static std::vector<Ui::NamedMemory> type
{
{"Cheap", 0x96915E}, {"Country", 0x96917B}, {"Fast", 0x96915F} {"Cheap", 0x96915E}, {"Country", 0x96917B}, {"Fast", 0x96915F}
}; };
Ui::RadioButtonAddress("Type", type); Ui::RadioButtonAddress("Type", type);
@ -1057,7 +1059,7 @@ void Vehicle::Draw()
{ {
return GetNameFromModel(std::stoi(str)); return GetNameFromModel(std::stoi(str));
}); });
#else // GTA3 & GTAVC #else
Ui::DrawJSON(m_Spawner::m_VehData, SpawnVehicle, nullptr); Ui::DrawJSON(m_Spawner::m_VehData, SpawnVehicle, nullptr);
#endif #endif
ImGui::EndTabItem(); ImGui::EndTabItem();
@ -1102,7 +1104,7 @@ void Vehicle::Draw()
ImGui::NewLine(); ImGui::NewLine();
ImGui::RadioButton("Tertiary", &m_Paint::m_nRadioButton, 3); ImGui::RadioButton("Tertiary", &m_Paint::m_nRadioButton, 3);
ImGui::RadioButton("Quaternary", &m_Paint::m_nRadioButton, 4); ImGui::RadioButton("Quaternary", &m_Paint::m_nRadioButton, 4);
#else // GTA3 & GTAVC #else
ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1); ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1);
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2); ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2);
@ -1259,9 +1261,18 @@ void Vehicle::Draw()
{ {
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawImages(m_TuneData, Ui::DrawImages(m_TuneData,
[](std::string& str) { AddComponent(str); }, [](std::string& str)
[](std::string& str) { RemoveComponent(str); }, {
[](std::string& str) { return str; }, AddComponent(str);
},
[](std::string& str)
{
RemoveComponent(str);
},
[](std::string& str)
{
return str;
},
[pPlayer](std::string& str) [pPlayer](std::string& str)
{ {
return ((bool(*)(int, CVehicle*))0x49B010)(std::stoi(str), pPlayer->m_pVehicle); return ((bool(*)(int, CVehicle*))0x49B010)(std::stoi(str), pPlayer->m_pVehicle);
@ -1316,7 +1327,8 @@ void Vehicle::Draw()
Ui::EditFloat("Damping level", pHandling + 0xB0, -10.0f, -10.0f, 10.0f); // test later Ui::EditFloat("Damping level", pHandling + 0xB0, -10.0f, -10.0f, 10.0f); // test later
Ui::EditFloat("Drag mult", pHandling + 0x10, 0.0f, 0.0f, 30.0f); Ui::EditFloat("Drag mult", pHandling + 0x10, 0.0f, 0.0f, 30.0f);
static std::vector<Ui::NamedValue> drive_type{ static std::vector<Ui::NamedValue> drive_type
{
{"Front wheel drive", 70}, {"Rear wheel drive", 82}, {"Four wheel drive", 52} {"Front wheel drive", 70}, {"Rear wheel drive", 82}, {"Four wheel drive", 52}
}; };
Ui::EditRadioButtonAddressEx("Drive type", pHandling + 0x74, drive_type); Ui::EditRadioButtonAddressEx("Drive type", pHandling + 0x74, drive_type);

View File

@ -20,7 +20,7 @@ private:
{ {
static inline bool m_bMatFilter = true; static inline bool m_bMatFilter = true;
static inline int m_nRadioButton = 1; static inline int m_nRadioButton = 1;
static inline float m_fColorPicker[3]{ 0, 0, 0 }; static inline float m_fColorPicker[3] { 0, 0, 0 };
static inline std::vector<std::string> m_vecNames{"Default"}; static inline std::vector<std::string> m_vecNames{"Default"};
static inline std::string m_Selected = "Default"; static inline std::string m_Selected = "Default";
}; };
@ -30,7 +30,7 @@ private:
static inline std::map<int, std::string> m_VehicleIDE; static inline std::map<int, std::string> m_VehicleIDE;
struct m_Neon struct m_Neon
{ {
static inline float m_fColorPicker[3]{ 0, 0, 0 }; static inline float m_fColorPicker[3] { 0, 0, 0 };
static inline bool m_bRainbowEffect; static inline bool m_bRainbowEffect;
static inline uint m_nRainbowTimer; static inline uint m_nRainbowTimer;
static inline bool m_bApplyOnTraffic; static inline bool m_bApplyOnTraffic;
@ -43,8 +43,8 @@ private:
{ {
#ifdef GTASA #ifdef GTASA
static inline ResourceStore m_VehData { "vehicles", eResourceType::TYPE_IMAGE, ImVec2(100, 75)}; static inline ResourceStore m_VehData { "vehicles", eResourceType::TYPE_IMAGE, ImVec2(100, 75)};
#else // GTA3 & GTAVC #else
static inline ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT}; static inline ResourceStore m_VehData {"vehicle", eResourceType::TYPE_TEXT};
#endif #endif
static inline bool m_bSpawnInside = true; static inline bool m_bSpawnInside = true;
static inline bool m_bSpawnInAir = true; static inline bool m_bSpawnInAir = true;
@ -93,7 +93,7 @@ private:
public: public:
#ifdef GTASA #ifdef GTASA
static void SpawnVehicle(std::string& name); static void SpawnVehicle(std::string& name);
#else // GTA3 & GTAVC #else
static void SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& model); static void SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& model);
#endif #endif
static std::string GetNameFromModel(int model); static std::string GetNameFromModel(int model);

View File

@ -13,7 +13,7 @@
#define TOTAL_WEATHERS 23 #define TOTAL_WEATHERS 23
#elif GTAVC #elif GTAVC
#define TOTAL_WEATHERS 7 #define TOTAL_WEATHERS 7
#else // GTA3 #else
#define TOTAL_WEATHERS 4 #define TOTAL_WEATHERS 4
#endif #endif
@ -47,7 +47,7 @@ int GetTCVal(T* addr, int index)
{ {
#ifdef GTASA #ifdef GTASA
T* arr = static_cast<T*>(patch::GetPointer(int(addr))); T* arr = static_cast<T*>(patch::GetPointer(int(addr)));
#else // GTA3 & GTAVC #else
T* arr = static_cast<T*>(addr); T* arr = static_cast<T*>(addr);
#endif #endif
return static_cast<int>(arr[index]); return static_cast<int>(arr[index]);
@ -120,7 +120,7 @@ void Visual::GenerateTimecycFile()
file << buffer << std::endl; file << buffer << std::endl;
} }
} }
#else // GTA3 & GTAVC #else
std::ofstream file = std::ofstream("timecyc.dat"); std::ofstream file = std::ofstream("timecyc.dat");
for (uint i = 0; i < TOTAL_WEATHERS; ++i) for (uint i = 0; i < TOTAL_WEATHERS; ++i)
@ -151,7 +151,7 @@ void Visual::GenerateTimecycFile()
#ifdef GTA3 #ifdef GTA3
buffer += "// Amb Dir Sky top Sky bot SunCore SunCorona SunSz SprSz SprBght Shdw LightShd TreeShd FarClp FogSt LightOnGround LowCloudsRGB TopCloudRGB BottomCloudRGB PostFx"; buffer += "// Amb Dir Sky top Sky bot SunCore SunCorona SunSz SprSz SprBght Shdw LightShd TreeShd FarClp FogSt LightOnGround LowCloudsRGB TopCloudRGB BottomCloudRGB PostFx";
#else // GTAVC #else
buffer += "// Amb Amb_Obj Amb_bl Amb_Obj_bl Dir Sky top Sky bot SunCore SunCorona SunSz SprSz SprBght Shdw LightShd PoleShd FarClp FogSt LightOnGround LowCloudsRGB TopCloudRGB BottomCloudRGB BlurRGB WaterRGBA"; buffer += "// Amb Amb_Obj Amb_bl Amb_Obj_bl Dir Sky top Sky bot SunCore SunCorona SunSz SprSz SprBght Shdw LightShd PoleShd FarClp FogSt LightOnGround LowCloudsRGB TopCloudRGB BottomCloudRGB BlurRGB WaterRGBA";
#endif #endif
file << buffer << std::endl; file << buffer << std::endl;
@ -164,7 +164,8 @@ void Visual::GenerateTimecycFile()
{ {
buffer = "// Extra Color " + std::to_string(j); buffer = "// Extra Color " + std::to_string(j);
static std::string intNames[] = { static std::string intNames[] =
{
"Maibu Club", "Strip Club", "Hotel", "Bank", "Police HQ", "Mall", "Rifle Range", "Mansion", "Dirtring", "Blood ring", "Maibu Club", "Strip Club", "Hotel", "Bank", "Police HQ", "Mall", "Rifle Range", "Mansion", "Dirtring", "Blood ring",
"Hotring", "Concert Hall", "Auntie Poulets", "Intro at Docks", "Biker Bar", "Intro Cafe Dark Room", "Studio" "Hotring", "Concert Hall", "Auntie Poulets", "Intro at Docks", "Biker Bar", "Intro Cafe Dark Room", "Studio"
}; };
@ -278,13 +279,13 @@ bool Visual::TimeCycColorEdit3(const char* label, T* r, T* g, T* b, ImGuiColorEd
auto red = static_cast<T*>(patch::GetPointer(int(r))); auto red = static_cast<T*>(patch::GetPointer(int(r)));
auto green = static_cast<T*>(patch::GetPointer(int(g))); auto green = static_cast<T*>(patch::GetPointer(int(g)));
auto blue = static_cast<T*>(patch::GetPointer(int(b))); auto blue = static_cast<T*>(patch::GetPointer(int(b)));
#else // GTA3 & GTAVC #else
auto red = static_cast<T*>(r); auto red = static_cast<T*>(r);
auto green = static_cast<T*>(g); auto green = static_cast<T*>(g);
auto blue = static_cast<T*>(b); auto blue = static_cast<T*>(b);
#endif #endif
float col[3]{ red[val] / 255.0f, green[val] / 255.0f, blue[val] / 255.0f }; float col[3] { red[val] / 255.0f, green[val] / 255.0f, blue[val] / 255.0f };
if (ImGui::ColorEdit3(label, col, flags)) if (ImGui::ColorEdit3(label, col, flags))
{ {
@ -304,7 +305,7 @@ void Visual::TimecycSlider(const char* label, T* ptr, int min, int max)
#ifdef GTASA #ifdef GTASA
// Compatable with 24h TimeCyc // Compatable with 24h TimeCyc
T* arr = static_cast<T*>(patch::GetPointer(int(ptr))); T* arr = static_cast<T*>(patch::GetPointer(int(ptr)));
#else // GTA3 & GTAVC #else
T* arr = static_cast<T*>(ptr); T* arr = static_cast<T*>(ptr);
#endif #endif
int a = arr[val]; int a = arr[val];
@ -324,14 +325,14 @@ bool Visual::TimeCycColorEdit4(const char* label, T* r, T* g, T* b, T* a, ImGuiC
auto green = static_cast<T*>(patch::GetPointer(int(g))); auto green = static_cast<T*>(patch::GetPointer(int(g)));
auto blue = static_cast<T*>(patch::GetPointer(int(b))); auto blue = static_cast<T*>(patch::GetPointer(int(b)));
auto alpha = static_cast<T*>(patch::GetPointer(int(a))); auto alpha = static_cast<T*>(patch::GetPointer(int(a)));
#else // GTA3 & GTAVC #else
auto red = static_cast<T*>(r); auto red = static_cast<T*>(r);
auto green = static_cast<T*>(g); auto green = static_cast<T*>(g);
auto blue = static_cast<T*>(b); auto blue = static_cast<T*>(b);
auto alpha = static_cast<T*>(a); auto alpha = static_cast<T*>(a);
#endif #endif
float col[4]{ red[val] / 255.0f, green[val] / 255.0f, blue[val] / 255.0f, alpha[val] / 255.0f }; float col[4] { red[val] / 255.0f, green[val] / 255.0f, blue[val] / 255.0f, alpha[val] / 255.0f };
if (ImGui::ColorEdit4(label, col, flags)) if (ImGui::ColorEdit4(label, col, flags))
{ {
@ -446,7 +447,7 @@ void Visual::Draw()
Ui::CheckboxAddress("Green scanlines", 0xA10B69); Ui::CheckboxAddress("Green scanlines", 0xA10B69);
Ui::CheckboxAddress("White scanlines", 0xA10B68); Ui::CheckboxAddress("White scanlines", 0xA10B68);
#else // GTA3 #else
static bool hideHud, hideRadar; static bool hideHud, hideRadar;
if (Ui::CheckboxWithHint("Hide hud", &hideHud)) if (Ui::CheckboxWithHint("Hide hud", &hideHud))
{ {
@ -567,7 +568,8 @@ void Visual::Draw()
Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54, 104, 44, 255)); Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54, 104, 44, 255));
Ui::EditAddress<float>("Money posX", *(int*)0x58F5FC, -999, 32, 999); Ui::EditAddress<float>("Money posX", *(int*)0x58F5FC, -999, 32, 999);
Ui::EditAddress<float>("Money posY", 0x866C88, -999, 89, 999); Ui::EditAddress<float>("Money posY", 0x866C88, -999, 89, 999);
static std::vector<Ui::NamedValue> font_outline{ static std::vector<Ui::NamedValue> font_outline
{
{"No outline", 0}, {"Thin outline", 1}, {"Default outline", 2} {"No outline", 0}, {"Thin outline", 1}, {"Default outline", 2}
}; };
Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline); Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline);
@ -601,7 +603,7 @@ void Visual::Draw()
#ifdef GTASA #ifdef GTASA
if (m_nTimecycHour == 8 ? ImGui::BeginTabItem("Timecyc") : ImGui::BeginTabItem("Timecyc 24h")) if (m_nTimecycHour == 8 ? ImGui::BeginTabItem("Timecyc") : ImGui::BeginTabItem("Timecyc 24h"))
#else // GTA3 & GTAVC #else
if (ImGui::BeginTabItem("Timecyc")) if (ImGui::BeginTabItem("Timecyc"))
#endif #endif
{ {

View File

@ -2,7 +2,6 @@
#include "weapon.h" #include "weapon.h"
#include "ui.h" #include "ui.h"
#include "util.h" #include "util.h"
#include "ped.h"
#include "CWeaponInfo.h" #include "CWeaponInfo.h"
Weapon::Weapon() Weapon::Weapon()
@ -41,7 +40,7 @@ Weapon::Weapon()
#ifdef GTASA #ifdef GTASA
CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType, player->GetWeaponSkill(weaponType)); CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType, player->GetWeaponSkill(weaponType));
#else // GTA3 & GTAVC #else
CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType); CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType);
if(m_bInfiniteAmmo) if(m_bInfiniteAmmo)
@ -62,7 +61,7 @@ Weapon::Weapon()
pWeaponInfo->m_fWeaponRange = 1000.0f; pWeaponInfo->m_fWeaponRange = 1000.0f;
pWeaponInfo->m_fAccuracy = 1.0f; pWeaponInfo->m_fAccuracy = 1.0f;
pWeaponInfo->m_nFlags.bReload2Start = true; pWeaponInfo->m_nFlags.bReload2Start = true;
#else // GTA3 & GTAVC #else
pWeaponInfo->m_fRange = 1000.0f; pWeaponInfo->m_fRange = 1000.0f;
#endif #endif
} }
@ -101,7 +100,7 @@ void Weapon::SetGangWeapon(std::string& weapon_type)
CGangs::SetGangWeapons(m_nSelectedGang, m_nGangWeaponList[m_nSelectedGang][0], m_nGangWeaponList[m_nSelectedGang][1], CGangs::SetGangWeapons(m_nSelectedGang, m_nGangWeaponList[m_nSelectedGang][0], m_nGangWeaponList[m_nSelectedGang][1],
m_nGangWeaponList[m_nSelectedGang][2]); m_nGangWeaponList[m_nSelectedGang][2]);
} }
#else // GTA3 & GTAVC #else
// Implementation of SA opcode 0x555 // Implementation of SA opcode 0x555
static void ClearPlayerWeapon(eWeaponType weaponType) static void ClearPlayerWeapon(eWeaponType weaponType)
{ {
@ -208,7 +207,7 @@ void Weapon::GiveWeaponToPlayer(std::string& weapon_type)
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(model); Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(model);
} }
} }
#else // GTA3 & GTAVC #else
void Weapon::GiveWeaponToPlayer(std::string& rootkey, std::string& name, std::string& model) void Weapon::GiveWeaponToPlayer(std::string& rootkey, std::string& name, std::string& model)
{ {
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
@ -248,14 +247,14 @@ void Weapon::Draw()
int model = 0, pickup = 0; int model = 0, pickup = 0;
#ifdef GTASA #ifdef GTASA
Command<Commands::GET_WEAPONTYPE_MODEL>(weaponType, &model); Command<Commands::GET_WEAPONTYPE_MODEL>(weaponType, &model);
#else // GTA3 & GTAVC #else
model = CallAndReturn<int, BY_GAME(NULL, 0x4418B0, 0x430690)>(weaponType); // int __cdecl CPickups::ModelForWeapon(int a1) model = CallAndReturn<int, BY_GAME(NULL, 0x4418B0, 0x430690)>(weaponType); // int __cdecl CPickups::ModelForWeapon(int a1)
#endif #endif
Command<Commands::CREATE_PICKUP_WITH_AMMO>(model, 3, 999, x, y, z, &pickup); Command<Commands::CREATE_PICKUP_WITH_AMMO>(model, 3, 999, x, y, z, &pickup);
#ifdef GTASA #ifdef GTASA
Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, weaponType); Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, weaponType);
#else // GTA3 & GTAVC #else
ClearPlayerWeapon(weaponType); ClearPlayerWeapon(weaponType);
#endif #endif
} }
@ -273,7 +272,7 @@ void Weapon::Draw()
Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType); Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType);
#elif GTAVC #elif GTAVC
ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType); ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType);
#else // GTA3 #else
ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType); ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType);
#endif #endif
} }
@ -364,10 +363,16 @@ void Weapon::Draw()
} }
#ifdef GTASA #ifdef GTASA
Ui::DrawImages(m_WeaponData, GiveWeaponToPlayer, nullptr, Ui::DrawImages(m_WeaponData, GiveWeaponToPlayer, nullptr,
[](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); }, [](std::string str)
[](std::string str) { return str != "0"; /*Unarmed*/ } {
return m_WeaponData.m_pJson->m_Data[str].get<std::string>();
},
[](std::string str)
{
return str != "0"; /*Unarmed*/
}
); );
#else // GTA3 & GTAVC #else
Ui::DrawJSON(m_WeaponData, GiveWeaponToPlayer, nullptr); Ui::DrawJSON(m_WeaponData, GiveWeaponToPlayer, nullptr);
#endif #endif
ImGui::EndTabItem(); ImGui::EndTabItem();
@ -376,7 +381,7 @@ void Weapon::Draw()
if (ImGui::BeginTabItem("Gang weapon editor")) if (ImGui::BeginTabItem("Gang weapon editor"))
{ {
ImGui::Spacing(); ImGui::Spacing();
Ui::ListBox("Select gang", Ped::m_GangNames, m_nSelectedGang); Ui::ListBox("Select gang", m_GangList, m_nSelectedGang);
ImGui::Columns(3, 0, false); ImGui::Columns(3, 0, false);
ImGui::RadioButton("Weap 1", &m_nSelectedWeapon, 0); ImGui::RadioButton("Weap 1", &m_nSelectedWeapon, 0);
@ -392,8 +397,14 @@ void Weapon::Draw()
std::string>().c_str()); std::string>().c_str());
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawImages(m_WeaponData, SetGangWeapon, nullptr, Ui::DrawImages(m_WeaponData, SetGangWeapon, nullptr,
[](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); }, [](std::string str)
[](std::string str) { return str != "-1"; /*Jetpack*/ } {
return m_WeaponData.m_pJson->m_Data[str].get<std::string>();
},
[](std::string str)
{
return str != "-1"; /*Jetpack*/
}
); );
ImGui::EndTabItem(); ImGui::EndTabItem();
} }

View File

@ -1,11 +1,11 @@
#pragma once #pragma once
#include "CWeapon.h" #include "pch.h"
class Weapon class Weapon
{ {
public: public:
#ifdef GTASA #ifdef GTASA
static inline ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65) }; static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65) };
static inline bool m_bAutoAim; static inline bool m_bAutoAim;
static inline bool m_bRapidFire; static inline bool m_bRapidFire;
@ -26,8 +26,14 @@ public:
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 9 {WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 9
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 10 {WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 10
}; };
#else // GTA3 & GTAVC
static inline ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_TEXT }; static inline std::vector<std::string> m_GangList =
{
"Ballas", "Grove street families", "Los santos vagos", "San fierro rifa",
"Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10"
};
#else
static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_TEXT };
static inline bool m_bInfiniteAmmo; static inline bool m_bInfiniteAmmo;
#endif #endif
static inline bool m_bFastReload; static inline bool m_bFastReload;
@ -43,7 +49,7 @@ public:
#ifdef GTASA #ifdef GTASA
static void GiveWeaponToPlayer(std::string& weapon_type); static void GiveWeaponToPlayer(std::string& weapon_type);
static void SetGangWeapon(std::string& weapon_type); static void SetGangWeapon(std::string& weapon_type);
#else // GTA3 & GTAVC #else
static void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name); static void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name);
#endif #endif
}; };

BIN
tools/AStyle.exe Normal file

Binary file not shown.

2
tools/FormatCode.bat Normal file
View File

@ -0,0 +1,2 @@
start tools/AStyle.exe --style=allman -n --recursive src/*.cpp src/*.h