From ff99373237178e9f7da02f51581f9a83d0e624d9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 27 May 2014 22:05:50 +0200 Subject: cPieceGenerator chooses starting pieces based on weights. Fixes #1033. --- src/Generating/PrefabPiecePool.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Generating/PrefabPiecePool.h') diff --git a/src/Generating/PrefabPiecePool.h b/src/Generating/PrefabPiecePool.h index c6a5ad360..695ab4ea5 100644 --- a/src/Generating/PrefabPiecePool.h +++ b/src/Generating/PrefabPiecePool.h @@ -70,6 +70,7 @@ protected: virtual cPieces GetPiecesWithConnector(int a_ConnectorType) override; virtual cPieces GetStartingPieces(void) override; virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override; + virtual int GetStartingPieceWeight(const cPiece & a_NewPiece) override; virtual void PiecePlaced(const cPiece & a_Piece) override; virtual void Reset(void) override; } ; -- cgit v1.2.3 From d29b242674fbf89035c8908753496522edf8eaee Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 28 May 2014 16:33:10 +0200 Subject: Fixed a memory leak in cPrefabPiecePool. The pool pieces weren't freed upon pool destruction. --- src/Generating/PrefabPiecePool.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Generating/PrefabPiecePool.h') diff --git a/src/Generating/PrefabPiecePool.h b/src/Generating/PrefabPiecePool.h index c6a5ad360..50ae63c0c 100644 --- a/src/Generating/PrefabPiecePool.h +++ b/src/Generating/PrefabPiecePool.h @@ -34,6 +34,12 @@ public: const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs ); + /** Destroys the pool, freeing all pieces. */ + ~cPrefabPiecePool(); + + /** Removes and frees all pieces from this pool. */ + void Clear(void); + /** Adds pieces from the specified definitions into m_AllPieces. Also adds the pieces into the m_PiecesByConnector map. May be called multiple times with different PieceDefs, will add all such pieces. */ @@ -44,7 +50,6 @@ public: May be called multiple times with different PieceDefs, will add all such pieces. */ void AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs); - protected: /** The type used to map a connector type to the list of pieces with that connector */ -- cgit v1.2.3