remove previous code & add GUI_NETWORK_SYNCS tab
- remove code related to logging explosion event in console - added GUI_NETWORK_SYNCS tab to track ped, vehicle, pickups, objects, explosion, ptfx events
This commit is contained in:
parent
982e286a90
commit
580af4b9a1
@ -119,7 +119,6 @@ namespace big
|
||||
{
|
||||
int metric_logs{};
|
||||
int packet_logs{};
|
||||
bool explosion_event = false;
|
||||
|
||||
bool script_hook_logs{};
|
||||
|
||||
|
42
src/core/var/misc.hpp
Normal file
42
src/core/var/misc.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#include "services/players/player.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
class sync_list
|
||||
{
|
||||
public:
|
||||
std::array<std::string, 100> list;
|
||||
int size = 0;
|
||||
|
||||
inline void add_sync_data_to_list(player_ptr sender, std::string details)
|
||||
{
|
||||
if (size == 100)
|
||||
{
|
||||
// Copy the last 50 elements to the first 50 positions
|
||||
std::copy(list.begin() + 50, list.end(), list.begin());
|
||||
size = 50;
|
||||
}
|
||||
|
||||
// Add the new element after the first 50 elements
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto localTime = std::chrono::zoned_time{std::chrono::current_zone(), now};
|
||||
|
||||
list[size] = std::format("[{:%H:%M:%S}] [{}] {}",localTime.get_local_time(), sender->get_name(), details);
|
||||
|
||||
++size;
|
||||
}
|
||||
};
|
||||
|
||||
struct g_misc_data_t
|
||||
{
|
||||
sync_list ped_sync_list;
|
||||
sync_list vehicle_sync_list;
|
||||
sync_list object_sync_list;
|
||||
sync_list pickup_sync_list;
|
||||
sync_list explosion_sync_list;
|
||||
sync_list ptfx_sync_list;
|
||||
};
|
||||
|
||||
inline g_misc_data_t g_misc_data{};
|
||||
}
|
@ -70,6 +70,7 @@
|
||||
#include "util/sync_trees.hpp"
|
||||
#include "vehicle/CTrainConfig.hpp"
|
||||
#include "vehicle/CVehicleModelInfo.hpp"
|
||||
#include "core/var/misc.hpp"
|
||||
|
||||
|
||||
namespace big
|
||||
@ -1205,6 +1206,10 @@ namespace big
|
||||
|
||||
veh_creation_model = creation_node->m_model;
|
||||
|
||||
auto& vehs = g_gta_data_service.vehicles();
|
||||
auto it = vehs.find(creation_node->m_model);
|
||||
g_misc_data.vehicle_sync_list.add_sync_data_to_list(sender_plyr, (it != vehs.end() ? g_gta_data_service.get_vehicle_full_name(it->second) : "?"));
|
||||
|
||||
break;
|
||||
}
|
||||
case sync_node_id("CDoorCreationDataNode"):
|
||||
@ -1235,6 +1240,8 @@ namespace big
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
g_misc_data.pickup_sync_list.add_sync_data_to_list(sender_plyr, "");
|
||||
break;
|
||||
}
|
||||
case sync_node_id("CPhysicalAttachDataNode"):
|
||||
@ -1289,6 +1296,12 @@ namespace big
|
||||
notify::crash_blocked(sender, "invalid ped prop model");
|
||||
return true;
|
||||
}
|
||||
|
||||
auto& peds = g_gta_data_service.peds();
|
||||
auto it = peds.find(creation_node->m_model);
|
||||
g_misc_data.ped_sync_list.add_sync_data_to_list(sender_plyr,
|
||||
std::format("{}, {}", it != peds.end() ? it->second.m_name : "?", it != peds.end() ? it->second.m_ped_type : "?"));
|
||||
|
||||
break;
|
||||
}
|
||||
case sync_node_id("CPedAttachDataNode"):
|
||||
@ -1318,6 +1331,8 @@ namespace big
|
||||
notify::crash_blocked(sender, "invalid object model");
|
||||
return true;
|
||||
}
|
||||
|
||||
g_misc_data.object_sync_list.add_sync_data_to_list(sender_plyr, std::to_string(creation_node->m_model));
|
||||
break;
|
||||
}
|
||||
case sync_node_id("CPlayerAppearanceDataNode"):
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "core/data/bullet_impact_types.hpp"
|
||||
#include "core/var/misc.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "gta/net_game_event.hpp"
|
||||
@ -395,27 +396,13 @@ namespace big
|
||||
return;
|
||||
}
|
||||
|
||||
// logs all type of explosion including owned one, fire, water hydrant etc, one without damage but camerashake, npcs shooting explosive ammo from planes from source client etc
|
||||
if (g.debug.logs.explosion_event && plyr)
|
||||
{
|
||||
static player_ptr last_exp_player = nullptr;
|
||||
static eExplosionTag last_exp_type = eExplosionTag::DONTCARE;
|
||||
std::chrono::system_clock::time_point last_exp_time{};
|
||||
|
||||
auto time_now = std::chrono::system_clock::now();
|
||||
if (last_exp_player != plyr || last_exp_type != explosionType || (time_now - last_exp_time < 1s))
|
||||
if (plyr)
|
||||
{
|
||||
auto exp_type_itr = BULLET_IMPACTS.find(explosionType);
|
||||
LOGF(WARNING,
|
||||
"EXPLOSION_EVENT from {} (Distance- {} Type- {})",
|
||||
player->get_name(),
|
||||
g_misc_data.explosion_sync_list.add_sync_data_to_list(plyr,
|
||||
std::format("(Dist- {}, {})",
|
||||
math::distance_between_vectors(*plyr->get_ped()->get_position(), {posX, posY, posZ}),
|
||||
exp_type_itr != BULLET_IMPACTS.end() ? exp_type_itr->second : "?");
|
||||
}
|
||||
|
||||
last_exp_player = plyr;
|
||||
last_exp_type = explosionType;
|
||||
last_exp_time = time_now;
|
||||
exp_type_itr != BULLET_IMPACTS.end() ? exp_type_itr->second : "?"));
|
||||
}
|
||||
|
||||
if (g.session.explosion_karma && g_local_player
|
||||
|
@ -59,6 +59,8 @@ namespace big
|
||||
PROXY_SETTINGS,
|
||||
DEBUG,
|
||||
|
||||
NETWORK_SYNCS,
|
||||
|
||||
PLAYER,
|
||||
|
||||
// Added at runtime by things like lua scripts.
|
||||
@ -166,6 +168,11 @@ namespace big
|
||||
{TAB_DECL(DEBUG), nullptr}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
TAB_DECL(NETWORK_SYNCS),
|
||||
view::network_syncs
|
||||
},
|
||||
},
|
||||
{
|
||||
tabs::PLAYER,
|
||||
|
@ -12,7 +12,6 @@ namespace big
|
||||
ImGui::Combo("DEBUG_LOG_METRICS"_T.data(), (int*)&g.debug.logs.metric_logs, options, IM_ARRAYSIZE(options));
|
||||
ImGui::Combo("VIEW_DEBUG_LOGS_LOG_PACKETS"_T.data(), (int*)&g.debug.logs.packet_logs, options, IM_ARRAYSIZE(options));
|
||||
ImGui::Checkbox("DEBUG_LOG_NATIVE_SCRIPT_HOOKS"_T.data(), &g.debug.logs.script_hook_logs);
|
||||
ImGui::Checkbox("DEBUG_LOG_EXPLOSION_EVENT"_T.data(), &g.debug.logs.explosion_event);
|
||||
|
||||
if (ImGui::TreeNode("DEBUG_LOG_TREE_SCRIPT_EVENT"_T.data()))
|
||||
{
|
||||
|
37
src/views/network_syncs.cpp
Normal file
37
src/views/network_syncs.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "core/var/misc.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
#include "view.hpp"
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
namespace big
|
||||
{
|
||||
static inline void render_special_view(std::string_view name, sync_list* list)
|
||||
{
|
||||
if (ImGui::BeginTabItem(name.data()))
|
||||
{
|
||||
ImGui::BeginChild("ScrollingRegion", {600, 450});
|
||||
for (int i = 0; i < list->size; ++i)
|
||||
ImGui::Text("%s", list->list[i].c_str());
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
static const std::unordered_map<std::string_view, sync_list*> all_special_views = {
|
||||
{"ped", &g_misc_data.ped_sync_list},
|
||||
{"vehicle", &g_misc_data.vehicle_sync_list},
|
||||
{"object", &g_misc_data.object_sync_list},
|
||||
{"pickup", &g_misc_data.pickup_sync_list},
|
||||
{"explosion", &g_misc_data.explosion_sync_list},
|
||||
{"ptfx", &g_misc_data.ptfx_sync_list},
|
||||
};
|
||||
|
||||
void view::network_syncs()
|
||||
{
|
||||
ImGui::BeginTabBar("network_syncs_tabbar");
|
||||
for (auto& pair : all_special_views)
|
||||
render_special_view(pair.first, pair.second);
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
@ -78,6 +78,7 @@ namespace big
|
||||
static void gta_cache();
|
||||
static void lua_scripts();
|
||||
static void vfx();
|
||||
static void network_syncs();
|
||||
|
||||
static void onboarding();
|
||||
|
||||
|
Reference in New Issue
Block a user