Refactor code, radarBlips fla compatible, new credits ui
This commit is contained in:
parent
5eb7bc0f41
commit
ba389f1ab7
@ -11,7 +11,6 @@
|
||||
|
||||
static bool bSaveGameFlag = false;
|
||||
|
||||
// Thanks to aap
|
||||
void Game::RealTimeClock()
|
||||
{
|
||||
time_t tmp = time(nullptr);
|
||||
@ -22,9 +21,9 @@ void Game::RealTimeClock()
|
||||
if (now->tm_yday != lastday)
|
||||
{
|
||||
CStats::SetStatValue(0x86, CStats::GetStatValue(0x86) + 1.0f);
|
||||
lastday = now->tm_yday;
|
||||
}
|
||||
|
||||
lastday = now->tm_yday;
|
||||
CClock::ms_nGameClockMonth = now->tm_mon + 1;
|
||||
CClock::ms_nGameClockDays = now->tm_mday;
|
||||
CClock::CurrentDay = now->tm_wday + 1;
|
||||
|
31
src/menu.cpp
31
src/menu.cpp
@ -606,10 +606,37 @@ void Menu::ShowPage()
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
ImGui::TextWrapped("If you find bugs or have suggestions, let me know on discord.");
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
ImGui::TextWrapped("Thanks to Junior-Djjr");
|
||||
ImGui::Dummy(ImVec2(0, 30));
|
||||
Ui::CenterdText("Copyright Grinch_ 2019-2022. All rights reserved");
|
||||
|
||||
ImGui::Dummy(ImVec2(0, 30));
|
||||
static ImGuiTableFlags flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY;
|
||||
if (ImGui::BeginTable("Hall of Fame", 2, flags))
|
||||
{
|
||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, 100);
|
||||
ImGui::TableSetupColumn("Credits");
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Codenulls");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("III & VC animation code");
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("DKPac22");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Vehicle texturing code");
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Junior-Djjr");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("Code & suggestions");
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ void Teleport::FetchRadarSpriteData()
|
||||
{
|
||||
uint cur_timer = CTimer::m_snTimeInMilliseconds;
|
||||
static uint timer = cur_timer;
|
||||
static int maxSprites = *(uint*)0x5D5870;
|
||||
|
||||
// Update the radar list each 5 seconds
|
||||
if (cur_timer - timer < 5000)
|
||||
@ -20,9 +21,7 @@ void Teleport::FetchRadarSpriteData()
|
||||
}
|
||||
|
||||
m_tpData.m_pJson->m_Data.erase("Radar");
|
||||
|
||||
// 175 is the max number of sprites, FLA can increase this limit, might need to update this
|
||||
for (int i = 0; i != 175; ++i)
|
||||
for (int i = 0; i != maxSprites; ++i)
|
||||
{
|
||||
CVector pos = CRadar::ms_RadarTrace[i].m_vPosition;
|
||||
uchar sprite = CRadar::ms_RadarTrace[i].m_nBlipSprite;
|
||||
|
71
src/util.cpp
71
src/util.cpp
@ -2,6 +2,63 @@
|
||||
#include "util.h"
|
||||
#include "psapi.h"
|
||||
|
||||
bool Util::IsInVehicle(CPed *pPed)
|
||||
{
|
||||
if (!pPed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return BY_GAME(pPed->m_nPedFlags.bInVehicle, pPed->m_bInVehicle, pPed->m_bInVehicle);
|
||||
}
|
||||
|
||||
void Util::FixVehicle(CVehicle *pVeh)
|
||||
{
|
||||
#ifdef GTASA
|
||||
pVeh->Fix();
|
||||
#else
|
||||
switch (pVeh->m_nVehicleClass)
|
||||
{
|
||||
case VEHICLE_AUTOMOBILE:
|
||||
{
|
||||
reinterpret_cast<CAutomobile*>(pVeh)->Fix();
|
||||
break;
|
||||
}
|
||||
#ifdef GTAVC
|
||||
case VEHICLE_BIKE:
|
||||
{
|
||||
reinterpret_cast<CBike *>(pVeh)->Fix();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
pVeh->m_fHealth = 1000.0f;
|
||||
}
|
||||
|
||||
void Util::FlipVehicle(CVehicle *pVeh)
|
||||
{
|
||||
#ifdef GTASA
|
||||
int hveh = CPools::GetVehicleRef(pVeh);
|
||||
float roll;
|
||||
|
||||
Command<Commands::GET_CAR_ROLL>(hveh, &roll);
|
||||
roll += 180;
|
||||
Command<Commands::SET_CAR_ROLL>(hveh, roll);
|
||||
Command<Commands::SET_CAR_ROLL>(hveh, roll); // z rot fix
|
||||
#elif GTAVC
|
||||
float x,y,z;
|
||||
pVeh->m_placement.GetOrientation(x, y, z);
|
||||
y += 135.0f;
|
||||
pVeh->m_placement.SetOrientation(x, y, z);
|
||||
#else
|
||||
float x,y,z;
|
||||
pVeh->GetOrientation(x, y, z);
|
||||
y += 135.0f;
|
||||
pVeh->SetOrientation(x, y, z);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Util::SetCarForwardSpeed(CVehicle *pVeh, float speed)
|
||||
{
|
||||
#ifdef GTA3
|
||||
@ -58,18 +115,18 @@ std::string Util::GetLocationName(CVector* pos)
|
||||
}
|
||||
|
||||
#ifdef GTASA
|
||||
void Util::ClearCharTasksVehCheck(CPed* ped)
|
||||
void Util::ClearCharTasksVehCheck(CPed* pPed)
|
||||
{
|
||||
uint hped = CPools::GetPedRef(ped);
|
||||
uint hped = CPools::GetPedRef(pPed);
|
||||
uint hveh = NULL;
|
||||
bool veh_engine = true;
|
||||
float speed;
|
||||
|
||||
if (ped->m_nPedFlags.bInVehicle)
|
||||
if (IsInVehicle(pPed))
|
||||
{
|
||||
hveh = CPools::GetVehicleRef(ped->m_pVehicle);
|
||||
veh_engine = ped->m_pVehicle->m_nVehicleFlags.bEngineOn;
|
||||
speed = ped->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f;
|
||||
hveh = CPools::GetVehicleRef(pPed->m_pVehicle);
|
||||
veh_engine = pPed->m_pVehicle->m_nVehicleFlags.bEngineOn;
|
||||
speed = pPed->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f;
|
||||
}
|
||||
|
||||
Command<Commands::CLEAR_CHAR_TASKS_IMMEDIATELY>(hped);
|
||||
@ -77,7 +134,7 @@ void Util::ClearCharTasksVehCheck(CPed* ped)
|
||||
if (hveh)
|
||||
{
|
||||
Command<Commands::TASK_WARP_CHAR_INTO_CAR_AS_DRIVER>(hped, hveh);
|
||||
ped->m_pVehicle->m_nVehicleFlags.bEngineOn = veh_engine;
|
||||
pPed->m_pVehicle->m_nVehicleFlags.bEngineOn = veh_engine;
|
||||
Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, speed);
|
||||
}
|
||||
}
|
||||
|
15
src/util.h
15
src/util.h
@ -2,6 +2,11 @@
|
||||
#include "tchar.h"
|
||||
#include "pdh.h"
|
||||
|
||||
|
||||
/*
|
||||
* Contains utility functions
|
||||
* for all 3 games
|
||||
*/
|
||||
class Util
|
||||
{
|
||||
private:
|
||||
@ -16,16 +21,20 @@ public:
|
||||
Util(Util&) = delete;
|
||||
|
||||
#ifdef GTASA
|
||||
static void ClearCharTasksVehCheck(CPed* ped);
|
||||
static int GetLargestGangInZone();
|
||||
static void ClearCharTasksVehCheck(CPed* ped);
|
||||
static bool IsOnMission();
|
||||
#endif
|
||||
static void SetCarForwardSpeed(CVehicle *pVeh, float speed);
|
||||
|
||||
static void FlipVehicle(CVehicle *pVeh);
|
||||
static void FixVehicle(CVehicle *pVeh);
|
||||
static CPed* GetClosestPed();
|
||||
static CVehicle* GetClosestVehicle();
|
||||
static void GetCPUUsageInit();
|
||||
static double GetCurrentCPUUsage();
|
||||
static std::string GetLocationName(CVector* pos);
|
||||
static bool IsOnCutscene();
|
||||
static bool IsOnMission();
|
||||
static bool IsInVehicle(CPed *pPed = FindPlayerPed());
|
||||
static void RainbowValues(int& r, int& g, int& b, float speed);
|
||||
static void SetCarForwardSpeed(CVehicle *pVeh, float speed);
|
||||
};
|
||||
|
@ -12,63 +12,6 @@
|
||||
#include "paint.h"
|
||||
#endif
|
||||
|
||||
void Vehicle::FixVehicle(CVehicle *pVeh)
|
||||
{
|
||||
#ifdef GTASA
|
||||
pVeh->Fix();
|
||||
#else
|
||||
switch (pVeh->m_nVehicleClass)
|
||||
{
|
||||
case VEHICLE_AUTOMOBILE:
|
||||
{
|
||||
reinterpret_cast<CAutomobile *>(pVeh)->Fix();
|
||||
break;
|
||||
}
|
||||
#ifdef GTAVC
|
||||
case VEHICLE_BIKE:
|
||||
{
|
||||
reinterpret_cast<CBike *>(pVeh)->Fix();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
pVeh->m_fHealth = 1000.0f;
|
||||
}
|
||||
|
||||
void FlipVehicle()
|
||||
{
|
||||
CPlayerPed* pPlayer = FindPlayerPed();
|
||||
#ifdef GTASA
|
||||
if (pPlayer->m_nPedFlags.bInVehicle)
|
||||
{
|
||||
int hveh = CPools::GetVehicleRef(pPlayer->m_pVehicle);
|
||||
float roll;
|
||||
|
||||
Command<Commands::GET_CAR_ROLL>(hveh, &roll);
|
||||
roll += 180;
|
||||
Command<Commands::SET_CAR_ROLL>(hveh, roll);
|
||||
Command<Commands::SET_CAR_ROLL>(hveh, roll); // z rot fix
|
||||
}
|
||||
#elif GTAVC
|
||||
if (pPlayer->m_bInVehicle)
|
||||
{
|
||||
float x,y,z;
|
||||
pPlayer->m_pVehicle->m_placement.GetOrientation(x, y, z);
|
||||
y += 135.0f;
|
||||
pPlayer->m_pVehicle->m_placement.SetOrientation(x, y, z);
|
||||
}
|
||||
#else
|
||||
if (pPlayer->m_bInVehicle)
|
||||
{
|
||||
float x,y,z;
|
||||
pPlayer->m_pVehicle->GetOrientation(x, y, z);
|
||||
y += 135.0f;
|
||||
pPlayer->m_pVehicle->SetOrientation(x, y, z);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Vehicle::Vehicle()
|
||||
{
|
||||
#ifdef GTASA
|
||||
@ -85,18 +28,18 @@ Vehicle::Vehicle()
|
||||
CPlayerPed* pPlayer = FindPlayerPed();
|
||||
CVehicle* pVeh = BY_GAME(FindPlayerVehicle(-1, false), FindPlayerVehicle(), FindPlayerVehicle());
|
||||
|
||||
if (pPlayer && pVeh)
|
||||
if (pPlayer && Util::IsInVehicle())
|
||||
{
|
||||
int hveh = CPools::GetVehicleRef(pVeh);
|
||||
|
||||
if (flipVeh.Pressed())
|
||||
{
|
||||
FlipVehicle();
|
||||
Util::FlipVehicle(pVeh);
|
||||
}
|
||||
|
||||
if (fixVeh.Pressed())
|
||||
{
|
||||
FixVehicle(pVeh);
|
||||
Util::FixVehicle(pVeh);
|
||||
SetHelpMessage("Vehicle fixed", false, false, false);
|
||||
}
|
||||
|
||||
@ -575,19 +518,16 @@ void Vehicle::ShowPage()
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Fix vehicle", ImVec2(Ui::GetSize(3))))
|
||||
if (ImGui::Button("Fix vehicle", ImVec2(Ui::GetSize(3))) && Util::IsInVehicle())
|
||||
{
|
||||
if (pPlayer && pVeh)
|
||||
{
|
||||
FixVehicle(pVeh);
|
||||
}
|
||||
Util::FixVehicle(pVeh);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Flip vehicle", ImVec2(Ui::GetSize(3))))
|
||||
if (ImGui::Button("Flip vehicle", ImVec2(Ui::GetSize(3))) && Util::IsInVehicle())
|
||||
{
|
||||
FlipVehicle();
|
||||
Util::FlipVehicle(pVeh);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
|
@ -82,12 +82,11 @@ private:
|
||||
#endif
|
||||
|
||||
private:
|
||||
static void FixVehicle(CVehicle *pVeh);
|
||||
|
||||
#ifdef GTASA
|
||||
static void AddComponent(const std::string& component, bool display_message = true);
|
||||
static void RemoveComponent(const std::string& component, bool display_message = true);
|
||||
static int GetRandomTrainIdForModel(int model);
|
||||
static void GenerateHandlingDataFile(int phandling);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user