mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Environment cleanup
* Move client list to ServerEnvironment and use RemotePlayer members instead of Player * ClientEnvironment only use setLocalPlayer to specify the current player * Remove ClientEnvironment dead code on player list (in fact other players are CAO not Player objects) * Drop LocalPlayer::getPlayer(xxx) functions which aren't used. * Improve a little bit performance by using const ref list for ClientEnvironment::getPlayerNames() & Client::getConnectedPlayerNames() * Drop isLocal() function from (Local)Player which is not needed anymore because of previous changes This change permits to cleanup shared client list which is very old code. ClientEnvironment doesn't use player list anymore, it only contains the local player, as addPlayer is only called from Client constructor client side. Clients are only CAO on client side, this cleanup permit to remove confusion about player list.
This commit is contained in:
parent
b3fc133442
commit
70f104be07
8 changed files with 97 additions and 162 deletions
|
@ -257,7 +257,7 @@ Client::Client(
|
|||
m_localdb(NULL)
|
||||
{
|
||||
// Add local player
|
||||
m_env.addPlayer(new LocalPlayer(this, playername));
|
||||
m_env.setLocalPlayer(new LocalPlayer(this, playername));
|
||||
|
||||
m_mapper = new Mapper(device, this);
|
||||
m_cache_save_interval = g_settings->getU16("server_map_save_interval");
|
||||
|
@ -1418,8 +1418,9 @@ Inventory* Client::getInventory(const InventoryLocation &loc)
|
|||
break;
|
||||
case InventoryLocation::PLAYER:
|
||||
{
|
||||
LocalPlayer *player = m_env.getPlayer(loc.name.c_str());
|
||||
if(!player)
|
||||
// Check if we are working with local player inventory
|
||||
LocalPlayer *player = m_env.getLocalPlayer();
|
||||
if (!player || strcmp(player->getName(), loc.name.c_str()) != 0)
|
||||
return NULL;
|
||||
return &player->inventory;
|
||||
}
|
||||
|
@ -1500,11 +1501,6 @@ ClientActiveObject * Client::getSelectedActiveObject(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
std::list<std::string> Client::getConnectedPlayerNames()
|
||||
{
|
||||
return m_env.getPlayerNames();
|
||||
}
|
||||
|
||||
float Client::getAnimationTime()
|
||||
{
|
||||
return m_animation_time;
|
||||
|
@ -1664,7 +1660,7 @@ void Client::addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server, bool ur
|
|||
ClientEvent Client::getClientEvent()
|
||||
{
|
||||
ClientEvent event;
|
||||
if(m_client_event_queue.size() == 0) {
|
||||
if (m_client_event_queue.empty()) {
|
||||
event.type = CE_NONE;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue