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

@ -70,53 +70,53 @@ namespace big
ImGui::EndListBox();
}
ImGui::Checkbox("Join in SCTV slots", &g->session.join_in_sctv_slots);
ImGui::Checkbox("Join in SCTV slots", &g.session.join_in_sctv_slots);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Allows you to join full and solo sessions but can be detected by other modders");
components::sub_title("Player Magnet");
ImGui::Checkbox("Enabled", &g->session.player_magnet_enabled);
if (g->session.player_magnet_enabled)
ImGui::Checkbox("Enabled", &g.session.player_magnet_enabled);
if (g.session.player_magnet_enabled)
{
ImGui::InputInt("Player Count", &g->session.player_magnet_count);
ImGui::InputInt("Player Count", &g.session.player_magnet_count);
}
components::sub_title("Chat");
ImGui::Checkbox("Auto-kick Chat Spammers", &g->session.kick_chat_spammers);
ImGui::Checkbox("Disable Filter", &g->session.disable_chat_filter);
ImGui::Checkbox("Log Chat Messages", &g->session.log_chat_messages);
ImGui::Checkbox("Log Text Messages", &g->session.log_text_messages);
ImGui::Checkbox("Auto-kick Chat Spammers", &g.session.kick_chat_spammers);
ImGui::Checkbox("Disable Filter", &g.session.disable_chat_filter);
ImGui::Checkbox("Log Chat Messages", &g.session.log_chat_messages);
ImGui::Checkbox("Log Text Messages", &g.session.log_text_messages);
static char msg[256];
ImGui::InputText("##message", msg, sizeof(msg));
ImGui::SameLine();
ImGui::Checkbox("Is Team", &g->session.is_team);
ImGui::Checkbox("Is Team", &g.session.is_team);
ImGui::SameLine();
components::button("Send", []
{
if(const auto net_game_player = gta_util::get_network_player_mgr()->m_local_net_player; net_game_player)
{
if(g_pointers->m_send_chat_message(*g_pointers->m_send_chat_ptr, net_game_player->get_net_data(), msg, g->session.is_team))
notify::draw_chat(msg, net_game_player->get_name(), g->session.is_team);
if(g_pointers->m_send_chat_message(*g_pointers->m_send_chat_ptr, net_game_player->get_net_data(), msg, g.session.is_team))
notify::draw_chat(msg, net_game_player->get_name(), g.session.is_team);
}
});
components::sub_title("Decloak");
components::script_patch_checkbox("Reveal OTR Players", &g->session.decloak_players);
components::script_patch_checkbox("Reveal OTR Players", &g.session.decloak_players);
components::sub_title("Force Host");
ImGui::Checkbox("Force Session Host", &g->session.force_session_host);
ImGui::Checkbox("Force Session Host", &g.session.force_session_host);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Join another session to apply changes. The original host of the session must leave or be kicked. This feature is easily detectable by other mod menus, use with caution");
ImGui::SameLine();
if (g->session.force_session_host)
if (g.session.force_session_host)
{
ImGui::SameLine();
ImGui::Checkbox("Kick Host During Join", &g->session.kick_host_when_forcing_host);
ImGui::Checkbox("Kick Host During Join", &g.session.kick_host_when_forcing_host);
}
if (ImGui::Checkbox("Force Script Host", &g->session.force_script_host))
if (ImGui::Checkbox("Force Script Host", &g.session.force_script_host))
{
if (g->session.force_script_host)
if (g.session.force_script_host)
g_fiber_pool->queue_job([]
{
scripts::force_host(RAGE_JOAAT("freemode"));
@ -126,40 +126,40 @@ namespace big
}
components::sub_title("Remote Name Spoofing");
ImGui::Checkbox("Spoof Other Players' Names", &g->session.name_spoof_enabled);
ImGui::Checkbox("Spoof Other Players' Names", &g.session.name_spoof_enabled);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Requires session host. Spoofed names will not visible locally nor to the player that had their name spoofed. Requires players to join after becoming host");
if (g->session.name_spoof_enabled)
if (g.session.name_spoof_enabled)
{
ImGui::Checkbox("Advertise YimMenu", &g->session.advertise_menu);
ImGui::Checkbox("Advertise YimMenu", &g.session.advertise_menu);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Advertise YimMenu by spoofing player names to differently colored variants of 'YimMenu'. You will not be able to customize the name with this option enabled");
if (!g->session.advertise_menu)
if (!g.session.advertise_menu)
{
constexpr size_t name_size = RTL_FIELD_SIZE(rage::rlGamerInfo, m_name);
static char name[name_size];
strcpy_s(name, sizeof(name), g->session.spoofed_name.c_str());
strcpy_s(name, sizeof(name), g.session.spoofed_name.c_str());
ImGui::Text("Name: ");
ImGui::InputText("##username_input", name, sizeof(name));
if (name != g->session.spoofed_name)
g->session.spoofed_name = std::string(name);
if (name != g.session.spoofed_name)
g.session.spoofed_name = std::string(name);
}
}
components::sub_title("All Players");
ImGui::Checkbox("Off The Radar", &g->session.off_radar_all);
ImGui::Checkbox("Off The Radar", &g.session.off_radar_all);
ImGui::SameLine();
ImGui::Checkbox("Never Wanted", &g->session.never_wanted_all);
ImGui::Checkbox("Never Wanted", &g.session.never_wanted_all);
ImGui::SameLine();
ImGui::Checkbox("Semi Godmode", &g->session.semi_godmode_all);
ImGui::Checkbox("Semi Godmode", &g.session.semi_godmode_all);
ImGui::Checkbox("Explosion Karma", &g->session.explosion_karma);
ImGui::Checkbox("Explosion Karma", &g.session.explosion_karma);
ImGui::SameLine();
ImGui::Checkbox("Damage Karma", &g->session.damage_karma);
ImGui::Checkbox("Damage Karma", &g.session.damage_karma);
static int global_wanted_level = 0;
@ -169,7 +169,7 @@ namespace big
}
ImGui::SameLine();
if (ImGui::Checkbox("Force", &g->session.wanted_level_all))
if (ImGui::Checkbox("Force", &g.session.wanted_level_all))
{
*scr_globals::globalplayer_bd.at(self::id, scr_globals::size::globalplayer_bd).at(212).as<Player*>() = __rdtsc() + 32;
*scr_globals::globalplayer_bd.at(self::id, scr_globals::size::globalplayer_bd).at(213).as<int*>() = global_wanted_level;
@ -197,16 +197,16 @@ namespace big
components::small_text("Teleports");
if (ImGui::BeginCombo("##apartment", apartment_names[g->session.send_to_apartment_idx]))
if (ImGui::BeginCombo("##apartment", apartment_names[g.session.send_to_apartment_idx]))
{
for (int i = 1; i < apartment_names.size(); i++)
{
if (ImGui::Selectable(apartment_names[i], i == g->session.send_to_apartment_idx))
if (ImGui::Selectable(apartment_names[i], i == g.session.send_to_apartment_idx))
{
g->session.send_to_apartment_idx = i;
g.session.send_to_apartment_idx = i;
}
if (i == g->session.send_to_apartment_idx)
if (i == g.session.send_to_apartment_idx)
{
ImGui::SetItemDefaultFocus();
}
@ -217,18 +217,18 @@ namespace big
ImGui::SameLine();
components::button("TP All To Apartment", [] { g_player_service->iterate([](auto& plyr) { toxic::send_player_to_apartment(plyr.second, g->session.send_to_apartment_idx); }); });
components::button("TP All To Apartment", [] { g_player_service->iterate([](auto& plyr) { toxic::send_player_to_apartment(plyr.second, g.session.send_to_apartment_idx); }); });
if (ImGui::BeginCombo("##warehouse", warehouse_names[g->session.send_to_warehouse_idx]))
if (ImGui::BeginCombo("##warehouse", warehouse_names[g.session.send_to_warehouse_idx]))
{
for (int i = 1; i < warehouse_names.size(); i++)
{
if (ImGui::Selectable(warehouse_names[i], i == g->session.send_to_warehouse_idx))
if (ImGui::Selectable(warehouse_names[i], i == g.session.send_to_warehouse_idx))
{
g->session.send_to_warehouse_idx = i;
g.session.send_to_warehouse_idx = i;
}
if (i == g->session.send_to_warehouse_idx)
if (i == g.session.send_to_warehouse_idx)
{
ImGui::SetItemDefaultFocus();
}
@ -239,7 +239,7 @@ namespace big
ImGui::SameLine();
components::button("TP All To Warehouse", [] { g_player_service->iterate([](auto& plyr) { toxic::send_player_to_warehouse(plyr.second, g->session.send_to_warehouse_idx); }); });
components::button("TP All To Warehouse", [] { g_player_service->iterate([](auto& plyr) { toxic::send_player_to_warehouse(plyr.second, g.session.send_to_warehouse_idx); }); });
components::button("TP All To Darts", [] { g_player_service->iterate([](auto& plyr) { toxic::start_activity(plyr.second, eActivityType::Darts); }); });
ImGui::SameLine();
@ -313,17 +313,17 @@ namespace big
components::button("Camhedz", [] { scripts::start_launcher_script(218); });
ImGui::EndGroup();
ImGui::Checkbox("Disable Pedestrians", &g->session.disable_peds);
ImGui::Checkbox("Disable Pedestrians", &g.session.disable_peds);
ImGui::SameLine();
ImGui::Checkbox("Disable Traffic", &g->session.disable_traffic);
ImGui::Checkbox("Disable Traffic", &g.session.disable_traffic);
ImGui::SameLine();
ImGui::Checkbox("Force Thunder", &g->session.force_thunder);
ImGui::Checkbox("Force Thunder", &g.session.force_thunder);
components::sub_title("Script Host Features");
ImGui::Checkbox("Disable CEO Money", &g->session.block_ceo_money);
ImGui::Checkbox("Disable CEO Money", &g.session.block_ceo_money);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Blocks CEO money drops across the entire session. This can also break other stuff, use with caution");
ImGui::SameLine();
ImGui::Checkbox("Randomize CEO Colors", &g->session.randomize_ceo_colors);
ImGui::Checkbox("Randomize CEO Colors", &g.session.randomize_ceo_colors);
}
}

View File

@ -87,22 +87,22 @@ namespace big
if (ImGui::TreeNode("Filters"))
{
ImGui::Checkbox("Region", &g->session_browser.region_filter_enabled);
ImGui::Checkbox("Region", &g.session_browser.region_filter_enabled);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("It is highly recommended to keep this filter enabled");
if (g->session_browser.region_filter_enabled)
if (g.session_browser.region_filter_enabled)
{
ImGui::SameLine();
if (ImGui::BeginCombo("###region_select", regions[g->session_browser.region_filter].name))
if (ImGui::BeginCombo("###region_select", regions[g.session_browser.region_filter].name))
{
for (const auto& region : regions)
{
if (ImGui::Selectable(region.name, g->session_browser.region_filter == region.id))
if (ImGui::Selectable(region.name, g.session_browser.region_filter == region.id))
{
g->session_browser.region_filter = region.id;
g.session_browser.region_filter = region.id;
}
}
ImGui::EndCombo();
@ -110,34 +110,34 @@ namespace big
}
ImGui::Checkbox("Language", &g->session_browser.language_filter_enabled);
ImGui::Checkbox("Language", &g.session_browser.language_filter_enabled);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Setting a correct region filter for the language will help tremendously");
if (g->session_browser.language_filter_enabled)
if (g.session_browser.language_filter_enabled)
{
ImGui::SameLine();
if (ImGui::BeginCombo("###language_select", languages[g->session_browser.language_filter].name))
if (ImGui::BeginCombo("###language_select", languages[g.session_browser.language_filter].name))
{
for (const auto& language : languages)
{
if (ImGui::Selectable(language.name, g->session_browser.language_filter == language.id))
if (ImGui::Selectable(language.name, g.session_browser.language_filter == language.id))
{
g->session_browser.language_filter = language.id;
g.session_browser.language_filter = language.id;
};
}
ImGui::EndCombo();
}
}
ImGui::Checkbox("Players", &g->session_browser.player_count_filter_enabled);
ImGui::Checkbox("Players", &g.session_browser.player_count_filter_enabled);
if (g->session_browser.player_count_filter_enabled)
if (g.session_browser.player_count_filter_enabled)
{
ImGui::InputInt("Minimum", &g->session_browser.player_count_filter_minimum);
ImGui::InputInt("Maximum", &g->session_browser.player_count_filter_maximum);
ImGui::InputInt("Minimum", &g.session_browser.player_count_filter_minimum);
ImGui::InputInt("Maximum", &g.session_browser.player_count_filter_maximum);
}
ImGui::TreePop();
@ -145,13 +145,13 @@ namespace big
if (ImGui::TreeNode("Sorting"))
{
ImGui::Combo("Sort By", &g->session_browser.sort_method, "Off\0Player Count");
if (g->session_browser.sort_method != 0)
ImGui::Combo("Direction", &g->session_browser.sort_direction, "Ascending\0Descending");
ImGui::Combo("Sort By", &g.session_browser.sort_method, "Off\0Player Count");
if (g.session_browser.sort_method != 0)
ImGui::Combo("Direction", &g.session_browser.sort_direction, "Ascending\0Descending");
ImGui::TreePop();
}
if (ImGui::Checkbox("Replace Game Matchmaking", &g->session_browser.replace_game_matchmaking));
if (ImGui::Checkbox("Replace Game Matchmaking", &g.session_browser.replace_game_matchmaking));
if (ImGui::IsItemHovered())
ImGui::SetTooltip("This will replace the default game matchmaking with a custom one that will use the filters and sorting set here");

View File

@ -17,17 +17,17 @@ namespace big
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
ImGui::Checkbox("Spoof Username", &g->spoofing.spoof_username);
ImGui::Checkbox("Spoof Username", &g.spoofing.spoof_username);
constexpr size_t name_size = RTL_FIELD_SIZE(rage::rlGamerInfo, m_name);
static char name[name_size];
strcpy_s(name, sizeof(name), g->spoofing.username.c_str());
strcpy_s(name, sizeof(name), g.spoofing.username.c_str());
ImGui::Text("Username:");
ImGui::InputText("##username_input", name, sizeof(name));
if (name != g->spoofing.username)
g->spoofing.username = std::string(name);
if (name != g.spoofing.username)
g.spoofing.username = std::string(name);
ImGui::Separator();
@ -37,10 +37,10 @@ namespace big
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
ImGui::Checkbox("Spoof IP", &g->spoofing.spoof_ip);
ImGui::Checkbox("Spoof IP", &g.spoofing.spoof_ip);
ImGui::Text("IP Address:");
ImGui::DragInt4("##ip_fields", g->spoofing.ip_address, 0, 255);
ImGui::DragInt4("##ip_fields", g.spoofing.ip_address.data(), 0, 255);
ImGui::Separator();
@ -50,14 +50,14 @@ namespace big
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
ImGui::Checkbox("Spoof Rockstar ID", &g->spoofing.spoof_rockstar_id);
ImGui::Checkbox("Spoof Rockstar ID", &g.spoofing.spoof_rockstar_id);
ImGui::Text("Rockstar ID:");
ImGui::InputScalar("##rockstar_id_input", ImGuiDataType_U64, &g->spoofing.rockstar_id);
ImGui::InputScalar("##rockstar_id_input", ImGuiDataType_U64, &g.spoofing.rockstar_id);
components::sub_title("Hide Features");
ImGui::Checkbox("Hide God Mode", &g->spoofing.spoof_hide_god);
ImGui::Checkbox("Hide Spectate", &g->spoofing.spoof_hide_spectate);
ImGui::Checkbox("Hide God Mode", &g.spoofing.spoof_hide_god);
ImGui::Checkbox("Hide Spectate", &g.spoofing.spoof_hide_spectate);
components::sub_title("Crew");
@ -65,70 +65,70 @@ namespace big
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
ImGui::Checkbox("Spoof Crew", &g->spoofing.spoof_crew_data);
ImGui::Checkbox("Spoof Crew", &g.spoofing.spoof_crew_data);
constexpr size_t crew_tag_size = RTL_FIELD_SIZE(ClanData, m_clan_tag);
static char crew_tag[crew_tag_size];
strcpy_s(crew_tag, sizeof(crew_tag), g->spoofing.crew_tag.c_str());
strcpy_s(crew_tag, sizeof(crew_tag), g.spoofing.crew_tag.c_str());
ImGui::Text("Crew Tag:");
ImGui::InputText("##crew_tag_input", crew_tag, sizeof(crew_tag));
if (crew_tag != g->spoofing.crew_tag)
g->spoofing.crew_tag = std::string(crew_tag);
if (crew_tag != g.spoofing.crew_tag)
g.spoofing.crew_tag = std::string(crew_tag);
ImGui::Checkbox("Is Rockstar Crew", &g->spoofing.rockstar_crew);
ImGui::Checkbox("Is Rockstar Crew", &g.spoofing.rockstar_crew);
ImGui::Checkbox("Square Crew Tag", &g->spoofing.square_crew_tag);
ImGui::Checkbox("Square Crew Tag", &g.spoofing.square_crew_tag);
components::sub_title("Extra - Only work when Spoofed RID");
ImGui::Checkbox("Is Cheater", &g->spoofing.spoof_cheater);
ImGui::Checkbox("Is Rockstar Dev", &g->spoofing.spoof_rockstar_dev);
ImGui::Checkbox("Is Rockstar QA", &g->spoofing.spoof_rockstar_qa);
ImGui::Checkbox("Is Cheater", &g.spoofing.spoof_cheater);
ImGui::Checkbox("Is Rockstar Dev", &g.spoofing.spoof_rockstar_dev);
ImGui::Checkbox("Is Rockstar QA", &g.spoofing.spoof_rockstar_qa);
components::sub_title("Session Attributes");
components::small_text("Only works when session host");
ImGui::Checkbox("Region", &g->spoofing.spoof_session_region_type);
if (g->spoofing.spoof_session_region_type)
ImGui::Checkbox("Region", &g.spoofing.spoof_session_region_type);
if (g.spoofing.spoof_session_region_type)
{
ImGui::SameLine();
if (ImGui::BeginCombo("###region_select", regions[g->spoofing.session_region_type].name))
if (ImGui::BeginCombo("###region_select", regions[g.spoofing.session_region_type].name))
{
for (const auto& region : regions)
{
if (ImGui::Selectable(region.name, g->spoofing.session_region_type == region.id))
if (ImGui::Selectable(region.name, g.spoofing.session_region_type == region.id))
{
g->spoofing.session_region_type = region.id;
g.spoofing.session_region_type = region.id;
}
}
ImGui::EndCombo();
}
}
ImGui::Checkbox("Language", &g->spoofing.spoof_session_language);
if (g->spoofing.spoof_session_language)
ImGui::Checkbox("Language", &g.spoofing.spoof_session_language);
if (g.spoofing.spoof_session_language)
{
ImGui::SameLine();
if (ImGui::BeginCombo("###language_select", languages[g->spoofing.session_language].name))
if (ImGui::BeginCombo("###language_select", languages[g.spoofing.session_language].name))
{
for (const auto& language : languages)
{
if (ImGui::Selectable(language.name, g->spoofing.session_language == language.id))
if (ImGui::Selectable(language.name, g.spoofing.session_language == language.id))
{
g->spoofing.session_language = language.id;
g.spoofing.session_language = language.id;
};
}
ImGui::EndCombo();
}
}
ImGui::Checkbox("Player Count", &g->spoofing.spoof_session_player_count);
if (g->spoofing.spoof_session_player_count)
ImGui::Checkbox("Player Count", &g.spoofing.spoof_session_player_count);
if (g.spoofing.spoof_session_player_count)
{
ImGui::SameLine();
ImGui::InputInt("###player_count", &g->spoofing.session_player_count);
ImGui::InputInt("###player_count", &g.spoofing.session_player_count);
}
}
}