Updated vehicle_abilities.cpp to work with latest GTAV-Classes PR (#2509)
This commit is contained in:
parent
7299be8cb8
commit
0798a413f9
@ -3,7 +3,7 @@ include(FetchContent)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
gtav_classes
|
gtav_classes
|
||||||
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
||||||
GIT_TAG b93fcb4848c935b6b11ce9d5e82fb38aba3a59f4
|
GIT_TAG e52b8c65379f3304cf7b72dc87561c9d3924d4b4
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_COMMAND ""
|
BUILD_COMMAND ""
|
||||||
|
@ -14,17 +14,17 @@ namespace big
|
|||||||
class vehicle_ability_helper
|
class vehicle_ability_helper
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static constexpr std::array<eVehicleAbilities, 4> m_abilities = {
|
static constexpr std::array<CVehicleModelInfoFlags, 4> m_abilities = {
|
||||||
eVehicleAbilities::JUMP,
|
CVehicleModelInfoFlags::JUMPING_CAR,
|
||||||
eVehicleAbilities::ROCKET,
|
CVehicleModelInfoFlags::HAS_ROCKET_BOOST,
|
||||||
eVehicleAbilities::PARACHUTE,
|
CVehicleModelInfoFlags::HAS_PARACHUTE,
|
||||||
eVehicleAbilities::RAMP_BUGGY,
|
CVehicleModelInfoFlags::RAMP,
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_set<eVehicleAbilities> m_stock_abilities;
|
std::unordered_set<CVehicleModelInfoFlags> m_stock_abilities;
|
||||||
CVehicle* m_vehicle = nullptr;
|
CVehicle* m_vehicle = nullptr;
|
||||||
uint16_t m_original_abilities;
|
bool m_original_abilities[4] = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
vehicle_ability_helper() = default;
|
vehicle_ability_helper() = default;
|
||||||
@ -34,12 +34,12 @@ namespace big
|
|||||||
return;
|
return;
|
||||||
m_vehicle = vehicle;
|
m_vehicle = vehicle;
|
||||||
|
|
||||||
const auto model_info = reinterpret_cast<CVehicleModelInfo*>(vehicle->m_model_info);
|
for (int i = 0; i < 4; i++)
|
||||||
m_original_abilities = model_info->m_ability_flag;
|
m_original_abilities[i] = has_ability(m_abilities.at(i));
|
||||||
|
|
||||||
for (const auto ability : m_abilities)
|
for (const auto ability : m_abilities)
|
||||||
{
|
{
|
||||||
if (m_original_abilities >> (uint16_t)ability & 1)
|
if (has_ability(ability))
|
||||||
{
|
{
|
||||||
m_stock_abilities.insert(ability);
|
m_stock_abilities.insert(ability);
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ namespace big
|
|||||||
* @return true
|
* @return true
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool get_ability_default(eVehicleAbilities ability)
|
bool get_ability_default(CVehicleModelInfoFlags ability)
|
||||||
{
|
{
|
||||||
return m_stock_abilities.contains(ability);
|
return m_stock_abilities.contains(ability);
|
||||||
}
|
}
|
||||||
@ -65,9 +65,9 @@ namespace big
|
|||||||
* @return true
|
* @return true
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool has_ability(eVehicleAbilities ability)
|
bool has_ability(CVehicleModelInfoFlags ability)
|
||||||
{
|
{
|
||||||
return m_vehicle && m_vehicle->m_model_info && reinterpret_cast<CVehicleModelInfo*>(m_vehicle->m_model_info)->m_ability_flag >> (uint16_t)ability & 1;
|
return m_vehicle && m_vehicle->m_model_info && reinterpret_cast<CVehicleModelInfo*>(m_vehicle->m_model_info)->get_vehicle_model_flag(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,9 +77,8 @@ namespace big
|
|||||||
{
|
{
|
||||||
if (m_vehicle && m_vehicle->m_model_info)
|
if (m_vehicle && m_vehicle->m_model_info)
|
||||||
{
|
{
|
||||||
const auto model_info = reinterpret_cast<CVehicleModelInfo*>(m_vehicle->m_model_info);
|
for (int i = 0; i < 4; i++)
|
||||||
|
toggle_ability(m_abilities.at(i), m_original_abilities[i]);
|
||||||
model_info->m_ability_flag = m_original_abilities;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,15 +88,13 @@ namespace big
|
|||||||
* @param ability
|
* @param ability
|
||||||
* @param toggle
|
* @param toggle
|
||||||
*/
|
*/
|
||||||
void toggle_ability(eVehicleAbilities ability, bool toggle)
|
void toggle_ability(CVehicleModelInfoFlags ability, bool toggle)
|
||||||
{
|
{
|
||||||
if (m_vehicle && m_vehicle->m_model_info)
|
if (m_vehicle && m_vehicle->m_model_info)
|
||||||
{
|
{
|
||||||
const auto model_info = reinterpret_cast<CVehicleModelInfo*>(m_vehicle->m_model_info);
|
const auto model_info = reinterpret_cast<CVehicleModelInfo*>(m_vehicle->m_model_info);
|
||||||
if (toggle)
|
|
||||||
misc::set_bits(&model_info->m_ability_flag, (uint16_t)ability);
|
model_info->set_vehicle_model_flag(ability, toggle);
|
||||||
else
|
|
||||||
misc::clear_bits(&model_info->m_ability_flag, (uint16_t)ability);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,10 +124,10 @@ namespace big
|
|||||||
reset(curr_veh);
|
reset(curr_veh);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vehicle_ability_helper.toggle_ability(eVehicleAbilities::JUMP, g.vehicle.abilities.jump);
|
m_vehicle_ability_helper.toggle_ability(CVehicleModelInfoFlags::JUMPING_CAR, g.vehicle.abilities.jump);
|
||||||
m_vehicle_ability_helper.toggle_ability(eVehicleAbilities::ROCKET, g.vehicle.abilities.rocket);
|
m_vehicle_ability_helper.toggle_ability(CVehicleModelInfoFlags::HAS_ROCKET_BOOST, g.vehicle.abilities.rocket);
|
||||||
m_vehicle_ability_helper.toggle_ability(eVehicleAbilities::PARACHUTE, g.vehicle.abilities.parachute);
|
m_vehicle_ability_helper.toggle_ability(CVehicleModelInfoFlags::HAS_PARACHUTE, g.vehicle.abilities.parachute);
|
||||||
m_vehicle_ability_helper.toggle_ability(eVehicleAbilities::RAMP_BUGGY, g.vehicle.abilities.ramp);
|
m_vehicle_ability_helper.toggle_ability(CVehicleModelInfoFlags::RAMP, g.vehicle.abilities.ramp);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void on_disable() override
|
virtual void on_disable() override
|
||||||
@ -154,22 +151,17 @@ namespace big
|
|||||||
// currently I'd keep overwriting the display values for what is default for the current vehicle
|
// currently I'd keep overwriting the display values for what is default for the current vehicle
|
||||||
// should we always persist the user's choice onto the vehicle? or only the ones that are enabled?
|
// should we always persist the user's choice onto the vehicle? or only the ones that are enabled?
|
||||||
// doesn't sound like too great of an idea for vehicles that have abilities by default and then suddenly they're disabled
|
// doesn't sound like too great of an idea for vehicles that have abilities by default and then suddenly they're disabled
|
||||||
g.vehicle.abilities.jump = m_vehicle_ability_helper.get_ability_default(eVehicleAbilities::JUMP);
|
g.vehicle.abilities.jump = m_vehicle_ability_helper.get_ability_default(CVehicleModelInfoFlags::JUMPING_CAR);
|
||||||
g.vehicle.abilities.rocket = m_vehicle_ability_helper.get_ability_default(eVehicleAbilities::ROCKET);
|
g.vehicle.abilities.rocket = m_vehicle_ability_helper.get_ability_default(CVehicleModelInfoFlags::HAS_ROCKET_BOOST);
|
||||||
g.vehicle.abilities.parachute = m_vehicle_ability_helper.get_ability_default(eVehicleAbilities::PARACHUTE);
|
g.vehicle.abilities.parachute = m_vehicle_ability_helper.get_ability_default(CVehicleModelInfoFlags::HAS_PARACHUTE);
|
||||||
g.vehicle.abilities.ramp = m_vehicle_ability_helper.get_ability_default(eVehicleAbilities::RAMP_BUGGY);
|
g.vehicle.abilities.ramp = m_vehicle_ability_helper.get_ability_default(CVehicleModelInfoFlags::RAMP);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
vehicle_ability
|
vehicle_ability g_vehicle_ability("modifyvehicleability", "MODIFY_VEHICLE_ABILITY", "MODIFY_VEHICLE_ABILITY_DESC", g.vehicle.abilities.enabled);
|
||||||
g_vehicle_ability("modifyvehicleability", "MODIFY_VEHICLE_ABILITY", "MODIFY_VEHICLE_ABILITY_DESC", g.vehicle.abilities.enabled);
|
|
||||||
|
|
||||||
bool_command g_jump_ability("jumpability", "BACKEND_LOOPED_VEHICLE_ABILITY_JUMP", "BACKEND_LOOPED_VEHICLE_ABILITY_JUMP_DESC",
|
bool_command g_jump_ability("jumpability", "BACKEND_LOOPED_VEHICLE_ABILITY_JUMP", "BACKEND_LOOPED_VEHICLE_ABILITY_JUMP_DESC", g.vehicle.abilities.jump);
|
||||||
g.vehicle.abilities.jump);
|
bool_command g_rocket_ability("rocketability", "BACKEND_LOOPED_VEHICLE_ABILITY_ROCKET", "BACKEND_LOOPED_VEHICLE_ABILITY_ROCKET_DESC", g.vehicle.abilities.rocket);
|
||||||
bool_command g_rocket_ability("rocketability", "BACKEND_LOOPED_VEHICLE_ABILITY_ROCKET", "BACKEND_LOOPED_VEHICLE_ABILITY_ROCKET_DESC",
|
bool_command g_parachute_ability("parachuteability", "BACKEND_LOOPED_VEHICLE_ABILITY_PARACHUTE", "BACKEND_LOOPED_VEHICLE_ABILITY_PARACHUTE_DESC", g.vehicle.abilities.parachute);
|
||||||
g.vehicle.abilities.rocket);
|
bool_command g_ramp_ability("rampability", "BACKEND_LOOPED_VEHICLE_ABILITY_RAMP", "BACKEND_LOOPED_VEHICLE_ABILITY_RAMP_DESC", g.vehicle.abilities.ramp);
|
||||||
bool_command g_parachute_ability("parachuteability", "BACKEND_LOOPED_VEHICLE_ABILITY_PARACHUTE", "BACKEND_LOOPED_VEHICLE_ABILITY_PARACHUTE_DESC",
|
|
||||||
g.vehicle.abilities.parachute);
|
|
||||||
bool_command g_ramp_ability("rampability", "BACKEND_LOOPED_VEHICLE_ABILITY_RAMP", "BACKEND_LOOPED_VEHICLE_ABILITY_RAMP_DESC",
|
|
||||||
g.vehicle.abilities.ramp);
|
|
||||||
}
|
}
|
@ -2004,14 +2004,6 @@ enum class eVehicleSeats
|
|||||||
OUTSIDE_RIGHT,
|
OUTSIDE_RIGHT,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class eVehicleAbilities : uint16_t
|
|
||||||
{
|
|
||||||
JUMP = 1 << 5,
|
|
||||||
ROCKET = 1 << 6,
|
|
||||||
PARACHUTE = 1 << 8,
|
|
||||||
RAMP_BUGGY = 1 << 9
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class eKnockOffVehicle
|
enum class eKnockOffVehicle
|
||||||
{
|
{
|
||||||
KNOCKOFFVEHICLE_DEFAULT,
|
KNOCKOFFVEHICLE_DEFAULT,
|
||||||
|
Reference in New Issue
Block a user