Code cleanup (#667)

* chore: Changed detour_hook extension back to cpp
* chore(crossmap): split crossmap into header and source file
* chore(logger): rename macro's to code style
* chore(logger): removed unused local variable
* chore(benchmark): changed extension to C++ header
* chore: cleanup pickup_rewards file
* chore(gta): cleanup code and file naming
* chore(CanApplyData): Removed unused code
This commit is contained in:
Yimura 2022-12-08 13:35:41 +01:00 committed by GitHub
parent f338479c5c
commit 173d01145d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 6219 additions and 6288 deletions

View File

@ -1,4 +1,4 @@
#include "gta/PickupRewards.h"
#include "gta/pickup_rewards.hpp"
#include "backend/looped/looped.hpp"
#include "services/players/player_service.hpp"
#include "util/globals.hpp"

View File

@ -1,5 +1,5 @@
#pragma once
#include "gta\VehicleValues.h"
#include "gta/vehicle_values.hpp"
static const std::map<int, std::string> lsc_plate_styles = {

6201
src/crossmap.cpp Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
#pragma once
#include "natives.hpp"
#include "gta\joaat.hpp"
#include "gta/joaat.hpp"
enum Rewards : Hash
{

View File

@ -3,7 +3,7 @@
#include "fwddec.hpp"
#include "extensible.hpp"
#include "vector.hpp"
#include "gta\natives.hpp"
#include "gta/natives.hpp"
namespace gta
{

View File

@ -1,6 +1,6 @@
#pragma once
#include "Vehicles.h"
#include "vehicles.hpp"
enum SeatPositions
{

View File

@ -1,6 +1,6 @@
#pragma once
#include "gta\joaat.hpp"
#include "gta/joaat.hpp"
#include "natives.hpp"
enum Boats : Hash

View File

@ -1,7 +1,7 @@
#pragma once
#include "natives.hpp"
#include "gta\joaat.hpp"
#include "gta/joaat.hpp"
enum WeaponHashes : Hash
{

View File

@ -83,81 +83,6 @@ namespace big
return false;
}
template<typename T>
T* get_node_from_object(rage::netSyncNodeBase* node)
{
constexpr uint64_t hash = CLASS_TO_MANGLED_NAME(T)""_fnv1a;
if (node->IsParentNode())
{
for (auto child = node->m_first_child; child; child = child->m_next_sibling)
{
T* attach_node = get_node_from_object<T>(child);
if (attach_node != nullptr)
return attach_node;
}
}
else if (node->IsDataNode())
{
if (typeid(*node).hash_code() == hash)
return dynamic_cast<T*>(node);
}
return nullptr;
}
bool is_attachment_infinite(CPhysicalAttachDataNode* node, uint16_t object_id)
{
if (rage::netObject* attached_object = (*g_pointers->m_network_object_mgr)->find_object_by_id(node->m_attached_to, false); attached_object)
{
if (rage::netSyncTree* tree = attached_object->GetSyncTree(); tree)
{
if (rage::netSyncNodeBase* base_node = tree->m_sync_node; base_node)
{
const auto attached_attach_node = get_node_from_object<CPhysicalAttachDataNode>(base_node);
if (attached_attach_node && attached_attach_node->m_attached)
{
if (attached_attach_node->m_attached_to == object_id)
{
return true;
}
else
{
return is_attachment_infinite(attached_attach_node, object_id);
}
}
}
}
}
return false;
}
bool is_ped_attachment_infinite(CPedAttachDataNode* node, uint16_t object_id)
{
if (rage::netObject* attached_object = (*g_pointers->m_network_object_mgr)->find_object_by_id(node->m_attached_to, false); attached_object)
{
if (rage::netSyncTree* tree = attached_object->GetSyncTree(); tree)
{
if (rage::netSyncNodeBase* base_node = tree->m_sync_node; base_node)
{
const auto attached_attach_node = get_node_from_object<CPedAttachDataNode>(base_node);
if (attached_attach_node && attached_attach_node->m_attached)
{
if (attached_attach_node->m_attached_to == object_id)
{
return true;
}
else
{
return is_ped_attachment_infinite(attached_attach_node, object_id);
}
}
}
}
}
return false;
}
bool check_node(rage::netSyncNodeBase* node, CNetGamePlayer* sender, rage::netObject* object)
{
if (node->IsParentNode())

View File

@ -32,8 +32,8 @@ namespace big
BLACK = 30
};
#define AddColorToStream(color) "\x1b[" << int(color) << "m"
#define ResetStreamColor "\x1b[" << int(LogColor::RESET) << "m"
#define ADD_COLOR_TO_STREAM(color) "\x1b[" << int(color) << "m"
#define RESET_STREAM_COLOR "\x1b[" << int(LogColor::RESET) << "m"
#define HEX_TO_UPPER(value) "0x" << std::hex << std::uppercase << (DWORD64)value << std::dec << std::nouppercase
class logger final
@ -181,17 +181,16 @@ namespace big
out
<< "[" << msg.timestamp("%H:%M:%S") << "]"
<< AddColorToStream(color)
<< ADD_COLOR_TO_STREAM(color)
<< "[" << msg.level() << "/"
<< msg.file() << ":" << msg.line() << "]"
<< ResetStreamColor
<< RESET_STREAM_COLOR
<< ": ";
return out.str();
}
static std::string format_file(const g3::LogMessage& msg)
{
LogColor color = log_sink::get_color(msg._level);
std::stringstream out;
out

View File

@ -1,7 +1,7 @@
#include "common.hpp"
#include "pointers.hpp"
#include "script_local.hpp"
#include "gta\script_thread.hpp"
#include "gta/script_thread.hpp"
namespace big
{

View File

@ -1,6 +1,6 @@
#pragma once
#include "gta\VehicleValues.h"
#include "gta/vehicle_values.hpp"
namespace big
{

View File

@ -3,7 +3,7 @@
#include "core/scr_globals.hpp"
#include "core/enums.hpp"
#include "gta/net_object_mgr.hpp"
#include "gta/PickupRewards.h"
#include "gta/pickup_rewards.hpp"
#include "util/session.hpp"
#include "util/scripts.hpp"
#include "services/gta_data/gta_data_service.hpp"

View File

@ -7,7 +7,7 @@
#include "script.hpp"
#include "teleport.hpp"
#include "script_global.hpp"
#include "gta/VehicleValues.h"
#include "gta/vehicle_values.hpp"
#include "services/vehicle_helper/vehicle_helper.hpp"
#include "core/scr_globals.hpp"