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.
This commit is contained in:
@@ -91,7 +91,7 @@ void ServerLevel::staticCtor()
|
||||
|
||||
};
|
||||
|
||||
ServerLevel::ServerLevel(MinecraftServer *server, shared_ptr<LevelStorage>levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings) : Level(levelStorage, levelName, levelSettings, Dimension::getNew(dimension), false)
|
||||
ServerLevel::ServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings) : Level(levelStorage, levelName, levelSettings, Dimension::getNew(dimension), false)
|
||||
{
|
||||
InitializeCriticalSection(&m_limiterCS);
|
||||
InitializeCriticalSection(&m_tickNextTickCS);
|
||||
@@ -289,7 +289,7 @@ void ServerLevel::updateSleepingPlayerList()
|
||||
m_bAtLeastOnePlayerSleeping = false;
|
||||
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (vector<shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
||||
for (vector<std::shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
||||
{
|
||||
if (!(*it)->isSleeping())
|
||||
{
|
||||
@@ -310,7 +310,7 @@ void ServerLevel::awakenAllPlayers()
|
||||
m_bAtLeastOnePlayerSleeping = false;
|
||||
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (vector<shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
||||
for (vector<std::shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
||||
{
|
||||
if ((*it)->isSleeping())
|
||||
{
|
||||
@@ -335,7 +335,7 @@ bool ServerLevel::allPlayersAreSleeping()
|
||||
{
|
||||
// all players are sleeping, but have they slept long enough?
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (vector<shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++ )
|
||||
for (vector<std::shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++ )
|
||||
{
|
||||
// System.out.println(player->entityId + ": " + player->getSleepTimer());
|
||||
if (! (*it)->isSleepingLongEnough())
|
||||
@@ -467,7 +467,7 @@ void ServerLevel::tickTiles()
|
||||
|
||||
if (isRainingAt(x, y, z))
|
||||
{
|
||||
addGlobalEntity( shared_ptr<LightningBolt>( new LightningBolt(this, x, y, z) ) );
|
||||
addGlobalEntity( std::shared_ptr<LightningBolt>( new LightningBolt(this, x, y, z) ) );
|
||||
lightningTime = 2;
|
||||
}
|
||||
}
|
||||
@@ -665,7 +665,7 @@ vector<TickNextTickData> *ServerLevel::fetchTicksInChunk(LevelChunk *chunk, bool
|
||||
return results;
|
||||
}
|
||||
|
||||
void ServerLevel::tick(shared_ptr<Entity> e, bool actual)
|
||||
void ServerLevel::tick(std::shared_ptr<Entity> e, bool actual)
|
||||
{
|
||||
if (!server->isAnimals() && ((e->GetType() & eTYPE_ANIMAL) || (e->GetType() & eTYPE_WATERANIMAL)))
|
||||
{
|
||||
@@ -681,7 +681,7 @@ void ServerLevel::tick(shared_ptr<Entity> e, bool actual)
|
||||
}
|
||||
}
|
||||
|
||||
void ServerLevel::forceTick(shared_ptr<Entity> e, bool actual)
|
||||
void ServerLevel::forceTick(std::shared_ptr<Entity> e, bool actual)
|
||||
{
|
||||
Level::tick(e, actual);
|
||||
}
|
||||
@@ -693,12 +693,12 @@ ChunkSource *ServerLevel::createChunkSource()
|
||||
return cache;
|
||||
}
|
||||
|
||||
vector<shared_ptr<TileEntity> > *ServerLevel::getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1)
|
||||
vector<std::shared_ptr<TileEntity> > *ServerLevel::getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1)
|
||||
{
|
||||
vector<shared_ptr<TileEntity> > *result = new vector<shared_ptr<TileEntity> >;
|
||||
vector<std::shared_ptr<TileEntity> > *result = new vector<std::shared_ptr<TileEntity> >;
|
||||
for (unsigned int i = 0; i < tileEntityList.size(); i++)
|
||||
{
|
||||
shared_ptr<TileEntity> te = tileEntityList[i];
|
||||
std::shared_ptr<TileEntity> te = tileEntityList[i];
|
||||
if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 && te->y < y1 && te->z < z1)
|
||||
{
|
||||
result->push_back(te);
|
||||
@@ -707,7 +707,7 @@ vector<shared_ptr<TileEntity> > *ServerLevel::getTileEntitiesInRegion(int x0, in
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ServerLevel::mayInteract(shared_ptr<Player> player, int xt, int yt, int zt, int content)
|
||||
bool ServerLevel::mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int content)
|
||||
{
|
||||
// 4J-PB - This will look like a bug to players, and we really should have a message to explain why we're not allowing lava to be placed at or near a spawn point
|
||||
// We'll need to do this in a future update
|
||||
@@ -814,7 +814,7 @@ void ServerLevel::generateBonusItemsNearSpawn()
|
||||
|
||||
if( getTile( x, y, z ) == Tile::chest_Id )
|
||||
{
|
||||
shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(getTileEntity(x, y, z));
|
||||
std::shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(getTileEntity(x, y, z));
|
||||
if (chest != NULL)
|
||||
{
|
||||
if( chest->isBonusChest )
|
||||
@@ -948,11 +948,11 @@ void ServerLevel::saveLevelData()
|
||||
savedDataStorage->save();
|
||||
}
|
||||
|
||||
void ServerLevel::entityAdded(shared_ptr<Entity> e)
|
||||
void ServerLevel::entityAdded(std::shared_ptr<Entity> e)
|
||||
{
|
||||
Level::entityAdded(e);
|
||||
entitiesById[e->entityId] = e;
|
||||
vector<shared_ptr<Entity> > *es = e->getSubEntities();
|
||||
vector<std::shared_ptr<Entity> > *es = e->getSubEntities();
|
||||
if (es != NULL)
|
||||
{
|
||||
//for (int i = 0; i < es.length; i++)
|
||||
@@ -964,11 +964,11 @@ void ServerLevel::entityAdded(shared_ptr<Entity> e)
|
||||
entityAddedExtra(e); // 4J added
|
||||
}
|
||||
|
||||
void ServerLevel::entityRemoved(shared_ptr<Entity> e)
|
||||
void ServerLevel::entityRemoved(std::shared_ptr<Entity> e)
|
||||
{
|
||||
Level::entityRemoved(e);
|
||||
entitiesById.erase(e->entityId);
|
||||
vector<shared_ptr<Entity> > *es = e->getSubEntities();
|
||||
vector<std::shared_ptr<Entity> > *es = e->getSubEntities();
|
||||
if (es != NULL)
|
||||
{
|
||||
//for (int i = 0; i < es.length; i++)
|
||||
@@ -980,32 +980,32 @@ void ServerLevel::entityRemoved(shared_ptr<Entity> e)
|
||||
entityRemovedExtra(e); // 4J added
|
||||
}
|
||||
|
||||
shared_ptr<Entity> ServerLevel::getEntity(int id)
|
||||
std::shared_ptr<Entity> ServerLevel::getEntity(int id)
|
||||
{
|
||||
return entitiesById[id];
|
||||
}
|
||||
|
||||
bool ServerLevel::addGlobalEntity(shared_ptr<Entity> e)
|
||||
bool ServerLevel::addGlobalEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
if (Level::addGlobalEntity(e))
|
||||
{
|
||||
server->getPlayers()->broadcast(e->x, e->y, e->z, 512, dimension->id, shared_ptr<AddGlobalEntityPacket>( new AddGlobalEntityPacket(e) ) );
|
||||
server->getPlayers()->broadcast(e->x, e->y, e->z, 512, dimension->id, std::shared_ptr<AddGlobalEntityPacket>( new AddGlobalEntityPacket(e) ) );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ServerLevel::broadcastEntityEvent(shared_ptr<Entity> e, byte event)
|
||||
void ServerLevel::broadcastEntityEvent(std::shared_ptr<Entity> e, byte event)
|
||||
{
|
||||
shared_ptr<Packet> p = shared_ptr<EntityEventPacket>( new EntityEventPacket(e->entityId, event) );
|
||||
std::shared_ptr<Packet> p = std::shared_ptr<EntityEventPacket>( new EntityEventPacket(e->entityId, event) );
|
||||
server->getLevel(dimension->id)->getTracker()->broadcastAndSend(e, p);
|
||||
}
|
||||
|
||||
shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks)
|
||||
std::shared_ptr<Explosion> ServerLevel::explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks)
|
||||
{
|
||||
// instead of calling super, we run the same explosion code here except
|
||||
// we don't generate any particles
|
||||
shared_ptr<Explosion> explosion = shared_ptr<Explosion>( new Explosion(this, source, x, y, z, r) );
|
||||
std::shared_ptr<Explosion> explosion = std::shared_ptr<Explosion>( new Explosion(this, source, x, y, z, r) );
|
||||
explosion->fire = fire;
|
||||
explosion->destroyBlocks = destroyBlocks;
|
||||
explosion->explode();
|
||||
@@ -1016,10 +1016,10 @@ shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x,
|
||||
explosion->toBlow.clear();
|
||||
}
|
||||
|
||||
vector<shared_ptr<ServerPlayer> > sentTo;
|
||||
vector<std::shared_ptr<ServerPlayer> > sentTo;
|
||||
for(AUTO_VAR(it, players.begin()); it != players.end(); ++it)
|
||||
{
|
||||
shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(*it);
|
||||
std::shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(*it);
|
||||
if (player->dimension != dimension->id) continue;
|
||||
|
||||
bool knockbackOnly = false;
|
||||
@@ -1034,7 +1034,7 @@ shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x,
|
||||
{
|
||||
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
||||
{
|
||||
shared_ptr<ServerPlayer> player2 = sentTo[j];
|
||||
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
|
||||
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
||||
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
||||
{
|
||||
@@ -1049,7 +1049,7 @@ shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x,
|
||||
Vec3 *knockbackVec = explosion->getHitPlayerKnockback(player);
|
||||
//app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n", knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z);
|
||||
// If the player is not the primary on the system, then we only want to send info for the knockback
|
||||
player->connection->send( shared_ptr<ExplodePacket>( new ExplodePacket(x, y, z, r, &explosion->toBlow, knockbackVec, knockbackOnly)));
|
||||
player->connection->send( std::shared_ptr<ExplodePacket>( new ExplodePacket(x, y, z, r, &explosion->toBlow, knockbackVec, knockbackOnly)));
|
||||
sentTo.push_back( player );
|
||||
}
|
||||
}
|
||||
@@ -1088,7 +1088,7 @@ void ServerLevel::runTileEvents()
|
||||
if (doTileEvent(&(*it)))
|
||||
{
|
||||
TileEventData te = *it;
|
||||
server->getPlayers()->broadcast(te.getX(), te.getY(), te.getZ(), 64, dimension->id, shared_ptr<TileEventPacket>( new TileEventPacket(te.getX(), te.getY(), te.getZ(), te.getTile(), te.getParamA(), te.getParamB())));
|
||||
server->getPlayers()->broadcast(te.getX(), te.getY(), te.getZ(), 64, dimension->id, std::shared_ptr<TileEventPacket>( new TileEventPacket(te.getX(), te.getY(), te.getZ(), te.getTile(), te.getParamA(), te.getParamB())));
|
||||
}
|
||||
}
|
||||
tileEvents[runList].clear();
|
||||
@@ -1119,11 +1119,11 @@ void ServerLevel::tickWeather()
|
||||
{
|
||||
if (wasRaining)
|
||||
{
|
||||
server->getPlayers()->broadcastAll( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) );
|
||||
server->getPlayers()->broadcastAll( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
server->getPlayers()->broadcastAll( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) );
|
||||
server->getPlayers()->broadcastAll( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1185,7 +1185,7 @@ void ServerLevel::runQueuedSendTileUpdates()
|
||||
}
|
||||
|
||||
// 4J - added special versions of addEntity and extra processing on entity removed and added so we can limit the number of itementities created
|
||||
bool ServerLevel::addEntity(shared_ptr<Entity> e)
|
||||
bool ServerLevel::addEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
// If its an item entity, and we've got to our capacity, delete the oldest
|
||||
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
|
||||
@@ -1244,7 +1244,7 @@ bool ServerLevel::addEntity(shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
// Maintain a cound of primed tnt & falling tiles in this level
|
||||
void ServerLevel::entityAddedExtra(shared_ptr<Entity> e)
|
||||
void ServerLevel::entityAddedExtra(std::shared_ptr<Entity> e)
|
||||
{
|
||||
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
|
||||
{
|
||||
@@ -1289,7 +1289,7 @@ void ServerLevel::entityAddedExtra(shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
// Maintain a cound of primed tnt & falling tiles in this level, and remove any item entities from our list
|
||||
void ServerLevel::entityRemovedExtra(shared_ptr<Entity> e)
|
||||
void ServerLevel::entityRemovedExtra(std::shared_ptr<Entity> e)
|
||||
{
|
||||
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user