Skip to content

Commit 24b4635

Browse files
committed
Added logic_matchmaking_composition logic
1 parent 9c678d1 commit 24b4635

4 files changed

Lines changed: 262 additions & 0 deletions

File tree

game/game.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ copy /b $(ProjectDir)source\config\version.cpp +,, $(ProjectDir)source\config\ve
340340
<ClCompile Include="source\networking\logic\life_cycle\life_cycle_matchmaking_quality.cpp" />
341341
<ClCompile Include="source\networking\logic\life_cycle\life_cycle_state_handler.cpp" />
342342
<ClCompile Include="source\networking\logic\logic_managed_user.cpp" />
343+
<ClCompile Include="source\networking\logic\logic_matchmaking_composition.cpp" />
343344
<ClCompile Include="source\networking\logic\logic_matchmaking_seeker.cpp" />
344345
<ClCompile Include="source\networking\logic\network_bandwidth.cpp" />
345346
<ClCompile Include="source\networking\logic\network_banhammer.cpp" />
@@ -1078,6 +1079,7 @@ copy /b $(ProjectDir)source\config\version.cpp +,, $(ProjectDir)source\config\ve
10781079
<ClInclude Include="source\networking\delivery\network_connection.hpp" />
10791080
<ClInclude Include="source\networking\logic\life_cycle\life_cycle_state_handler.hpp" />
10801081
<ClInclude Include="source\networking\logic\logic_managed_user.hpp" />
1082+
<ClInclude Include="source\networking\logic\logic_matchmaking_composition.hpp" />
10811083
<ClInclude Include="source\networking\logic\logic_matchmaking_seeker.hpp" />
10821084
<ClInclude Include="source\networking\logic\logic_session_tracker.hpp" />
10831085
<ClInclude Include="source\networking\logic\network_bandwidth.hpp" />

game/game.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,9 @@
19621962
<ClCompile Include="source\interface\user_interface_data.cpp">
19631963
<Filter>Source Files</Filter>
19641964
</ClCompile>
1965+
<ClCompile Include="source\networking\logic\logic_matchmaking_composition.cpp">
1966+
<Filter>Source Files</Filter>
1967+
</ClCompile>
19651968
</ItemGroup>
19661969
<ItemGroup>
19671970
<ClInclude Include="source\camera\camera.hpp">
@@ -4367,6 +4370,9 @@
43674370
<ClInclude Include="source\objects\emblems.hpp">
43684371
<Filter>Header Files</Filter>
43694372
</ClInclude>
4373+
<ClInclude Include="source\networking\logic\logic_matchmaking_composition.hpp">
4374+
<Filter>Header Files</Filter>
4375+
</ClInclude>
43704376
</ItemGroup>
43714377
<ItemGroup>
43724378
<ResourceCompile Include="resource\resource.rc">
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
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+
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#pragma once
2+
3+
#include "cseries/cseries.hpp"
4+
#include "networking/logic/logic_matchmaking_desirability.hpp"
5+
6+
struct c_hopper_configuration;
7+
struct c_network_session;
8+
struct c_network_session_membership;
9+
10+
enum e_network_session_matchmaking_composition_build_result
11+
{
12+
_network_session_matchmaking_composition_build_result_none = 0,
13+
_network_session_matchmaking_composition_build_result_session_state_not_ready,
14+
_network_session_matchmaking_composition_build_result_session_no_hopper_configuration,
15+
_network_session_matchmaking_composition_build_result_session_hopper_mismatch,
16+
_network_session_matchmaking_composition_build_result_session_no_game_set,
17+
_network_session_matchmaking_composition_build_result_session_not_ready_no_stats,
18+
_network_session_matchmaking_composition_build_result_session_not_ready_banned,
19+
_network_session_matchmaking_composition_build_result_session_not_ready_no_controller,
20+
_network_session_matchmaking_composition_build_result_invalid_player_count,
21+
_network_session_matchmaking_composition_build_result_invalid_party_composition,
22+
_network_session_matchmaking_composition_build_result_invalid_guests_not_allowed,
23+
_network_session_matchmaking_composition_build_result_invalid_cannot_pick_teams,
24+
_network_session_matchmaking_composition_build_result_invalid_cannot_even_out_teams,
25+
_network_session_matchmaking_composition_build_result_invalid_big_party_needs_more_big_parties_before_rabble,
26+
_network_session_matchmaking_composition_build_result_invalid_big_party_imbalance_exceeded,
27+
_network_session_matchmaking_composition_build_result_invalid_big_party_count_exceeds_team_count,
28+
_network_session_matchmaking_composition_build_result_invalid_no_signed_in_player,
29+
_network_session_matchmaking_composition_build_result_invalid_skill_range,
30+
_network_session_matchmaking_composition_build_result_success,
31+
32+
k_network_session_matchmaking_composition_build_result_count,
33+
};
34+
35+
struct s_network_session_player_matchmaking_composition
36+
{
37+
int32 skill_level;
38+
int32 experience_rank;
39+
real32 mu;
40+
int32 adjusted_skill_level;
41+
};
42+
static_assert(sizeof(s_network_session_player_matchmaking_composition) == 0x10);
43+
44+
struct __declspec(align(4)) s_network_session_party_matchmaking_composition
45+
{
46+
int32 player_count;
47+
int32 guest_count;
48+
int32 average_adjusted_skill_level;
49+
int32 maximum_skill_level;
50+
int32 minimum_adjusted_skill_level;
51+
real32 average_mu;
52+
int32 average_experience_rank;
53+
c_network_session_matchmaking_composition_flags flags;
54+
};
55+
static_assert(sizeof(s_network_session_party_matchmaking_composition) == 0x20);
56+
57+
struct s_network_session_matchmaking_composition
58+
{
59+
s_matchmaking_session_properties session_properties;
60+
int32 guest_count;
61+
c_static_array<s_network_session_player_matchmaking_composition, 16> players;
62+
int32 team_imbalance;
63+
int32 party_count;
64+
int32 big_party_count;
65+
int32 big_party_imbalance;
66+
c_static_array<s_network_session_party_matchmaking_composition, 17> parties;
67+
int32 best_host_estimated_downstream_bandwidth_bps;
68+
int32 best_host_estimated_upstream_bandwidth_bps;
69+
};
70+
static_assert(sizeof(s_network_session_matchmaking_composition) == 0x400);
71+
72+
//extern char const*(&k_network_session_matchmaking_composition_build_results)[k_network_session_matchmaking_composition_build_result_count];
73+
extern char const* k_network_session_matchmaking_composition_build_results[k_network_session_matchmaking_composition_build_result_count];
74+
75+
extern 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);
76+
extern 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);
77+
extern 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);
78+
extern 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);
79+
extern 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);
80+
extern 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);
81+
extern 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);
82+
extern 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);
83+
extern 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);
84+
extern char const* __cdecl network_session_matchmaking_composition_get_build_result_string(e_network_session_matchmaking_composition_build_result result);
85+
extern 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);
86+
extern bool __cdecl network_session_matchmaking_composition_session_state_valid(c_network_session const* session, e_network_session_matchmaking_composition_build_result* result_out);
87+

0 commit comments

Comments
 (0)