shared_ptr -> std::shared_ptr

This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today.
This commit is contained in:
void_17
2026-03-02 15:58:20 +07:00
parent d63f79325f
commit 7074f35e4b
1373 changed files with 12054 additions and 12054 deletions

View File

@@ -43,14 +43,14 @@ void AddEnchantmentRuleDefinition::addAttribute(const wstring &attributeName, co
}
}
bool AddEnchantmentRuleDefinition::enchantItem(shared_ptr<ItemInstance> item)
bool AddEnchantmentRuleDefinition::enchantItem(std::shared_ptr<ItemInstance> item)
{
bool enchanted = false;
if (item != NULL)
{
// 4J-JEV: Ripped code from enchantmenthelpers
// Maybe we want to add an addEnchantment method to EnchantmentHelpers
if (item->id == Item::enchantedBook_Id)
if (item->id == Item::enchantedBook_Id)
{
Item::enchantedBook->addEnchantment( item, new EnchantmentInstance(m_enchantmentId, m_enchantmentLevel) );
}

View File

@@ -19,5 +19,5 @@ public:
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
bool enchantItem(shared_ptr<ItemInstance> item);
bool enchantItem(std::shared_ptr<ItemInstance> item);
};

View File

@@ -94,13 +94,13 @@ void AddItemRuleDefinition::addAttribute(const wstring &attributeName, const wst
}
}
bool AddItemRuleDefinition::addItemToContainer(shared_ptr<Container> container, int slotId)
bool AddItemRuleDefinition::addItemToContainer(std::shared_ptr<Container> container, int slotId)
{
bool added = false;
if(Item::items[m_itemId] != NULL)
{
int quantity = min(m_quantity, Item::items[m_itemId]->getMaxStackSize());
shared_ptr<ItemInstance> newItem = shared_ptr<ItemInstance>(new ItemInstance(m_itemId,quantity,m_auxValue) );
std::shared_ptr<ItemInstance> newItem = std::shared_ptr<ItemInstance>(new ItemInstance(m_itemId,quantity,m_auxValue) );
newItem->set4JData(m_dataTag);
for(AUTO_VAR(it, m_enchantments.begin()); it != m_enchantments.end(); ++it)

View File

@@ -26,5 +26,5 @@ public:
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
bool addItemToContainer(shared_ptr<Container> container, int slotId);
bool addItemToContainer(std::shared_ptr<Container> container, int slotId);
};

View File

@@ -74,7 +74,7 @@ void CollectItemRuleDefinition::populateGameRule(GameRulesInstance::EGameRulesIn
GameRuleDefinition::populateGameRule(type, rule);
}
bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item)
bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, std::shared_ptr<ItemInstance> item)
{
bool statusChanged = false;
if(item != NULL && item->id == m_itemId && item->getAuxValue() == m_auxValue && item->get4JData() == m_4JDataValue)
@@ -94,7 +94,7 @@ bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemIns
if(rule->getConnection() != NULL)
{
rule->getConnection()->send( shared_ptr<UpdateGameRuleProgressPacket>( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId, m_itemId, m_auxValue, this->m_4JDataValue,NULL,0)));
rule->getConnection()->send( std::shared_ptr<UpdateGameRuleProgressPacket>( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId, m_itemId, m_auxValue, this->m_4JDataValue,NULL,0)));
}
}
}
@@ -102,7 +102,7 @@ bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemIns
return statusChanged;
}
wstring CollectItemRuleDefinition::generateXml(shared_ptr<ItemInstance> item)
wstring CollectItemRuleDefinition::generateXml(std::shared_ptr<ItemInstance> item)
{
// 4J Stu - This should be kept in sync with the GameRulesDefinition.xsd
wstring xml = L"";

View File

@@ -25,16 +25,16 @@ public:
virtual int getGoal();
virtual int getProgress(GameRule *rule);
virtual int getIcon() { return m_itemId; }
virtual int getAuxValue() { return m_auxValue; }
void populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule);
bool onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item);
bool onCollectItem(GameRule *rule, std::shared_ptr<ItemInstance> item);
static wstring generateXml(shared_ptr<ItemInstance> item);
static wstring generateXml(std::shared_ptr<ItemInstance> item);
private:
private:
//static wstring generateXml(CollectItemRuleDefinition *ruleDef);
};

View File

