Add Garage drop-down to Spawn PV menu (#2171)

* Fixed edge case where a garage that contained only banned vehicles would show if the user was using Spawn Clone.
Refactored a large portion of the garage code to be production ready.
Formatting changes.

* Added singular garage items to the m_garage setter like the Terrorbyte.

* Fixed is_blacklisted_vehicle returning an inverted condition.
Fixed Garage drop-down not updating properly.

* Separated out m_garage's setter into a ctor function.
Replaced the 4 singular garages that use an overloaded index with a define to be able to shift them easier when new properties are added.

* Removed obsolete and incorrect player.character_slot config entry.
Removed deprecated local_player.hpp.
Added self::char_slot that is guaranteed to be correct.

* Removed extraneous semi-colon.

* Added more stuff to fillsnacks.
Removed more extraneous usages of MPPLY_LAST_MP_CHAR.

* Added the vehicle's name to player info.

* Fixed get_property_garage_size returning the incorrect size for the facility.
Fixed get_static_property_name returning the Nightclub's name instead of Nightclub Service Entrance to maintain consistency with the Mechanic.
Fixed garage_slot_iterator not starting and ending at the correct indexes.

* Shifted the singular properties down one to compensate for the new math.

* Fixed backwards math on Terrorbyte and Nightclub B1.

* Fixed garage not being updated when the player moved the vehicle.

* Fixed backwards comments.
This commit is contained in:
gir489
2023-09-22 17:16:33 -04:00
committed by GitHub
parent 247536aacc
commit 220e995035
18 changed files with 388 additions and 111 deletions

View File

@ -4,11 +4,13 @@
#include "natives.hpp"
#include "services/player_database/player_database_service.hpp"
#include "views/view.hpp"
#include "services/gta_data/gta_data_service.hpp"
#include <network/netConnection.hpp>
#include <script/globals/GPBD_FM.hpp>
#include <script/globals/GPBD_FM_3.hpp>
#include <script/globals/GlobalPlayerBD.hpp>
#include <vehicle/CVehicleModelInfo.hpp>
namespace big
{
@ -48,7 +50,8 @@ namespace big
uint32_t ped_health = 0;
uint32_t ped_maxhealth = 0;
uint32_t veh_damage_bits = 0;
std::string mode_str = "";
std::string mode_str{};
std::string vehicle_name{};
if (CPed* ped = g_player_service->get_selected()->get_ped(); ped != nullptr)
{
@ -209,42 +212,47 @@ namespace big
ImGui::Text("PLAYER_INFO_PROOFS"_T.data(), mode_str.c_str());
mode_str = "";
if (auto vehicle = g_player_service->get_selected()->get_current_vehicle(); vehicle != nullptr)
{
veh_damage_bits = vehicle->m_damage_bits;
}
mode_str.clear();
if (ped_task_flag & (uint8_t)ePedTask::TASK_DRIVING)
{
if (veh_damage_bits & (uint32_t)eEntityProofs::GOD)
if (auto vehicle = g_player_service->get_selected()->get_current_vehicle(); vehicle != nullptr)
{
mode_str = "PLAYER_INFO_GOD"_T;
}
else
{
if (veh_damage_bits & (uint32_t)eEntityProofs::COLLISION)
{
mode_str += "PLAYER_INFO_COLLISION"_T;
}
if (veh_damage_bits & (uint32_t)eEntityProofs::EXPLOSION)
{
mode_str += "PLAYER_INFO_EXPLOSION"_T;
}
}
veh_damage_bits = vehicle->m_damage_bits;
if (mode_str.empty())
{
mode_str = "NO"_T;
if (CVehicleModelInfo* vehicle_model_info = static_cast<CVehicleModelInfo*>(vehicle->m_model_info))
{
vehicle_name = g_gta_data_service->vehicles()[vehicle_model_info->m_name].m_display_name;
}
if (veh_damage_bits & (uint32_t)eEntityProofs::GOD)
{
mode_str = "PLAYER_INFO_GOD"_T;
}
else
{
if (veh_damage_bits & (uint32_t)eEntityProofs::COLLISION)
{
mode_str += "PLAYER_INFO_COLLISION"_T;
}
if (veh_damage_bits & (uint32_t)eEntityProofs::EXPLOSION)
{
mode_str += "PLAYER_INFO_EXPLOSION"_T;
}
}
if (mode_str.empty())
{
mode_str = "NO"_T;
}
}
}
else
{
mode_str = "PLAYER_INFO_NO_VEHICLE"_T;
vehicle_name = "PLAYER_INFO_NO_VEHICLE"_T;
}
ImGui::Text("PLAYER_INFO_VEHICLE_PROOFS"_T.data(), mode_str.c_str());
ImGui::Text("PLAYER_INFO_VEHICLE"_T.data(), vehicle_name.c_str(), mode_str.c_str());
if (auto net_player_data = g_player_service->get_selected()->get_net_data())
{

View File

@ -3,7 +3,6 @@
#include "fiber_pool.hpp"
#include "services/orbital_drone/orbital_drone.hpp"
#include "util/entity.hpp"
#include "util/local_player.hpp"
#include "util/scripts.hpp"
#include "views/view.hpp"

View File

@ -27,7 +27,6 @@ namespace big::helper
namespace big
{
static int character_index = 0;
static int year, month, day, hour, minute, second, millisecond;
static char stat_int_read_result[256] = {};
@ -100,7 +99,7 @@ namespace big
{
auto substr = text.substr(1);
if (substr.substr(0, 3) == "mpx")
substr[2] = character_index + '0';
substr[2] = self::char_index + '0';
return rage::joaat(substr);
}
return get_text_value<Hash>(text);
@ -440,7 +439,6 @@ namespace big
}(), true);
g_fiber_pool->queue_job([] {
STATS::STAT_GET_INT(RAGE_JOAAT("MPPLY_LAST_MP_CHAR"), &character_index, -1);
CLOCK::GET_POSIX_TIME(&year, &month, &day, &hour, &minute, &second);
if (g.stat_editor.stat.int_read)
strcpy_s(stat_int_read_result, sizeof(stat_int_read_result), helper::stat_get_int(stat_int_text).c_str());
@ -471,7 +469,7 @@ namespace big
});
components::sub_title(std::format("Posix Time: {}-{}-{} {}:{}:{}", year, month, day, hour, minute, second));
components::sub_title(std::format("Character Index: {}", character_index));
components::sub_title(std::format("Character Index: {}", self::char_index));
components::sub_title("Be aware of stat limits, use with caution, modifying some stats are risky.");
if (ImGui::BeginTabBar("##stat_editor_tab_bar"))
@ -605,7 +603,7 @@ namespace big::helper
index_max = index_v[1];
int value_n = get_text_value<int>(value);
for (int i = index_min; i <= index_max; i++)
STATS::SET_PACKED_STAT_INT_CODE(i, value_n, character_index);
STATS::SET_PACKED_STAT_INT_CODE(i, value_n, self::char_index);
}
void packed_stat_set_bool(std::string index, std::string value)
@ -619,7 +617,7 @@ namespace big::helper
index_max = index_v[1];
int value_b = get_text_value<bool>(value);
for (int i = index_min; i <= index_max; i++)
STATS::SET_PACKED_STAT_BOOL_CODE(i, value_b, character_index);
STATS::SET_PACKED_STAT_BOOL_CODE(i, value_b, self::char_index);
}
std::string packed_stat_get_int(std::string index)
@ -629,7 +627,7 @@ namespace big::helper
std::stringstream ss(index);
std::getline(ss, str, ' ');
if (str != "")
result = STATS::GET_PACKED_STAT_INT_CODE(get_text_value<int>(str), character_index);
result = STATS::GET_PACKED_STAT_INT_CODE(get_text_value<int>(str), self::char_index);
return std::to_string(result);
}
@ -640,7 +638,7 @@ namespace big::helper
std::stringstream ss(index);
std::getline(ss, str, ' ');
if (str != "")
result = STATS::GET_PACKED_STAT_BOOL_CODE(get_text_value<int>(str), character_index);
result = STATS::GET_PACKED_STAT_BOOL_CODE(get_text_value<int>(str), self::char_index);
return std::to_string(result);
}
}

