Revert "shared_ptr -> std::shared_ptr"

This reverts commit 7074f35e4b.
This commit is contained in:
void_17
2026-03-02 17:37:16 +07:00
parent 8a2a62ea1d
commit 119bff3514
1373 changed files with 12049 additions and 12049 deletions

View File

@@ -54,7 +54,7 @@ PlayerList::PlayerList(MinecraftServer *server)
maxPlayers = server->settings->getInt(L"max-players", 20);
doWhiteList = false;
InitializeCriticalSection(&m_kickPlayersCS);
InitializeCriticalSection(&m_closePlayersCS);
}
@@ -72,7 +72,7 @@ PlayerList::~PlayerList()
DeleteCriticalSection(&m_closePlayersCS);
}
void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPlayer> player, std::shared_ptr<LoginPacket> packet)
void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer> player, shared_ptr<LoginPacket> packet)
{
bool newPlayer = load(player);
player->setLevel(server->getLevel(player->dimension));
@@ -82,7 +82,7 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPl
INetworkPlayer *networkPlayer = connection->getSocket()->getPlayer();
if(networkPlayer != NULL && networkPlayer->IsHost())
{
player->enableAllPlayerPrivileges(true);
player->enableAllPlayerPrivileges(true);
player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_HOST,1);
}
@@ -127,8 +127,8 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPl
player->setCustomCape( packet->m_playerCapeId );
// 4J-JEV: Moved this here so we can send player-model texture and geometry data.
std::shared_ptr<PlayerConnection> playerConnection = std::shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player));
//player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use std::shared_ptr
shared_ptr<PlayerConnection> playerConnection = shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player));
//player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use shared_ptr
if(newPlayer)
{
@@ -143,7 +143,7 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPl
int centreZC = 0;
#endif
// 4J Added - Give every player a map the first time they join a server
player->inventory->setItem( 9, std::shared_ptr<ItemInstance>( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) );
player->inventory->setItem( 9, shared_ptr<ItemInstance>( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) );
if(app.getGameRuleDefinitions() != NULL)
{
app.getGameRuleDefinitions()->postProcessPlayer(player);
@@ -157,11 +157,11 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPl
#ifndef _CONTENT_PACKAGE
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl.c_str(), player->name.c_str());
#endif
playerConnection->send(std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) );
playerConnection->send(shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) );
}
}
else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl))
{
{
// Update the ref count on the memory texture data
app.AddMemoryTextureFile(player->customTextureUrl,NULL,0);
}
@@ -173,11 +173,11 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPl
#ifndef _CONTENT_PACKAGE
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str());
#endif
playerConnection->send(std::shared_ptr<TexturePacket>( new TexturePacket(player->customTextureUrl2,NULL,0) ) );
playerConnection->send(shared_ptr<TexturePacket>( new TexturePacket(player->customTextureUrl2,NULL,0) ) );
}
}
else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2))
{
{
// Update the ref count on the memory texture data
app.AddMemoryTextureFile(player->customTextureUrl2,NULL,0);
}
@@ -196,8 +196,8 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPl
player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,player->gameMode->getGameModeForPlayer()->getId() );
}
//std::shared_ptr<PlayerConnection> playerConnection = std::shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player));
player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use std::shared_ptr
//shared_ptr<PlayerConnection> playerConnection = shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player));
player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use shared_ptr
// 4J Added to store UGC settings
playerConnection->m_friendsOnlyUGC = packet->m_friendsOnlyUGC;
@@ -209,19 +209,19 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPl
addPlayerToReceiving( player );
playerConnection->send( std::shared_ptr<LoginPacket>( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(),
playerConnection->send( shared_ptr<LoginPacket>( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(),
(byte) level->dimension->id, (byte) level->getMaxBuildHeight(), (byte) getMaxPlayers(),
level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), (BYTE)playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(),
level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) );
playerConnection->send( std::shared_ptr<SetSpawnPositionPacket>( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) );
playerConnection->send( std::shared_ptr<PlayerAbilitiesPacket>( new PlayerAbilitiesPacket(&player->abilities)) );
playerConnection->send( shared_ptr<SetSpawnPositionPacket>( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) );
playerConnection->send( shared_ptr<PlayerAbilitiesPacket>( new PlayerAbilitiesPacket(&player->abilities)) );
delete spawnPos;
sendLevelInfo(player, level);
// 4J-PB - removed, since it needs to be localised in the language the client is in
//server->players->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(L"<22>e" + playerEntity->name + L" joined the game.") ) );
broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) );
//server->players->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(L"<22>e" + playerEntity->name + L" joined the game.") ) );
broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) );
MemSect(14);
add(player);
@@ -231,13 +231,13 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPl
playerConnection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
server->getConnection()->addPlayerConnection(playerConnection);
playerConnection->send( std::shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
playerConnection->send( shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
AUTO_VAR(activeEffects, player->getActiveEffects());
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it)
{
MobEffectInstance *effect = *it;
playerConnection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
playerConnection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
}
player->initMenu();
@@ -249,7 +249,7 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPl
{
for(AUTO_VAR(it, players.begin()); it != players.end(); ++it)
{
std::shared_ptr<ServerPlayer> servPlayer = *it;
shared_ptr<ServerPlayer> servPlayer = *it;
INetworkPlayer *checkPlayer = servPlayer->connection->getNetworkPlayer();
if(thisPlayer != checkPlayer && checkPlayer != NULL && thisPlayer->IsSameSystem( checkPlayer ) && servPlayer->wonGame )
{
@@ -265,7 +265,7 @@ void PlayerList::setLevel(ServerLevelArray levels)
playerIo = levels[0]->getLevelStorage()->getPlayerIO();
}
void PlayerList::changeDimension(std::shared_ptr<ServerPlayer> player, ServerLevel *from)
void PlayerList::changeDimension(shared_ptr<ServerPlayer> player, ServerLevel *from)
{
ServerLevel *to = player->getLevel();
@@ -281,12 +281,12 @@ int PlayerList::getMaxRange()
}
// 4J Changed return val to bool to check if new player or loaded player
bool PlayerList::load(std::shared_ptr<ServerPlayer> player)
bool PlayerList::load(shared_ptr<ServerPlayer> player)
{
return playerIo->load(player);
}
void PlayerList::save(std::shared_ptr<ServerPlayer> player)
void PlayerList::save(shared_ptr<ServerPlayer> player)
{
playerIo->save(player);
}
@@ -295,7 +295,7 @@ void PlayerList::save(std::shared_ptr<ServerPlayer> player)
// Add this function to take some of the code from the PlayerList::add function with the fixes
// for checking spawn area, especially in the nether. These needed to be done in a different order from before
// Fix for #13150 - When a player loads/joins a game after saving/leaving in the nether, sometimes they are spawned on top of the nether and cannot mine down
void PlayerList::validatePlayerSpawnPosition(std::shared_ptr<ServerPlayer> player)
void PlayerList::validatePlayerSpawnPosition(shared_ptr<ServerPlayer> player)
{
// 4J Stu - Some adjustments to make sure the current players position is correct
// Make sure that the player is on the ground, and in the centre x/z of the current column
@@ -354,17 +354,17 @@ void PlayerList::validatePlayerSpawnPosition(std::shared_ptr<ServerPlayer> playe
{
player->setPos(player->x, player->y + 1, player->z);
}
app.DebugPrintf("Updated pos is %f, %f, %f in dimension %d\n", player->x, player->y, player->z, player->dimension);
}
}
void PlayerList::add(std::shared_ptr<ServerPlayer> player)
void PlayerList::add(shared_ptr<ServerPlayer> player)
{
//broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, true, 1000) ) );
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, true, 1000) ) );
if( player->connection->getNetworkPlayer() )
{
broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( player ) ) );
broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( player ) ) );
}
players.push_back(player);
@@ -380,42 +380,42 @@ void PlayerList::add(std::shared_ptr<ServerPlayer> player)
// Some code from here has been moved to the above validatePlayerSpawnPosition function
// 4J Stu - Swapped these lines about so that we get the chunk visiblity packet way ahead of all the add tracked entity packets
// Fix for #9169 - ART : Sign text is replaced with the words <20>Awaiting approval<61>.
// Fix for #9169 - ART : Sign text is replaced with the words <20>Awaiting approval<61>.
changeDimension(player, NULL);
level->addEntity(player);
for (int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> op = players.at(i);
//player->connection->send(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
shared_ptr<ServerPlayer> op = players.at(i);
//player->connection->send(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
if( op->connection->getNetworkPlayer() )
{
player->connection->send(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
player->connection->send(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
}
}
if(level->isAtLeastOnePlayerSleeping())
{
std::shared_ptr<ServerPlayer> firstSleepingPlayer = nullptr;
shared_ptr<ServerPlayer> firstSleepingPlayer = nullptr;
for (unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> thisPlayer = players[i];
shared_ptr<ServerPlayer> thisPlayer = players[i];
if(thisPlayer->isSleeping())
{
if(firstSleepingPlayer == NULL) firstSleepingPlayer = thisPlayer;
thisPlayer->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep)));
if(firstSleepingPlayer == NULL) firstSleepingPlayer = thisPlayer;
thisPlayer->connection->send(shared_ptr<ChatPacket>( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep)));
}
}
player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep)));
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep)));
}
}
void PlayerList::move(std::shared_ptr<ServerPlayer> player)
void PlayerList::move(shared_ptr<ServerPlayer> player)
{
player->getLevel()->getChunkMap()->move(player);
}
void PlayerList::remove(std::shared_ptr<ServerPlayer> player)
void PlayerList::remove(shared_ptr<ServerPlayer> player)
{
save(player);
//4J Stu - We don't want to save the map data for guests, so when we are sure that the player is gone delete the map
@@ -428,7 +428,7 @@ void PlayerList::remove(std::shared_ptr<ServerPlayer> player)
{
players.erase(it);
}
//broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, false, 9999) ) );
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, false, 9999) ) );
removePlayerFromReceiving(player);
player->connection = nullptr; // Must remove reference to connection, or else there is a circular dependency
@@ -439,15 +439,15 @@ void PlayerList::remove(std::shared_ptr<ServerPlayer> player)
saveAll(NULL,false);
}
std::shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid)
shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid)
{
if (players.size() >= maxPlayers)
{
pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull);
return std::shared_ptr<ServerPlayer>();
return shared_ptr<ServerPlayer>();
}
std::shared_ptr<ServerPlayer> player = std::shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) ));
shared_ptr<ServerPlayer> player = shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) ));
player->gameMode->player = player; // 4J added as had to remove this assignment from ServerPlayer ctor
player->setXuid( xuid ); // 4J Added
player->setOnlineXuid( onlineXuid ); // 4J Added
@@ -469,9 +469,9 @@ std::shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *p
return player;
}
std::shared_ptr<ServerPlayer> PlayerList::respawn(std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData)
shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData)
{
// How we handle the entity tracker depends on whether we are the primary player currently, and whether there will be any player in the same system in the same dimension once we finish respawning.
// How we handle the entity tracker depends on whether we are the primary player currently, and whether there will be any player in the same system in the same dimension once we finish respawning.
bool isPrimary = canReceiveAllPackets(serverPlayer); // Is this the primary player in its current dimension?
int oldDimension = serverPlayer->dimension;
bool isEmptying = ( targetDimension != oldDimension); // We're not emptying this dimension on this machine if this player is going back into the same dimension
@@ -483,7 +483,7 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(std::shared_ptr<ServerPlayer>
for( unsigned int i = 0; i < players.size(); i++ )
{
std::shared_ptr<ServerPlayer> ep = players[i];
shared_ptr<ServerPlayer> ep = players[i];
if( ep == serverPlayer ) continue;
if( ep->dimension != oldDimension ) continue;
@@ -539,8 +539,8 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(std::shared_ptr<ServerPlayer>
PlayerUID playerXuid = serverPlayer->getXuid();
PlayerUID playerOnlineXuid = serverPlayer->getOnlineXuid();
std::shared_ptr<ServerPlayer> player = std::shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(serverPlayer->dimension), serverPlayer->name, new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension))));
shared_ptr<ServerPlayer> player = shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(serverPlayer->dimension), serverPlayer->name, new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension))));
player->restoreFrom(serverPlayer, keepAllPlayerData);
if (keepAllPlayerData)
{
@@ -598,7 +598,7 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(std::shared_ptr<ServerPlayer>
}
else
{
player->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) );
player->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) );
}
delete bedPosition;
}
@@ -611,7 +611,7 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(std::shared_ptr<ServerPlayer>
player->setPos(player->x, player->y + 1, player->z);
}
player->connection->send( std::shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, player->level->getSeed(), player->level->getMaxBuildHeight(),
player->connection->send( shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, player->level->getSeed(), player->level->getMaxBuildHeight(),
player->gameMode->getGameModeForPlayer(), level->difficulty, level->getLevelData()->getGenerator(),
player->level->useNewSeaLevel(), player->entityId, level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale()) ) );
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
@@ -623,7 +623,7 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(std::shared_ptr<ServerPlayer>
{
MobEffectInstance *effect = *it;
player->connection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
player->connection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
}
delete activeEffects;
player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID);
@@ -639,7 +639,7 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(std::shared_ptr<ServerPlayer>
// 4J-JEV - Dying before this point in the tutorial is pretty annoying,
// making sure to remove health/hunger and give you back your meat.
if( Minecraft::GetInstance()->isTutorial()
if( Minecraft::GetInstance()->isTutorial()
&& (!Minecraft::GetInstance()->gameMode->getTutorial()->isStateCompleted(e_Tutorial_State_Food_Bar)) )
{
app.getGameRuleDefinitions()->postProcessPlayer(player);
@@ -654,10 +654,10 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(std::shared_ptr<ServerPlayer>
}
void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player, int targetDimension)
void PlayerList::toggleDimension(shared_ptr<ServerPlayer> player, int targetDimension)
{
int lastDimension = player->dimension;
// How we handle the entity tracker depends on whether we are the primary player currently, and whether there will be any player in the same system in the same dimension once we finish respawning.
// How we handle the entity tracker depends on whether we are the primary player currently, and whether there will be any player in the same system in the same dimension once we finish respawning.
bool isPrimary = canReceiveAllPackets(player); // Is this the primary player in its current dimension?
bool isEmptying = true;
@@ -666,7 +666,7 @@ void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player, int targe
for( unsigned int i = 0; i < players.size(); i++ )
{
std::shared_ptr<ServerPlayer> ep = players[i];
shared_ptr<ServerPlayer> ep = players[i];
if( ep == player ) continue;
if( ep->dimension != lastDimension ) continue;
@@ -728,7 +728,7 @@ void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player, int targe
// 4J Stu Added so that we remove entities from the correct level, after the respawn packet we will be in the wrong level
player->flushEntitiesToRemove();
player->connection->send( std::shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, newLevel->getSeed(), newLevel->getMaxBuildHeight(),
player->connection->send( shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, newLevel->getSeed(), newLevel->getMaxBuildHeight(),
player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(),
newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale()) ) );
@@ -772,7 +772,7 @@ void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player, int targe
oldLevel->tick(player, false);
}
}
removePlayerFromReceiving(player, false, lastDimension);
addPlayerToReceiving(player);
@@ -807,7 +807,7 @@ void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player, int targe
// Force sending of the current chunk
player->doTick(true, true, true);
}
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
// 4J Stu - Fix for #64683 - Customer Encountered: TU7: Content: Gameplay: Potion effects are removed after using the Nether Portal
@@ -816,7 +816,7 @@ void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player, int targe
{
MobEffectInstance *effect = *it;
player->connection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
player->connection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
}
delete activeEffects;
player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID);
@@ -833,13 +833,13 @@ void PlayerList::tick()
sendAllPlayerInfoIn = 0;
}
if (sendAllPlayerInfoIn < players.size())
if (sendAllPlayerInfoIn < players.size())
{
std::shared_ptr<ServerPlayer> op = players[sendAllPlayerInfoIn];
//broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
shared_ptr<ServerPlayer> op = players[sendAllPlayerInfoIn];
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
if( op->connection->getNetworkPlayer() )
{
broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
}
}
@@ -849,11 +849,11 @@ void PlayerList::tick()
BYTE smallId = m_smallIdsToClose.front();
m_smallIdsToClose.pop_front();
std::shared_ptr<ServerPlayer> player = nullptr;
shared_ptr<ServerPlayer> player = nullptr;
for(unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> p = players.at(i);
shared_ptr<ServerPlayer> p = players.at(i);
// 4J Stu - May be being a bit overprotective with all the NULL checks, but adding late in TU7 so want to be safe
if (p != NULL && p->connection != NULL && p->connection->connection != NULL && p->connection->connection->getSocket() != NULL && p->connection->connection->getSocket()->getSmallId() == smallId )
{
@@ -882,11 +882,11 @@ void PlayerList::tick()
//#ifdef _XBOX
PlayerUID xuid = selectedPlayer->GetUID();
// Kick this player from the game
std::shared_ptr<ServerPlayer> player = nullptr;
shared_ptr<ServerPlayer> player = nullptr;
for(unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> p = players.at(i);
shared_ptr<ServerPlayer> p = players.at(i);
PlayerUID playersXuid = p->getOnlineXuid();
if (p != NULL && ProfileManager.AreXUIDSEqual(playersXuid, xuid ) )
{
@@ -901,7 +901,7 @@ void PlayerList::tick()
// 4J Stu - If we have kicked a player, make sure that they have no privileges if they later try to join the world when trust players is off
player->enableAllPlayerPrivileges( false );
player->connection->setWasKicked();
player->connection->send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) ));
player->connection->send( shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) ));
}
//#endif
}
@@ -914,10 +914,10 @@ void PlayerList::tick()
{
for(unsigned int i = 0; i < receiveAllPlayers[dim].size(); ++i)
{
std::shared_ptr<ServerPlayer> currentPlayer = receiveAllPlayers[dim][i];
shared_ptr<ServerPlayer> currentPlayer = receiveAllPlayers[dim][i];
if(currentPlayer->removed)
{
std::shared_ptr<ServerPlayer> newPlayer = findAlivePlayerOnSystem(currentPlayer);
shared_ptr<ServerPlayer> newPlayer = findAlivePlayerOnSystem(currentPlayer);
if(newPlayer != NULL)
{
receiveAllPlayers[dim][i] = newPlayer;
@@ -939,20 +939,20 @@ void PlayerList::prioritiseTileChanges(int x, int y, int z, int dimension)
server->getLevel(dimension)->getChunkMap()->prioritiseTileChanges(x, y, z);
}
void PlayerList::broadcastAll(std::shared_ptr<Packet> packet)
void PlayerList::broadcastAll(shared_ptr<Packet> packet)
{
for (unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> player = players[i];
shared_ptr<ServerPlayer> player = players[i];
player->connection->send(packet);
}
}
void PlayerList::broadcastAll(std::shared_ptr<Packet> packet, int dimension)
void PlayerList::broadcastAll(shared_ptr<Packet> packet, int dimension)
{
for (unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> player = players[i];
shared_ptr<ServerPlayer> player = players[i];
if (player->dimension == dimension) player->connection->send(packet);
}
}
@@ -978,7 +978,7 @@ bool PlayerList::isOp(const wstring& name)
return false;
}
bool PlayerList::isOp(std::shared_ptr<ServerPlayer> player)
bool PlayerList::isOp(shared_ptr<ServerPlayer> player)
{
bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled);
#ifdef _DEBUG_MENUS_ENABLED
@@ -989,11 +989,11 @@ bool PlayerList::isOp(std::shared_ptr<ServerPlayer> player)
return isOp;
}
std::shared_ptr<ServerPlayer> PlayerList::getPlayer(const wstring& name)
shared_ptr<ServerPlayer> PlayerList::getPlayer(const wstring& name)
{
for (unsigned int i = 0; i < players.size(); i++)
for (unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> p = players[i];
shared_ptr<ServerPlayer> p = players[i];
if (p->name == name) // 4J - used to be case insensitive (using equalsIgnoreCase) - imagine we'll be shifting to XUIDs anyway
{
return p;
@@ -1003,11 +1003,11 @@ std::shared_ptr<ServerPlayer> PlayerList::getPlayer(const wstring& name)
}
// 4J Added
std::shared_ptr<ServerPlayer> PlayerList::getPlayer(PlayerUID uid)
shared_ptr<ServerPlayer> PlayerList::getPlayer(PlayerUID uid)
{
for (unsigned int i = 0; i < players.size(); i++)
for (unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> p = players[i];
shared_ptr<ServerPlayer> p = players[i];
if (p->getXuid() == uid || p->getOnlineXuid() == uid) // 4J - used to be case insensitive (using equalsIgnoreCase) - imagine we'll be shifting to XUIDs anyway
{
return p;
@@ -1018,23 +1018,23 @@ std::shared_ptr<ServerPlayer> PlayerList::getPlayer(PlayerUID uid)
void PlayerList::sendMessage(const wstring& name, const wstring& message)
{
std::shared_ptr<ServerPlayer> player = getPlayer(name);
shared_ptr<ServerPlayer> player = getPlayer(name);
if (player != NULL)
{
player->connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(message) ) );
player->connection->send( shared_ptr<ChatPacket>( new ChatPacket(message) ) );
}
}
void PlayerList::broadcast(double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet)
void PlayerList::broadcast(double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet)
{
broadcast(nullptr, x, y, z, range, dimension, packet);
}
void PlayerList::broadcast(std::shared_ptr<Player> except, double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet)
void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet)
{
// 4J - altered so that we don't send to the same machine more than once. Add the source player to the machines we have "sent" to as it doesn't need to go to that
// machine either
vector< std::shared_ptr<ServerPlayer> > sentTo;
vector< shared_ptr<ServerPlayer> > sentTo;
if( except != NULL )
{
sentTo.push_back(dynamic_pointer_cast<ServerPlayer>(except));
@@ -1042,7 +1042,7 @@ void PlayerList::broadcast(std::shared_ptr<Player> except, double x, double y, d
for (unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> p = players[i];
shared_ptr<ServerPlayer> p = players[i];
if (p == except) continue;
if (p->dimension != dimension) continue;
@@ -1057,9 +1057,9 @@ void PlayerList::broadcast(std::shared_ptr<Player> except, double x, double y, d
}
else
{
for(unsigned int j = 0; j < sentTo.size(); j++ )
for(unsigned int j = 0; j < sentTo.size(); j++ )
{
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
shared_ptr<ServerPlayer> player2 = sentTo[j];
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
{
@@ -1080,7 +1080,7 @@ void PlayerList::broadcast(std::shared_ptr<Player> except, double x, double y, d
if (xd * xd + yd * yd + zd * zd < range * range)
{
#if 0 // _DEBUG
std::shared_ptr<LevelSoundPacket> SoundPacket= dynamic_pointer_cast<LevelSoundPacket>(packet);
shared_ptr<LevelSoundPacket> SoundPacket= dynamic_pointer_cast<LevelSoundPacket>(packet);
if(SoundPacket)
{
@@ -1099,10 +1099,10 @@ void PlayerList::broadcast(std::shared_ptr<Player> except, double x, double y, d
void PlayerList::broadcastToAllOps(const wstring& message)
{
std::shared_ptr<Packet> chatPacket = std::shared_ptr<ChatPacket>( new ChatPacket(message) );
shared_ptr<Packet> chatPacket = shared_ptr<ChatPacket>( new ChatPacket(message) );
for (unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<ServerPlayer> p = players[i];
shared_ptr<ServerPlayer> p = players[i];
if (isOp(p->name))
{
p->connection->send(chatPacket);
@@ -1110,9 +1110,9 @@ void PlayerList::broadcastToAllOps(const wstring& message)
}
}
bool PlayerList::sendTo(const wstring& name, std::shared_ptr<Packet> packet)
bool PlayerList::sendTo(const wstring& name, shared_ptr<Packet> packet)
{
std::shared_ptr<ServerPlayer> player = getPlayer(name);
shared_ptr<ServerPlayer> player = getPlayer(name);
if (player != NULL)
{
player->connection->send(packet);
@@ -1131,7 +1131,7 @@ void PlayerList::saveAll(ProgressListener *progressListener, bool bDeleteGuestMa
for (unsigned int i = 0; i < players.size(); i++)
{
playerIo->save(players[i]);
//4J Stu - We don't want to save the map data for guests, so when we are sure that the player is gone delete the map
if(bDeleteGuestMaps && players[i]->isGuest()) playerIo->deleteMapFilesForPlayer(players[i]);
@@ -1154,28 +1154,28 @@ void PlayerList::reloadWhitelist()
{
}
void PlayerList::sendLevelInfo(std::shared_ptr<ServerPlayer> player, ServerLevel *level)
void PlayerList::sendLevelInfo(shared_ptr<ServerPlayer> player, ServerLevel *level)
{
player->connection->send( std::shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
player->connection->send( shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
if (level->isRaining())
{
player->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) );
player->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) );
}
else
{
// 4J Stu - Fix for #44836 - Customer Encountered: Out of Sync Weather [A-10]
// If it was raining when the player left the level, and is now not raining we need to make sure that state is updated
player->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) );
player->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) );
}
// send the stronghold position if there is one
// send the stronghold position if there is one
if((level->dimension->id==0) && level->getLevelData()->getHasStronghold())
{
player->connection->send( std::shared_ptr<XZPacket>( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) );
player->connection->send( shared_ptr<XZPacket>( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) );
}
}
void PlayerList::sendAllPlayerInfo(std::shared_ptr<ServerPlayer> player)
void PlayerList::sendAllPlayerInfo(shared_ptr<ServerPlayer> player)
{
player->refreshContainer(player->inventoryMenu);
player->resetSentInfo();
@@ -1218,7 +1218,7 @@ void PlayerList::setOverrideGameMode(GameType *gameMode)
this->overrideGameMode = gameMode;
}
void PlayerList::updatePlayerGameMode(std::shared_ptr<ServerPlayer> newPlayer, std::shared_ptr<ServerPlayer> oldPlayer, Level *level)
void PlayerList::updatePlayerGameMode(shared_ptr<ServerPlayer> newPlayer, shared_ptr<ServerPlayer> oldPlayer, Level *level)
{
// reset the player's game mode (first pick from old, then copy level if
@@ -1239,7 +1239,7 @@ void PlayerList::setAllowCheatsForAllPlayers(bool allowCommands)
this->allowCheatsForAllPlayers = allowCommands;
}
std::shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(std::shared_ptr<ServerPlayer> player)
shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(shared_ptr<ServerPlayer> player)
{
int dimIndex, playerDim;
dimIndex = playerDim = player->dimension;
@@ -1251,7 +1251,7 @@ std::shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(std::shared_pt
{
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
{
std::shared_ptr<ServerPlayer> newPlayer = *itP;
shared_ptr<ServerPlayer> newPlayer = *itP;
INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer();
@@ -1270,7 +1270,7 @@ std::shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(std::shared_pt
return nullptr;
}
void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player, bool usePlayerDimension /*= true*/, int dimension /*= 0*/)
void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool usePlayerDimension /*= true*/, int dimension /*= 0*/)
{
int dimIndex, playerDim;
dimIndex = playerDim = usePlayerDimension ? player->dimension : dimension;
@@ -1297,7 +1297,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
{
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
{
std::shared_ptr<ServerPlayer> newPlayer = *itP;
shared_ptr<ServerPlayer> newPlayer = *itP;
INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer();
@@ -1324,7 +1324,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
// Re-check all active players and make sure they have someone on their system to receive all packets
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
{
std::shared_ptr<ServerPlayer> newPlayer = *itP;
shared_ptr<ServerPlayer> newPlayer = *itP;
INetworkPlayer *checkingPlayer = newPlayer->connection->getNetworkPlayer();
if( checkingPlayer != NULL )
@@ -1335,7 +1335,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
bool foundPrimary = false;
for(AUTO_VAR(it, receiveAllPlayers[newPlayerDim].begin()); it != receiveAllPlayers[newPlayerDim].end(); ++it)
{
std::shared_ptr<ServerPlayer> primaryPlayer = *it;
shared_ptr<ServerPlayer> primaryPlayer = *it;
INetworkPlayer *primPlayer = primaryPlayer->connection->getNetworkPlayer();
if(primPlayer != NULL && checkingPlayer->IsSameSystem( primPlayer ) )
{
@@ -1355,7 +1355,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
}
}
void PlayerList::addPlayerToReceiving(std::shared_ptr<ServerPlayer> player)
void PlayerList::addPlayerToReceiving(shared_ptr<ServerPlayer> player)
{
int playerDim = 0;
if( player->dimension == -1 ) playerDim = 1;
@@ -1380,16 +1380,16 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr<ServerPlayer> player)
{
for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it)
{
std::shared_ptr<ServerPlayer> oldPlayer = *it;
shared_ptr<ServerPlayer> oldPlayer = *it;
INetworkPlayer *checkingPlayer = oldPlayer->connection->getNetworkPlayer();
if(checkingPlayer != NULL && checkingPlayer->IsSameSystem( thisPlayer ) )
if(checkingPlayer != NULL && checkingPlayer->IsSameSystem( thisPlayer ) )
{
shouldAddPlayer = false;
break;
}
}
}
if( shouldAddPlayer )
{
#ifndef _CONTENT_PACKAGE
@@ -1399,14 +1399,14 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr<ServerPlayer> player)
}
}
bool PlayerList::canReceiveAllPackets(std::shared_ptr<ServerPlayer> player)
bool PlayerList::canReceiveAllPackets(shared_ptr<ServerPlayer> player)
{
int playerDim = 0;
if( player->dimension == -1 ) playerDim = 1;
else if( player->dimension == 1) playerDim = 2;
for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it)
{
std::shared_ptr<ServerPlayer> newPlayer = *it;
shared_ptr<ServerPlayer> newPlayer = *it;
if(newPlayer == player)
{
return true;