@@ -17,7 +17,7 @@ bool CompleteAllRuleDefinition::onUseTile(GameRule *rule, int tileId, int x, int
return statusChanged;
}
bool CompleteAllRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item)
bool CompleteAllRuleDefinition::onCollectItem(GameRule *rule, std::shared_ptr<ItemInstance> item)
{
bool statusChanged = CompoundGameRuleDefinition::onCollectItem(rule,item);
if(statusChanged) updateStatus(rule);
@@ -44,14 +44,14 @@ void CompleteAllRuleDefinition::updateStatus(GameRule *rule)
int icon = -1;
int auxValue = 0;
if(m_lastRuleStatusChanged != NULL)
{
{
icon = m_lastRuleStatusChanged->getIcon();
auxValue = m_lastRuleStatusChanged->getAuxValue();
m_lastRuleStatusChanged = NULL;
}
rule->getConnection()->send( shared_ptr<UpdateGameRuleProgressPacket>( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId,icon, auxValue, 0,&data,sizeof(PacketData))));
rule->getConnection()->send( std::shared_ptr<UpdateGameRuleProgressPacket>( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId,icon, auxValue, 0,&data,sizeof(PacketData))));
}
app.DebugPrintf("Updated CompleteAllRule - Completed %d of %d\n", progress, goal);
}

View File

@@ -17,7 +17,7 @@ public:
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual bool onUseTile(GameRule *rule, int tileId, int x, int y, int z);
virtual bool onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item);
virtual bool onCollectItem(GameRule *rule, std::shared_ptr<ItemInstance> item);
static wstring generateDescriptionString(const wstring &description, void *data, int dataLength);

View File

