This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/services/vehicle/handling_profile.cpp
Yimura 7da9427128
refactor(HandlingService): Use JSON to store profiles (#711)
* fix(HandlingService): Correctly apply profile from storage
* fix(HandlingService): Name inconsistency in UI
* feat(HandlingService): Convert old handling profiles
2022-12-17 14:11:36 +00:00

24 lines
781 B
C++

#include "handling_profile.hpp"
namespace big
{
handling_profile::handling_profile(CVehicle* vehicle)
{
m_gravity = vehicle->m_gravity;
m_handling_data = *vehicle->m_handling_data;
}
void handling_profile::apply_to(CVehicle* vehicle, bool restore_hash) const
{
const auto hash = vehicle->m_handling_data->m_model_hash;
vehicle->m_gravity = m_gravity;
// cursed but works perfectly without overriding members that we shouldn't override
nlohmann::json j = m_handling_data; // exports our binary object so we can apply it field by field instead of copying the whole object
from_json(j, *vehicle->m_handling_data); // macro is defined in global scope of which CHandlingData is part of
if (restore_hash)
vehicle->m_handling_data->m_model_hash = hash;
}
}