diff --git a/game/source/game/players.cpp b/game/source/game/players.cpp index 53fb49191..93c1dccc5 100644 --- a/game/source/game/players.cpp +++ b/game/source/game/players.cpp @@ -6,6 +6,7 @@ #include "game/multiplayer_definitions.hpp" #include "input/input_abstraction.hpp" #include "interface/interface_constants.hpp" +#include "memory/bitstream.hpp" #include "memory/module.hpp" #include "memory/thread_local.hpp" #include "render/render_debug.hpp" @@ -17,6 +18,8 @@ HOOK_DECLARE(0x00536020, player_get_armor_loadout); HOOK_DECLARE(0x00536680, player_get_weapon_loadout); HOOK_DECLARE(0x0053F220, player_suppress_action); +HOOK_DECLARE_CLASS_MEMBER(0x00B26390, s_emblem_info, decode); +HOOK_DECLARE_CLASS_MEMBER(0x00B267B0, s_emblem_info, encode); bool debug_player_network_aiming = false; bool debug_objects_biped_melee_in_range = false; @@ -794,6 +797,26 @@ void __cdecl players_verify() //.text:00544610 ; //.text:00544680 ; +void s_emblem_info::decode(c_bitstream* packet) +{ + foreground_emblem = (char)packet->read_integer("foreground-emblem", 6); + background_emblem = (char)packet->read_integer("background-emblem", 6); + emblem_flags.set_unsafe((byte)packet->read_integer("emblem-flags", 3)); + emblem_primary_color.set_raw_value((char)packet->read_integer("emblem-primary-color", 6)); + emblem_primary_color.set_raw_value((char)packet->read_integer("emblem-secondary-color", 6)); + emblem_primary_color.set_raw_value((char)packet->read_integer("emblem-background-color", 6)); +} + +void s_emblem_info::encode(c_bitstream* packet) +{ + packet->write_integer("foreground-emblem", foreground_emblem, 6); + packet->write_integer("background-emblem", background_emblem, 6); + packet->write_integer("emblem-flags", emblem_flags.get_unsafe(), 3); + packet->write_integer("emblem-primary-color", emblem_primary_color, 6); + packet->write_integer("emblem-secondary-color", emblem_primary_color, 6); + packet->write_integer("emblem-background-color", emblem_primary_color, 6); +} + s_s3d_player_armor_configuration_loadout* __cdecl player_get_armor_loadout(player_datum* player) { s_s3d_player_armor_configuration_loadout& loadout = player->configuration.host.armor.loadouts[player->armor_loadout_index]; diff --git a/game/source/game/players.hpp b/game/source/game/players.hpp index b70a3d9c2..2f6844e51 100644 --- a/game/source/game/players.hpp +++ b/game/source/game/players.hpp @@ -36,31 +36,41 @@ struct s_player_identifier }; static_assert(sizeof(s_player_identifier) == 0x8); +enum e_emblem_info_flags +{ + _emblem_info_bit0 = 0, + _emblem_info_bit1, + _emblem_info_bit2, + + k_emblem_info_flags +}; + struct s_emblem_info { - struct + s_emblem_info() : + foreground_emblem(), + background_emblem(), + emblem_flags(), + emblem_primary_color(), + emblem_secondary_color(), + emblem_background_color(), + pad(0), + __pad8({}) { - struct - { - word __unknown0; - word __unknown2; - word __unknown4; - word __unknown6; - word __unknown8; - word __unknownA; - word __unknownC; - byte __unknownE; - byte __unknownF; - } __unknown0[50]; - - long __unknown0_count; - } __unknown0[2]; - - // checksums calculated with `fast_checksum` - // `fast_checksum` is a wrapper around the `hashlittle` as part of `lookup3` - // lookup3.c, by Bob Jenkins, May 2006, Public Domain. - // https://burtleburtle.net/bob/c/lookup3.c - dword __unknown0_checksums[2]; + } + + void __thiscall decode(c_bitstream* packet); + void __thiscall encode(c_bitstream* packet); + + c_enum foreground_emblem; + c_enum background_emblem; + c_flags emblem_flags; + c_enum emblem_primary_color; + c_enum emblem_secondary_color; + c_enum emblem_background_color; + word pad; + + byte __pad8[0x648]; }; static_assert(sizeof(s_emblem_info) == 0x650); @@ -79,8 +89,12 @@ struct s_player_appearance byte_flags flags; byte player_model_choice; + byte __pad2[0x2]; + s_emblem_info emblem_info; c_static_wchar_string<5> service_tag; + + byte __pad65E[0x2]; }; static_assert(sizeof(s_player_appearance) == 0x660); diff --git a/game/source/interface/gui_screens/start_menu/panes/settings_appearance_colors/start_menu_settings_appearance_colors.cpp b/game/source/interface/gui_screens/start_menu/panes/settings_appearance_colors/start_menu_settings_appearance_colors.cpp index d6647e19f..f010b8c05 100644 --- a/game/source/interface/gui_screens/start_menu/panes/settings_appearance_colors/start_menu_settings_appearance_colors.cpp +++ b/game/source/interface/gui_screens/start_menu/panes/settings_appearance_colors/start_menu_settings_appearance_colors.cpp @@ -94,9 +94,13 @@ void __thiscall c_start_menu_settings_appearance_colors::set_color_values_from_p set_color_focused_list_item(STRING_ID(gui, color_armor1), player_profile->get_primary_change_color()); set_color_focused_list_item(STRING_ID(gui, color_armor2), player_profile->get_secondary_change_color()); //set_color_focused_list_item(STRING_ID(gui, color_armor3), player_profile->get_tertiary_change_color()); - //set_color_focused_list_item(STRING_ID(gui, color_emblem1), player_profile->get_emblem_info().emblem_primary_color); - //set_color_focused_list_item(STRING_ID(gui, color_emblem2), player_profile->get_emblem_info().emblem_secondary_color); - //set_color_focused_list_item(STRING_ID(gui, color_emblem3), player_profile->get_emblem_info().emblem_background_color); + //set_color_focused_list_item(string_id_retrieve("color_armor3"), player_profile->get_tertiary_change_color()); + + //s_emblem_info emblem_info = player_profile->get_emblem_info(); + s_emblem_info emblem_info = player_profile->m_emblem_info; + set_color_focused_list_item(STRING_ID(gui, color_emblem1), emblem_info.emblem_primary_color); + set_color_focused_list_item(STRING_ID(gui, color_emblem2), emblem_info.emblem_secondary_color); + set_color_focused_list_item(STRING_ID(gui, color_emblem3), emblem_info.emblem_background_color); } }