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/BigBaseV2/src/services/vehicle_service.cpp

40 lines
932 B
C++
Raw Normal View History

2021-08-08 15:10:08 +02:00
#include "vehicle_service.hpp"
namespace big
{
vehicle_service::vehicle_service()
{
g_vehicle_service = this;
}
vehicle_service::~vehicle_service()
{
g_vehicle_service = nullptr;
}
int vehicle_service::attempt_save()
{
if (g_local_player == nullptr || g_local_player->m_in_vehicle == 0x10 || g_local_player->m_vehicle == nullptr)
return -1;
if (m_handling_backup.find(g_local_player->m_vehicle->m_handling->m_model_hash) != m_handling_backup.end())
return 0;
CHandlingData handling = *g_local_player->m_vehicle->m_handling;
m_handling_backup.emplace(g_local_player->m_vehicle->m_handling->m_model_hash, handling);
return 1;
}
bool vehicle_service::restore_vehicle()
{
if (auto it = m_handling_backup.find(g_local_player->m_vehicle->m_handling->m_model_hash); it != m_handling_backup.end())
{
*g_local_player->m_vehicle->m_handling = it->second;
return true;
}
return false;
}
}