|
| 1 | +#include "networking/logic/logic_matchmaking_composition.hpp" |
| 2 | + |
| 3 | +#include "game/multiplayer_game_hopper.hpp" |
| 4 | +#include "memory/module.hpp" |
| 5 | +#include "networking/session/network_session.hpp" |
| 6 | + |
| 7 | +//REFERENCE_DECLARE_ARRAY(0x0189C1E8, char const*, k_network_session_matchmaking_composition_build_results, k_network_session_matchmaking_composition_build_result_count); |
| 8 | + |
| 9 | +HOOK_DECLARE(0x004D2840, network_session_build_matchmaking_composition); |
| 10 | + |
| 11 | +//.text:004D27E0 ; public: bool c_hopper_configuration::are_guests_allowed() const |
| 12 | +//.text:004D27F0 ; public: int32 c_hopper_configuration::get_big_squad_size_threshold() const |
| 13 | +//.text:004D2810 ; public: int32 c_hopper_configuration::get_maximum_big_squad_imbalance() const |
| 14 | +//.text:004D2820 ; public: bool c_hopper_configuration::is_big_squad_restriction_enabled() const |
| 15 | + |
| 16 | +e_network_session_matchmaking_composition_build_result __cdecl network_session_build_matchmaking_composition(c_network_session const* session, s_network_session_matchmaking_composition* composition_out) |
| 17 | +{ |
| 18 | + //return INVOKE(0x004D2840, network_session_build_matchmaking_composition, session, composition_out); |
| 19 | + |
| 20 | + ASSERT(session); |
| 21 | + ASSERT(composition_out); |
| 22 | + |
| 23 | + csmemset(composition_out, 0, sizeof(s_network_session_matchmaking_composition)); |
| 24 | + |
| 25 | + e_network_session_matchmaking_composition_build_result result = _network_session_matchmaking_composition_build_result_none; |
| 26 | + |
| 27 | + if (!network_session_matchmaking_composition_session_state_valid(session, &result)) |
| 28 | + { |
| 29 | + if (result != _network_session_matchmaking_composition_build_result_success) |
| 30 | + { |
| 31 | + return result; |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + c_network_session_membership const* session_membership = session->get_session_membership(); |
| 36 | + c_hopper_configuration const* hopper_configuration = multiplayer_game_hoppers_get_current_hopper_configuration(); |
| 37 | + if (!network_session_matchmaking_composition_session_state_ready(session_membership, hopper_configuration, &result)) |
| 38 | + { |
| 39 | + if (result != _network_session_matchmaking_composition_build_result_success) |
| 40 | + { |
| 41 | + return result; |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + //composition_out->session_properties.hopper_identifier = hopper_configuration->get_hopper_identifier(); |
| 46 | + composition_out->session_properties.hopper_identifier = hopper_configuration->m_universal.hopper_identifier; |
| 47 | + |
| 48 | + //composition_out->session_properties.hopper_ranked = hopper_configuration->is_ranked(); |
| 49 | + e_hopper_type hopper_type = hopper_configuration->m_universal.hopper_type; |
| 50 | + composition_out->session_properties.hopper_ranked = hopper_type == _hopper_type_ranked_ffa || hopper_type == _hopper_type_ranked_teams; |
| 51 | + |
| 52 | + result = network_session_matchmaking_composition_build_players_and_parties(session_membership, hopper_configuration, composition_out); |
| 53 | + if (result != _network_session_matchmaking_composition_build_result_success) |
| 54 | + { |
| 55 | + return result; |
| 56 | + } |
| 57 | + |
| 58 | + result = network_session_matchmaking_composition_build_party_masks(session_membership, hopper_configuration, composition_out); |
| 59 | + if (result != _network_session_matchmaking_composition_build_result_success) |
| 60 | + { |
| 61 | + return result; |
| 62 | + } |
| 63 | + |
| 64 | + result = network_session_matchmaking_composition_build_session_statistics(session_membership, composition_out); |
| 65 | + if (result != _network_session_matchmaking_composition_build_result_success) |
| 66 | + { |
| 67 | + return result; |
| 68 | + } |
| 69 | + |
| 70 | + result = network_session_matchmaking_composition_build_local_properties(session_membership, composition_out); |
| 71 | + if (result != _network_session_matchmaking_composition_build_result_success) |
| 72 | + { |
| 73 | + return result; |
| 74 | + } |
| 75 | + |
| 76 | + composition_out->session_properties.flags.set(_network_session_matchmaking_composition_valid_bit, true); |
| 77 | + |
| 78 | + return _network_session_matchmaking_composition_build_result_success; |
| 79 | +} |
| 80 | + |
| 81 | +e_network_session_matchmaking_composition_build_result __cdecl network_session_matchmaking_composition_build_flags(c_network_session_membership const* session_membership, c_hopper_configuration const* hopper_configuration, s_network_session_matchmaking_composition* composition_out) |
| 82 | +{ |
| 83 | + return INVOKE(0x004D2930, network_session_matchmaking_composition_build_flags, session_membership, hopper_configuration, composition_out); |
| 84 | +} |
| 85 | + |
| 86 | +e_network_session_matchmaking_composition_build_result __cdecl network_session_matchmaking_composition_build_guest_statistics(c_network_session_membership const* session_membership, c_hopper_configuration const* hopper_configuration, s_network_session_matchmaking_composition* composition_out) |
| 87 | +{ |
| 88 | + return INVOKE(0x004D2970, network_session_matchmaking_composition_build_guest_statistics, session_membership, hopper_configuration, composition_out); |
| 89 | +} |
| 90 | + |
| 91 | +e_network_session_matchmaking_composition_build_result __cdecl network_session_matchmaking_composition_build_local_properties(c_network_session_membership const* session_membership, s_network_session_matchmaking_composition* composition_out) |
| 92 | +{ |
| 93 | + //return INVOKE(0x004D2A00, network_session_matchmaking_composition_build_local_properties, session_membership, composition_out); |
| 94 | + |
| 95 | + // $TODO: implement me |
| 96 | + |
| 97 | + composition_out->session_properties.language = session_membership->m_shared_network_membership.peers[session_membership->m_local_peer_index].properties.language; |
| 98 | + composition_out->session_properties.nat_type = session_membership->m_shared_network_membership.peers[session_membership->m_local_peer_index].properties.nat_type; |
| 99 | + |
| 100 | + //composition_out->session_properties.gamer_region = ; |
| 101 | + //composition_out->session_properties.gamer_zone = ; |
| 102 | + |
| 103 | + return _network_session_matchmaking_composition_build_result_success; |
| 104 | +} |
| 105 | + |
| 106 | +e_network_session_matchmaking_composition_build_result __cdecl network_session_matchmaking_composition_build_party_masks(c_network_session_membership const* session_membership, c_hopper_configuration const* hopper_configuration, s_network_session_matchmaking_composition* composition_out) |
| 107 | +{ |
| 108 | + return INVOKE(0x004D2A40, network_session_matchmaking_composition_build_party_masks, session_membership, hopper_configuration, composition_out); |
| 109 | +} |
| 110 | + |
| 111 | +e_network_session_matchmaking_composition_build_result __cdecl network_session_matchmaking_composition_build_player_party_indices(c_network_session_membership const* session_membership, c_hopper_configuration const* hopper_configuration, s_network_session_matchmaking_composition* composition_out) |
| 112 | +{ |
| 113 | + return INVOKE(0x004D2F30, network_session_matchmaking_composition_build_player_party_indices, session_membership, hopper_configuration, composition_out); |
| 114 | +} |
| 115 | + |
| 116 | +e_network_session_matchmaking_composition_build_result __cdecl network_session_matchmaking_composition_build_player_statistics(c_network_session_membership const* session_membership, c_hopper_configuration const* hopper_configuration, s_network_session_matchmaking_composition* composition_out) |
| 117 | +{ |
| 118 | + return INVOKE(0x004D30C0, network_session_matchmaking_composition_build_player_statistics, session_membership, hopper_configuration, composition_out); |
| 119 | +} |
| 120 | + |
| 121 | +e_network_session_matchmaking_composition_build_result __cdecl network_session_matchmaking_composition_build_players_and_parties(c_network_session_membership const* session_membership, c_hopper_configuration const* hopper_configuration, s_network_session_matchmaking_composition* composition_out) |
| 122 | +{ |
| 123 | + return INVOKE(0x004D33B0, network_session_matchmaking_composition_build_players_and_parties, session_membership, hopper_configuration, composition_out); |
| 124 | +} |
| 125 | +e_network_session_matchmaking_composition_build_result __cdecl network_session_matchmaking_composition_build_session_statistics(c_network_session_membership const* session_membership, s_network_session_matchmaking_composition* composition_out) |
| 126 | +{ |
| 127 | + return INVOKE(0x004D3460, network_session_matchmaking_composition_build_session_statistics, session_membership, composition_out); |
| 128 | +} |
| 129 | + |
| 130 | +char const* __cdecl network_session_matchmaking_composition_get_build_result_string(e_network_session_matchmaking_composition_build_result result) |
| 131 | +{ |
| 132 | + return INVOKE(0x004D34E0, network_session_matchmaking_composition_get_build_result_string, result); |
| 133 | +} |
| 134 | + |
| 135 | +bool __cdecl network_session_matchmaking_composition_session_state_ready(c_network_session_membership const* session_membership, c_hopper_configuration const* hopper_configuration, e_network_session_matchmaking_composition_build_result* failure_build_result_out) |
| 136 | +{ |
| 137 | + return INVOKE(0x004D34F0, network_session_matchmaking_composition_session_state_ready, session_membership, hopper_configuration, failure_build_result_out); |
| 138 | +} |
| 139 | + |
| 140 | +bool __cdecl network_session_matchmaking_composition_session_state_valid(c_network_session const* session, e_network_session_matchmaking_composition_build_result* result_out) |
| 141 | +{ |
| 142 | + return INVOKE(0x004D35C0, network_session_matchmaking_composition_session_state_valid, session, result_out); |
| 143 | +} |
| 144 | + |
| 145 | +char const* k_network_session_matchmaking_composition_build_results[k_network_session_matchmaking_composition_build_result_count] //.data:0189C1E8 ; |
| 146 | +{ |
| 147 | + "none", |
| 148 | + "session-state-not-ready", |
| 149 | + "no-hopper-configuration", |
| 150 | + "hopper-mismatch", |
| 151 | + "no-game-set", |
| 152 | + "session-not-ready-no-stats", |
| 153 | + "session-not-ready-banned", |
| 154 | + "session-not-ready-no-controller", |
| 155 | + "invalid-player-count", |
| 156 | + "invalid-party-composition", |
| 157 | + "guests-not-allowed", |
| 158 | + "can't-pick-teams", |
| 159 | + "can't-even-out-teams", |
| 160 | + "big-party-no-rabble-yet", |
| 161 | + "big-party-teams-exceed-imbalance", |
| 162 | + "big-party-count-exceeds-teams", |
| 163 | + "no-signed-in-local-players", |
| 164 | + "invalid-skill-range", |
| 165 | + "success" |
| 166 | +}; |
| 167 | + |
0 commit comments