From 7074f35e4ba831e358117842b99ee35b87f85ae5 Mon Sep 17 00:00:00 2001 From: void_17 Date: Mon, 2 Mar 2026 15:58:20 +0700 Subject: shared_ptr -> std::shared_ptr This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today. --- Minecraft.Client/PlayerList.cpp | 232 ++++++++++++++++++++-------------------- 1 file changed, 116 insertions(+), 116 deletions(-) (limited to 'Minecraft.Client/PlayerList.cpp') diff --git a/Minecraft.Client/PlayerList.cpp b/Minecraft.Client/PlayerList.cpp index 7921cbf8..9beea76b 100644 --- a/Minecraft.Client/PlayerList.cpp +++ b/Minecraft.Client/PlayerList.cpp @@ -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, shared_ptr player, shared_ptr packet) +void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr player, std::shared_ptr packet) { bool newPlayer = load(player); player->setLevel(server->getLevel(player->dimension)); @@ -82,7 +82,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr 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, shared_ptr player->setCustomCape( packet->m_playerCapeId ); // 4J-JEV: Moved this here so we can send player-model texture and geometry data. - shared_ptr playerConnection = shared_ptr(new PlayerConnection(server, connection, player)); - //player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use shared_ptr + std::shared_ptr playerConnection = std::shared_ptr(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 if(newPlayer) { @@ -143,7 +143,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr int centreZC = 0; #endif // 4J Added - Give every player a map the first time they join a server - player->inventory->setItem( 9, shared_ptr( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) ); + player->inventory->setItem( 9, std::shared_ptr( 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, shared_ptr #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(shared_ptr( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) ); + playerConnection->send(std::shared_ptr( 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, shared_ptr #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(shared_ptr( new TexturePacket(player->customTextureUrl2,NULL,0) ) ); + playerConnection->send(std::shared_ptr( 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, shared_ptr player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,player->gameMode->getGameModeForPlayer()->getId() ); } - //shared_ptr playerConnection = shared_ptr(new PlayerConnection(server, connection, player)); - player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use shared_ptr + //std::shared_ptr playerConnection = std::shared_ptr(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 // 4J Added to store UGC settings playerConnection->m_friendsOnlyUGC = packet->m_friendsOnlyUGC; @@ -209,19 +209,19 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr addPlayerToReceiving( player ); - playerConnection->send( shared_ptr( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(), + playerConnection->send( std::shared_ptr( 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( shared_ptr( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) ); - playerConnection->send( shared_ptr( new PlayerAbilitiesPacket(&player->abilities)) ); + playerConnection->send( std::shared_ptr( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) ); + playerConnection->send( std::shared_ptr( 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( shared_ptr( new ChatPacket(L"§e" + playerEntity->name + L" joined the game.") ) ); - broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) ); + //server->players->broadcastAll( std::shared_ptr( new ChatPacket(L"�e" + playerEntity->name + L" joined the game.") ) ); + broadcastAll( std::shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) ); MemSect(14); add(player); @@ -231,13 +231,13 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr playerConnection->teleport(player->x, player->y, player->z, player->yRot, player->xRot); server->getConnection()->addPlayerConnection(playerConnection); - playerConnection->send( shared_ptr( new SetTimePacket(level->getTime()) ) ); + playerConnection->send( std::shared_ptr( new SetTimePacket(level->getTime()) ) ); AUTO_VAR(activeEffects, player->getActiveEffects()); for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it) { MobEffectInstance *effect = *it; - playerConnection->send(shared_ptr( new UpdateMobEffectPacket(player->entityId, effect) ) ); + playerConnection->send(std::shared_ptr( new UpdateMobEffectPacket(player->entityId, effect) ) ); } player->initMenu(); @@ -249,7 +249,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr { for(AUTO_VAR(it, players.begin()); it != players.end(); ++it) { - shared_ptr servPlayer = *it; + std::shared_ptr 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(shared_ptr player, ServerLevel *from) +void PlayerList::changeDimension(std::shared_ptr 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(shared_ptr player) +bool PlayerList::load(std::shared_ptr player) { return playerIo->load(player); } -void PlayerList::save(shared_ptr player) +void PlayerList::save(std::shared_ptr player) { playerIo->save(player); } @@ -295,7 +295,7 @@ void PlayerList::save(shared_ptr 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(shared_ptr player) +void PlayerList::validatePlayerSpawnPosition(std::shared_ptr 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(shared_ptr player) { 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(shared_ptr player) +void PlayerList::add(std::shared_ptr player) { - //broadcastAll(shared_ptr( new PlayerInfoPacket(player->name, true, 1000) ) ); + //broadcastAll(std::shared_ptr( new PlayerInfoPacket(player->name, true, 1000) ) ); if( player->connection->getNetworkPlayer() ) { - broadcastAll(shared_ptr( new PlayerInfoPacket( player ) ) ); + broadcastAll(std::shared_ptr( new PlayerInfoPacket( player ) ) ); } players.push_back(player); @@ -380,42 +380,42 @@ void PlayerList::add(shared_ptr 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 “Awaiting approval”. + // Fix for #9169 - ART : Sign text is replaced with the words �Awaiting approval�. changeDimension(player, NULL); level->addEntity(player); for (int i = 0; i < players.size(); i++) { - shared_ptr op = players.at(i); - //player->connection->send(shared_ptr( new PlayerInfoPacket(op->name, true, op->latency) ) ); + std::shared_ptr op = players.at(i); + //player->connection->send(std::shared_ptr( new PlayerInfoPacket(op->name, true, op->latency) ) ); if( op->connection->getNetworkPlayer() ) { - player->connection->send(shared_ptr( new PlayerInfoPacket( op ) ) ); + player->connection->send(std::shared_ptr( new PlayerInfoPacket( op ) ) ); } } if(level->isAtLeastOnePlayerSleeping()) { - shared_ptr firstSleepingPlayer = nullptr; + std::shared_ptr firstSleepingPlayer = nullptr; for (unsigned int i = 0; i < players.size(); i++) { - shared_ptr thisPlayer = players[i]; + std::shared_ptr thisPlayer = players[i]; if(thisPlayer->isSleeping()) { - if(firstSleepingPlayer == NULL) firstSleepingPlayer = thisPlayer; - thisPlayer->connection->send(shared_ptr( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep))); + if(firstSleepingPlayer == NULL) firstSleepingPlayer = thisPlayer; + thisPlayer->connection->send(std::shared_ptr( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep))); } } - player->connection->send(shared_ptr( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep))); + player->connection->send(std::shared_ptr( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep))); } } -void PlayerList::move(shared_ptr player) +void PlayerList::move(std::shared_ptr player) { player->getLevel()->getChunkMap()->move(player); } -void PlayerList::remove(shared_ptr player) +void PlayerList::remove(std::shared_ptr 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(shared_ptr player) { players.erase(it); } - //broadcastAll(shared_ptr( new PlayerInfoPacket(player->name, false, 9999) ) ); + //broadcastAll(std::shared_ptr( 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(shared_ptr player) saveAll(NULL,false); } -shared_ptr PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid) +std::shared_ptr PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid) { if (players.size() >= maxPlayers) { pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull); - return shared_ptr(); + return std::shared_ptr(); } - - shared_ptr player = shared_ptr(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) )); + + std::shared_ptr player = std::shared_ptr(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 @@ shared_ptr PlayerList::getPlayerForLogin(PendingConnection *pendin return player; } -shared_ptr PlayerList::respawn(shared_ptr serverPlayer, int targetDimension, bool keepAllPlayerData) +std::shared_ptr PlayerList::respawn(std::shared_ptr 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 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay for( unsigned int i = 0; i < players.size(); i++ ) { - shared_ptr ep = players[i]; + std::shared_ptr ep = players[i]; if( ep == serverPlayer ) continue; if( ep->dimension != oldDimension ) continue; @@ -539,8 +539,8 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay PlayerUID playerXuid = serverPlayer->getXuid(); PlayerUID playerOnlineXuid = serverPlayer->getOnlineXuid(); - - shared_ptr player = shared_ptr(new ServerPlayer(server, server->getLevel(serverPlayer->dimension), serverPlayer->name, new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension)))); + + std::shared_ptr player = std::shared_ptr(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 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay } else { - player->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) ); + player->connection->send( std::shared_ptr( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) ); } delete bedPosition; } @@ -611,7 +611,7 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay player->setPos(player->x, player->y + 1, player->z); } - player->connection->send( shared_ptr( new RespawnPacket((char) player->dimension, player->level->getSeed(), player->level->getMaxBuildHeight(), + player->connection->send( std::shared_ptr( 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 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay { MobEffectInstance *effect = *it; - player->connection->send(shared_ptr( new UpdateMobEffectPacket(player->entityId, effect) ) ); + player->connection->send(std::shared_ptr( new UpdateMobEffectPacket(player->entityId, effect) ) ); } delete activeEffects; player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID); @@ -639,7 +639,7 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay // 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 @@ shared_ptr PlayerList::respawn(shared_ptr serverPlay } -void PlayerList::toggleDimension(shared_ptr player, int targetDimension) +void PlayerList::toggleDimension(std::shared_ptr 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(shared_ptr player, int targetDime for( unsigned int i = 0; i < players.size(); i++ ) { - shared_ptr ep = players[i]; + std::shared_ptr ep = players[i]; if( ep == player ) continue; if( ep->dimension != lastDimension ) continue; @@ -728,7 +728,7 @@ void PlayerList::toggleDimension(shared_ptr player, int targetDime // 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( shared_ptr( new RespawnPacket((char) player->dimension, newLevel->getSeed(), newLevel->getMaxBuildHeight(), + player->connection->send( std::shared_ptr( 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(shared_ptr player, int targetDime oldLevel->tick(player, false); } } - + removePlayerFromReceiving(player, false, lastDimension); addPlayerToReceiving(player); @@ -807,7 +807,7 @@ void PlayerList::toggleDimension(shared_ptr player, int targetDime // 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(shared_ptr player, int targetDime { MobEffectInstance *effect = *it; - player->connection->send(shared_ptr( new UpdateMobEffectPacket(player->entityId, effect) ) ); + player->connection->send(std::shared_ptr( 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()) { - shared_ptr op = players[sendAllPlayerInfoIn]; - //broadcastAll(shared_ptr( new PlayerInfoPacket(op->name, true, op->latency) ) ); + std::shared_ptr op = players[sendAllPlayerInfoIn]; + //broadcastAll(std::shared_ptr( new PlayerInfoPacket(op->name, true, op->latency) ) ); if( op->connection->getNetworkPlayer() ) { - broadcastAll(shared_ptr( new PlayerInfoPacket( op ) ) ); + broadcastAll(std::shared_ptr( new PlayerInfoPacket( op ) ) ); } } @@ -849,11 +849,11 @@ void PlayerList::tick() BYTE smallId = m_smallIdsToClose.front(); m_smallIdsToClose.pop_front(); - shared_ptr player = nullptr; + std::shared_ptr player = nullptr; for(unsigned int i = 0; i < players.size(); i++) { - shared_ptr p = players.at(i); + std::shared_ptr 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 - shared_ptr player = nullptr; + std::shared_ptr player = nullptr; for(unsigned int i = 0; i < players.size(); i++) { - shared_ptr p = players.at(i); + std::shared_ptr 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( shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) )); + player->connection->send( std::shared_ptr( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) )); } //#endif } @@ -914,10 +914,10 @@ void PlayerList::tick() { for(unsigned int i = 0; i < receiveAllPlayers[dim].size(); ++i) { - shared_ptr currentPlayer = receiveAllPlayers[dim][i]; + std::shared_ptr currentPlayer = receiveAllPlayers[dim][i]; if(currentPlayer->removed) { - shared_ptr newPlayer = findAlivePlayerOnSystem(currentPlayer); + std::shared_ptr 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(shared_ptr packet) +void PlayerList::broadcastAll(std::shared_ptr packet) { for (unsigned int i = 0; i < players.size(); i++) { - shared_ptr player = players[i]; + std::shared_ptr player = players[i]; player->connection->send(packet); } } -void PlayerList::broadcastAll(shared_ptr packet, int dimension) +void PlayerList::broadcastAll(std::shared_ptr packet, int dimension) { for (unsigned int i = 0; i < players.size(); i++) { - shared_ptr player = players[i]; + std::shared_ptr 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(shared_ptr player) +bool PlayerList::isOp(std::shared_ptr player) { bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled); #ifdef _DEBUG_MENUS_ENABLED @@ -989,11 +989,11 @@ bool PlayerList::isOp(shared_ptr player) return isOp; } -shared_ptr PlayerList::getPlayer(const wstring& name) +std::shared_ptr PlayerList::getPlayer(const wstring& name) { - for (unsigned int i = 0; i < players.size(); i++) + for (unsigned int i = 0; i < players.size(); i++) { - shared_ptr p = players[i]; + std::shared_ptr 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 @@ shared_ptr PlayerList::getPlayer(const wstring& name) } // 4J Added -shared_ptr PlayerList::getPlayer(PlayerUID uid) +std::shared_ptr PlayerList::getPlayer(PlayerUID uid) { - for (unsigned int i = 0; i < players.size(); i++) + for (unsigned int i = 0; i < players.size(); i++) { - shared_ptr p = players[i]; + std::shared_ptr 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 @@ shared_ptr PlayerList::getPlayer(PlayerUID uid) void PlayerList::sendMessage(const wstring& name, const wstring& message) { - shared_ptr player = getPlayer(name); + std::shared_ptr player = getPlayer(name); if (player != NULL) { - player->connection->send( shared_ptr( new ChatPacket(message) ) ); + player->connection->send( std::shared_ptr( new ChatPacket(message) ) ); } } -void PlayerList::broadcast(double x, double y, double z, double range, int dimension, shared_ptr packet) +void PlayerList::broadcast(double x, double y, double z, double range, int dimension, std::shared_ptr packet) { broadcast(nullptr, x, y, z, range, dimension, packet); } -void PlayerList::broadcast(shared_ptr except, double x, double y, double z, double range, int dimension, shared_ptr packet) +void PlayerList::broadcast(std::shared_ptr except, double x, double y, double z, double range, int dimension, std::shared_ptr 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< shared_ptr > sentTo; + vector< std::shared_ptr > sentTo; if( except != NULL ) { sentTo.push_back(dynamic_pointer_cast(except)); @@ -1042,7 +1042,7 @@ void PlayerList::broadcast(shared_ptr except, double x, double y, double for (unsigned int i = 0; i < players.size(); i++) { - shared_ptr p = players[i]; + std::shared_ptr p = players[i]; if (p == except) continue; if (p->dimension != dimension) continue; @@ -1057,9 +1057,9 @@ void PlayerList::broadcast(shared_ptr except, double x, double y, double } else { - for(unsigned int j = 0; j < sentTo.size(); j++ ) + for(unsigned int j = 0; j < sentTo.size(); j++ ) { - shared_ptr player2 = sentTo[j]; + std::shared_ptr player2 = sentTo[j]; INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer(); if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) { @@ -1080,7 +1080,7 @@ void PlayerList::broadcast(shared_ptr except, double x, double y, double if (xd * xd + yd * yd + zd * zd < range * range) { #if 0 // _DEBUG - shared_ptr SoundPacket= dynamic_pointer_cast(packet); + std::shared_ptr SoundPacket= dynamic_pointer_cast(packet); if(SoundPacket) { @@ -1099,10 +1099,10 @@ void PlayerList::broadcast(shared_ptr except, double x, double y, double void PlayerList::broadcastToAllOps(const wstring& message) { - shared_ptr chatPacket = shared_ptr( new ChatPacket(message) ); + std::shared_ptr chatPacket = std::shared_ptr( new ChatPacket(message) ); for (unsigned int i = 0; i < players.size(); i++) { - shared_ptr p = players[i]; + std::shared_ptr 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, shared_ptr packet) +bool PlayerList::sendTo(const wstring& name, std::shared_ptr packet) { - shared_ptr player = getPlayer(name); + std::shared_ptr 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(shared_ptr player, ServerLevel *level) +void PlayerList::sendLevelInfo(std::shared_ptr player, ServerLevel *level) { - player->connection->send( shared_ptr( new SetTimePacket(level->getTime()) ) ); + player->connection->send( std::shared_ptr( new SetTimePacket(level->getTime()) ) ); if (level->isRaining()) { - player->connection->send( shared_ptr( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) ); + player->connection->send( std::shared_ptr( 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( shared_ptr( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) ); + player->connection->send( std::shared_ptr( 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( shared_ptr( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) ); + player->connection->send( std::shared_ptr( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) ); } } -void PlayerList::sendAllPlayerInfo(shared_ptr player) +void PlayerList::sendAllPlayerInfo(std::shared_ptr player) { player->refreshContainer(player->inventoryMenu); player->resetSentInfo(); @@ -1218,7 +1218,7 @@ void PlayerList::setOverrideGameMode(GameType *gameMode) this->overrideGameMode = gameMode; } -void PlayerList::updatePlayerGameMode(shared_ptr newPlayer, shared_ptr oldPlayer, Level *level) +void PlayerList::updatePlayerGameMode(std::shared_ptr newPlayer, std::shared_ptr 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; } -shared_ptr PlayerList::findAlivePlayerOnSystem(shared_ptr player) +std::shared_ptr PlayerList::findAlivePlayerOnSystem(std::shared_ptr player) { int dimIndex, playerDim; dimIndex = playerDim = player->dimension; @@ -1251,7 +1251,7 @@ shared_ptr PlayerList::findAlivePlayerOnSystem(shared_ptr newPlayer = *itP; + std::shared_ptr newPlayer = *itP; INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer(); @@ -1270,7 +1270,7 @@ shared_ptr PlayerList::findAlivePlayerOnSystem(shared_ptr player, bool usePlayerDimension /*= true*/, int dimension /*= 0*/) +void PlayerList::removePlayerFromReceiving(std::shared_ptr player, bool usePlayerDimension /*= true*/, int dimension /*= 0*/) { int dimIndex, playerDim; dimIndex = playerDim = usePlayerDimension ? player->dimension : dimension; @@ -1297,7 +1297,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr player, bool { for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP) { - shared_ptr newPlayer = *itP; + std::shared_ptr newPlayer = *itP; INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer(); @@ -1324,7 +1324,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr player, bool // 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) { - shared_ptr newPlayer = *itP; + std::shared_ptr newPlayer = *itP; INetworkPlayer *checkingPlayer = newPlayer->connection->getNetworkPlayer(); if( checkingPlayer != NULL ) @@ -1335,7 +1335,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr player, bool bool foundPrimary = false; for(AUTO_VAR(it, receiveAllPlayers[newPlayerDim].begin()); it != receiveAllPlayers[newPlayerDim].end(); ++it) { - shared_ptr primaryPlayer = *it; + std::shared_ptr primaryPlayer = *it; INetworkPlayer *primPlayer = primaryPlayer->connection->getNetworkPlayer(); if(primPlayer != NULL && checkingPlayer->IsSameSystem( primPlayer ) ) { @@ -1355,7 +1355,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr player, bool } } -void PlayerList::addPlayerToReceiving(shared_ptr player) +void PlayerList::addPlayerToReceiving(std::shared_ptr player) { int playerDim = 0; if( player->dimension == -1 ) playerDim = 1; @@ -1380,16 +1380,16 @@ void PlayerList::addPlayerToReceiving(shared_ptr player) { for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it) { - shared_ptr oldPlayer = *it; + std::shared_ptr 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(shared_ptr player) } } -bool PlayerList::canReceiveAllPackets(shared_ptr player) +bool PlayerList::canReceiveAllPackets(std::shared_ptr 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) { - shared_ptr newPlayer = *it; + std::shared_ptr newPlayer = *it; if(newPlayer == player) { return true; -- cgit v1.2.3