2021-05-26 13:17:19 +02:00
|
|
|
#include "backend/looped/looped.hpp"
|
|
|
|
#include "natives.hpp"
|
2021-07-26 21:23:27 +02:00
|
|
|
#include "pointers.hpp"
|
2021-05-26 13:17:19 +02:00
|
|
|
#include "script.hpp"
|
2021-07-26 21:23:27 +02:00
|
|
|
#include "util/notify.hpp"
|
2021-05-26 13:17:19 +02:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
static bool busy = false;
|
|
|
|
|
|
|
|
void looped::system_update_players()
|
|
|
|
{
|
|
|
|
if (busy) return;
|
|
|
|
busy = true;
|
|
|
|
|
2021-07-26 21:23:27 +02:00
|
|
|
int friend_count = g.friend_count;
|
|
|
|
int player_count = g.player_count;
|
2021-07-23 18:06:33 +02:00
|
|
|
|
2021-05-26 13:17:19 +02:00
|
|
|
for (Player i = 0; i < 32; i++)
|
|
|
|
{
|
2021-08-05 01:28:18 +02:00
|
|
|
if (NETWORK::NETWORK_IS_PLAYER_ACTIVE(i))
|
2021-05-26 13:17:19 +02:00
|
|
|
{
|
2021-07-26 21:23:27 +02:00
|
|
|
if (g.players[i].is_online) continue;
|
2021-05-26 13:17:19 +02:00
|
|
|
|
2021-05-26 13:33:26 +02:00
|
|
|
g.players[i].id = i;
|
2021-05-26 13:17:19 +02:00
|
|
|
g.players[i].is_online = true;
|
|
|
|
|
|
|
|
int iNetworkHandle[26];
|
|
|
|
NETWORK::NETWORK_HANDLE_FROM_PLAYER(i, &iNetworkHandle[0], 13);
|
2021-08-05 01:28:18 +02:00
|
|
|
bool is_friend = NETWORK::NETWORK_IS_HANDLE_VALID(&iNetworkHandle[0], 13) && NETWORK::NETWORK_IS_FRIEND(&iNetworkHandle[0]);
|
2021-05-26 13:17:19 +02:00
|
|
|
|
2021-08-05 01:28:18 +02:00
|
|
|
if (is_friend)
|
2021-07-23 18:06:33 +02:00
|
|
|
{
|
|
|
|
g.players[i].is_friend = true;
|
|
|
|
|
|
|
|
friend_count++;
|
|
|
|
}
|
|
|
|
else player_count++;
|
2021-05-26 13:17:19 +02:00
|
|
|
|
|
|
|
strcpy(g.players[i].name, PLAYER::GET_PLAYER_NAME(i));
|
2021-07-26 21:23:27 +02:00
|
|
|
|
|
|
|
g.players[i].net_player = g_pointers->m_get_net_game_player(i);
|
|
|
|
|
|
|
|
notify::player_joined(g.players[i]);
|
2021-05-26 13:17:19 +02:00
|
|
|
}
|
2021-07-26 21:23:27 +02:00
|
|
|
else if (g.players[i].is_online)
|
2021-05-26 13:17:19 +02:00
|
|
|
{
|
2021-07-26 21:23:27 +02:00
|
|
|
if (g.players[i].is_friend) friend_count--;
|
|
|
|
else player_count--;
|
|
|
|
|
2021-05-26 13:17:19 +02:00
|
|
|
g.players[i].is_friend = false;
|
2021-07-26 21:23:27 +02:00
|
|
|
g.players[i].is_online = false;
|
2021-05-26 13:17:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
script::get_current()->yield();
|
|
|
|
}
|
|
|
|
|
2021-07-23 18:06:33 +02:00
|
|
|
g.friend_count = friend_count;
|
|
|
|
g.player_count = player_count;
|
|
|
|
|
2021-05-26 13:17:19 +02:00
|
|
|
busy = false;
|
|
|
|
}
|
|
|
|
}
|