From 187abe3f5e2219e0a80c0cdca4db362e223b60ae Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 26 Feb 2017 22:49:23 +0100 Subject: Gen: Moved PiecePool into a separate file. Also rewritten the PieceGenerator to use std::unique_ptr. --- src/Generating/VillageGen.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/Generating/VillageGen.cpp') diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 6d5216a16..11617c9ec 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -5,7 +5,7 @@ #include "Globals.h" #include "VillageGen.h" -#include "PieceGenerator.h" +#include "PieceGeneratorBFSTree.h" @@ -133,7 +133,7 @@ public: m_HeightGen(a_HeightGen) { // Generate the pieces for this village; don't care about the Y coord: - cBFSPieceGenerator pg(*this, a_Seed); + cPieceGeneratorBFSTree pg(*this, a_Seed); pg.PlacePieces(a_OriginX, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces); if (m_Pieces.empty()) { @@ -141,10 +141,6 @@ public: } } - ~cVillage() - { - cPieceGenerator::FreePieces(m_Pieces); - } protected: /** Seed for the random functions */ @@ -193,7 +189,7 @@ protected: { PlacePieceOnGround(**itr); } - Prefab.Draw(a_Chunk, *itr); + Prefab.Draw(a_Chunk, itr->get()); } // for itr - m_PlacedPieces[] } @@ -304,11 +300,11 @@ protected: void MoveAllDescendants(cPlacedPieces & a_PlacedPieces, size_t a_Pivot, int a_HeightDifference) { size_t num = a_PlacedPieces.size(); - cPlacedPiece * Pivot = a_PlacedPieces[a_Pivot]; + auto & Pivot = a_PlacedPieces[a_Pivot]; for (size_t i = a_Pivot + 1; i < num; i++) { if ( - (a_PlacedPieces[i]->GetParent() == Pivot) && // It is a direct dependant of the pivot + (a_PlacedPieces[i]->GetParent() == Pivot.get()) && // It is a direct dependant of the pivot !(static_cast(a_PlacedPieces[i]->GetPiece())).ShouldMoveToGround() // It attaches strictly by connectors ) { -- cgit v1.2.3