refactor!: globals (#717)

* refactor(globals): use macro's for to_json/from_json
* refactor(globals): switch from global pointer to global instance
This commit is contained in:
Yimura
2022-12-18 23:15:52 +01:00
committed by GitHub
parent 4041370763
commit f6c00f113d
147 changed files with 1280 additions and 1902 deletions

View File

@ -131,7 +131,7 @@ namespace big
{
case eModelType::Object:
{
if (!misc::has_bits_set(&g->context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::OBJECT)))
if (!misc::has_bits_set(&g.context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::OBJECT)))
{
break;
}
@ -144,7 +144,7 @@ namespace big
if (ped->m_ped_task_flag & static_cast<uint8_t>(ePedTask::TASK_DRIVING) &&
ped->m_vehicle)
{
if (!misc::has_bits_set(&g->context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::VEHICLE)))
if (!misc::has_bits_set(&g.context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::VEHICLE)))
{
break;
}
@ -154,7 +154,7 @@ namespace big
}
if (ped->m_player_info)
{
if (!misc::has_bits_set(&g->context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::PLAYER)))
if (!misc::has_bits_set(&g.context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::PLAYER)))
{
break;
}
@ -163,7 +163,7 @@ namespace big
}
}
if (!misc::has_bits_set(&g->context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::PED)))
if (!misc::has_bits_set(&g.context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::PED)))
{
break;
}
@ -172,7 +172,7 @@ namespace big
}
case eModelType::Vehicle:
{
if (!misc::has_bits_set(&g->context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::VEHICLE)))
if (!misc::has_bits_set(&g.context_menu.allowed_entity_types, static_cast<uint8_t>(ContextEntityType::VEHICLE)))
{
break;
}
@ -292,7 +292,7 @@ namespace big
{
while (g_running)
{
if (!g->context_menu.enabled)
if (!g.context_menu.enabled)
{
g_context_menu_service->enabled = false;

View File

@ -4,7 +4,7 @@ namespace big
{
const char* respawn_label_callback(const char* label)
{
if (g->self.god_mode)
if (g.self.god_mode)
return "~r~Dying with god mode, how?";
return nullptr;

View File

@ -6,9 +6,9 @@ namespace big::hotkey_funcs
{
void toggle_noclip()
{
const auto state = !g->self.noclip;
const auto state = !g.self.noclip;
g_notification_service->push("Noclip", std::format("Noclip has been {}.", state ? "enabled" : "disabled"));
g->self.noclip = state;
g.self.noclip = state;
}
}

View File

@ -11,9 +11,9 @@ namespace big
{
hotkey_service::hotkey_service()
{
register_hotkey("waypoint", g->settings.hotkeys.teleport_waypoint, teleport::to_waypoint);
register_hotkey("objective", g->settings.hotkeys.teleport_objective, teleport::to_objective);
register_hotkey("noclip", g->settings.hotkeys.noclip, hotkey_funcs::toggle_noclip);
register_hotkey("waypoint", g.settings.hotkeys.teleport_waypoint, teleport::to_waypoint);
register_hotkey("objective", g.settings.hotkeys.teleport_objective, teleport::to_objective);
register_hotkey("noclip", g.settings.hotkeys.noclip, hotkey_funcs::toggle_noclip);
g_renderer->add_wndproc_callback([this](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{

View File

@ -28,9 +28,9 @@ namespace big
component.m_game_mode = 0;
component.m_num_parameters = 0;
if (g->session_browser.region_filter_enabled)
if (g.session_browser.region_filter_enabled)
{
component.SetParameter("MMATTR_REGION", 0, g->session_browser.region_filter);
component.SetParameter("MMATTR_REGION", 0, g.session_browser.region_filter);
}
if (constraint)
@ -57,23 +57,23 @@ namespace big
if (constraint && m_found_sessions[i].attributes.player_count >= 30)
m_found_sessions[i].is_valid = false;
if (g->session_browser.language_filter_enabled && m_found_sessions[i].attributes.language != g->session_browser.language_filter)
if (g.session_browser.language_filter_enabled && m_found_sessions[i].attributes.language != g.session_browser.language_filter)
m_found_sessions[i].is_valid = false;
if (g->session_browser.player_count_filter_enabled && (m_found_sessions[i].attributes.player_count < g->session_browser.player_count_filter_minimum ||
m_found_sessions[i].attributes.player_count > g->session_browser.player_count_filter_maximum))
if (g.session_browser.player_count_filter_enabled && (m_found_sessions[i].attributes.player_count < g.session_browser.player_count_filter_minimum ||
m_found_sessions[i].attributes.player_count > g.session_browser.player_count_filter_maximum))
{
m_found_sessions[i].is_valid = false;
}
}
if (g->session_browser.sort_method != 0)
if (g.session_browser.sort_method != 0)
{
std::qsort(m_found_sessions, m_num_sessions_found, sizeof(session), [](const void* a1, const void* a2) -> int
{
std::strong_ordering result;
if (g->session_browser.sort_method == 1)
if (g.session_browser.sort_method == 1)
{
result = (((session*)(a1))->attributes.player_count <=> ((session*)(a2))->attributes.player_count);
}
@ -82,10 +82,10 @@ namespace big
return 0;
if (result > 0)
return g->session_browser.sort_direction ? -1 : 1;
return g.session_browser.sort_direction ? -1 : 1;
if (result < 0)
return g->session_browser.sort_direction ? 1 : -1;
return g.session_browser.sort_direction ? 1 : -1;
std::unreachable();

View File

@ -5,7 +5,7 @@ namespace big
{
notification_service::notification_service()
{
push("Welcome", std::format("Loaded YimMenu. Press {} to open", ImGui::key_names[g->settings.hotkeys.menu_toggle]));
push("Welcome", std::format("Loaded YimMenu. Press {} to open", ImGui::key_names[g.settings.hotkeys.menu_toggle]));
g_notification_service = this;
}