mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-08-02 16:01:16 +00:00
refactor: unglob std::shared_ptr
This commit is contained in:
@@ -11,7 +11,7 @@ LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS = LevelSettings(
|
||||
1.0
|
||||
);
|
||||
|
||||
DemoLevel::DemoLevel(shared_ptr<LevelStorage> levelStorage, const wstring& levelName) : Level(levelStorage, levelName, &DEMO_LEVEL_SETTINGS)
|
||||
DemoLevel::DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const wstring& levelName) : Level(levelStorage, levelName, &DEMO_LEVEL_SETTINGS)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ private:
|
||||
static const int DEMO_SPAWN_Z = -731;
|
||||
static LevelSettings DEMO_LEVEL_SETTINGS;
|
||||
public:
|
||||
DemoLevel(shared_ptr<LevelStorage> levelStorage, const wstring& levelName);
|
||||
DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const wstring& levelName);
|
||||
DemoLevel(Level *level, Dimension *dimension);
|
||||
protected:
|
||||
virtual void setInitialSpawn();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "../../Minecraft.World/Level/Storage/SavedDataStorage.h"
|
||||
#include "../../Minecraft.World/Level/DerivedLevelData.h"
|
||||
|
||||
DerivedServerLevel::DerivedServerLevel(MinecraftServer *server, shared_ptr<LevelStorage> levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped)
|
||||
DerivedServerLevel::DerivedServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage> levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped)
|
||||
: ServerLevel(server, levelStorage, levelName, dimension, levelSettings)
|
||||
{
|
||||
// 4J-PB - we're going to override the savedDataStorage, so we need to delete the current one
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
class DerivedServerLevel : public ServerLevel
|
||||
{
|
||||
public:
|
||||
DerivedServerLevel(MinecraftServer *server, shared_ptr<LevelStorage>levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped);
|
||||
DerivedServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped);
|
||||
~DerivedServerLevel();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -24,7 +24,7 @@ MultiPlayerLevel::ResetInfo::ResetInfo(int x, int y, int z, int tile, int data)
|
||||
}
|
||||
|
||||
MultiPlayerLevel::MultiPlayerLevel(ClientConnection *connection, LevelSettings *levelSettings, int dimension, int difficulty)
|
||||
: Level(shared_ptr<MockedLevelStorage >(new MockedLevelStorage()), L"MpServer", Dimension::getNew(dimension), levelSettings, false)
|
||||
: Level(std::shared_ptr<MockedLevelStorage >(new MockedLevelStorage()), L"MpServer", Dimension::getNew(dimension), levelSettings, false)
|
||||
{
|
||||
minecraft = Minecraft::GetInstance();
|
||||
|
||||
@@ -108,7 +108,7 @@ void MultiPlayerLevel::tick()
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
for (int i = 0; i < 10 && !reEntries.empty(); i++)
|
||||
{
|
||||
shared_ptr<Entity> e = *(reEntries.begin());
|
||||
std::shared_ptr<Entity> e = *(reEntries.begin());
|
||||
|
||||
if (find(entities.begin(), entities.end(), e) == entities.end() ) addEntity(e);
|
||||
}
|
||||
@@ -403,7 +403,7 @@ void MultiPlayerLevel::setChunkVisible(int x, int z, bool visible)
|
||||
|
||||
}
|
||||
|
||||
bool MultiPlayerLevel::addEntity(shared_ptr<Entity> e)
|
||||
bool MultiPlayerLevel::addEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
bool ok = Level::addEntity(e);
|
||||
forced.insert(e);
|
||||
@@ -416,7 +416,7 @@ bool MultiPlayerLevel::addEntity(shared_ptr<Entity> e)
|
||||
return ok;
|
||||
}
|
||||
|
||||
void MultiPlayerLevel::removeEntity(shared_ptr<Entity> e)
|
||||
void MultiPlayerLevel::removeEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
// 4J Stu - Add this remove from the reEntries collection to stop us continually removing and re-adding things,
|
||||
// in particular the MultiPlayerLocalPlayer when they die
|
||||
@@ -430,7 +430,7 @@ void MultiPlayerLevel::removeEntity(shared_ptr<Entity> e)
|
||||
forced.erase(e);
|
||||
}
|
||||
|
||||
void MultiPlayerLevel::entityAdded(shared_ptr<Entity> e)
|
||||
void MultiPlayerLevel::entityAdded(std::shared_ptr<Entity> e)
|
||||
{
|
||||
Level::entityAdded(e);
|
||||
AUTO_VAR(it, reEntries.find(e));
|
||||
@@ -440,7 +440,7 @@ void MultiPlayerLevel::entityAdded(shared_ptr<Entity> e)
|
||||
}
|
||||
}
|
||||
|
||||
void MultiPlayerLevel::entityRemoved(shared_ptr<Entity> e)
|
||||
void MultiPlayerLevel::entityRemoved(std::shared_ptr<Entity> e)
|
||||
{
|
||||
Level::entityRemoved(e);
|
||||
AUTO_VAR(it, forced.find(e));
|
||||
@@ -450,9 +450,9 @@ void MultiPlayerLevel::entityRemoved(shared_ptr<Entity> e)
|
||||
}
|
||||
}
|
||||
|
||||
void MultiPlayerLevel::putEntity(int id, shared_ptr<Entity> e)
|
||||
void MultiPlayerLevel::putEntity(int id, std::shared_ptr<Entity> e)
|
||||
{
|
||||
shared_ptr<Entity> old = getEntity(id);
|
||||
std::shared_ptr<Entity> old = getEntity(id);
|
||||
if (old != NULL)
|
||||
{
|
||||
removeEntity(old);
|
||||
@@ -467,16 +467,16 @@ void MultiPlayerLevel::putEntity(int id, shared_ptr<Entity> e)
|
||||
entitiesById[id] = e;
|
||||
}
|
||||
|
||||
shared_ptr<Entity> MultiPlayerLevel::getEntity(int id)
|
||||
std::shared_ptr<Entity> MultiPlayerLevel::getEntity(int id)
|
||||
{
|
||||
AUTO_VAR(it, entitiesById.find(id));
|
||||
if( it == entitiesById.end() ) return nullptr;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
shared_ptr<Entity> MultiPlayerLevel::removeEntity(int id)
|
||||
std::shared_ptr<Entity> MultiPlayerLevel::removeEntity(int id)
|
||||
{
|
||||
shared_ptr<Entity> e;
|
||||
std::shared_ptr<Entity> e;
|
||||
AUTO_VAR(it, entitiesById.find(id));
|
||||
if( it != entitiesById.end() )
|
||||
{
|
||||
@@ -493,11 +493,11 @@ shared_ptr<Entity> MultiPlayerLevel::removeEntity(int id)
|
||||
|
||||
// 4J Added to remove the entities from the forced list
|
||||
// This gets called when a chunk is unloaded, but we only do half an unload to remove entities slightly differently
|
||||
void MultiPlayerLevel::removeEntities(vector<shared_ptr<Entity> > *list)
|
||||
void MultiPlayerLevel::removeEntities(vector<std::shared_ptr<Entity> > *list)
|
||||
{
|
||||
for(AUTO_VAR(it, list->begin()); it < list->end(); ++it)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;
|
||||
std::shared_ptr<Entity> e = *it;
|
||||
|
||||
AUTO_VAR(reIt, reEntries.find(e));
|
||||
if (reIt!=reEntries.end())
|
||||
@@ -609,7 +609,7 @@ void MultiPlayerLevel::disconnect(bool sendDisconnect /*= true*/)
|
||||
{
|
||||
for(AUTO_VAR(it, connections.begin()); it < connections.end(); ++it )
|
||||
{
|
||||
(*it)->sendAndDisconnect( shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );
|
||||
(*it)->sendAndDisconnect( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -730,7 +730,7 @@ void MultiPlayerLevel::animateTickDoWork()
|
||||
|
||||
}
|
||||
|
||||
void MultiPlayerLevel::playSound(shared_ptr<Entity> entity, int iSound, float volume, float pitch)
|
||||
void MultiPlayerLevel::playSound(std::shared_ptr<Entity> entity, int iSound, float volume, float pitch)
|
||||
{
|
||||
playLocalSound(entity->x, entity->y - entity->heightOffset, entity->z, iSound, volume, pitch);
|
||||
}
|
||||
@@ -790,7 +790,7 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals()
|
||||
AUTO_VAR(endIt, entitiesToRemove.end());
|
||||
for (AUTO_VAR(it, entitiesToRemove.begin()); it != endIt; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;
|
||||
std::shared_ptr<Entity> e = *it;
|
||||
int xc = e->xChunk;
|
||||
int zc = e->zChunk;
|
||||
if (e->inChunk && hasChunk(xc, zc))
|
||||
@@ -809,10 +809,10 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals()
|
||||
|
||||
//for (int i = 0; i < entities.size(); i++)
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
vector<shared_ptr<Entity> >::iterator it = entities.begin();
|
||||
vector<std::shared_ptr<Entity> >::iterator it = entities.begin();
|
||||
while( it != entities.end() )
|
||||
{
|
||||
shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
std::shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
|
||||
if (e->riding != NULL)
|
||||
{
|
||||
@@ -853,7 +853,7 @@ void MultiPlayerLevel::removeClientConnection(ClientConnection *c, bool sendDisc
|
||||
{
|
||||
if( sendDisconnect )
|
||||
{
|
||||
c->sendAndDisconnect( shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );
|
||||
c->sendAndDisconnect( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );
|
||||
}
|
||||
|
||||
AUTO_VAR(it, find( connections.begin(), connections.end(), c ));
|
||||
@@ -886,7 +886,7 @@ void MultiPlayerLevel::removeUnusedTileEntitiesInRegion(int x0, int y0, int z0,
|
||||
for (unsigned int i = 0; i < tileEntityList.size();)
|
||||
{
|
||||
bool removed = false;
|
||||
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)
|
||||
{
|
||||
LevelChunk *lc = getChunk(te->x >> 4, te->z >> 4);
|
||||
|
||||
@@ -54,21 +54,21 @@ public:
|
||||
void setChunkVisible(int x, int z, bool visible);
|
||||
|
||||
private:
|
||||
unordered_map<int, shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
|
||||
unordered_set<shared_ptr<Entity> > forced;
|
||||
unordered_set<shared_ptr<Entity> > reEntries;
|
||||
unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
|
||||
unordered_set<std::shared_ptr<Entity> > forced;
|
||||
unordered_set<std::shared_ptr<Entity> > reEntries;
|
||||
|
||||
public:
|
||||
virtual bool addEntity(shared_ptr<Entity> e);
|
||||
virtual void removeEntity(shared_ptr<Entity> e);
|
||||
virtual bool addEntity(std::shared_ptr<Entity> e);
|
||||
virtual void removeEntity(std::shared_ptr<Entity> e);
|
||||
protected:
|
||||
virtual void entityAdded(shared_ptr<Entity> e);
|
||||
virtual void entityRemoved(shared_ptr<Entity> e);
|
||||
virtual void entityAdded(std::shared_ptr<Entity> e);
|
||||
virtual void entityRemoved(std::shared_ptr<Entity> e);
|
||||
public:
|
||||
void putEntity(int id, shared_ptr<Entity> e);
|
||||
shared_ptr<Entity> getEntity(int id);
|
||||
shared_ptr<Entity> removeEntity(int id);
|
||||
virtual void removeEntities(vector<shared_ptr<Entity> > *list); // 4J Added override
|
||||
void putEntity(int id, std::shared_ptr<Entity> e);
|
||||
std::shared_ptr<Entity> getEntity(int id);
|
||||
std::shared_ptr<Entity> removeEntity(int id);
|
||||
virtual void removeEntities(vector<std::shared_ptr<Entity> > *list); // 4J Added override
|
||||
virtual bool setDataNoUpdate(int x, int y, int z, int data);
|
||||
virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data);
|
||||
virtual bool setTileNoUpdate(int x, int y, int z, int tile);
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
public:
|
||||
void removeAllPendingEntityRemovals();
|
||||
|
||||
virtual void playSound(shared_ptr<Entity> entity, int iSound, float volume, float pitch);
|
||||
virtual void playSound(std::shared_ptr<Entity> entity, int iSound, float volume, float pitch);
|
||||
|
||||
virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f);
|
||||
|
||||
|
||||
@@ -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, uint8_t event)
|
||||
void ServerLevel::broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t 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 )
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
int activeTileEventsList;
|
||||
public:
|
||||
static void staticCtor();
|
||||
ServerLevel(MinecraftServer *server, shared_ptr<LevelStorage>levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings);
|
||||
ServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings);
|
||||
~ServerLevel();
|
||||
void tick();
|
||||
Biome::MobSpawnerData *getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z);
|
||||
@@ -65,15 +65,15 @@ public:
|
||||
void tickEntities();
|
||||
bool tickPendingTicks(bool force);
|
||||
vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
|
||||
virtual void tick(shared_ptr<Entity> e, bool actual);
|
||||
void forceTick(shared_ptr<Entity> e, bool actual);
|
||||
virtual void tick(std::shared_ptr<Entity> e, bool actual);
|
||||
void forceTick(std::shared_ptr<Entity> e, bool actual);
|
||||
bool AllPlayersAreSleeping() { return allPlayersSleeping;} // 4J added for a message to other players
|
||||
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping;}
|
||||
protected:
|
||||
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
||||
public:
|
||||
vector<shared_ptr<TileEntity> > *getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1);
|
||||
virtual bool mayInteract(shared_ptr<Player> player, int xt, int yt, int zt, int id);
|
||||
vector<std::shared_ptr<TileEntity> > *getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1);
|
||||
virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int id);
|
||||
protected:
|
||||
virtual void initializeLevel(LevelSettings *settings);
|
||||
virtual void setInitialSpawn(LevelSettings *settings);
|
||||
@@ -90,16 +90,16 @@ public:
|
||||
private:
|
||||
void saveLevelData();
|
||||
|
||||
typedef unordered_map<int, shared_ptr<Entity> , IntKeyHash2, IntKeyEq> intEntityMap;
|
||||
typedef unordered_map<int, std::shared_ptr<Entity> , IntKeyHash2, IntKeyEq> intEntityMap;
|
||||
intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing function as this uses
|
||||
protected:
|
||||
virtual void entityAdded(shared_ptr<Entity> e);
|
||||
virtual void entityRemoved(shared_ptr<Entity> e);
|
||||
virtual void entityAdded(std::shared_ptr<Entity> e);
|
||||
virtual void entityRemoved(std::shared_ptr<Entity> e);
|
||||
public:
|
||||
shared_ptr<Entity> getEntity(int id);
|
||||
virtual bool addGlobalEntity(shared_ptr<Entity> e);
|
||||
void broadcastEntityEvent(shared_ptr<Entity> e, uint8_t event);
|
||||
virtual shared_ptr<Explosion> explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks);
|
||||
std::shared_ptr<Entity> getEntity(int id);
|
||||
virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
|
||||
void broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t event);
|
||||
virtual std::shared_ptr<Explosion> explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks);
|
||||
virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1);
|
||||
|
||||
private:
|
||||
@@ -134,14 +134,14 @@ public:
|
||||
int m_primedTntCount;
|
||||
int m_fallingTileCount;
|
||||
CRITICAL_SECTION m_limiterCS;
|
||||
list< shared_ptr<Entity> > m_itemEntities;
|
||||
list< shared_ptr<Entity> > m_hangingEntities;
|
||||
list< shared_ptr<Entity> > m_arrowEntities;
|
||||
list< shared_ptr<Entity> > m_experienceOrbEntities;
|
||||
list< std::shared_ptr<Entity> > m_itemEntities;
|
||||
list< std::shared_ptr<Entity> > m_hangingEntities;
|
||||
list< std::shared_ptr<Entity> > m_arrowEntities;
|
||||
list< std::shared_ptr<Entity> > m_experienceOrbEntities;
|
||||
|
||||
virtual bool addEntity(shared_ptr<Entity> e);
|
||||
void entityAddedExtra(shared_ptr<Entity> e);
|
||||
void entityRemovedExtra(shared_ptr<Entity> e);
|
||||
virtual bool addEntity(std::shared_ptr<Entity> e);
|
||||
void entityAddedExtra(std::shared_ptr<Entity> e);
|
||||
void entityRemovedExtra(std::shared_ptr<Entity> e);
|
||||
|
||||
virtual bool newPrimedTntAllowed();
|
||||
virtual bool newFallingTileAllowed();
|
||||
|
||||
@@ -33,22 +33,22 @@ void ServerLevelListener::allChanged()
|
||||
{
|
||||
}
|
||||
|
||||
void ServerLevelListener::entityAdded(shared_ptr<Entity> entity)
|
||||
void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
MemSect(10);
|
||||
level->getTracker()->addEntity(entity);
|
||||
MemSect(0);
|
||||
}
|
||||
|
||||
void ServerLevelListener::entityRemoved(shared_ptr<Entity> entity)
|
||||
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
level->getTracker()->removeEntity(entity);
|
||||
}
|
||||
|
||||
// 4J added
|
||||
void ServerLevelListener::playerRemoved(shared_ptr<Entity> entity)
|
||||
void ServerLevelListener::playerRemoved(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(entity);
|
||||
std::shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(entity);
|
||||
player->getLevel()->getTracker()->removePlayer(entity);
|
||||
}
|
||||
|
||||
@@ -62,11 +62,11 @@ void ServerLevelListener::playSound(int iSound, double x, double y, double z, fl
|
||||
{
|
||||
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
|
||||
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
|
||||
server->getPlayers()->broadcast(x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||
server->getPlayers()->broadcast(x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, std::shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||
}
|
||||
}
|
||||
|
||||
void ServerLevelListener::playSound(shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist)
|
||||
void ServerLevelListener::playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist)
|
||||
{
|
||||
if(iSound < 0)
|
||||
{
|
||||
@@ -76,8 +76,8 @@ void ServerLevelListener::playSound(shared_ptr<Entity> entity,int iSound, double
|
||||
{
|
||||
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
|
||||
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
|
||||
shared_ptr<Player> player= dynamic_pointer_cast<Player>(entity);
|
||||
server->getPlayers()->broadcast(player,x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||
std::shared_ptr<Player> player= dynamic_pointer_cast<Player>(entity);
|
||||
server->getPlayers()->broadcast(player,x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, std::shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,9 +102,9 @@ void ServerLevelListener::playStreamingMusic(const wstring& name, int x, int y,
|
||||
{
|
||||
}
|
||||
|
||||
void ServerLevelListener::levelEvent(shared_ptr<Player> source, int type, int x, int y, int z, int data)
|
||||
void ServerLevelListener::levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data)
|
||||
{
|
||||
server->getPlayers()->broadcast(source, x, y, z, 64, level->dimension->id, shared_ptr<LevelEventPacket>( new LevelEventPacket(type, x, y, z, data) ) );
|
||||
server->getPlayers()->broadcast(source, x, y, z, 64, level->dimension->id, std::shared_ptr<LevelEventPacket>( new LevelEventPacket(type, x, y, z, data) ) );
|
||||
}
|
||||
|
||||
void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int progress)
|
||||
@@ -112,7 +112,7 @@ void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int p
|
||||
//for (ServerPlayer p : server->getPlayers()->players)
|
||||
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it)
|
||||
{
|
||||
shared_ptr<ServerPlayer> p = *it;
|
||||
std::shared_ptr<ServerPlayer> p = *it;
|
||||
if (p == NULL || p->level != level || p->entityId == id) continue;
|
||||
double xd = (double) x - p->x;
|
||||
double yd = (double) y - p->y;
|
||||
@@ -120,7 +120,7 @@ void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int p
|
||||
|
||||
if (xd * xd + yd * yd + zd * zd < 32 * 32)
|
||||
{
|
||||
p->connection->send(shared_ptr<TileDestructionPacket>(new TileDestructionPacket(id, x, y, z, progress)));
|
||||
p->connection->send(std::shared_ptr<TileDestructionPacket>(new TileDestructionPacket(id, x, y, z, progress)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,16 @@ public:
|
||||
// 4J removed - virtual void addParticle(const wstring& name, double x, double y, double z, double xa, double ya, double za);
|
||||
virtual void addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za); // 4J added
|
||||
virtual void allChanged();
|
||||
virtual void entityAdded(shared_ptr<Entity> entity);
|
||||
virtual void entityRemoved(shared_ptr<Entity> entity);
|
||||
virtual void playerRemoved(shared_ptr<Entity> entity); // 4J added - for when a player is removed from the level's player array, not just the entity storage
|
||||
virtual void entityAdded(std::shared_ptr<Entity> entity);
|
||||
virtual void entityRemoved(std::shared_ptr<Entity> entity);
|
||||
virtual void playerRemoved(std::shared_ptr<Entity> entity); // 4J added - for when a player is removed from the level's player array, not just the entity storage
|
||||
virtual void playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
||||
virtual void playSound(shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
||||
virtual void playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
||||
virtual void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level); // 4J - added level param
|
||||
virtual void skyColorChanged();
|
||||
virtual void tileChanged(int x, int y, int z);
|
||||
virtual void tileLightChanged(int x, int y, int z);
|
||||
virtual void playStreamingMusic(const wstring& name, int x, int y, int z);
|
||||
virtual void levelEvent(shared_ptr<Player> source, int type, int x, int y, int z, int data);
|
||||
virtual void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data);
|
||||
virtual void destroyTileProgress(int id, int x, int y, int z, int progress);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user