View File

@ -8,32 +8,6 @@
namespace big
{
bool is_blacklist_vehicle(Hash vehicle_hash)
{
switch (vehicle_hash)
{
case RAGE_JOAAT("avenger"):
case RAGE_JOAAT("avenger3"):
case RAGE_JOAAT("hauler2"):
case RAGE_JOAAT("phantom3"):
case RAGE_JOAAT("trailersmall2"):
case RAGE_JOAAT("khanjali"):
case RAGE_JOAAT("chernobog"):
case RAGE_JOAAT("riot2"):
case RAGE_JOAAT("thruster"):
case RAGE_JOAAT("brickade2"):
case RAGE_JOAAT("manchez3"):
case RAGE_JOAAT("terbyte"):
case RAGE_JOAAT("speedo4"):
case RAGE_JOAAT("mule4"):
case RAGE_JOAAT("pounder2"):
case RAGE_JOAAT("rcbandito"):
case RAGE_JOAAT("minitank"):
return true;
}
return false;
}
void view::pv()
{
ImGui::SetWindowSize({0.f, (float)*g_pointers->m_gta.m_resolution_y}, ImGuiCond_Always);
@ -55,7 +29,10 @@ namespace big
static char plate_buf[9] = {0};
ImGui::Checkbox("SPAWN_CLONE"_T.data(), &g.clone_pv.spawn_clone);
if (ImGui::Checkbox("SPAWN_CLONE"_T.data(), &g.clone_pv.spawn_clone))
{
g_mobile_service->refresh_garages();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("SPAWN_CLONE_DESC"_T.data());
if (g.clone_pv.spawn_clone)
@ -106,6 +83,28 @@ namespace big
ImGui::EndCombo();
}
ImGui::SetNextItemWidth(300.f);
std::string garage_display = g.clone_pv.garage.empty() ? "ALL"_T.data() : g.clone_pv.garage;
if (ImGui::BeginCombo("GARAGE"_T.data(), garage_display.c_str()))
{
if (ImGui::Selectable("ALL"_T.data(), g.clone_pv.garage.empty()))
{
g.clone_pv.garage.clear();
}
for (auto garage : g_mobile_service->garages())
{
if (ImGui::Selectable(garage.c_str(), garage == g.clone_pv.garage))
{
g.clone_pv.garage = garage;
}
if (garage == g.clone_pv.garage)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
static char search[64];
@ -138,7 +137,7 @@ namespace big
if ((selected_class == -1 || class_arr[selected_class] == vehicle_class)
&& (display_name.find(lower_search) != std::string::npos || display_manufacturer.find(lower_search) != std::string::npos))
{
if (!g.clone_pv.spawn_clone && is_blacklist_vehicle(personal_veh->get_hash()))
if (personal_veh->is_blacklisted_vehicle() || !personal_veh->is_in_selected_garage())
{
continue;
}

View File

@ -1,4 +1,3 @@
#include "util/local_player.hpp"
#include "views/view.hpp"
namespace big