refactor: unglob std::shared_ptr

This commit is contained in:
Tropical 2026-03-06 11:20:45 -06:00
parent 0dd1654dec
commit 67ceccf2d4
1065 changed files with 5754 additions and 5749 deletions

View file

@ -14,7 +14,7 @@ EGameCommand TeleportCommand::getId()
return eGameCommand_Teleport; return eGameCommand_Teleport;
} }
void TeleportCommand::execute(shared_ptr<CommandSender> source, byteArray commandData) void TeleportCommand::execute(std::shared_ptr<CommandSender> source, byteArray commandData)
{ {
ByteArrayInputStream bais(commandData); ByteArrayInputStream bais(commandData);
DataInputStream dis(&bais); DataInputStream dis(&bais);
@ -26,8 +26,8 @@ void TeleportCommand::execute(shared_ptr<CommandSender> source, byteArray comman
PlayerList *players = MinecraftServer::getInstance()->getPlayerList(); PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID); std::shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
shared_ptr<ServerPlayer> destination = players->getPlayer(destinationID); std::shared_ptr<ServerPlayer> destination = players->getPlayer(destinationID);
if(subject != NULL && destination != NULL && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive() ) if(subject != NULL && destination != NULL && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive() )
{ {
@ -78,7 +78,7 @@ void TeleportCommand::execute(shared_ptr<CommandSender> source, byteArray comman
//} //}
} }
shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(PlayerUID subject, PlayerUID destination) std::shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(PlayerUID subject, PlayerUID destination)
{ {
ByteArrayOutputStream baos; ByteArrayOutputStream baos;
DataOutputStream dos(&baos); DataOutputStream dos(&baos);
@ -86,5 +86,5 @@ shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(PlayerUID subject,
dos.writePlayerUID(subject); dos.writePlayerUID(subject);
dos.writePlayerUID(destination); dos.writePlayerUID(destination);
return shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() )); return std::shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() ));
} }

View file

@ -6,7 +6,7 @@ class TeleportCommand : public Command
{ {
public: public:
virtual EGameCommand getId(); virtual EGameCommand getId();
virtual void execute(shared_ptr<CommandSender> source, byteArray commandData); virtual void execute(std::shared_ptr<CommandSender> source, byteArray commandData);
static shared_ptr<GameCommandPacket> preparePacket(PlayerUID subject, PlayerUID destination); static std::shared_ptr<GameCommandPacket> preparePacket(PlayerUID subject, PlayerUID destination);
}; };

View file

@ -21,7 +21,7 @@ void CreativeMode::init()
// initPlayer(); // initPlayer();
} }
void CreativeMode::enableCreativeForPlayer(shared_ptr<Player> player) void CreativeMode::enableCreativeForPlayer(std::shared_ptr<Player> player)
{ {
// please check ServerPlayerGameMode.java if you change these // please check ServerPlayerGameMode.java if you change these
player->abilities.mayfly = true; player->abilities.mayfly = true;
@ -29,7 +29,7 @@ void CreativeMode::enableCreativeForPlayer(shared_ptr<Player> player)
player->abilities.invulnerable = true; player->abilities.invulnerable = true;
} }
void CreativeMode::disableCreativeForPlayer(shared_ptr<Player> player) void CreativeMode::disableCreativeForPlayer(std::shared_ptr<Player> player)
{ {
player->abilities.mayfly = false; player->abilities.mayfly = false;
player->abilities.flying = false; player->abilities.flying = false;
@ -37,7 +37,7 @@ void CreativeMode::disableCreativeForPlayer(shared_ptr<Player> player)
player->abilities.invulnerable = false; player->abilities.invulnerable = false;
} }
void CreativeMode::adjustPlayer(shared_ptr<Player> player) void CreativeMode::adjustPlayer(std::shared_ptr<Player> player)
{ {
enableCreativeForPlayer(player); enableCreativeForPlayer(player);
@ -45,7 +45,7 @@ void CreativeMode::adjustPlayer(shared_ptr<Player> player)
{ {
if (player->inventory->items[i] == NULL) if (player->inventory->items[i] == NULL)
{ {
player->inventory->items[i] = shared_ptr<ItemInstance>( new ItemInstance(User::allowedTiles[i]) ); player->inventory->items[i] = std::shared_ptr<ItemInstance>( new ItemInstance(User::allowedTiles[i]) );
} }
else else
{ {
@ -63,7 +63,7 @@ void CreativeMode::creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode
} }
} }
bool CreativeMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem) bool CreativeMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
{ {
int t = level->getTile(x, y, z); int t = level->getTile(x, y, z);
if (t > 0) if (t > 0)

View file

@ -9,11 +9,11 @@ private:
public: public:
CreativeMode(Minecraft *minecraft); CreativeMode(Minecraft *minecraft);
virtual void init(); virtual void init();
static void enableCreativeForPlayer(shared_ptr<Player> player); static void enableCreativeForPlayer(std::shared_ptr<Player> player);
static void disableCreativeForPlayer(shared_ptr<Player> player); static void disableCreativeForPlayer(std::shared_ptr<Player> player);
virtual void adjustPlayer(shared_ptr<Player> player); virtual void adjustPlayer(std::shared_ptr<Player> player);
static void creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode, int x, int y, int z, int face); static void creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode, int x, int y, int z, int face);
virtual bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL); virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL);
virtual void startDestroyBlock(int x, int y, int z, int face); virtual void startDestroyBlock(int x, int y, int z, int face);
virtual void continueDestroyBlock(int x, int y, int z, int face); virtual void continueDestroyBlock(int x, int y, int z, int face);
virtual void stopDestroyBlock(); virtual void stopDestroyBlock();

View file

@ -95,7 +95,7 @@ bool DemoMode::destroyBlock(int x, int y, int z, int face)
return SurvivalMode::destroyBlock(x, y, z, face); return SurvivalMode::destroyBlock(x, y, z, face);
} }
bool DemoMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item) bool DemoMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item)
{ {
if (demoHasEnded) if (demoHasEnded)
{ {
@ -105,7 +105,7 @@ bool DemoMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemI
return SurvivalMode::useItem(player, level, item); return SurvivalMode::useItem(player, level, item);
} }
bool DemoMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face) bool DemoMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face)
{ {
if (demoHasEnded) { if (demoHasEnded) {
outputDemoReminder(); outputDemoReminder();
@ -114,7 +114,7 @@ bool DemoMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<Ite
return SurvivalMode::useItemOn(player, level, item, x, y, z, face); return SurvivalMode::useItemOn(player, level, item, x, y, z, face);
} }
void DemoMode::attack(shared_ptr<Player> player, shared_ptr<Entity> entity) void DemoMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
{ {
if (demoHasEnded) if (demoHasEnded)
{ {

View file

@ -21,7 +21,7 @@ public:
virtual void startDestroyBlock(int x, int y, int z, int face); virtual void startDestroyBlock(int x, int y, int z, int face);
virtual void continueDestroyBlock(int x, int y, int z, int face); virtual void continueDestroyBlock(int x, int y, int z, int face);
virtual bool destroyBlock(int x, int y, int z, int face); virtual bool destroyBlock(int x, int y, int z, int face);
virtual bool useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item); virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item);
virtual bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face); virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face);
virtual void attack(shared_ptr<Player> player, shared_ptr<Entity> entity); virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
}; };

View file

@ -47,11 +47,11 @@ void GameMode::render(float a)
{ {
} }
bool GameMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly) bool GameMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly)
{ {
} }
void GameMode::initPlayer(shared_ptr<Player> player) void GameMode::initPlayer(std::shared_ptr<Player> player)
{ {
} }
@ -59,11 +59,11 @@ void GameMode::tick()
{ {
} }
void GameMode::adjustPlayer(shared_ptr<Player> player) void GameMode::adjustPlayer(std::shared_ptr<Player> player)
{ {
} }
//bool GameMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly) //bool GameMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly)
//{ //{
// // 4J-PB - Adding a test only version to allow tooltips to be displayed // // 4J-PB - Adding a test only version to allow tooltips to be displayed
// int t = level->getTile(x, y, z); // int t = level->getTile(x, y, z);
@ -101,27 +101,27 @@ void GameMode::adjustPlayer(shared_ptr<Player> player)
//} //}
shared_ptr<Player> GameMode::createPlayer(Level *level) std::shared_ptr<Player> GameMode::createPlayer(Level *level)
{ {
return shared_ptr<Player>( new LocalPlayer(minecraft, level, minecraft->user, level->dimension->id) ); return std::shared_ptr<Player>( new LocalPlayer(minecraft, level, minecraft->user, level->dimension->id) );
} }
bool GameMode::interact(shared_ptr<Player> player, shared_ptr<Entity> entity) bool GameMode::interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
{ {
return player->interact(entity); return player->interact(entity);
} }
void GameMode::attack(shared_ptr<Player> player, shared_ptr<Entity> entity) void GameMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
{ {
player->attack(entity); player->attack(entity);
} }
shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player) std::shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player)
{ {
return nullptr; return nullptr;
} }
void GameMode::handleCloseInventory(int containerId, shared_ptr<Player> player) void GameMode::handleCloseInventory(int containerId, std::shared_ptr<Player> player)
{ {
player->containerMenu->removed(player); player->containerMenu->removed(player);
delete player->containerMenu; delete player->containerMenu;
@ -138,7 +138,7 @@ bool GameMode::isCutScene()
return false; return false;
} }
void GameMode::releaseUsingItem(shared_ptr<Player> player) void GameMode::releaseUsingItem(std::shared_ptr<Player> player)
{ {
player->releaseUsingItem(); player->releaseUsingItem();
} }
@ -163,21 +163,21 @@ bool GameMode::hasFarPickRange()
return false; return false;
} }
void GameMode::handleCreativeModeItemAdd(shared_ptr<ItemInstance> clicked, int i) void GameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i)
{ {
} }
void GameMode::handleCreativeModeItemDrop(shared_ptr<ItemInstance> clicked) void GameMode::handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked)
{ {
} }
bool GameMode::handleCraftItem(int recipe, shared_ptr<Player> player) bool GameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player)
{ {
return true; return true;
} }
// 4J-PB // 4J-PB
void GameMode::handleDebugOptions(unsigned int uiVal, shared_ptr<Player> player) void GameMode::handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player)
{ {
player->SetDebugOptions(uiVal); player->SetDebugOptions(uiVal);
} }

View file

@ -25,32 +25,32 @@ public:
virtual void stopDestroyBlock() = 0; virtual void stopDestroyBlock() = 0;
virtual void render(float a); virtual void render(float a);
virtual float getPickRange() = 0; virtual float getPickRange() = 0;
virtual void initPlayer(shared_ptr<Player> player); virtual void initPlayer(std::shared_ptr<Player> player);
virtual void tick(); virtual void tick();
virtual bool canHurtPlayer() = 0; virtual bool canHurtPlayer() = 0;
virtual void adjustPlayer(shared_ptr<Player> player); virtual void adjustPlayer(std::shared_ptr<Player> player);
virtual bool useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly=false); virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
virtual bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL) = 0; virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL) = 0;
virtual shared_ptr<Player> createPlayer(Level *level); virtual std::shared_ptr<Player> createPlayer(Level *level);
virtual bool interact(shared_ptr<Player> player, shared_ptr<Entity> entity); virtual bool interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
virtual void attack(shared_ptr<Player> player, shared_ptr<Entity> entity); virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
virtual shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player); virtual std::shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player);
virtual void handleCloseInventory(int containerId, shared_ptr<Player> player); virtual void handleCloseInventory(int containerId, std::shared_ptr<Player> player);
virtual void handleInventoryButtonClick(int containerId, int buttonId); virtual void handleInventoryButtonClick(int containerId, int buttonId);
virtual bool isCutScene(); virtual bool isCutScene();
virtual void releaseUsingItem(shared_ptr<Player> player); virtual void releaseUsingItem(std::shared_ptr<Player> player);
virtual bool hasExperience(); virtual bool hasExperience();
virtual bool hasMissTime(); virtual bool hasMissTime();
virtual bool hasInfiniteItems(); virtual bool hasInfiniteItems();
virtual bool hasFarPickRange(); virtual bool hasFarPickRange();
virtual void handleCreativeModeItemAdd(shared_ptr<ItemInstance> clicked, int i); virtual void handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i);
virtual void handleCreativeModeItemDrop(shared_ptr<ItemInstance> clicked); virtual void handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked);
// 4J Stu - Added so we can send packets for this in the network game // 4J Stu - Added so we can send packets for this in the network game
virtual bool handleCraftItem(int recipe, shared_ptr<Player> player); virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
virtual void handleDebugOptions(unsigned int uiVal, shared_ptr<Player> player); virtual void handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player);
// 4J Stu - Added for tutorial checks // 4J Stu - Added for tutorial checks
virtual bool isInputAllowed(int mapping) { return true; } virtual bool isInputAllowed(int mapping) { return true; }

View file

@ -45,7 +45,7 @@ SurvivalMode::SurvivalMode(SurvivalMode *copy) : GameMode( copy->minecraft )
destroyDelay = copy->destroyDelay; destroyDelay = copy->destroyDelay;
} }
void SurvivalMode::initPlayer(shared_ptr<Player> player) void SurvivalMode::initPlayer(std::shared_ptr<Player> player)
{ {
player->yRot = -180; player->yRot = -180;
} }
@ -65,7 +65,7 @@ bool SurvivalMode::destroyBlock(int x, int y, int z, int face)
int data = minecraft->level->getData(x, y, z); int data = minecraft->level->getData(x, y, z);
bool changed = GameMode::destroyBlock(x, y, z, face); bool changed = GameMode::destroyBlock(x, y, z, face);
shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem(); std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]); bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]);
if (item != NULL) if (item != NULL)
{ {
@ -173,9 +173,9 @@ void SurvivalMode::initLevel(Level *level)
GameMode::initLevel(level); GameMode::initLevel(level);
} }
shared_ptr<Player> SurvivalMode::createPlayer(Level *level) std::shared_ptr<Player> SurvivalMode::createPlayer(Level *level)
{ {
shared_ptr<Player> player = GameMode::createPlayer(level); std::shared_ptr<Player> player = GameMode::createPlayer(level);
// player.inventory.add(new ItemInstance(Item.pickAxe_diamond)); // player.inventory.add(new ItemInstance(Item.pickAxe_diamond));
// player.inventory.add(new ItemInstance(Item.hatchet_diamond)); // player.inventory.add(new ItemInstance(Item.hatchet_diamond));
// player.inventory.add(new ItemInstance(Tile.torch, 64)); // player.inventory.add(new ItemInstance(Tile.torch, 64));
@ -191,7 +191,7 @@ void SurvivalMode::tick()
//minecraft->soundEngine->playMusicTick(); //minecraft->soundEngine->playMusicTick();
} }
bool SurvivalMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem) bool SurvivalMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
{ {
int t = level->getTile(x, y, z); int t = level->getTile(x, y, z);
if (t > 0) if (t > 0)

View file

@ -15,7 +15,7 @@ private:
public: public:
SurvivalMode(Minecraft *minecraft); SurvivalMode(Minecraft *minecraft);
SurvivalMode(SurvivalMode *copy); SurvivalMode(SurvivalMode *copy);
virtual void initPlayer(shared_ptr<Player> player); virtual void initPlayer(std::shared_ptr<Player> player);
virtual void init(); virtual void init();
virtual bool canHurtPlayer(); virtual bool canHurtPlayer();
virtual bool destroyBlock(int x, int y, int z, int face); virtual bool destroyBlock(int x, int y, int z, int face);
@ -25,8 +25,8 @@ public:
virtual void render(float a); virtual void render(float a);
virtual float getPickRange(); virtual float getPickRange();
virtual void initLevel(Level *level); virtual void initLevel(Level *level);
virtual shared_ptr<Player> createPlayer(Level *level); virtual std::shared_ptr<Player> createPlayer(Level *level);
virtual void tick(); virtual void tick();
virtual bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL); virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL);
virtual bool hasExperience(); virtual bool hasExperience();
}; };

View file

@ -11,7 +11,7 @@ LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS = LevelSettings(
1.0 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)
{ {
} }

View file

@ -10,7 +10,7 @@ private:
static const int DEMO_SPAWN_Z = -731; static const int DEMO_SPAWN_Z = -731;
static LevelSettings DEMO_LEVEL_SETTINGS; static LevelSettings DEMO_LEVEL_SETTINGS;
public: public:
DemoLevel(shared_ptr<LevelStorage> levelStorage, const wstring& levelName); DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const wstring& levelName);
DemoLevel(Level *level, Dimension *dimension); DemoLevel(Level *level, Dimension *dimension);
protected: protected:
virtual void setInitialSpawn(); virtual void setInitialSpawn();

View file

@ -3,7 +3,7 @@
#include "../../Minecraft.World/Level/Storage/SavedDataStorage.h" #include "../../Minecraft.World/Level/Storage/SavedDataStorage.h"
#include "../../Minecraft.World/Level/DerivedLevelData.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) : ServerLevel(server, levelStorage, levelName, dimension, levelSettings)
{ {
// 4J-PB - we're going to override the savedDataStorage, so we need to delete the current one // 4J-PB - we're going to override the savedDataStorage, so we need to delete the current one

View file

@ -4,7 +4,7 @@
class DerivedServerLevel : public ServerLevel class DerivedServerLevel : public ServerLevel
{ {
public: 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(); ~DerivedServerLevel();
protected: protected:

View file

@ -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) 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(); minecraft = Minecraft::GetInstance();
@ -108,7 +108,7 @@ void MultiPlayerLevel::tick()
EnterCriticalSection(&m_entitiesCS); EnterCriticalSection(&m_entitiesCS);
for (int i = 0; i < 10 && !reEntries.empty(); i++) 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); 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); bool ok = Level::addEntity(e);
forced.insert(e); forced.insert(e);
@ -416,7 +416,7 @@ bool MultiPlayerLevel::addEntity(shared_ptr<Entity> e)
return ok; 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, // 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 // in particular the MultiPlayerLocalPlayer when they die
@ -430,7 +430,7 @@ void MultiPlayerLevel::removeEntity(shared_ptr<Entity> e)
forced.erase(e); forced.erase(e);
} }
void MultiPlayerLevel::entityAdded(shared_ptr<Entity> e) void MultiPlayerLevel::entityAdded(std::shared_ptr<Entity> e)
{ {
Level::entityAdded(e); Level::entityAdded(e);
AUTO_VAR(it, reEntries.find(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); Level::entityRemoved(e);
AUTO_VAR(it, forced.find(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) if (old != NULL)
{ {
removeEntity(old); removeEntity(old);
@ -467,16 +467,16 @@ void MultiPlayerLevel::putEntity(int id, shared_ptr<Entity> e)
entitiesById[id] = 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)); AUTO_VAR(it, entitiesById.find(id));
if( it == entitiesById.end() ) return nullptr; if( it == entitiesById.end() ) return nullptr;
return it->second; 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)); AUTO_VAR(it, entitiesById.find(id));
if( it != entitiesById.end() ) 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 // 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 // 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) 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)); AUTO_VAR(reIt, reEntries.find(e));
if (reIt!=reEntries.end()) if (reIt!=reEntries.end())
@ -609,7 +609,7 @@ void MultiPlayerLevel::disconnect(bool sendDisconnect /*= true*/)
{ {
for(AUTO_VAR(it, connections.begin()); it < connections.end(); ++it ) 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 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); playLocalSound(entity->x, entity->y - entity->heightOffset, entity->z, iSound, volume, pitch);
} }
@ -790,7 +790,7 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals()
AUTO_VAR(endIt, entitiesToRemove.end()); AUTO_VAR(endIt, entitiesToRemove.end());
for (AUTO_VAR(it, entitiesToRemove.begin()); it != endIt; it++) 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 xc = e->xChunk;
int zc = e->zChunk; int zc = e->zChunk;
if (e->inChunk && hasChunk(xc, zc)) if (e->inChunk && hasChunk(xc, zc))
@ -809,10 +809,10 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals()
//for (int i = 0; i < entities.size(); i++) //for (int i = 0; i < entities.size(); i++)
EnterCriticalSection(&m_entitiesCS); EnterCriticalSection(&m_entitiesCS);
vector<shared_ptr<Entity> >::iterator it = entities.begin(); vector<std::shared_ptr<Entity> >::iterator it = entities.begin();
while( it != entities.end() ) 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) if (e->riding != NULL)
{ {
@ -853,7 +853,7 @@ void MultiPlayerLevel::removeClientConnection(ClientConnection *c, bool sendDisc
{ {
if( sendDisconnect ) 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 )); 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();) for (unsigned int i = 0; i < tileEntityList.size();)
{ {
bool removed = false; 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) 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); LevelChunk *lc = getChunk(te->x >> 4, te->z >> 4);

View file

@ -54,21 +54,21 @@ public:
void setChunkVisible(int x, int z, bool visible); void setChunkVisible(int x, int z, bool visible);
private: private:
unordered_map<int, shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
unordered_set<shared_ptr<Entity> > forced; unordered_set<std::shared_ptr<Entity> > forced;
unordered_set<shared_ptr<Entity> > reEntries; unordered_set<std::shared_ptr<Entity> > reEntries;
public: public:
virtual bool addEntity(shared_ptr<Entity> e); virtual bool addEntity(std::shared_ptr<Entity> e);
virtual void removeEntity(shared_ptr<Entity> e); virtual void removeEntity(std::shared_ptr<Entity> e);
protected: protected:
virtual void entityAdded(shared_ptr<Entity> e); virtual void entityAdded(std::shared_ptr<Entity> e);
virtual void entityRemoved(shared_ptr<Entity> e); virtual void entityRemoved(std::shared_ptr<Entity> e);
public: public:
void putEntity(int id, shared_ptr<Entity> e); void putEntity(int id, std::shared_ptr<Entity> e);
shared_ptr<Entity> getEntity(int id); std::shared_ptr<Entity> getEntity(int id);
shared_ptr<Entity> removeEntity(int id); std::shared_ptr<Entity> removeEntity(int id);
virtual void removeEntities(vector<shared_ptr<Entity> > *list); // 4J Added override 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 setDataNoUpdate(int x, int y, int z, int data);
virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile, 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); virtual bool setTileNoUpdate(int x, int y, int z, int tile);
@ -87,7 +87,7 @@ public:
public: public:
void removeAllPendingEntityRemovals(); 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); virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f);

View file

@ -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_limiterCS);
InitializeCriticalSection(&m_tickNextTickCS); InitializeCriticalSection(&m_tickNextTickCS);
@ -289,7 +289,7 @@ void ServerLevel::updateSleepingPlayerList()
m_bAtLeastOnePlayerSleeping = false; m_bAtLeastOnePlayerSleeping = false;
AUTO_VAR(itEnd, players.end()); 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()) if (!(*it)->isSleeping())
{ {
@ -310,7 +310,7 @@ void ServerLevel::awakenAllPlayers()
m_bAtLeastOnePlayerSleeping = false; m_bAtLeastOnePlayerSleeping = false;
AUTO_VAR(itEnd, players.end()); 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()) if ((*it)->isSleeping())
{ {
@ -335,7 +335,7 @@ bool ServerLevel::allPlayersAreSleeping()
{ {
// all players are sleeping, but have they slept long enough? // all players are sleeping, but have they slept long enough?
AUTO_VAR(itEnd, players.end()); 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()); // System.out.println(player->entityId + ": " + player->getSleepTimer());
if (! (*it)->isSleepingLongEnough()) if (! (*it)->isSleepingLongEnough())
@ -467,7 +467,7 @@ void ServerLevel::tickTiles()
if (isRainingAt(x, y, z)) 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; lightningTime = 2;
} }
} }
@ -665,7 +665,7 @@ vector<TickNextTickData> *ServerLevel::fetchTicksInChunk(LevelChunk *chunk, bool
return results; 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))) 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); Level::tick(e, actual);
} }
@ -693,12 +693,12 @@ ChunkSource *ServerLevel::createChunkSource()
return cache; 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++) 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) if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 && te->y < y1 && te->z < z1)
{ {
result->push_back(te); result->push_back(te);
@ -707,7 +707,7 @@ vector<shared_ptr<TileEntity> > *ServerLevel::getTileEntitiesInRegion(int x0, in
return result; 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 // 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 // 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 ) 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 != NULL)
{ {
if( chest->isBonusChest ) if( chest->isBonusChest )
@ -948,11 +948,11 @@ void ServerLevel::saveLevelData()
savedDataStorage->save(); savedDataStorage->save();
} }
void ServerLevel::entityAdded(shared_ptr<Entity> e) void ServerLevel::entityAdded(std::shared_ptr<Entity> e)
{ {
Level::entityAdded(e); Level::entityAdded(e);
entitiesById[e->entityId] = e; entitiesById[e->entityId] = e;
vector<shared_ptr<Entity> > *es = e->getSubEntities(); vector<std::shared_ptr<Entity> > *es = e->getSubEntities();
if (es != NULL) if (es != NULL)
{ {
//for (int i = 0; i < es.length; i++) //for (int i = 0; i < es.length; i++)
@ -964,11 +964,11 @@ void ServerLevel::entityAdded(shared_ptr<Entity> e)
entityAddedExtra(e); // 4J added entityAddedExtra(e); // 4J added
} }
void ServerLevel::entityRemoved(shared_ptr<Entity> e) void ServerLevel::entityRemoved(std::shared_ptr<Entity> e)
{ {
Level::entityRemoved(e); Level::entityRemoved(e);
entitiesById.erase(e->entityId); entitiesById.erase(e->entityId);
vector<shared_ptr<Entity> > *es = e->getSubEntities(); vector<std::shared_ptr<Entity> > *es = e->getSubEntities();
if (es != NULL) if (es != NULL)
{ {
//for (int i = 0; i < es.length; i++) //for (int i = 0; i < es.length; i++)
@ -980,32 +980,32 @@ void ServerLevel::entityRemoved(shared_ptr<Entity> e)
entityRemovedExtra(e); // 4J added entityRemovedExtra(e); // 4J added
} }
shared_ptr<Entity> ServerLevel::getEntity(int id) std::shared_ptr<Entity> ServerLevel::getEntity(int id)
{ {
return entitiesById[id]; return entitiesById[id];
} }
bool ServerLevel::addGlobalEntity(shared_ptr<Entity> e) bool ServerLevel::addGlobalEntity(std::shared_ptr<Entity> e)
{ {
if (Level::addGlobalEntity(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 true;
} }
return false; 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); 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 // instead of calling super, we run the same explosion code here except
// we don't generate any particles // 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->fire = fire;
explosion->destroyBlocks = destroyBlocks; explosion->destroyBlocks = destroyBlocks;
explosion->explode(); explosion->explode();
@ -1016,10 +1016,10 @@ shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x,
explosion->toBlow.clear(); explosion->toBlow.clear();
} }
vector<shared_ptr<ServerPlayer> > sentTo; vector<std::shared_ptr<ServerPlayer> > sentTo;
for(AUTO_VAR(it, players.begin()); it != players.end(); ++it) 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; if (player->dimension != dimension->id) continue;
bool knockbackOnly = false; 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++ ) 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(); INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) 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); Vec3 *knockbackVec = explosion->getHitPlayerKnockback(player);
//app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n", knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z); //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 // 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 ); sentTo.push_back( player );
} }
} }
@ -1088,7 +1088,7 @@ void ServerLevel::runTileEvents()
if (doTileEvent(&(*it))) if (doTileEvent(&(*it)))
{ {
TileEventData te = *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(); tileEvents[runList].clear();
@ -1119,11 +1119,11 @@ void ServerLevel::tickWeather()
{ {
if (wasRaining) 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 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 // 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 its an item entity, and we've got to our capacity, delete the oldest
if( dynamic_pointer_cast<ItemEntity>(e) != NULL ) 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 // 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 ) 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 // 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 ) if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
{ {

View file

@ -41,7 +41,7 @@ private:
int activeTileEventsList; int activeTileEventsList;
public: public:
static void staticCtor(); 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(); ~ServerLevel();
void tick(); void tick();
Biome::MobSpawnerData *getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z); Biome::MobSpawnerData *getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z);
@ -65,15 +65,15 @@ public:
void tickEntities(); void tickEntities();
bool tickPendingTicks(bool force); bool tickPendingTicks(bool force);
vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove); vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
virtual void tick(shared_ptr<Entity> e, bool actual); virtual void tick(std::shared_ptr<Entity> e, bool actual);
void forceTick(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 AllPlayersAreSleeping() { return allPlayersSleeping;} // 4J added for a message to other players
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping;} bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping;}
protected: protected:
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
public: public:
vector<shared_ptr<TileEntity> > *getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1); vector<std::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); virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int id);
protected: protected:
virtual void initializeLevel(LevelSettings *settings); virtual void initializeLevel(LevelSettings *settings);
virtual void setInitialSpawn(LevelSettings *settings); virtual void setInitialSpawn(LevelSettings *settings);
@ -90,16 +90,16 @@ public:
private: private:
void saveLevelData(); 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 intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing function as this uses
protected: protected:
virtual void entityAdded(shared_ptr<Entity> e); virtual void entityAdded(std::shared_ptr<Entity> e);
virtual void entityRemoved(shared_ptr<Entity> e); virtual void entityRemoved(std::shared_ptr<Entity> e);
public: public:
shared_ptr<Entity> getEntity(int id); std::shared_ptr<Entity> getEntity(int id);
virtual bool addGlobalEntity(shared_ptr<Entity> e); virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
void broadcastEntityEvent(shared_ptr<Entity> e, uint8_t event); void broadcastEntityEvent(std::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); 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); virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1);
private: private:
@ -134,14 +134,14 @@ public:
int m_primedTntCount; int m_primedTntCount;
int m_fallingTileCount; int m_fallingTileCount;
CRITICAL_SECTION m_limiterCS; CRITICAL_SECTION m_limiterCS;
list< shared_ptr<Entity> > m_itemEntities; list< std::shared_ptr<Entity> > m_itemEntities;
list< shared_ptr<Entity> > m_hangingEntities; list< std::shared_ptr<Entity> > m_hangingEntities;
list< shared_ptr<Entity> > m_arrowEntities; list< std::shared_ptr<Entity> > m_arrowEntities;
list< shared_ptr<Entity> > m_experienceOrbEntities; list< std::shared_ptr<Entity> > m_experienceOrbEntities;
virtual bool addEntity(shared_ptr<Entity> e); virtual bool addEntity(std::shared_ptr<Entity> e);
void entityAddedExtra(shared_ptr<Entity> e); void entityAddedExtra(std::shared_ptr<Entity> e);
void entityRemovedExtra(shared_ptr<Entity> e); void entityRemovedExtra(std::shared_ptr<Entity> e);
virtual bool newPrimedTntAllowed(); virtual bool newPrimedTntAllowed();
virtual bool newFallingTileAllowed(); virtual bool newFallingTileAllowed();

View file

@ -33,22 +33,22 @@ void ServerLevelListener::allChanged()
{ {
} }
void ServerLevelListener::entityAdded(shared_ptr<Entity> entity) void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity)
{ {
MemSect(10); MemSect(10);
level->getTracker()->addEntity(entity); level->getTracker()->addEntity(entity);
MemSect(0); MemSect(0);
} }
void ServerLevelListener::entityRemoved(shared_ptr<Entity> entity) void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity)
{ {
level->getTracker()->removeEntity(entity); level->getTracker()->removeEntity(entity);
} }
// 4J added // 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); 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. // 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 // 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) 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. // 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 // 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); 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, shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch))); 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) 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 (ServerPlayer p : server->getPlayers()->players)
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it) 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; if (p == NULL || p->level != level || p->entityId == id) continue;
double xd = (double) x - p->x; double xd = (double) x - p->x;
double yd = (double) y - p->y; 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) 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)));
} }
} }
} }

View file

@ -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); // 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 addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za); // 4J added
virtual void allChanged(); virtual void allChanged();
virtual void entityAdded(shared_ptr<Entity> entity); virtual void entityAdded(std::shared_ptr<Entity> entity);
virtual void entityRemoved(shared_ptr<Entity> entity); virtual void entityRemoved(std::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 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(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 setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level); // 4J - added level param
virtual void skyColorChanged(); virtual void skyColorChanged();
virtual void tileChanged(int x, int y, int z); virtual void tileChanged(int x, int y, int z);
virtual void tileLightChanged(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 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); virtual void destroyTileProgress(int id, int x, int y, int z, int progress);
}; };

View file

@ -977,7 +977,7 @@ bool Minecraft::addLocalPlayer(int idx)
if(success) if(success)
{ {
app.DebugPrintf("Adding temp local player on pad %d\n", idx); app.DebugPrintf("Adding temp local player on pad %d\n", idx);
localplayers[idx] = shared_ptr<MultiplayerLocalPlayer>( new MultiplayerLocalPlayer(this, level, user, NULL ) ); localplayers[idx] = std::shared_ptr<MultiplayerLocalPlayer>( new MultiplayerLocalPlayer(this, level, user, NULL ) );
localgameModes[idx] = NULL; localgameModes[idx] = NULL;
updatePlayerViewportAssignments(); updatePlayerViewportAssignments();
@ -1025,7 +1025,7 @@ void Minecraft::addPendingLocalConnection(int idx, ClientConnection *connection)
m_pendingLocalConnections[idx] = connection; m_pendingLocalConnections[idx] = connection;
} }
shared_ptr<MultiplayerLocalPlayer> Minecraft::createExtraLocalPlayer(int idx, const wstring& name, int iPad, int iDimension, ClientConnection *clientConnection /*= NULL*/,MultiPlayerLevel *levelpassedin) std::shared_ptr<MultiplayerLocalPlayer> Minecraft::createExtraLocalPlayer(int idx, const wstring& name, int iPad, int iDimension, ClientConnection *clientConnection /*= NULL*/,MultiPlayerLevel *levelpassedin)
{ {
if( clientConnection == NULL) return nullptr; if( clientConnection == NULL) return nullptr;
@ -1141,7 +1141,7 @@ void Minecraft::removeLocalPlayerIdx(int idx)
{ {
if( getLevel( localplayers[idx]->dimension )->isClientSide ) if( getLevel( localplayers[idx]->dimension )->isClientSide )
{ {
shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[idx]; std::shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[idx];
( (MultiPlayerLevel *)getLevel( localplayers[idx]->dimension ) )->removeClientConnection(mplp->connection, true); ( (MultiPlayerLevel *)getLevel( localplayers[idx]->dimension ) )->removeClientConnection(mplp->connection, true);
delete mplp->connection; delete mplp->connection;
mplp->connection = NULL; mplp->connection = NULL;
@ -1163,7 +1163,7 @@ void Minecraft::removeLocalPlayerIdx(int idx)
} }
else if( m_pendingLocalConnections[idx] != NULL ) else if( m_pendingLocalConnections[idx] != NULL )
{ {
m_pendingLocalConnections[idx]->sendAndDisconnect( shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );; m_pendingLocalConnections[idx]->sendAndDisconnect( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );;
delete m_pendingLocalConnections[idx]; delete m_pendingLocalConnections[idx];
m_pendingLocalConnections[idx] = NULL; m_pendingLocalConnections[idx] = NULL;
g_NetworkManager.RemoveLocalPlayerByUserIndex(idx); g_NetworkManager.RemoveLocalPlayerByUserIndex(idx);
@ -1584,7 +1584,7 @@ void Minecraft::run_middle()
else else
{ {
// create the localplayer // create the localplayer
shared_ptr<Player> player = localplayers[i]; std::shared_ptr<Player> player = localplayers[i];
if( player == NULL) if( player == NULL)
{ {
player = createExtraLocalPlayer(i, (convStringToWstring( ProfileManager.GetGamertag(i) )).c_str(), i, level->dimension->id); player = createExtraLocalPlayer(i, (convStringToWstring( ProfileManager.GetGamertag(i) )).c_str(), i, level->dimension->id);
@ -1800,7 +1800,7 @@ void Minecraft::run_middle()
// if (pause) timer.a = 1; // if (pause) timer.a = 1;
PIXBeginNamedEvent(0,"Sound engine update"); PIXBeginNamedEvent(0,"Sound engine update");
soundEngine->tick((shared_ptr<Mob> *)localplayers, timer->a); soundEngine->tick((std::shared_ptr<Mob> *)localplayers, timer->a);
PIXEndNamedEvent(); PIXEndNamedEvent();
PIXBeginNamedEvent(0,"Light update"); PIXBeginNamedEvent(0,"Light update");
@ -2345,7 +2345,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
else else
{ {
// no hit result, but we may have something in our hand that we can do something with // no hit result, but we may have something in our hand that we can do something with
shared_ptr<ItemInstance> itemInstance = player->inventory->getSelected(); std::shared_ptr<ItemInstance> itemInstance = player->inventory->getSelected();
// 4J-JEV: Moved all this here to avoid having it in 3 different places. // 4J-JEV: Moved all this here to avoid having it in 3 different places.
if (itemInstance) if (itemInstance)
@ -2716,14 +2716,14 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
// is there an object in hand? // is there an object in hand?
if(player->inventory->IsHeldItem()) if(player->inventory->IsHeldItem())
{ {
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id; int iID=heldItem->getItem()->id;
switch(iID) switch(iID)
{ {
default: default:
{ {
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
{ {
@ -2740,7 +2740,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
// is there an object in hand? // is there an object in hand?
if(player->inventory->IsHeldItem()) if(player->inventory->IsHeldItem())
{ {
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id; int iID=heldItem->getItem()->id;
// It's an item // It's an item
@ -2752,7 +2752,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break; break;
default: default:
{ {
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
{ {
@ -2769,7 +2769,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
{ {
if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT;
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id; int iID=heldItem->getItem()->id;
// It's an item // It's an item
@ -2783,13 +2783,13 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
case Item::shears_Id: case Item::shears_Id:
{ {
if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT;
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
if(!animal->isBaby()) *piUse=IDS_TOOLTIPS_SHEAR; if(!animal->isBaby()) *piUse=IDS_TOOLTIPS_SHEAR;
} }
break; break;
default: default:
{ {
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
{ {
@ -2842,7 +2842,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
// is there an object in hand? // is there an object in hand?
if(player->inventory->IsHeldItem()) if(player->inventory->IsHeldItem())
{ {
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id; int iID=heldItem->getItem()->id;
if(iID==Item::coal->id) if(iID==Item::coal->id)
@ -2864,14 +2864,14 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT; if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT;
if(player->inventory->IsHeldItem()) if(player->inventory->IsHeldItem())
{ {
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id; int iID=heldItem->getItem()->id;
switch(iID) switch(iID)
{ {
case Item::dye_powder_Id: case Item::dye_powder_Id:
{ {
shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity); std::shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity);
// convert to tile-based color value (0 is white instead of black) // convert to tile-based color value (0 is white instead of black)
int newColor = ClothTile::getTileDataForItemAuxValue(heldItem->getAuxValue()); int newColor = ClothTile::getTileDataForItemAuxValue(heldItem->getAuxValue());
@ -2884,7 +2884,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break; break;
case Item::shears_Id: case Item::shears_Id:
{ {
shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity); std::shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity);
// can only shear a sheep that hasn't been sheared // can only shear a sheep that hasn't been sheared
if(!sheep->isSheared() ) if(!sheep->isSheared() )
@ -2896,7 +2896,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break; break;
default: default:
{ {
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
{ {
@ -2926,7 +2926,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
{ {
if(player->inventory->IsHeldItem()) if(player->inventory->IsHeldItem())
{ {
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected(); std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id; int iID=heldItem->getItem()->id;
switch(iID) switch(iID)
@ -2936,7 +2936,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break; break;
default: default:
{ {
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity); std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem)) if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
{ {
@ -2954,8 +2954,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
// can be tamed, fed, and made to sit/stand, or enter love mode // can be tamed, fed, and made to sit/stand, or enter love mode
{ {
int iID=-1; int iID=-1;
shared_ptr<ItemInstance> heldItem=nullptr; std::shared_ptr<ItemInstance> heldItem=nullptr;
shared_ptr<Wolf> wolf = dynamic_pointer_cast<Wolf>(hitResult->entity); std::shared_ptr<Wolf> wolf = dynamic_pointer_cast<Wolf>(hitResult->entity);
if(player->inventory->IsHeldItem()) if(player->inventory->IsHeldItem())
{ {
@ -3044,8 +3044,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
case eTYPE_OZELOT: case eTYPE_OZELOT:
{ {
int iID=-1; int iID=-1;
shared_ptr<ItemInstance> heldItem=nullptr; std::shared_ptr<ItemInstance> heldItem=nullptr;
shared_ptr<Ozelot> ocelot = dynamic_pointer_cast<Ozelot>(hitResult->entity); std::shared_ptr<Ozelot> ocelot = dynamic_pointer_cast<Ozelot>(hitResult->entity);
if(player->inventory->IsHeldItem()) if(player->inventory->IsHeldItem())
{ {
@ -3106,7 +3106,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
case eTYPE_PLAYER: case eTYPE_PLAYER:
{ {
// Fix for #58576 - TU6: Content: Gameplay: Hit button prompt is available when attacking a host who has "Invisible" option turned on // Fix for #58576 - TU6: Content: Gameplay: Hit button prompt is available when attacking a host who has "Invisible" option turned on
shared_ptr<Player> TargetPlayer = dynamic_pointer_cast<Player>(hitResult->entity); std::shared_ptr<Player> TargetPlayer = dynamic_pointer_cast<Player>(hitResult->entity);
if(!TargetPlayer->hasInvisiblePrivilege()) // This means they are invisible, not just that they have the privilege if(!TargetPlayer->hasInvisiblePrivilege()) // This means they are invisible, not just that they have the privilege
{ {
@ -3119,7 +3119,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break; break;
case eTYPE_ITEM_FRAME: case eTYPE_ITEM_FRAME:
{ {
shared_ptr<ItemFrame> itemFrame = dynamic_pointer_cast<ItemFrame>(hitResult->entity); std::shared_ptr<ItemFrame> itemFrame = dynamic_pointer_cast<ItemFrame>(hitResult->entity);
// is the frame occupied? // is the frame occupied?
if(itemFrame->getItem()!=NULL) if(itemFrame->getItem()!=NULL)
@ -3141,7 +3141,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break; break;
case eTYPE_VILLAGER: case eTYPE_VILLAGER:
{ {
shared_ptr<Villager> villager = dynamic_pointer_cast<Villager>(hitResult->entity); std::shared_ptr<Villager> villager = dynamic_pointer_cast<Villager>(hitResult->entity);
if (!villager->isBaby()) if (!villager->isBaby())
{ {
*piUse=IDS_TOOLTIPS_TRADE; *piUse=IDS_TOOLTIPS_TRADE;
@ -3151,8 +3151,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break; break;
case eTYPE_ZOMBIE: case eTYPE_ZOMBIE:
{ {
shared_ptr<Zombie> zomb = dynamic_pointer_cast<Zombie>(hitResult->entity); std::shared_ptr<Zombie> zomb = dynamic_pointer_cast<Zombie>(hitResult->entity);
shared_ptr<ItemInstance> heldItem=nullptr; std::shared_ptr<ItemInstance> heldItem=nullptr;
if(player->inventory->IsHeldItem()) if(player->inventory->IsHeldItem())
{ {
@ -3337,9 +3337,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_SPAWN_CREEPER)) && app.GetMobsDontAttackEnabled()) if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_SPAWN_CREEPER)) && app.GetMobsDontAttackEnabled())
{ {
//shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Creeper::_class->newInstance( level )); //std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Creeper::_class->newInstance( level ));
//shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level )); //std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(shared_ptr<Spider>(new Spider( level ))); std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(std::shared_ptr<Spider>(new Spider( level )));
mob->moveTo(player->x+1, player->y, player->z+1, level->random->nextFloat() * 360, 0); mob->moveTo(player->x+1, player->y, player->z+1, level->random->nextFloat() * 360, 0);
level->addEntity(mob); level->addEntity(mob);
} }
@ -3369,14 +3369,14 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_INVENTORY)) && gameMode->isInputAllowed(MINECRAFT_ACTION_INVENTORY)) if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_INVENTORY)) && gameMode->isInputAllowed(MINECRAFT_ACTION_INVENTORY))
{ {
shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player ); std::shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
ui.PlayUISFX(eSFX_Press); ui.PlayUISFX(eSFX_Press);
app.LoadInventoryMenu(iPad,player); app.LoadInventoryMenu(iPad,player);
} }
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_CRAFTING)) && gameMode->isInputAllowed(MINECRAFT_ACTION_CRAFTING)) if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_CRAFTING)) && gameMode->isInputAllowed(MINECRAFT_ACTION_CRAFTING))
{ {
shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player ); std::shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
// 4J-PB - reordered the if statement so creative mode doesn't bring up the crafting table // 4J-PB - reordered the if statement so creative mode doesn't bring up the crafting table
// Fix for #39014 - TU5: Creative Mode: Pressing X to access the creative menu while looking at a crafting table causes the crafting menu to display // Fix for #39014 - TU5: Creative Mode: Pressing X to access the creative menu while looking at a crafting table causes the crafting menu to display
@ -3440,7 +3440,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
if( selected || wheel != 0 || (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) ) if( selected || wheel != 0 || (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) )
{ {
wstring itemName = L""; wstring itemName = L"";
shared_ptr<ItemInstance> selectedItem = player->getSelectedItem(); std::shared_ptr<ItemInstance> selectedItem = player->getSelectedItem();
// Dropping items happens over network, so if we only have one then assume that we dropped it and should hide the item // Dropping items happens over network, so if we only have one then assume that we dropped it and should hide the item
int iCount=0; int iCount=0;
@ -3708,7 +3708,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
setLocalPlayerIdx(idx); setLocalPlayerIdx(idx);
gameRenderer->setupCamera(timer->a, i); gameRenderer->setupCamera(timer->a, i);
Camera::prepare(localplayers[idx], localplayers[idx]->ThirdPersonView() == 2); Camera::prepare(localplayers[idx], localplayers[idx]->ThirdPersonView() == 2);
shared_ptr<Mob> cameraEntity = cameraTargetPlayer; std::shared_ptr<Mob> cameraEntity = cameraTargetPlayer;
double xOff = cameraEntity->xOld + (cameraEntity->x - cameraEntity->xOld) * timer->a; double xOff = cameraEntity->xOld + (cameraEntity->x - cameraEntity->xOld) * timer->a;
double yOff = cameraEntity->yOld + (cameraEntity->y - cameraEntity->yOld) * timer->a; double yOff = cameraEntity->yOld + (cameraEntity->y - cameraEntity->yOld) * timer->a;
double zOff = cameraEntity->zOld + (cameraEntity->z - cameraEntity->zOld) * timer->a; double zOff = cameraEntity->zOld + (cameraEntity->z - cameraEntity->zOld) * timer->a;
@ -3834,7 +3834,7 @@ MultiPlayerLevel *Minecraft::getLevel(int dimension)
//} //}
// Also causing ambiguous call for some reason // Also causing ambiguous call for some reason
// as it is matching shared_ptr<Player> from the func below with bool from this one // as it is matching std::shared_ptr<Player> from the func below with bool from this one
//void Minecraft::setLevel(Level *level, const wstring& message, bool doForceStatsSave /*= true*/) //void Minecraft::setLevel(Level *level, const wstring& message, bool doForceStatsSave /*= true*/)
//{ //{
// setLevel(level, message, NULL, doForceStatsSave); // setLevel(level, message, NULL, doForceStatsSave);
@ -3848,7 +3848,7 @@ void Minecraft::forceaddLevel(MultiPlayerLevel *level)
else levels[0] = level; else levels[0] = level;
} }
void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_ptr<Player> forceInsertPlayer /*=NULL*/, bool doForceStatsSave /*=true*/, bool bPrimaryPlayerSignedOut /*=false*/) void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, std::shared_ptr<Player> forceInsertPlayer /*=NULL*/, bool doForceStatsSave /*=true*/, bool bPrimaryPlayerSignedOut /*=false*/)
{ {
EnterCriticalSection(&m_setLevelCS); EnterCriticalSection(&m_setLevelCS);
bool playerAdded = false; bool playerAdded = false;
@ -3913,7 +3913,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt
// Delete all the player objects // Delete all the player objects
for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
{ {
shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[idx]; std::shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[idx];
if(mplp != NULL && mplp->connection != NULL ) if(mplp != NULL && mplp->connection != NULL )
{ {
delete mplp->connection; delete mplp->connection;
@ -4160,7 +4160,7 @@ wstring Minecraft::gatherStats4()
void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId)
{ {
gameRenderer->DisableUpdateThread(); // 4J - don't do updating whilst we are adjusting the player & localplayer array gameRenderer->DisableUpdateThread(); // 4J - don't do updating whilst we are adjusting the player & localplayer array
shared_ptr<MultiplayerLocalPlayer> localPlayer = localplayers[iPad]; std::shared_ptr<MultiplayerLocalPlayer> localPlayer = localplayers[iPad];
level->validateSpawn(); level->validateSpawn();
level->removeAllPendingEntityRemovals(); level->removeAllPendingEntityRemovals();
@ -4171,7 +4171,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId)
level->removeEntity(localPlayer); level->removeEntity(localPlayer);
} }
shared_ptr<Player> oldPlayer = localPlayer; std::shared_ptr<Player> oldPlayer = localPlayer;
cameraTargetPlayer = nullptr; cameraTargetPlayer = nullptr;
// 4J-PB - copy and set the players xbox pad // 4J-PB - copy and set the players xbox pad
@ -4559,7 +4559,7 @@ bool mayUse = true;
if(button==1 && (player->isSleeping() && level != NULL && level->isClientSide)) if(button==1 && (player->isSleeping() && level != NULL && level->isClientSide))
{ {
shared_ptr<MultiplayerLocalPlayer> mplp = dynamic_pointer_cast<MultiplayerLocalPlayer>( player ); std::shared_ptr<MultiplayerLocalPlayer> mplp = dynamic_pointer_cast<MultiplayerLocalPlayer>( player );
if(mplp) mplp->StopSleeping(); if(mplp) mplp->StopSleeping();
@ -4608,7 +4608,7 @@ gameMode->startDestroyBlock(x, y, z, hitResult->f);
} }
else else
{ {
shared_ptr<ItemInstance> item = player->inventory->getSelected(); std::shared_ptr<ItemInstance> item = player->inventory->getSelected();
int oldCount = item != NULL ? item->count : 0; int oldCount = item != NULL ? item->count : 0;
if (gameMode->useItemOn(player, level, item, x, y, z, face)) if (gameMode->useItemOn(player, level, item, x, y, z, face))
{ {
@ -4634,7 +4634,7 @@ gameRenderer->itemInHandRenderer->itemPlaced();
if (mayUse && button == 1) if (mayUse && button == 1)
{ {
shared_ptr<ItemInstance> item = player->inventory->getSelected(); std::shared_ptr<ItemInstance> item = player->inventory->getSelected();
if (item != NULL) if (item != NULL)
{ {
if (gameMode->useItem(player, level, item)) if (gameMode->useItem(player, level, item))
@ -4721,7 +4721,7 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP
else if( ProfileManager.IsSignedInLive(iPad) && ProfileManager.AllowedToPlayMultiplayer(iPad) ) else if( ProfileManager.IsSignedInLive(iPad) && ProfileManager.AllowedToPlayMultiplayer(iPad) )
{ {
// create the local player for the iPad // create the local player for the iPad
shared_ptr<Player> player = pClass->localplayers[iPad]; std::shared_ptr<Player> player = pClass->localplayers[iPad];
if( player == NULL) if( player == NULL)
{ {
if( pClass->level->isClientSide ) if( pClass->level->isClientSide )
@ -4731,7 +4731,7 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP
else else
{ {
// create the local player for the iPad // create the local player for the iPad
shared_ptr<Player> player = pClass->localplayers[iPad]; std::shared_ptr<Player> player = pClass->localplayers[iPad];
if( player == NULL) if( player == NULL)
{ {
player = pClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pClass->level->dimension->id); player = pClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pClass->level->dimension->id);
@ -4802,7 +4802,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad)
else else
{ {
// create the local player for the iPad // create the local player for the iPad
shared_ptr<Player> player = pMinecraftClass->localplayers[iPad]; std::shared_ptr<Player> player = pMinecraftClass->localplayers[iPad];
if( player == NULL) if( player == NULL)
{ {
player = pMinecraftClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pMinecraftClass->level->dimension->id); player = pMinecraftClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pMinecraftClass->level->dimension->id);
@ -4831,7 +4831,7 @@ void Minecraft::tickAllConnections()
int oldIdx = getLocalPlayerIdx(); int oldIdx = getLocalPlayerIdx();
for(unsigned int i = 0; i < XUSER_MAX_COUNT; i++ ) for(unsigned int i = 0; i < XUSER_MAX_COUNT; i++ )
{ {
shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[i]; std::shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[i];
if( mplp && mplp->connection) if( mplp && mplp->connection)
{ {
setLocalPlayerIdx(i); setLocalPlayerIdx(i);

View file

@ -94,11 +94,11 @@ public:
MultiPlayerLevel *level; MultiPlayerLevel *level;
LevelRenderer *levelRenderer; LevelRenderer *levelRenderer;
shared_ptr<MultiplayerLocalPlayer> player; std::shared_ptr<MultiplayerLocalPlayer> player;
MultiPlayerLevelArray levels; MultiPlayerLevelArray levels;
shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT]; std::shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT];
MultiPlayerGameMode *localgameModes[XUSER_MAX_COUNT]; MultiPlayerGameMode *localgameModes[XUSER_MAX_COUNT];
int localPlayerIdx; int localPlayerIdx;
ItemInHandRenderer *localitemInHandRenderers[XUSER_MAX_COUNT]; ItemInHandRenderer *localitemInHandRenderers[XUSER_MAX_COUNT];
@ -114,7 +114,7 @@ public:
void addPendingLocalConnection(int idx, ClientConnection *connection); void addPendingLocalConnection(int idx, ClientConnection *connection);
void connectionDisconnected(int idx, DisconnectPacket::eDisconnectReason reason) { m_connectionFailed[idx] = true; m_connectionFailedReason[idx] = reason; } void connectionDisconnected(int idx, DisconnectPacket::eDisconnectReason reason) { m_connectionFailed[idx] = true; m_connectionFailedReason[idx] = reason; }
shared_ptr<MultiplayerLocalPlayer> createExtraLocalPlayer(int idx, const wstring& name, int pad, int iDimension, ClientConnection *clientConnection = NULL,MultiPlayerLevel *levelpassedin=NULL); std::shared_ptr<MultiplayerLocalPlayer> createExtraLocalPlayer(int idx, const wstring& name, int pad, int iDimension, ClientConnection *clientConnection = NULL,MultiPlayerLevel *levelpassedin=NULL);
void createPrimaryLocalPlayer(int iPad); void createPrimaryLocalPlayer(int iPad);
bool setLocalPlayerIdx(int idx); bool setLocalPlayerIdx(int idx);
int getLocalPlayerIdx(); int getLocalPlayerIdx();
@ -123,7 +123,7 @@ public:
void updatePlayerViewportAssignments(); void updatePlayerViewportAssignments();
int unoccupiedQuadrant; // 4J - added int unoccupiedQuadrant; // 4J - added
shared_ptr<Mob> cameraTargetPlayer; std::shared_ptr<Mob> cameraTargetPlayer;
ParticleEngine *particleEngine; ParticleEngine *particleEngine;
User *user; User *user;
wstring serverDomain; wstring serverDomain;
@ -277,7 +277,7 @@ public:
// 4J Stu - Added the doForceStatsSave param // 4J Stu - Added the doForceStatsSave param
//void setLevel(Level *level, bool doForceStatsSave = true); //void setLevel(Level *level, bool doForceStatsSave = true);
//void setLevel(Level *level, const wstring& message, bool doForceStatsSave = true); //void setLevel(Level *level, const wstring& message, bool doForceStatsSave = true);
void setLevel(MultiPlayerLevel *level, int message = -1, shared_ptr<Player> forceInsertPlayer = nullptr, bool doForceStatsSave = true,bool bPrimaryPlayerSignedOut=false); void setLevel(MultiPlayerLevel *level, int message = -1, std::shared_ptr<Player> forceInsertPlayer = nullptr, bool doForceStatsSave = true,bool bPrimaryPlayerSignedOut=false);
// 4J-PB - added to force in the 'other' level when the main player creates the level at game load time // 4J-PB - added to force in the 'other' level when the main player creates the level at game load time
void forceaddLevel(MultiPlayerLevel *level); void forceaddLevel(MultiPlayerLevel *level);
void prepareLevel(int title); // 4J - changed to public void prepareLevel(int title); // 4J - changed to public

View file

@ -398,7 +398,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
if( app.GetGameHostOption(eGameHostOption_BonusChest ) ) levelSettings->enableStartingBonusItems(); if( app.GetGameHostOption(eGameHostOption_BonusChest ) ) levelSettings->enableStartingBonusItems();
// 4J - temp - load existing level // 4J - temp - load existing level
shared_ptr<McRegionLevelStorage> storage = nullptr; std::shared_ptr<McRegionLevelStorage> storage = nullptr;
bool levelChunksNeedConverted = false; bool levelChunksNeedConverted = false;
if( initData->saveData != NULL ) if( initData->saveData != NULL )
{ {
@ -416,7 +416,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
levelChunksNeedConverted = true; levelChunksNeedConverted = true;
pSave->ConvertToLocalPlatform(); // check if we need to convert this file from PS3->PS4 pSave->ConvertToLocalPlatform(); // check if we need to convert this file from PS3->PS4
storage = shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(pSave, File(L"."), name, true)); storage = std::shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(pSave, File(L"."), name, true));
} }
else else
{ {
@ -441,9 +441,9 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
newFormatSave = new ConsoleSaveFileSplit( L"" ); newFormatSave = new ConsoleSaveFileSplit( L"" );
} }
storage = shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(newFormatSave, File(L"."), name, true)); storage = std::shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(newFormatSave, File(L"."), name, true));
#else #else
storage = shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(new ConsoleSaveFileOriginal( L"" ), File(L"."), name, true)); storage = std::shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(new ConsoleSaveFileOriginal( L"" ), File(L"."), name, true));
#endif #endif
} }
@ -1258,7 +1258,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
players->saveAll(Minecraft::GetInstance()->progressRenderer); players->saveAll(Minecraft::GetInstance()->progressRenderer);
} }
players->broadcastAll( shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) ); players->broadcastAll( std::shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) );
for (unsigned int j = 0; j < levels.length; j++) for (unsigned int j = 0; j < levels.length; j++)
{ {
@ -1269,7 +1269,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
ServerLevel *level = levels[levels.length - 1 - j]; ServerLevel *level = levels[levels.length - 1 - j];
level->save(true, Minecraft::GetInstance()->progressRenderer, (eAction==eXuiServerAction_AutoSaveGame)); level->save(true, Minecraft::GetInstance()->progressRenderer, (eAction==eXuiServerAction_AutoSaveGame));
players->broadcastAll( shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(33 + (j*33) ) ) ); players->broadcastAll( std::shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(33 + (j*33) ) ) );
} }
if( !s_bServerHalted ) if( !s_bServerHalted )
{ {
@ -1282,16 +1282,16 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
case eXuiServerAction_DropItem: case eXuiServerAction_DropItem:
// Find the player, and drop the id at their feet // Find the player, and drop the id at their feet
{ {
shared_ptr<ServerPlayer> player = players->players.at(0); std::shared_ptr<ServerPlayer> player = players->players.at(0);
size_t id = (size_t) param; size_t id = (size_t) param;
player->drop( shared_ptr<ItemInstance>( new ItemInstance(id, 1, 0 ) ) ); player->drop( std::shared_ptr<ItemInstance>( new ItemInstance(id, 1, 0 ) ) );
} }
break; break;
case eXuiServerAction_SpawnMob: case eXuiServerAction_SpawnMob:
{ {
shared_ptr<ServerPlayer> player = players->players.at(0); std::shared_ptr<ServerPlayer> player = players->players.at(0);
eINSTANCEOF factory = (eINSTANCEOF)((size_t)param); eINSTANCEOF factory = (eINSTANCEOF)((size_t)param);
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(EntityIO::newByEnumType(factory,player->level )); std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(EntityIO::newByEnumType(factory,player->level ));
mob->moveTo(player->x+1, player->y, player->z+1, player->level->random->nextFloat() * 360, 0); mob->moveTo(player->x+1, player->y, player->z+1, player->level->random->nextFloat() * 360, 0);
mob->setDespawnProtected(); // 4J added, default to being protected against despawning (has to be done after initial position is set) mob->setDespawnProtected(); // 4J added, default to being protected against despawning (has to be done after initial position is set)
player->level->addEntity(mob); player->level->addEntity(mob);
@ -1319,20 +1319,20 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
} }
break; break;
case eXuiServerAction_ServerSettingChanged_Gamertags: case eXuiServerAction_ServerSettingChanged_Gamertags:
players->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_OPTIONS, app.GetGameHostOption(eGameHostOption_Gamertags)) ) ); players->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_OPTIONS, app.GetGameHostOption(eGameHostOption_Gamertags)) ) );
break; break;
case eXuiServerAction_ServerSettingChanged_BedrockFog: case eXuiServerAction_ServerSettingChanged_BedrockFog:
players->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All)) ) ); players->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All)) ) );
break; break;
case eXuiServerAction_ServerSettingChanged_Difficulty: case eXuiServerAction_ServerSettingChanged_Difficulty:
players->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, Minecraft::GetInstance()->options->difficulty) ) ); players->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, Minecraft::GetInstance()->options->difficulty) ) );
break; break;
case eXuiServerAction_ExportSchematic: case eXuiServerAction_ExportSchematic:
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
app.EnterSaveNotificationSection(); app.EnterSaveNotificationSection();
//players->broadcastAll( shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) ); //players->broadcastAll( std::shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) );
if( !s_bServerHalted ) if( !s_bServerHalted )
{ {
@ -1370,7 +1370,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
pos->m_yRot, pos->m_elev pos->m_yRot, pos->m_elev
); );
shared_ptr<ServerPlayer> player = players->players.at(pos->player); std::shared_ptr<ServerPlayer> player = players->players.at(pos->player);
player->debug_setPosition( pos->m_camX, pos->m_camY, pos->m_camZ, player->debug_setPosition( pos->m_camX, pos->m_camY, pos->m_camZ,
pos->m_yRot, pos->m_elev ); pos->m_yRot, pos->m_elev );
@ -1427,14 +1427,14 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
void MinecraftServer::broadcastStartSavingPacket() void MinecraftServer::broadcastStartSavingPacket()
{ {
players->broadcastAll( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_SAVING, 0) ) );; players->broadcastAll( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_SAVING, 0) ) );;
} }
void MinecraftServer::broadcastStopSavingPacket() void MinecraftServer::broadcastStopSavingPacket()
{ {
if( !s_bServerHalted ) if( !s_bServerHalted )
{ {
players->broadcastAll( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_SAVING, 0) ) );; players->broadcastAll( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_SAVING, 0) ) );;
} }
} }
@ -1469,7 +1469,7 @@ void MinecraftServer::tick()
/* if(m_lastSentDifficulty != pMinecraft->options->difficulty) /* if(m_lastSentDifficulty != pMinecraft->options->difficulty)
{ {
m_lastSentDifficulty = pMinecraft->options->difficulty; m_lastSentDifficulty = pMinecraft->options->difficulty;
players->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, pMinecraft->options->difficulty) ) ); players->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, pMinecraft->options->difficulty) ) );
}*/ }*/
for (unsigned int i = 0; i < levels.length; i++) for (unsigned int i = 0; i < levels.length; i++)
@ -1489,7 +1489,7 @@ void MinecraftServer::tick()
if (tickCount % 20 == 0) if (tickCount % 20 == 0)
{ {
players->broadcastAll( shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime() ) ), level->dimension->id); players->broadcastAll( std::shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime() ) ), level->dimension->id);
} }
// #ifndef __PS3__ // #ifndef __PS3__
static __int64 stc = 0; static __int64 stc = 0;

File diff suppressed because it is too large Load diff

View file

@ -49,92 +49,92 @@ public:
~ClientConnection(); ~ClientConnection();
void tick(); void tick();
INetworkPlayer *getNetworkPlayer(); INetworkPlayer *getNetworkPlayer();
virtual void handleLogin(shared_ptr<LoginPacket> packet); virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
virtual void handleAddEntity(shared_ptr<AddEntityPacket> packet); virtual void handleAddEntity(std::shared_ptr<AddEntityPacket> packet);
virtual void handleAddExperienceOrb(shared_ptr<AddExperienceOrbPacket> packet); virtual void handleAddExperienceOrb(std::shared_ptr<AddExperienceOrbPacket> packet);
virtual void handleAddGlobalEntity(shared_ptr<AddGlobalEntityPacket> packet); virtual void handleAddGlobalEntity(std::shared_ptr<AddGlobalEntityPacket> packet);
virtual void handleAddPainting(shared_ptr<AddPaintingPacket> packet); virtual void handleAddPainting(std::shared_ptr<AddPaintingPacket> packet);
virtual void handleSetEntityMotion(shared_ptr<SetEntityMotionPacket> packet); virtual void handleSetEntityMotion(std::shared_ptr<SetEntityMotionPacket> packet);
virtual void handleSetEntityData(shared_ptr<SetEntityDataPacket> packet); virtual void handleSetEntityData(std::shared_ptr<SetEntityDataPacket> packet);
virtual void handleAddPlayer(shared_ptr<AddPlayerPacket> packet); virtual void handleAddPlayer(std::shared_ptr<AddPlayerPacket> packet);
virtual void handleTeleportEntity(shared_ptr<TeleportEntityPacket> packet); virtual void handleTeleportEntity(std::shared_ptr<TeleportEntityPacket> packet);
virtual void handleMoveEntity(shared_ptr<MoveEntityPacket> packet); virtual void handleMoveEntity(std::shared_ptr<MoveEntityPacket> packet);
virtual void handleRotateMob(shared_ptr<RotateHeadPacket> packet); virtual void handleRotateMob(std::shared_ptr<RotateHeadPacket> packet);
virtual void handleMoveEntitySmall(shared_ptr<MoveEntityPacketSmall> packet); virtual void handleMoveEntitySmall(std::shared_ptr<MoveEntityPacketSmall> packet);
virtual void handleRemoveEntity(shared_ptr<RemoveEntitiesPacket> packet); virtual void handleRemoveEntity(std::shared_ptr<RemoveEntitiesPacket> packet);
virtual void handleMovePlayer(shared_ptr<MovePlayerPacket> packet); virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
Random *random; Random *random;
// 4J Added // 4J Added
virtual void handleChunkVisibilityArea(shared_ptr<ChunkVisibilityAreaPacket> packet); virtual void handleChunkVisibilityArea(std::shared_ptr<ChunkVisibilityAreaPacket> packet);
virtual void handleChunkVisibility(shared_ptr<ChunkVisibilityPacket> packet); virtual void handleChunkVisibility(std::shared_ptr<ChunkVisibilityPacket> packet);
virtual void handleChunkTilesUpdate(shared_ptr<ChunkTilesUpdatePacket> packet); virtual void handleChunkTilesUpdate(std::shared_ptr<ChunkTilesUpdatePacket> packet);
virtual void handleBlockRegionUpdate(shared_ptr<BlockRegionUpdatePacket> packet); virtual void handleBlockRegionUpdate(std::shared_ptr<BlockRegionUpdatePacket> packet);
virtual void handleTileUpdate(shared_ptr<TileUpdatePacket> packet); virtual void handleTileUpdate(std::shared_ptr<TileUpdatePacket> packet);
virtual void handleDisconnect(shared_ptr<DisconnectPacket> packet); virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects); virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
void sendAndDisconnect(shared_ptr<Packet> packet); void sendAndDisconnect(std::shared_ptr<Packet> packet);
void send(shared_ptr<Packet> packet); void send(std::shared_ptr<Packet> packet);
virtual void handleTakeItemEntity(shared_ptr<TakeItemEntityPacket> packet); virtual void handleTakeItemEntity(std::shared_ptr<TakeItemEntityPacket> packet);
virtual void handleChat(shared_ptr<ChatPacket> packet); virtual void handleChat(std::shared_ptr<ChatPacket> packet);
virtual void handleAnimate(shared_ptr<AnimatePacket> packet); virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
virtual void handleEntityActionAtPosition(shared_ptr<EntityActionAtPositionPacket> packet); virtual void handleEntityActionAtPosition(std::shared_ptr<EntityActionAtPositionPacket> packet);
virtual void handlePreLogin(shared_ptr<PreLoginPacket> packet); virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
void close(); void close();
virtual void handleAddMob(shared_ptr<AddMobPacket> packet); virtual void handleAddMob(std::shared_ptr<AddMobPacket> packet);
virtual void handleSetTime(shared_ptr<SetTimePacket> packet); virtual void handleSetTime(std::shared_ptr<SetTimePacket> packet);
virtual void handleSetSpawn(shared_ptr<SetSpawnPositionPacket> packet); virtual void handleSetSpawn(std::shared_ptr<SetSpawnPositionPacket> packet);
virtual void handleRidePacket(shared_ptr<SetRidingPacket> packet); virtual void handleRidePacket(std::shared_ptr<SetRidingPacket> packet);
virtual void handleEntityEvent(shared_ptr<EntityEventPacket> packet); virtual void handleEntityEvent(std::shared_ptr<EntityEventPacket> packet);
private: private:
shared_ptr<Entity> getEntity(int entityId); std::shared_ptr<Entity> getEntity(int entityId);
wstring GetDisplayNameByGamertag(wstring gamertag); wstring GetDisplayNameByGamertag(wstring gamertag);
public: public:
virtual void handleSetHealth(shared_ptr<SetHealthPacket> packet); virtual void handleSetHealth(std::shared_ptr<SetHealthPacket> packet);
virtual void handleSetExperience(shared_ptr<SetExperiencePacket> packet); virtual void handleSetExperience(std::shared_ptr<SetExperiencePacket> packet);
virtual void handleRespawn(shared_ptr<RespawnPacket> packet); virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
virtual void handleExplosion(shared_ptr<ExplodePacket> packet); virtual void handleExplosion(std::shared_ptr<ExplodePacket> packet);
virtual void handleContainerOpen(shared_ptr<ContainerOpenPacket> packet); virtual void handleContainerOpen(std::shared_ptr<ContainerOpenPacket> packet);
virtual void handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> packet); virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
virtual void handleContainerAck(shared_ptr<ContainerAckPacket> packet); virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
virtual void handleContainerContent(shared_ptr<ContainerSetContentPacket> packet); virtual void handleContainerContent(std::shared_ptr<ContainerSetContentPacket> packet);
virtual void handleSignUpdate(shared_ptr<SignUpdatePacket> packet); virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
virtual void handleTileEntityData(shared_ptr<TileEntityDataPacket> packet); virtual void handleTileEntityData(std::shared_ptr<TileEntityDataPacket> packet);
virtual void handleContainerSetData(shared_ptr<ContainerSetDataPacket> packet); virtual void handleContainerSetData(std::shared_ptr<ContainerSetDataPacket> packet);
virtual void handleSetEquippedItem(shared_ptr<SetEquippedItemPacket> packet); virtual void handleSetEquippedItem(std::shared_ptr<SetEquippedItemPacket> packet);
virtual void handleContainerClose(shared_ptr<ContainerClosePacket> packet); virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
virtual void handleTileEvent(shared_ptr<TileEventPacket> packet); virtual void handleTileEvent(std::shared_ptr<TileEventPacket> packet);
virtual void handleTileDestruction(shared_ptr<TileDestructionPacket> packet); virtual void handleTileDestruction(std::shared_ptr<TileDestructionPacket> packet);
virtual bool canHandleAsyncPackets(); virtual bool canHandleAsyncPackets();
virtual void handleGameEvent(shared_ptr<GameEventPacket> gameEventPacket); virtual void handleGameEvent(std::shared_ptr<GameEventPacket> gameEventPacket);
virtual void handleComplexItemData(shared_ptr<ComplexItemDataPacket> packet); virtual void handleComplexItemData(std::shared_ptr<ComplexItemDataPacket> packet);
virtual void handleLevelEvent(shared_ptr<LevelEventPacket> packet); virtual void handleLevelEvent(std::shared_ptr<LevelEventPacket> packet);
virtual void handleAwardStat(shared_ptr<AwardStatPacket> packet); virtual void handleAwardStat(std::shared_ptr<AwardStatPacket> packet);
virtual void handleUpdateMobEffect(shared_ptr<UpdateMobEffectPacket> packet); virtual void handleUpdateMobEffect(std::shared_ptr<UpdateMobEffectPacket> packet);
virtual void handleRemoveMobEffect(shared_ptr<RemoveMobEffectPacket> packet); virtual void handleRemoveMobEffect(std::shared_ptr<RemoveMobEffectPacket> packet);
virtual bool isServerPacketListener(); virtual bool isServerPacketListener();
virtual void handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet); virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet);
virtual void handleKeepAlive(shared_ptr<KeepAlivePacket> packet); virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket); virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleSoundEvent(shared_ptr<LevelSoundPacket> packet); virtual void handleSoundEvent(std::shared_ptr<LevelSoundPacket> packet);
virtual void handleCustomPayload(shared_ptr<CustomPayloadPacket> customPayloadPacket); virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
virtual Connection *getConnection(); virtual Connection *getConnection();
// 4J Added // 4J Added
virtual void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet); virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleTexture(shared_ptr<TexturePacket> packet); virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(shared_ptr<TextureAndGeometryPacket> packet); virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleUpdateProgress(shared_ptr<UpdateProgressPacket> packet); virtual void handleUpdateProgress(std::shared_ptr<UpdateProgressPacket> packet);
// 4J Added // 4J Added
static int HostDisconnectReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static int HostDisconnectReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static int ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
virtual void handleTextureChange(shared_ptr<TextureChangePacket> packet); virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
virtual void handleTextureAndGeometryChange(shared_ptr<TextureAndGeometryChangePacket> packet); virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleUpdateGameRuleProgressPacket(shared_ptr<UpdateGameRuleProgressPacket> packet); virtual void handleUpdateGameRuleProgressPacket(std::shared_ptr<UpdateGameRuleProgressPacket> packet);
virtual void handleXZ(shared_ptr<XZPacket> packet); virtual void handleXZ(std::shared_ptr<XZPacket> packet);
void displayPrivilegeChanges(shared_ptr<MultiplayerLocalPlayer> player, unsigned int oldPrivileges); void displayPrivilegeChanges(std::shared_ptr<MultiplayerLocalPlayer> player, unsigned int oldPrivileges);
}; };

View file

@ -62,7 +62,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
// logger.info("Disconnecting " + getName() + ": " + reason); // logger.info("Disconnecting " + getName() + ": " + reason);
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick); fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick);
app.DebugPrintf("Pending connection disconnect: %d\n", reason ); app.DebugPrintf("Pending connection disconnect: %d\n", reason );
connection->send( shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ) ); connection->send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ) );
connection->sendAndQuit(); connection->sendAndQuit();
done = true; done = true;
// } catch (Exception e) { // } catch (Exception e) {
@ -70,7 +70,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
// } // }
} }
void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet) void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet)
{ {
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION) if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION)
{ {
@ -104,7 +104,7 @@ void PendingConnection::sendPreLoginResponse()
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers(); PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it) for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
{ {
shared_ptr<ServerPlayer> player = *it; std::shared_ptr<ServerPlayer> player = *it;
// If the offline Xuid is invalid but the online one is not then that's guest which we should ignore // If the offline Xuid is invalid but the online one is not then that's guest which we should ignore
// If the online Xuid is invalid but the offline one is not then we are definitely an offline game so dont care about UGC // If the online Xuid is invalid but the offline one is not then we are definitely an offline game so dont care about UGC
@ -129,16 +129,16 @@ void PendingConnection::sendPreLoginResponse()
if (false)// server->onlineMode) // 4J - removed if (false)// server->onlineMode) // 4J - removed
{ {
loginKey = L"TOIMPLEMENT"; // 4J - todo Long.toHexString(random.nextLong()); loginKey = L"TOIMPLEMENT"; // 4J - todo Long.toHexString(random.nextLong());
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(loginKey, ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex) ) ); connection->send( std::shared_ptr<PreLoginPacket>( new PreLoginPacket(loginKey, ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex) ) );
} }
else else
#endif #endif
{ {
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) ); connection->send( std::shared_ptr<PreLoginPacket>( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) );
} }
} }
void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet) void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet)
{ {
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n", packet->clientVersion); fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n", packet->clientVersion);
//name = packet->userName; //name = packet->userName;
@ -199,7 +199,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
} }
void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet) void PendingConnection::handleAcceptedLogin(std::shared_ptr<LoginPacket> packet)
{ {
if(packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion) if(packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion)
{ {
@ -212,7 +212,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
PlayerUID playerXuid = packet->m_offlineXuid; PlayerUID playerXuid = packet->m_offlineXuid;
if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid; if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid); std::shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
if (playerEntity != NULL) if (playerEntity != NULL)
{ {
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet); server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
@ -228,12 +228,12 @@ void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
done = true; done = true;
} }
void PendingConnection::handleGetInfo(shared_ptr<GetInfoPacket> packet) void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet)
{ {
//try { //try {
//String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers(); //String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers();
//connection->send(new DisconnectPacket(message)); //connection->send(new DisconnectPacket(message));
connection->send(shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) ); connection->send(std::shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) );
connection->sendAndQuit(); connection->sendAndQuit();
server->connection->removeSpamProtection(connection->getSocket()); server->connection->removeSpamProtection(connection->getSocket());
done = true; done = true;
@ -242,17 +242,17 @@ void PendingConnection::handleGetInfo(shared_ptr<GetInfoPacket> packet)
//} //}
} }
void PendingConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet) void PendingConnection::handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet)
{ {
// Ignore // Ignore
} }
void PendingConnection::onUnhandledPacket(shared_ptr<Packet> packet) void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet)
{ {
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket); disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
} }
void PendingConnection::send(shared_ptr<Packet> packet) void PendingConnection::send(std::shared_ptr<Packet> packet)
{ {
connection->send(packet); connection->send(packet);
} }

View file

@ -24,7 +24,7 @@ private:
MinecraftServer *server; MinecraftServer *server;
int _tick; int _tick;
wstring name; wstring name;
shared_ptr<LoginPacket> acceptedLogin; std::shared_ptr<LoginPacket> acceptedLogin;
wstring loginKey; wstring loginKey;
public: public:
@ -32,14 +32,14 @@ public:
~PendingConnection(); ~PendingConnection();
void tick(); void tick();
void disconnect(DisconnectPacket::eDisconnectReason reason); void disconnect(DisconnectPacket::eDisconnectReason reason);
virtual void handlePreLogin(shared_ptr<PreLoginPacket> packet); virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
virtual void handleLogin(shared_ptr<LoginPacket> packet); virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
virtual void handleAcceptedLogin(shared_ptr<LoginPacket> packet); virtual void handleAcceptedLogin(std::shared_ptr<LoginPacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects); virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
virtual void handleGetInfo(shared_ptr<GetInfoPacket> packet); virtual void handleGetInfo(std::shared_ptr<GetInfoPacket> packet);
virtual void handleKeepAlive(shared_ptr<KeepAlivePacket> packet); virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void onUnhandledPacket(shared_ptr<Packet> packet); virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
void send(shared_ptr<Packet> packet); void send(std::shared_ptr<Packet> packet);
wstring getName(); wstring getName();
virtual bool isServerPacketListener(); virtual bool isServerPacketListener();

View file

@ -44,12 +44,12 @@ void PlayerChunkMap::flagEntitiesToBeRemoved(unsigned int *flags, bool *flagToBe
{ {
for(AUTO_VAR(it,players.begin()); it != players.end(); it++) for(AUTO_VAR(it,players.begin()); it != players.end(); it++)
{ {
shared_ptr<ServerPlayer> serverPlayer = *it; std::shared_ptr<ServerPlayer> serverPlayer = *it;
serverPlayer->flagEntitiesToBeRemoved(flags, flagToBeRemoved); serverPlayer->flagEntitiesToBeRemoved(flags, flagToBeRemoved);
} }
} }
void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool sendPacket /*= true*/) void PlayerChunkMap::PlayerChunk::add(std::shared_ptr<ServerPlayer> player, bool sendPacket /*= true*/)
{ {
//app.DebugPrintf("--- Adding player to chunk x=%d\tz=%d\n",x, z); //app.DebugPrintf("--- Adding player to chunk x=%d\tz=%d\n",x, z);
if (find(players.begin(),players.end(),player) != players.end()) if (find(players.begin(),players.end(),player) != players.end())
@ -66,7 +66,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool send
player->seenChunks.insert(pos); player->seenChunks.insert(pos);
// 4J Added the sendPacket check. See PlayerChunkMap::add for the usage // 4J Added the sendPacket check. See PlayerChunkMap::add for the usage
if( sendPacket ) player->connection->send( shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, true) ) ); if( sendPacket ) player->connection->send( std::shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, true) ) );
players.push_back(player); players.push_back(player);
@ -77,7 +77,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool send
#endif #endif
} }
void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player) void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr<ServerPlayer> player)
{ {
PlayerChunkMap::PlayerChunk *toDelete = NULL; PlayerChunkMap::PlayerChunk *toDelete = NULL;
@ -121,7 +121,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
{ {
for( AUTO_VAR(it, players.begin()); it < players.end(); ++it ) for( AUTO_VAR(it, players.begin()); it < players.end(); ++it )
{ {
shared_ptr<ServerPlayer> currPlayer = *it; std::shared_ptr<ServerPlayer> currPlayer = *it;
INetworkPlayer *currNetPlayer = currPlayer->connection->getNetworkPlayer(); INetworkPlayer *currNetPlayer = currPlayer->connection->getNetworkPlayer();
if( currNetPlayer != NULL && currNetPlayer->IsSameSystem( thisNetPlayer ) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end() ) if( currNetPlayer != NULL && currNetPlayer->IsSameSystem( thisNetPlayer ) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end() )
{ {
@ -132,7 +132,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
if(noOtherPlayersFound) if(noOtherPlayersFound)
{ {
//wprintf(L"Sending ChunkVisiblity packet false for chunk (%d,%d) to player %ls\n", x, z, player->name.c_str() ); //wprintf(L"Sending ChunkVisiblity packet false for chunk (%d,%d) to player %ls\n", x, z, player->name.c_str() );
player->connection->send( shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, false) ) ); player->connection->send( std::shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, false) ) );
} }
} }
else else
@ -181,12 +181,12 @@ void PlayerChunkMap::PlayerChunk::prioritiseTileChanges()
prioritised = true; prioritised = true;
} }
void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet) void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<Packet> packet)
{ {
vector< shared_ptr<ServerPlayer> > sentTo; vector< std::shared_ptr<ServerPlayer> > sentTo;
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = players[i]; std::shared_ptr<ServerPlayer> player = players[i];
// 4J - don't send to a player we've already sent this data to that shares the same machine. TileUpdatePacket, // 4J - don't send to a player we've already sent this data to that shares the same machine. TileUpdatePacket,
// ChunkTilesUpdatePacket and SignUpdatePacket all used to limit themselves to sending once to each machine // ChunkTilesUpdatePacket and SignUpdatePacket all used to limit themselves to sending once to each machine
@ -205,7 +205,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet)
{ {
for(unsigned int j = 0; j < sentTo.size(); j++ ) 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(); INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
{ {
@ -244,7 +244,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet)
for( int i = 0; i < parent->level->getServer()->getPlayers()->players.size(); i++ ) for( int i = 0; i < parent->level->getServer()->getPlayers()->players.size(); i++ )
{ {
shared_ptr<ServerPlayer> player = parent->level->getServer()->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = parent->level->getServer()->getPlayers()->players[i];
// Don't worry about local players, they get all their updates through sharing level with the server anyway // Don't worry about local players, they get all their updates through sharing level with the server anyway
if ( player->connection == NULL ) continue; if ( player->connection == NULL ) continue;
if( player->connection->isLocal() ) continue; if( player->connection->isLocal() ) continue;
@ -267,7 +267,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet)
{ {
for(unsigned int j = 0; j < sentTo.size(); j++ ) 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(); INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
{ {
@ -299,7 +299,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
int x = pos.x * 16 + xChangeMin; int x = pos.x * 16 + xChangeMin;
int y = yChangeMin; int y = yChangeMin;
int z = pos.z * 16 + zChangeMin; int z = pos.z * 16 + zChangeMin;
broadcast( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) ); broadcast( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
if (level->isEntityTile(x, y, z)) if (level->isEntityTile(x, y, z))
{ {
broadcast(level->getTileEntity(x, y, z)); broadcast(level->getTileEntity(x, y, z));
@ -329,8 +329,8 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
// Block region update packets can only encode ys in a range of 1 - 256 // Block region update packets can only encode ys in a range of 1 - 256
if( ys > 256 ) ys = 256; if( ys > 256 ) ys = 256;
broadcast( shared_ptr<BlockRegionUpdatePacket>( new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level) ) ); broadcast( std::shared_ptr<BlockRegionUpdatePacket>( new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level) ) );
vector<shared_ptr<TileEntity> > *tes = level->getTileEntitiesInRegion(xp, yp, zp, xp + xs, yp + ys, zp + zs); vector<std::shared_ptr<TileEntity> > *tes = level->getTileEntitiesInRegion(xp, yp, zp, xp + xs, yp + ys, zp + zs);
for (unsigned int i = 0; i < tes->size(); i++) for (unsigned int i = 0; i < tes->size(); i++)
{ {
broadcast(tes->at(i)); broadcast(tes->at(i));
@ -342,7 +342,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
else else
{ {
// 4J As we only get here if changes is less than MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in the packet // 4J As we only get here if changes is less than MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in the packet
broadcast( shared_ptr<ChunkTilesUpdatePacket>( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, (uint8_t)changes, level) ) ); broadcast( std::shared_ptr<ChunkTilesUpdatePacket>( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, (uint8_t)changes, level) ) );
for (int i = 0; i < changes; i++) for (int i = 0; i < changes; i++)
{ {
int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15); int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15);
@ -361,11 +361,11 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
return didRegionUpdate; return didRegionUpdate;
} }
void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<TileEntity> te) void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<TileEntity> te)
{ {
if (te != NULL) if (te != NULL)
{ {
shared_ptr<Packet> p = te->getUpdatePacket(); std::shared_ptr<Packet> p = te->getUpdatePacket();
if (p != NULL) if (p != NULL)
{ {
broadcast(p); broadcast(p);
@ -458,7 +458,7 @@ PlayerChunkMap::PlayerChunk *PlayerChunkMap::getChunk(int x, int z, bool create)
// 4J - added. If a chunk exists, add a player to it straight away. If it doesn't exist, // 4J - added. If a chunk exists, add a player to it straight away. If it doesn't exist,
// queue a request for it to be created. // queue a request for it to be created.
void PlayerChunkMap::getChunkAndAddPlayer(int x, int z, shared_ptr<ServerPlayer> player) void PlayerChunkMap::getChunkAndAddPlayer(int x, int z, std::shared_ptr<ServerPlayer> player)
{ {
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32); __int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
AUTO_VAR(it, chunks.find(id)); AUTO_VAR(it, chunks.find(id));
@ -475,7 +475,7 @@ void PlayerChunkMap::getChunkAndAddPlayer(int x, int z, shared_ptr<ServerPlayer>
// 4J - added. If the chunk and player are in the queue to be added, remove from there. Otherwise // 4J - added. If the chunk and player are in the queue to be added, remove from there. Otherwise
// attempt to remove from main chunk map. // attempt to remove from main chunk map.
void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, shared_ptr<ServerPlayer> player) void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, std::shared_ptr<ServerPlayer> player)
{ {
for( AUTO_VAR(it, addRequests.begin()); it != addRequests.end(); it++ ) for( AUTO_VAR(it, addRequests.begin()); it != addRequests.end(); it++ )
{ {
@ -497,7 +497,7 @@ void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, shared_ptr<ServerPlay
} }
// 4J - added - actually create & add player to a playerchunk, if there is one queued for this player. // 4J - added - actually create & add player to a playerchunk, if there is one queued for this player.
void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player) void PlayerChunkMap::tickAddRequests(std::shared_ptr<ServerPlayer> player)
{ {
if( addRequests.size() ) if( addRequests.size() )
{ {
@ -533,7 +533,7 @@ void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
} }
} }
void PlayerChunkMap::broadcastTileUpdate(shared_ptr<Packet> packet, int x, int y, int z) void PlayerChunkMap::broadcastTileUpdate(std::shared_ptr<Packet> packet, int x, int y, int z)
{ {
int xc = x >> 4; int xc = x >> 4;
int zc = z >> 4; int zc = z >> 4;
@ -576,7 +576,7 @@ void PlayerChunkMap::prioritiseTileChanges(int x, int y, int z)
} }
} }
void PlayerChunkMap::add(shared_ptr<ServerPlayer> player) void PlayerChunkMap::add(std::shared_ptr<ServerPlayer> player)
{ {
static int direction[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, {0, -1} }; static int direction[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, {0, -1} };
@ -649,7 +649,7 @@ void PlayerChunkMap::add(shared_ptr<ServerPlayer> player)
} }
// CraftBukkit end // CraftBukkit end
player->connection->send( shared_ptr<ChunkVisibilityAreaPacket>( new ChunkVisibilityAreaPacket(minX, maxX, minZ, maxZ) ) ); player->connection->send( std::shared_ptr<ChunkVisibilityAreaPacket>( new ChunkVisibilityAreaPacket(minX, maxX, minZ, maxZ) ) );
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
getLevel()->cache->dontDrop(xc,zc); getLevel()->cache->dontDrop(xc,zc);
@ -659,7 +659,7 @@ void PlayerChunkMap::add(shared_ptr<ServerPlayer> player)
} }
void PlayerChunkMap::remove(shared_ptr<ServerPlayer> player) void PlayerChunkMap::remove(std::shared_ptr<ServerPlayer> player)
{ {
int xc = ((int) player->lastMoveX) >> 4; int xc = ((int) player->lastMoveX) >> 4;
int zc = ((int) player->lastMoveZ) >> 4; int zc = ((int) player->lastMoveZ) >> 4;
@ -702,7 +702,7 @@ bool PlayerChunkMap::chunkInRange(int x, int z, int xc, int zc)
// 4J - have changed this so that we queue requests to add the player to chunks if they // 4J - have changed this so that we queue requests to add the player to chunks if they
// need to be created, so that we aren't creating potentially 20 chunks per player per tick // need to be created, so that we aren't creating potentially 20 chunks per player per tick
void PlayerChunkMap::move(shared_ptr<ServerPlayer> player) void PlayerChunkMap::move(std::shared_ptr<ServerPlayer> player)
{ {
int xc = ((int) player->x) >> 4; int xc = ((int) player->x) >> 4;
int zc = ((int) player->z) >> 4; int zc = ((int) player->z) >> 4;
@ -744,7 +744,7 @@ int PlayerChunkMap::getMaxRange()
return radius * 16 - 16; return radius * 16 - 16;
} }
bool PlayerChunkMap::isPlayerIn(shared_ptr<ServerPlayer> player, int xChunk, int zChunk) bool PlayerChunkMap::isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk, int zChunk)
{ {
PlayerChunk *chunk = getChunk(xChunk, zChunk, false); PlayerChunk *chunk = getChunk(xChunk, zChunk, false);
@ -775,7 +775,7 @@ void PlayerChunkMap::setRadius(int newRadius)
PlayerList* players = level->getServer()->getPlayerList(); PlayerList* players = level->getServer()->getPlayerList();
for( int i = 0;i < players->players.size();i += 1 ) for( int i = 0;i < players->players.size();i += 1 )
{ {
shared_ptr<ServerPlayer> player = players->players[i]; std::shared_ptr<ServerPlayer> player = players->players[i];
if( player->level == level ) if( player->level == level )
{ {
int xc = ((int) player->x) >> 4; int xc = ((int) player->x) >> 4;

View file

@ -25,8 +25,8 @@ public:
{ {
public: public:
int x,z; int x,z;
shared_ptr<ServerPlayer> player; std::shared_ptr<ServerPlayer> player;
PlayerChunkAddRequest(int x, int z, shared_ptr<ServerPlayer> player ) : x(x), z(z), player(player) {} PlayerChunkAddRequest(int x, int z, std::shared_ptr<ServerPlayer> player ) : x(x), z(z), player(player) {}
}; };
class PlayerChunk class PlayerChunk
@ -34,7 +34,7 @@ public:
friend class PlayerChunkMap; friend class PlayerChunkMap;
private: private:
PlayerChunkMap *parent; // 4J added PlayerChunkMap *parent; // 4J added
vector<shared_ptr<ServerPlayer> > players; vector<std::shared_ptr<ServerPlayer> > players;
//int x, z; //int x, z;
ChunkPos pos; ChunkPos pos;
@ -51,25 +51,25 @@ public:
~PlayerChunk(); ~PlayerChunk();
// 4J Added sendPacket param so we can aggregate the initial send into one much smaller packet // 4J Added sendPacket param so we can aggregate the initial send into one much smaller packet
void add(shared_ptr<ServerPlayer> player, bool sendPacket = true); void add(std::shared_ptr<ServerPlayer> player, bool sendPacket = true);
void remove(shared_ptr<ServerPlayer> player); void remove(std::shared_ptr<ServerPlayer> player);
void tileChanged(int x, int y, int z); void tileChanged(int x, int y, int z);
void prioritiseTileChanges(); // 4J added void prioritiseTileChanges(); // 4J added
void broadcast(shared_ptr<Packet> packet); void broadcast(std::shared_ptr<Packet> packet);
bool broadcastChanges(bool allowRegionUpdate); // 4J - added parm bool broadcastChanges(bool allowRegionUpdate); // 4J - added parm
private: private:
void broadcast(shared_ptr<TileEntity> te); void broadcast(std::shared_ptr<TileEntity> te);
}; };
public: public:
vector<shared_ptr<ServerPlayer> > players; vector<std::shared_ptr<ServerPlayer> > players;
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
private: private:
unordered_map<__int64,PlayerChunk *,LongKeyHash,LongKeyEq> chunks; // 4J - was LongHashMap unordered_map<__int64,PlayerChunk *,LongKeyHash,LongKeyEq> chunks; // 4J - was LongHashMap
vector<PlayerChunk *> changedChunks; vector<PlayerChunk *> changedChunks;
vector<PlayerChunkAddRequest> addRequests; // 4J added vector<PlayerChunkAddRequest> addRequests; // 4J added
void tickAddRequests(shared_ptr<ServerPlayer> player); // 4J added void tickAddRequests(std::shared_ptr<ServerPlayer> player); // 4J added
ServerLevel *level; ServerLevel *level;
int radius; int radius;
@ -83,21 +83,21 @@ public:
bool hasChunk(int x, int z); bool hasChunk(int x, int z);
private: private:
PlayerChunk *getChunk(int x, int z, bool create); PlayerChunk *getChunk(int x, int z, bool create);
void getChunkAndAddPlayer(int x, int z, shared_ptr<ServerPlayer> player); // 4J added void getChunkAndAddPlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
void getChunkAndRemovePlayer(int x, int z, shared_ptr<ServerPlayer> player); // 4J added void getChunkAndRemovePlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
public: public:
void broadcastTileUpdate(shared_ptr<Packet> packet, int x, int y, int z); void broadcastTileUpdate(std::shared_ptr<Packet> packet, int x, int y, int z);
void tileChanged(int x, int y, int z); void tileChanged(int x, int y, int z);
bool isTrackingTile(int x, int y, int z); // 4J added bool isTrackingTile(int x, int y, int z); // 4J added
void prioritiseTileChanges(int x, int y, int z); // 4J added void prioritiseTileChanges(int x, int y, int z); // 4J added
void add(shared_ptr<ServerPlayer> player); void add(std::shared_ptr<ServerPlayer> player);
void remove(shared_ptr<ServerPlayer> player); void remove(std::shared_ptr<ServerPlayer> player);
private: private:
bool chunkInRange(int x, int z, int xc, int zc); bool chunkInRange(int x, int z, int xc, int zc);
public: public:
void move(shared_ptr<ServerPlayer> player); void move(std::shared_ptr<ServerPlayer> player);
int getMaxRange(); int getMaxRange();
bool isPlayerIn(shared_ptr<ServerPlayer> player, int xChunk, int zChunk); bool isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk, int zChunk);
static int convertChunkRangeToBlock(int radius); static int convertChunkRangeToBlock(int radius);
// AP added for Vita // AP added for Vita

View file

@ -34,7 +34,7 @@
Random PlayerConnection::random; Random PlayerConnection::random;
PlayerConnection::PlayerConnection(MinecraftServer *server, Connection *connection, shared_ptr<ServerPlayer> player) PlayerConnection::PlayerConnection(MinecraftServer *server, Connection *connection, std::shared_ptr<ServerPlayer> player)
{ {
// 4J - added initialisers // 4J - added initialisers
done = false; done = false;
@ -93,7 +93,7 @@ void PlayerConnection::tick()
lastKeepAliveTick = tickCount; lastKeepAliveTick = tickCount;
lastKeepAliveTime = System::nanoTime() / 1000000; lastKeepAliveTime = System::nanoTime() / 1000000;
lastKeepAliveId = random.nextInt(); lastKeepAliveId = random.nextInt();
send( shared_ptr<KeepAlivePacket>( new KeepAlivePacket(lastKeepAliveId) ) ); send( std::shared_ptr<KeepAlivePacket>( new KeepAlivePacket(lastKeepAliveId) ) );
} }
// if (!didTick) { // if (!didTick) {
// player->doTick(false); // player->doTick(false);
@ -123,17 +123,17 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
// 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system // 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system
server->getPlayers()->removePlayerFromReceiving( player ); server->getPlayers()->removePlayerFromReceiving( player );
send( shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) )); send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ));
connection->sendAndQuit(); connection->sendAndQuit();
// 4J-PB - removed, since it needs to be localised in the language the client is in // 4J-PB - removed, since it needs to be localised in the language the client is in
//server->players->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(L"§e" + player->name + L" left the game.") ) ); //server->players->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(L"§e" + player->name + L" left the game.") ) );
if(getWasKicked()) if(getWasKicked())
{ {
server->getPlayers()->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) ); server->getPlayers()->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) );
} }
else else
{ {
server->getPlayers()->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) ); server->getPlayers()->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) );
} }
server->getPlayers()->remove(player); server->getPlayers()->remove(player);
@ -141,12 +141,12 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
LeaveCriticalSection(&done_cs); LeaveCriticalSection(&done_cs);
} }
void PlayerConnection::handlePlayerInput(shared_ptr<PlayerInputPacket> packet) void PlayerConnection::handlePlayerInput(std::shared_ptr<PlayerInputPacket> packet)
{ {
player->setPlayerInput(packet->getXa(), packet->getYa(), packet->isJumping(), packet->isSneaking(), packet->getXRot(), packet->getYRot()); player->setPlayerInput(packet->getXa(), packet->getYa(), packet->isJumping(), packet->isSneaking(), packet->getXRot(), packet->getYRot());
} }
void PlayerConnection::handleMovePlayer(shared_ptr<MovePlayerPacket> packet) void PlayerConnection::handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet)
{ {
ServerLevel *level = server->getLevel(player->dimension); ServerLevel *level = server->getLevel(player->dimension);
@ -391,10 +391,10 @@ void PlayerConnection::teleport(double x, double y, double z, float yRot, float
player->absMoveTo(x, y, z, yRot, xRot); player->absMoveTo(x, y, z, yRot, xRot);
// 4J - note that 1.62 is added to the height here as the client connection that receives this will presume it represents y + heightOffset at that end // 4J - note that 1.62 is added to the height here as the client connection that receives this will presume it represents y + heightOffset at that end
// This is different to the way that height is sent back to the server, where it represents the bottom of the player bounding volume // This is different to the way that height is sent back to the server, where it represents the bottom of the player bounding volume
if(sendPacket) player->connection->send( shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(x, y + 1.62f, y, z, yRot, xRot, false, false) ) ); if(sendPacket) player->connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(x, y + 1.62f, y, z, yRot, xRot, false, false) ) );
} }
void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet) void PlayerConnection::handlePlayerAction(std::shared_ptr<PlayerActionPacket> packet)
{ {
ServerLevel *level = server->getLevel(player->dimension); ServerLevel *level = server->getLevel(player->dimension);
@ -442,19 +442,19 @@ void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
if (packet->action == PlayerActionPacket::START_DESTROY_BLOCK) if (packet->action == PlayerActionPacket::START_DESTROY_BLOCK)
{ {
if (zd > 16 || canEditSpawn) player->gameMode->startDestroyBlock(x, y, z, packet->face); if (zd > 16 || canEditSpawn) player->gameMode->startDestroyBlock(x, y, z, packet->face);
else player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) ); else player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
} }
else if (packet->action == PlayerActionPacket::STOP_DESTROY_BLOCK) else if (packet->action == PlayerActionPacket::STOP_DESTROY_BLOCK)
{ {
player->gameMode->stopDestroyBlock(x, y, z); player->gameMode->stopDestroyBlock(x, y, z);
server->getPlayers()->prioritiseTileChanges(x, y, z, level->dimension->id); // 4J added - make sure that the update packets for this get prioritised over other general world updates server->getPlayers()->prioritiseTileChanges(x, y, z, level->dimension->id); // 4J added - make sure that the update packets for this get prioritised over other general world updates
if (level->getTile(x, y, z) != 0) player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) ); if (level->getTile(x, y, z) != 0) player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
} }
else if (packet->action == PlayerActionPacket::ABORT_DESTROY_BLOCK) else if (packet->action == PlayerActionPacket::ABORT_DESTROY_BLOCK)
{ {
player->gameMode->abortDestroyBlock(x, y, z); player->gameMode->abortDestroyBlock(x, y, z);
if (level->getTile(x, y, z) != 0) player->connection->send(shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level))); if (level->getTile(x, y, z) != 0) player->connection->send(std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level)));
} }
else if (packet->action == PlayerActionPacket::GET_UPDATED_BLOCK) else if (packet->action == PlayerActionPacket::GET_UPDATED_BLOCK)
{ {
@ -464,7 +464,7 @@ void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
double dist = xDist * xDist + yDist * yDist + zDist * zDist; double dist = xDist * xDist + yDist * yDist + zDist * zDist;
if (dist < 16 * 16) if (dist < 16 * 16)
{ {
player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) ); player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
} }
} }
@ -473,10 +473,10 @@ void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
} }
void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet) void PlayerConnection::handleUseItem(std::shared_ptr<UseItemPacket> packet)
{ {
ServerLevel *level = server->getLevel(player->dimension); ServerLevel *level = server->getLevel(player->dimension);
shared_ptr<ItemInstance> item = player->inventory->getSelected(); std::shared_ptr<ItemInstance> item = player->inventory->getSelected();
bool informClient = false; bool informClient = false;
int x = packet->getX(); int x = packet->getX();
int y = packet->getY(); int y = packet->getY();
@ -509,14 +509,14 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
} }
else else
{ {
//player->connection->send(shared_ptr<ChatPacket>(new ChatPacket("\u00A77Height limit for building is " + server->maxBuildHeight))); //player->connection->send(std::shared_ptr<ChatPacket>(new ChatPacket("\u00A77Height limit for building is " + server->maxBuildHeight)));
informClient = true; informClient = true;
} }
if (informClient) if (informClient)
{ {
player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) ); player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
if (face == 0) y--; if (face == 0) y--;
if (face == 1) y++; if (face == 1) y++;
@ -532,7 +532,7 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
// isn't what it is expecting. // isn't what it is expecting.
if( level->getTile(x,y,z) != Tile::pistonMovingPiece_Id ) if( level->getTile(x,y,z) != Tile::pistonMovingPiece_Id )
{ {
player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) ); player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
} }
} }
@ -554,7 +554,7 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
if (!ItemInstance::matches(player->inventory->getSelected(), packet->getItem())) if (!ItemInstance::matches(player->inventory->getSelected(), packet->getItem()))
{ {
send( shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(player->containerMenu->containerId, s->index, player->inventory->getSelected()) ) ); send( std::shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(player->containerMenu->containerId, s->index, player->inventory->getSelected()) ) );
} }
} }
@ -569,27 +569,27 @@ void PlayerConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
if( done ) return; if( done ) return;
// logger.info(player.name + " lost connection: " + reason); // logger.info(player.name + " lost connection: " + reason);
// 4J-PB - removed, since it needs to be localised in the language the client is in // 4J-PB - removed, since it needs to be localised in the language the client is in
//server->players->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(L"§e" + player->name + L" left the game.") ) ); //server->players->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(L"§e" + player->name + L" left the game.") ) );
if(getWasKicked()) if(getWasKicked())
{ {
server->getPlayers()->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) ); server->getPlayers()->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) );
} }
else else
{ {
server->getPlayers()->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) ); server->getPlayers()->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) );
} }
server->getPlayers()->remove(player); server->getPlayers()->remove(player);
done = true; done = true;
LeaveCriticalSection(&done_cs); LeaveCriticalSection(&done_cs);
} }
void PlayerConnection::onUnhandledPacket(shared_ptr<Packet> packet) void PlayerConnection::onUnhandledPacket(std::shared_ptr<Packet> packet)
{ {
// logger.warning(getClass() + " wasn't prepared to deal with a " + packet.getClass()); // logger.warning(getClass() + " wasn't prepared to deal with a " + packet.getClass());
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket); disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
} }
void PlayerConnection::send(shared_ptr<Packet> packet) void PlayerConnection::send(std::shared_ptr<Packet> packet)
{ {
if( connection->getSocket() != NULL ) if( connection->getSocket() != NULL )
{ {
@ -607,7 +607,7 @@ void PlayerConnection::send(shared_ptr<Packet> packet)
} }
// 4J Added // 4J Added
void PlayerConnection::queueSend(shared_ptr<Packet> packet) void PlayerConnection::queueSend(std::shared_ptr<Packet> packet)
{ {
if( connection->getSocket() != NULL ) if( connection->getSocket() != NULL )
{ {
@ -624,7 +624,7 @@ void PlayerConnection::queueSend(shared_ptr<Packet> packet)
} }
} }
void PlayerConnection::handleSetCarriedItem(shared_ptr<SetCarriedItemPacket> packet) void PlayerConnection::handleSetCarriedItem(std::shared_ptr<SetCarriedItemPacket> packet)
{ {
if (packet->slot < 0 || packet->slot >= Inventory::getSelectionSize()) if (packet->slot < 0 || packet->slot >= Inventory::getSelectionSize())
{ {
@ -634,7 +634,7 @@ void PlayerConnection::handleSetCarriedItem(shared_ptr<SetCarriedItemPacket> pac
player->inventory->selected = packet->slot; player->inventory->selected = packet->slot;
} }
void PlayerConnection::handleChat(shared_ptr<ChatPacket> packet) void PlayerConnection::handleChat(std::shared_ptr<ChatPacket> packet)
{ {
// 4J - TODO // 4J - TODO
#if 0 #if 0
@ -678,7 +678,7 @@ void PlayerConnection::handleCommand(const wstring& message)
#endif #endif
} }
void PlayerConnection::handleAnimate(shared_ptr<AnimatePacket> packet) void PlayerConnection::handleAnimate(std::shared_ptr<AnimatePacket> packet)
{ {
if (packet->action == AnimatePacket::SWING) if (packet->action == AnimatePacket::SWING)
{ {
@ -686,7 +686,7 @@ void PlayerConnection::handleAnimate(shared_ptr<AnimatePacket> packet)
} }
} }
void PlayerConnection::handlePlayerCommand(shared_ptr<PlayerCommandPacket> packet) void PlayerConnection::handlePlayerCommand(std::shared_ptr<PlayerCommandPacket> packet)
{ {
if (packet->action == PlayerCommandPacket::START_SNEAKING) if (packet->action == PlayerCommandPacket::START_SNEAKING)
{ {
@ -725,7 +725,7 @@ void PlayerConnection::setShowOnMaps(bool bVal)
player->setShowOnMaps(bVal); player->setShowOnMaps(bVal);
} }
void PlayerConnection::handleDisconnect(shared_ptr<DisconnectPacket> packet) void PlayerConnection::handleDisconnect(std::shared_ptr<DisconnectPacket> packet)
{ {
// 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system // 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system
server->getPlayers()->removePlayerFromReceiving( player ); server->getPlayers()->removePlayerFromReceiving( player );
@ -740,13 +740,13 @@ int PlayerConnection::countDelayedPackets()
void PlayerConnection::info(const wstring& string) void PlayerConnection::info(const wstring& string)
{ {
// 4J-PB - removed, since it needs to be localised in the language the client is in // 4J-PB - removed, since it needs to be localised in the language the client is in
//send( shared_ptr<ChatPacket>( new ChatPacket(L"§7" + string) ) ); //send( std::shared_ptr<ChatPacket>( new ChatPacket(L"§7" + string) ) );
} }
void PlayerConnection::warn(const wstring& string) void PlayerConnection::warn(const wstring& string)
{ {
// 4J-PB - removed, since it needs to be localised in the language the client is in // 4J-PB - removed, since it needs to be localised in the language the client is in
//send( shared_ptr<ChatPacket>( new ChatPacket(L"§9" + string) ) ); //send( std::shared_ptr<ChatPacket>( new ChatPacket(L"§9" + string) ) );
} }
wstring PlayerConnection::getConsoleName() wstring PlayerConnection::getConsoleName()
@ -754,10 +754,10 @@ wstring PlayerConnection::getConsoleName()
return player->name; return player->name;
} }
void PlayerConnection::handleInteract(shared_ptr<InteractPacket> packet) void PlayerConnection::handleInteract(std::shared_ptr<InteractPacket> packet)
{ {
ServerLevel *level = server->getLevel(player->dimension); ServerLevel *level = server->getLevel(player->dimension);
shared_ptr<Entity> target = level->getEntity(packet->target); std::shared_ptr<Entity> target = level->getEntity(packet->target);
// Fix for #8218 - Gameplay: Attacking zombies from a different level often results in no hits being registered // Fix for #8218 - Gameplay: Attacking zombies from a different level often results in no hits being registered
// 4J Stu - If the client says that we hit something, then agree with it. The canSee can fail here as it checks // 4J Stu - If the client says that we hit something, then agree with it. The canSee can fail here as it checks
@ -792,7 +792,7 @@ bool PlayerConnection::canHandleAsyncPackets()
return true; return true;
} }
void PlayerConnection::handleTexture(shared_ptr<TexturePacket> packet) void PlayerConnection::handleTexture(std::shared_ptr<TexturePacket> packet)
{ {
// Both PlayerConnection and ClientConnection should handle this mostly the same way // Both PlayerConnection and ClientConnection should handle this mostly the same way
@ -808,7 +808,7 @@ void PlayerConnection::handleTexture(shared_ptr<TexturePacket> packet)
if(dwBytes!=0) if(dwBytes!=0)
{ {
send( shared_ptr<TexturePacket>( new TexturePacket(packet->textureName,pbData,dwBytes) ) ); send( std::shared_ptr<TexturePacket>( new TexturePacket(packet->textureName,pbData,dwBytes) ) );
} }
else else
{ {
@ -826,7 +826,7 @@ void PlayerConnection::handleTexture(shared_ptr<TexturePacket> packet)
} }
} }
void PlayerConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPacket> packet) void PlayerConnection::handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet)
{ {
// Both PlayerConnection and ClientConnection should handle this mostly the same way // Both PlayerConnection and ClientConnection should handle this mostly the same way
@ -848,11 +848,11 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPac
{ {
if(pDLCSkinFile->getAdditionalBoxesCount()!=0) if(pDLCSkinFile->getAdditionalBoxesCount()!=0)
{ {
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pDLCSkinFile) ) ); send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pDLCSkinFile) ) );
} }
else else
{ {
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes) ) ); send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes) ) );
} }
} }
else else
@ -861,7 +861,7 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPac
vector<SKIN_BOX *> *pvSkinBoxes = app.GetAdditionalSkinBoxes(packet->dwSkinID); vector<SKIN_BOX *> *pvSkinBoxes = app.GetAdditionalSkinBoxes(packet->dwSkinID);
unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID);
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pvSkinBoxes,uiAnimOverrideBitmask) ) ); send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pvSkinBoxes,uiAnimOverrideBitmask) ) );
} }
} }
else else
@ -906,7 +906,7 @@ void PlayerConnection::handleTextureReceived(const wstring &textureName)
if(dwBytes!=0) if(dwBytes!=0)
{ {
send( shared_ptr<TexturePacket>( new TexturePacket(textureName,pbData,dwBytes) ) ); send( std::shared_ptr<TexturePacket>( new TexturePacket(textureName,pbData,dwBytes) ) );
m_texturesRequested.erase(it); m_texturesRequested.erase(it);
} }
} }
@ -927,7 +927,7 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa
{ {
if(pDLCSkinFile && (pDLCSkinFile->getAdditionalBoxesCount()!=0)) if(pDLCSkinFile && (pDLCSkinFile->getAdditionalBoxesCount()!=0))
{ {
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes,pDLCSkinFile) ) ); send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes,pDLCSkinFile) ) );
} }
else else
{ {
@ -936,14 +936,14 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa
vector<SKIN_BOX *> *pvSkinBoxes = app.GetAdditionalSkinBoxes(dwSkinID); vector<SKIN_BOX *> *pvSkinBoxes = app.GetAdditionalSkinBoxes(dwSkinID);
unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(dwSkinID);
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask) ) ); send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask) ) );
} }
m_texturesRequested.erase(it); m_texturesRequested.erase(it);
} }
} }
} }
void PlayerConnection::handleTextureChange(shared_ptr<TextureChangePacket> packet) void PlayerConnection::handleTextureChange(std::shared_ptr<TextureChangePacket> packet)
{ {
switch(packet->action) switch(packet->action)
{ {
@ -968,7 +968,7 @@ void PlayerConnection::handleTextureChange(shared_ptr<TextureChangePacket> packe
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str()); wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str());
#endif #endif
send(shared_ptr<TexturePacket>( new TexturePacket(packet->path,NULL,0) ) ); send(std::shared_ptr<TexturePacket>( new TexturePacket(packet->path,NULL,0) ) );
} }
} }
else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path))
@ -976,10 +976,10 @@ void PlayerConnection::handleTextureChange(shared_ptr<TextureChangePacket> packe
// Update the ref count on the memory texture data // Update the ref count on the memory texture data
app.AddMemoryTextureFile(packet->path,NULL,0); app.AddMemoryTextureFile(packet->path,NULL,0);
} }
server->getPlayers()->broadcastAll( shared_ptr<TextureChangePacket>( new TextureChangePacket(player,packet->action,packet->path) ), player->dimension ); server->getPlayers()->broadcastAll( std::shared_ptr<TextureChangePacket>( new TextureChangePacket(player,packet->action,packet->path) ), player->dimension );
} }
void PlayerConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeometryChangePacket> packet) void PlayerConnection::handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet)
{ {
player->setCustomSkin( app.getSkinIdFromPath( packet->path ) ); player->setCustomSkin( app.getSkinIdFromPath( packet->path ) );
@ -995,7 +995,7 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeome
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str()); wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str());
#endif #endif
send(shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->path,NULL,0) ) ); send(std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->path,NULL,0) ) );
} }
} }
else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path)) else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path))
@ -1009,10 +1009,10 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeome
//app.SetAdditionalSkinBoxes(packet->dwSkinID,) //app.SetAdditionalSkinBoxes(packet->dwSkinID,)
//DebugBreak(); //DebugBreak();
} }
server->getPlayers()->broadcastAll( shared_ptr<TextureAndGeometryChangePacket>( new TextureAndGeometryChangePacket(player,packet->path) ), player->dimension ); server->getPlayers()->broadcastAll( std::shared_ptr<TextureAndGeometryChangePacket>( new TextureAndGeometryChangePacket(player,packet->path) ), player->dimension );
} }
void PlayerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet) void PlayerConnection::handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet)
{ {
if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS) if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)
{ {
@ -1024,7 +1024,7 @@ void PlayerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
app.SetGameHostOption(eGameHostOption_FireSpreads, app.GetGameHostOption(packet->data,eGameHostOption_FireSpreads)); app.SetGameHostOption(eGameHostOption_FireSpreads, app.GetGameHostOption(packet->data,eGameHostOption_FireSpreads));
app.SetGameHostOption(eGameHostOption_TNT, app.GetGameHostOption(packet->data,eGameHostOption_TNT)); app.SetGameHostOption(eGameHostOption_TNT, app.GetGameHostOption(packet->data,eGameHostOption_TNT));
server->getPlayers()->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS,app.GetGameHostOption(eGameHostOption_All) ) ) ); server->getPlayers()->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS,app.GetGameHostOption(eGameHostOption_All) ) ) );
// Update the QoS data // Update the QoS data
g_NetworkManager.UpdateAndSetGameSessionData(); g_NetworkManager.UpdateAndSetGameSessionData();
@ -1032,7 +1032,7 @@ void PlayerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
} }
} }
void PlayerConnection::handleKickPlayer(shared_ptr<KickPlayerPacket> packet) void PlayerConnection::handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet)
{ {
INetworkPlayer *networkPlayer = getNetworkPlayer(); INetworkPlayer *networkPlayer = getNetworkPlayer();
if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator()) if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator())
@ -1041,12 +1041,12 @@ void PlayerConnection::handleKickPlayer(shared_ptr<KickPlayerPacket> packet)
} }
} }
void PlayerConnection::handleGameCommand(shared_ptr<GameCommandPacket> packet) void PlayerConnection::handleGameCommand(std::shared_ptr<GameCommandPacket> packet)
{ {
MinecraftServer::getInstance()->getCommandDispatcher()->performCommand(player, packet->command, packet->data); MinecraftServer::getInstance()->getCommandDispatcher()->performCommand(player, packet->command, packet->data);
} }
void PlayerConnection::handleClientCommand(shared_ptr<ClientCommandPacket> packet) void PlayerConnection::handleClientCommand(std::shared_ptr<ClientCommandPacket> packet)
{ {
if (packet->action == ClientCommandPacket::PERFORM_RESPAWN) if (packet->action == ClientCommandPacket::PERFORM_RESPAWN)
{ {
@ -1078,17 +1078,17 @@ void PlayerConnection::handleClientCommand(shared_ptr<ClientCommandPacket> packe
} }
} }
void PlayerConnection::handleRespawn(shared_ptr<RespawnPacket> packet) void PlayerConnection::handleRespawn(std::shared_ptr<RespawnPacket> packet)
{ {
} }
void PlayerConnection::handleContainerClose(shared_ptr<ContainerClosePacket> packet) void PlayerConnection::handleContainerClose(std::shared_ptr<ContainerClosePacket> packet)
{ {
player->doCloseContainer(); player->doCloseContainer();
} }
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
void PlayerConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> packet) void PlayerConnection::handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet)
{ {
if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_CARRIED ) if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_CARRIED )
{ {
@ -1098,7 +1098,7 @@ void PlayerConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket>
{ {
if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_INVENTORY && packet->slot >= 36 && packet->slot < 36 + 9) if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_INVENTORY && packet->slot >= 36 && packet->slot < 36 + 9)
{ {
shared_ptr<ItemInstance> lastItem = player->inventoryMenu->getSlot(packet->slot)->getItem(); std::shared_ptr<ItemInstance> lastItem = player->inventoryMenu->getSlot(packet->slot)->getItem();
if (packet->item != NULL) if (packet->item != NULL)
{ {
if (lastItem == NULL || lastItem->count < packet->item->count) if (lastItem == NULL || lastItem->count < packet->item->count)
@ -1124,16 +1124,16 @@ void PlayerConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket>
} }
#endif #endif
void PlayerConnection::handleContainerClick(shared_ptr<ContainerClickPacket> packet) void PlayerConnection::handleContainerClick(std::shared_ptr<ContainerClickPacket> packet)
{ {
if (player->containerMenu->containerId == packet->containerId && player->containerMenu->isSynched(player)) if (player->containerMenu->containerId == packet->containerId && player->containerMenu->isSynched(player))
{ {
shared_ptr<ItemInstance> clicked = player->containerMenu->clicked(packet->slotNum, packet->buttonNum, packet->quickKey?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, player); std::shared_ptr<ItemInstance> clicked = player->containerMenu->clicked(packet->slotNum, packet->buttonNum, packet->quickKey?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, player);
if (ItemInstance::matches(packet->item, clicked)) if (ItemInstance::matches(packet->item, clicked))
{ {
// Yep, you sure did click what you claimed to click! // Yep, you sure did click what you claimed to click!
player->connection->send( shared_ptr<ContainerAckPacket>( new ContainerAckPacket(packet->containerId, packet->uid, true) ) ); player->connection->send( std::shared_ptr<ContainerAckPacket>( new ContainerAckPacket(packet->containerId, packet->uid, true) ) );
player->ignoreSlotUpdateHack = true; player->ignoreSlotUpdateHack = true;
player->containerMenu->broadcastChanges(); player->containerMenu->broadcastChanges();
player->broadcastCarriedItem(); player->broadcastCarriedItem();
@ -1143,10 +1143,10 @@ void PlayerConnection::handleContainerClick(shared_ptr<ContainerClickPacket> pac
{ {
// No, you clicked the wrong thing! // No, you clicked the wrong thing!
expectedAcks[player->containerMenu->containerId] = packet->uid; expectedAcks[player->containerMenu->containerId] = packet->uid;
player->connection->send( shared_ptr<ContainerAckPacket>( new ContainerAckPacket(packet->containerId, packet->uid, false) ) ); player->connection->send( std::shared_ptr<ContainerAckPacket>( new ContainerAckPacket(packet->containerId, packet->uid, false) ) );
player->containerMenu->setSynched(player, false); player->containerMenu->setSynched(player, false);
vector<shared_ptr<ItemInstance> > items; vector<std::shared_ptr<ItemInstance> > items;
for (unsigned int i = 0; i < player->containerMenu->slots->size(); i++) for (unsigned int i = 0; i < player->containerMenu->slots->size(); i++)
{ {
items.push_back(player->containerMenu->slots->at(i)->getItem()); items.push_back(player->containerMenu->slots->at(i)->getItem());
@ -1159,7 +1159,7 @@ void PlayerConnection::handleContainerClick(shared_ptr<ContainerClickPacket> pac
} }
void PlayerConnection::handleContainerButtonClick(shared_ptr<ContainerButtonClickPacket> packet) void PlayerConnection::handleContainerButtonClick(std::shared_ptr<ContainerButtonClickPacket> packet)
{ {
if (player->containerMenu->containerId == packet->containerId && player->containerMenu->isSynched(player)) if (player->containerMenu->containerId == packet->containerId && player->containerMenu->isSynched(player))
{ {
@ -1168,12 +1168,12 @@ void PlayerConnection::handleContainerButtonClick(shared_ptr<ContainerButtonClic
} }
} }
void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotPacket> packet) void PlayerConnection::handleSetCreativeModeSlot(std::shared_ptr<SetCreativeModeSlotPacket> packet)
{ {
if (player->gameMode->isCreative()) if (player->gameMode->isCreative())
{ {
bool drop = packet->slotNum < 0; bool drop = packet->slotNum < 0;
shared_ptr<ItemInstance> item = packet->item; std::shared_ptr<ItemInstance> item = packet->item;
if(item != NULL && item->id == Item::map_Id) if(item != NULL && item->id == Item::map_Id)
{ {
@ -1189,7 +1189,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
#endif #endif
item->setAuxValue( player->level->getAuxValueForMap(player->getXuid(), player->dimension, centreXC, centreZC, mapScale) ); item->setAuxValue( player->level->getAuxValueForMap(player->getXuid(), player->dimension, centreXC, centreZC, mapScale) );
shared_ptr<MapItemSavedData> data = MapItem::getSavedData(item->getAuxValue(), player->level); std::shared_ptr<MapItemSavedData> data = MapItem::getSavedData(item->getAuxValue(), player->level);
// 4J Stu - We only have one map per player per dimension, so don't reset the one that they have // 4J Stu - We only have one map per player per dimension, so don't reset the one that they have
// when a new one is created // when a new one is created
wchar_t buf[64]; wchar_t buf[64];
@ -1197,9 +1197,9 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
std::wstring id = wstring(buf); std::wstring id = wstring(buf);
if( data == NULL ) if( data == NULL )
{ {
data = shared_ptr<MapItemSavedData>( new MapItemSavedData(id) ); data = std::shared_ptr<MapItemSavedData>( new MapItemSavedData(id) );
} }
player->level->setSavedData(id, (shared_ptr<SavedData> ) data); player->level->setSavedData(id, (std::shared_ptr<SavedData> ) data);
data->scale = mapScale; data->scale = mapScale;
// 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map // 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map
@ -1232,7 +1232,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
{ {
dropSpamTickCount += SharedConstants::TICKS_PER_SECOND; dropSpamTickCount += SharedConstants::TICKS_PER_SECOND;
// drop item // drop item
shared_ptr<ItemEntity> dropped = player->drop(item); std::shared_ptr<ItemEntity> dropped = player->drop(item);
if (dropped != NULL) if (dropped != NULL)
{ {
dropped->setShortLifeTime(); dropped->setShortLifeTime();
@ -1244,7 +1244,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
{ {
// 4J Stu - Maps need to have their aux value update, so the client should always be assumed to be wrong // 4J Stu - Maps need to have their aux value update, so the client should always be assumed to be wrong
// This is how the Java works, as the client also incorrectly predicts the auxvalue of the mapItem // This is how the Java works, as the client also incorrectly predicts the auxvalue of the mapItem
vector<shared_ptr<ItemInstance> > items; vector<std::shared_ptr<ItemInstance> > items;
for (unsigned int i = 0; i < player->inventoryMenu->slots->size(); i++) for (unsigned int i = 0; i < player->inventoryMenu->slots->size(); i++)
{ {
items.push_back(player->inventoryMenu->slots->at(i)->getItem()); items.push_back(player->inventoryMenu->slots->at(i)->getItem());
@ -1254,7 +1254,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
} }
} }
void PlayerConnection::handleContainerAck(shared_ptr<ContainerAckPacket> packet) void PlayerConnection::handleContainerAck(std::shared_ptr<ContainerAckPacket> packet)
{ {
AUTO_VAR(it, expectedAcks.find(player->containerMenu->containerId)); AUTO_VAR(it, expectedAcks.find(player->containerMenu->containerId));
@ -1264,18 +1264,18 @@ void PlayerConnection::handleContainerAck(shared_ptr<ContainerAckPacket> packet)
} }
} }
void PlayerConnection::handleSignUpdate(shared_ptr<SignUpdatePacket> packet) void PlayerConnection::handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet)
{ {
app.DebugPrintf("PlayerConnection::handleSignUpdate\n"); app.DebugPrintf("PlayerConnection::handleSignUpdate\n");
ServerLevel *level = server->getLevel(player->dimension); ServerLevel *level = server->getLevel(player->dimension);
if (level->hasChunkAt(packet->x, packet->y, packet->z)) if (level->hasChunkAt(packet->x, packet->y, packet->z))
{ {
shared_ptr<TileEntity> te = level->getTileEntity(packet->x, packet->y, packet->z); std::shared_ptr<TileEntity> te = level->getTileEntity(packet->x, packet->y, packet->z);
if (dynamic_pointer_cast<SignTileEntity>(te) != NULL) if (dynamic_pointer_cast<SignTileEntity>(te) != NULL)
{ {
shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te); std::shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te);
if (!ste->isEditable()) if (!ste->isEditable())
{ {
server->warn(L"Player " + player->name + L" just tried to change non-editable sign"); server->warn(L"Player " + player->name + L" just tried to change non-editable sign");
@ -1289,7 +1289,7 @@ void PlayerConnection::handleSignUpdate(shared_ptr<SignUpdatePacket> packet)
int x = packet->x; int x = packet->x;
int y = packet->y; int y = packet->y;
int z = packet->z; int z = packet->z;
shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te); std::shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
wstring lineText = packet->lines[i].substr(0,15); wstring lineText = packet->lines[i].substr(0,15);
@ -1303,7 +1303,7 @@ void PlayerConnection::handleSignUpdate(shared_ptr<SignUpdatePacket> packet)
} }
void PlayerConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet) void PlayerConnection::handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet)
{ {
if (packet->id == lastKeepAliveId) if (packet->id == lastKeepAliveId)
{ {
@ -1312,18 +1312,18 @@ void PlayerConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet)
} }
} }
void PlayerConnection::handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet) void PlayerConnection::handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet)
{ {
// Need to check that this player has permission to change each individual setting? // Need to check that this player has permission to change each individual setting?
INetworkPlayer *networkPlayer = getNetworkPlayer(); INetworkPlayer *networkPlayer = getNetworkPlayer();
if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator() ) if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator() )
{ {
shared_ptr<ServerPlayer> serverPlayer; std::shared_ptr<ServerPlayer> serverPlayer;
// Find the player being edited // Find the player being edited
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it) for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it)
{ {
shared_ptr<ServerPlayer> checkingPlayer = *it; std::shared_ptr<ServerPlayer> checkingPlayer = *it;
if(checkingPlayer->connection->getNetworkPlayer() != NULL && checkingPlayer->connection->getNetworkPlayer()->GetSmallId() == packet->m_networkSmallId) if(checkingPlayer->connection->getNetworkPlayer() != NULL && checkingPlayer->connection->getNetworkPlayer()->GetSmallId() == packet->m_networkSmallId)
{ {
serverPlayer = checkingPlayer; serverPlayer = checkingPlayer;
@ -1348,7 +1348,7 @@ void PlayerConnection::handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet)
#endif #endif
serverPlayer->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,Player::getPlayerGamePrivilege(packet->m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) ); serverPlayer->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,Player::getPlayerGamePrivilege(packet->m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) );
serverPlayer->gameMode->setGameModeForPlayer(gameType); serverPlayer->gameMode->setGameModeForPlayer(gameType);
serverPlayer->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, gameType->getId()) )); serverPlayer->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, gameType->getId()) ));
} }
else else
{ {
@ -1400,7 +1400,7 @@ void PlayerConnection::handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet)
} }
} }
server->getPlayers()->broadcastAll( shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( serverPlayer ) ) ); server->getPlayers()->broadcastAll( std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( serverPlayer ) ) );
} }
} }
} }
@ -1410,7 +1410,7 @@ bool PlayerConnection::isServerPacketListener()
return true; return true;
} }
void PlayerConnection::handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket) void PlayerConnection::handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket)
{ {
player->abilities.flying = playerAbilitiesPacket->isFlying() && player->abilities.mayfly; player->abilities.flying = playerAbilitiesPacket->isFlying() && player->abilities.mayfly;
} }
@ -1427,19 +1427,19 @@ void PlayerConnection::handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> p
// player.connection.send(new ChatAutoCompletePacket(result.toString())); // player.connection.send(new ChatAutoCompletePacket(result.toString()));
//} //}
//void handleClientInformation(shared_ptr<ClientInformationPacket> packet) //void handleClientInformation(std::shared_ptr<ClientInformationPacket> packet)
//{ //{
// player->updateOptions(packet); // player->updateOptions(packet);
//} //}
void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> customPayloadPacket) void PlayerConnection::handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket)
{ {
#if 0 #if 0
if (CustomPayloadPacket.CUSTOM_BOOK_PACKET.equals(customPayloadPacket.identifier)) if (CustomPayloadPacket.CUSTOM_BOOK_PACKET.equals(customPayloadPacket.identifier))
{ {
ByteArrayInputStream bais(customPayloadPacket->data); ByteArrayInputStream bais(customPayloadPacket->data);
DataInputStream input(&bais); DataInputStream input(&bais);
shared_ptr<ItemInstance> sentItem = Packet::readItem(input); std::shared_ptr<ItemInstance> sentItem = Packet::readItem(input);
if (!WritingBookItem.makeSureTagIsValid(sentItem.getTag())) if (!WritingBookItem.makeSureTagIsValid(sentItem.getTag()))
{ {
@ -1510,13 +1510,13 @@ void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
// 4J Added // 4J Added
void PlayerConnection::handleDebugOptions(shared_ptr<DebugOptionsPacket> packet) void PlayerConnection::handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet)
{ {
//Player player = dynamic_pointer_cast<Player>( player->shared_from_this() ); //Player player = dynamic_pointer_cast<Player>( player->shared_from_this() );
player->SetDebugOptions(packet->m_uiVal); player->SetDebugOptions(packet->m_uiVal);
} }
void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet) void PlayerConnection::handleCraftItem(std::shared_ptr<CraftItemPacket> packet)
{ {
int iRecipe = packet->recipe; int iRecipe = packet->recipe;
@ -1524,7 +1524,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
return; return;
Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); std::shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
if(app.DebugSettingsOn() && (player->GetDebugOptions()&(1L<<eDebugSetting_CraftAnything))) if(app.DebugSettingsOn() && (player->GetDebugOptions()&(1L<<eDebugSetting_CraftAnything)))
{ {
@ -1549,7 +1549,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
{ {
for(int j=0;j<pRecipeIngredientsRequired[iRecipe].iIngValA[i];j++) for(int j=0;j<pRecipeIngredientsRequired[iRecipe].iIngValA[i];j++)
{ {
shared_ptr<ItemInstance> ingItemInst = nullptr; std::shared_ptr<ItemInstance> ingItemInst = nullptr;
// do we need to remove a specific aux value? // do we need to remove a specific aux value?
if(pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]!=Recipes::ANY_AUX_VALUE) if(pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]!=Recipes::ANY_AUX_VALUE)
{ {
@ -1568,7 +1568,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
if (ingItemInst->getItem()->hasCraftingRemainingItem()) if (ingItemInst->getItem()->hasCraftingRemainingItem())
{ {
// replace item with remaining result // replace item with remaining result
player->inventory->add( shared_ptr<ItemInstance>( new ItemInstance(ingItemInst->getItem()->getCraftingRemainingItem()) ) ); player->inventory->add( std::shared_ptr<ItemInstance>( new ItemInstance(ingItemInst->getItem()->getCraftingRemainingItem()) ) );
} }
} }
@ -1586,7 +1586,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
{ {
// 4J Stu - Maps need to have their aux value update, so the client should always be assumed to be wrong // 4J Stu - Maps need to have their aux value update, so the client should always be assumed to be wrong
// This is how the Java works, as the client also incorrectly predicts the auxvalue of the mapItem // This is how the Java works, as the client also incorrectly predicts the auxvalue of the mapItem
vector<shared_ptr<ItemInstance> > items; vector<std::shared_ptr<ItemInstance> > items;
for (unsigned int i = 0; i < player->containerMenu->slots->size(); i++) for (unsigned int i = 0; i < player->containerMenu->slots->size(); i++)
{ {
items.push_back(player->containerMenu->slots->at(i)->getItem()); items.push_back(player->containerMenu->slots->at(i)->getItem());
@ -1625,7 +1625,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
} }
void PlayerConnection::handleTradeItem(shared_ptr<TradeItemPacket> packet) void PlayerConnection::handleTradeItem(std::shared_ptr<TradeItemPacket> packet)
{ {
if (player->containerMenu->containerId == packet->containerId) if (player->containerMenu->containerId == packet->containerId)
{ {
@ -1642,8 +1642,8 @@ void PlayerConnection::handleTradeItem(shared_ptr<TradeItemPacket> packet)
if(!activeRecipe->isDeprecated()) if(!activeRecipe->isDeprecated())
{ {
// Do we have the ingredients? // Do we have the ingredients?
shared_ptr<ItemInstance> buyAItem = activeRecipe->getBuyAItem(); std::shared_ptr<ItemInstance> buyAItem = activeRecipe->getBuyAItem();
shared_ptr<ItemInstance> buyBItem = activeRecipe->getBuyBItem(); std::shared_ptr<ItemInstance> buyBItem = activeRecipe->getBuyBItem();
int buyAMatches = player->inventory->countMatches(buyAItem); int buyAMatches = player->inventory->countMatches(buyAItem);
int buyBMatches = player->inventory->countMatches(buyBItem); int buyBMatches = player->inventory->countMatches(buyBItem);
@ -1656,7 +1656,7 @@ void PlayerConnection::handleTradeItem(shared_ptr<TradeItemPacket> packet)
player->inventory->removeResources(buyBItem); player->inventory->removeResources(buyBItem);
// Add the item we have purchased // Add the item we have purchased
shared_ptr<ItemInstance> result = activeRecipe->getSellItem()->copy(); std::shared_ptr<ItemInstance> result = activeRecipe->getSellItem()->copy();
// 4J JEV - Award itemsBought stat. // 4J JEV - Award itemsBought stat.
player->awardStat( player->awardStat(

View file

@ -25,7 +25,7 @@ public:
private: private:
MinecraftServer *server; MinecraftServer *server;
shared_ptr<ServerPlayer> player; std::shared_ptr<ServerPlayer> player;
int tickCount; int tickCount;
int aboveGroundTickCount; int aboveGroundTickCount;
@ -40,7 +40,7 @@ private:
bool m_bHasClientTickedOnce; bool m_bHasClientTickedOnce;
public: public:
PlayerConnection(MinecraftServer *server, Connection *connection, shared_ptr<ServerPlayer> player); PlayerConnection(MinecraftServer *server, Connection *connection, std::shared_ptr<ServerPlayer> player);
~PlayerConnection(); ~PlayerConnection();
void tick(); void tick();
void disconnect(DisconnectPacket::eDisconnectReason reason); void disconnect(DisconnectPacket::eDisconnectReason reason);
@ -50,32 +50,32 @@ private:
bool synched; bool synched;
public: public:
virtual void handlePlayerInput(shared_ptr<PlayerInputPacket> packet); virtual void handlePlayerInput(std::shared_ptr<PlayerInputPacket> packet);
virtual void handleMovePlayer(shared_ptr<MovePlayerPacket> packet); virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
void teleport(double x, double y, double z, float yRot, float xRot, bool sendPacket = true); // 4J Added sendPacket param void teleport(double x, double y, double z, float yRot, float xRot, bool sendPacket = true); // 4J Added sendPacket param
virtual void handlePlayerAction(shared_ptr<PlayerActionPacket> packet); virtual void handlePlayerAction(std::shared_ptr<PlayerActionPacket> packet);
virtual void handleUseItem(shared_ptr<UseItemPacket> packet); virtual void handleUseItem(std::shared_ptr<UseItemPacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects); virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
virtual void onUnhandledPacket(shared_ptr<Packet> packet); virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
void send(shared_ptr<Packet> packet); void send(std::shared_ptr<Packet> packet);
void queueSend(shared_ptr<Packet> packet); // 4J Added void queueSend(std::shared_ptr<Packet> packet); // 4J Added
virtual void handleSetCarriedItem(shared_ptr<SetCarriedItemPacket> packet); virtual void handleSetCarriedItem(std::shared_ptr<SetCarriedItemPacket> packet);
virtual void handleChat(shared_ptr<ChatPacket> packet); virtual void handleChat(std::shared_ptr<ChatPacket> packet);
private: private:
void handleCommand(const wstring& message); void handleCommand(const wstring& message);
public: public:
virtual void handleAnimate(shared_ptr<AnimatePacket> packet); virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
virtual void handlePlayerCommand(shared_ptr<PlayerCommandPacket> packet); virtual void handlePlayerCommand(std::shared_ptr<PlayerCommandPacket> packet);
virtual void handleDisconnect(shared_ptr<DisconnectPacket> packet); virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
int countDelayedPackets(); int countDelayedPackets();
virtual void info(const wstring& string); virtual void info(const wstring& string);
virtual void warn(const wstring& string); virtual void warn(const wstring& string);
virtual wstring getConsoleName(); virtual wstring getConsoleName();
virtual void handleInteract(shared_ptr<InteractPacket> packet); virtual void handleInteract(std::shared_ptr<InteractPacket> packet);
bool canHandleAsyncPackets(); bool canHandleAsyncPackets();
virtual void handleClientCommand(shared_ptr<ClientCommandPacket> packet); virtual void handleClientCommand(std::shared_ptr<ClientCommandPacket> packet);
virtual void handleRespawn(shared_ptr<RespawnPacket> packet); virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
virtual void handleContainerClose(shared_ptr<ContainerClosePacket> packet); virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
private: private:
unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks; unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
@ -83,38 +83,38 @@ private:
public: public:
// 4J Stu - Handlers only valid in debug mode // 4J Stu - Handlers only valid in debug mode
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
virtual void handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> packet); virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
#endif #endif
virtual void handleContainerClick(shared_ptr<ContainerClickPacket> packet); virtual void handleContainerClick(std::shared_ptr<ContainerClickPacket> packet);
virtual void handleContainerButtonClick(shared_ptr<ContainerButtonClickPacket> packet); virtual void handleContainerButtonClick(std::shared_ptr<ContainerButtonClickPacket> packet);
virtual void handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotPacket> packet); virtual void handleSetCreativeModeSlot(std::shared_ptr<SetCreativeModeSlotPacket> packet);
virtual void handleContainerAck(shared_ptr<ContainerAckPacket> packet); virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
virtual void handleSignUpdate(shared_ptr<SignUpdatePacket> packet); virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
virtual void handleKeepAlive(shared_ptr<KeepAlivePacket> packet); virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet); // 4J Added virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet); // 4J Added
virtual bool isServerPacketListener(); virtual bool isServerPacketListener();
virtual void handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket); virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleCustomPayload(shared_ptr<CustomPayloadPacket> customPayloadPacket); virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
// 4J Added // 4J Added
virtual void handleCraftItem(shared_ptr<CraftItemPacket> packet); virtual void handleCraftItem(std::shared_ptr<CraftItemPacket> packet);
virtual void handleTradeItem(shared_ptr<TradeItemPacket> packet); virtual void handleTradeItem(std::shared_ptr<TradeItemPacket> packet);
virtual void handleDebugOptions(shared_ptr<DebugOptionsPacket> packet); virtual void handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet);
virtual void handleTexture(shared_ptr<TexturePacket> packet); virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(shared_ptr<TextureAndGeometryPacket> packet); virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleTextureChange(shared_ptr<TextureChangePacket> packet); virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
virtual void handleTextureAndGeometryChange(shared_ptr<TextureAndGeometryChangePacket> packet); virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet); virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleKickPlayer(shared_ptr<KickPlayerPacket> packet); virtual void handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet);
virtual void handleGameCommand(shared_ptr<GameCommandPacket> packet); virtual void handleGameCommand(std::shared_ptr<GameCommandPacket> packet);
INetworkPlayer *getNetworkPlayer(); INetworkPlayer *getNetworkPlayer();
bool isLocal(); bool isLocal();
bool isGuest(); bool isGuest();
// 4J Added as we need to set this from outside sometimes // 4J Added as we need to set this from outside sometimes
void setPlayer(shared_ptr<ServerPlayer> player) { this->player = player; } void setPlayer(std::shared_ptr<ServerPlayer> player) { this->player = player; }
shared_ptr<ServerPlayer> getPlayer() { return player; } std::shared_ptr<ServerPlayer> getPlayer() { return player; }
// 4J Added to signal a disconnect from another thread // 4J Added to signal a disconnect from another thread
void closeOnTick() { m_bCloseOnTick = true; } void closeOnTick() { m_bCloseOnTick = true; }

View file

@ -72,7 +72,7 @@ PlayerList::~PlayerList()
DeleteCriticalSection(&m_closePlayersCS); DeleteCriticalSection(&m_closePlayersCS);
} }
void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer> player, shared_ptr<LoginPacket> packet) void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPlayer> player, std::shared_ptr<LoginPacket> packet)
{ {
bool newPlayer = load(player); bool newPlayer = load(player);
player->setLevel(server->getLevel(player->dimension)); player->setLevel(server->getLevel(player->dimension));
@ -127,8 +127,8 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
player->setCustomCape( packet->m_playerCapeId ); player->setCustomCape( packet->m_playerCapeId );
// 4J-JEV: Moved this here so we can send player-model texture and geometry data. // 4J-JEV: Moved this here so we can send player-model texture and geometry data.
shared_ptr<PlayerConnection> playerConnection = shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player)); 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 shared_ptr //player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use std::shared_ptr
if(newPlayer) if(newPlayer)
{ {
@ -143,7 +143,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
int centreZC = 0; int centreZC = 0;
#endif #endif
// 4J Added - Give every player a map the first time they join a server // 4J Added - Give every player a map the first time they join a server
player->inventory->setItem( 9, shared_ptr<ItemInstance>( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) ); player->inventory->setItem( 9, std::shared_ptr<ItemInstance>( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) );
if(app.getGameRuleDefinitions() != NULL) if(app.getGameRuleDefinitions() != NULL)
{ {
app.getGameRuleDefinitions()->postProcessPlayer(player); app.getGameRuleDefinitions()->postProcessPlayer(player);
@ -157,7 +157,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
#ifndef _CONTENT_PACKAGE #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()); wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl.c_str(), player->name.c_str());
#endif #endif
playerConnection->send(shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) ); playerConnection->send(std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) );
} }
} }
else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl)) else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl))
@ -173,7 +173,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
#ifndef _CONTENT_PACKAGE #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()); wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str());
#endif #endif
playerConnection->send(shared_ptr<TexturePacket>( new TexturePacket(player->customTextureUrl2,NULL,0) ) ); playerConnection->send(std::shared_ptr<TexturePacket>( new TexturePacket(player->customTextureUrl2,NULL,0) ) );
} }
} }
else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2)) else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2))
@ -196,8 +196,8 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,player->gameMode->getGameModeForPlayer()->getId() ); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,player->gameMode->getGameModeForPlayer()->getId() );
} }
//shared_ptr<PlayerConnection> playerConnection = shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player)); //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 shared_ptr 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 // 4J Added to store UGC settings
playerConnection->m_friendsOnlyUGC = packet->m_friendsOnlyUGC; playerConnection->m_friendsOnlyUGC = packet->m_friendsOnlyUGC;
@ -209,19 +209,19 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
addPlayerToReceiving( player ); addPlayerToReceiving( player );
playerConnection->send( shared_ptr<LoginPacket>( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(), playerConnection->send( std::shared_ptr<LoginPacket>( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(),
(uint8_t) level->dimension->id, (uint8_t) level->getMaxBuildHeight(), (uint8_t) getMaxPlayers(), (uint8_t) level->dimension->id, (uint8_t) level->getMaxBuildHeight(), (uint8_t) getMaxPlayers(),
level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), (BYTE)playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(), level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), (BYTE)playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(),
level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) ); level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) );
playerConnection->send( shared_ptr<SetSpawnPositionPacket>( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) ); playerConnection->send( std::shared_ptr<SetSpawnPositionPacket>( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) );
playerConnection->send( shared_ptr<PlayerAbilitiesPacket>( new PlayerAbilitiesPacket(&player->abilities)) ); playerConnection->send( std::shared_ptr<PlayerAbilitiesPacket>( new PlayerAbilitiesPacket(&player->abilities)) );
delete spawnPos; delete spawnPos;
sendLevelInfo(player, level); sendLevelInfo(player, level);
// 4J-PB - removed, since it needs to be localised in the language the client is in // 4J-PB - removed, since it needs to be localised in the language the client is in
//server->players->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(L"§e" + playerEntity->name + L" joined the game.") ) ); //server->players->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(L"§e" + playerEntity->name + L" joined the game.") ) );
broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) ); broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) );
MemSect(14); MemSect(14);
add(player); add(player);
@ -231,13 +231,13 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
playerConnection->teleport(player->x, player->y, player->z, player->yRot, player->xRot); playerConnection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
server->getConnection()->addPlayerConnection(playerConnection); server->getConnection()->addPlayerConnection(playerConnection);
playerConnection->send( shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) ); playerConnection->send( std::shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
AUTO_VAR(activeEffects, player->getActiveEffects()); AUTO_VAR(activeEffects, player->getActiveEffects());
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it) for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it)
{ {
MobEffectInstance *effect = *it; MobEffectInstance *effect = *it;
playerConnection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) ); playerConnection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
} }
player->initMenu(); player->initMenu();
@ -249,7 +249,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
{ {
for(AUTO_VAR(it, players.begin()); it != players.end(); ++it) for(AUTO_VAR(it, players.begin()); it != players.end(); ++it)
{ {
shared_ptr<ServerPlayer> servPlayer = *it; std::shared_ptr<ServerPlayer> servPlayer = *it;
INetworkPlayer *checkPlayer = servPlayer->connection->getNetworkPlayer(); INetworkPlayer *checkPlayer = servPlayer->connection->getNetworkPlayer();
if(thisPlayer != checkPlayer && checkPlayer != NULL && thisPlayer->IsSameSystem( checkPlayer ) && servPlayer->wonGame ) if(thisPlayer != checkPlayer && checkPlayer != NULL && thisPlayer->IsSameSystem( checkPlayer ) && servPlayer->wonGame )
{ {
@ -265,7 +265,7 @@ void PlayerList::setLevel(ServerLevelArray levels)
playerIo = levels[0]->getLevelStorage()->getPlayerIO(); playerIo = levels[0]->getLevelStorage()->getPlayerIO();
} }
void PlayerList::changeDimension(shared_ptr<ServerPlayer> player, ServerLevel *from) void PlayerList::changeDimension(std::shared_ptr<ServerPlayer> player, ServerLevel *from)
{ {
ServerLevel *to = player->getLevel(); 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 // 4J Changed return val to bool to check if new player or loaded player
bool PlayerList::load(shared_ptr<ServerPlayer> player) bool PlayerList::load(std::shared_ptr<ServerPlayer> player)
{ {
return playerIo->load(player); return playerIo->load(player);
} }
void PlayerList::save(shared_ptr<ServerPlayer> player) void PlayerList::save(std::shared_ptr<ServerPlayer> player)
{ {
playerIo->save(player); playerIo->save(player);
} }
@ -295,7 +295,7 @@ void PlayerList::save(shared_ptr<ServerPlayer> player)
// Add this function to take some of the code from the PlayerList::add function with the fixes // 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 // 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 // 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<ServerPlayer> player) void PlayerList::validatePlayerSpawnPosition(std::shared_ptr<ServerPlayer> player)
{ {
// 4J Stu - Some adjustments to make sure the current players position is correct // 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 // Make sure that the player is on the ground, and in the centre x/z of the current column
@ -359,12 +359,12 @@ void PlayerList::validatePlayerSpawnPosition(shared_ptr<ServerPlayer> player)
} }
} }
void PlayerList::add(shared_ptr<ServerPlayer> player) void PlayerList::add(std::shared_ptr<ServerPlayer> player)
{ {
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, true, 1000) ) ); //broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, true, 1000) ) );
if( player->connection->getNetworkPlayer() ) if( player->connection->getNetworkPlayer() )
{ {
broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( player ) ) ); broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( player ) ) );
} }
players.push_back(player); players.push_back(player);
@ -386,36 +386,36 @@ void PlayerList::add(shared_ptr<ServerPlayer> player)
for (int i = 0; i < players.size(); i++) for (int i = 0; i < players.size(); i++)
{ {
shared_ptr<ServerPlayer> op = players.at(i); std::shared_ptr<ServerPlayer> op = players.at(i);
//player->connection->send(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) ); //player->connection->send(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
if( op->connection->getNetworkPlayer() ) if( op->connection->getNetworkPlayer() )
{ {
player->connection->send(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) ); player->connection->send(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
} }
} }
if(level->isAtLeastOnePlayerSleeping()) if(level->isAtLeastOnePlayerSleeping())
{ {
shared_ptr<ServerPlayer> firstSleepingPlayer = nullptr; std::shared_ptr<ServerPlayer> firstSleepingPlayer = nullptr;
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<ServerPlayer> thisPlayer = players[i]; std::shared_ptr<ServerPlayer> thisPlayer = players[i];
if(thisPlayer->isSleeping()) if(thisPlayer->isSleeping())
{ {
if(firstSleepingPlayer == NULL) firstSleepingPlayer = thisPlayer; if(firstSleepingPlayer == NULL) firstSleepingPlayer = thisPlayer;
thisPlayer->connection->send(shared_ptr<ChatPacket>( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep))); thisPlayer->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep)));
} }
} }
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep)));
} }
} }
void PlayerList::move(shared_ptr<ServerPlayer> player) void PlayerList::move(std::shared_ptr<ServerPlayer> player)
{ {
player->getLevel()->getChunkMap()->move(player); player->getLevel()->getChunkMap()->move(player);
} }
void PlayerList::remove(shared_ptr<ServerPlayer> player) void PlayerList::remove(std::shared_ptr<ServerPlayer> player)
{ {
save(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 //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<ServerPlayer> player)
{ {
players.erase(it); players.erase(it);
} }
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, false, 9999) ) ); //broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, false, 9999) ) );
removePlayerFromReceiving(player); removePlayerFromReceiving(player);
player->connection = nullptr; // Must remove reference to connection, or else there is a circular dependency player->connection = nullptr; // Must remove reference to connection, or else there is a circular dependency
@ -439,15 +439,15 @@ void PlayerList::remove(shared_ptr<ServerPlayer> player)
saveAll(NULL,false); saveAll(NULL,false);
} }
shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid) std::shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid)
{ {
if (players.size() >= maxPlayers) if (players.size() >= maxPlayers)
{ {
pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull); pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull);
return shared_ptr<ServerPlayer>(); return std::shared_ptr<ServerPlayer>();
} }
shared_ptr<ServerPlayer> player = shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) )); std::shared_ptr<ServerPlayer> player = std::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->gameMode->player = player; // 4J added as had to remove this assignment from ServerPlayer ctor
player->setXuid( xuid ); // 4J Added player->setXuid( xuid ); // 4J Added
player->setOnlineXuid( onlineXuid ); // 4J Added player->setOnlineXuid( onlineXuid ); // 4J Added
@ -469,7 +469,7 @@ shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendin
return player; return player;
} }
shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData) std::shared_ptr<ServerPlayer> PlayerList::respawn(std::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? bool isPrimary = canReceiveAllPackets(serverPlayer); // Is this the primary player in its current dimension?
@ -483,7 +483,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
for( unsigned int i = 0; i < players.size(); i++ ) for( unsigned int i = 0; i < players.size(); i++ )
{ {
shared_ptr<ServerPlayer> ep = players[i]; std::shared_ptr<ServerPlayer> ep = players[i];
if( ep == serverPlayer ) continue; if( ep == serverPlayer ) continue;
if( ep->dimension != oldDimension ) continue; if( ep->dimension != oldDimension ) continue;
@ -540,7 +540,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
PlayerUID playerXuid = serverPlayer->getXuid(); PlayerUID playerXuid = serverPlayer->getXuid();
PlayerUID playerOnlineXuid = serverPlayer->getOnlineXuid(); PlayerUID playerOnlineXuid = serverPlayer->getOnlineXuid();
shared_ptr<ServerPlayer> player = shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(serverPlayer->dimension), serverPlayer->name, new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension)))); std::shared_ptr<ServerPlayer> player = std::shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(serverPlayer->dimension), serverPlayer->name, new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension))));
player->restoreFrom(serverPlayer, keepAllPlayerData); player->restoreFrom(serverPlayer, keepAllPlayerData);
if (keepAllPlayerData) if (keepAllPlayerData)
{ {
@ -598,7 +598,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
} }
else else
{ {
player->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) ); player->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) );
} }
delete bedPosition; delete bedPosition;
} }
@ -611,7 +611,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
player->setPos(player->x, player->y + 1, player->z); player->setPos(player->x, player->y + 1, player->z);
} }
player->connection->send( shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, player->level->getSeed(), player->level->getMaxBuildHeight(), player->connection->send( std::shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, player->level->getSeed(), player->level->getMaxBuildHeight(),
player->gameMode->getGameModeForPlayer(), level->difficulty, level->getLevelData()->getGenerator(), player->gameMode->getGameModeForPlayer(), level->difficulty, level->getLevelData()->getGenerator(),
player->level->useNewSeaLevel(), player->entityId, level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale()) ) ); player->level->useNewSeaLevel(), player->entityId, level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale()) ) );
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot); player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
@ -623,7 +623,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
{ {
MobEffectInstance *effect = *it; MobEffectInstance *effect = *it;
player->connection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) ); player->connection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
} }
delete activeEffects; delete activeEffects;
player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID); player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID);
@ -654,7 +654,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
} }
void PlayerList::toggleDimension(shared_ptr<ServerPlayer> player, int targetDimension) void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player, int targetDimension)
{ {
int lastDimension = player->dimension; 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.
@ -666,7 +666,7 @@ void PlayerList::toggleDimension(shared_ptr<ServerPlayer> player, int targetDime
for( unsigned int i = 0; i < players.size(); i++ ) for( unsigned int i = 0; i < players.size(); i++ )
{ {
shared_ptr<ServerPlayer> ep = players[i]; std::shared_ptr<ServerPlayer> ep = players[i];
if( ep == player ) continue; if( ep == player ) continue;
if( ep->dimension != lastDimension ) continue; if( ep->dimension != lastDimension ) continue;
@ -728,7 +728,7 @@ void PlayerList::toggleDimension(shared_ptr<ServerPlayer> 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 // 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->flushEntitiesToRemove();
player->connection->send( shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, newLevel->getSeed(), newLevel->getMaxBuildHeight(), player->connection->send( std::shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, newLevel->getSeed(), newLevel->getMaxBuildHeight(),
player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(), player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(),
newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale()) ) ); newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale()) ) );
@ -816,7 +816,7 @@ void PlayerList::toggleDimension(shared_ptr<ServerPlayer> player, int targetDime
{ {
MobEffectInstance *effect = *it; MobEffectInstance *effect = *it;
player->connection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) ); player->connection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
} }
delete activeEffects; delete activeEffects;
player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID); player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID);
@ -835,11 +835,11 @@ void PlayerList::tick()
if (sendAllPlayerInfoIn < players.size()) if (sendAllPlayerInfoIn < players.size())
{ {
shared_ptr<ServerPlayer> op = players[sendAllPlayerInfoIn]; std::shared_ptr<ServerPlayer> op = players[sendAllPlayerInfoIn];
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) ); //broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
if( op->connection->getNetworkPlayer() ) if( op->connection->getNetworkPlayer() )
{ {
broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) ); broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
} }
} }
@ -849,11 +849,11 @@ void PlayerList::tick()
BYTE smallId = m_smallIdsToClose.front(); BYTE smallId = m_smallIdsToClose.front();
m_smallIdsToClose.pop_front(); m_smallIdsToClose.pop_front();
shared_ptr<ServerPlayer> player = nullptr; std::shared_ptr<ServerPlayer> player = nullptr;
for(unsigned int i = 0; i < players.size(); i++) for(unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<ServerPlayer> p = players.at(i); std::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 // 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 ) 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 //#ifdef _XBOX
PlayerUID xuid = selectedPlayer->GetUID(); PlayerUID xuid = selectedPlayer->GetUID();
// Kick this player from the game // Kick this player from the game
shared_ptr<ServerPlayer> player = nullptr; std::shared_ptr<ServerPlayer> player = nullptr;
for(unsigned int i = 0; i < players.size(); i++) for(unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<ServerPlayer> p = players.at(i); std::shared_ptr<ServerPlayer> p = players.at(i);
PlayerUID playersXuid = p->getOnlineXuid(); PlayerUID playersXuid = p->getOnlineXuid();
if (p != NULL && ProfileManager.AreXUIDSEqual(playersXuid, xuid ) ) 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 // 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->enableAllPlayerPrivileges( false );
player->connection->setWasKicked(); player->connection->setWasKicked();
player->connection->send( shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) )); player->connection->send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) ));
} }
//#endif //#endif
} }
@ -914,10 +914,10 @@ void PlayerList::tick()
{ {
for(unsigned int i = 0; i < receiveAllPlayers[dim].size(); ++i) for(unsigned int i = 0; i < receiveAllPlayers[dim].size(); ++i)
{ {
shared_ptr<ServerPlayer> currentPlayer = receiveAllPlayers[dim][i]; std::shared_ptr<ServerPlayer> currentPlayer = receiveAllPlayers[dim][i];
if(currentPlayer->removed) if(currentPlayer->removed)
{ {
shared_ptr<ServerPlayer> newPlayer = findAlivePlayerOnSystem(currentPlayer); std::shared_ptr<ServerPlayer> newPlayer = findAlivePlayerOnSystem(currentPlayer);
if(newPlayer != NULL) if(newPlayer != NULL)
{ {
receiveAllPlayers[dim][i] = newPlayer; 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); server->getLevel(dimension)->getChunkMap()->prioritiseTileChanges(x, y, z);
} }
void PlayerList::broadcastAll(shared_ptr<Packet> packet) void PlayerList::broadcastAll(std::shared_ptr<Packet> packet)
{ {
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = players[i]; std::shared_ptr<ServerPlayer> player = players[i];
player->connection->send(packet); player->connection->send(packet);
} }
} }
void PlayerList::broadcastAll(shared_ptr<Packet> packet, int dimension) void PlayerList::broadcastAll(std::shared_ptr<Packet> packet, int dimension)
{ {
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = players[i]; std::shared_ptr<ServerPlayer> player = players[i];
if (player->dimension == dimension) player->connection->send(packet); if (player->dimension == dimension) player->connection->send(packet);
} }
} }
@ -978,7 +978,7 @@ bool PlayerList::isOp(const wstring& name)
return false; return false;
} }
bool PlayerList::isOp(shared_ptr<ServerPlayer> player) bool PlayerList::isOp(std::shared_ptr<ServerPlayer> player)
{ {
bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled); bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled);
#ifdef _DEBUG_MENUS_ENABLED #ifdef _DEBUG_MENUS_ENABLED
@ -989,11 +989,11 @@ bool PlayerList::isOp(shared_ptr<ServerPlayer> player)
return isOp; return isOp;
} }
shared_ptr<ServerPlayer> PlayerList::getPlayer(const wstring& name) std::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++)
{ {
shared_ptr<ServerPlayer> p = players[i]; std::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 if (p->name == name) // 4J - used to be case insensitive (using equalsIgnoreCase) - imagine we'll be shifting to XUIDs anyway
{ {
return p; return p;
@ -1003,11 +1003,11 @@ shared_ptr<ServerPlayer> PlayerList::getPlayer(const wstring& name)
} }
// 4J Added // 4J Added
shared_ptr<ServerPlayer> PlayerList::getPlayer(PlayerUID uid) std::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++)
{ {
shared_ptr<ServerPlayer> p = players[i]; std::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 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; return p;
@ -1018,23 +1018,23 @@ shared_ptr<ServerPlayer> PlayerList::getPlayer(PlayerUID uid)
void PlayerList::sendMessage(const wstring& name, const wstring& message) void PlayerList::sendMessage(const wstring& name, const wstring& message)
{ {
shared_ptr<ServerPlayer> player = getPlayer(name); std::shared_ptr<ServerPlayer> player = getPlayer(name);
if (player != NULL) if (player != NULL)
{ {
player->connection->send( shared_ptr<ChatPacket>( new ChatPacket(message) ) ); player->connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(message) ) );
} }
} }
void PlayerList::broadcast(double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet) void PlayerList::broadcast(double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet)
{ {
broadcast(nullptr, x, y, z, range, dimension, packet); broadcast(nullptr, x, y, z, range, dimension, packet);
} }
void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet) void PlayerList::broadcast(std::shared_ptr<Player> except, double x, double y, double z, double range, int dimension, std::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 // 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 // machine either
vector< shared_ptr<ServerPlayer> > sentTo; vector< std::shared_ptr<ServerPlayer> > sentTo;
if( except != NULL ) if( except != NULL )
{ {
sentTo.push_back(dynamic_pointer_cast<ServerPlayer>(except)); sentTo.push_back(dynamic_pointer_cast<ServerPlayer>(except));
@ -1042,7 +1042,7 @@ void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<ServerPlayer> p = players[i]; std::shared_ptr<ServerPlayer> p = players[i];
if (p == except) continue; if (p == except) continue;
if (p->dimension != dimension) continue; if (p->dimension != dimension) continue;
@ -1059,7 +1059,7 @@ void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double
{ {
for(unsigned int j = 0; j < sentTo.size(); j++ ) 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(); INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
{ {
@ -1080,7 +1080,7 @@ void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double
if (xd * xd + yd * yd + zd * zd < range * range) if (xd * xd + yd * yd + zd * zd < range * range)
{ {
#if 0 // _DEBUG #if 0 // _DEBUG
shared_ptr<LevelSoundPacket> SoundPacket= dynamic_pointer_cast<LevelSoundPacket>(packet); std::shared_ptr<LevelSoundPacket> SoundPacket= dynamic_pointer_cast<LevelSoundPacket>(packet);
if(SoundPacket) if(SoundPacket)
{ {
@ -1099,10 +1099,10 @@ void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double
void PlayerList::broadcastToAllOps(const wstring& message) void PlayerList::broadcastToAllOps(const wstring& message)
{ {
shared_ptr<Packet> chatPacket = shared_ptr<ChatPacket>( new ChatPacket(message) ); std::shared_ptr<Packet> chatPacket = std::shared_ptr<ChatPacket>( new ChatPacket(message) );
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<ServerPlayer> p = players[i]; std::shared_ptr<ServerPlayer> p = players[i];
if (isOp(p->name)) if (isOp(p->name))
{ {
p->connection->send(chatPacket); p->connection->send(chatPacket);
@ -1110,9 +1110,9 @@ void PlayerList::broadcastToAllOps(const wstring& message)
} }
} }
bool PlayerList::sendTo(const wstring& name, shared_ptr<Packet> packet) bool PlayerList::sendTo(const wstring& name, std::shared_ptr<Packet> packet)
{ {
shared_ptr<ServerPlayer> player = getPlayer(name); std::shared_ptr<ServerPlayer> player = getPlayer(name);
if (player != NULL) if (player != NULL)
{ {
player->connection->send(packet); player->connection->send(packet);
@ -1154,28 +1154,28 @@ void PlayerList::reloadWhitelist()
{ {
} }
void PlayerList::sendLevelInfo(shared_ptr<ServerPlayer> player, ServerLevel *level) void PlayerList::sendLevelInfo(std::shared_ptr<ServerPlayer> player, ServerLevel *level)
{ {
player->connection->send( shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) ); player->connection->send( std::shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
if (level->isRaining()) if (level->isRaining())
{ {
player->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) ); player->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) );
} }
else else
{ {
// 4J Stu - Fix for #44836 - Customer Encountered: Out of Sync Weather [A-10] // 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 // 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<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) ); player->connection->send( std::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()) if((level->dimension->id==0) && level->getLevelData()->getHasStronghold())
{ {
player->connection->send( shared_ptr<XZPacket>( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) ); player->connection->send( std::shared_ptr<XZPacket>( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) );
} }
} }
void PlayerList::sendAllPlayerInfo(shared_ptr<ServerPlayer> player) void PlayerList::sendAllPlayerInfo(std::shared_ptr<ServerPlayer> player)
{ {
player->refreshContainer(player->inventoryMenu); player->refreshContainer(player->inventoryMenu);
player->resetSentInfo(); player->resetSentInfo();
@ -1218,7 +1218,7 @@ void PlayerList::setOverrideGameMode(GameType *gameMode)
this->overrideGameMode = gameMode; this->overrideGameMode = gameMode;
} }
void PlayerList::updatePlayerGameMode(shared_ptr<ServerPlayer> newPlayer, shared_ptr<ServerPlayer> oldPlayer, Level *level) void PlayerList::updatePlayerGameMode(std::shared_ptr<ServerPlayer> newPlayer, std::shared_ptr<ServerPlayer> oldPlayer, Level *level)
{ {
// reset the player's game mode (first pick from old, then copy level if // 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; this->allowCheatsForAllPlayers = allowCommands;
} }
shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(shared_ptr<ServerPlayer> player) std::shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(std::shared_ptr<ServerPlayer> player)
{ {
int dimIndex, playerDim; int dimIndex, playerDim;
dimIndex = playerDim = player->dimension; dimIndex = playerDim = player->dimension;
@ -1251,7 +1251,7 @@ shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(shared_ptr<ServerPl
{ {
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP) for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
{ {
shared_ptr<ServerPlayer> newPlayer = *itP; std::shared_ptr<ServerPlayer> newPlayer = *itP;
INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer(); INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer();
@ -1270,7 +1270,7 @@ shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(shared_ptr<ServerPl
return nullptr; return nullptr;
} }
void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool usePlayerDimension /*= true*/, int dimension /*= 0*/) void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player, bool usePlayerDimension /*= true*/, int dimension /*= 0*/)
{ {
int dimIndex, playerDim; int dimIndex, playerDim;
dimIndex = playerDim = usePlayerDimension ? player->dimension : dimension; dimIndex = playerDim = usePlayerDimension ? player->dimension : dimension;
@ -1297,7 +1297,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool
{ {
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP) for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
{ {
shared_ptr<ServerPlayer> newPlayer = *itP; std::shared_ptr<ServerPlayer> newPlayer = *itP;
INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer(); INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer();
@ -1324,7 +1324,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool
// Re-check all active players and make sure they have someone on their system to receive all packets // 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) for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
{ {
shared_ptr<ServerPlayer> newPlayer = *itP; std::shared_ptr<ServerPlayer> newPlayer = *itP;
INetworkPlayer *checkingPlayer = newPlayer->connection->getNetworkPlayer(); INetworkPlayer *checkingPlayer = newPlayer->connection->getNetworkPlayer();
if( checkingPlayer != NULL ) if( checkingPlayer != NULL )
@ -1335,7 +1335,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool
bool foundPrimary = false; bool foundPrimary = false;
for(AUTO_VAR(it, receiveAllPlayers[newPlayerDim].begin()); it != receiveAllPlayers[newPlayerDim].end(); ++it) for(AUTO_VAR(it, receiveAllPlayers[newPlayerDim].begin()); it != receiveAllPlayers[newPlayerDim].end(); ++it)
{ {
shared_ptr<ServerPlayer> primaryPlayer = *it; std::shared_ptr<ServerPlayer> primaryPlayer = *it;
INetworkPlayer *primPlayer = primaryPlayer->connection->getNetworkPlayer(); INetworkPlayer *primPlayer = primaryPlayer->connection->getNetworkPlayer();
if(primPlayer != NULL && checkingPlayer->IsSameSystem( primPlayer ) ) if(primPlayer != NULL && checkingPlayer->IsSameSystem( primPlayer ) )
{ {
@ -1355,7 +1355,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool
} }
} }
void PlayerList::addPlayerToReceiving(shared_ptr<ServerPlayer> player) void PlayerList::addPlayerToReceiving(std::shared_ptr<ServerPlayer> player)
{ {
int playerDim = 0; int playerDim = 0;
if( player->dimension == -1 ) playerDim = 1; if( player->dimension == -1 ) playerDim = 1;
@ -1380,7 +1380,7 @@ void PlayerList::addPlayerToReceiving(shared_ptr<ServerPlayer> player)
{ {
for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it) for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it)
{ {
shared_ptr<ServerPlayer> oldPlayer = *it; std::shared_ptr<ServerPlayer> oldPlayer = *it;
INetworkPlayer *checkingPlayer = oldPlayer->connection->getNetworkPlayer(); INetworkPlayer *checkingPlayer = oldPlayer->connection->getNetworkPlayer();
if(checkingPlayer != NULL && checkingPlayer->IsSameSystem( thisPlayer ) ) if(checkingPlayer != NULL && checkingPlayer->IsSameSystem( thisPlayer ) )
{ {
@ -1399,14 +1399,14 @@ void PlayerList::addPlayerToReceiving(shared_ptr<ServerPlayer> player)
} }
} }
bool PlayerList::canReceiveAllPackets(shared_ptr<ServerPlayer> player) bool PlayerList::canReceiveAllPackets(std::shared_ptr<ServerPlayer> player)
{ {
int playerDim = 0; int playerDim = 0;
if( player->dimension == -1 ) playerDim = 1; if( player->dimension == -1 ) playerDim = 1;
else if( player->dimension == 1) playerDim = 2; else if( player->dimension == 1) playerDim = 2;
for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it) for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it)
{ {
shared_ptr<ServerPlayer> newPlayer = *it; std::shared_ptr<ServerPlayer> newPlayer = *it;
if(newPlayer == player) if(newPlayer == player)
{ {
return true; return true;

View file

@ -22,7 +22,7 @@ private:
static const int SEND_PLAYER_INFO_INTERVAL = 20 * 10; // 4J - brought forward from 1.2.3 static const int SEND_PLAYER_INFO_INTERVAL = 20 * 10; // 4J - brought forward from 1.2.3
// public static Logger logger = Logger.getLogger("Minecraft"); // public static Logger logger = Logger.getLogger("Minecraft");
public: public:
vector<shared_ptr<ServerPlayer> > players; vector<std::shared_ptr<ServerPlayer> > players;
private: private:
MinecraftServer *server; MinecraftServer *server;
@ -51,60 +51,60 @@ private:
int sendAllPlayerInfoIn; int sendAllPlayerInfoIn;
// 4J Added to maintain which players in which dimensions can receive all packet types // 4J Added to maintain which players in which dimensions can receive all packet types
vector<shared_ptr<ServerPlayer> > receiveAllPlayers[3]; vector<std::shared_ptr<ServerPlayer> > receiveAllPlayers[3];
private: private:
shared_ptr<ServerPlayer> findAlivePlayerOnSystem(shared_ptr<ServerPlayer> currentPlayer); std::shared_ptr<ServerPlayer> findAlivePlayerOnSystem(std::shared_ptr<ServerPlayer> currentPlayer);
public: public:
void removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool usePlayerDimension = true, int dimension = 0); void removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player, bool usePlayerDimension = true, int dimension = 0);
void addPlayerToReceiving(shared_ptr<ServerPlayer> player); void addPlayerToReceiving(std::shared_ptr<ServerPlayer> player);
bool canReceiveAllPackets(shared_ptr<ServerPlayer> player); bool canReceiveAllPackets(std::shared_ptr<ServerPlayer> player);
public: public:
PlayerList(MinecraftServer *server); PlayerList(MinecraftServer *server);
~PlayerList(); ~PlayerList();
void placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer> player, shared_ptr<LoginPacket> packet); void placeNewPlayer(Connection *connection, std::shared_ptr<ServerPlayer> player, std::shared_ptr<LoginPacket> packet);
void setLevel(ServerLevelArray levels); void setLevel(ServerLevelArray levels);
void changeDimension(shared_ptr<ServerPlayer> player, ServerLevel *from); void changeDimension(std::shared_ptr<ServerPlayer> player, ServerLevel *from);
int getMaxRange(); int getMaxRange();
bool load(shared_ptr<ServerPlayer> player); // 4J Changed return val to bool to check if new player or loaded player bool load(std::shared_ptr<ServerPlayer> player); // 4J Changed return val to bool to check if new player or loaded player
protected: protected:
void save(shared_ptr<ServerPlayer> player); void save(std::shared_ptr<ServerPlayer> player);
public: public:
void validatePlayerSpawnPosition(shared_ptr<ServerPlayer> player); // 4J Added void validatePlayerSpawnPosition(std::shared_ptr<ServerPlayer> player); // 4J Added
void add(shared_ptr<ServerPlayer> player); void add(std::shared_ptr<ServerPlayer> player);
void move(shared_ptr<ServerPlayer> player); void move(std::shared_ptr<ServerPlayer> player);
void remove(shared_ptr<ServerPlayer> player); void remove(std::shared_ptr<ServerPlayer> player);
shared_ptr<ServerPlayer> getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID OnlineXuid); std::shared_ptr<ServerPlayer> getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID OnlineXuid);
shared_ptr<ServerPlayer> respawn(shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData); std::shared_ptr<ServerPlayer> respawn(std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData);
void toggleDimension(shared_ptr<ServerPlayer> player, int targetDimension); void toggleDimension(std::shared_ptr<ServerPlayer> player, int targetDimension);
void tick(); void tick();
bool isTrackingTile(int x, int y, int z, int dimension); // 4J added bool isTrackingTile(int x, int y, int z, int dimension); // 4J added
void prioritiseTileChanges(int x, int y, int z, int dimension); // 4J added void prioritiseTileChanges(int x, int y, int z, int dimension); // 4J added
void broadcastAll(shared_ptr<Packet> packet); void broadcastAll(std::shared_ptr<Packet> packet);
void broadcastAll(shared_ptr<Packet> packet, int dimension); void broadcastAll(std::shared_ptr<Packet> packet, int dimension);
wstring getPlayerNames(); wstring getPlayerNames();
public: public:
bool isWhiteListed(const wstring& name); bool isWhiteListed(const wstring& name);
bool isOp(const wstring& name); bool isOp(const wstring& name);
bool isOp(shared_ptr<ServerPlayer> player); // 4J Added bool isOp(std::shared_ptr<ServerPlayer> player); // 4J Added
shared_ptr<ServerPlayer> getPlayer(const wstring& name); std::shared_ptr<ServerPlayer> getPlayer(const wstring& name);
shared_ptr<ServerPlayer> getPlayer(PlayerUID uid); std::shared_ptr<ServerPlayer> getPlayer(PlayerUID uid);
void sendMessage(const wstring& name, const wstring& message); void sendMessage(const wstring& name, const wstring& message);
void broadcast(double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet); void broadcast(double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet);
void broadcast(shared_ptr<Player> except, double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet); void broadcast(std::shared_ptr<Player> except, double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet);
void broadcastToAllOps(const wstring& message); void broadcastToAllOps(const wstring& message);
bool sendTo(const wstring& name, shared_ptr<Packet> packet); bool sendTo(const wstring& name, std::shared_ptr<Packet> packet);
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps param // 4J Added ProgressListener *progressListener param and bDeleteGuestMaps param
void saveAll(ProgressListener *progressListener, bool bDeleteGuestMaps = false); void saveAll(ProgressListener *progressListener, bool bDeleteGuestMaps = false);
void whiteList(const wstring& playerName); void whiteList(const wstring& playerName);
void blackList(const wstring& playerName); void blackList(const wstring& playerName);
// Set<String> getWhiteList(); / 4J removed // Set<String> getWhiteList(); / 4J removed
void reloadWhitelist(); void reloadWhitelist();
void sendLevelInfo(shared_ptr<ServerPlayer> player, ServerLevel *level); void sendLevelInfo(std::shared_ptr<ServerPlayer> player, ServerLevel *level);
void sendAllPlayerInfo(shared_ptr<ServerPlayer> player); void sendAllPlayerInfo(std::shared_ptr<ServerPlayer> player);
int getPlayerCount(); int getPlayerCount();
int getPlayerCount(ServerLevel *level); // 4J Added int getPlayerCount(ServerLevel *level); // 4J Added
int getMaxPlayers(); int getMaxPlayers();
@ -113,7 +113,7 @@ public:
void setOverrideGameMode(GameType *gameMode); void setOverrideGameMode(GameType *gameMode);
private: private:
void updatePlayerGameMode(shared_ptr<ServerPlayer> newPlayer, shared_ptr<ServerPlayer> oldPlayer, Level *level); void updatePlayerGameMode(std::shared_ptr<ServerPlayer> newPlayer, std::shared_ptr<ServerPlayer> oldPlayer, Level *level);
public: public:
void setAllowCheatsForAllPlayers(bool allowCommands); void setAllowCheatsForAllPlayers(bool allowCommands);

View file

@ -52,13 +52,13 @@ ServerCommandDispatcher::ServerCommandDispatcher()
Command::setLogger(this); Command::setLogger(this);
} }
void ServerCommandDispatcher::logAdminCommand(shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const wstring& message, int customData, const wstring& additionalMessage) void ServerCommandDispatcher::logAdminCommand(std::shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const wstring& message, int customData, const wstring& additionalMessage)
{ {
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers(); PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
//for (Player player : MinecraftServer.getInstance().getPlayers().players) //for (Player player : MinecraftServer.getInstance().getPlayers().players)
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it) for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
{ {
shared_ptr<ServerPlayer> player = *it; std::shared_ptr<ServerPlayer> player = *it;
if (player != source && playerList->isOp(player)) if (player != source && playerList->isOp(player))
{ {
// TODO: Change chat packet to be able to send more bits of data // TODO: Change chat packet to be able to send more bits of data

View file

@ -7,5 +7,5 @@ class ServerCommandDispatcher : public CommandDispatcher, public AdminLogCommand
{ {
public: public:
ServerCommandDispatcher(); ServerCommandDispatcher();
void logAdminCommand(shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const wstring& message = L"", int customData = -1, const wstring& additionalMessage = L""); void logAdminCommand(std::shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const wstring& message = L"", int customData = -1, const wstring& additionalMessage = L"");
}; };

View file

@ -26,16 +26,16 @@ ServerConnection::~ServerConnection()
// 4J - added to handle incoming connections, to replace thread that original used to have // 4J - added to handle incoming connections, to replace thread that original used to have
void ServerConnection::NewIncomingSocket(Socket *socket) void ServerConnection::NewIncomingSocket(Socket *socket)
{ {
shared_ptr<PendingConnection> unconnectedClient = shared_ptr<PendingConnection>(new PendingConnection(server, socket, L"Connection #" + _toString<int>(connectionCounter++))); std::shared_ptr<PendingConnection> unconnectedClient = std::shared_ptr<PendingConnection>(new PendingConnection(server, socket, L"Connection #" + _toString<int>(connectionCounter++)));
handleConnection(unconnectedClient); handleConnection(unconnectedClient);
} }
void ServerConnection::addPlayerConnection(shared_ptr<PlayerConnection> uc) void ServerConnection::addPlayerConnection(std::shared_ptr<PlayerConnection> uc)
{ {
players.push_back(uc); players.push_back(uc);
} }
void ServerConnection::handleConnection(shared_ptr<PendingConnection> uc) void ServerConnection::handleConnection(std::shared_ptr<PendingConnection> uc)
{ {
EnterCriticalSection(&pending_cs); EnterCriticalSection(&pending_cs);
pending.push_back(uc); pending.push_back(uc);
@ -47,14 +47,14 @@ void ServerConnection::stop()
EnterCriticalSection(&pending_cs); EnterCriticalSection(&pending_cs);
for (unsigned int i = 0; i < pending.size(); i++) for (unsigned int i = 0; i < pending.size(); i++)
{ {
shared_ptr<PendingConnection> uc = pending[i]; std::shared_ptr<PendingConnection> uc = pending[i];
uc->connection->close(DisconnectPacket::eDisconnect_Closed); uc->connection->close(DisconnectPacket::eDisconnect_Closed);
} }
LeaveCriticalSection(&pending_cs); LeaveCriticalSection(&pending_cs);
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<PlayerConnection> player = players[i]; std::shared_ptr<PlayerConnection> player = players[i];
player->connection->close(DisconnectPacket::eDisconnect_Closed); player->connection->close(DisconnectPacket::eDisconnect_Closed);
} }
} }
@ -64,12 +64,12 @@ void ServerConnection::tick()
{ {
// MGH - changed this so that the the CS lock doesn't cover the tick (was causing a lockup when 2 players tried to join) // MGH - changed this so that the the CS lock doesn't cover the tick (was causing a lockup when 2 players tried to join)
EnterCriticalSection(&pending_cs); EnterCriticalSection(&pending_cs);
vector< shared_ptr<PendingConnection> > tempPending = pending; vector< std::shared_ptr<PendingConnection> > tempPending = pending;
LeaveCriticalSection(&pending_cs); LeaveCriticalSection(&pending_cs);
for (unsigned int i = 0; i < tempPending.size(); i++) for (unsigned int i = 0; i < tempPending.size(); i++)
{ {
shared_ptr<PendingConnection> uc = tempPending[i]; std::shared_ptr<PendingConnection> uc = tempPending[i];
// try { // 4J - removed try/catch // try { // 4J - removed try/catch
uc->tick(); uc->tick();
// } catch (Exception e) { // } catch (Exception e) {
@ -92,8 +92,8 @@ void ServerConnection::tick()
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<PlayerConnection> player = players[i]; std::shared_ptr<PlayerConnection> player = players[i];
shared_ptr<ServerPlayer> serverPlayer = player->getPlayer(); std::shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
if( serverPlayer ) if( serverPlayer )
{ {
serverPlayer->doChunkSendingTick(false); serverPlayer->doChunkSendingTick(false);
@ -138,7 +138,7 @@ void ServerConnection::handleTextureReceived(const wstring &textureName)
} }
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<PlayerConnection> player = players[i]; std::shared_ptr<PlayerConnection> player = players[i];
if (!player->done) if (!player->done)
{ {
player->handleTextureReceived(textureName); player->handleTextureReceived(textureName);
@ -155,7 +155,7 @@ void ServerConnection::handleTextureAndGeometryReceived(const wstring &textureNa
} }
for (unsigned int i = 0; i < players.size(); i++) for (unsigned int i = 0; i < players.size(); i++)
{ {
shared_ptr<PlayerConnection> player = players[i]; std::shared_ptr<PlayerConnection> player = players[i];
if (!player->done) if (!player->done)
{ {
player->handleTextureAndGeometryReceived(textureName); player->handleTextureAndGeometryReceived(textureName);
@ -163,7 +163,7 @@ void ServerConnection::handleTextureAndGeometryReceived(const wstring &textureNa
} }
} }
void ServerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet) void ServerConnection::handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet)
{ {
Minecraft *pMinecraft = Minecraft::GetInstance(); Minecraft *pMinecraft = Minecraft::GetInstance();
@ -197,7 +197,7 @@ void ServerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
// //
// for (unsigned int i = 0; i < players.size(); i++) // for (unsigned int i = 0; i < players.size(); i++)
// { // {
// shared_ptr<PlayerConnection> playerconnection = players[i]; // std::shared_ptr<PlayerConnection> playerconnection = players[i];
// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting()); // playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
// } // }
// } // }

View file

@ -20,8 +20,8 @@ private:
int connectionCounter; int connectionCounter;
private: private:
CRITICAL_SECTION pending_cs; // 4J added CRITICAL_SECTION pending_cs; // 4J added
vector< shared_ptr<PendingConnection> > pending; vector< std::shared_ptr<PendingConnection> > pending;
vector< shared_ptr<PlayerConnection> > players; vector< std::shared_ptr<PlayerConnection> > players;
// 4J - When the server requests a texture, it should add it to here while we are waiting for it // 4J - When the server requests a texture, it should add it to here while we are waiting for it
vector<wstring> m_pendingTextureRequests; vector<wstring> m_pendingTextureRequests;
@ -34,9 +34,9 @@ public:
void NewIncomingSocket(Socket *socket); // 4J - added void NewIncomingSocket(Socket *socket); // 4J - added
void removeSpamProtection(Socket *socket) { }// 4J Stu - Not implemented as not required void removeSpamProtection(Socket *socket) { }// 4J Stu - Not implemented as not required
void addPlayerConnection(shared_ptr<PlayerConnection> uc); void addPlayerConnection(std::shared_ptr<PlayerConnection> uc);
private: private:
void handleConnection(shared_ptr<PendingConnection> uc); void handleConnection(std::shared_ptr<PendingConnection> uc);
public: public:
void stop(); void stop();
void tick(); void tick();
@ -45,5 +45,5 @@ public:
bool addPendingTextureRequest(const wstring &textureName); bool addPendingTextureRequest(const wstring &textureName);
void handleTextureReceived(const wstring &textureName); void handleTextureReceived(const wstring &textureName);
void handleTextureAndGeometryReceived(const wstring &textureName); void handleTextureAndGeometryReceived(const wstring &textureName);
void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet); void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
}; };

View file

@ -57,7 +57,7 @@ bool CDurangoTelemetryManager::RecordPlayerSessionStart(int iPad)
bool CDurangoTelemetryManager::RecordPlayerSessionExit(int iPad, int exitStatus) bool CDurangoTelemetryManager::RecordPlayerSessionExit(int iPad, int exitStatus)
{ {
PlayerUID puid; shared_ptr<Player> plr; PlayerUID puid; std::shared_ptr<Player> plr;
ProfileManager.GetXUID(iPad, &puid, true); ProfileManager.GetXUID(iPad, &puid, true);
plr = Minecraft::GetInstance()->localplayers[iPad]; plr = Minecraft::GetInstance()->localplayers[iPad];
@ -127,7 +127,7 @@ bool CDurangoTelemetryManager::RecordLevelStart(int iPad, ESen_FriendOrMatch fri
ULONG hr = 0; ULONG hr = 0;
// Grab player info. // Grab player info.
PlayerUID puid; shared_ptr<Player> plr; PlayerUID puid; std::shared_ptr<Player> plr;
ProfileManager.GetXUID(iPad, &puid, true); ProfileManager.GetXUID(iPad, &puid, true);
plr = Minecraft::GetInstance()->localplayers[iPad]; plr = Minecraft::GetInstance()->localplayers[iPad];

View file

@ -25,7 +25,7 @@ using std::tr1::const_pointer_cast;
using std::tr1::dynamic_pointer_cast; using std::tr1::dynamic_pointer_cast;
using std::tr1::enable_shared_from_this; using std::tr1::enable_shared_from_this;
using std::tr1::get_deleter; using std::tr1::get_deleter;
using std::tr1::shared_ptr; using std::tr1::std::shared_ptr;
using std::tr1::static_pointer_cast; using std::tr1::static_pointer_cast;
using std::tr1::swap; using std::tr1::swap;
using std::tr1::weak_ptr; using std::tr1::weak_ptr;
@ -62,7 +62,7 @@ using boost::hash;
class Cnullptr{ class Cnullptr{
public: public:
template<typename T> template<typename T>
operator shared_ptr<T>() { return shared_ptr<T>(); } operator std::shared_ptr<T>() { return std::shared_ptr<T>(); }
}; };
extern Cnullptr nullptr; extern Cnullptr nullptr;

View file

@ -647,7 +647,7 @@ void ChunkRebuildData::tesselateAllTiles(TileRenderer_SPU* pTileRenderer)
{ {
// if (m_currentLayer == 0 && m_tileData.isEntityTile[tileId]) // if (m_currentLayer == 0 && m_tileData.isEntityTile[tileId])
// { // {
// shared_ptr<TileEntity> et = region->getTileEntity(x, y, z); // std::shared_ptr<TileEntity> et = region->getTileEntity(x, y, z);
// if (TileEntityRenderDispatcher::instance->hasRenderer(et)) // if (TileEntityRenderDispatcher::instance->hasRenderer(et))
// { // {
// renderableTileEntities.push_back(et); // renderableTileEntities.push_back(et);

View file

@ -8,5 +8,5 @@ public:
virtual bool blocksLight() { return false; } virtual bool blocksLight() { return false; }
virtual bool isSolidRender(bool isServerLevel = false) { return false; } virtual bool isSolidRender(bool isServerLevel = false) { return false; }
virtual int getRenderShape() { return Tile_SPU::SHAPE_LEVER; } virtual int getRenderShape() { return Tile_SPU::SHAPE_LEVER; }
// virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param // virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param
}; };

View file

@ -12,7 +12,7 @@ public:
virtual int getRenderShape() { return SHAPE_PISTON_BASE; } virtual int getRenderShape() { return SHAPE_PISTON_BASE; }
virtual bool isSolidRender(bool isServerLevel = false) { return false; } virtual bool isSolidRender(bool isServerLevel = false) { return false; }
// virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param // virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param
// virtual void updateDefaultShape(); // virtual void updateDefaultShape();
}; };

View file

@ -9,5 +9,5 @@ public:
virtual Icon_SPU *getTexture(int face, int data) { return NULL; } virtual Icon_SPU *getTexture(int face, int data) { return NULL; }
virtual int getRenderShape() { return SHAPE_PISTON_EXTENSION; } virtual int getRenderShape() { return SHAPE_PISTON_EXTENSION; }
virtual bool isSolidRender(bool isServerLevel = false) { return false; } virtual bool isSolidRender(bool isServerLevel = false) { return false; }
// virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param // virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param
}; };

View file

@ -6,7 +6,7 @@ class TheEndPortal_SPU : public EntityTile_SPU
public: public:
TheEndPortal_SPU(int id) : EntityTile_SPU(id) {} TheEndPortal_SPU(int id) : EntityTile_SPU(id) {}
// virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param // virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<TileEntity>()); // 4J added forceData, forceEntity param
virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face) virtual bool shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
{ {
if (face != 0) return false; if (face != 0) return false;

View file

@ -288,7 +288,7 @@ Icon_SPU *Tile_SPU::getTexture(int face)
// return id; // return id;
// } // }
// //
// float Tile_SPU::getDestroyProgress(shared_ptr<Player> player) // float Tile_SPU::getDestroyProgress(std::shared_ptr<Player> player)
// { // {
// if (destroySpeed < 0) return 0; // if (destroySpeed < 0) return 0;
// if (!player->canDestroy(this)) return 1 / destroySpeed / 100.0f; // if (!player->canDestroy(this)) return 1 / destroySpeed / 100.0f;
@ -310,11 +310,11 @@ Icon_SPU *Tile_SPU::getTexture(int face)
// int type = getResource(data, level->random, playerBonusLevel); // int type = getResource(data, level->random, playerBonusLevel);
// if (type <= 0) continue; // if (type <= 0) continue;
// //
// popResource(level, x, y, z, shared_ptr<ItemInstance>( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) ); // popResource(level, x, y, z, std::shared_ptr<ItemInstance>( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) );
// } // }
// } // }
// //
// void Tile_SPU::popResource(Level *level, int x, int y, int z, shared_ptr<ItemInstance> itemInstance) // void Tile_SPU::popResource(Level *level, int x, int y, int z, std::shared_ptr<ItemInstance> itemInstance)
// { // {
// if( level->isClientSide ) return; // if( level->isClientSide ) return;
// //
@ -322,7 +322,7 @@ Icon_SPU *Tile_SPU::getTexture(int face)
// double xo = level->random->nextFloat() * s + (1 - s) * 0.5; // double xo = level->random->nextFloat() * s + (1 - s) * 0.5;
// double yo = level->random->nextFloat() * s + (1 - s) * 0.5; // double yo = level->random->nextFloat() * s + (1 - s) * 0.5;
// double zo = level->random->nextFloat() * s + (1 - s) * 0.5; // double zo = level->random->nextFloat() * s + (1 - s) * 0.5;
// shared_ptr<ItemEntity> item = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) ); // std::shared_ptr<ItemEntity> item = std::shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) );
// item->throwTime = 10; // item->throwTime = 10;
// level->addEntity(item); // level->addEntity(item);
// } // }
@ -336,7 +336,7 @@ Icon_SPU *Tile_SPU::getTexture(int face)
// { // {
// int newCount = ExperienceOrb::getExperienceValue(amount); // int newCount = ExperienceOrb::getExperienceValue(amount);
// amount -= newCount; // amount -= newCount;
// level->addEntity(shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount))); // level->addEntity(std::shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
// } // }
// } // }
// } // }
@ -346,7 +346,7 @@ Icon_SPU *Tile_SPU::getTexture(int face)
// return 0; // return 0;
// } // }
// //
// float Tile_SPU::getExplosionResistance(shared_ptr<Entity> source) // float Tile_SPU::getExplosionResistance(std::shared_ptr<Entity> source)
// { // {
// return explosionResistance / 5.0f; // return explosionResistance / 5.0f;
// } // }
@ -437,17 +437,17 @@ int Tile_SPU::getRenderLayer()
// return false; // return false;
// } // }
// //
// bool Tile_SPU::TestUse(Level *level, int x, int y, int z, shared_ptr<Player> player) // bool Tile_SPU::TestUse(Level *level, int x, int y, int z, std::shared_ptr<Player> player)
// { // {
// return false; // return false;
// } // }
// //
// bool Tile_SPU::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param // bool Tile_SPU::use(Level *level, int x, int y, int z, std::shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param
// { // {
// return false; // return false;
// } // }
// //
// void Tile_SPU::stepOn(Level *level, int x, int y, int z, shared_ptr<Entity> entity) // void Tile_SPU::stepOn(Level *level, int x, int y, int z, std::shared_ptr<Entity> entity)
// { // {
// } // }
// //
@ -459,11 +459,11 @@ int Tile_SPU::getRenderLayer()
// { // {
// } // }
// //
// void Tile_SPU::attack(Level *level, int x, int y, int z, shared_ptr<Player> player) // void Tile_SPU::attack(Level *level, int x, int y, int z, std::shared_ptr<Player> player)
// { // {
// } // }
// //
// void Tile_SPU::handleEntityInside(Level *level, int x, int y, int z, shared_ptr<Entity> e, Vec3 *current) // void Tile_SPU::handleEntityInside(Level *level, int x, int y, int z, std::shared_ptr<Entity> e, Vec3 *current)
// { // {
// } // }
// //
@ -498,7 +498,7 @@ int Tile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
// return false; // return false;
// } // }
// //
// void Tile_SPU::entityInside(Level *level, int x, int y, int z, shared_ptr<Entity> entity) // void Tile_SPU::entityInside(Level *level, int x, int y, int z, std::shared_ptr<Entity> entity)
// { // {
// } // }
// //
@ -511,7 +511,7 @@ void Tile_SPU::updateDefaultShape()
{ {
} }
// //
// void Tile_SPU::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y, int z, int data) // void Tile_SPU::playerDestroy(Level *level, std::shared_ptr<Player> player, int x, int y, int z, int data)
// { // {
// // 4J Stu - Special case - only record a crop destroy if is fully grown // // 4J Stu - Special case - only record a crop destroy if is fully grown
// if(id==Tile_SPU::crops_Id) // if(id==Tile_SPU::crops_Id)
@ -532,7 +532,7 @@ void Tile_SPU::updateDefaultShape()
// //
// if (isCubeShaped() && !isEntityTile[id] && EnchantmentHelper::hasSilkTouch(player->inventory)) // if (isCubeShaped() && !isEntityTile[id] && EnchantmentHelper::hasSilkTouch(player->inventory))
// { // {
// shared_ptr<ItemInstance> item = getSilkTouchItemInstance(data); // std::shared_ptr<ItemInstance> item = getSilkTouchItemInstance(data);
// if (item != NULL) // if (item != NULL)
// { // {
// popResource(level, x, y, z, item); // popResource(level, x, y, z, item);
@ -545,14 +545,14 @@ void Tile_SPU::updateDefaultShape()
// } // }
// } // }
// //
// shared_ptr<ItemInstance> Tile_SPU::getSilkTouchItemInstance(int data) // std::shared_ptr<ItemInstance> Tile_SPU::getSilkTouchItemInstance(int data)
// { // {
// int popData = 0; // int popData = 0;
// if (id >= 0 && id < Item::items.length && Item::items[id]->isStackedByData()) // if (id >= 0 && id < Item::items.length && Item::items[id]->isStackedByData())
// { // {
// popData = data; // popData = data;
// } // }
// return shared_ptr<ItemInstance>(new ItemInstance(id, 1, popData)); // return std::shared_ptr<ItemInstance>(new ItemInstance(id, 1, popData));
// } // }
// //
// int Tile_SPU::getResourceCountForLootBonus(int bonusLevel, Random *random) // int Tile_SPU::getResourceCountForLootBonus(int bonusLevel, Random *random)
@ -565,7 +565,7 @@ void Tile_SPU::updateDefaultShape()
// return true; // return true;
// } // }
// //
// void Tile_SPU::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<Mob> by) // void Tile_SPU::setPlacedBy(Level *level, int x, int y, int z, std::shared_ptr<Mob> by)
// { // {
// } // }
// //
@ -646,7 +646,7 @@ Material_SPU* Tile_SPU::getMaterial()
} }
// //
// void Tile_SPU::fallOn(Level *level, int x, int y, int z, shared_ptr<Entity> entity, float fallDistance) // void Tile_SPU::fallOn(Level *level, int x, int y, int z, std::shared_ptr<Entity> entity, float fallDistance)
// { // {
// } // }
// //

View file

@ -172,7 +172,7 @@ void LevelRenderer_FindNearestChunk_DataIn::findNearestChunk()
for( int p = 0; p < 4; p++ ) for( int p = 0; p < 4; p++ )
{ {
// It's possible that the localplayers member can be set to NULL on the main thread when a player chooses to exit the game // It's possible that the localplayers member can be set to NULL on the main thread when a player chooses to exit the game
// So take a reference to the player object now. As it is a shared_ptr it should live as long as we need it // So take a reference to the player object now. As it is a std::shared_ptr it should live as long as we need it
PlayerData* player = &playerData[p]; PlayerData* player = &playerData[p];
if( player->bValid == NULL ) continue; if( player->bValid == NULL ) continue;
if( chunks[p] == NULL ) continue; if( chunks[p] == NULL ) continue;

View file

@ -64,7 +64,7 @@ public:
int id; int id;
int padding[1]; int padding[1];
//public: //public:
// vector<shared_ptr<TileEntity> > renderableTileEntities; // 4J - removed // vector<std::shared_ptr<TileEntity> > renderableTileEntities; // 4J - removed
private: private:
void *globalRenderableTileEntities; void *globalRenderableTileEntities;

View file

@ -984,7 +984,7 @@ void SoundEngine::update3DPosition(SoundEngine::soundInfo *pInfo, bool bPlaceEmi
XACT3DApply( &m_DSPSettings, pInfo->pCue); XACT3DApply( &m_DSPSettings, pInfo->pCue);
} }
void SoundEngine::tick(shared_ptr<Mob> *players, float a) void SoundEngine::tick(std::shared_ptr<Mob> *players, float a)
{ {
if( m_pXACT3Engine == NULL ) return; if( m_pXACT3Engine == NULL ) return;

View file

@ -86,7 +86,7 @@ public:
virtual void updateSystemMusicPlaying(bool isPlaying); virtual void updateSystemMusicPlaying(bool isPlaying);
virtual void updateSoundEffectVolume(float fVal); virtual void updateSoundEffectVolume(float fVal);
virtual void init(Options *); virtual void init(Options *);
virtual void tick(shared_ptr<Mob> *players, float a); // 4J - updated to take array of local players rather than single one virtual void tick(std::shared_ptr<Mob> *players, float a); // 4J - updated to take array of local players rather than single one
virtual void add(const wstring& name, File *file); virtual void add(const wstring& name, File *file);
virtual void addMusic(const wstring& name, File *file); virtual void addMusic(const wstring& name, File *file);
virtual void addStreaming(const wstring& name, File *file); virtual void addStreaming(const wstring& name, File *file);

View file

@ -26,12 +26,12 @@ EntityTracker::EntityTracker(ServerLevel *level)
maxRange = level->getServer()->getPlayers()->getMaxRange(); maxRange = level->getServer()->getPlayers()->getMaxRange();
} }
void EntityTracker::addEntity(shared_ptr<Entity> e) void EntityTracker::addEntity(std::shared_ptr<Entity> e)
{ {
if (e->GetType() == eTYPE_SERVERPLAYER) if (e->GetType() == eTYPE_SERVERPLAYER)
{ {
addEntity(e, 32 * 16, 2); addEntity(e, 32 * 16, 2);
shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(e); std::shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(e);
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ ) for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
{ {
if( (*it)->e != player ) if( (*it)->e != player )
@ -65,12 +65,12 @@ void EntityTracker::addEntity(shared_ptr<Entity> e)
else if (e->GetType() == eTYPE_ITEM_FRAME) addEntity(e, 16 * 10, INT_MAX, false); else if (e->GetType() == eTYPE_ITEM_FRAME) addEntity(e, 16 * 10, INT_MAX, false);
} }
void EntityTracker::addEntity(shared_ptr<Entity> e, int range, int updateInterval) void EntityTracker::addEntity(std::shared_ptr<Entity> e, int range, int updateInterval)
{ {
addEntity(e, range, updateInterval, false); addEntity(e, range, updateInterval, false);
} }
void EntityTracker::addEntity(shared_ptr<Entity> e, int range, int updateInterval, bool trackDeltas) void EntityTracker::addEntity(std::shared_ptr<Entity> e, int range, int updateInterval, bool trackDeltas)
{ {
if (range > maxRange) range = maxRange; if (range > maxRange) range = maxRange;
if (entityMap.find(e->entityId) != entityMap.end()) if (entityMap.find(e->entityId) != entityMap.end())
@ -81,7 +81,7 @@ void EntityTracker::addEntity(shared_ptr<Entity> e, int range, int updateInterva
{ {
__debugbreak(); __debugbreak();
} }
shared_ptr<TrackedEntity> te = shared_ptr<TrackedEntity>( new TrackedEntity(e, range, updateInterval, trackDeltas) ); std::shared_ptr<TrackedEntity> te = std::shared_ptr<TrackedEntity>( new TrackedEntity(e, range, updateInterval, trackDeltas) );
entities.insert(te); entities.insert(te);
entityMap[e->entityId] = te; entityMap[e->entityId] = te;
te->updatePlayers(this, &level->players); te->updatePlayers(this, &level->players);
@ -89,23 +89,23 @@ void EntityTracker::addEntity(shared_ptr<Entity> e, int range, int updateInterva
// 4J - have split removeEntity into two bits - it used to do the equivalent of EntityTracker::removePlayer followed by EntityTracker::removeEntity. // 4J - have split removeEntity into two bits - it used to do the equivalent of EntityTracker::removePlayer followed by EntityTracker::removeEntity.
// This is to allow us to now choose to remove the player as a "seenBy" only when the player has actually been removed from the level's own player array // This is to allow us to now choose to remove the player as a "seenBy" only when the player has actually been removed from the level's own player array
void EntityTracker::removeEntity(shared_ptr<Entity> e) void EntityTracker::removeEntity(std::shared_ptr<Entity> e)
{ {
AUTO_VAR(it, entityMap.find(e->entityId)); AUTO_VAR(it, entityMap.find(e->entityId));
if( it != entityMap.end() ) if( it != entityMap.end() )
{ {
shared_ptr<TrackedEntity> te = it->second; std::shared_ptr<TrackedEntity> te = it->second;
entityMap.erase(it); entityMap.erase(it);
entities.erase(te); entities.erase(te);
te->broadcastRemoved(); te->broadcastRemoved();
} }
} }
void EntityTracker::removePlayer(shared_ptr<Entity> e) void EntityTracker::removePlayer(std::shared_ptr<Entity> e)
{ {
if (e->GetType() == eTYPE_SERVERPLAYER) if (e->GetType() == eTYPE_SERVERPLAYER)
{ {
shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(e); std::shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(e);
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ ) for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
{ {
(*it)->removePlayer(player); (*it)->removePlayer(player);
@ -115,10 +115,10 @@ void EntityTracker::removePlayer(shared_ptr<Entity> e)
void EntityTracker::tick() void EntityTracker::tick()
{ {
vector<shared_ptr<ServerPlayer> > movedPlayers; vector<std::shared_ptr<ServerPlayer> > movedPlayers;
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ ) for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
{ {
shared_ptr<TrackedEntity> te = *it; std::shared_ptr<TrackedEntity> te = *it;
te->tick(this, &level->players); te->tick(this, &level->players);
if (te->moved && te->e->GetType() == eTYPE_SERVERPLAYER) if (te->moved && te->e->GetType() == eTYPE_SERVERPLAYER)
{ {
@ -132,7 +132,7 @@ void EntityTracker::tick()
MinecraftServer *server = MinecraftServer::getInstance(); MinecraftServer *server = MinecraftServer::getInstance();
for( unsigned int i = 0; i < server->getPlayers()->players.size(); i++ ) for( unsigned int i = 0; i < server->getPlayers()->players.size(); i++ )
{ {
shared_ptr<ServerPlayer> ep = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> ep = server->getPlayers()->players[i];
if( ep->dimension != level->dimension->id ) continue; if( ep->dimension != level->dimension->id ) continue;
if( ep->connection == NULL ) continue; if( ep->connection == NULL ) continue;
@ -142,7 +142,7 @@ void EntityTracker::tick()
bool addPlayer = false; bool addPlayer = false;
for (unsigned int j = 0; j < movedPlayers.size(); j++) for (unsigned int j = 0; j < movedPlayers.size(); j++)
{ {
shared_ptr<ServerPlayer> sp = movedPlayers[j]; std::shared_ptr<ServerPlayer> sp = movedPlayers[j];
if( sp == ep ) break; if( sp == ep ) break;
@ -159,11 +159,11 @@ void EntityTracker::tick()
for (unsigned int i = 0; i < movedPlayers.size(); i++) for (unsigned int i = 0; i < movedPlayers.size(); i++)
{ {
shared_ptr<ServerPlayer> player = movedPlayers[i]; std::shared_ptr<ServerPlayer> player = movedPlayers[i];
if(player->connection == NULL) continue; if(player->connection == NULL) continue;
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ ) for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
{ {
shared_ptr<TrackedEntity> te = *it; std::shared_ptr<TrackedEntity> te = *it;
if (te->e != player) if (te->e != player)
{ {
te->updatePlayer(this, player); te->updatePlayer(this, player);
@ -174,7 +174,7 @@ void EntityTracker::tick()
// 4J Stu - We want to do this for dead players as they don't tick normally // 4J Stu - We want to do this for dead players as they don't tick normally
for(AUTO_VAR(it, level->players.begin()); it != level->players.end(); ++it) for(AUTO_VAR(it, level->players.begin()); it != level->players.end(); ++it)
{ {
shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(*it); std::shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(*it);
if(!player->isAlive()) if(!player->isAlive())
{ {
player->flushEntitiesToRemove(); player->flushEntitiesToRemove();
@ -182,31 +182,31 @@ void EntityTracker::tick()
} }
} }
void EntityTracker::broadcast(shared_ptr<Entity> e, shared_ptr<Packet> packet) void EntityTracker::broadcast(std::shared_ptr<Entity> e, std::shared_ptr<Packet> packet)
{ {
AUTO_VAR(it, entityMap.find( e->entityId )); AUTO_VAR(it, entityMap.find( e->entityId ));
if( it != entityMap.end() ) if( it != entityMap.end() )
{ {
shared_ptr<TrackedEntity> te = it->second; std::shared_ptr<TrackedEntity> te = it->second;
te->broadcast(packet); te->broadcast(packet);
} }
} }
void EntityTracker::broadcastAndSend(shared_ptr<Entity> e, shared_ptr<Packet> packet) void EntityTracker::broadcastAndSend(std::shared_ptr<Entity> e, std::shared_ptr<Packet> packet)
{ {
AUTO_VAR(it, entityMap.find( e->entityId )); AUTO_VAR(it, entityMap.find( e->entityId ));
if( it != entityMap.end() ) if( it != entityMap.end() )
{ {
shared_ptr<TrackedEntity> te = it->second; std::shared_ptr<TrackedEntity> te = it->second;
te->broadcastAndSend(packet); te->broadcastAndSend(packet);
} }
} }
void EntityTracker::clear(shared_ptr<ServerPlayer> serverPlayer) void EntityTracker::clear(std::shared_ptr<ServerPlayer> serverPlayer)
{ {
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ ) for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
{ {
shared_ptr<TrackedEntity> te = *it; std::shared_ptr<TrackedEntity> te = *it;
te->clear(serverPlayer); te->clear(serverPlayer);
} }
} }
@ -218,7 +218,7 @@ void EntityTracker::updateMaxRange()
} }
shared_ptr<TrackedEntity> EntityTracker::getTracker(shared_ptr<Entity> e) std::shared_ptr<TrackedEntity> EntityTracker::getTracker(std::shared_ptr<Entity> e)
{ {
AUTO_VAR(it, entityMap.find(e->entityId)); AUTO_VAR(it, entityMap.find(e->entityId));
if( it != entityMap.end() ) if( it != entityMap.end() )

View file

@ -13,24 +13,24 @@ class EntityTracker
{ {
private: private:
ServerLevel *level; ServerLevel *level;
unordered_set<shared_ptr<TrackedEntity> > entities; unordered_set<std::shared_ptr<TrackedEntity> > entities;
unordered_map<int, shared_ptr<TrackedEntity> , IntKeyHash2, IntKeyEq> entityMap; // was IntHashMap unordered_map<int, std::shared_ptr<TrackedEntity> , IntKeyHash2, IntKeyEq> entityMap; // was IntHashMap
int maxRange; int maxRange;
public: public:
EntityTracker(ServerLevel *level); EntityTracker(ServerLevel *level);
void addEntity(shared_ptr<Entity> e); void addEntity(std::shared_ptr<Entity> e);
void addEntity(shared_ptr<Entity> e, int range, int updateInterval); void addEntity(std::shared_ptr<Entity> e, int range, int updateInterval);
void addEntity(shared_ptr<Entity> e, int range, int updateInterval, bool trackDeltas); void addEntity(std::shared_ptr<Entity> e, int range, int updateInterval, bool trackDeltas);
void removeEntity(shared_ptr<Entity> e); void removeEntity(std::shared_ptr<Entity> e);
void removePlayer(shared_ptr<Entity> e); // 4J added void removePlayer(std::shared_ptr<Entity> e); // 4J added
void tick(); void tick();
void broadcast(shared_ptr<Entity> e, shared_ptr<Packet> packet); void broadcast(std::shared_ptr<Entity> e, std::shared_ptr<Packet> packet);
void broadcastAndSend(shared_ptr<Entity> e, shared_ptr<Packet> packet); void broadcastAndSend(std::shared_ptr<Entity> e, std::shared_ptr<Packet> packet);
void clear(shared_ptr<ServerPlayer> serverPlayer); void clear(std::shared_ptr<ServerPlayer> serverPlayer);
void updateMaxRange(); // AP added for Vita void updateMaxRange(); // AP added for Vita
// 4J-JEV: Added, needed access to tracked entity of a riders mount. // 4J-JEV: Added, needed access to tracked entity of a riders mount.
shared_ptr<TrackedEntity> getTracker(shared_ptr<Entity> entity); std::shared_ptr<TrackedEntity> getTracker(std::shared_ptr<Entity> entity);
}; };

View file

@ -583,14 +583,14 @@ void LocalPlayer::closeContainer()
ui.CloseUIScenes( m_iPad ); ui.CloseUIScenes( m_iPad );
} }
void LocalPlayer::openTextEdit(shared_ptr<SignTileEntity> sign) void LocalPlayer::openTextEdit(std::shared_ptr<SignTileEntity> sign)
{ {
bool success = app.LoadSignEntryMenu(GetXboxPad(), sign ); bool success = app.LoadSignEntryMenu(GetXboxPad(), sign );
if( success ) ui.PlayUISFX(eSFX_Press); if( success ) ui.PlayUISFX(eSFX_Press);
//minecraft->setScreen(new TextEditScreen(sign)); //minecraft->setScreen(new TextEditScreen(sign));
} }
bool LocalPlayer::openContainer(shared_ptr<Container> container) bool LocalPlayer::openContainer(std::shared_ptr<Container> container)
{ {
bool success = app.LoadContainerMenu(GetXboxPad(), inventory, container ); bool success = app.LoadContainerMenu(GetXboxPad(), inventory, container );
if( success ) ui.PlayUISFX(eSFX_Press); if( success ) ui.PlayUISFX(eSFX_Press);
@ -623,7 +623,7 @@ bool LocalPlayer::startRepairing(int x, int y, int z)
return success; return success;
} }
bool LocalPlayer::openFurnace(shared_ptr<FurnaceTileEntity> furnace) bool LocalPlayer::openFurnace(std::shared_ptr<FurnaceTileEntity> furnace)
{ {
bool success = app.LoadFurnaceMenu(GetXboxPad(),inventory, furnace); bool success = app.LoadFurnaceMenu(GetXboxPad(),inventory, furnace);
if( success ) ui.PlayUISFX(eSFX_Press); if( success ) ui.PlayUISFX(eSFX_Press);
@ -631,7 +631,7 @@ bool LocalPlayer::openFurnace(shared_ptr<FurnaceTileEntity> furnace)
return success; return success;
} }
bool LocalPlayer::openBrewingStand(shared_ptr<BrewingStandTileEntity> brewingStand) bool LocalPlayer::openBrewingStand(std::shared_ptr<BrewingStandTileEntity> brewingStand)
{ {
bool success = app.LoadBrewingStandMenu(GetXboxPad(),inventory, brewingStand); bool success = app.LoadBrewingStandMenu(GetXboxPad(),inventory, brewingStand);
if( success ) ui.PlayUISFX(eSFX_Press); if( success ) ui.PlayUISFX(eSFX_Press);
@ -639,7 +639,7 @@ bool LocalPlayer::openBrewingStand(shared_ptr<BrewingStandTileEntity> brewingSta
return success; return success;
} }
bool LocalPlayer::openTrap(shared_ptr<DispenserTileEntity> trap) bool LocalPlayer::openTrap(std::shared_ptr<DispenserTileEntity> trap)
{ {
bool success = app.LoadTrapMenu(GetXboxPad(),inventory, trap); bool success = app.LoadTrapMenu(GetXboxPad(),inventory, trap);
if( success ) ui.PlayUISFX(eSFX_Press); if( success ) ui.PlayUISFX(eSFX_Press);
@ -647,7 +647,7 @@ bool LocalPlayer::openTrap(shared_ptr<DispenserTileEntity> trap)
return success; return success;
} }
bool LocalPlayer::openTrading(shared_ptr<Merchant> traderTarget) bool LocalPlayer::openTrading(std::shared_ptr<Merchant> traderTarget)
{ {
bool success = app.LoadTradingMenu(GetXboxPad(),inventory, traderTarget, level); bool success = app.LoadTradingMenu(GetXboxPad(),inventory, traderTarget, level);
if( success ) ui.PlayUISFX(eSFX_Press); if( success ) ui.PlayUISFX(eSFX_Press);
@ -655,23 +655,23 @@ bool LocalPlayer::openTrading(shared_ptr<Merchant> traderTarget)
return success; return success;
} }
void LocalPlayer::crit(shared_ptr<Entity> e) void LocalPlayer::crit(std::shared_ptr<Entity> e)
{ {
shared_ptr<CritParticle> critParticle = shared_ptr<CritParticle>( new CritParticle((Level *)minecraft->level, e) ); std::shared_ptr<CritParticle> critParticle = std::shared_ptr<CritParticle>( new CritParticle((Level *)minecraft->level, e) );
critParticle->CritParticlePostConstructor(); critParticle->CritParticlePostConstructor();
minecraft->particleEngine->add(critParticle); minecraft->particleEngine->add(critParticle);
} }
void LocalPlayer::magicCrit(shared_ptr<Entity> e) void LocalPlayer::magicCrit(std::shared_ptr<Entity> e)
{ {
shared_ptr<CritParticle> critParticle = shared_ptr<CritParticle>( new CritParticle((Level *)minecraft->level, e, eParticleType_magicCrit) ); std::shared_ptr<CritParticle> critParticle = std::shared_ptr<CritParticle>( new CritParticle((Level *)minecraft->level, e, eParticleType_magicCrit) );
critParticle->CritParticlePostConstructor(); critParticle->CritParticlePostConstructor();
minecraft->particleEngine->add(critParticle); minecraft->particleEngine->add(critParticle);
} }
void LocalPlayer::take(shared_ptr<Entity> e, int orgCount) void LocalPlayer::take(std::shared_ptr<Entity> e, int orgCount)
{ {
minecraft->particleEngine->add( shared_ptr<TakeAnimationParticle>( new TakeAnimationParticle((Level *)minecraft->level, e, shared_from_this(), -0.5f) ) ); minecraft->particleEngine->add( std::shared_ptr<TakeAnimationParticle>( new TakeAnimationParticle((Level *)minecraft->level, e, shared_from_this(), -0.5f) ) );
} }
void LocalPlayer::chat(const wstring& message) void LocalPlayer::chat(const wstring& message)
@ -1130,7 +1130,7 @@ bool LocalPlayer::hasPermission(EGameCommand command)
return level->getLevelData()->getAllowCommands(); return level->getLevelData()->getAllowCommands();
} }
void LocalPlayer::onCrafted(shared_ptr<ItemInstance> item) void LocalPlayer::onCrafted(std::shared_ptr<ItemInstance> item)
{ {
if( minecraft->localgameModes[m_iPad] != NULL ) if( minecraft->localgameModes[m_iPad] != NULL )
{ {
@ -1408,7 +1408,7 @@ bool LocalPlayer::handleMouseClick(int button)
if(lastClickState == lastClick_oldRepeat) return false; if(lastClickState == lastClick_oldRepeat) return false;
shared_ptr<MultiplayerLocalPlayer> mplp = dynamic_pointer_cast<MultiplayerLocalPlayer>( shared_from_this() ); std::shared_ptr<MultiplayerLocalPlayer> mplp = dynamic_pointer_cast<MultiplayerLocalPlayer>( shared_from_this() );
if(mplp && mplp->connection) mplp->StopSleeping(); if(mplp && mplp->connection) mplp->StopSleeping();
@ -1419,7 +1419,7 @@ bool LocalPlayer::handleMouseClick(int button)
return false; return false;
} }
shared_ptr<ItemInstance> oldItem = inventory->getSelected(); std::shared_ptr<ItemInstance> oldItem = inventory->getSelected();
if (minecraft->hitResult == NULL) if (minecraft->hitResult == NULL)
{ {
@ -1441,7 +1441,7 @@ bool LocalPlayer::handleMouseClick(int button)
if(minecraft->hitResult->entity->GetType()==eTYPE_COW) if(minecraft->hitResult->entity->GetType()==eTYPE_COW)
{ {
// If I have an empty bucket in my hand, it's going to be filled with milk, so turn off mayUse // If I have an empty bucket in my hand, it's going to be filled with milk, so turn off mayUse
shared_ptr<ItemInstance> item = inventory->getSelected(); std::shared_ptr<ItemInstance> item = inventory->getSelected();
if(item && (item->id==Item::bucket_empty_Id)) if(item && (item->id==Item::bucket_empty_Id))
{ {
mayUse=false; mayUse=false;
@ -1471,7 +1471,7 @@ bool LocalPlayer::handleMouseClick(int button)
} }
else else
{ {
shared_ptr<ItemInstance> item = oldItem; std::shared_ptr<ItemInstance> item = oldItem;
int oldCount = item != NULL ? item->count : 0; int oldCount = item != NULL ? item->count : 0;
bool usedItem = false; bool usedItem = false;
if (minecraft->gameMode->useItemOn(minecraft->localplayers[GetXboxPad()], level, item, x, y, z, face, minecraft->hitResult->pos, false, &usedItem)) if (minecraft->gameMode->useItemOn(minecraft->localplayers[GetXboxPad()], level, item, x, y, z, face, minecraft->hitResult->pos, false, &usedItem))
@ -1503,7 +1503,7 @@ bool LocalPlayer::handleMouseClick(int button)
if (mayUse && button == 1) if (mayUse && button == 1)
{ {
shared_ptr<ItemInstance> item = inventory->getSelected(); std::shared_ptr<ItemInstance> item = inventory->getSelected();
if (item != NULL) if (item != NULL)
{ {
if (minecraft->gameMode->useItem(minecraft->localplayers[GetXboxPad()], level, item)) if (minecraft->gameMode->useItem(minecraft->localplayers[GetXboxPad()], level, item))
@ -1519,7 +1519,7 @@ void LocalPlayer::updateRichPresence()
{ {
if((m_iPad!=-1)/* && !ui.GetMenuDisplayed(m_iPad)*/ ) if((m_iPad!=-1)/* && !ui.GetMenuDisplayed(m_iPad)*/ )
{ {
shared_ptr<ItemInstance> selectedItem = inventory->getSelected(); std::shared_ptr<ItemInstance> selectedItem = inventory->getSelected();
if(selectedItem != NULL && selectedItem->id == Item::fishingRod_Id) if(selectedItem != NULL && selectedItem->id == Item::fishingRod_Id)
{ {
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FISHING); app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FISHING);
@ -1575,7 +1575,7 @@ float LocalPlayer::getAndResetChangeDimensionTimer()
return returnVal; return returnVal;
} }
void LocalPlayer::handleCollectItem(shared_ptr<ItemInstance> item) void LocalPlayer::handleCollectItem(std::shared_ptr<ItemInstance> item)
{ {
if(item != NULL) if(item != NULL)
{ {

View file

@ -99,18 +99,18 @@ public:
virtual void addAdditonalSaveData(CompoundTag *entityTag); virtual void addAdditonalSaveData(CompoundTag *entityTag);
virtual void readAdditionalSaveData(CompoundTag *entityTag); virtual void readAdditionalSaveData(CompoundTag *entityTag);
virtual void closeContainer(); virtual void closeContainer();
virtual void openTextEdit(shared_ptr<SignTileEntity> sign); virtual void openTextEdit(std::shared_ptr<SignTileEntity> sign);
virtual bool openContainer(shared_ptr<Container> container); // 4J added bool return virtual bool openContainer(std::shared_ptr<Container> container); // 4J added bool return
virtual bool startCrafting(int x, int y, int z); // 4J added bool return virtual bool startCrafting(int x, int y, int z); // 4J added bool return
virtual bool startEnchanting(int x, int y, int z); // 4J added bool return virtual bool startEnchanting(int x, int y, int z); // 4J added bool return
virtual bool startRepairing(int x, int y, int z); virtual bool startRepairing(int x, int y, int z);
virtual bool openFurnace(shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return virtual bool openFurnace(std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
virtual bool openBrewingStand(shared_ptr<BrewingStandTileEntity> brewingStand); // 4J added bool return virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity> brewingStand); // 4J added bool return
virtual bool openTrap(shared_ptr<DispenserTileEntity> trap); // 4J added bool return virtual bool openTrap(std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
virtual bool openTrading(shared_ptr<Merchant> traderTarget); virtual bool openTrading(std::shared_ptr<Merchant> traderTarget);
virtual void crit(shared_ptr<Entity> e); virtual void crit(std::shared_ptr<Entity> e);
virtual void magicCrit(shared_ptr<Entity> e); virtual void magicCrit(std::shared_ptr<Entity> e);
virtual void take(shared_ptr<Entity> e, int orgCount); virtual void take(std::shared_ptr<Entity> e, int orgCount);
virtual void chat(const wstring& message); virtual void chat(const wstring& message);
virtual bool isSneaking(); virtual bool isSneaking();
//virtual bool isIdle(); //virtual bool isIdle();
@ -159,7 +159,7 @@ public:
int lastClickState; int lastClickState;
// 4J Stu - Added to allow callback to tutorial to stay within Minecraft.Client // 4J Stu - Added to allow callback to tutorial to stay within Minecraft.Client
virtual void onCrafted(shared_ptr<ItemInstance> item); virtual void onCrafted(std::shared_ptr<ItemInstance> item);
virtual void setAndBroadcastCustomSkin(DWORD skinId); virtual void setAndBroadcastCustomSkin(DWORD skinId);
virtual void setAndBroadcastCustomCape(DWORD capeId); virtual void setAndBroadcastCustomCape(DWORD capeId);
@ -189,7 +189,7 @@ public:
float getAndResetChangeDimensionTimer(); float getAndResetChangeDimensionTimer();
virtual void handleCollectItem(shared_ptr<ItemInstance> item); virtual void handleCollectItem(std::shared_ptr<ItemInstance> item);
void SetPlayerAdditionalModelParts(vector<ModelPart *>pAdditionalModelParts); void SetPlayerAdditionalModelParts(vector<ModelPart *>pAdditionalModelParts);
private: private:

View file

@ -38,7 +38,7 @@ void MultiPlayerGameMode::creativeDestroyBlock(Minecraft *minecraft, MultiPlayer
} }
} }
void MultiPlayerGameMode::adjustPlayer(shared_ptr<Player> player) void MultiPlayerGameMode::adjustPlayer(std::shared_ptr<Player> player)
{ {
localPlayerMode->updatePlayerAbilities(&player->abilities); localPlayerMode->updatePlayerAbilities(&player->abilities);
} }
@ -54,7 +54,7 @@ void MultiPlayerGameMode::setLocalMode(GameType *mode)
localPlayerMode->updatePlayerAbilities(&minecraft->player->abilities); localPlayerMode->updatePlayerAbilities(&minecraft->player->abilities);
} }
void MultiPlayerGameMode::initPlayer(shared_ptr<Player> player) void MultiPlayerGameMode::initPlayer(std::shared_ptr<Player> player)
{ {
player->yRot = -180; player->yRot = -180;
} }
@ -87,7 +87,7 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face)
if (!localPlayerMode->isCreative()) if (!localPlayerMode->isCreative())
{ {
shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem(); std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
if (item != NULL) if (item != NULL)
{ {
item->mineBlock(level, oldTile->id, x, y, z, minecraft->player); item->mineBlock(level, oldTile->id, x, y, z, minecraft->player);
@ -111,13 +111,13 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face)
if (localPlayerMode->isCreative()) if (localPlayerMode->isCreative())
{ {
connection->send(shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) )); connection->send(std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ));
creativeDestroyBlock(minecraft, this, x, y, z, face); creativeDestroyBlock(minecraft, this, x, y, z, face);
destroyDelay = 5; destroyDelay = 5;
} }
else if (!isDestroying || x != xDestroyBlock || y != yDestroyBlock || z != zDestroyBlock) else if (!isDestroying || x != xDestroyBlock || y != yDestroyBlock || z != zDestroyBlock)
{ {
connection->send( shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) ); connection->send( std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) );
int t = minecraft->level->getTile(x, y, z); int t = minecraft->level->getTile(x, y, z);
if (t > 0 && destroyProgress == 0) Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player); if (t > 0 && destroyProgress == 0) Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player);
if (t > 0 && if (t > 0 &&
@ -147,7 +147,7 @@ void MultiPlayerGameMode::stopDestroyBlock()
{ {
if (isDestroying) if (isDestroying)
{ {
connection->send(shared_ptr<PlayerActionPacket>(new PlayerActionPacket(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1))); connection->send(std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1)));
} }
isDestroying = false; isDestroying = false;
@ -170,7 +170,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face)
if (localPlayerMode->isCreative()) if (localPlayerMode->isCreative())
{ {
destroyDelay = 5; destroyDelay = 5;
connection->send(shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) ); connection->send(std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) );
creativeDestroyBlock(minecraft, this, x, y, z, face); creativeDestroyBlock(minecraft, this, x, y, z, face);
return; return;
} }
@ -202,7 +202,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face)
if (destroyProgress >= 1) if (destroyProgress >= 1)
{ {
isDestroying = false; isDestroying = false;
connection->send( shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face) ) ); connection->send( std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face) ) );
destroyBlock(x, y, z, face); destroyBlock(x, y, z, face);
destroyProgress = 0; destroyProgress = 0;
oDestroyProgress = 0; oDestroyProgress = 0;
@ -241,11 +241,11 @@ void MultiPlayerGameMode::ensureHasSentCarriedItem()
if (newItem != carriedItem) if (newItem != carriedItem)
{ {
carriedItem = newItem; carriedItem = newItem;
connection->send( shared_ptr<SetCarriedItemPacket>( new SetCarriedItemPacket(carriedItem) ) ); connection->send( std::shared_ptr<SetCarriedItemPacket>( new SetCarriedItemPacket(carriedItem) ) );
} }
} }
bool MultiPlayerGameMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly, bool *pbUsedItem) bool MultiPlayerGameMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly, bool *pbUsedItem)
{ {
if( pbUsedItem ) *pbUsedItem = false; // Did we actually use the held item? if( pbUsedItem ) *pbUsedItem = false; // Did we actually use the held item?
@ -338,12 +338,12 @@ bool MultiPlayerGameMode::useItemOn(shared_ptr<Player> player, Level *level, sha
// Fix for #7904 - Gameplay: Players can dupe torches by throwing them repeatedly into water. // Fix for #7904 - Gameplay: Players can dupe torches by throwing them repeatedly into water.
if(!bTestUseOnly) if(!bTestUseOnly)
{ {
connection->send( shared_ptr<UseItemPacket>( new UseItemPacket(x, y, z, face, player->inventory->getSelected(), clickX, clickY, clickZ) ) ); connection->send( std::shared_ptr<UseItemPacket>( new UseItemPacket(x, y, z, face, player->inventory->getSelected(), clickX, clickY, clickZ) ) );
} }
return didSomething; return didSomething;
} }
bool MultiPlayerGameMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly) bool MultiPlayerGameMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly)
{ {
if(!player->isAllowedToUse(item)) return false; if(!player->isAllowedToUse(item)) return false;
@ -366,7 +366,7 @@ bool MultiPlayerGameMode::useItem(shared_ptr<Player> player, Level *level, share
else else
{ {
int oldCount = item->count; int oldCount = item->count;
shared_ptr<ItemInstance> itemInstance = item->use(level, player); std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
if ((itemInstance != NULL && itemInstance != item) || (itemInstance != NULL && itemInstance->count != oldCount)) if ((itemInstance != NULL && itemInstance != item) || (itemInstance != NULL && itemInstance->count != oldCount))
{ {
player->inventory->items[player->inventory->selected] = itemInstance; player->inventory->items[player->inventory->selected] = itemInstance;
@ -380,65 +380,65 @@ bool MultiPlayerGameMode::useItem(shared_ptr<Player> player, Level *level, share
if(!bTestUseOnly) if(!bTestUseOnly)
{ {
connection->send( shared_ptr<UseItemPacket>( new UseItemPacket(-1, -1, -1, 255, player->inventory->getSelected(), 0, 0, 0) ) ); connection->send( std::shared_ptr<UseItemPacket>( new UseItemPacket(-1, -1, -1, 255, player->inventory->getSelected(), 0, 0, 0) ) );
} }
return result; return result;
} }
shared_ptr<MultiplayerLocalPlayer> MultiPlayerGameMode::createPlayer(Level *level) std::shared_ptr<MultiplayerLocalPlayer> MultiPlayerGameMode::createPlayer(Level *level)
{ {
return shared_ptr<MultiplayerLocalPlayer>( new MultiplayerLocalPlayer(minecraft, level, minecraft->user, connection) ); return std::shared_ptr<MultiplayerLocalPlayer>( new MultiplayerLocalPlayer(minecraft, level, minecraft->user, connection) );
} }
void MultiPlayerGameMode::attack(shared_ptr<Player> player, shared_ptr<Entity> entity) void MultiPlayerGameMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
{ {
ensureHasSentCarriedItem(); ensureHasSentCarriedItem();
connection->send( shared_ptr<InteractPacket>( new InteractPacket(player->entityId, entity->entityId, InteractPacket::ATTACK) ) ); connection->send( std::shared_ptr<InteractPacket>( new InteractPacket(player->entityId, entity->entityId, InteractPacket::ATTACK) ) );
player->attack(entity); player->attack(entity);
} }
bool MultiPlayerGameMode::interact(shared_ptr<Player> player, shared_ptr<Entity> entity) bool MultiPlayerGameMode::interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
{ {
ensureHasSentCarriedItem(); ensureHasSentCarriedItem();
connection->send(shared_ptr<InteractPacket>( new InteractPacket(player->entityId, entity->entityId, InteractPacket::INTERACT) ) ); connection->send(std::shared_ptr<InteractPacket>( new InteractPacket(player->entityId, entity->entityId, InteractPacket::INTERACT) ) );
return player->interact(entity); return player->interact(entity);
} }
shared_ptr<ItemInstance> MultiPlayerGameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player) std::shared_ptr<ItemInstance> MultiPlayerGameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player)
{ {
short changeUid = player->containerMenu->backup(player->inventory); short changeUid = player->containerMenu->backup(player->inventory);
shared_ptr<ItemInstance> clicked = player->containerMenu->clicked(slotNum, buttonNum, quickKeyHeld?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, player); std::shared_ptr<ItemInstance> clicked = player->containerMenu->clicked(slotNum, buttonNum, quickKeyHeld?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, player);
connection->send( shared_ptr<ContainerClickPacket>( new ContainerClickPacket(containerId, slotNum, buttonNum, quickKeyHeld, clicked, changeUid) ) ); connection->send( std::shared_ptr<ContainerClickPacket>( new ContainerClickPacket(containerId, slotNum, buttonNum, quickKeyHeld, clicked, changeUid) ) );
return clicked; return clicked;
} }
void MultiPlayerGameMode::handleInventoryButtonClick(int containerId, int buttonId) void MultiPlayerGameMode::handleInventoryButtonClick(int containerId, int buttonId)
{ {
connection->send(shared_ptr<ContainerButtonClickPacket>( new ContainerButtonClickPacket(containerId, buttonId) )); connection->send(std::shared_ptr<ContainerButtonClickPacket>( new ContainerButtonClickPacket(containerId, buttonId) ));
} }
void MultiPlayerGameMode::handleCreativeModeItemAdd(shared_ptr<ItemInstance> clicked, int slot) void MultiPlayerGameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int slot)
{ {
if (localPlayerMode->isCreative()) if (localPlayerMode->isCreative())
{ {
connection->send(shared_ptr<SetCreativeModeSlotPacket>( new SetCreativeModeSlotPacket(slot, clicked) ) ); connection->send(std::shared_ptr<SetCreativeModeSlotPacket>( new SetCreativeModeSlotPacket(slot, clicked) ) );
} }
} }
void MultiPlayerGameMode::handleCreativeModeItemDrop(shared_ptr<ItemInstance> clicked) void MultiPlayerGameMode::handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked)
{ {
if (localPlayerMode->isCreative() && clicked != NULL) if (localPlayerMode->isCreative() && clicked != NULL)
{ {
connection->send(shared_ptr<SetCreativeModeSlotPacket>( new SetCreativeModeSlotPacket(-1, clicked) ) ); connection->send(std::shared_ptr<SetCreativeModeSlotPacket>( new SetCreativeModeSlotPacket(-1, clicked) ) );
} }
} }
void MultiPlayerGameMode::releaseUsingItem(shared_ptr<Player> player) void MultiPlayerGameMode::releaseUsingItem(std::shared_ptr<Player> player)
{ {
ensureHasSentCarriedItem(); ensureHasSentCarriedItem();
connection->send(shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 255) ) ); connection->send(std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 255) ) );
player->releaseUsingItem(); player->releaseUsingItem();
} }
@ -462,17 +462,17 @@ bool MultiPlayerGameMode::hasFarPickRange()
return localPlayerMode->isCreative(); return localPlayerMode->isCreative();
} }
bool MultiPlayerGameMode::handleCraftItem(int recipe, shared_ptr<Player> player) bool MultiPlayerGameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player)
{ {
short changeUid = player->containerMenu->backup(player->inventory); short changeUid = player->containerMenu->backup(player->inventory);
connection->send( shared_ptr<CraftItemPacket>( new CraftItemPacket(recipe, changeUid) ) ); connection->send( std::shared_ptr<CraftItemPacket>( new CraftItemPacket(recipe, changeUid) ) );
return true; return true;
} }
void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal, shared_ptr<Player> player) void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player)
{ {
player->SetDebugOptions(uiVal); player->SetDebugOptions(uiVal);
connection->send( shared_ptr<DebugOptionsPacket>( new DebugOptionsPacket(uiVal) ) ); connection->send( std::shared_ptr<DebugOptionsPacket>( new DebugOptionsPacket(uiVal) ) );
} }

View file

@ -24,10 +24,10 @@ protected:
public: public:
MultiPlayerGameMode(Minecraft *minecraft, ClientConnection *connection); MultiPlayerGameMode(Minecraft *minecraft, ClientConnection *connection);
static void creativeDestroyBlock(Minecraft *minecraft, MultiPlayerGameMode *gameMode, int x, int y, int z, int face); static void creativeDestroyBlock(Minecraft *minecraft, MultiPlayerGameMode *gameMode, int x, int y, int z, int face);
void adjustPlayer(shared_ptr<Player> player); void adjustPlayer(std::shared_ptr<Player> player);
bool isCutScene(); bool isCutScene();
void setLocalMode(GameType *mode); void setLocalMode(GameType *mode);
virtual void initPlayer(shared_ptr<Player> player); virtual void initPlayer(std::shared_ptr<Player> player);
virtual bool canHurtPlayer(); virtual bool canHurtPlayer();
virtual bool destroyBlock(int x, int y, int z, int face); virtual bool destroyBlock(int x, int y, int z, int face);
virtual void startDestroyBlock(int x, int y, int z, int face); virtual void startDestroyBlock(int x, int y, int z, int face);
@ -41,24 +41,24 @@ private:
private: private:
void ensureHasSentCarriedItem(); void ensureHasSentCarriedItem();
public: public:
virtual bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly=false, bool *pbUsedItem=NULL); virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly=false, bool *pbUsedItem=NULL);
virtual bool useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly=false); virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
virtual shared_ptr<MultiplayerLocalPlayer> createPlayer(Level *level); virtual std::shared_ptr<MultiplayerLocalPlayer> createPlayer(Level *level);
virtual void attack(shared_ptr<Player> player, shared_ptr<Entity> entity); virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
virtual bool interact(shared_ptr<Player> player, shared_ptr<Entity> entity); virtual bool interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
virtual shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player); virtual std::shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player);
virtual void handleInventoryButtonClick(int containerId, int buttonId); virtual void handleInventoryButtonClick(int containerId, int buttonId);
virtual void handleCreativeModeItemAdd(shared_ptr<ItemInstance> clicked, int slot); virtual void handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int slot);
virtual void handleCreativeModeItemDrop(shared_ptr<ItemInstance> clicked); virtual void handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked);
virtual void releaseUsingItem(shared_ptr<Player> player); virtual void releaseUsingItem(std::shared_ptr<Player> player);
virtual bool hasExperience(); virtual bool hasExperience();
virtual bool hasMissTime(); virtual bool hasMissTime();
virtual bool hasInfiniteItems(); virtual bool hasInfiniteItems();
virtual bool hasFarPickRange(); virtual bool hasFarPickRange();
// 4J Stu - Added so we can send packets for this in the network game // 4J Stu - Added so we can send packets for this in the network game
virtual bool handleCraftItem(int recipe, shared_ptr<Player> player); virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
virtual void handleDebugOptions(unsigned int uiVal, shared_ptr<Player> player); virtual void handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player);
// 4J Stu - Added for tutorial checks // 4J Stu - Added for tutorial checks
virtual bool isInputAllowed(int mapping) { return true; } virtual bool isInputAllowed(int mapping) { return true; }

View file

@ -49,8 +49,8 @@ void MultiplayerLocalPlayer::tick()
/*if((app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0) != m_bShownOnMaps) /*if((app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0) != m_bShownOnMaps)
{ {
m_bShownOnMaps = (app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0); m_bShownOnMaps = (app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0);
if (m_bShownOnMaps) connection->send( shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::SHOW_ON_MAPS) ) ); if (m_bShownOnMaps) connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::SHOW_ON_MAPS) ) );
else connection->send( shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::HIDE_ON_MAPS) ) ); else connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::HIDE_ON_MAPS) ) );
}*/ }*/
if (!level->hasChunkAt(Mth::floor(x), 0, Mth::floor(z))) return; if (!level->hasChunkAt(Mth::floor(x), 0, Mth::floor(z))) return;
@ -75,8 +75,8 @@ void MultiplayerLocalPlayer::sendPosition()
bool sprinting = isSprinting(); bool sprinting = isSprinting();
if (sprinting != lastSprinting) if (sprinting != lastSprinting)
{ {
if (sprinting) connection->send(shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SPRINTING))); if (sprinting) connection->send(std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SPRINTING)));
else connection->send(shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SPRINTING))); else connection->send(std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SPRINTING)));
lastSprinting = sprinting; lastSprinting = sprinting;
} }
@ -84,8 +84,8 @@ void MultiplayerLocalPlayer::sendPosition()
bool sneaking = isSneaking(); bool sneaking = isSneaking();
if (sneaking != lastSneaked) if (sneaking != lastSneaked)
{ {
if (sneaking) connection->send( shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SNEAKING) ) ); if (sneaking) connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SNEAKING) ) );
else connection->send( shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SNEAKING) ) ); else connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SNEAKING) ) );
lastSneaked = sneaking; lastSneaked = sneaking;
} }
@ -93,8 +93,8 @@ void MultiplayerLocalPlayer::sendPosition()
bool idle = isIdle(); bool idle = isIdle();
if (idle != lastIdle) if (idle != lastIdle)
{ {
if (idle) connection->send( shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_IDLEANIM) ) ); if (idle) connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_IDLEANIM) ) );
else connection->send( shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM) ) ); else connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM) ) );
lastIdle = idle; lastIdle = idle;
} }
@ -110,26 +110,26 @@ void MultiplayerLocalPlayer::sendPosition()
bool rot = rydd != 0 || rxdd != 0; bool rot = rydd != 0 || rxdd != 0;
if (riding != NULL) if (riding != NULL)
{ {
connection->send( shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying) ) ); connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying) ) );
move = false; move = false;
} }
else else
{ {
if (move && rot) if (move && rot)
{ {
connection->send( shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(x, bb->y0, y, z, yRot, xRot, onGround, abilities.flying) ) ); connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(x, bb->y0, y, z, yRot, xRot, onGround, abilities.flying) ) );
} }
else if (move) else if (move)
{ {
connection->send( shared_ptr<MovePlayerPacket>( new MovePlayerPacket::Pos(x, bb->y0, y, z, onGround, abilities.flying) ) ); connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::Pos(x, bb->y0, y, z, onGround, abilities.flying) ) );
} }
else if (rot) else if (rot)
{ {
connection->send( shared_ptr<MovePlayerPacket>( new MovePlayerPacket::Rot(yRot, xRot, onGround, abilities.flying) ) ); connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::Rot(yRot, xRot, onGround, abilities.flying) ) );
} }
else else
{ {
connection->send( shared_ptr<MovePlayerPacket>( new MovePlayerPacket(onGround, abilities.flying) ) ); connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket(onGround, abilities.flying) ) );
} }
} }
@ -152,31 +152,31 @@ void MultiplayerLocalPlayer::sendPosition()
} }
shared_ptr<ItemEntity> MultiplayerLocalPlayer::drop() std::shared_ptr<ItemEntity> MultiplayerLocalPlayer::drop()
{ {
connection->send( shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::DROP_ITEM, 0, 0, 0, 0) ) ); connection->send( std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::DROP_ITEM, 0, 0, 0, 0) ) );
return nullptr; return nullptr;
} }
void MultiplayerLocalPlayer::reallyDrop(shared_ptr<ItemEntity> itemEntity) void MultiplayerLocalPlayer::reallyDrop(std::shared_ptr<ItemEntity> itemEntity)
{ {
} }
void MultiplayerLocalPlayer::chat(const wstring& message) void MultiplayerLocalPlayer::chat(const wstring& message)
{ {
connection->send( shared_ptr<ChatPacket>( new ChatPacket(message) ) ); connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(message) ) );
} }
void MultiplayerLocalPlayer::swing() void MultiplayerLocalPlayer::swing()
{ {
LocalPlayer::swing(); LocalPlayer::swing();
connection->send( shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::SWING) ) ); connection->send( std::shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::SWING) ) );
} }
void MultiplayerLocalPlayer::respawn() void MultiplayerLocalPlayer::respawn()
{ {
connection->send( shared_ptr<ClientCommandPacket>( new ClientCommandPacket(ClientCommandPacket::PERFORM_RESPAWN))); connection->send( std::shared_ptr<ClientCommandPacket>( new ClientCommandPacket(ClientCommandPacket::PERFORM_RESPAWN)));
} }
@ -238,7 +238,7 @@ void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance *effect)
void MultiplayerLocalPlayer::closeContainer() void MultiplayerLocalPlayer::closeContainer()
{ {
connection->send( shared_ptr<ContainerClosePacket>( new ContainerClosePacket(containerMenu->containerId) ) ); connection->send( std::shared_ptr<ContainerClosePacket>( new ContainerClosePacket(containerMenu->containerId) ) );
inventory->setCarried(nullptr); inventory->setCarried(nullptr);
LocalPlayer::closeContainer(); LocalPlayer::closeContainer();
} }
@ -286,7 +286,7 @@ void MultiplayerLocalPlayer::awardStatFromServer(Stat *stat, byteArray param)
void MultiplayerLocalPlayer::onUpdateAbilities() void MultiplayerLocalPlayer::onUpdateAbilities()
{ {
connection->send(shared_ptr<PlayerAbilitiesPacket>(new PlayerAbilitiesPacket(&abilities))); connection->send(std::shared_ptr<PlayerAbilitiesPacket>(new PlayerAbilitiesPacket(&abilities)));
} }
bool MultiplayerLocalPlayer::isLocalPlayer() bool MultiplayerLocalPlayer::isLocalPlayer()
@ -294,7 +294,7 @@ bool MultiplayerLocalPlayer::isLocalPlayer()
return true; return true;
} }
void MultiplayerLocalPlayer::ride(shared_ptr<Entity> e) void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e)
{ {
bool wasRiding = riding != NULL; bool wasRiding = riding != NULL;
LocalPlayer::ride(e); LocalPlayer::ride(e);
@ -344,7 +344,7 @@ void MultiplayerLocalPlayer::ride(shared_ptr<Entity> e)
void MultiplayerLocalPlayer::StopSleeping() void MultiplayerLocalPlayer::StopSleeping()
{ {
connection->send( shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SLEEPING) ) ); connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SLEEPING) ) );
} }
// 4J Added // 4J Added
@ -355,7 +355,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(DWORD skinId)
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
wprintf(L"Skin for local player %ls has changed to %ls (%d)\n", name.c_str(), customTextureUrl.c_str(), getPlayerDefaultSkin() ); wprintf(L"Skin for local player %ls has changed to %ls (%d)\n", name.c_str(), customTextureUrl.c_str(), getPlayerDefaultSkin() );
#endif #endif
if(getCustomSkin() != oldSkinIndex) connection->send( shared_ptr<TextureAndGeometryChangePacket>( new TextureAndGeometryChangePacket( shared_from_this(), app.GetPlayerSkinName(GetXboxPad()) ) ) ); if(getCustomSkin() != oldSkinIndex) connection->send( std::shared_ptr<TextureAndGeometryChangePacket>( new TextureAndGeometryChangePacket( shared_from_this(), app.GetPlayerSkinName(GetXboxPad()) ) ) );
} }
void MultiplayerLocalPlayer::setAndBroadcastCustomCape(DWORD capeId) void MultiplayerLocalPlayer::setAndBroadcastCustomCape(DWORD capeId)
@ -365,5 +365,5 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomCape(DWORD capeId)
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
wprintf(L"Cape for local player %ls has changed to %ls\n", name.c_str(), customTextureUrl2.c_str()); wprintf(L"Cape for local player %ls has changed to %ls\n", name.c_str(), customTextureUrl2.c_str());
#endif #endif
if(getCustomCape() != oldCapeIndex) connection->send( shared_ptr<TextureChangePacket>( new TextureChangePacket( shared_from_this(), TextureChangePacket::e_TextureChange_Cape, app.GetPlayerCapeName(GetXboxPad()) ) ) ); if(getCustomCape() != oldCapeIndex) connection->send( std::shared_ptr<TextureChangePacket>( new TextureChangePacket( shared_from_this(), TextureChangePacket::e_TextureChange_Cape, app.GetPlayerCapeName(GetXboxPad()) ) ) );
} }

View file

@ -33,9 +33,9 @@ public:
void sendPosition(); void sendPosition();
using Player::drop; using Player::drop;
virtual shared_ptr<ItemEntity> drop(); virtual std::shared_ptr<ItemEntity> drop();
protected: protected:
virtual void reallyDrop(shared_ptr<ItemEntity> itemEntity); virtual void reallyDrop(std::shared_ptr<ItemEntity> itemEntity);
public: public:
virtual void chat(const wstring& message); virtual void chat(const wstring& message);
virtual void swing(); virtual void swing();
@ -62,7 +62,7 @@ public:
//void CustomSkin(PBYTE pbData, DWORD dwBytes); //void CustomSkin(PBYTE pbData, DWORD dwBytes);
// 4J Overriding this so we can flag an event for the tutorial // 4J Overriding this so we can flag an event for the tutorial
virtual void ride(shared_ptr<Entity> e); virtual void ride(std::shared_ptr<Entity> e);
// 4J - added for the Stop Sleeping // 4J - added for the Stop Sleeping
virtual void StopSleeping(); virtual void StopSleeping();

View file

@ -66,7 +66,7 @@ void RemotePlayer::tick()
if (!hasStartedUsingItem && isUsingItemFlag() && inventory->items[inventory->selected] != NULL) if (!hasStartedUsingItem && isUsingItemFlag() && inventory->items[inventory->selected] != NULL)
{ {
shared_ptr<ItemInstance> item = inventory->items[inventory->selected]; std::shared_ptr<ItemInstance> item = inventory->items[inventory->selected];
startUsingItem(inventory->items[inventory->selected], Item::items[item->id]->getUseDuration(item)); startUsingItem(inventory->items[inventory->selected], Item::items[item->id]->getUseDuration(item));
hasStartedUsingItem = true; hasStartedUsingItem = true;
} }
@ -129,7 +129,7 @@ void RemotePlayer::aiStep()
} }
// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game // 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
void RemotePlayer::setEquippedSlot(int slot, shared_ptr<ItemInstance> item) void RemotePlayer::setEquippedSlot(int slot, std::shared_ptr<ItemInstance> item)
{ {
if (slot == 0) if (slot == 0)
{ {

View file

@ -26,7 +26,7 @@ public:
virtual void tick(); virtual void tick();
virtual float getShadowHeightOffs(); virtual float getShadowHeightOffs();
virtual void aiStep(); virtual void aiStep();
virtual void setEquippedSlot(int slot, shared_ptr<ItemInstance> item);// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game virtual void setEquippedSlot(int slot, std::shared_ptr<ItemInstance> item);// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
virtual void animateRespawn(); virtual void animateRespawn();
virtual float getHeadHeight(); virtual float getHeadHeight();
bool hasPermission(EGameCommand command) { return false; } bool hasPermission(EGameCommand command) { return false; }

View file

@ -236,10 +236,10 @@ void ServerPlayer::tick()
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
shared_ptr<ItemInstance> currentCarried = getCarried(i); std::shared_ptr<ItemInstance> currentCarried = getCarried(i);
if (currentCarried != lastCarried[i]) if (currentCarried != lastCarried[i])
{ {
getLevel()->getTracker()->broadcast(shared_from_this(), shared_ptr<SetEquippedItemPacket>( new SetEquippedItemPacket(this->entityId, i, currentCarried) ) ); getLevel()->getTracker()->broadcast(shared_from_this(), std::shared_ptr<SetEquippedItemPacket>( new SetEquippedItemPacket(this->entityId, i, currentCarried) ) );
lastCarried[i] = currentCarried; lastCarried[i] = currentCarried;
} }
} }
@ -264,7 +264,7 @@ void ServerPlayer::flushEntitiesToRemove()
it = entitiesToRemove.erase(it); it = entitiesToRemove.erase(it);
} }
connection->send(shared_ptr<RemoveEntitiesPacket>(new RemoveEntitiesPacket(ids))); connection->send(std::shared_ptr<RemoveEntitiesPacket>(new RemoveEntitiesPacket(ids)));
} }
} }
@ -286,14 +286,14 @@ void ServerPlayer::doTickA()
for (unsigned int i = 0; i < inventory->getContainerSize(); i++) for (unsigned int i = 0; i < inventory->getContainerSize(); i++)
{ {
shared_ptr<ItemInstance> ie = inventory->getItem(i); std::shared_ptr<ItemInstance> ie = inventory->getItem(i);
if (ie != NULL) if (ie != NULL)
{ {
// 4J - removed condition. These were getting lower priority than tile update packets etc. on the slow outbound queue, and so were extremely slow to send sometimes, // 4J - removed condition. These were getting lower priority than tile update packets etc. on the slow outbound queue, and so were extremely slow to send sometimes,
// particularly at the start of a game. They don't typically seem to be massive and shouldn't be send when there isn't actually any updating to do. // particularly at the start of a game. They don't typically seem to be massive and shouldn't be send when there isn't actually any updating to do.
if (Item::items[ie->id]->isComplex() ) // && connection->countDelayedPackets() <= 2) if (Item::items[ie->id]->isComplex() ) // && connection->countDelayedPackets() <= 2)
{ {
shared_ptr<Packet> packet = (dynamic_cast<ComplexItem *>(Item::items[ie->id])->getUpdatePacket(ie, level, dynamic_pointer_cast<Player>( shared_from_this() ) ) ); std::shared_ptr<Packet> packet = (dynamic_cast<ComplexItem *>(Item::items[ie->id])->getUpdatePacket(ie, level, dynamic_pointer_cast<Player>( shared_from_this() ) ) );
if (packet != NULL) if (packet != NULL)
{ {
connection->send(packet); connection->send(packet);
@ -402,7 +402,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
{ {
// app.DebugPrintf("Creating BRUP for %d %d\n",nearest.x, nearest.z); // app.DebugPrintf("Creating BRUP for %d %d\n",nearest.x, nearest.z);
PIXBeginNamedEvent(0,"Creation BRUP for sending\n"); PIXBeginNamedEvent(0,"Creation BRUP for sending\n");
shared_ptr<BlockRegionUpdatePacket> packet = shared_ptr<BlockRegionUpdatePacket>( new BlockRegionUpdatePacket(nearest.x * 16, 0, nearest.z * 16, 16, Level::maxBuildHeight, 16, level) ); std::shared_ptr<BlockRegionUpdatePacket> packet = std::shared_ptr<BlockRegionUpdatePacket>( new BlockRegionUpdatePacket(nearest.x * 16, 0, nearest.z * 16, 16, Level::maxBuildHeight, 16, level) );
PIXEndNamedEvent(); PIXEndNamedEvent();
if( dontDelayChunks ) packet->shouldDelay = false; if( dontDelayChunks ) packet->shouldDelay = false;
@ -441,7 +441,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
// Don't send TileEntity data until we have sent the block data // Don't send TileEntity data until we have sent the block data
if( connection->isLocal() || chunkDataSent) if( connection->isLocal() || chunkDataSent)
{ {
vector<shared_ptr<TileEntity> > *tes = level->getTileEntitiesInRegion(nearest.x * 16, 0, nearest.z * 16, nearest.x * 16 + 16, Level::maxBuildHeight, nearest.z * 16 + 16); vector<std::shared_ptr<TileEntity> > *tes = level->getTileEntitiesInRegion(nearest.x * 16, 0, nearest.z * 16, nearest.x * 16 + 16, Level::maxBuildHeight, nearest.z * 16 + 16);
for (unsigned int i = 0; i < tes->size(); i++) for (unsigned int i = 0; i < tes->size(); i++)
{ {
// 4J Stu - Added delay param to ensure that these arrive after the BRUPs from above // 4J Stu - Added delay param to ensure that these arrive after the BRUPs from above
@ -541,7 +541,7 @@ void ServerPlayer::doTickB(bool ignorePortal)
if (getHealth() != lastSentHealth || lastSentFood != foodData.getFoodLevel() || ((foodData.getSaturationLevel() == 0) != lastFoodSaturationZero)) if (getHealth() != lastSentHealth || lastSentFood != foodData.getFoodLevel() || ((foodData.getSaturationLevel() == 0) != lastFoodSaturationZero))
{ {
// 4J Stu - Added m_lastDamageSource for telemetry // 4J Stu - Added m_lastDamageSource for telemetry
connection->send( shared_ptr<SetHealthPacket>( new SetHealthPacket(getHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel(), m_lastDamageSource) ) ); connection->send( std::shared_ptr<SetHealthPacket>( new SetHealthPacket(getHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel(), m_lastDamageSource) ) );
lastSentHealth = getHealth(); lastSentHealth = getHealth();
lastSentFood = foodData.getFoodLevel(); lastSentFood = foodData.getFoodLevel();
lastFoodSaturationZero = foodData.getSaturationLevel() == 0; lastFoodSaturationZero = foodData.getSaturationLevel() == 0;
@ -550,12 +550,12 @@ void ServerPlayer::doTickB(bool ignorePortal)
if (totalExperience != lastSentExp) if (totalExperience != lastSentExp)
{ {
lastSentExp = totalExperience; lastSentExp = totalExperience;
connection->send( shared_ptr<SetExperiencePacket>( new SetExperiencePacket(experienceProgress, totalExperience, experienceLevel) ) ); connection->send( std::shared_ptr<SetExperiencePacket>( new SetExperiencePacket(experienceProgress, totalExperience, experienceLevel) ) );
} }
} }
shared_ptr<ItemInstance> ServerPlayer::getCarried(int slot) std::shared_ptr<ItemInstance> ServerPlayer::getCarried(int slot)
{ {
if (slot == 0) return inventory->getSelected(); if (slot == 0) return inventory->getSelected();
return inventory->armor[slot - 1]; return inventory->armor[slot - 1];
@ -575,7 +575,7 @@ bool ServerPlayer::hurt(DamageSource *dmgSource, int dmg)
{ {
// 4J Stu - Fix for #46422 - TU5: Crash: Gameplay: Crash when being hit by a trap using a dispenser // 4J Stu - Fix for #46422 - TU5: Crash: Gameplay: Crash when being hit by a trap using a dispenser
// getEntity returns the owner of projectiles, and this would never be the arrow. The owner is sometimes NULL. // getEntity returns the owner of projectiles, and this would never be the arrow. The owner is sometimes NULL.
shared_ptr<Entity> source = dmgSource->getDirectEntity(); std::shared_ptr<Entity> source = dmgSource->getDirectEntity();
if (dynamic_pointer_cast<Player>(source) != NULL && (!server->pvp || !dynamic_pointer_cast<Player>(source)->isAllowedToAttackPlayers()) ) if (dynamic_pointer_cast<Player>(source) != NULL && (!server->pvp || !dynamic_pointer_cast<Player>(source)->isAllowedToAttackPlayers()) )
@ -585,7 +585,7 @@ bool ServerPlayer::hurt(DamageSource *dmgSource, int dmg)
if (source != NULL && source->GetType() == eTYPE_ARROW) if (source != NULL && source->GetType() == eTYPE_ARROW)
{ {
shared_ptr<Arrow> arrow = dynamic_pointer_cast<Arrow>(source); std::shared_ptr<Arrow> arrow = dynamic_pointer_cast<Arrow>(source);
if (dynamic_pointer_cast<Player>(arrow->owner) != NULL && (!server->pvp || !dynamic_pointer_cast<Player>(arrow->owner)->isAllowedToAttackPlayers()) ) if (dynamic_pointer_cast<Player>(arrow->owner) != NULL && (!server->pvp || !dynamic_pointer_cast<Player>(arrow->owner)->isAllowedToAttackPlayers()) )
{ {
return false; return false;
@ -608,7 +608,7 @@ bool ServerPlayer::hurt(DamageSource *dmgSource, int dmg)
else if(dmgSource == DamageSource::cactus) m_lastDamageSource = eTelemetryPlayerDeathSource_Cactus; else if(dmgSource == DamageSource::cactus) m_lastDamageSource = eTelemetryPlayerDeathSource_Cactus;
else else
{ {
shared_ptr<Entity> source = dmgSource->getEntity(); std::shared_ptr<Entity> source = dmgSource->getEntity();
if( source != NULL ) if( source != NULL )
{ {
switch(source->GetType()) switch(source->GetType())
@ -647,7 +647,7 @@ bool ServerPlayer::hurt(DamageSource *dmgSource, int dmg)
case eTYPE_ARROW: case eTYPE_ARROW:
if ((dynamic_pointer_cast<Arrow>(source))->owner != NULL) if ((dynamic_pointer_cast<Arrow>(source))->owner != NULL)
{ {
shared_ptr<Entity> attacker = (dynamic_pointer_cast<Arrow>(source))->owner; std::shared_ptr<Entity> attacker = (dynamic_pointer_cast<Arrow>(source))->owner;
if (attacker != NULL) if (attacker != NULL)
{ {
switch(attacker->GetType()) switch(attacker->GetType())
@ -696,19 +696,19 @@ void ServerPlayer::changeDimension(int i)
level->removeEntity(shared_from_this()); level->removeEntity(shared_from_this());
wonGame = true; wonGame = true;
m_enteredEndExitPortal = true; // We only flag this for the player in the portal m_enteredEndExitPortal = true; // We only flag this for the player in the portal
connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex()) ) ); connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex()) ) );
app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex()); app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex());
} }
if(thisPlayer != NULL) if(thisPlayer != NULL)
{ {
for(AUTO_VAR(it, MinecraftServer::getInstance()->getPlayers()->players.begin()); it != MinecraftServer::getInstance()->getPlayers()->players.end(); ++it) for(AUTO_VAR(it, MinecraftServer::getInstance()->getPlayers()->players.begin()); it != MinecraftServer::getInstance()->getPlayers()->players.end(); ++it)
{ {
shared_ptr<ServerPlayer> servPlayer = *it; std::shared_ptr<ServerPlayer> servPlayer = *it;
INetworkPlayer *checkPlayer = servPlayer->connection->getNetworkPlayer(); INetworkPlayer *checkPlayer = servPlayer->connection->getNetworkPlayer();
if(thisPlayer != checkPlayer && checkPlayer != NULL && thisPlayer->IsSameSystem( checkPlayer ) && !servPlayer->wonGame ) if(thisPlayer != checkPlayer && checkPlayer != NULL && thisPlayer->IsSameSystem( checkPlayer ) && !servPlayer->wonGame )
{ {
servPlayer->wonGame = true; servPlayer->wonGame = true;
servPlayer->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex() ) ) ); servPlayer->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex() ) ) );
app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex()); app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex());
} }
} }
@ -733,11 +733,11 @@ void ServerPlayer::changeDimension(int i)
} }
// 4J Added delay param // 4J Added delay param
void ServerPlayer::broadcast(shared_ptr<TileEntity> te, bool delay /*= false*/) void ServerPlayer::broadcast(std::shared_ptr<TileEntity> te, bool delay /*= false*/)
{ {
if (te != NULL) if (te != NULL)
{ {
shared_ptr<Packet> p = te->getUpdatePacket(); std::shared_ptr<Packet> p = te->getUpdatePacket();
if (p != NULL) if (p != NULL)
{ {
p->shouldDelay = delay; p->shouldDelay = delay;
@ -747,22 +747,22 @@ void ServerPlayer::broadcast(shared_ptr<TileEntity> te, bool delay /*= false*/)
} }
} }
void ServerPlayer::take(shared_ptr<Entity> e, int orgCount) void ServerPlayer::take(std::shared_ptr<Entity> e, int orgCount)
{ {
if (!e->removed) if (!e->removed)
{ {
EntityTracker *entityTracker = getLevel()->getTracker(); EntityTracker *entityTracker = getLevel()->getTracker();
if (e->GetType() == eTYPE_ITEMENTITY) if (e->GetType() == eTYPE_ITEMENTITY)
{ {
entityTracker->broadcast(e, shared_ptr<TakeItemEntityPacket>( new TakeItemEntityPacket(e->entityId, entityId) ) ); entityTracker->broadcast(e, std::shared_ptr<TakeItemEntityPacket>( new TakeItemEntityPacket(e->entityId, entityId) ) );
} }
if (e->GetType() == eTYPE_ARROW) if (e->GetType() == eTYPE_ARROW)
{ {
entityTracker->broadcast(e, shared_ptr<TakeItemEntityPacket>( new TakeItemEntityPacket(e->entityId, entityId) ) ); entityTracker->broadcast(e, std::shared_ptr<TakeItemEntityPacket>( new TakeItemEntityPacket(e->entityId, entityId) ) );
} }
if (e->GetType() == eTYPE_EXPERIENCEORB) if (e->GetType() == eTYPE_EXPERIENCEORB)
{ {
entityTracker->broadcast(e, shared_ptr<TakeItemEntityPacket>( new TakeItemEntityPacket(e->entityId, entityId) ) ); entityTracker->broadcast(e, std::shared_ptr<TakeItemEntityPacket>( new TakeItemEntityPacket(e->entityId, entityId) ) );
} }
} }
Player::take(e, orgCount); Player::take(e, orgCount);
@ -775,7 +775,7 @@ void ServerPlayer::swing()
{ {
swingTime = -1; swingTime = -1;
swinging = true; swinging = true;
getLevel()->getTracker()->broadcast(shared_from_this(), shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::SWING) ) ); getLevel()->getTracker()->broadcast(shared_from_this(), std::shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::SWING) ) );
} }
} }
@ -784,7 +784,7 @@ Player::BedSleepingResult ServerPlayer::startSleepInBed(int x, int y, int z, boo
BedSleepingResult result = Player::startSleepInBed(x, y, z, bTestUse); BedSleepingResult result = Player::startSleepInBed(x, y, z, bTestUse);
if (result == OK) if (result == OK)
{ {
shared_ptr<Packet> p = shared_ptr<EntityActionAtPositionPacket>( new EntityActionAtPositionPacket(shared_from_this(), EntityActionAtPositionPacket::START_SLEEP, x, y, z) ); std::shared_ptr<Packet> p = std::shared_ptr<EntityActionAtPositionPacket>( new EntityActionAtPositionPacket(shared_from_this(), EntityActionAtPositionPacket::START_SLEEP, x, y, z) );
getLevel()->getTracker()->broadcast(shared_from_this(), p); getLevel()->getTracker()->broadcast(shared_from_this(), p);
connection->teleport(this->x, this->y, this->z, yRot, xRot); connection->teleport(this->x, this->y, this->z, yRot, xRot);
connection->send(p); connection->send(p);
@ -796,16 +796,16 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, boo
{ {
if (isSleeping()) if (isSleeping())
{ {
getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::WAKE_UP) ) ); getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::WAKE_UP) ) );
} }
Player::stopSleepInBed(forcefulWakeUp, updateLevelList, saveRespawnPoint); Player::stopSleepInBed(forcefulWakeUp, updateLevelList, saveRespawnPoint);
if (connection != NULL) connection->teleport(x, y, z, yRot, xRot); if (connection != NULL) connection->teleport(x, y, z, yRot, xRot);
} }
void ServerPlayer::ride(shared_ptr<Entity> e) void ServerPlayer::ride(std::shared_ptr<Entity> e)
{ {
Player::ride(e); Player::ride(e);
connection->send( shared_ptr<SetRidingPacket>( new SetRidingPacket(shared_from_this(), riding) ) ); connection->send( std::shared_ptr<SetRidingPacket>( new SetRidingPacket(shared_from_this(), riding) ) );
// 4J Removed this - The act of riding will be handled on the client and will change the position // 4J Removed this - The act of riding will be handled on the client and will change the position
// of the player. If we also teleport it then we can end up with a repeating movements, e.g. bouncing // of the player. If we also teleport it then we can end up with a repeating movements, e.g. bouncing
@ -832,7 +832,7 @@ bool ServerPlayer::startCrafting(int x, int y, int z)
if(containerMenu == inventoryMenu) if(containerMenu == inventoryMenu)
{ {
nextContainerCounter(); nextContainerCounter();
connection->send( shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::WORKBENCH, 0, 9) ) ); connection->send( std::shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::WORKBENCH, 0, 9) ) );
containerMenu = new CraftingMenu(inventory, level, x, y, z); containerMenu = new CraftingMenu(inventory, level, x, y, z);
containerMenu->containerId = containerCounter; containerMenu->containerId = containerCounter;
containerMenu->addSlotListener(this); containerMenu->addSlotListener(this);
@ -850,7 +850,7 @@ bool ServerPlayer::startEnchanting(int x, int y, int z)
if(containerMenu == inventoryMenu) if(containerMenu == inventoryMenu)
{ {
nextContainerCounter(); nextContainerCounter();
connection->send(shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::ENCHANTMENT, 0, 9) )); connection->send(std::shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::ENCHANTMENT, 0, 9) ));
containerMenu = new EnchantmentMenu(inventory, level, x, y, z); containerMenu = new EnchantmentMenu(inventory, level, x, y, z);
containerMenu->containerId = containerCounter; containerMenu->containerId = containerCounter;
containerMenu->addSlotListener(this); containerMenu->addSlotListener(this);
@ -868,7 +868,7 @@ bool ServerPlayer::startRepairing(int x, int y, int z)
if(containerMenu == inventoryMenu) if(containerMenu == inventoryMenu)
{ {
nextContainerCounter(); nextContainerCounter();
connection->send(shared_ptr<ContainerOpenPacket> ( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::REPAIR_TABLE, 0, 9)) ); connection->send(std::shared_ptr<ContainerOpenPacket> ( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::REPAIR_TABLE, 0, 9)) );
containerMenu = new RepairMenu(inventory, level, x, y, z, dynamic_pointer_cast<Player>(shared_from_this())); containerMenu = new RepairMenu(inventory, level, x, y, z, dynamic_pointer_cast<Player>(shared_from_this()));
containerMenu->containerId = containerCounter; containerMenu->containerId = containerCounter;
containerMenu->addSlotListener(this); containerMenu->addSlotListener(this);
@ -881,12 +881,12 @@ bool ServerPlayer::startRepairing(int x, int y, int z)
return true; return true;
} }
bool ServerPlayer::openContainer(shared_ptr<Container> container) bool ServerPlayer::openContainer(std::shared_ptr<Container> container)
{ {
if(containerMenu == inventoryMenu) if(containerMenu == inventoryMenu)
{ {
nextContainerCounter(); nextContainerCounter();
connection->send( shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::CONTAINER, container->getName(), container->getContainerSize()) ) ); connection->send( std::shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::CONTAINER, container->getName(), container->getContainerSize()) ) );
containerMenu = new ContainerMenu(inventory, container); containerMenu = new ContainerMenu(inventory, container);
containerMenu->containerId = containerCounter; containerMenu->containerId = containerCounter;
@ -900,12 +900,12 @@ bool ServerPlayer::openContainer(shared_ptr<Container> container)
return true; return true;
} }
bool ServerPlayer::openFurnace(shared_ptr<FurnaceTileEntity> furnace) bool ServerPlayer::openFurnace(std::shared_ptr<FurnaceTileEntity> furnace)
{ {
if(containerMenu == inventoryMenu) if(containerMenu == inventoryMenu)
{ {
nextContainerCounter(); nextContainerCounter();
connection->send( shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::FURNACE, 0, furnace->getContainerSize()) ) ); connection->send( std::shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::FURNACE, 0, furnace->getContainerSize()) ) );
containerMenu = new FurnaceMenu(inventory, furnace); containerMenu = new FurnaceMenu(inventory, furnace);
containerMenu->containerId = containerCounter; containerMenu->containerId = containerCounter;
containerMenu->addSlotListener(this); containerMenu->addSlotListener(this);
@ -918,12 +918,12 @@ bool ServerPlayer::openFurnace(shared_ptr<FurnaceTileEntity> furnace)
return true; return true;
} }
bool ServerPlayer::openTrap(shared_ptr<DispenserTileEntity> trap) bool ServerPlayer::openTrap(std::shared_ptr<DispenserTileEntity> trap)
{ {
if(containerMenu == inventoryMenu) if(containerMenu == inventoryMenu)
{ {
nextContainerCounter(); nextContainerCounter();
connection->send( shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::TRAP, 0, trap->getContainerSize()) ) ); connection->send( std::shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::TRAP, 0, trap->getContainerSize()) ) );
containerMenu = new TrapMenu(inventory, trap); containerMenu = new TrapMenu(inventory, trap);
containerMenu->containerId = containerCounter; containerMenu->containerId = containerCounter;
containerMenu->addSlotListener(this); containerMenu->addSlotListener(this);
@ -936,12 +936,12 @@ bool ServerPlayer::openTrap(shared_ptr<DispenserTileEntity> trap)
return true; return true;
} }
bool ServerPlayer::openBrewingStand(shared_ptr<BrewingStandTileEntity> brewingStand) bool ServerPlayer::openBrewingStand(std::shared_ptr<BrewingStandTileEntity> brewingStand)
{ {
if(containerMenu == inventoryMenu) if(containerMenu == inventoryMenu)
{ {
nextContainerCounter(); nextContainerCounter();
connection->send(shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::BREWING_STAND, 0, brewingStand->getContainerSize()))); connection->send(std::shared_ptr<ContainerOpenPacket>( new ContainerOpenPacket(containerCounter, ContainerOpenPacket::BREWING_STAND, 0, brewingStand->getContainerSize())));
containerMenu = new BrewingStandMenu(inventory, brewingStand); containerMenu = new BrewingStandMenu(inventory, brewingStand);
containerMenu->containerId = containerCounter; containerMenu->containerId = containerCounter;
containerMenu->addSlotListener(this); containerMenu->addSlotListener(this);
@ -954,7 +954,7 @@ bool ServerPlayer::openBrewingStand(shared_ptr<BrewingStandTileEntity> brewingSt
return true; return true;
} }
bool ServerPlayer::openTrading(shared_ptr<Merchant> traderTarget) bool ServerPlayer::openTrading(std::shared_ptr<Merchant> traderTarget)
{ {
if(containerMenu == inventoryMenu) if(containerMenu == inventoryMenu)
{ {
@ -962,9 +962,9 @@ bool ServerPlayer::openTrading(shared_ptr<Merchant> traderTarget)
containerMenu = new MerchantMenu(inventory, traderTarget, level); containerMenu = new MerchantMenu(inventory, traderTarget, level);
containerMenu->containerId = containerCounter; containerMenu->containerId = containerCounter;
containerMenu->addSlotListener(this); containerMenu->addSlotListener(this);
shared_ptr<Container> container = ((MerchantMenu *) containerMenu)->getTradeContainer(); std::shared_ptr<Container> container = ((MerchantMenu *) containerMenu)->getTradeContainer();
connection->send(shared_ptr<ContainerOpenPacket>(new ContainerOpenPacket(containerCounter, ContainerOpenPacket::TRADER_NPC, container->getName(), container->getContainerSize()))); connection->send(std::shared_ptr<ContainerOpenPacket>(new ContainerOpenPacket(containerCounter, ContainerOpenPacket::TRADER_NPC, container->getName(), container->getContainerSize())));
MerchantRecipeList *offers = traderTarget->getOffers(dynamic_pointer_cast<Player>(shared_from_this())); MerchantRecipeList *offers = traderTarget->getOffers(dynamic_pointer_cast<Player>(shared_from_this()));
if (offers != NULL) if (offers != NULL)
@ -976,7 +976,7 @@ bool ServerPlayer::openTrading(shared_ptr<Merchant> traderTarget)
output.writeInt(containerCounter); output.writeInt(containerCounter);
offers->writeToStream(&output); offers->writeToStream(&output);
connection->send(shared_ptr<CustomPayloadPacket>( new CustomPayloadPacket(CustomPayloadPacket::TRADER_LIST_PACKET, rawOutput.toByteArray()))); connection->send(std::shared_ptr<CustomPayloadPacket>( new CustomPayloadPacket(CustomPayloadPacket::TRADER_LIST_PACKET, rawOutput.toByteArray())));
} }
} }
else else
@ -987,7 +987,7 @@ bool ServerPlayer::openTrading(shared_ptr<Merchant> traderTarget)
return true; return true;
} }
void ServerPlayer::slotChanged(AbstractContainerMenu *container, int slotIndex, shared_ptr<ItemInstance> item) void ServerPlayer::slotChanged(AbstractContainerMenu *container, int slotIndex, std::shared_ptr<ItemInstance> item)
{ {
if (dynamic_cast<ResultSlot *>(container->getSlot(slotIndex))) if (dynamic_cast<ResultSlot *>(container->getSlot(slotIndex)))
{ {
@ -1004,21 +1004,21 @@ void ServerPlayer::slotChanged(AbstractContainerMenu *container, int slotIndex,
return; return;
} }
connection->send( shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(container->containerId, slotIndex, item) ) ); connection->send( std::shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(container->containerId, slotIndex, item) ) );
} }
void ServerPlayer::refreshContainer(AbstractContainerMenu *menu) void ServerPlayer::refreshContainer(AbstractContainerMenu *menu)
{ {
vector<shared_ptr<ItemInstance> > *items = menu->getItems(); vector<std::shared_ptr<ItemInstance> > *items = menu->getItems();
refreshContainer(menu, items); refreshContainer(menu, items);
delete items; delete items;
} }
void ServerPlayer::refreshContainer(AbstractContainerMenu *container, vector<shared_ptr<ItemInstance> > *items) void ServerPlayer::refreshContainer(AbstractContainerMenu *container, vector<std::shared_ptr<ItemInstance> > *items)
{ {
connection->send( shared_ptr<ContainerSetContentPacket>( new ContainerSetContentPacket(container->containerId, items) ) ); connection->send( std::shared_ptr<ContainerSetContentPacket>( new ContainerSetContentPacket(container->containerId, items) ) );
connection->send( shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(-1, -1, inventory->getCarried()) ) ); connection->send( std::shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(-1, -1, inventory->getCarried()) ) );
} }
void ServerPlayer::setContainerData(AbstractContainerMenu *container, int id, int value) void ServerPlayer::setContainerData(AbstractContainerMenu *container, int id, int value)
@ -1033,12 +1033,12 @@ void ServerPlayer::setContainerData(AbstractContainerMenu *container, int id, in
// client again. // client again.
return; return;
} }
connection->send( shared_ptr<ContainerSetDataPacket>( new ContainerSetDataPacket(container->containerId, id, value) ) ); connection->send( std::shared_ptr<ContainerSetDataPacket>( new ContainerSetDataPacket(container->containerId, id, value) ) );
} }
void ServerPlayer::closeContainer() void ServerPlayer::closeContainer()
{ {
connection->send( shared_ptr<ContainerClosePacket>( new ContainerClosePacket(containerMenu->containerId) ) ); connection->send( std::shared_ptr<ContainerClosePacket>( new ContainerClosePacket(containerMenu->containerId) ) );
doCloseContainer(); doCloseContainer();
} }
@ -1052,7 +1052,7 @@ void ServerPlayer::broadcastCarriedItem()
// client again. // client again.
return; return;
} }
connection->send( shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(-1, -1, inventory->getCarried()) ) ); connection->send( std::shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(-1, -1, inventory->getCarried()) ) );
} }
void ServerPlayer::doCloseContainer() void ServerPlayer::doCloseContainer()
@ -1087,12 +1087,12 @@ void ServerPlayer::awardStat(Stat *stat, byteArray param)
while (count > 100) while (count > 100)
{ {
connection->send( shared_ptr<AwardStatPacket>( new AwardStatPacket(stat->id, 100) ) ); connection->send( std::shared_ptr<AwardStatPacket>( new AwardStatPacket(stat->id, 100) ) );
count -= 100; count -= 100;
} }
connection->send( shared_ptr<AwardStatPacket>( new AwardStatPacket(stat->id, count) ) ); connection->send( std::shared_ptr<AwardStatPacket>( new AwardStatPacket(stat->id, count) ) );
#else #else
connection->send( shared_ptr<AwardStatPacket>( new AwardStatPacket(stat->id, param) ) ); connection->send( std::shared_ptr<AwardStatPacket>( new AwardStatPacket(stat->id, param) ) );
// byteArray deleted in AwardStatPacket destructor. // byteArray deleted in AwardStatPacket destructor.
#endif #endif
} }
@ -1122,33 +1122,33 @@ void ServerPlayer::displayClientMessage(int messageId)
{ {
case IDS_TILE_BED_OCCUPIED: case IDS_TILE_BED_OCCUPIED:
messageType = ChatPacket::e_ChatBedOccupied; messageType = ChatPacket::e_ChatBedOccupied;
connection->send( shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) ); connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) );
break; break;
case IDS_TILE_BED_NO_SLEEP: case IDS_TILE_BED_NO_SLEEP:
messageType = ChatPacket::e_ChatBedNoSleep; messageType = ChatPacket::e_ChatBedNoSleep;
connection->send( shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) ); connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) );
break; break;
case IDS_TILE_BED_NOT_VALID: case IDS_TILE_BED_NOT_VALID:
messageType = ChatPacket::e_ChatBedNotValid; messageType = ChatPacket::e_ChatBedNotValid;
connection->send( shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) ); connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) );
break; break;
case IDS_TILE_BED_NOTSAFE: case IDS_TILE_BED_NOTSAFE:
messageType = ChatPacket::e_ChatBedNotSafe; messageType = ChatPacket::e_ChatBedNotSafe;
connection->send( shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) ); connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) );
break; break;
case IDS_TILE_BED_PLAYERSLEEP: case IDS_TILE_BED_PLAYERSLEEP:
messageType = ChatPacket::e_ChatBedPlayerSleep; messageType = ChatPacket::e_ChatBedPlayerSleep;
// broadcast to all the other players in the game // broadcast to all the other players in the game
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()!=player) if(shared_from_this()!=player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatBedPlayerSleep))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatBedPlayerSleep)));
} }
else else
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatBedMeSleep))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatBedMeSleep)));
} }
} }
return; return;
@ -1156,85 +1156,85 @@ void ServerPlayer::displayClientMessage(int messageId)
case IDS_PLAYER_ENTERED_END: case IDS_PLAYER_ENTERED_END:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()!=player) if(shared_from_this()!=player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerEnteredEnd))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerEnteredEnd)));
} }
} }
break; break;
case IDS_PLAYER_LEFT_END: case IDS_PLAYER_LEFT_END:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()!=player) if(shared_from_this()!=player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerLeftEnd))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerLeftEnd)));
} }
} }
break; break;
case IDS_TILE_BED_MESLEEP: case IDS_TILE_BED_MESLEEP:
messageType = ChatPacket::e_ChatBedMeSleep; messageType = ChatPacket::e_ChatBedMeSleep;
connection->send( shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) ); connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) );
break; break;
case IDS_MAX_PIGS_SHEEP_COWS_CATS_SPAWNED: case IDS_MAX_PIGS_SHEEP_COWS_CATS_SPAWNED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxPigsSheepCows))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxPigsSheepCows)));
} }
} }
break; break;
case IDS_MAX_CHICKENS_SPAWNED: case IDS_MAX_CHICKENS_SPAWNED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxChickens))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxChickens)));
} }
} }
break; break;
case IDS_MAX_SQUID_SPAWNED: case IDS_MAX_SQUID_SPAWNED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxSquid))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxSquid)));
} }
} }
break; break;
case IDS_MAX_WOLVES_SPAWNED: case IDS_MAX_WOLVES_SPAWNED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxWolves))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxWolves)));
} }
} }
break; break;
case IDS_MAX_MOOSHROOMS_SPAWNED: case IDS_MAX_MOOSHROOMS_SPAWNED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxMooshrooms))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxMooshrooms)));
} }
} }
break; break;
case IDS_MAX_ENEMIES_SPAWNED: case IDS_MAX_ENEMIES_SPAWNED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxEnemies))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxEnemies)));
} }
} }
break; break;
@ -1242,40 +1242,40 @@ void ServerPlayer::displayClientMessage(int messageId)
case IDS_MAX_VILLAGERS_SPAWNED: case IDS_MAX_VILLAGERS_SPAWNED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxVillagers))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxVillagers)));
} }
} }
break; break;
case IDS_MAX_PIGS_SHEEP_COWS_CATS_BRED: case IDS_MAX_PIGS_SHEEP_COWS_CATS_BRED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredPigsSheepCows))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredPigsSheepCows)));
} }
} }
break; break;
case IDS_MAX_CHICKENS_BRED: case IDS_MAX_CHICKENS_BRED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredChickens))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredChickens)));
} }
} }
break; break;
case IDS_MAX_MUSHROOMCOWS_BRED: case IDS_MAX_MUSHROOMCOWS_BRED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredMooshrooms))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredMooshrooms)));
} }
} }
break; break;
@ -1283,10 +1283,10 @@ void ServerPlayer::displayClientMessage(int messageId)
case IDS_MAX_WOLVES_BRED: case IDS_MAX_WOLVES_BRED:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredWolves))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBredWolves)));
} }
} }
break; break;
@ -1294,10 +1294,10 @@ void ServerPlayer::displayClientMessage(int messageId)
case IDS_CANT_SHEAR_MOOSHROOM: case IDS_CANT_SHEAR_MOOSHROOM:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerCantShearMooshroom))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerCantShearMooshroom)));
} }
} }
break; break;
@ -1306,20 +1306,20 @@ void ServerPlayer::displayClientMessage(int messageId)
case IDS_MAX_HANGINGENTITIES: case IDS_MAX_HANGINGENTITIES:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxHangingEntities))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxHangingEntities)));
} }
} }
break; break;
case IDS_CANT_SPAWN_IN_PEACEFUL: case IDS_CANT_SPAWN_IN_PEACEFUL:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerCantSpawnInPeaceful))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerCantSpawnInPeaceful)));
} }
} }
break; break;
@ -1327,10 +1327,10 @@ void ServerPlayer::displayClientMessage(int messageId)
case IDS_MAX_BOATS: case IDS_MAX_BOATS:
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++)
{ {
shared_ptr<ServerPlayer> player = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> player = server->getPlayers()->players[i];
if(shared_from_this()==player) if(shared_from_this()==player)
{ {
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBoats))); player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(name, ChatPacket::e_ChatPlayerMaxBoats)));
} }
} }
break; break;
@ -1343,26 +1343,26 @@ void ServerPlayer::displayClientMessage(int messageId)
//Language *language = Language::getInstance(); //Language *language = Language::getInstance();
//wstring languageString = app.GetString(messageId);//language->getElement(messageId); //wstring languageString = app.GetString(messageId);//language->getElement(messageId);
//connection->send( shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) ); //connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(L"", messageType) ) );
} }
void ServerPlayer::completeUsingItem() void ServerPlayer::completeUsingItem()
{ {
connection->send(shared_ptr<EntityEventPacket>( new EntityEventPacket(entityId, EntityEvent::USE_ITEM_COMPLETE) ) ); connection->send(std::shared_ptr<EntityEventPacket>( new EntityEventPacket(entityId, EntityEvent::USE_ITEM_COMPLETE) ) );
Player::completeUsingItem(); Player::completeUsingItem();
} }
void ServerPlayer::startUsingItem(shared_ptr<ItemInstance> instance, int duration) void ServerPlayer::startUsingItem(std::shared_ptr<ItemInstance> instance, int duration)
{ {
Player::startUsingItem(instance, duration); Player::startUsingItem(instance, duration);
if (instance != NULL && instance->getItem() != NULL && instance->getItem()->getUseAnimation(instance) == UseAnim_eat) if (instance != NULL && instance->getItem() != NULL && instance->getItem()->getUseAnimation(instance) == UseAnim_eat)
{ {
getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::EAT) ) ); getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::EAT) ) );
} }
} }
void ServerPlayer::restoreFrom(shared_ptr<Player> oldPlayer, bool restoreAll) void ServerPlayer::restoreFrom(std::shared_ptr<Player> oldPlayer, bool restoreAll)
{ {
Player::restoreFrom(oldPlayer, restoreAll); Player::restoreFrom(oldPlayer, restoreAll);
lastSentExp = -1; lastSentExp = -1;
@ -1374,21 +1374,21 @@ void ServerPlayer::restoreFrom(shared_ptr<Player> oldPlayer, bool restoreAll)
void ServerPlayer::onEffectAdded(MobEffectInstance *effect) void ServerPlayer::onEffectAdded(MobEffectInstance *effect)
{ {
Player::onEffectAdded(effect); Player::onEffectAdded(effect);
connection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(entityId, effect) ) ); connection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(entityId, effect) ) );
} }
void ServerPlayer::onEffectUpdated(MobEffectInstance *effect) void ServerPlayer::onEffectUpdated(MobEffectInstance *effect)
{ {
Player::onEffectUpdated(effect); Player::onEffectUpdated(effect);
connection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(entityId, effect) ) ); connection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(entityId, effect) ) );
} }
void ServerPlayer::onEffectRemoved(MobEffectInstance *effect) void ServerPlayer::onEffectRemoved(MobEffectInstance *effect)
{ {
Player::onEffectRemoved(effect); Player::onEffectRemoved(effect);
connection->send(shared_ptr<RemoveMobEffectPacket>( new RemoveMobEffectPacket(entityId, effect) ) ); connection->send(std::shared_ptr<RemoveMobEffectPacket>( new RemoveMobEffectPacket(entityId, effect) ) );
} }
void ServerPlayer::teleportTo(double x, double y, double z) void ServerPlayer::teleportTo(double x, double y, double z)
@ -1396,20 +1396,20 @@ void ServerPlayer::teleportTo(double x, double y, double z)
connection->teleport(x, y, z, yRot, xRot); connection->teleport(x, y, z, yRot, xRot);
} }
void ServerPlayer::crit(shared_ptr<Entity> entity) void ServerPlayer::crit(std::shared_ptr<Entity> entity)
{ {
getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr<AnimatePacket>( new AnimatePacket(entity, AnimatePacket::CRITICAL_HIT) )); getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::shared_ptr<AnimatePacket>( new AnimatePacket(entity, AnimatePacket::CRITICAL_HIT) ));
} }
void ServerPlayer::magicCrit(shared_ptr<Entity> entity) void ServerPlayer::magicCrit(std::shared_ptr<Entity> entity)
{ {
getLevel()->getTracker()->broadcastAndSend(shared_from_this(), shared_ptr<AnimatePacket>( new AnimatePacket(entity, AnimatePacket::MAGIC_CRITICAL_HIT) )); getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::shared_ptr<AnimatePacket>( new AnimatePacket(entity, AnimatePacket::MAGIC_CRITICAL_HIT) ));
} }
void ServerPlayer::onUpdateAbilities() void ServerPlayer::onUpdateAbilities()
{ {
if (connection == NULL) return; if (connection == NULL) return;
connection->send(shared_ptr<PlayerAbilitiesPacket>(new PlayerAbilitiesPacket(&abilities))); connection->send(std::shared_ptr<PlayerAbilitiesPacket>(new PlayerAbilitiesPacket(&abilities)));
} }
ServerLevel *ServerPlayer::getLevel() ServerLevel *ServerPlayer::getLevel()
@ -1420,12 +1420,12 @@ ServerLevel *ServerPlayer::getLevel()
void ServerPlayer::setGameMode(GameType *mode) void ServerPlayer::setGameMode(GameType *mode)
{ {
gameMode->setGameModeForPlayer(mode); gameMode->setGameModeForPlayer(mode);
connection->send(shared_ptr<GameEventPacket>(new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, mode->getId()))); connection->send(std::shared_ptr<GameEventPacket>(new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, mode->getId())));
} }
void ServerPlayer::sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type /*= e_ChatCustom*/, int customData /*= -1*/, const wstring& additionalMessage /*= L""*/) void ServerPlayer::sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type /*= e_ChatCustom*/, int customData /*= -1*/, const wstring& additionalMessage /*= L""*/)
{ {
connection->send(shared_ptr<ChatPacket>(new ChatPacket(message,type,customData,additionalMessage))); connection->send(std::shared_ptr<ChatPacket>(new ChatPacket(message,type,customData,additionalMessage)));
} }
bool ServerPlayer::hasPermission(EGameCommand command) bool ServerPlayer::hasPermission(EGameCommand command)
@ -1434,7 +1434,7 @@ bool ServerPlayer::hasPermission(EGameCommand command)
} }
// 4J - Don't use // 4J - Don't use
//void ServerPlayer::updateOptions(shared_ptr<ClientInformationPacket> packet) //void ServerPlayer::updateOptions(std::shared_ptr<ClientInformationPacket> packet)
//{ //{
// // 4J - Don't need // // 4J - Don't need
// //if (language.getLanguageList().containsKey(packet.getLanguage())) // //if (language.getLanguageList().containsKey(packet.getLanguage()))
@ -1502,7 +1502,7 @@ int ServerPlayer::getPlayerViewDistanceModifier()
return value; return value;
} }
void ServerPlayer::handleCollectItem(shared_ptr<ItemInstance> item) void ServerPlayer::handleCollectItem(std::shared_ptr<ItemInstance> item)
{ {
if(gameMode->getGameRules() != NULL) gameMode->getGameRules()->onCollectItem(item); if(gameMode->getGameRules() != NULL) gameMode->getGameRules()->onCollectItem(item);
} }

View file

@ -17,7 +17,7 @@ class ServerPlayer : public Player, public net_minecraft_world_inventory::Contai
{ {
public: public:
eINSTANCEOF GetType() { return eTYPE_SERVERPLAYER; } eINSTANCEOF GetType() { return eTYPE_SERVERPLAYER; }
shared_ptr<PlayerConnection> connection; std::shared_ptr<PlayerConnection> connection;
MinecraftServer *server; MinecraftServer *server;
ServerPlayerGameMode *gameMode; ServerPlayerGameMode *gameMode;
double lastMoveX, lastMoveZ; double lastMoveX, lastMoveZ;
@ -59,7 +59,7 @@ public:
virtual float getHeadHeight(); virtual float getHeadHeight();
virtual void tick(); virtual void tick();
void flushEntitiesToRemove(); void flushEntitiesToRemove();
virtual shared_ptr<ItemInstance> getCarried(int slot); virtual std::shared_ptr<ItemInstance> getCarried(int slot);
virtual void die(DamageSource *source); virtual void die(DamageSource *source);
virtual bool hurt(DamageSource *dmgSource, int dmg); virtual bool hurt(DamageSource *dmgSource, int dmg);
virtual bool isPlayerVersusPlayer(); virtual bool isPlayerVersusPlayer();
@ -69,15 +69,15 @@ public:
void doTickB(bool ignorePortal); void doTickB(bool ignorePortal);
virtual void changeDimension(int i); virtual void changeDimension(int i);
private: private:
void broadcast(shared_ptr<TileEntity> te, bool delay = false); void broadcast(std::shared_ptr<TileEntity> te, bool delay = false);
public: public:
virtual void take(shared_ptr<Entity> e, int orgCount); virtual void take(std::shared_ptr<Entity> e, int orgCount);
virtual void swing(); virtual void swing();
virtual BedSleepingResult startSleepInBed(int x, int y, int z, bool bTestUse = false); virtual BedSleepingResult startSleepInBed(int x, int y, int z, bool bTestUse = false);
public: public:
virtual void stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool saveRespawnPoint); virtual void stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool saveRespawnPoint);
virtual void ride(shared_ptr<Entity> e); virtual void ride(std::shared_ptr<Entity> e);
protected: protected:
virtual void checkFallDamage(double ya, bool onGround); virtual void checkFallDamage(double ya, bool onGround);
public: public:
@ -97,14 +97,14 @@ public:
virtual bool startCrafting(int x, int y, int z); // 4J added bool return virtual bool startCrafting(int x, int y, int z); // 4J added bool return
virtual bool startEnchanting(int x, int y, int z); // 4J added bool return virtual bool startEnchanting(int x, int y, int z); // 4J added bool return
virtual bool startRepairing(int x, int y, int z); // 4J added bool return virtual bool startRepairing(int x, int y, int z); // 4J added bool return
virtual bool openContainer(shared_ptr<Container> container); // 4J added bool return virtual bool openContainer(std::shared_ptr<Container> container); // 4J added bool return
virtual bool openFurnace(shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return virtual bool openFurnace(std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
virtual bool openTrap(shared_ptr<DispenserTileEntity> trap); // 4J added bool return virtual bool openTrap(std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
virtual bool openBrewingStand(shared_ptr<BrewingStandTileEntity> brewingStand); // 4J added bool return virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity> brewingStand); // 4J added bool return
virtual bool openTrading(shared_ptr<Merchant> traderTarget); // 4J added bool return virtual bool openTrading(std::shared_ptr<Merchant> traderTarget); // 4J added bool return
virtual void slotChanged(AbstractContainerMenu *container, int slotIndex, shared_ptr<ItemInstance> item); virtual void slotChanged(AbstractContainerMenu *container, int slotIndex, std::shared_ptr<ItemInstance> item);
void refreshContainer(AbstractContainerMenu *menu); void refreshContainer(AbstractContainerMenu *menu);
virtual void refreshContainer(AbstractContainerMenu *container, vector<shared_ptr<ItemInstance> > *items); virtual void refreshContainer(AbstractContainerMenu *container, vector<std::shared_ptr<ItemInstance> > *items);
virtual void setContainerData(AbstractContainerMenu *container, int id, int value); virtual void setContainerData(AbstractContainerMenu *container, int id, int value);
virtual void closeContainer(); virtual void closeContainer();
void broadcastCarriedItem(); void broadcastCarriedItem();
@ -121,8 +121,8 @@ protected:
virtual void completeUsingItem(); virtual void completeUsingItem();
public: public:
virtual void startUsingItem(shared_ptr<ItemInstance> instance, int duration); virtual void startUsingItem(std::shared_ptr<ItemInstance> instance, int duration);
virtual void restoreFrom(shared_ptr<Player> oldPlayer, bool restoreAll); virtual void restoreFrom(std::shared_ptr<Player> oldPlayer, bool restoreAll);
protected: protected:
virtual void onEffectAdded(MobEffectInstance *effect); virtual void onEffectAdded(MobEffectInstance *effect);
@ -131,8 +131,8 @@ protected:
public: public:
virtual void teleportTo(double x, double y, double z); virtual void teleportTo(double x, double y, double z);
virtual void crit(shared_ptr<Entity> entity); virtual void crit(std::shared_ptr<Entity> entity);
virtual void magicCrit(shared_ptr<Entity> entity); virtual void magicCrit(std::shared_ptr<Entity> entity);
void onUpdateAbilities(); void onUpdateAbilities();
ServerLevel *getLevel(); ServerLevel *getLevel();
@ -140,7 +140,7 @@ public:
void sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom, int customData = -1, const wstring& additionalMessage = L""); void sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom, int customData = -1, const wstring& additionalMessage = L"");
bool hasPermission(EGameCommand command); bool hasPermission(EGameCommand command);
// 4J - Don't use // 4J - Don't use
//void updateOptions(shared_ptr<ClientInformationPacket> packet); //void updateOptions(std::shared_ptr<ClientInformationPacket> packet);
int getViewDistance(); int getViewDistance();
//bool canChatInColor(); //bool canChatInColor();
//int getChatVisibility(); //int getChatVisibility();
@ -152,7 +152,7 @@ public:
public: public:
// 4J Stu - Added hooks for the game rules // 4J Stu - Added hooks for the game rules
virtual void handleCollectItem(shared_ptr<ItemInstance> item); virtual void handleCollectItem(std::shared_ptr<ItemInstance> item);
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
void debug_setPosition(double,double,double,double,double); void debug_setPosition(double,double,double,double,double);

View file

@ -272,7 +272,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
if (isCreative()) if (isCreative())
{ {
shared_ptr<TileUpdatePacket> tup = shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ); std::shared_ptr<TileUpdatePacket> tup = std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) );
// 4J - a bit of a hack here, but if we want to tell the client that it needs to inform the renderer of a block being destroyed, then send a block 255 instead of a 0. This is handled in ClientConnection::handleTileUpdate // 4J - a bit of a hack here, but if we want to tell the client that it needs to inform the renderer of a block being destroyed, then send a block 255 instead of a 0. This is handled in ClientConnection::handleTileUpdate
if( tup->block == 0 ) if( tup->block == 0 )
{ {
@ -282,7 +282,7 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
} }
else else
{ {
shared_ptr<ItemInstance> item = player->getSelectedItem(); std::shared_ptr<ItemInstance> item = player->getSelectedItem();
bool canDestroy = player->canDestroy(Tile::tiles[t]); bool canDestroy = player->canDestroy(Tile::tiles[t]);
if (item != NULL) if (item != NULL)
{ {
@ -301,13 +301,13 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
} }
bool ServerPlayerGameMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly) bool ServerPlayerGameMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly)
{ {
if(!player->isAllowedToUse(item)) return false; if(!player->isAllowedToUse(item)) return false;
int oldCount = item->count; int oldCount = item->count;
int oldAux = item->getAuxValue(); int oldAux = item->getAuxValue();
shared_ptr<ItemInstance> itemInstance = item->use(level, player); std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
if ((itemInstance != NULL && itemInstance != item) || (itemInstance != NULL && itemInstance->count != oldCount) || (itemInstance != NULL && itemInstance->getUseDuration() > 0)) if ((itemInstance != NULL && itemInstance != item) || (itemInstance != NULL && itemInstance->count != oldCount) || (itemInstance != NULL && itemInstance->getUseDuration() > 0))
{ {
player->inventory->items[player->inventory->selected] = itemInstance; player->inventory->items[player->inventory->selected] = itemInstance;
@ -326,7 +326,7 @@ bool ServerPlayerGameMode::useItem(shared_ptr<Player> player, Level *level, shar
} }
bool ServerPlayerGameMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly, bool *pbUsedItem) bool ServerPlayerGameMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly, bool *pbUsedItem)
{ {
// 4J-PB - Adding a test only version to allow tooltips to be displayed // 4J-PB - Adding a test only version to allow tooltips to be displayed
int t = level->getTile(x, y, z); int t = level->getTile(x, y, z);

View file

@ -10,7 +10,7 @@ class ServerPlayerGameMode
{ {
public: public:
Level *level; Level *level;
shared_ptr<ServerPlayer> player; std::shared_ptr<ServerPlayer> player;
private: private:
GameType *gameModeForPlayer; GameType *gameModeForPlayer;
@ -53,8 +53,8 @@ private:
public: public:
bool destroyBlock(int x, int y, int z); bool destroyBlock(int x, int y, int z);
bool useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly=false); bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL); bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL);
void setLevel(ServerLevel *newLevel); void setLevel(ServerLevel *newLevel);
}; };

View file

@ -22,7 +22,7 @@
#include <qnet.h> #include <qnet.h>
#endif // __linux__ #endif // __linux__
TrackedEntity::TrackedEntity(shared_ptr<Entity> e, int range, int updateInterval, bool trackDelta) TrackedEntity::TrackedEntity(std::shared_ptr<Entity> e, int range, int updateInterval, bool trackDelta)
{ {
// 4J added initialisers // 4J added initialisers
xap = yap = zap = 0; xap = yap = zap = 0;
@ -48,7 +48,7 @@ TrackedEntity::TrackedEntity(shared_ptr<Entity> e, int range, int updateInterval
int c0a = 0, c0b = 0, c1a = 0, c1b = 0, c1c = 0, c2a = 0, c2b = 0; int c0a = 0, c0b = 0, c1a = 0, c1b = 0, c1c = 0, c2a = 0, c2b = 0;
void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *players) void TrackedEntity::tick(EntityTracker *tracker, vector<std::shared_ptr<Player> > *players)
{ {
moved = false; moved = false;
if (!updatedPlayerVisibility || e->distanceToSqr(xpu, ypu, zpu) > 4 * 4) if (!updatedPlayerVisibility || e->distanceToSqr(xpu, ypu, zpu) > 4 * 4)
@ -64,35 +64,35 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
if (wasRiding != e->riding) if (wasRiding != e->riding)
{ {
wasRiding = e->riding; wasRiding = e->riding;
broadcast(shared_ptr<SetRidingPacket>(new SetRidingPacket(e, e->riding))); broadcast(std::shared_ptr<SetRidingPacket>(new SetRidingPacket(e, e->riding)));
} }
// Moving forward special case for item frames // Moving forward special case for item frames
if (e->GetType()== eTYPE_ITEM_FRAME && tickCount % 10 == 0) if (e->GetType()== eTYPE_ITEM_FRAME && tickCount % 10 == 0)
{ {
shared_ptr<ItemFrame> frame = dynamic_pointer_cast<ItemFrame> (e); std::shared_ptr<ItemFrame> frame = dynamic_pointer_cast<ItemFrame> (e);
shared_ptr<ItemInstance> item = frame->getItem(); std::shared_ptr<ItemInstance> item = frame->getItem();
if (item != NULL && item->getItem()->id == Item::map_Id && !e->removed) if (item != NULL && item->getItem()->id == Item::map_Id && !e->removed)
{ {
shared_ptr<MapItemSavedData> data = Item::map->getSavedData(item, e->level); std::shared_ptr<MapItemSavedData> data = Item::map->getSavedData(item, e->level);
for (AUTO_VAR(it,players->begin() ); it != players->end(); ++it) 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);
data->tickCarriedBy(player, item); data->tickCarriedBy(player, item);
if (!player->removed && player->connection && player->connection->countDelayedPackets() <= 5) if (!player->removed && player->connection && player->connection->countDelayedPackets() <= 5)
{ {
shared_ptr<Packet> packet = Item::map->getUpdatePacket(item, e->level, player); std::shared_ptr<Packet> packet = Item::map->getUpdatePacket(item, e->level, player);
if (packet != NULL) player->connection->send(packet); if (packet != NULL) player->connection->send(packet);
} }
} }
} }
shared_ptr<SynchedEntityData> entityData = e->getEntityData(); std::shared_ptr<SynchedEntityData> entityData = e->getEntityData();
if (entityData->isDirty()) if (entityData->isDirty())
{ {
broadcastAndSend( shared_ptr<SetEntityDataPacket>( new SetEntityDataPacket(e->entityId, entityData, false) ) ); broadcastAndSend( std::shared_ptr<SetEntityDataPacket>( new SetEntityDataPacket(e->entityId, entityData, false) ) );
} }
} }
else else
@ -113,7 +113,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
int ya = yn - yp; int ya = yn - yp;
int za = zn - zp; int za = zn - zp;
shared_ptr<Packet> packet = nullptr; std::shared_ptr<Packet> packet = nullptr;
// 4J - this pos flag used to be set based on abs(xn) etc. but that just seems wrong // 4J - this pos flag used to be set based on abs(xn) etc. but that just seems wrong
bool pos = abs(xa) >= TOLERANCE_LEVEL || abs(ya) >= TOLERANCE_LEVEL || abs(za) >= TOLERANCE_LEVEL; bool pos = abs(xa) >= TOLERANCE_LEVEL || abs(ya) >= TOLERANCE_LEVEL || abs(za) >= TOLERANCE_LEVEL;
@ -136,7 +136,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
) )
{ {
teleportDelay = 0; teleportDelay = 0;
packet = shared_ptr<TeleportEntityPacket>( new TeleportEntityPacket(e->entityId, xn, yn, zn, (uint8_t) yRotn, (uint8_t) xRotn) ); packet = std::shared_ptr<TeleportEntityPacket>( new TeleportEntityPacket(e->entityId, xn, yn, zn, (uint8_t) yRotn, (uint8_t) xRotn) );
// printf("%d: New teleport rot %d\n",e->entityId,yRotn); // printf("%d: New teleport rot %d\n",e->entityId,yRotn);
yRotp = yRotn; yRotp = yRotn;
xRotp = xRotn; xRotp = xRotn;
@ -163,12 +163,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
yRotn = yRotp + yRota; yRotn = yRotp + yRota;
} }
// 5 bits each for x & z, and 6 for y // 5 bits each for x & z, and 6 for y
packet = shared_ptr<MoveEntityPacketSmall>( new MoveEntityPacketSmall::PosRot(e->entityId, (char) xa, (char) ya, (char) za, (char) yRota, 0 ) ); packet = std::shared_ptr<MoveEntityPacketSmall>( new MoveEntityPacketSmall::PosRot(e->entityId, (char) xa, (char) ya, (char) za, (char) yRota, 0 ) );
c0a++; c0a++;
} }
else else
{ {
packet = shared_ptr<MoveEntityPacket>( new MoveEntityPacket::PosRot(e->entityId, (char) xa, (char) ya, (char) za, (char) yRota, (char) xRota) ); packet = std::shared_ptr<MoveEntityPacket>( new MoveEntityPacket::PosRot(e->entityId, (char) xa, (char) ya, (char) za, (char) yRota, (char) xRota) );
// printf("%d: New posrot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); // printf("%d: New posrot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn);
c0b++; c0b++;
} }
@ -181,7 +181,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
( ya >= -16 ) && ( ya <= 15 ) ) ( ya >= -16 ) && ( ya <= 15 ) )
{ {
// 4 bits each for x & z, and 5 for y // 4 bits each for x & z, and 5 for y
packet = shared_ptr<MoveEntityPacketSmall>( new MoveEntityPacketSmall::Pos(e->entityId, (char) xa, (char) ya, (char) za) ); packet = std::shared_ptr<MoveEntityPacketSmall>( new MoveEntityPacketSmall::Pos(e->entityId, (char) xa, (char) ya, (char) za) );
c1a++; c1a++;
} }
@ -190,12 +190,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
( ya >= -32 ) && ( ya <= 31 ) ) ( ya >= -32 ) && ( ya <= 31 ) )
{ {
// use the packet with small packet with rotation if we can - 5 bits each for x & z, and 6 for y - still a byte less than the alternative // use the packet with small packet with rotation if we can - 5 bits each for x & z, and 6 for y - still a byte less than the alternative
packet = shared_ptr<MoveEntityPacketSmall>( new MoveEntityPacketSmall::PosRot(e->entityId, (char) xa, (char) ya, (char) za, 0, 0 )); packet = std::shared_ptr<MoveEntityPacketSmall>( new MoveEntityPacketSmall::PosRot(e->entityId, (char) xa, (char) ya, (char) za, 0, 0 ));
c1b++; c1b++;
} }
else else
{ {
packet = shared_ptr<MoveEntityPacket>( new MoveEntityPacket::Pos(e->entityId, (char) xa, (char) ya, (char) za) ); packet = std::shared_ptr<MoveEntityPacket>( new MoveEntityPacket::Pos(e->entityId, (char) xa, (char) ya, (char) za) );
c1c++; c1c++;
} }
} }
@ -215,13 +215,13 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
yRota = 15; yRota = 15;
yRotn = yRotp + yRota; yRotn = yRotp + yRota;
} }
packet = shared_ptr<MoveEntityPacketSmall>( new MoveEntityPacketSmall::Rot(e->entityId, (char) yRota, 0) ); packet = std::shared_ptr<MoveEntityPacketSmall>( new MoveEntityPacketSmall::Rot(e->entityId, (char) yRota, 0) );
c2a++; c2a++;
} }
else else
{ {
// printf("%d: New rot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); // printf("%d: New rot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn);
packet = shared_ptr<MoveEntityPacket>( new MoveEntityPacket::Rot(e->entityId, (char) yRota, (char) xRota) ); packet = std::shared_ptr<MoveEntityPacket>( new MoveEntityPacket::Rot(e->entityId, (char) yRota, (char) xRota) );
c2b++; c2b++;
} }
} }
@ -242,7 +242,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
xap = e->xd; xap = e->xd;
yap = e->yd; yap = e->yd;
zap = e->zd; zap = e->zd;
broadcast( shared_ptr<SetEntityMotionPacket>( new SetEntityMotionPacket(e->entityId, xap, yap, zap) ) ); broadcast( std::shared_ptr<SetEntityMotionPacket>( new SetEntityMotionPacket(e->entityId, xap, yap, zap) ) );
} }
} }
@ -252,17 +252,17 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
broadcast(packet); broadcast(packet);
} }
shared_ptr<SynchedEntityData> entityData = e->getEntityData(); std::shared_ptr<SynchedEntityData> entityData = e->getEntityData();
if (entityData->isDirty()) if (entityData->isDirty())
{ {
broadcastAndSend( shared_ptr<SetEntityDataPacket>( new SetEntityDataPacket(e->entityId, entityData, false) ) ); broadcastAndSend( std::shared_ptr<SetEntityDataPacket>( new SetEntityDataPacket(e->entityId, entityData, false) ) );
} }
int yHeadRot = Mth::floor(e->getYHeadRot() * 256 / 360); int yHeadRot = Mth::floor(e->getYHeadRot() * 256 / 360);
if (abs(yHeadRot - yHeadRotp) >= TOLERANCE_LEVEL) if (abs(yHeadRot - yHeadRotp) >= TOLERANCE_LEVEL)
{ {
broadcast(shared_ptr<RotateHeadPacket>(new RotateHeadPacket(e->entityId, (uint8_t) yHeadRot))); broadcast(std::shared_ptr<RotateHeadPacket>(new RotateHeadPacket(e->entityId, (uint8_t) yHeadRot)));
yHeadRotp = yHeadRot; yHeadRotp = yHeadRot;
} }
@ -287,9 +287,9 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
} }
else // 4J-JEV: Added: Mobs in minecarts weren't synching their invisibility. else // 4J-JEV: Added: Mobs in minecarts weren't synching their invisibility.
{ {
shared_ptr<SynchedEntityData> entityData = e->getEntityData(); std::shared_ptr<SynchedEntityData> entityData = e->getEntityData();
if (entityData->isDirty()) if (entityData->isDirty())
broadcastAndSend( shared_ptr<SetEntityDataPacket>( new SetEntityDataPacket(e->entityId, entityData, false) ) ); broadcastAndSend( std::shared_ptr<SetEntityDataPacket>( new SetEntityDataPacket(e->entityId, entityData, false) ) );
} }
e->hasImpulse = false; e->hasImpulse = false;
} }
@ -297,18 +297,18 @@ void TrackedEntity::tick(EntityTracker *tracker, vector<shared_ptr<Player> > *pl
if (e->hurtMarked) if (e->hurtMarked)
{ {
// broadcast(new AnimatePacket(e, AnimatePacket.HURT)); // broadcast(new AnimatePacket(e, AnimatePacket.HURT));
broadcastAndSend( shared_ptr<SetEntityMotionPacket>( new SetEntityMotionPacket(e) ) ); broadcastAndSend( std::shared_ptr<SetEntityMotionPacket>( new SetEntityMotionPacket(e) ) );
e->hurtMarked = false; e->hurtMarked = false;
} }
} }
void TrackedEntity::broadcast(shared_ptr<Packet> packet) void TrackedEntity::broadcast(std::shared_ptr<Packet> packet)
{ {
if( Packet::canSendToAnyClient( packet ) ) if( Packet::canSendToAnyClient( packet ) )
{ {
// 4J-PB - due to the knockback on a player being hit, we need to send to all players, but limit the network traffic here to players that have not already had it sent to their system // 4J-PB - due to the knockback on a player being hit, we need to send to all players, but limit the network traffic here to players that have not already had it sent to their system
vector< shared_ptr<ServerPlayer> > sentTo; vector< std::shared_ptr<ServerPlayer> > sentTo;
// 4J - don't send to a player we've already sent this data to that shares the same machine. // 4J - don't send to a player we've already sent this data to that shares the same machine.
// EntityMotionPacket used to limit themselves to sending once to each machine // EntityMotionPacket used to limit themselves to sending once to each machine
@ -318,7 +318,7 @@ void TrackedEntity::broadcast(shared_ptr<Packet> packet)
for( AUTO_VAR(it, seenBy.begin()); it != seenBy.end(); it++ ) for( AUTO_VAR(it, seenBy.begin()); it != seenBy.end(); it++ )
{ {
shared_ptr<ServerPlayer> player = *it; std::shared_ptr<ServerPlayer> player = *it;
bool dontSend = false; bool dontSend = false;
if( sentTo.size() ) if( sentTo.size() )
{ {
@ -331,13 +331,13 @@ void TrackedEntity::broadcast(shared_ptr<Packet> packet)
{ {
for(unsigned int j = 0; j < sentTo.size(); j++ ) 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(); INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
{ {
dontSend = true; dontSend = true;
// #ifdef _DEBUG // #ifdef _DEBUG
// shared_ptr<SetEntityMotionPacket> emp= dynamic_pointer_cast<SetEntityMotionPacket> (packet); // std::shared_ptr<SetEntityMotionPacket> emp= dynamic_pointer_cast<SetEntityMotionPacket> (packet);
// if(emp!=NULL) // if(emp!=NULL)
// { // {
// app.DebugPrintf("Not sending this SetEntityMotionPacket to player - it's already been sent to a player on their console\n"); // app.DebugPrintf("Not sending this SetEntityMotionPacket to player - it's already been sent to a player on their console\n");
@ -368,11 +368,11 @@ void TrackedEntity::broadcast(shared_ptr<Packet> packet)
} }
} }
void TrackedEntity::broadcastAndSend(shared_ptr<Packet> packet) void TrackedEntity::broadcastAndSend(std::shared_ptr<Packet> packet)
{ {
vector< shared_ptr<ServerPlayer> > sentTo; vector< std::shared_ptr<ServerPlayer> > sentTo;
broadcast(packet); broadcast(packet);
shared_ptr<ServerPlayer> sp = dynamic_pointer_cast<ServerPlayer>(e); std::shared_ptr<ServerPlayer> sp = dynamic_pointer_cast<ServerPlayer>(e);
if (sp != NULL && sp->connection) if (sp != NULL && sp->connection)
{ {
sp->connection->send(packet); sp->connection->send(packet);
@ -387,7 +387,7 @@ void TrackedEntity::broadcastRemoved()
} }
} }
void TrackedEntity::removePlayer(shared_ptr<ServerPlayer> sp) void TrackedEntity::removePlayer(std::shared_ptr<ServerPlayer> sp)
{ {
AUTO_VAR(it, seenBy.find( sp )); AUTO_VAR(it, seenBy.find( sp ));
if( it != seenBy.end() ) if( it != seenBy.end() )
@ -397,7 +397,7 @@ void TrackedEntity::removePlayer(shared_ptr<ServerPlayer> sp)
} }
// 4J-JEV: Added for code reuse. // 4J-JEV: Added for code reuse.
TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shared_ptr<ServerPlayer> sp, bool forRider) TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, std::shared_ptr<ServerPlayer> sp, bool forRider)
{ {
// 4J Stu - We call update players when the entity has moved more than a certain amount at the start of it's tick // 4J Stu - We call update players when the entity has moved more than a certain amount at the start of it's tick
// Before this call we set xpu, ypu and zpu to the entities new position, but xp,yp and zp are the old position until later in the tick. // Before this call we set xpu, ypu and zpu to the entities new position, but xp,yp and zp are the old position until later in the tick.
@ -426,7 +426,7 @@ TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shar
for( unsigned int i = 0; i < server->getPlayers()->players.size(); i++ ) for( unsigned int i = 0; i < server->getPlayers()->players.size(); i++ )
{ {
// Consider extra players, but not if they are the entity we are tracking, or the player we've been passed as input, or in another dimension // Consider extra players, but not if they are the entity we are tracking, or the player we've been passed as input, or in another dimension
shared_ptr<ServerPlayer> ep = server->getPlayers()->players[i]; std::shared_ptr<ServerPlayer> ep = server->getPlayers()->players[i];
if( ep == sp ) continue; if( ep == sp ) continue;
if( ep == e ) continue; if( ep == e ) continue;
if( ep->dimension != sp->dimension ) continue; if( ep->dimension != sp->dimension ) continue;
@ -463,7 +463,7 @@ TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shar
else return eVisibility_NotVisible; else return eVisibility_NotVisible;
} }
void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr<ServerPlayer> sp) void TrackedEntity::updatePlayer(EntityTracker *tracker, std::shared_ptr<ServerPlayer> sp)
{ {
if (sp == e) return; if (sp == e) return;
@ -473,14 +473,14 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr<ServerPlayer
&& seenBy.find(sp) == seenBy.end() ) && seenBy.find(sp) == seenBy.end() )
{ {
seenBy.insert(sp); seenBy.insert(sp);
shared_ptr<Packet> packet = getAddEntityPacket(); std::shared_ptr<Packet> packet = getAddEntityPacket();
sp->connection->send(packet); sp->connection->send(packet);
xap = e->xd; xap = e->xd;
yap = e->yd; yap = e->yd;
zap = e->zd; zap = e->zd;
shared_ptr<Player> plr = dynamic_pointer_cast<Player>(e); std::shared_ptr<Player> plr = dynamic_pointer_cast<Player>(e);
if (plr != NULL) if (plr != NULL)
{ {
app.DebugPrintf( "TrackedEntity:: Player '%ls' is now visible to player '%ls', %s.\n", app.DebugPrintf( "TrackedEntity:: Player '%ls' is now visible to player '%ls', %s.\n",
@ -492,17 +492,17 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr<ServerPlayer
// 4J Stu brought forward to fix when Item Frames // 4J Stu brought forward to fix when Item Frames
if (!e->getEntityData()->isEmpty() && !(dynamic_pointer_cast<AddMobPacket>(packet))) if (!e->getEntityData()->isEmpty() && !(dynamic_pointer_cast<AddMobPacket>(packet)))
{ {
sp->connection->send(shared_ptr<SetEntityDataPacket>( new SetEntityDataPacket(e->entityId, e->getEntityData(), true))); sp->connection->send(std::shared_ptr<SetEntityDataPacket>( new SetEntityDataPacket(e->entityId, e->getEntityData(), true)));
} }
if (this->trackDelta) if (this->trackDelta)
{ {
sp->connection->send( shared_ptr<SetEntityMotionPacket>( new SetEntityMotionPacket(e->entityId, e->xd, e->yd, e->zd) ) ); sp->connection->send( std::shared_ptr<SetEntityMotionPacket>( new SetEntityMotionPacket(e->entityId, e->xd, e->yd, e->zd) ) );
} }
if (e->riding != NULL) if (e->riding != NULL)
{ {
sp->connection->send(shared_ptr<SetRidingPacket>(new SetRidingPacket(e, e->riding))); sp->connection->send(std::shared_ptr<SetRidingPacket>(new SetRidingPacket(e, e->riding)));
} }
ItemInstanceArray equipped = e->getEquipmentSlots(); ItemInstanceArray equipped = e->getEquipmentSlots();
@ -510,28 +510,28 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr<ServerPlayer
{ {
for (unsigned int i = 0; i < equipped.length; i++) for (unsigned int i = 0; i < equipped.length; i++)
{ {
sp->connection->send( shared_ptr<SetEquippedItemPacket>( new SetEquippedItemPacket(e->entityId, i, equipped[i]) ) ); sp->connection->send( std::shared_ptr<SetEquippedItemPacket>( new SetEquippedItemPacket(e->entityId, i, equipped[i]) ) );
} }
} }
if (dynamic_pointer_cast<Player>(e) != NULL) if (dynamic_pointer_cast<Player>(e) != NULL)
{ {
shared_ptr<Player> spe = dynamic_pointer_cast<Player>(e); std::shared_ptr<Player> spe = dynamic_pointer_cast<Player>(e);
if (spe->isSleeping()) if (spe->isSleeping())
{ {
sp->connection->send( shared_ptr<EntityActionAtPositionPacket>( new EntityActionAtPositionPacket(e, EntityActionAtPositionPacket::START_SLEEP, Mth::floor(e->x), Mth::floor(e->y), Mth::floor(e->z)) ) ); sp->connection->send( std::shared_ptr<EntityActionAtPositionPacket>( new EntityActionAtPositionPacket(e, EntityActionAtPositionPacket::START_SLEEP, Mth::floor(e->x), Mth::floor(e->y), Mth::floor(e->z)) ) );
} }
} }
if (dynamic_pointer_cast<Mob>(e) != NULL) if (dynamic_pointer_cast<Mob>(e) != NULL)
{ {
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(e); std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(e);
vector<MobEffectInstance *> *activeEffects = mob->getActiveEffects(); vector<MobEffectInstance *> *activeEffects = mob->getActiveEffects();
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it) for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it)
{ {
MobEffectInstance *effect = *it; MobEffectInstance *effect = *it;
sp->connection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(e->entityId, effect) ) ); sp->connection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(e->entityId, effect) ) );
} }
delete activeEffects; delete activeEffects;
} }
@ -548,7 +548,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr<ServerPlayer
} }
bool TrackedEntity::canBySeenBy(shared_ptr<ServerPlayer> player) bool TrackedEntity::canBySeenBy(std::shared_ptr<ServerPlayer> player)
{ {
// 4J - for some reason this isn't currently working, and is causing players to not appear until we are really close to them. Not sure // 4J - for some reason this isn't currently working, and is causing players to not appear until we are really close to them. Not sure
// what the conflict is between the java & our version, but removing for now as it is causing issues and we shouldn't *really* need it // what the conflict is between the java & our version, but removing for now as it is causing issues and we shouldn't *really* need it
@ -558,7 +558,7 @@ bool TrackedEntity::canBySeenBy(shared_ptr<ServerPlayer> player)
// return player->getLevel()->getChunkMap()->isPlayerIn(player, e->xChunk, e->zChunk); // return player->getLevel()->getChunkMap()->isPlayerIn(player, e->xChunk, e->zChunk);
} }
void TrackedEntity::updatePlayers(EntityTracker *tracker, vector<shared_ptr<Player> > *players) void TrackedEntity::updatePlayers(EntityTracker *tracker, vector<std::shared_ptr<Player> > *players)
{ {
for (unsigned int i = 0; i < players->size(); i++) for (unsigned int i = 0; i < players->size(); i++)
{ {
@ -566,7 +566,7 @@ void TrackedEntity::updatePlayers(EntityTracker *tracker, vector<shared_ptr<Play
} }
} }
shared_ptr<Packet> TrackedEntity::getAddEntityPacket() std::shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
{ {
if (e->removed) if (e->removed)
{ {
@ -577,20 +577,20 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
if (dynamic_pointer_cast<Creature>(e) != NULL) if (dynamic_pointer_cast<Creature>(e) != NULL)
{ {
yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360);
return shared_ptr<AddMobPacket>( new AddMobPacket(dynamic_pointer_cast<Mob>(e), yRotp, xRotp, xp, yp, zp, yHeadRotp) ); return std::shared_ptr<AddMobPacket>( new AddMobPacket(dynamic_pointer_cast<Mob>(e), yRotp, xRotp, xp, yp, zp, yHeadRotp) );
} }
switch(e->GetType()) switch(e->GetType())
{ {
case eTYPE_ITEMENTITY: case eTYPE_ITEMENTITY:
{ {
shared_ptr<AddEntityPacket> packet = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ITEM, 1, yRotp, xRotp, xp, yp, zp) ); std::shared_ptr<AddEntityPacket> packet = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ITEM, 1, yRotp, xRotp, xp, yp, zp) );
return packet; return packet;
} }
break; break;
case eTYPE_SERVERPLAYER: case eTYPE_SERVERPLAYER:
{ {
shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(e); std::shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(e);
PlayerUID xuid = INVALID_XUID; PlayerUID xuid = INVALID_XUID;
PlayerUID OnlineXuid = INVALID_XUID; PlayerUID OnlineXuid = INVALID_XUID;
if( player != NULL ) if( player != NULL )
@ -599,76 +599,76 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
OnlineXuid = player->getOnlineXuid(); OnlineXuid = player->getOnlineXuid();
} }
// 4J Added yHeadRotp param to fix #102563 - TU12: Content: Gameplay: When one of the Players is idle for a few minutes his head turns 180 degrees. // 4J Added yHeadRotp param to fix #102563 - TU12: Content: Gameplay: When one of the Players is idle for a few minutes his head turns 180 degrees.
return shared_ptr<AddPlayerPacket>( new AddPlayerPacket(dynamic_pointer_cast<Player>(e), xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp, yHeadRotp ) ); return std::shared_ptr<AddPlayerPacket>( new AddPlayerPacket(dynamic_pointer_cast<Player>(e), xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp, yHeadRotp ) );
} }
break; break;
case eTYPE_MINECART: case eTYPE_MINECART:
{ {
shared_ptr<Minecart> minecart = dynamic_pointer_cast<Minecart>(e); std::shared_ptr<Minecart> minecart = dynamic_pointer_cast<Minecart>(e);
if (minecart->type == Minecart::RIDEABLE) return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_RIDEABLE, yRotp, xRotp, xp, yp, zp) ); if (minecart->type == Minecart::RIDEABLE) return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_RIDEABLE, yRotp, xRotp, xp, yp, zp) );
if (minecart->type == Minecart::CHEST) return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_CHEST, yRotp, xRotp, xp, yp, zp) ); if (minecart->type == Minecart::CHEST) return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_CHEST, yRotp, xRotp, xp, yp, zp) );
if (minecart->type == Minecart::FURNACE) return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_FURNACE, yRotp, xRotp, xp, yp, zp) ); if (minecart->type == Minecart::FURNACE) return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_FURNACE, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_BOAT: case eTYPE_BOAT:
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_ENDERDRAGON: case eTYPE_ENDERDRAGON:
{ {
yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360);
return shared_ptr<AddMobPacket>( new AddMobPacket(dynamic_pointer_cast<Mob>(e), yRotp, xRotp, xp, yp, zp, yHeadRotp ) ); return std::shared_ptr<AddMobPacket>( new AddMobPacket(dynamic_pointer_cast<Mob>(e), yRotp, xRotp, xp, yp, zp, yHeadRotp ) );
} }
break; break;
case eTYPE_FISHINGHOOK: case eTYPE_FISHINGHOOK:
{ {
shared_ptr<Entity> owner = dynamic_pointer_cast<FishingHook>(e)->owner; std::shared_ptr<Entity> owner = dynamic_pointer_cast<FishingHook>(e)->owner;
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_ARROW: case eTYPE_ARROW:
{ {
shared_ptr<Entity> owner = (dynamic_pointer_cast<Arrow>(e))->owner; std::shared_ptr<Entity> owner = (dynamic_pointer_cast<Arrow>(e))->owner;
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ARROW, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ARROW, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_SNOWBALL: case eTYPE_SNOWBALL:
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_THROWNPOTION: case eTYPE_THROWNPOTION:
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast<ThrownPotion>(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp)); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast<ThrownPotion>(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp));
} }
break; break;
case eTYPE_THROWNEXPBOTTLE: case eTYPE_THROWNEXPBOTTLE:
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_THROWNENDERPEARL: case eTYPE_THROWNENDERPEARL:
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_EYEOFENDERSIGNAL: case eTYPE_EYEOFENDERSIGNAL:
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_SMALL_FIREBALL: case eTYPE_SMALL_FIREBALL:
{ {
shared_ptr<SmallFireball> fb = dynamic_pointer_cast<SmallFireball>(e); std::shared_ptr<SmallFireball> fb = dynamic_pointer_cast<SmallFireball>(e);
shared_ptr<AddEntityPacket> aep = nullptr; std::shared_ptr<AddEntityPacket> aep = nullptr;
if (fb->owner != NULL) if (fb->owner != NULL)
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SMALL_FIREBALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SMALL_FIREBALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) );
} }
else else
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SMALL_FIREBALL, 0, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SMALL_FIREBALL, 0, yRotp, xRotp, xp, yp, zp) );
} }
aep->xa = (int) (fb->xPower * 8000); aep->xa = (int) (fb->xPower * 8000);
aep->ya = (int) (fb->yPower * 8000); aep->ya = (int) (fb->yPower * 8000);
@ -678,15 +678,15 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
break; break;
case eTYPE_DRAGON_FIREBALL: case eTYPE_DRAGON_FIREBALL:
{ {
shared_ptr<DragonFireball> fb = dynamic_pointer_cast<DragonFireball>(e); std::shared_ptr<DragonFireball> fb = dynamic_pointer_cast<DragonFireball>(e);
shared_ptr<AddEntityPacket> aep = nullptr; std::shared_ptr<AddEntityPacket> aep = nullptr;
if (fb->owner != NULL) if (fb->owner != NULL)
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::DRAGON_FIRE_BALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::DRAGON_FIRE_BALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) );
} }
else else
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::DRAGON_FIRE_BALL, 0, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::DRAGON_FIRE_BALL, 0, yRotp, xRotp, xp, yp, zp) );
} }
aep->xa = (int) (fb->xPower * 8000); aep->xa = (int) (fb->xPower * 8000);
aep->ya = (int) (fb->yPower * 8000); aep->ya = (int) (fb->yPower * 8000);
@ -696,15 +696,15 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
break; break;
case eTYPE_FIREBALL: case eTYPE_FIREBALL:
{ {
shared_ptr<Fireball> fb = dynamic_pointer_cast<Fireball>(e); std::shared_ptr<Fireball> fb = dynamic_pointer_cast<Fireball>(e);
shared_ptr<AddEntityPacket> aep = nullptr; std::shared_ptr<AddEntityPacket> aep = nullptr;
if (fb->owner != NULL) if (fb->owner != NULL)
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FIREBALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FIREBALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) );
} }
else else
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FIREBALL, 0, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FIREBALL, 0, yRotp, xRotp, xp, yp, zp) );
} }
aep->xa = (int) (fb->xPower * 8000); aep->xa = (int) (fb->xPower * 8000);
aep->ya = (int) (fb->yPower * 8000); aep->ya = (int) (fb->yPower * 8000);
@ -714,33 +714,33 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
break; break;
case eTYPE_THROWNEGG: case eTYPE_THROWNEGG:
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_PRIMEDTNT: case eTYPE_PRIMEDTNT:
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_ENDER_CRYSTAL: case eTYPE_ENDER_CRYSTAL:
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_FALLINGTILE: case eTYPE_FALLINGTILE:
{ {
shared_ptr<FallingTile> ft = dynamic_pointer_cast<FallingTile>(e); std::shared_ptr<FallingTile> ft = dynamic_pointer_cast<FallingTile>(e);
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FALLING, ft->tile | (ft->data << 16), yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FALLING, ft->tile | (ft->data << 16), yRotp, xRotp, xp, yp, zp) );
} }
break; break;
case eTYPE_PAINTING: case eTYPE_PAINTING:
{ {
return shared_ptr<AddPaintingPacket>( new AddPaintingPacket(dynamic_pointer_cast<Painting>(e)) ); return std::shared_ptr<AddPaintingPacket>( new AddPaintingPacket(dynamic_pointer_cast<Painting>(e)) );
} }
break; break;
case eTYPE_ITEM_FRAME: case eTYPE_ITEM_FRAME:
{ {
shared_ptr<ItemFrame> frame = dynamic_pointer_cast<ItemFrame>(e); std::shared_ptr<ItemFrame> frame = dynamic_pointer_cast<ItemFrame>(e);
{ {
int ix= (int)frame->xTile; int ix= (int)frame->xTile;
@ -749,7 +749,7 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
app.DebugPrintf("eTYPE_ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz); app.DebugPrintf("eTYPE_ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz);
} }
shared_ptr<AddEntityPacket> packet = shared_ptr<AddEntityPacket>(new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp)); std::shared_ptr<AddEntityPacket> packet = std::shared_ptr<AddEntityPacket>(new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp));
packet->x = Mth::floor(frame->xTile * 32.0f); packet->x = Mth::floor(frame->xTile * 32.0f);
packet->y = Mth::floor(frame->yTile * 32.0f); packet->y = Mth::floor(frame->yTile * 32.0f);
packet->z = Mth::floor(frame->zTile * 32.0f); packet->z = Mth::floor(frame->zTile * 32.0f);
@ -758,7 +758,7 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
break; break;
case eTYPE_EXPERIENCEORB: case eTYPE_EXPERIENCEORB:
{ {
return shared_ptr<AddExperienceOrbPacket>( new AddExperienceOrbPacket(dynamic_pointer_cast<ExperienceOrb>(e)) ); return std::shared_ptr<AddExperienceOrbPacket>( new AddExperienceOrbPacket(dynamic_pointer_cast<ExperienceOrb>(e)) );
} }
break; break;
default: default:
@ -768,8 +768,8 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
/* /*
if (e->GetType() == eTYPE_ITEMENTITY) if (e->GetType() == eTYPE_ITEMENTITY)
{ {
shared_ptr<ItemEntity> itemEntity = dynamic_pointer_cast<ItemEntity>(e); std::shared_ptr<ItemEntity> itemEntity = dynamic_pointer_cast<ItemEntity>(e);
shared_ptr<AddItemEntityPacket> packet = shared_ptr<AddItemEntityPacket>( new AddItemEntityPacket(itemEntity, xp, yp, zp) ); std::shared_ptr<AddItemEntityPacket> packet = std::shared_ptr<AddItemEntityPacket>( new AddItemEntityPacket(itemEntity, xp, yp, zp) );
itemEntity->x = packet->x / 32.0; itemEntity->x = packet->x / 32.0;
itemEntity->y = packet->y / 32.0; itemEntity->y = packet->y / 32.0;
itemEntity->z = packet->z / 32.0; itemEntity->z = packet->z / 32.0;
@ -778,7 +778,7 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
if (e->GetType() == eTYPE_SERVERPLAYER ) if (e->GetType() == eTYPE_SERVERPLAYER )
{ {
shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(e); std::shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(e);
XUID xuid = INVALID_XUID; XUID xuid = INVALID_XUID;
XUID OnlineXuid = INVALID_XUID; XUID OnlineXuid = INVALID_XUID;
if( player != NULL ) if( player != NULL )
@ -786,68 +786,68 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
xuid = player->getXuid(); xuid = player->getXuid();
OnlineXuid = player->getOnlineXuid(); OnlineXuid = player->getOnlineXuid();
} }
return shared_ptr<AddPlayerPacket>( new AddPlayerPacket(dynamic_pointer_cast<Player>(e), xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp ) ); return std::shared_ptr<AddPlayerPacket>( new AddPlayerPacket(dynamic_pointer_cast<Player>(e), xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp ) );
} }
if (e->GetType() == eTYPE_MINECART) if (e->GetType() == eTYPE_MINECART)
{ {
shared_ptr<Minecart> minecart = dynamic_pointer_cast<Minecart>(e); std::shared_ptr<Minecart> minecart = dynamic_pointer_cast<Minecart>(e);
if (minecart->type == Minecart::RIDEABLE) return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_RIDEABLE, yRotp, xRotp, xp, yp, zp) ); if (minecart->type == Minecart::RIDEABLE) return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_RIDEABLE, yRotp, xRotp, xp, yp, zp) );
if (minecart->type == Minecart::CHEST) return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_CHEST, yRotp, xRotp, xp, yp, zp) ); if (minecart->type == Minecart::CHEST) return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_CHEST, yRotp, xRotp, xp, yp, zp) );
if (minecart->type == Minecart::FURNACE) return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_FURNACE, yRotp, xRotp, xp, yp, zp) ); if (minecart->type == Minecart::FURNACE) return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::MINECART_FURNACE, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_BOAT) if (e->GetType() == eTYPE_BOAT)
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp) );
} }
if (dynamic_pointer_cast<Creature>(e) != NULL) if (dynamic_pointer_cast<Creature>(e) != NULL)
{ {
return shared_ptr<AddMobPacket>( new AddMobPacket(dynamic_pointer_cast<Mob>(e), yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddMobPacket>( new AddMobPacket(dynamic_pointer_cast<Mob>(e), yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_ENDERDRAGON) if (e->GetType() == eTYPE_ENDERDRAGON)
{ {
return shared_ptr<AddMobPacket>( new AddMobPacket(dynamic_pointer_cast<Mob>(e), yRotp, xRotp, xp, yp, zp ) ); return std::shared_ptr<AddMobPacket>( new AddMobPacket(dynamic_pointer_cast<Mob>(e), yRotp, xRotp, xp, yp, zp ) );
} }
if (e->GetType() == eTYPE_FISHINGHOOK) if (e->GetType() == eTYPE_FISHINGHOOK)
{ {
shared_ptr<Entity> owner = dynamic_pointer_cast<FishingHook>(e)->owner; std::shared_ptr<Entity> owner = dynamic_pointer_cast<FishingHook>(e)->owner;
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_ARROW) if (e->GetType() == eTYPE_ARROW)
{ {
shared_ptr<Entity> owner = (dynamic_pointer_cast<Arrow>(e))->owner; std::shared_ptr<Entity> owner = (dynamic_pointer_cast<Arrow>(e))->owner;
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ARROW, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ARROW, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_SNOWBALL) if (e->GetType() == eTYPE_SNOWBALL)
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_THROWNPOTION) if (e->GetType() == eTYPE_THROWNPOTION)
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast<ThrownPotion>(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp)); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast<ThrownPotion>(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp));
} }
if (e->GetType() == eTYPE_THROWNEXPBOTTLE) if (e->GetType() == eTYPE_THROWNEXPBOTTLE)
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_THROWNENDERPEARL) if (e->GetType() == eTYPE_THROWNENDERPEARL)
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_EYEOFENDERSIGNAL) if (e->GetType() == eTYPE_EYEOFENDERSIGNAL)
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_SMALL_FIREBALL) if (e->GetType() == eTYPE_SMALL_FIREBALL)
{ {
shared_ptr<SmallFireball> fb = dynamic_pointer_cast<SmallFireball>(e); std::shared_ptr<SmallFireball> fb = dynamic_pointer_cast<SmallFireball>(e);
shared_ptr<AddEntityPacket> aep = NULL; std::shared_ptr<AddEntityPacket> aep = NULL;
if (fb->owner != NULL) if (fb->owner != NULL)
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SMALL_FIREBALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SMALL_FIREBALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) );
} }
else else
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SMALL_FIREBALL, 0, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::SMALL_FIREBALL, 0, yRotp, xRotp, xp, yp, zp) );
} }
aep->xa = (int) (fb->xPower * 8000); aep->xa = (int) (fb->xPower * 8000);
aep->ya = (int) (fb->yPower * 8000); aep->ya = (int) (fb->yPower * 8000);
@ -856,15 +856,15 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
} }
if (e->GetType() == eTYPE_FIREBALL) if (e->GetType() == eTYPE_FIREBALL)
{ {
shared_ptr<Fireball> fb = dynamic_pointer_cast<Fireball>(e); std::shared_ptr<Fireball> fb = dynamic_pointer_cast<Fireball>(e);
shared_ptr<AddEntityPacket> aep = NULL; std::shared_ptr<AddEntityPacket> aep = NULL;
if (fb->owner != NULL) if (fb->owner != NULL)
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FIREBALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FIREBALL, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) );
} }
else else
{ {
aep = shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FIREBALL, 0, yRotp, xRotp, xp, yp, zp) ); aep = std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FIREBALL, 0, yRotp, xRotp, xp, yp, zp) );
} }
aep->xa = (int) (fb->xPower * 8000); aep->xa = (int) (fb->xPower * 8000);
aep->ya = (int) (fb->yPower * 8000); aep->ya = (int) (fb->yPower * 8000);
@ -873,30 +873,30 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
} }
if (e->GetType() == eTYPE_THROWNEGG) if (e->GetType() == eTYPE_THROWNEGG)
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_PRIMEDTNT) if (e->GetType() == eTYPE_PRIMEDTNT)
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_ENDER_CRYSTAL) if (e->GetType() == eTYPE_ENDER_CRYSTAL)
{ {
return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp) ); return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_FALLINGTILE) if (e->GetType() == eTYPE_FALLINGTILE)
{ {
shared_ptr<FallingTile> ft = dynamic_pointer_cast<FallingTile>(e); std::shared_ptr<FallingTile> ft = dynamic_pointer_cast<FallingTile>(e);
if (ft->tile == Tile::sand_Id) return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FALLING_SAND, yRotp, xRotp, xp, yp, zp) ); if (ft->tile == Tile::sand_Id) return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FALLING_SAND, yRotp, xRotp, xp, yp, zp) );
if (ft->tile == Tile::gravel_Id) return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FALLING_GRAVEL, yRotp, xRotp, xp, yp, zp) ); if (ft->tile == Tile::gravel_Id) return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FALLING_GRAVEL, yRotp, xRotp, xp, yp, zp) );
if (ft->tile == Tile::dragonEgg_Id) return shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FALLING_EGG, yRotp, xRotp, xp, yp, zp) ); if (ft->tile == Tile::dragonEgg_Id) return std::shared_ptr<AddEntityPacket>( new AddEntityPacket(e, AddEntityPacket::FALLING_EGG, yRotp, xRotp, xp, yp, zp) );
} }
if (e->GetType() == eTYPE_PAINTING) if (e->GetType() == eTYPE_PAINTING)
{ {
return shared_ptr<AddPaintingPacket>( new AddPaintingPacket(dynamic_pointer_cast<Painting>(e)) ); return std::shared_ptr<AddPaintingPacket>( new AddPaintingPacket(dynamic_pointer_cast<Painting>(e)) );
} }
if (e->GetType() == eTYPE_ITEM_FRAME) if (e->GetType() == eTYPE_ITEM_FRAME)
{ {
shared_ptr<ItemFrame> frame = dynamic_pointer_cast<ItemFrame>(e); std::shared_ptr<ItemFrame> frame = dynamic_pointer_cast<ItemFrame>(e);
{ {
int ix= (int)frame->xTile; int ix= (int)frame->xTile;
@ -905,7 +905,7 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
app.DebugPrintf("eTYPE_ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz); app.DebugPrintf("eTYPE_ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz);
} }
shared_ptr<AddEntityPacket> packet = shared_ptr<AddEntityPacket>(new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp)); std::shared_ptr<AddEntityPacket> packet = std::shared_ptr<AddEntityPacket>(new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp));
packet->x = Mth::floor(frame->xTile * 32.0f); packet->x = Mth::floor(frame->xTile * 32.0f);
packet->y = Mth::floor(frame->yTile * 32.0f); packet->y = Mth::floor(frame->yTile * 32.0f);
packet->z = Mth::floor(frame->zTile * 32.0f); packet->z = Mth::floor(frame->zTile * 32.0f);
@ -913,14 +913,14 @@ shared_ptr<Packet> TrackedEntity::getAddEntityPacket()
} }
if (e->GetType() == eTYPE_EXPERIENCEORB) if (e->GetType() == eTYPE_EXPERIENCEORB)
{ {
return shared_ptr<AddExperienceOrbPacket>( new AddExperienceOrbPacket(dynamic_pointer_cast<ExperienceOrb>(e)) ); return std::shared_ptr<AddExperienceOrbPacket>( new AddExperienceOrbPacket(dynamic_pointer_cast<ExperienceOrb>(e)) );
} }
assert(false); assert(false);
*/ */
return nullptr; return nullptr;
} }
void TrackedEntity::clear(shared_ptr<ServerPlayer> sp) void TrackedEntity::clear(std::shared_ptr<ServerPlayer> sp)
{ {
AUTO_VAR(it, seenBy.find(sp)); AUTO_VAR(it, seenBy.find(sp));
if (it != seenBy.end()) if (it != seenBy.end())

View file

@ -15,7 +15,7 @@ private:
static const int TOLERANCE_LEVEL = 4; static const int TOLERANCE_LEVEL = 4;
public: public:
shared_ptr<Entity> e; std::shared_ptr<Entity> e;
int range, updateInterval; int range, updateInterval;
int xp, yp, zp, yRotp, xRotp, yHeadRotp; int xp, yp, zp, yRotp, xRotp, yHeadRotp;
@ -27,23 +27,23 @@ private:
bool updatedPlayerVisibility; bool updatedPlayerVisibility;
bool trackDelta; bool trackDelta;
int teleportDelay; int teleportDelay;
shared_ptr<Entity> wasRiding; std::shared_ptr<Entity> wasRiding;
public: public:
bool moved; bool moved;
unordered_set<shared_ptr<ServerPlayer> , PlayerKeyHash, PlayerKeyEq > seenBy; unordered_set<std::shared_ptr<ServerPlayer> , PlayerKeyHash, PlayerKeyEq > seenBy;
TrackedEntity(shared_ptr<Entity> e, int range, int updateInterval, bool trackDelta); TrackedEntity(std::shared_ptr<Entity> e, int range, int updateInterval, bool trackDelta);
void tick(EntityTracker *tracker, vector<shared_ptr<Player> > *players); void tick(EntityTracker *tracker, vector<std::shared_ptr<Player> > *players);
void broadcast(shared_ptr<Packet> packet); void broadcast(std::shared_ptr<Packet> packet);
void broadcastAndSend(shared_ptr<Packet> packet); void broadcastAndSend(std::shared_ptr<Packet> packet);
void broadcastRemoved(); void broadcastRemoved();
void removePlayer(shared_ptr<ServerPlayer> sp); void removePlayer(std::shared_ptr<ServerPlayer> sp);
private: private:
bool canBySeenBy(shared_ptr<ServerPlayer> player); bool canBySeenBy(std::shared_ptr<ServerPlayer> player);
enum eVisibility enum eVisibility
{ {
@ -52,14 +52,14 @@ private:
eVisibility_SeenAndVisible = 2, eVisibility_SeenAndVisible = 2,
}; };
eVisibility isVisible(EntityTracker *tracker, shared_ptr<ServerPlayer> sp, bool forRider = false); // 4J Added forRider eVisibility isVisible(EntityTracker *tracker, std::shared_ptr<ServerPlayer> sp, bool forRider = false); // 4J Added forRider
public: public:
void updatePlayer(EntityTracker *tracker, shared_ptr<ServerPlayer> sp); void updatePlayer(EntityTracker *tracker, std::shared_ptr<ServerPlayer> sp);
void updatePlayers(EntityTracker *tracker, vector<shared_ptr<Player> > *players); void updatePlayers(EntityTracker *tracker, vector<std::shared_ptr<Player> > *players);
private: private:
void sendEntityData(shared_ptr<PlayerConnection> conn); void sendEntityData(std::shared_ptr<PlayerConnection> conn);
shared_ptr<Packet> getAddEntityPacket(); std::shared_ptr<Packet> getAddEntityPacket();
public: public:
void clear(shared_ptr<ServerPlayer> sp); void clear(std::shared_ptr<ServerPlayer> sp);
}; };

View file

@ -21,7 +21,7 @@ float Camera::za = 0.0f;
float Camera::xa2 = 0.0f; float Camera::xa2 = 0.0f;
float Camera::za2 = 0.0f; float Camera::za2 = 0.0f;
void Camera::prepare(shared_ptr<Player> player, bool mirror) void Camera::prepare(std::shared_ptr<Player> player, bool mirror)
{ {
glGetFloat(GL_MODELVIEW_MATRIX, modelview); glGetFloat(GL_MODELVIEW_MATRIX, modelview);
glGetFloat(GL_PROJECTION_MATRIX, projection); glGetFloat(GL_PROJECTION_MATRIX, projection);
@ -88,12 +88,12 @@ void Camera::prepare(shared_ptr<Player> player, bool mirror)
ya = cosf(xRot * PI / 180.0f); ya = cosf(xRot * PI / 180.0f);
} }
TilePos *Camera::getCameraTilePos(shared_ptr<Mob> player, double alpha) TilePos *Camera::getCameraTilePos(std::shared_ptr<Mob> player, double alpha)
{ {
return new TilePos(getCameraPos(player, alpha)); return new TilePos(getCameraPos(player, alpha));
} }
Vec3 *Camera::getCameraPos(shared_ptr<Mob> player, double alpha) Vec3 *Camera::getCameraPos(std::shared_ptr<Mob> player, double alpha)
{ {
double xx = player->xo + (player->x - player->xo) * alpha; double xx = player->xo + (player->x - player->xo) * alpha;
double yy = player->yo + (player->y - player->yo) * alpha + player->getHeadHeight(); double yy = player->yo + (player->y - player->yo) * alpha + player->getHeadHeight();
@ -106,7 +106,7 @@ Vec3 *Camera::getCameraPos(shared_ptr<Mob> player, double alpha)
return Vec3::newTemp(xt, yt, zt); return Vec3::newTemp(xt, yt, zt);
} }
int Camera::getBlockAt(Level *level, shared_ptr<Mob> player, float alpha) int Camera::getBlockAt(Level *level, std::shared_ptr<Mob> player, float alpha)
{ {
Vec3 *p = Camera::getCameraPos(player, alpha); Vec3 *p = Camera::getCameraPos(player, alpha);
TilePos tp = TilePos(p); TilePos tp = TilePos(p);

View file

@ -24,9 +24,9 @@ private:
public: public:
static float xa, ya, za, xa2, za2; static float xa, ya, za, xa2, za2;
static void prepare(shared_ptr<Player> player, bool mirror); static void prepare(std::shared_ptr<Player> player, bool mirror);
static TilePos *getCameraTilePos(shared_ptr<Mob> player, double alpha); static TilePos *getCameraTilePos(std::shared_ptr<Mob> player, double alpha);
static Vec3 *getCameraPos(shared_ptr<Mob> player, double alpha); static Vec3 *getCameraPos(std::shared_ptr<Mob> player, double alpha);
static int getBlockAt(Level *level, shared_ptr<Mob> player, float alpha); static int getBlockAt(Level *level, std::shared_ptr<Mob> player, float alpha);
}; };

View file

@ -204,10 +204,10 @@ void Chunk::rebuild()
LevelChunk::touchedSky = false; LevelChunk::touchedSky = false;
// unordered_set<shared_ptr<TileEntity> > oldTileEntities(renderableTileEntities.begin(),renderableTileEntities.end()); // 4J removed this & next line // unordered_set<std::shared_ptr<TileEntity> > oldTileEntities(renderableTileEntities.begin(),renderableTileEntities.end()); // 4J removed this & next line
// renderableTileEntities.clear(); // renderableTileEntities.clear();
vector<shared_ptr<TileEntity> > renderableTileEntities; // 4J - added vector<std::shared_ptr<TileEntity> > renderableTileEntities; // 4J - added
int r = 1; int r = 1;
@ -402,7 +402,7 @@ void Chunk::rebuild()
Tile *tile = Tile::tiles[tileId]; Tile *tile = Tile::tiles[tileId];
if (currentLayer == 0 && tile->isEntityTile()) if (currentLayer == 0 && tile->isEntityTile())
{ {
shared_ptr<TileEntity> et = region->getTileEntity(x, y, z); std::shared_ptr<TileEntity> et = region->getTileEntity(x, y, z);
if (TileEntityRenderDispatcher::instance->hasRenderer(et)) if (TileEntityRenderDispatcher::instance->hasRenderer(et))
{ {
renderableTileEntities.push_back(et); renderableTileEntities.push_back(et);
@ -554,10 +554,10 @@ void Chunk::rebuild()
*/ */
unordered_set<shared_ptr<TileEntity> > newTileEntities(renderableTileEntities.begin(),renderableTileEntities.end()); unordered_set<std::shared_ptr<TileEntity> > newTileEntities(renderableTileEntities.begin(),renderableTileEntities.end());
AUTO_VAR(endIt, oldTileEntities.end()); AUTO_VAR(endIt, oldTileEntities.end());
for( unordered_set<shared_ptr<TileEntity> >::iterator it = oldTileEntities.begin(); it != endIt; it++ ) for( unordered_set<std::shared_ptr<TileEntity> >::iterator it = oldTileEntities.begin(); it != endIt; it++ )
{ {
newTileEntities.erase(*it); newTileEntities.erase(*it);
} }
@ -566,7 +566,7 @@ void Chunk::rebuild()
EnterCriticalSection(globalRenderableTileEntities_cs); EnterCriticalSection(globalRenderableTileEntities_cs);
endIt = newTileEntities.end(); endIt = newTileEntities.end();
for( unordered_set<shared_ptr<TileEntity> >::iterator it = newTileEntities.begin(); it != endIt; it++ ) for( unordered_set<std::shared_ptr<TileEntity> >::iterator it = newTileEntities.begin(); it != endIt; it++ )
{ {
globalRenderableTileEntities->push_back(*it); globalRenderableTileEntities->push_back(*it);
} }
@ -574,12 +574,12 @@ void Chunk::rebuild()
// 4J - All these new things added to globalRenderableTileEntities // 4J - All these new things added to globalRenderableTileEntities
AUTO_VAR(endItRTE, renderableTileEntities.end()); AUTO_VAR(endItRTE, renderableTileEntities.end());
for( vector<shared_ptr<TileEntity> >::iterator it = renderableTileEntities.begin(); it != endItRTE; it++ ) for( vector<std::shared_ptr<TileEntity> >::iterator it = renderableTileEntities.begin(); it != endItRTE; it++ )
{ {
oldTileEntities.erase(*it); oldTileEntities.erase(*it);
} }
// 4J - oldTileEntities is now the removed items // 4J - oldTileEntities is now the removed items
vector<shared_ptr<TileEntity> >::iterator it = globalRenderableTileEntities->begin(); vector<std::shared_ptr<TileEntity> >::iterator it = globalRenderableTileEntities->begin();
while( it != globalRenderableTileEntities->end() ) while( it != globalRenderableTileEntities->end() )
{ {
if( oldTileEntities.find(*it) != oldTileEntities.end() ) if( oldTileEntities.find(*it) != oldTileEntities.end() )
@ -656,10 +656,10 @@ void Chunk::rebuild_SPU()
LevelChunk::touchedSky = false; LevelChunk::touchedSky = false;
// unordered_set<shared_ptr<TileEntity> > oldTileEntities(renderableTileEntities.begin(),renderableTileEntities.end()); // 4J removed this & next line // unordered_set<std::shared_ptr<TileEntity> > oldTileEntities(renderableTileEntities.begin(),renderableTileEntities.end()); // 4J removed this & next line
// renderableTileEntities.clear(); // renderableTileEntities.clear();
vector<shared_ptr<TileEntity> > renderableTileEntities; // 4J - added vector<std::shared_ptr<TileEntity> > renderableTileEntities; // 4J - added
// List<TileEntity> newTileEntities = new ArrayList<TileEntity>(); // List<TileEntity> newTileEntities = new ArrayList<TileEntity>();
// newTileEntities.clear(); // newTileEntities.clear();
@ -750,7 +750,7 @@ void Chunk::rebuild_SPU()
{ {
if (currentLayer == 0 && Tile::tiles[tileId]->isEntityTile()) if (currentLayer == 0 && Tile::tiles[tileId]->isEntityTile())
{ {
shared_ptr<TileEntity> et = region.getTileEntity(x, y, z); std::shared_ptr<TileEntity> et = region.getTileEntity(x, y, z);
if (TileEntityRenderDispatcher::instance->hasRenderer(et)) if (TileEntityRenderDispatcher::instance->hasRenderer(et))
{ {
renderableTileEntities.push_back(et); renderableTileEntities.push_back(et);
@ -883,10 +883,10 @@ void Chunk::rebuild_SPU()
*/ */
unordered_set<shared_ptr<TileEntity> > newTileEntities(renderableTileEntities.begin(),renderableTileEntities.end()); unordered_set<std::shared_ptr<TileEntity> > newTileEntities(renderableTileEntities.begin(),renderableTileEntities.end());
AUTO_VAR(endIt, oldTileEntities.end()); AUTO_VAR(endIt, oldTileEntities.end());
for( unordered_set<shared_ptr<TileEntity> >::iterator it = oldTileEntities.begin(); it != endIt; it++ ) for( unordered_set<std::shared_ptr<TileEntity> >::iterator it = oldTileEntities.begin(); it != endIt; it++ )
{ {
newTileEntities.erase(*it); newTileEntities.erase(*it);
} }
@ -895,7 +895,7 @@ void Chunk::rebuild_SPU()
EnterCriticalSection(globalRenderableTileEntities_cs); EnterCriticalSection(globalRenderableTileEntities_cs);
endIt = newTileEntities.end(); endIt = newTileEntities.end();
for( unordered_set<shared_ptr<TileEntity> >::iterator it = newTileEntities.begin(); it != endIt; it++ ) for( unordered_set<std::shared_ptr<TileEntity> >::iterator it = newTileEntities.begin(); it != endIt; it++ )
{ {
globalRenderableTileEntities.push_back(*it); globalRenderableTileEntities.push_back(*it);
} }
@ -903,12 +903,12 @@ void Chunk::rebuild_SPU()
// 4J - All these new things added to globalRenderableTileEntities // 4J - All these new things added to globalRenderableTileEntities
AUTO_VAR(endItRTE, renderableTileEntities.end()); AUTO_VAR(endItRTE, renderableTileEntities.end());
for( vector<shared_ptr<TileEntity> >::iterator it = renderableTileEntities.begin(); it != endItRTE; it++ ) for( vector<std::shared_ptr<TileEntity> >::iterator it = renderableTileEntities.begin(); it != endItRTE; it++ )
{ {
oldTileEntities.erase(*it); oldTileEntities.erase(*it);
} }
// 4J - oldTileEntities is now the removed items // 4J - oldTileEntities is now the removed items
vector<shared_ptr<TileEntity> >::iterator it = globalRenderableTileEntities->begin(); vector<std::shared_ptr<TileEntity> >::iterator it = globalRenderableTileEntities->begin();
while( it != globalRenderableTileEntities->end() ) while( it != globalRenderableTileEntities->end() )
{ {
if( oldTileEntities.find(*it) != oldTileEntities.end() ) if( oldTileEntities.find(*it) != oldTileEntities.end() )
@ -941,7 +941,7 @@ void Chunk::rebuild_SPU()
#endif // _PS3_ #endif // _PS3_
float Chunk::distanceToSqr(shared_ptr<Entity> player) const float Chunk::distanceToSqr(std::shared_ptr<Entity> player) const
{ {
float xd = (float) (player->x - xm); float xd = (float) (player->x - xm);
float yd = (float) (player->y - ym); float yd = (float) (player->y - ym);
@ -949,7 +949,7 @@ float Chunk::distanceToSqr(shared_ptr<Entity> player) const
return xd * xd + yd * yd + zd * zd; return xd * xd + yd * yd + zd * zd;
} }
float Chunk::squishedDistanceToSqr(shared_ptr<Entity> player) float Chunk::squishedDistanceToSqr(std::shared_ptr<Entity> player)
{ {
float xd = (float) (player->x - xm); float xd = (float) (player->x - xm);
float yd = (float) (player->y - ym) * 2; float yd = (float) (player->y - ym) * 2;

View file

@ -52,7 +52,7 @@ public:
int id; int id;
//public: //public:
// vector<shared_ptr<TileEntity> > renderableTileEntities; // 4J - removed // vector<std::shared_ptr<TileEntity> > renderableTileEntities; // 4J - removed
private: private:
LevelRenderer::rteMap *globalRenderableTileEntities; LevelRenderer::rteMap *globalRenderableTileEntities;
@ -71,8 +71,8 @@ public:
#ifdef __PS3__ #ifdef __PS3__
void rebuild_SPU(); void rebuild_SPU();
#endif // __PS3__ #endif // __PS3__
float distanceToSqr(shared_ptr<Entity> player) const; float distanceToSqr(std::shared_ptr<Entity> player) const;
float squishedDistanceToSqr(shared_ptr<Entity> player); float squishedDistanceToSqr(std::shared_ptr<Entity> player);
void reset(); void reset();
void _delete(); void _delete();

View file

@ -3,7 +3,7 @@
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.player.h" #include "../../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
#include "../Chunk.h" #include "../Chunk.h"
DirtyChunkSorter::DirtyChunkSorter(shared_ptr<Mob> cameraEntity, int playerIndex) // 4J - added player index DirtyChunkSorter::DirtyChunkSorter(std::shared_ptr<Mob> cameraEntity, int playerIndex) // 4J - added player index
{ {
this->cameraEntity = cameraEntity; this->cameraEntity = cameraEntity;
this->playerIndex = playerIndex; this->playerIndex = playerIndex;

View file

@ -5,10 +5,10 @@ class Mob;
class DirtyChunkSorter : public std::binary_function<const Chunk *,const Chunk *,bool> class DirtyChunkSorter : public std::binary_function<const Chunk *,const Chunk *,bool>
{ {
private: private:
shared_ptr<Mob> cameraEntity; std::shared_ptr<Mob> cameraEntity;
int playerIndex; // 4J added int playerIndex; // 4J added
public: public:
DirtyChunkSorter(shared_ptr<Mob> cameraEntity, int playerIndex); // 4J - added player index DirtyChunkSorter(std::shared_ptr<Mob> cameraEntity, int playerIndex); // 4J - added player index
bool operator()(const Chunk *a, const Chunk *b) const; bool operator()(const Chunk *a, const Chunk *b) const;
}; };

View file

@ -3,7 +3,7 @@
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.player.h" #include "../../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
#include "../Chunk.h" #include "../Chunk.h"
DistanceChunkSorter::DistanceChunkSorter(shared_ptr<Entity> player) DistanceChunkSorter::DistanceChunkSorter(std::shared_ptr<Entity> player)
{ {
ix = -player->x; ix = -player->x;
iy = -player->y; iy = -player->y;

View file

@ -8,6 +8,6 @@ private:
double ix, iy, iz; double ix, iy, iz;
public: public:
DistanceChunkSorter(shared_ptr<Entity> player); DistanceChunkSorter(std::shared_ptr<Entity> player);
bool operator()(const Chunk *a, const Chunk *b) const; bool operator()(const Chunk *a, const Chunk *b) const;
}; };

View file

@ -49,7 +49,7 @@ bool ViewportCuller::Face::fullyInFront(double x0, double y0, double z0, double
return true; return true;
} }
ViewportCuller::ViewportCuller(shared_ptr<Mob> mob, double fogDistance, float a) ViewportCuller::ViewportCuller(std::shared_ptr<Mob> mob, double fogDistance, float a)
{ {
float yRot = mob->yRotO+(mob->yRot-mob->yRotO)*a; float yRot = mob->yRotO+(mob->yRot-mob->yRotO)*a;
float xRot = mob->xRotO+(mob->xRot-mob->xRotO)*a; float xRot = mob->xRotO+(mob->xRot-mob->xRotO)*a;

View file

@ -24,7 +24,7 @@ private:
Face faces[6]; Face faces[6];
double xOff, yOff, zOff; double xOff, yOff, zOff;
public: public:
ViewportCuller(shared_ptr<Mob> mob, double fogDistance, float a); ViewportCuller(std::shared_ptr<Mob> mob, double fogDistance, float a);
virtual bool isVisible(AABB bb); virtual bool isVisible(AABB bb);
virtual bool cubeInFrustum(double x0, double y0, double z0, double x1, double y1, double z1); virtual bool cubeInFrustum(double x0, double y0, double z0, double x1, double y1, double z1);
virtual bool cubeFullyInFrustum(double x0, double y0, double z0, double x1, double y1, double z1); virtual bool cubeFullyInFrustum(double x0, double y0, double z0, double x1, double y1, double z1);

View file

@ -3,11 +3,11 @@
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.projectile.h" #include "../../../Minecraft.World/Headers/net.minecraft.world.entity.projectile.h"
#include "../../../Minecraft.World/Util/Mth.h" #include "../../../Minecraft.World/Util/Mth.h"
void ArrowRenderer::render(shared_ptr<Entity> _arrow, double x, double y, double z, float rot, float a) void ArrowRenderer::render(std::shared_ptr<Entity> _arrow, double x, double y, double z, float rot, float a)
{ {
// 4J - original version used generics and thus had an input parameter of type Arrow rather than shared_ptr<Entity> we have here - // 4J - original version used generics and thus had an input parameter of type Arrow rather than std::shared_ptr<Entity> we have here -
// do some casting around instead // do some casting around instead
shared_ptr<Arrow> arrow = dynamic_pointer_cast<Arrow>(_arrow); std::shared_ptr<Arrow> arrow = dynamic_pointer_cast<Arrow>(_arrow);
bindTexture(TN_ITEM_ARROWS); // 4J - was L"/item/arrows.png" bindTexture(TN_ITEM_ARROWS); // 4J - was L"/item/arrows.png"
glPushMatrix(); glPushMatrix();

View file

@ -4,5 +4,5 @@
class ArrowRenderer : public EntityRenderer class ArrowRenderer : public EntityRenderer
{ {
public: public:
virtual void render(shared_ptr<Entity> _arrow, double x, double y, double z, float rot, float a); virtual void render(std::shared_ptr<Entity> _arrow, double x, double y, double z, float rot, float a);
}; };

View file

@ -8,11 +8,11 @@ BlazeRenderer::BlazeRenderer() : MobRenderer(new BlazeModel(), 0.5f)
this->modelVersion = ((BlazeModel *) model)->modelVersion(); this->modelVersion = ((BlazeModel *) model)->modelVersion();
} }
void BlazeRenderer::render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a) void BlazeRenderer::render(std::shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a)
{ {
// 4J - original version used generics and thus had an input parameter of type Blaze rather than shared_ptr<Entity> we have here - // 4J - original version used generics and thus had an input parameter of type Blaze rather than std::shared_ptr<Entity> we have here -
// do some casting around instead // do some casting around instead
shared_ptr<Blaze> mob = dynamic_pointer_cast<Blaze>(_mob); std::shared_ptr<Blaze> mob = dynamic_pointer_cast<Blaze>(_mob);
int modelVersion = ((BlazeModel *) model)->modelVersion(); int modelVersion = ((BlazeModel *) model)->modelVersion();
if (modelVersion != this->modelVersion) if (modelVersion != this->modelVersion)

View file

@ -10,5 +10,5 @@ private:
public: public:
BlazeRenderer(); BlazeRenderer();
virtual void render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a); virtual void render(std::shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
}; };

View file

@ -10,11 +10,11 @@ BoatRenderer::BoatRenderer() : EntityRenderer()
model = new BoatModel(); model = new BoatModel();
} }
void BoatRenderer::render(shared_ptr<Entity> _boat, double x, double y, double z, float rot, float a) void BoatRenderer::render(std::shared_ptr<Entity> _boat, double x, double y, double z, float rot, float a)
{ {
// 4J - original version used generics and thus had an input parameter of type Boat rather than shared_ptr<Entity> we have here - // 4J - original version used generics and thus had an input parameter of type Boat rather than std::shared_ptr<Entity> we have here -
// do some casting around instead // do some casting around instead
shared_ptr<Boat> boat = dynamic_pointer_cast<Boat>(_boat); std::shared_ptr<Boat> boat = dynamic_pointer_cast<Boat>(_boat);
glPushMatrix(); glPushMatrix();

View file

@ -9,5 +9,5 @@ protected:
public: public:
BoatRenderer(); BoatRenderer();
virtual void render(shared_ptr<Entity> boat, double x, double y, double z, float rot, float a); virtual void render(std::shared_ptr<Entity> boat, double x, double y, double z, float rot, float a);
}; };

View file

@ -18,10 +18,10 @@ ChestRenderer::~ChestRenderer()
delete largeChestModel; delete largeChestModel;
} }
void ChestRenderer::render(shared_ptr<TileEntity> _chest, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled) void ChestRenderer::render(std::shared_ptr<TileEntity> _chest, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled)
{ {
// 4J Convert as we aren't using a templated class // 4J Convert as we aren't using a templated class
shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(_chest); std::shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(_chest);
int data; int data;

View file

@ -14,5 +14,5 @@ public:
ChestRenderer(); ChestRenderer();
~ChestRenderer(); ~ChestRenderer();
void render(shared_ptr<TileEntity> _chest, double x, double y, double z, float a, bool setColor, float alpha=1.0f, bool useCompiled = true); // 4J added setColor param void render(std::shared_ptr<TileEntity> _chest, double x, double y, double z, float a, bool setColor, float alpha=1.0f, bool useCompiled = true); // 4J added setColor param
}; };

View file

@ -7,15 +7,15 @@ ChickenRenderer::ChickenRenderer(Model *model, float shadow) : MobRenderer(model
{ {
} }
void ChickenRenderer::render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a) void ChickenRenderer::render(std::shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a)
{ {
MobRenderer::render(_mob, x, y, z, rot, a); MobRenderer::render(_mob, x, y, z, rot, a);
} }
float ChickenRenderer::getBob(shared_ptr<Mob> _mob, float a) float ChickenRenderer::getBob(std::shared_ptr<Mob> _mob, float a)
{ {
// 4J - dynamic cast required because we aren't using templates/generics in our version // 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<Chicken> mob = dynamic_pointer_cast<Chicken>(_mob); std::shared_ptr<Chicken> mob = dynamic_pointer_cast<Chicken>(_mob);
float flap = mob->oFlap+(mob->flap-mob->oFlap)*a; float flap = mob->oFlap+(mob->flap-mob->oFlap)*a;
float flapSpeed = mob->oFlapSpeed+(mob->flapSpeed-mob->oFlapSpeed)*a; float flapSpeed = mob->oFlapSpeed+(mob->flapSpeed-mob->oFlapSpeed)*a;

View file

@ -5,7 +5,7 @@ class ChickenRenderer : public MobRenderer
{ {
public: public:
ChickenRenderer(Model *model, float shadow); ChickenRenderer(Model *model, float shadow);
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a); virtual void render(std::shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
protected: protected:
virtual float getBob(shared_ptr<Mob> _mob, float a); virtual float getBob(std::shared_ptr<Mob> _mob, float a);
}; };

View file

@ -5,7 +5,7 @@ CowRenderer::CowRenderer(Model *model, float shadow) : MobRenderer(model, shadow
{ {
} }
void CowRenderer::render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a) void CowRenderer::render(std::shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a)
{ {
MobRenderer::render(_mob, x, y, z, rot, a); MobRenderer::render(_mob, x, y, z, rot, a);
} }

View file

@ -5,5 +5,5 @@ class CowRenderer : public MobRenderer
{ {
public: public:
CowRenderer(Model *model, float shadow); CowRenderer(Model *model, float shadow);
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a); virtual void render(std::shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
}; };

View file

@ -9,9 +9,9 @@ CreeperRenderer::CreeperRenderer() : MobRenderer( new CreeperModel(), 0.5f )
armorModel = new CreeperModel(2); armorModel = new CreeperModel(2);
} }
void CreeperRenderer::scale(shared_ptr<Mob> mob, float a) void CreeperRenderer::scale(std::shared_ptr<Mob> mob, float a)
{ {
shared_ptr<Creeper> creeper = dynamic_pointer_cast<Creeper>(mob); std::shared_ptr<Creeper> creeper = dynamic_pointer_cast<Creeper>(mob);
float g = creeper->getSwelling(a); float g = creeper->getSwelling(a);
@ -25,9 +25,9 @@ void CreeperRenderer::scale(shared_ptr<Mob> mob, float a)
glScalef(s, hs, s); glScalef(s, hs, s);
} }
int CreeperRenderer::getOverlayColor(shared_ptr<Mob> mob, float br, float a) int CreeperRenderer::getOverlayColor(std::shared_ptr<Mob> mob, float br, float a)
{ {
shared_ptr<Creeper> creeper = dynamic_pointer_cast<Creeper>(mob); std::shared_ptr<Creeper> creeper = dynamic_pointer_cast<Creeper>(mob);
float step = creeper->getSwelling(a); float step = creeper->getSwelling(a);
@ -44,10 +44,10 @@ int CreeperRenderer::getOverlayColor(shared_ptr<Mob> mob, float br, float a)
return (_a << 24) | (r << 16) | (g << 8) | b; return (_a << 24) | (r << 16) | (g << 8) | b;
} }
int CreeperRenderer::prepareArmor(shared_ptr<Mob> _mob, int layer, float a) int CreeperRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer, float a)
{ {
// 4J - dynamic cast required because we aren't using templates/generics in our version // 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<Creeper> mob = dynamic_pointer_cast<Creeper>(_mob); std::shared_ptr<Creeper> mob = dynamic_pointer_cast<Creeper>(_mob);
if (mob->isPowered()) if (mob->isPowered())
{ {
if (mob->isInvisible()) glDepthMask(false); if (mob->isInvisible()) glDepthMask(false);
@ -84,7 +84,7 @@ int CreeperRenderer::prepareArmor(shared_ptr<Mob> _mob, int layer, float a)
} }
int CreeperRenderer::prepareArmorOverlay(shared_ptr<Mob> mob, int layer, float a) int CreeperRenderer::prepareArmorOverlay(std::shared_ptr<Mob> mob, int layer, float a)
{ {
return -1; return -1;
} }

View file

@ -9,8 +9,8 @@ private:
public: public:
CreeperRenderer(); CreeperRenderer();
protected: protected:
virtual void scale(shared_ptr<Mob> _mob, float a); virtual void scale(std::shared_ptr<Mob> _mob, float a);
virtual int getOverlayColor(shared_ptr<Mob> mob, float br, float a); virtual int getOverlayColor(std::shared_ptr<Mob> mob, float br, float a);
virtual int prepareArmor(shared_ptr<Mob> mob, int layer, float a); virtual int prepareArmor(std::shared_ptr<Mob> mob, int layer, float a);
virtual int prepareArmorOverlay(shared_ptr<Mob> _mob, int layer, float a); virtual int prepareArmorOverlay(std::shared_ptr<Mob> _mob, int layer, float a);
}; };

View file

@ -2,7 +2,7 @@
#include "DefaultRenderer.h" #include "DefaultRenderer.h"
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.h" #include "../../../Minecraft.World/Headers/net.minecraft.world.entity.h"
void DefaultRenderer::render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a) void DefaultRenderer::render(std::shared_ptr<Entity> entity, double x, double y, double z, float rot, float a)
{ {
glPushMatrix(); glPushMatrix();
// 4J - removed following line as doesn't really make any sense // 4J - removed following line as doesn't really make any sense

View file

@ -4,5 +4,5 @@
class DefaultRenderer : public EntityRenderer class DefaultRenderer : public EntityRenderer
{ {
public: public:
virtual void render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a); virtual void render(std::shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
}; };

View file

@ -14,10 +14,10 @@ EnchantTableRenderer::~EnchantTableRenderer()
delete bookModel; delete bookModel;
} }
void EnchantTableRenderer::render(shared_ptr<TileEntity> _table, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled) void EnchantTableRenderer::render(std::shared_ptr<TileEntity> _table, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled)
{ {
// 4J Convert as we aren't using a templated class // 4J Convert as we aren't using a templated class
shared_ptr<EnchantmentTableEntity> table = dynamic_pointer_cast<EnchantmentTableEntity>(_table); std::shared_ptr<EnchantmentTableEntity> table = dynamic_pointer_cast<EnchantmentTableEntity>(_table);
#ifdef __PSVITA__ #ifdef __PSVITA__
// AP - the book pages are made with 0 depth so the front and back polys are at the same location. This can cause z-fighting if culling is disabled which can sometimes happen // AP - the book pages are made with 0 depth so the front and back polys are at the same location. This can cause z-fighting if culling is disabled which can sometimes happen

View file

@ -15,5 +15,5 @@ public:
EnchantTableRenderer(); EnchantTableRenderer();
~EnchantTableRenderer(); ~EnchantTableRenderer();
virtual void render(shared_ptr<TileEntity> _table, double x, double y, double z, float a, bool setColor, float alpha=1.0f, bool useCompiled = true); virtual void render(std::shared_ptr<TileEntity> _table, double x, double y, double z, float a, bool setColor, float alpha=1.0f, bool useCompiled = true);
}; };

View file

@ -3,10 +3,10 @@
#include "../Models/ModelPart.h" #include "../Models/ModelPart.h"
#include "EnderChestRenderer.h" #include "EnderChestRenderer.h"
void EnderChestRenderer::render(shared_ptr<TileEntity> _chest, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled) void EnderChestRenderer::render(std::shared_ptr<TileEntity> _chest, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled)
{ {
// 4J Convert as we aren't using a templated class // 4J Convert as we aren't using a templated class
shared_ptr<EnderChestTileEntity> chest = dynamic_pointer_cast<EnderChestTileEntity>(_chest); std::shared_ptr<EnderChestTileEntity> chest = dynamic_pointer_cast<EnderChestTileEntity>(_chest);
int data = 0; int data = 0;

View file

@ -9,5 +9,5 @@ private:
ChestModel chestModel; ChestModel chestModel;
public: public:
void render(shared_ptr<TileEntity> _chest, double x, double y, double z, float a, bool setColor, float alpha=1.0f, bool useCompiled = true); // 4J added setColor param void render(std::shared_ptr<TileEntity> _chest, double x, double y, double z, float a, bool setColor, float alpha=1.0f, bool useCompiled = true); // 4J added setColor param
}; };

View file

@ -9,11 +9,11 @@ EnderCrystalRenderer::EnderCrystalRenderer()
this->shadowRadius = 0.5f; this->shadowRadius = 0.5f;
} }
void EnderCrystalRenderer::render(shared_ptr<Entity> _crystal, double x, double y, double z, float rot, float a) void EnderCrystalRenderer::render(std::shared_ptr<Entity> _crystal, double x, double y, double z, float rot, float a)
{ {
// 4J - original version used generics and thus had an input parameter of type EnderCrystal rather than shared_ptr<Entity> we have here - // 4J - original version used generics and thus had an input parameter of type EnderCrystal rather than std::shared_ptr<Entity> we have here -
// do some casting around instead // do some casting around instead
shared_ptr<EnderCrystal> crystal = dynamic_pointer_cast<EnderCrystal>(_crystal); std::shared_ptr<EnderCrystal> crystal = dynamic_pointer_cast<EnderCrystal>(_crystal);
if (currentModel != EnderCrystalModel::MODEL_ID) if (currentModel != EnderCrystalModel::MODEL_ID)
{ {
model = new EnderCrystalModel(0); model = new EnderCrystalModel(0);

View file

@ -13,5 +13,5 @@ private:
public: public:
EnderCrystalRenderer(); EnderCrystalRenderer();
virtual void render(shared_ptr<Entity> _crystal, double x, double y, double z, float rot, float a); virtual void render(std::shared_ptr<Entity> _crystal, double x, double y, double z, float rot, float a);
}; };

View file

@ -5,7 +5,7 @@
#include "../Lighting.h" #include "../Lighting.h"
#include "EnderDragonRenderer.h" #include "EnderDragonRenderer.h"
shared_ptr<EnderDragon> EnderDragonRenderer::bossInstance; std::shared_ptr<EnderDragon> EnderDragonRenderer::bossInstance;
int EnderDragonRenderer::currentModel; int EnderDragonRenderer::currentModel;
EnderDragonRenderer::EnderDragonRenderer() : MobRenderer(new DragonModel(0), 0.5f) EnderDragonRenderer::EnderDragonRenderer() : MobRenderer(new DragonModel(0), 0.5f)
@ -15,10 +15,10 @@ EnderDragonRenderer::EnderDragonRenderer() : MobRenderer(new DragonModel(0), 0.5
this->setArmor(model); this->setArmor(model);
} }
void EnderDragonRenderer::setupRotations(shared_ptr<Mob> _mob, float bob, float bodyRot, float a) void EnderDragonRenderer::setupRotations(std::shared_ptr<Mob> _mob, float bob, float bodyRot, float a)
{ {
// 4J - dynamic cast required because we aren't using templates/generics in our version // 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob); std::shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob);
// 4J - reorganised a bit so we can free allocations // 4J - reorganised a bit so we can free allocations
double lpComponents[3]; double lpComponents[3];
@ -46,10 +46,10 @@ void EnderDragonRenderer::setupRotations(shared_ptr<Mob> _mob, float bob, float
} }
} }
void EnderDragonRenderer::renderModel(shared_ptr<Entity> _mob, float wp, float ws, float bob, float headRotMinusBodyRot, float headRotx, float scale) void EnderDragonRenderer::renderModel(std::shared_ptr<Entity> _mob, float wp, float ws, float bob, float headRotMinusBodyRot, float headRotx, float scale)
{ {
// 4J - dynamic cast required because we aren't using templates/generics in our version // 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob); std::shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob);
if (mob->dragonDeathTime > 0) if (mob->dragonDeathTime > 0)
{ {
@ -87,10 +87,10 @@ void EnderDragonRenderer::renderModel(shared_ptr<Entity> _mob, float wp, float w
} }
} }
void EnderDragonRenderer::render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a) void EnderDragonRenderer::render(std::shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a)
{ {
// 4J - dynamic cast required because we aren't using templates/generics in our version // 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob); std::shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob);
EnderDragonRenderer::bossInstance = mob; EnderDragonRenderer::bossInstance = mob;
if (currentModel != DragonModel::MODEL_ID) if (currentModel != DragonModel::MODEL_ID)
{ {
@ -167,10 +167,10 @@ void EnderDragonRenderer::render(shared_ptr<Entity> _mob, double x, double y, do
} }
} }
void EnderDragonRenderer::additionalRendering(shared_ptr<Mob> _mob, float a) void EnderDragonRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a)
{ {
// 4J - dynamic cast required because we aren't using templates/generics in our version // 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob); std::shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob);
MobRenderer::additionalRendering(mob, a); MobRenderer::additionalRendering(mob, a);
Tesselator *t = Tesselator::getInstance(); Tesselator *t = Tesselator::getInstance();
@ -227,10 +227,10 @@ void EnderDragonRenderer::additionalRendering(shared_ptr<Mob> _mob, float a)
} }
int EnderDragonRenderer::prepareArmor(shared_ptr<Mob> _mob, int layer, float a) int EnderDragonRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer, float a)
{ {
// 4J - dynamic cast required because we aren't using templates/generics in our version // 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob); std::shared_ptr<EnderDragon> mob = dynamic_pointer_cast<EnderDragon>(_mob);
if (layer == 1) if (layer == 1)
{ {

View file

@ -10,7 +10,7 @@ class DragonModel;
class EnderDragonRenderer : public MobRenderer class EnderDragonRenderer : public MobRenderer
{ {
public: public:
static shared_ptr<EnderDragon> bossInstance; static std::shared_ptr<EnderDragon> bossInstance;
private: private:
static int currentModel; static int currentModel;
@ -22,15 +22,15 @@ public:
EnderDragonRenderer(); EnderDragonRenderer();
protected: protected:
virtual void setupRotations(shared_ptr<Mob> _mob, float bob, float bodyRot, float a); virtual void setupRotations(std::shared_ptr<Mob> _mob, float bob, float bodyRot, float a);
protected: protected:
void renderModel(shared_ptr<Entity> _mob, float wp, float ws, float bob, float headRotMinusBodyRot, float headRotx, float scale); void renderModel(std::shared_ptr<Entity> _mob, float wp, float ws, float bob, float headRotMinusBodyRot, float headRotx, float scale);
public: public:
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a); virtual void render(std::shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
protected: protected:
virtual void additionalRendering(shared_ptr<Mob> _mob, float a); virtual void additionalRendering(std::shared_ptr<Mob> _mob, float a);
virtual int prepareArmor(shared_ptr<Mob> _mob, int layer, float a); virtual int prepareArmor(std::shared_ptr<Mob> _mob, int layer, float a);
}; };

View file

@ -10,11 +10,11 @@ EndermanRenderer::EndermanRenderer() : MobRenderer(new EndermanModel(), 0.5f)
this->setArmor(model); this->setArmor(model);
} }
void EndermanRenderer::render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a) void EndermanRenderer::render(std::shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a)
{ {
// 4J - original version used generics and thus had an input parameter of type Boat rather than shared_ptr<Entity> we have here - // 4J - original version used generics and thus had an input parameter of type Boat rather than std::shared_ptr<Entity> we have here -
// do some casting around instead // do some casting around instead
shared_ptr<EnderMan> mob = dynamic_pointer_cast<EnderMan>(_mob); std::shared_ptr<EnderMan> mob = dynamic_pointer_cast<EnderMan>(_mob);
model->carrying = mob->getCarryingTile() > 0; model->carrying = mob->getCarryingTile() > 0;
model->creepy = mob->isCreepy(); model->creepy = mob->isCreepy();
@ -29,11 +29,11 @@ void EndermanRenderer::render(shared_ptr<Entity> _mob, double x, double y, doubl
MobRenderer::render(mob, x, y, z, rot, a); MobRenderer::render(mob, x, y, z, rot, a);
} }
void EndermanRenderer::additionalRendering(shared_ptr<Mob> _mob, float a) void EndermanRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a)
{ {
// 4J - original version used generics and thus had an input parameter of type Boat rather than shared_ptr<Entity> we have here - // 4J - original version used generics and thus had an input parameter of type Boat rather than std::shared_ptr<Entity> we have here -
// do some casting around instead // do some casting around instead
shared_ptr<EnderMan> mob = dynamic_pointer_cast<EnderMan>(_mob); std::shared_ptr<EnderMan> mob = dynamic_pointer_cast<EnderMan>(_mob);
MobRenderer::additionalRendering(_mob, a); MobRenderer::additionalRendering(_mob, a);
@ -68,11 +68,11 @@ void EndermanRenderer::additionalRendering(shared_ptr<Mob> _mob, float a)
} }
} }
int EndermanRenderer::prepareArmor(shared_ptr<Mob> _mob, int layer, float a) int EndermanRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer, float a)
{ {
// 4J - original version used generics and thus had an input parameter of type Boat rather than shared_ptr<Entity> we have here - // 4J - original version used generics and thus had an input parameter of type Boat rather than std::shared_ptr<Entity> we have here -
// do some casting around instead // do some casting around instead
shared_ptr<EnderMan> mob = dynamic_pointer_cast<EnderMan>(_mob); std::shared_ptr<EnderMan> mob = dynamic_pointer_cast<EnderMan>(_mob);
if (layer != 0) return -1; if (layer != 0) return -1;

Some files were not shown because too many files have changed in this diff Show more