dynamic_pointer_cast -> std::dynamic_pointer_cast

This commit is contained in:
void_17
2026-03-02 17:10:34 +07:00
parent 7bee4770df
commit 07ad68bc15
207 changed files with 623 additions and 623 deletions

View File

@@ -214,7 +214,7 @@ void Player::releaseUsingItem()
{
if (useItem != NULL)
{
useItem->releaseUsing(level, dynamic_pointer_cast<Player>( shared_from_this() ), useItemDuration);
useItem->releaseUsing(level, std::dynamic_pointer_cast<Player>( shared_from_this() ), useItemDuration);
// 4J Stu - Fix for various bugs where an incorrect bow was displayed when it broke (#70859,#93972,#93974)
if (useItem->count == 0)
@@ -312,7 +312,7 @@ void Player::tick()
if (!level->isClientSide)
{
if (containerMenu != NULL && !containerMenu->stillValid( dynamic_pointer_cast<Player>( shared_from_this() ) ))
if (containerMenu != NULL && !containerMenu->stillValid( std::dynamic_pointer_cast<Player>( shared_from_this() ) ))
{
closeContainer();
containerMenu = inventoryMenu;
@@ -355,7 +355,7 @@ void Player::tick()
if (!level->isClientSide)
{
foodData.tick(dynamic_pointer_cast<Player>(shared_from_this()));
foodData.tick(std::dynamic_pointer_cast<Player>(shared_from_this()));
}
// 4J Stu Debugging
@@ -411,29 +411,29 @@ void Player::tick()
//this->drop( std::shared_ptr<ItemInstance>( new ItemInstance( Tile::fence, 64 ) ) );
//std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Pig::_class->newInstance( level ));
//std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(Pig::_class->newInstance( level ));
//mob->moveTo(x+1, y, z+1, level->random->nextFloat() * 360, 0);
//level->addEntity(mob);
// 4J : WESTY : Spawn some wolves to befriend!
/*
std::shared_ptr<Mob> mob1 = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
std::shared_ptr<Mob> mob1 = std::dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
mob1->moveTo(x+1, y, z+1, level->random->nextFloat() * 360, 0);
level->addEntity(mob1);
std::shared_ptr<Mob> mob2 = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
std::shared_ptr<Mob> mob2 = std::dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
mob2->moveTo(x+2, y, z+1, level->random->nextFloat() * 360, 0);
level->addEntity(mob2);
std::shared_ptr<Mob> mob3 = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
std::shared_ptr<Mob> mob3 = std::dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
mob3->moveTo(x+1, y, z+2, level->random->nextFloat() * 360, 0);
level->addEntity(mob3);
std::shared_ptr<Mob> mob4 = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
std::shared_ptr<Mob> mob4 = std::dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
mob4->moveTo(x+3, y, z+1, level->random->nextFloat() * 360, 0);
level->addEntity(mob4);
std::shared_ptr<Mob> mob5 = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
std::shared_ptr<Mob> mob5 = std::dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
mob5->moveTo(x+1, y, z+3, level->random->nextFloat() * 360, 0);
level->addEntity(mob5);
*/
@@ -558,7 +558,7 @@ void Player::completeUsingItem()
spawnEatParticles(useItem, 16);
int oldCount = useItem->count;
std::shared_ptr<ItemInstance> itemInstance = useItem->useTimeDepleted(level, dynamic_pointer_cast<Player>(shared_from_this()));
std::shared_ptr<ItemInstance> itemInstance = useItem->useTimeDepleted(level, std::dynamic_pointer_cast<Player>(shared_from_this()));
if (itemInstance != useItem || (itemInstance != NULL && itemInstance->count != oldCount))
{
inventory->items[inventory->selected] = itemInstance;
@@ -943,7 +943,7 @@ void Player::rideTick()
//xRot = preXRot;
//yRot = preYRot;
std::shared_ptr<Pig> pig = dynamic_pointer_cast<Pig>(riding);
std::shared_ptr<Pig> pig = std::dynamic_pointer_cast<Pig>(riding);
yBodyRot = pig->yBodyRot;
while (yBodyRot - yBodyRotO < -180)
@@ -1056,7 +1056,7 @@ void Player::aiStep()
void Player::touch(std::shared_ptr<Entity> entity)
{
entity->playerTouch( dynamic_pointer_cast<Player>( shared_from_this() ) );
entity->playerTouch( std::dynamic_pointer_cast<Player>( shared_from_this() ) );
}
// 4J - Removed 1.0.1
@@ -1350,17 +1350,17 @@ bool Player::hurt(DamageSource *source, int dmg)
if (dmg == 0) return false;
std::shared_ptr<Entity> attacker = source->getEntity();
if ( dynamic_pointer_cast<Arrow>( attacker ) != NULL )
if ( std::dynamic_pointer_cast<Arrow>( attacker ) != NULL )
{
if ((dynamic_pointer_cast<Arrow>(attacker))->owner != NULL)
if ((std::dynamic_pointer_cast<Arrow>(attacker))->owner != NULL)
{
attacker = (dynamic_pointer_cast<Arrow>(attacker))->owner;
attacker = (std::dynamic_pointer_cast<Arrow>(attacker))->owner;
}
}
if ( dynamic_pointer_cast<Mob>( attacker ) != NULL )
if ( std::dynamic_pointer_cast<Mob>( attacker ) != NULL )
{
// aggreviate all pet wolves nearby
directAllTameWolvesOnTarget(dynamic_pointer_cast<Mob>(attacker), false);
directAllTameWolvesOnTarget(std::dynamic_pointer_cast<Mob>(attacker), false);
}
return this->Mob::hurt(source, dmg);
@@ -1399,20 +1399,20 @@ void Player::directAllTameWolvesOnTarget(std::shared_ptr<Mob> target, bool skipS
{
// filter un-attackable mobs
if ((dynamic_pointer_cast<Creeper>( target ) != NULL) || (dynamic_pointer_cast<Ghast>( target) != NULL))
if ((std::dynamic_pointer_cast<Creeper>( target ) != NULL) || (std::dynamic_pointer_cast<Ghast>( target) != NULL))
{
return;
}
// never target wolves that has this player as owner
if (dynamic_pointer_cast<Wolf>(target) != NULL)
if (std::dynamic_pointer_cast<Wolf>(target) != NULL)
{
std::shared_ptr<Wolf> wolfTarget = dynamic_pointer_cast<Wolf>(target);
std::shared_ptr<Wolf> wolfTarget = std::dynamic_pointer_cast<Wolf>(target);
if (wolfTarget->isTame() && m_UUID.compare( wolfTarget->getOwnerUUID() ) == 0 )
{
return;
}
}
if ((dynamic_pointer_cast<Player>( target ) != NULL) && !isPlayerVersusPlayer())
if ((std::dynamic_pointer_cast<Player>( target ) != NULL) && !isPlayerVersusPlayer())
{
// pvp is off
return;
@@ -1424,7 +1424,7 @@ void Player::directAllTameWolvesOnTarget(std::shared_ptr<Mob> target, bool skipS
AUTO_VAR(itEnd, nearbyWolves->end());
for (AUTO_VAR(it, nearbyWolves->begin()); it != itEnd; it++)
{
std::shared_ptr<Wolf> wolf = dynamic_pointer_cast<Wolf>(*it);;
std::shared_ptr<Wolf> wolf = std::dynamic_pointer_cast<Wolf>(*it);;
if (wolf->isTame() && wolf->getAttackTarget() == NULL && m_UUID.compare( wolf->getOwnerUUID() ) == 0)
{
if (!skipSitting || !wolf->isSitting())
@@ -1509,15 +1509,15 @@ void Player::openItemInstanceGui(std::shared_ptr<ItemInstance> itemInstance)
bool Player::interact(std::shared_ptr<Entity> entity)
{
if (entity->interact( dynamic_pointer_cast<Player>( shared_from_this() ) )) return true;
if (entity->interact( std::dynamic_pointer_cast<Player>( shared_from_this() ) )) return true;
std::shared_ptr<ItemInstance> item = getSelectedItem();
if (item != NULL && dynamic_pointer_cast<Mob>( entity ) != NULL)
if (item != NULL && std::dynamic_pointer_cast<Mob>( entity ) != NULL)
{
// 4J - PC Comments
// Hack to prevent item stacks from decrementing if the player has
// the ability to instabuild
if(this->abilities.instabuild) item = item->copy();
if(item->interactEnemy(dynamic_pointer_cast<Mob>(entity)))
if(item->interactEnemy(std::dynamic_pointer_cast<Mob>(entity)))
{
// 4J - PC Comments
// Don't remove the item in hand if the player has the ability
@@ -1577,7 +1577,7 @@ void Player::attack(std::shared_ptr<Entity> entity)
int knockback = 0;
int magicBoost = 0;
std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(entity);
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(entity);
if (mob != NULL)
{
magicBoost = EnchantmentHelper::getDamageBonus(inventory, mob);
@@ -1600,14 +1600,14 @@ void Player::attack(std::shared_ptr<Entity> entity)
// Ensure we put the entity on fire if we're hitting with a
// fire-enchanted weapon
bool setOnFireTemporatily = false;
int fireAspect = EnchantmentHelper::getFireAspect(dynamic_pointer_cast<Mob>(shared_from_this()));
if (dynamic_pointer_cast<Mob>(entity) && fireAspect > 0 && !entity->isOnFire())
int fireAspect = EnchantmentHelper::getFireAspect(std::dynamic_pointer_cast<Mob>(shared_from_this()));
if (std::dynamic_pointer_cast<Mob>(entity) && fireAspect > 0 && !entity->isOnFire())
{
setOnFireTemporatily = true;
entity->setOnFire(1);
}
DamageSource *damageSource = DamageSource::playerAttack(dynamic_pointer_cast<Player>(shared_from_this()));
DamageSource *damageSource = DamageSource::playerAttack(std::dynamic_pointer_cast<Player>(shared_from_this()));
bool wasHurt = entity->hurt(damageSource, dmg);
delete damageSource;
if (wasHurt)
@@ -1635,7 +1635,7 @@ void Player::attack(std::shared_ptr<Entity> entity)
}
setLastHurtMob(entity);
std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(entity);
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(entity);
if (mob)
{
ThornsEnchantment::doThornsAfterAttack(shared_from_this(), mob, random);
@@ -1643,19 +1643,19 @@ void Player::attack(std::shared_ptr<Entity> entity)
}
std::shared_ptr<ItemInstance> item = getSelectedItem();
if (item != NULL && dynamic_pointer_cast<Mob>( entity ) != NULL)
if (item != NULL && std::dynamic_pointer_cast<Mob>( entity ) != NULL)
{
item->hurtEnemy(dynamic_pointer_cast<Mob>(entity), dynamic_pointer_cast<Player>( shared_from_this() ) );
item->hurtEnemy(std::dynamic_pointer_cast<Mob>(entity), std::dynamic_pointer_cast<Player>( shared_from_this() ) );
if (item->count <= 0)
{
removeSelectedItem();
}
}
if (dynamic_pointer_cast<Mob>( entity ) != NULL)
if (std::dynamic_pointer_cast<Mob>( entity ) != NULL)
{
if (entity->isAlive())
{
directAllTameWolvesOnTarget(dynamic_pointer_cast<Mob>(entity), true);
directAllTameWolvesOnTarget(std::dynamic_pointer_cast<Mob>(entity), true);
}
// 4J Stu - Brought forward wasHurt check to Fix 66140 - Bug: Fire Aspect bypasses "Player v Player" being Disabled
if (fireAspect > 0 && wasHurt)
@@ -1708,10 +1708,10 @@ Slot *Player::getInventorySlot(int slotId)
void Player::remove()
{
this->Mob::remove();
inventoryMenu->removed( dynamic_pointer_cast<Player>( shared_from_this() ) );
inventoryMenu->removed( std::dynamic_pointer_cast<Player>( shared_from_this() ) );
if (containerMenu != NULL)
{
containerMenu->removed( dynamic_pointer_cast<Player>( shared_from_this() ) );
containerMenu->removed( std::dynamic_pointer_cast<Player>( shared_from_this() ) );
}
}
@@ -2142,7 +2142,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz)
int distance = (int) Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f);
if (distance > 0)
{
if ( dynamic_pointer_cast<Minecart>( riding ) )
if ( std::dynamic_pointer_cast<Minecart>( riding ) )
{
distanceMinecart += distance;
if( distanceMinecart >= 100 )
@@ -2189,7 +2189,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz)
}
}
else if (dynamic_pointer_cast<Boat>( riding ) != NULL)
else if (std::dynamic_pointer_cast<Boat>( riding ) != NULL)
{
distanceBoat += distance;
if( distanceBoat >= 100 )
@@ -2199,7 +2199,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz)
awardStat(GenericStats::boatOneM(), GenericStats::param_boat(newDistance/100) );
}
}
else if (dynamic_pointer_cast<Pig>( riding ) != NULL)
else if (std::dynamic_pointer_cast<Pig>( riding ) != NULL)
{
distancePig += distance;
if( distancePig >= 100 )
@@ -2235,7 +2235,7 @@ void Player::causeFallDamage(float distance)
void Player::killed(std::shared_ptr<Mob> mob)
{
// 4J-PB - added the lavaslime enemy - fix for #64007 - TU7: Code: Achievements: TCR#073: Killing Magma Cubes doesn't unlock "Monster Hunter" Achievement.
if( dynamic_pointer_cast<Monster>( mob ) != NULL || mob->GetType() == eTYPE_GHAST || mob->GetType() == eTYPE_SLIME || mob->GetType() == eTYPE_LAVASLIME || mob->GetType() == eTYPE_ENDERDRAGON)
if( std::dynamic_pointer_cast<Monster>( mob ) != NULL || mob->GetType() == eTYPE_GHAST || mob->GetType() == eTYPE_SLIME || mob->GetType() == eTYPE_LAVASLIME || mob->GetType() == eTYPE_ENDERDRAGON)
{
awardStat(GenericStats::killEnemy(), GenericStats::param_noArgs());
@@ -2425,7 +2425,7 @@ void Player::startUsingItem(std::shared_ptr<ItemInstance> instance, int duration
// 4J-JEV, hook for ItemUsed event, and ironbelly achievement.
awardStat(GenericStats::itemsUsed(instance->getItem()->id),
GenericStats::param_itemsUsed(dynamic_pointer_cast<Player>(shared_from_this()),instance));
GenericStats::param_itemsUsed(std::dynamic_pointer_cast<Player>(shared_from_this()),instance));
#if (!defined _DURANGO) && (defined _EXTENDED_ACHIEVEMENTS)
if ( (instance->getItem()->id == Item::rotten_flesh_Id) && (getFoodData()->getFoodLevel() == 0) )
@@ -2774,7 +2774,7 @@ bool Player::isAllowedToInteract(std::shared_ptr<Entity> target)
{
if (getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CanUseContainers) == 0)
{
std::shared_ptr<Minecart> minecart = dynamic_pointer_cast<Minecart>( target );
std::shared_ptr<Minecart> minecart = std::dynamic_pointer_cast<Minecart>( target );
if (minecart->type == Minecart::CHEST)
allowed = false;
}