2021-02-07 01:13:23 +01:00
|
|
|
#include "features/functions.hpp"
|
2021-02-05 02:38:56 +01:00
|
|
|
#include "features/sys.hpp"
|
2020-12-31 20:53:04 +01:00
|
|
|
#include <algorithm>
|
2021-02-05 02:38:56 +01:00
|
|
|
#include "fiber_pool.hpp"
|
|
|
|
#include "script.hpp"
|
2020-12-31 11:06:36 +01:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2021-02-05 02:38:56 +01:00
|
|
|
void sys::update_player_structs()
|
2020-12-31 11:06:36 +01:00
|
|
|
{
|
2021-02-05 02:38:56 +01:00
|
|
|
player players[32];
|
2020-12-31 20:53:04 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
for (uint8_t i = 0; i < 32; i++)
|
2020-12-31 11:06:36 +01:00
|
|
|
{
|
2021-02-05 02:38:56 +01:00
|
|
|
if (NETWORK::NETWORK_IS_PLAYER_CONNECTED(i))
|
2020-12-31 11:06:36 +01:00
|
|
|
{
|
2021-02-07 01:13:23 +01:00
|
|
|
bool exists = g_players.find(i) != g_players.end();
|
|
|
|
if (!exists || (exists && !g_players.at(i).is_online)) func::join_message((Player)i);
|
2020-12-31 11:06:36 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
players[i].id = i;
|
|
|
|
players[i].is_online = true;
|
2020-12-31 11:06:36 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
int iNetworkHandle[26];
|
|
|
|
NETWORK::NETWORK_HANDLE_FROM_PLAYER(i, &iNetworkHandle[0], 13);
|
|
|
|
NETWORK::NETWORK_IS_HANDLE_VALID(&iNetworkHandle[0], 13) && NETWORK::NETWORK_IS_FRIEND(&iNetworkHandle[0]);
|
2020-12-31 11:06:36 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
players[i].is_friend = NETWORK::NETWORK_IS_HANDLE_VALID(iNetworkHandle, 13) && NETWORK::NETWORK_IS_FRIEND(iNetworkHandle);
|
2020-12-31 11:06:36 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
strcpy(players[i].name, PLAYER::GET_PLAYER_NAME(i));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
players[i].is_online = false;
|
|
|
|
players[i].is_friend = false;
|
2020-12-31 11:06:36 +01:00
|
|
|
}
|
2020-12-31 20:53:04 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
script::get_current()->yield();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::sort(std::begin(players), std::end(players));
|
|
|
|
|
2021-02-06 00:32:27 +01:00
|
|
|
g_temp.friend_count = 0;
|
|
|
|
g_temp.player_count = 0;
|
2021-02-05 02:38:56 +01:00
|
|
|
g_players.clear();
|
|
|
|
for (uint8_t i = 0; i < 32; i++)
|
|
|
|
{
|
|
|
|
player player = players[i];
|
2020-12-31 20:53:04 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
if (player.id == PLAYER::PLAYER_ID()) g_player = player;
|
2021-02-06 00:32:27 +01:00
|
|
|
else if (player.is_online)
|
|
|
|
if (player.is_friend)
|
|
|
|
g_temp.friend_count++;
|
|
|
|
else
|
|
|
|
g_temp.player_count++;
|
2020-12-31 20:53:04 +01:00
|
|
|
|
2021-02-05 02:38:56 +01:00
|
|
|
g_players.emplace(player.id, player);
|
|
|
|
}
|
2020-12-31 11:06:36 +01:00
|
|
|
}
|
2020-12-26 19:26:10 +01:00
|
|
|
}
|