Skip to content

Commit 2f55482

Browse files
committed
Updated game_create_players
1 parent 8d81349 commit 2f55482

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

game/source/game/game.cpp

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "memory/module.hpp"
4242
#include "memory/thread_local.hpp"
4343
#include "networking/network_globals.hpp"
44+
#include "networking/online/online.hpp"
4445
#include "networking/online/online_achievements.hpp"
4546
#include "networking/tools/network_webstats.hpp"
4647
#include "networking/tools/remote_command.hpp"
@@ -274,23 +275,40 @@ void __cdecl game_create_players()
274275
// simulation_notify_players_created();
275276
//}
276277

277-
if (game_is_splitscreen_deterministic())
278+
if (!game_is_splitscreen_deterministic())
279+
return;
280+
281+
c_player_in_game_iterator player_iterator;
282+
player_iterator.begin();
283+
while (player_iterator.next())
278284
{
279-
c_player_in_game_iterator player_iterator;
280-
player_iterator.begin();
281-
while (player_iterator.next())
285+
if (!player_is_local(player_iterator.get_index()))
286+
continue;
287+
288+
short absolute_index = player_iterator.get_absolute_index();
289+
player_datum* player = player_iterator.get_datum();
290+
291+
e_controller_index controller_index = (e_controller_index)absolute_index;
292+
if (VALID_CONTROLLER(controller_index))
282293
{
283-
if (player_is_local(player_iterator.get_index()))
284-
{
285-
short absolute_index = player_iterator.get_absolute_index();
286-
player_datum* player = player_iterator.get_datum();
294+
qword player_identifier = online_local_user_get_player_identifier(controller_index);
295+
player->player_identifier = player_identifier;
287296

288-
if (player->configuration.host.name.is_empty())
289-
player->configuration.host.name.print(L"player_%d", absolute_index);
297+
wchar_t const* name = online_local_user_get_name(controller_index);
290298

291-
if (player->configuration.client.desired_name.is_empty())
292-
player->configuration.client.desired_name.print(L"player_%d", absolute_index);
293-
}
299+
if (player->configuration.host.name.is_empty())
300+
player->configuration.host.name = name;
301+
302+
if (player->configuration.client.desired_name.is_empty())
303+
player->configuration.client.desired_name = name;
304+
}
305+
else
306+
{
307+
if (player->configuration.host.name.is_empty())
308+
player->configuration.host.name.print(L"player_%d", absolute_index);
309+
310+
if (player->configuration.client.desired_name.is_empty())
311+
player->configuration.client.desired_name.print(L"player_%d", absolute_index);
294312
}
295313
}
296314
}

game/source/game/players.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ s_player_identifier::s_player_identifier() :
5656
{
5757
}
5858

59+
s_player_identifier::s_player_identifier(qword data) :
60+
identifier(0)
61+
{
62+
csmemcpy(identifier, &data, sizeof(identifier));
63+
}
64+
5965
s_player_identifier::s_player_identifier(dword _ipv4_address, word _port, word_flags _flags) :
6066
identifier(0)
6167
{

game/source/game/players.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct transport_address;
1818
struct s_player_identifier
1919
{
2020
s_player_identifier();
21+
s_player_identifier(qword data);
2122
s_player_identifier(dword _ipv4_address, word _port, word_flags _flags);
2223
s_player_identifier(transport_address const* address);
2324

0 commit comments

Comments
 (0)