From 087b7e7abfe81dd7f0fdcdea36ac9f245950df1a Mon Sep 17 00:00:00 2001 From: Loki Rautio Date: Sat, 7 Mar 2026 21:12:22 -0600 Subject: Revert "Project modernization (#630)" This code was not tested and breaks in Release builds, reverting to restore functionality of the nightly. All in-game menus do not work and generating a world crashes. This reverts commit a9be52c41a02d207233199e98898fe7483d7e817. --- Minecraft.World/Entity.cpp | 74 +++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'Minecraft.World/Entity.cpp') diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index d754330b..e8233140 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -41,7 +41,7 @@ int Entity::extraWanderCount = 0; int Entity::getSmallId() { unsigned int *puiUsedFlags = entityIdUsedFlags; - unsigned int *puiRemovedFlags = nullptr; + unsigned int *puiRemovedFlags = NULL; // If we are the server (we should be, if we are allocating small Ids), then check with the server if there are any small Ids which are // still in the ServerPlayer's vectors of entities to be removed - these are used to gather up a set of entities into one network packet @@ -260,7 +260,7 @@ void Entity::_init(bool useSmallId, Level *level) riding = nullptr; forcedLoading = false; - //level = nullptr; // Level is assigned to in the original c_tor code + //level = NULL; // Level is assigned to in the original c_tor code xo = yo = zo = 0.0; x = y = z = 0.0; xd = yd = zd = 0.0; @@ -312,7 +312,7 @@ void Entity::_init(bool useSmallId, Level *level) // values that need to be sent to clients in SMP if( useSmallId ) { - entityData = std::make_shared(); + entityData = shared_ptr(new SynchedEntityData()); } else { @@ -355,14 +355,14 @@ Entity::Entity(Level *level, bool useSmallId) // 4J - added useSmallId parameter // resetPos(); setPos(0, 0, 0); - if (level != nullptr) + if (level != NULL) { dimension = level->dimension->id; } if( entityData ) { - entityData->define(DATA_SHARED_FLAGS_ID, static_cast(0)); + entityData->define(DATA_SHARED_FLAGS_ID, (byte) 0); entityData->define(DATA_AIR_SUPPLY_ID, TOTAL_AIR_SUPPLY); // 4J Stu - Brought forward from 1.2.3 to fix 38654 - Gameplay: Player will take damage when air bubbles are present if resuming game from load/autosave underwater. } @@ -398,7 +398,7 @@ return entityId; void Entity::resetPos() { - if (level == nullptr) return; + if (level == NULL) return; shared_ptr sharedThis = shared_from_this(); while (true && y > 0) @@ -510,7 +510,7 @@ void Entity::baseTick() // 4J Stu - Not needed //util.Timer.push("entityBaseTick"); - if (riding != nullptr && riding->removed) + if (riding != NULL && riding->removed) { riding = nullptr; } @@ -533,7 +533,7 @@ void Entity::baseTick() { if (server->isNetherEnabled()) { - if (riding == nullptr) + if (riding == NULL) { if (portalTime++ >= waitTime) { @@ -883,7 +883,7 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J - double zm = z - zo; - if (makeStepSound() && !isPlayerSneaking && riding == nullptr) + if (makeStepSound() && !isPlayerSneaking && riding == NULL) { int xt = Mth::floor(x); int yt = Mth::floor(y - 0.2f - heightOffset); @@ -907,7 +907,7 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J - if (moveDist > nextStep && t > 0) { - nextStep = static_cast(moveDist) + 1; + nextStep = (int) moveDist + 1; if (isInWater()) { float speed = Mth::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * 0.35f; @@ -1023,13 +1023,13 @@ void Entity::checkFallDamage(double ya, bool onGround) } else { - if (ya < 0) fallDistance -= static_cast(ya); + if (ya < 0) fallDistance -= (float) ya; } } AABB *Entity::getCollideBox() { - return nullptr; + return NULL; } void Entity::burn(int dmg) @@ -1047,7 +1047,7 @@ bool Entity::isFireImmune() void Entity::causeFallDamage(float distance) { - if (rider.lock() != nullptr) rider.lock()->causeFallDamage(distance); + if (rider.lock() != NULL) rider.lock()->causeFallDamage(distance); } @@ -1072,7 +1072,7 @@ bool Entity::updateInWaterState() MemSect(31); playSound(eSoundType_RANDOM_SPLASH, speed, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f); MemSect(0); - float yt = static_cast(Mth::floor(bb->y0)); + float yt = (float) Mth::floor(bb->y0); for (int i = 0; i < 1 + bbWidth * 20; i++) { float xo = (random->nextFloat() * 2 - 1) * bbWidth; @@ -1202,9 +1202,9 @@ void Entity::moveTo(double x, double y, double z, float yRot, float xRot) float Entity::distanceTo(shared_ptr e) { - float xd = static_cast(x - e->x); - float yd = static_cast(y - e->y); - float zd = static_cast(z - e->z); + float xd = (float) (x - e->x); + float yd = (float) (y - e->y); + float zd = (float) (z - e->z); return sqrt(xd * xd + yd * yd + zd * zd); } @@ -1348,7 +1348,7 @@ bool Entity::saveAsMount(CompoundTag *entityTag) bool Entity::save(CompoundTag *entityTag) { wstring id = getEncodeId(); - if (removed || id.empty() || (rider.lock() != nullptr) ) + if (removed || id.empty() || (rider.lock() != NULL) ) { return false; } @@ -1365,8 +1365,8 @@ void Entity::saveWithoutId(CompoundTag *entityTag) entityTag->put(L"Rotation", newFloatList(2, yRot, xRot)); entityTag->putFloat(L"FallDistance", fallDistance); - entityTag->putShort(L"Fire", static_cast(onFire)); - entityTag->putShort(L"Air", static_cast(getAirSupply())); + entityTag->putShort(L"Fire", (short) onFire); + entityTag->putShort(L"Air", (short) getAirSupply()); entityTag->putBoolean(L"OnGround", onGround); entityTag->putInt(L"Dimension", dimension); entityTag->putBoolean(L"Invulnerable", invulnerable); @@ -1376,7 +1376,7 @@ void Entity::saveWithoutId(CompoundTag *entityTag) addAdditonalSaveData(entityTag); - if (riding != nullptr) + if (riding != NULL) { CompoundTag *ridingTag = new CompoundTag(RIDING_TAG); if (riding->saveAsMount(ridingTag)) @@ -1511,7 +1511,7 @@ shared_ptr Entity::spawnAtLocation(int resource, int count) shared_ptr Entity::spawnAtLocation(int resource, int count, float yOffs) { - return spawnAtLocation(std::make_shared(resource, count, 0), yOffs); + return spawnAtLocation(shared_ptr( new ItemInstance(resource, count, 0) ), yOffs); } shared_ptr Entity::spawnAtLocation(shared_ptr itemInstance, float yOffs) @@ -1520,7 +1520,7 @@ shared_ptr Entity::spawnAtLocation(shared_ptr itemInst { return nullptr; } - shared_ptr ie = std::make_shared(level, x, y + yOffs, z, itemInstance); + shared_ptr ie = shared_ptr( new ItemEntity(level, x, y + yOffs, z, itemInstance) ); ie->throwTime = 10; level->addEntity(ie); return ie; @@ -1556,7 +1556,7 @@ bool Entity::interact(shared_ptr player) AABB *Entity::getCollideAgainstBox(shared_ptr entity) { - return nullptr; + return NULL; } void Entity::rideTick() @@ -1569,7 +1569,7 @@ void Entity::rideTick() xd = yd = zd = 0; tick(); - if (riding == nullptr) return; + if (riding == NULL) return; // Sets riders old&new position to it's mount's old&new position (plus the ride y-seperatation). riding->positionRider(); @@ -1605,7 +1605,7 @@ void Entity::rideTick() void Entity::positionRider() { shared_ptr lockedRider = rider.lock(); - if( lockedRider == nullptr) + if( lockedRider == NULL) { return; } @@ -1627,9 +1627,9 @@ void Entity::ride(shared_ptr e) xRideRotA = 0; yRideRotA = 0; - if (e == nullptr) + if (e == NULL) { - if (riding != nullptr) + if (riding != NULL) { // 4J Stu - Position should already be updated before the SetEntityLinkPacket comes in if(!level->isClientSide) moveTo(riding->x, riding->bb->y0 + riding->bbHeight, riding->z, yRot, xRot); @@ -1638,7 +1638,7 @@ void Entity::ride(shared_ptr e) riding = nullptr; return; } - if (riding != nullptr) + if (riding != NULL) { riding->rider = weak_ptr(); } @@ -1677,7 +1677,7 @@ float Entity::getPickRadius() Vec3 *Entity::getLookAngle() { - return nullptr; + return NULL; } void Entity::handleInsidePortal() @@ -1721,7 +1721,7 @@ void Entity::animateHurt() ItemInstanceArray Entity::getEquipmentSlots() // ItemInstance[] { - return ItemInstanceArray(); // Default ctor creates nullptr internal array + return ItemInstanceArray(); // Default ctor creates NULL internal array } // 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 @@ -1736,7 +1736,7 @@ bool Entity::isOnFire() bool Entity::isRiding() { - return riding != nullptr; + return riding != NULL; } bool Entity::isSneaking() @@ -1823,11 +1823,11 @@ void Entity::setSharedFlag(int flag, bool value) byte currentValue = entityData->getByte(DATA_SHARED_FLAGS_ID); if (value) { - entityData->set(DATA_SHARED_FLAGS_ID, static_cast(currentValue | (1 << flag))); + entityData->set(DATA_SHARED_FLAGS_ID, (byte) (currentValue | (1 << flag))); } else { - entityData->set(DATA_SHARED_FLAGS_ID, static_cast(currentValue & ~(1 << flag))); + entityData->set(DATA_SHARED_FLAGS_ID, (byte) (currentValue & ~(1 << flag))); } } } @@ -1841,7 +1841,7 @@ int Entity::getAirSupply() // 4J Stu - Brought forward from 1.2.3 to fix 38654 - Gameplay: Player will take damage when air bubbles are present if resuming game from load/autosave underwater. void Entity::setAirSupply(int supply) { - entityData->set(DATA_AIR_SUPPLY_ID, static_cast(supply)); + entityData->set(DATA_AIR_SUPPLY_ID, (short) supply); } void Entity::thunderHit(const LightningBolt *lightningBolt) @@ -1937,7 +1937,7 @@ wstring Entity::getAName() vector > *Entity::getSubEntities() { - return nullptr; + return NULL; } bool Entity::is(shared_ptr other) @@ -2023,7 +2023,7 @@ void Entity::changeDimension(int i) server->getPlayers()->repositionAcrossDimension(shared_from_this(), lastDimension, oldLevel, newLevel); shared_ptr newEntity = EntityIO::newEntity(EntityIO::getEncodeId(shared_from_this()), newLevel); - if (newEntity != nullptr) + if (newEntity != NULL) { newEntity->restoreFrom(shared_from_this(), true); -- cgit v1.2.3