diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index 76138cf23..927a8b71f 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -3862,12 +3862,6 @@ LevelRenderer::DestroyedTileManager::RecentTile::RecentTile(int x, int y, int z, rebuilt = false; } -LevelRenderer::DestroyedTileManager::RecentTile::~RecentTile() { - for (AUTO_VAR(it, boxes.begin()); it != boxes.end(); it++) { - delete *it; - } -} - LevelRenderer::DestroyedTileManager::DestroyedTileManager() { InitializeCriticalSection(&m_csDestroyedTiles); } @@ -3899,14 +3893,6 @@ void LevelRenderer::DestroyedTileManager::destroyingTileAt(Level* level, int x, tile->addAABBs(level, x, y, z, &box, &recentTile->boxes, nullptr); } - // Make these temporary AABBs into permanently allocated AABBs - for (unsigned int i = 0; i < recentTile->boxes.size(); i++) { - recentTile->boxes[i] = - new AABB(recentTile->boxes[i]->x0, recentTile->boxes[i]->y0, - recentTile->boxes[i]->z0, recentTile->boxes[i]->x1, - recentTile->boxes[i]->y1, recentTile->boxes[i]->z1); - } - m_destroyedTiles.push_back(recentTile); LeaveCriticalSection(&m_csDestroyedTiles); @@ -3977,14 +3963,13 @@ void LevelRenderer::DestroyedTileManager::addAABBs(Level* level, AABB* box, // interested in, add them to the output list, making a temp // AABB copy so that we can destroy our own copy without // worrying about the lifespan of the copy we've passed out - if (m_destroyedTiles[i]->boxes[j]->intersects(*box)) { - AABB bb(m_destroyedTiles[i]->boxes[j]->x0, - m_destroyedTiles[i]->boxes[j]->y0, - m_destroyedTiles[i]->boxes[j]->z0, - m_destroyedTiles[i]->boxes[j]->x1, - m_destroyedTiles[i]->boxes[j]->y1, - m_destroyedTiles[i]->boxes[j]->z1); - boxes->push_back(&bb); + if (m_destroyedTiles[i]->boxes[j].intersects(*box)) { + boxes->push_back({m_destroyedTiles[i]->boxes[j].x0, + m_destroyedTiles[i]->boxes[j].y0, + m_destroyedTiles[i]->boxes[j].z0, + m_destroyedTiles[i]->boxes[j].x1, + m_destroyedTiles[i]->boxes[j].y1, + m_destroyedTiles[i]->boxes[j].z1}); } } } diff --git a/Minecraft.Client/Rendering/LevelRenderer.h b/Minecraft.Client/Rendering/LevelRenderer.h index 1275ee4e8..58f194a3b 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.h +++ b/Minecraft.Client/Rendering/LevelRenderer.h @@ -234,7 +234,7 @@ public: int timeout_ticks; bool rebuilt; RecentTile(int x, int y, int z, Level* level); - ~RecentTile(); + ~RecentTile() = default; }; CRITICAL_SECTION m_csDestroyedTiles; std::vector m_destroyedTiles; diff --git a/Minecraft.World/Blocks/Tile.cpp b/Minecraft.World/Blocks/Tile.cpp index a895238ef..a2033379b 100644 --- a/Minecraft.World/Blocks/Tile.cpp +++ b/Minecraft.World/Blocks/Tile.cpp @@ -2016,7 +2016,7 @@ AABB* Tile::getTileAABB(Level* level, int x, int y, int z) { void Tile::addAABBs(Level* level, int x, int y, int z, AABB* box, AABBList* boxes, std::shared_ptr source) { AABB* aabb = getAABB(level, x, y, z); - if (aabb != NULL && box->intersects(*aabb)) boxes->push_back(aabb); + if (aabb != NULL && box->intersects(*aabb)) boxes->push_back(*aabb); } AABB* Tile::getAABB(Level* level, int x, int y, int z) { diff --git a/Minecraft.World/Entities/Entity.cpp b/Minecraft.World/Entities/Entity.cpp index 80a56fd74..d07f16799 100644 --- a/Minecraft.World/Entities/Entity.cpp +++ b/Minecraft.World/Entities/Entity.cpp @@ -733,7 +733,7 @@ void Entity::move(double xa, double ya, double za, // But if we don't have the chunk data then all the collision info will // be incorrect as well for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++) - ya = (*it)->clipYCollide(*bb, ya); + ya = it->clipYCollide(*bb, ya); *bb = bb->move(0, ya, 0); } @@ -745,7 +745,7 @@ void Entity::move(double xa, double ya, double za, itEndAABB = aABBs->end(); for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++) - xa = (*it)->clipXCollide(*bb, xa); + xa = it->clipXCollide(*bb, xa); *bb = bb->move(xa, 0, 0); @@ -755,7 +755,7 @@ void Entity::move(double xa, double ya, double za, itEndAABB = aABBs->end(); for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++) - za = (*it)->clipZCollide(*bb, za); + za = it->clipZCollide(*bb, za); *bb = bb->move(0, 0, za); if (!slide && zaOrg != za) { @@ -789,7 +789,7 @@ void Entity::move(double xa, double ya, double za, // all! But if we don't have the chunk data then all the collision // info will be incorrect as well for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++) - ya = (*it)->clipYCollide(*bb, ya); + ya = it->clipYCollide(*bb, ya); *bb = bb->move(0, ya, 0); } @@ -799,7 +799,7 @@ void Entity::move(double xa, double ya, double za, itEndAABB = aABBs->end(); for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++) - xa = (*it)->clipXCollide(*bb, xa); + xa = it->clipXCollide(*bb, xa); *bb = bb->move(xa, 0, 0); if (!slide && xaOrg != xa) { @@ -808,7 +808,7 @@ void Entity::move(double xa, double ya, double za, itEndAABB = aABBs->end(); for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++) - za = (*it)->clipZCollide(*bb, za); + za = it->clipZCollide(*bb, za); *bb = bb->move(0, 0, za); if (!slide && zaOrg != za) { @@ -822,7 +822,7 @@ void Entity::move(double xa, double ya, double za, // LAND FIRST, then x and z itEndAABB = aABBs->end(); for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++) - ya = (*it)->clipYCollide(*bb, ya); + ya = it->clipYCollide(*bb, ya); *bb = bb->move(0, ya, 0); } @@ -1526,8 +1526,7 @@ void Entity::lerpTo(double x, double y, double z, float yRot, float xRot, double yTop = 0; AUTO_VAR(itEnd, collisions->end()); for (AUTO_VAR(it, collisions->begin()); it != itEnd; it++) { - AABB* ab = *it; // collisions->at(i); - if (ab->y1 > yTop) yTop = ab->y1; + if (it->y1 > yTop) yTop = it->y1; } y += yTop - bb->y0; @@ -1668,7 +1667,7 @@ bool Entity::checkInTile(double x, double y, double z) { double yd = y - (yTile); double zd = z - (zTile); - std::vector* cubes = level->getTileCubes(bb); + auto* cubes = level->getTileCubes(bb); if ((cubes && !cubes->empty()) || level->isFullAABBTile(xTile, yTile, zTile)) { bool west = !level->isFullAABBTile(xTile - 1, yTile, zTile); diff --git a/Minecraft.World/Entities/LivingEntity.cpp b/Minecraft.World/Entities/LivingEntity.cpp index 8725643cf..c30033456 100644 --- a/Minecraft.World/Entities/LivingEntity.cpp +++ b/Minecraft.World/Entities/LivingEntity.cpp @@ -1518,8 +1518,7 @@ void LivingEntity::aiStep() { double yTop = 0; AUTO_VAR(itEnd, collisions->end()); for (AUTO_VAR(it, collisions->begin()); it != itEnd; it++) { - AABB* ab = *it; // collisions->at(i); - if (ab->y1 > yTop) yTop = ab->y1; + if (it->y1 > yTop) yTop = it->y1; } yt += yTop - bb->y0; diff --git a/Minecraft.World/Level/Level.cpp b/Minecraft.World/Level/Level.cpp index cd572cbf7..bfaab0c3d 100644 --- a/Minecraft.World/Level/Level.cpp +++ b/Minecraft.World/Level/Level.cpp @@ -1805,12 +1805,12 @@ AABBList* Level::getCubes(std::shared_ptr source, AABB* box, for (AUTO_VAR(it, ee->begin()); it != itEnd; it++) { AABB* collideBox = (*it)->getCollideBox(); if (collideBox != NULL && collideBox->intersects(*box)) { - boxes.push_back(collideBox); + boxes.push_back(*collideBox); } collideBox = source->getCollideAgainstBox(*it); if (collideBox != NULL && collideBox->intersects(*box)) { - boxes.push_back(collideBox); + boxes.push_back(*collideBox); } } diff --git a/Minecraft.World/Util/Definitions.h b/Minecraft.World/Util/Definitions.h index b0dec3cfe..3ad0caa91 100644 --- a/Minecraft.World/Util/Definitions.h +++ b/Minecraft.World/Util/Definitions.h @@ -4,7 +4,7 @@ class AABB; class Recipy; class Object; -typedef std::vector AABBList; +typedef std::vector AABBList; typedef std::vector RecipyList; typedef std::vector ObjectList; @@ -34,4 +34,4 @@ enum EDefaultSkins { eDefaultSkins_Skin7, eDefaultSkins_Count, -}; \ No newline at end of file +};