@@ -40,7 +40,7 @@ GameRuleDefinition *CompoundGameRuleDefinition::addChild(ConsoleGameRules::EGame
rule = new UseTileRuleDefinition();
}
else if(ruleType == ConsoleGameRules::eGameRuleType_UpdatePlayerRule)
{
{
rule = new UpdatePlayerRuleDefinition();
}
else
@@ -91,7 +91,7 @@ bool CompoundGameRuleDefinition::onUseTile(GameRule *rule, int tileId, int x, in
return statusChanged;
}
bool CompoundGameRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item)
bool CompoundGameRuleDefinition::onCollectItem(GameRule *rule, std::shared_ptr<ItemInstance> item)
{
bool statusChanged = false;
for(AUTO_VAR(it, rule->m_parameters.begin()); it != rule->m_parameters.end(); ++it)
@@ -100,7 +100,7 @@ bool CompoundGameRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemIn
{
bool changed = it->second.gr->getGameRuleDefinition()->onCollectItem(it->second.gr,item);
if(!statusChanged && changed)
{
{
m_lastRuleStatusChanged = it->second.gr->getGameRuleDefinition();
statusChanged = true;
}
@@ -109,7 +109,7 @@ bool CompoundGameRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemIn
return statusChanged;
}
void CompoundGameRuleDefinition::postProcessPlayer(shared_ptr<Player> player)
void CompoundGameRuleDefinition::postProcessPlayer(std::shared_ptr<Player> player)
{
for(AUTO_VAR(it, m_children.begin()); it != m_children.end(); ++it)
{

View File

@@ -18,6 +18,6 @@ public:
virtual void populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule);
virtual bool onUseTile(GameRule *rule, int tileId, int x, int y, int z);
virtual bool onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item);
virtual void postProcessPlayer(shared_ptr<Player> player);
virtual bool onCollectItem(GameRule *rule, std::shared_ptr<ItemInstance> item);
virtual void postProcessPlayer(std::shared_ptr<Player> player);
};

View File

@@ -116,7 +116,7 @@ void ConsoleSchematicFile::load(DataInputStream *dis)
for (int i = 0; i < tileEntityTags->size(); i++)
{
CompoundTag *teTag = tileEntityTags->get(i);
shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
std::shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
if(te == NULL)
{
@@ -433,7 +433,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox,
{
for(AUTO_VAR(it, m_tileEntities.begin()); it != m_tileEntities.end();++it)
{
shared_ptr<TileEntity> te = *it;
std::shared_ptr<TileEntity> te = *it;
double targetX = te->x;
double targetY = te->y + destinationBox->y0;
@@ -444,7 +444,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox,
Vec3 *pos = Vec3::newTemp(targetX,targetY,targetZ);
if( chunkBox->containsIncludingLowerBound(pos) )
{
shared_ptr<TileEntity> teCopy = chunk->getTileEntity( (int)targetX & 15, (int)targetY & 15, (int)targetZ & 15 );
std::shared_ptr<TileEntity> teCopy = chunk->getTileEntity( (int)targetX & 15, (int)targetY & 15, (int)targetZ & 15 );
if ( teCopy != NULL )
{
@@ -495,11 +495,11 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox,
}
CompoundTag *eTag = it->second;
shared_ptr<Entity> e = EntityIO::loadStatic(eTag, NULL);
std::shared_ptr<Entity> e = EntityIO::loadStatic(eTag, NULL);
if( e->GetType() == eTYPE_PAINTING )
{
shared_ptr<Painting> painting = dynamic_pointer_cast<Painting>(e);
std::shared_ptr<Painting> painting = dynamic_pointer_cast<Painting>(e);
double tileX = painting->xTile;
double tileZ = painting->zTile;
@@ -512,7 +512,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox,
}
else 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);
double tileX = frame->xTile;
double tileZ = frame->zTile;
@@ -678,12 +678,12 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l
{
for (int zc = zc0; zc <= zc1; zc++)
{
vector<shared_ptr<TileEntity> > *tileEntities = getTileEntitiesInRegion(level->getChunk(xc, zc), xStart, yStart, zStart, xStart + xSize, yStart + ySize, zStart + zSize);
vector<std::shared_ptr<TileEntity> > *tileEntities = getTileEntitiesInRegion(level->getChunk(xc, zc), xStart, yStart, zStart, xStart + xSize, yStart + ySize, zStart + zSize);
for(AUTO_VAR(it, tileEntities->begin()); it != tileEntities->end(); ++it)
{
shared_ptr<TileEntity> te = *it;
std::shared_ptr<TileEntity> te = *it;
CompoundTag *teTag = new CompoundTag();
shared_ptr<TileEntity> teCopy = te->clone();
std::shared_ptr<TileEntity> teCopy = te->clone();
// Adjust the tileEntity position to schematic coords from world co-ords
teCopy->x -= xStart;
@@ -698,12 +698,12 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l
tag.put(L"TileEntities", tileEntitiesTag);
AABB *bb = AABB::newTemp(xStart,yStart,zStart,xEnd,yEnd,zEnd);
vector<shared_ptr<Entity> > *entities = level->getEntities(nullptr, bb);
vector<std::shared_ptr<Entity> > *entities = level->getEntities(nullptr, bb);
ListTag<CompoundTag> *entitiesTag = new ListTag<CompoundTag>(L"entities");
for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it)
{
shared_ptr<Entity> e = *it;
std::shared_ptr<Entity> e = *it;
bool mobCanBeSaved = false;
if(bSaveMobs)
@@ -1005,12 +1005,12 @@ void ConsoleSchematicFile::setBlocksAndData(LevelChunk *chunk, byteArray blockDa
}
}
vector<shared_ptr<TileEntity> > *ConsoleSchematicFile::getTileEntitiesInRegion(LevelChunk *chunk, int x0, int y0, int z0, int x1, int y1, int z1)
vector<std::shared_ptr<TileEntity> > *ConsoleSchematicFile::getTileEntitiesInRegion(LevelChunk *chunk, 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 (AUTO_VAR(it, chunk->tileEntities.begin()); it != chunk->tileEntities.end(); ++it)
{
shared_ptr<TileEntity> te = it->second;
std::shared_ptr<TileEntity> te = it->second;
if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 && te->y < y1 && te->z < z1)
{
result->push_back(te);

View File

@@ -55,7 +55,7 @@ public:
} XboxSchematicInitParam;
private:
int m_xSize, m_ySize, m_zSize;
vector<shared_ptr<TileEntity> > m_tileEntities;
vector<std::shared_ptr<TileEntity> > m_tileEntities;
vector< pair<Vec3 *, CompoundTag *> > m_entities;
public:
@@ -83,7 +83,7 @@ private:
void load_tags(DataInputStream *dis);
static void getBlocksAndData(LevelChunk *chunk, byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int &blocksP, int &dataP, int &blockLightP, int &skyLightP);
static vector<shared_ptr<TileEntity> > *getTileEntitiesInRegion(LevelChunk *chunk, int x0, int y0, int z0, int x1, int y1, int z1);
static vector<std::shared_ptr<TileEntity> > *getTileEntitiesInRegion(LevelChunk *chunk, int x0, int y0, int z0, int x1, int y1, int z1);
void chunkCoordToSchematicCoord(AABB *destinationBox, int chunkX, int chunkZ, ESchematicRotation rot, int &schematicX, int &schematicZ);
void schematicCoordToChunkCoord(AABB *destinationBox, double schematicX, double schematicZ, ESchematicRotation rot, double &chunkX, double &chunkZ);

View File

@@ -53,7 +53,7 @@ GameRuleDefinition *GameRule::getGameRuleDefinition()
}
void GameRule::onUseTile(int tileId, int x, int y, int z) { m_definition->onUseTile(this,tileId,x,y,z); }
void GameRule::onCollectItem(shared_ptr<ItemInstance> item) { m_definition->onCollectItem(this,item); }
void GameRule::onCollectItem(std::shared_ptr<ItemInstance> item) { m_definition->onCollectItem(this,item); }
void GameRule::write(DataOutputStream *dos)
{
@@ -63,7 +63,7 @@ void GameRule::write(DataOutputStream *dos)
{
wstring pName = (*it).first;
ValueType vType = (*it).second;
dos->writeUTF( (*it).first );
dos->writeBoolean( vType.isPointer );
@@ -80,7 +80,7 @@ void GameRule::read(DataInputStream *dis)
for (int i = 0; i < savedParams; i++)
{
wstring pNames = dis->readUTF();
ValueType vType = getParameter(pNames);
if (dis->readBoolean())

View File

@@ -51,7 +51,7 @@ public:
// All the hooks go here
void onUseTile(int tileId, int x, int y, int z);
void onCollectItem(shared_ptr<ItemInstance> item);
void onCollectItem(std::shared_ptr<ItemInstance> item);
// 4J-JEV: For saving.
//CompoundTag *toTags(unordered_map<GameRuleDefinition *, int> *map);

View File

@@ -39,7 +39,7 @@ public:
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
virtual void populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule);
bool getComplete(GameRule *rule);
@@ -53,8 +53,8 @@ public:
// Here we should have functions for all the hooks, with a GameRule* as the first parameter
virtual bool onUseTile(GameRule *rule, int tileId, int x, int y, int z) { return false; }
virtual bool onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item) { return false; }
virtual void postProcessPlayer(shared_ptr<Player> player) { }
virtual bool onCollectItem(GameRule *rule, std::shared_ptr<ItemInstance> item) { return false; }
virtual void postProcessPlayer(std::shared_ptr<Player> player) { }
vector<GameRuleDefinition *> *enumerate();
unordered_map<GameRuleDefinition *, int> *enumerateMap();

View File

@@ -11,7 +11,7 @@ UpdatePlayerRuleDefinition::UpdatePlayerRuleDefinition()
{
m_bUpdateHealth = m_bUpdateFood = m_bUpdateYRot = false;;
m_health = 0;
m_food = 0;
m_food = 0;
m_spawnPos = NULL;
m_yRot = 0.0f;
}
@@ -130,7 +130,7 @@ void UpdatePlayerRuleDefinition::addAttribute(const wstring &attributeName, cons
}
}
void UpdatePlayerRuleDefinition::postProcessPlayer(shared_ptr<Player> player)
void UpdatePlayerRuleDefinition::postProcessPlayer(std::shared_ptr<Player> player)
{
if(m_bUpdateHealth)
{

View File

@@ -13,7 +13,7 @@ private:
bool m_bUpdateHealth, m_bUpdateFood, m_bUpdateYRot, m_bUpdateInventory;
int m_health;
int m_food;
int m_food;
Pos *m_spawnPos;
float m_yRot;
@@ -22,12 +22,12 @@ public:
~UpdatePlayerRuleDefinition();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_UpdatePlayerRule; }
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
virtual void postProcessPlayer(shared_ptr<Player> player);
virtual void postProcessPlayer(std::shared_ptr<Player> player);
};

View File

@@ -22,7 +22,7 @@ XboxStructureActionPlaceContainer::~XboxStructureActionPlaceContainer()
// 4J-JEV: Super class handles attr-facing fine.
//void XboxStructureActionPlaceContainer::writeAttributes(DataOutputStream *dos, UINT numAttrs)
void XboxStructureActionPlaceContainer::getChildren(vector<GameRuleDefinition *> *children)
{
@@ -78,8 +78,8 @@ bool XboxStructureActionPlaceContainer::placeContainerInLevel(StructurePiece *st
}
level->setTile( worldX, worldY, worldZ, m_tile );
shared_ptr<Container> container = dynamic_pointer_cast<Container>(level->getTileEntity( worldX, worldY, worldZ ));
std::shared_ptr<Container> container = dynamic_pointer_cast<Container>(level->getTileEntity( worldX, worldY, worldZ ));
app.DebugPrintf("XboxStructureActionPlaceContainer - placing a container at (%d,%d,%d)\n", worldX, worldY, worldZ);
if ( container != NULL )
{

View File

@@ -54,7 +54,7 @@ bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel(StructurePiece *struct
}
level->setTile( worldX, worldY, worldZ, m_tile );
shared_ptr<MobSpawnerTileEntity> entity = dynamic_pointer_cast<MobSpawnerTileEntity>(level->getTileEntity( worldX, worldY, worldZ ));
std::shared_ptr<MobSpawnerTileEntity> entity = dynamic_pointer_cast<MobSpawnerTileEntity>(level->getTileEntity( worldX, worldY, worldZ ));
#ifndef _CONTENT_PACKAGE
wprintf(L"XboxStructureActionPlaceSpawner - placing a %ls spawner at (%d,%d,%d)\n", m_entityId.c_str(), worldX, worldY, worldZ);