Permalink
Browse files

Merge https://github.com/Caldfir/stonesense

  • Loading branch information...
2 parents 8cc2b41 + 65fcd68 commit 17b653665567a5f1df628217820f76bb0b9c70a5 @peterix peterix committed Jun 13, 2012
View
@@ -6,32 +6,43 @@ BlockFactory blockFactory;
BlockFactory::BlockFactory(void)
{
- poolSize = 0;
+ poolSize = 0;
+ blocksCreated = 0;
}
BlockFactory::~BlockFactory(void)
{
- for(uint32_t i=0; i<poolSize; i++){
- free( pool[i] );
- }
+ for(uint32_t i=0; i<poolSize; i++){
+ free( pool[i] );
+ blocksCreated--;
+ }
+ poolSize = 0;
+ pool.clear();
}
Block* BlockFactory::allocateBlock(){
- if( poolSize > 0 ){
- poolSize--;
- Block* b = pool[poolSize];
- pool.pop_back();
- return b;
- }
-
- //pool is empty(full), just New up a new block
- Block* b = (Block*) malloc( sizeof(Block) );
- return b;
+ if( poolSize > 0 ){
+ poolSize--;
+ Block* b = pool[poolSize];
+ pool.pop_back();
+ return b;
+ }
+
+ //pool is empty(full), just New up a new block
+ blocksCreated++;
+ Block* b = (Block*) malloc( sizeof(Block) );
+ return b;
}
void BlockFactory::deleteBlock(Block *b){
- poolSize++;
- pool.push_back( b );
+ if(2*poolSize < blocksCreated){
+ poolSize++;
+ pool.push_back( b );
+ }
+ else{
+ blocksCreated--;
+ free( b );
+ }
}
View
@@ -5,6 +5,7 @@
class BlockFactory
{
uint32_t poolSize;
+ uint32_t blocksCreated;
vector<Block*> pool;
public:
@@ -13,6 +14,7 @@ class BlockFactory
Block* allocateBlock( );
void deleteBlock( Block* );
uint32_t getPoolSize(){ return poolSize; }
+ uint32_t getBlocksCreated(){ return blocksCreated; }
};
View
@@ -6,6 +6,7 @@ using namespace std;
#include "common.h"
#include "Block.h"
+#include "BlockFactory.h"
#include "GUI.h"
//#include "SpriteMaps.h"
#include "GameBuildings.h"
@@ -521,6 +522,9 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms)
delete last;
}
+ //need to explicitly tear down the current block factory
+ blockFactory.~BlockFactory();
+
al_destroy_bitmap(IMGIcon);
IMGIcon = 0;
delete contentLoader;
@@ -1,4 +1,4 @@
-large_256/index.txt
+large_128/index.txt
caravan_animals.xml
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,23 @@
+<?xml version="1.0" ?>
+<creatures>
+ <creature gameID="CRUNDLE" file="crundle.png" >
+
+ <variant special="Normal" sex="F" sheetIndex="0" zoom="2" color="bodypart" bodypart="scales" >
+ <subsprite sheetIndex="1" zoom="2" />
+ </variant>
+
+ <variant special="Normal" sex="M" sheetIndex="0" zoom="2" color="bodypart" bodypart="scales" >
+ <subsprite sheetIndex="21" zoom="2" />
+ </variant>
+
+ </creature>
+
+ <creature gameID="IMP_FIRE" file="crundle.png" >
+
+ <variant special="Normal" sheetIndex="40" zoom="2" color="bodypart" bodypart="skin" >
+ <subsprite sheetIndex="41" zoom="2" />
+ </variant>
+
+ </creature>
+
+</creatures>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -3,110 +3,110 @@
<creature gameID="WATER_BUFFALO" file="domestic.png" >
- <variant special="Normal" prof="CHILD" sheetIndex="4" zoom="3" color="bodypart" bodypart="skin" >
- <subsprite sheetIndex="5" zoom="3" color="bodypart" bodypart="hair" />
- <subsprite sheetIndex="6" zoom="3" />
+ <variant special="Normal" prof="CHILD" sheetIndex="4" zoom="2" color="bodypart" bodypart="skin" >
+ <subsprite sheetIndex="5" zoom="2" color="bodypart" bodypart="hair" />
+ <subsprite sheetIndex="6" zoom="2" />
</variant>
- <variant special="Normal" sex="F" sheetIndex="0" zoom="3" color="bodypart" bodypart="skin" >
- <subsprite sheetIndex="1" zoom="3" color="bodypart" bodypart="hair" />
- <subsprite sheetIndex="2" zoom="3" />
+ <variant special="Normal" sex="F" sheetIndex="0" zoom="2" color="bodypart" bodypart="skin" >
+ <subsprite sheetIndex="1" zoom="2" color="bodypart" bodypart="hair" />
+ <subsprite sheetIndex="2" zoom="2" />
</variant>
- <variant special="Normal" sex="M" sheetIndex="0" zoom="3" color="bodypart" bodypart="skin" >
- <subsprite sheetIndex="1" zoom="3" color="bodypart" bodypart="hair" />
- <subsprite sheetIndex="3" zoom="3" />
+ <variant special="Normal" sex="M" sheetIndex="0" zoom="2" color="bodypart" bodypart="skin" >
+ <subsprite sheetIndex="1" zoom="2" color="bodypart" bodypart="hair" />
+ <subsprite sheetIndex="3" zoom="2" />
</variant>
</creature>
<creature gameID="GOAT" file="domestic.png" >
- <variant special="Normal" prof="CHILD" sheetIndex="25" zoom="3" color="bodypart" bodypart="hair" >
- <subsprite sheetIndex="26" zoom="3" />
+ <variant special="Normal" prof="CHILD" sheetIndex="25" zoom="2" color="bodypart" bodypart="hair" >
+ <subsprite sheetIndex="26" zoom="2" />
</variant>
- <variant special="Normal" sex="F" sheetIndex="20" zoom="3" color="bodypart" bodypart="hair" >
- <subsprite sheetIndex="21" zoom="3" color="bodypart" bodypart="beard" />
- <subsprite sheetIndex="22" zoom="3" />
+ <variant special="Normal" sex="F" sheetIndex="20" zoom="2" color="bodypart" bodypart="hair" >
+ <subsprite sheetIndex="21" zoom="2" color="bodypart" bodypart="beard" />
+ <subsprite sheetIndex="22" zoom="2" />
</variant>
- <variant special="Normal" sex="M" sheetIndex="20" zoom="3" color="bodypart" bodypart="hair" >
- <subsprite sheetIndex="23" zoom="3" color="bodypart" bodypart="beard" />
- <subsprite sheetIndex="24" zoom="3" />
+ <variant special="Normal" sex="M" sheetIndex="20" zoom="2" color="bodypart" bodypart="hair" >
+ <subsprite sheetIndex="23" zoom="2" color="bodypart" bodypart="beard" />
+ <subsprite sheetIndex="24" zoom="2" />
</variant>
</creature>
<creature gameID="SHEEP" file="domestic.png" >
- <variant special="Normal" prof="CHILD" sheetIndex="44" zoom="3" color="bodypart" bodypart="skin" >
- <subsprite sheetIndex="45" zoom="3" color="bodypart" bodypart="wool" />
- <subsprite sheetIndex="46" zoom="3" />
+ <variant special="Normal" prof="CHILD" sheetIndex="44" zoom="2" color="bodypart" bodypart="skin" >
+ <subsprite sheetIndex="45" zoom="2" color="bodypart" bodypart="wool" />
+ <subsprite sheetIndex="46" zoom="2" />
</variant>
- <variant special="Normal" sex="F" sheetIndex="40" zoom="3" color="bodypart" bodypart="skin" >
- <subsprite sheetIndex="41" zoom="3" color="bodypart" bodypart="wool" />
- <subsprite sheetIndex="42" zoom="3" />
+ <variant special="Normal" sex="F" sheetIndex="40" zoom="2" color="bodypart" bodypart="skin" >
+ <subsprite sheetIndex="41" zoom="2" color="bodypart" bodypart="wool" />
+ <subsprite sheetIndex="42" zoom="2" />
</variant>
- <variant special="Normal" sex="M" sheetIndex="40" zoom="3" color="bodypart" bodypart="skin" >
- <subsprite sheetIndex="41" zoom="3" color="bodypart" bodypart="wool" />
- <subsprite sheetIndex="43" zoom="3" />
+ <variant special="Normal" sex="M" sheetIndex="40" zoom="2" color="bodypart" bodypart="skin" >
+ <subsprite sheetIndex="41" zoom="2" color="bodypart" bodypart="wool" />
+ <subsprite sheetIndex="43" zoom="2" />
</variant>
</creature>
<creature gameID="REINDEER" file="domestic.png" >
- <variant special="Normal" prof="CHILD" sheetIndex="62" zoom="3" color="bodypart" bodypart="hair" >
- <subsprite sheetIndex="63" zoom="3" />
+ <variant special="Normal" prof="CHILD" sheetIndex="62" zoom="2" color="bodypart" bodypart="hair" >
+ <subsprite sheetIndex="63" zoom="2" />
</variant>
- <variant special="Normal" sheetIndex="60" zoom="3" color="bodypart" bodypart="hair" >
- <subsprite sheetIndex="61" zoom="3" />
+ <variant special="Normal" sheetIndex="60" zoom="2" color="bodypart" bodypart="hair" >
+ <subsprite sheetIndex="61" zoom="2" />
</variant>
</creature>
<creature gameID="PIG" file="domestic.png" >
- <variant special="Normal" prof="CHILD" sheetIndex="81" zoom="3" color="bodypart" bodypart="skin" />
+ <variant special="Normal" prof="CHILD" sheetIndex="81" zoom="2" color="bodypart" bodypart="skin" />
- <variant special="Normal" sheetIndex="80" zoom="3" color="bodypart" bodypart="skin" />
+ <variant special="Normal" sheetIndex="80" zoom="2" color="bodypart" bodypart="skin" />
</creature>
<creature gameID="BIRD_CHICKEN" file="domestic.png" >
- <variant special="Normal" prof="CHILD" sheetIndex="104" zoom="3" >
- <subsprite sheetIndex="105" zoom="3" color="bodypart" bodypart="feathers" />
+ <variant special="Normal" prof="CHILD" sheetIndex="104" zoom="2" >
+ <subsprite sheetIndex="105" zoom="2" color="bodypart" bodypart="feathers" />
</variant>
- <variant special="Normal" sex="F" sheetIndex="100" zoom="3" >
- <subsprite sheetIndex="101" zoom="3" color="bodypart" bodypart="feathers" />
+ <variant special="Normal" sex="F" sheetIndex="100" zoom="2" >
+ <subsprite sheetIndex="101" zoom="2" color="bodypart" bodypart="feathers" />
</variant>
- <variant special="Normal" sex="M" sheetIndex="102" zoom="3" >
- <subsprite sheetIndex="103" zoom="3" color="bodypart" bodypart="feathers" />
+ <variant special="Normal" sex="M" sheetIndex="102" zoom="2" >
+ <subsprite sheetIndex="103" zoom="2" color="bodypart" bodypart="feathers" />
</variant>
</creature>
<creature gameID="BIRD_DUCK" file="domestic.png" >
- <variant special="Normal" prof="CHILD" sheetIndex="104" zoom="3" >
- <subsprite sheetIndex="105" zoom="3" color="bodypart" bodypart="feathers" />
+ <variant special="Normal" prof="CHILD" sheetIndex="104" zoom="2" >
+ <subsprite sheetIndex="105" zoom="2" color="bodypart" bodypart="feathers" />
</variant>
- <variant special="Normal" sheetIndex="120" zoom="3" >
- <subsprite sheetIndex="121" zoom="3" color="bodypart" bodypart="feathers" />
+ <variant special="Normal" sheetIndex="120" zoom="2" >
+ <subsprite sheetIndex="121" zoom="2" color="bodypart" bodypart="feathers" />
</variant>
</creature>
Oops, something went wrong.

0 comments on commit 17b6536

Please sign in to comment.