Skip to content

Commit

Permalink
Updated s_emblem_info
Browse files Browse the repository at this point in the history
We're Halo 3 now lads (not really)
  • Loading branch information
twist84 committed Sep 21, 2024
1 parent 5bb5fcb commit f3a79fb
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 25 deletions.
23 changes: 23 additions & 0 deletions game/source/game/players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
58 changes: 36 additions & 22 deletions game/source/game/players.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<e_player_color_index, char, _player_color_none, k_number_of_player_colors> foreground_emblem;
c_enum<e_player_color_index, char, _player_color_none, k_number_of_player_colors> background_emblem;
c_flags<e_emblem_info_flags, byte, k_emblem_info_flags> emblem_flags;
c_enum<e_player_color_index, char, _player_color_none, k_number_of_player_colors> emblem_primary_color;
c_enum<e_player_color_index, char, _player_color_none, k_number_of_player_colors> emblem_secondary_color;
c_enum<e_player_color_index, char, _player_color_none, k_number_of_player_colors> emblem_background_color;
word pad;

byte __pad8[0x648];
};
static_assert(sizeof(s_emblem_info) == 0x650);

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit f3a79fb

Please sign in to comment.