Skip to content

Commit

Permalink
0.0.020 -> 0.0.021: Optimisations and local tiles
Browse files Browse the repository at this point in the history
Some optimisations to cleanup for another release and prepare for local tile development.

Remove excessive vector resizing. This significantly improves performance, though it is still not ideal. This may slightly increase memory usage, but probably not by much.
Add vDeceased to store pointers to deceased Characters. (However deceased Characters have always remained in memory so this doesn't affect memory requirements).
Add ocean biome rendering for local tiles. However much work remains to be done here.
Removed some pointless calls to RNG on local tiles.
Localtile seed is now utilised properly, therefore local tiles are not all the same now (although there's not much to see at the moment).
Set wrapY default to "no".
Set quickstart global to false for release.
Set LOCAL_MAP_SIZE to 100, however in future it will be about 2000.
  • Loading branch information
RyanBabij committed Jul 19, 2018
1 parent 95c501e commit cb72bf3
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CompileCount.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
*/
#include <string>

const std::string COMPILE_COUNT = "4851";
const std::string COMPILE_COUNT = "4867";
#endif
6 changes: 3 additions & 3 deletions Driver_Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int lastline = 0;

bool FAST_COUT = false;

const std::string VERSION = "0.0.017 Win32 dev";
const std::string VERSION = "0.0.021 Win32 dev";
const std::string G_WINDOW_TITLE = "WorldSim";

const std::string SAVE_FOLDER_PATH = "savedata";
Expand All @@ -29,7 +29,7 @@ volatile const std::string devmessage = "HEY THIS IS GARO WADDUP.";
/* DEBUG MENU SHORTCUTS */
//bool AUTO_GENERATE_WORLD = false;
//bool AUTO_NEW_SIMULATION = true;
bool QUICKSTART = true; // Skip menu stuff and jump right into the game. (Will use defaults).
bool QUICKSTART = false; // Skip menu stuff and jump right into the game. (Will use defaults).
//Quickly go straight into the simulator.
bool QUICKSTART_SIMULATOR = false; // Skip menu stuff and jump right into the game. (Will use defaults).
// DEFAULT WORLD WHICH IS AUTO-GENERATED.
Expand All @@ -48,7 +48,7 @@ int DEFAULT_NUMBER_CIVS = 0;

bool FOG_OF_WAR = true;

const int LOCAL_MAP_SIZE = 64; /* Size of each city in tiles. Size is CITY_SIZE * CITY_SIZE. */
const int LOCAL_MAP_SIZE = 100; /* Size of each city in tiles. Size is CITY_SIZE * CITY_SIZE. */
//const int LOCAL_MAP_SIZE = 2000; /* Size of each city in tiles. Size is CITY_SIZE * CITY_SIZE. */

int TIME_SCALE = 60; /* How many seconds of gametime pass per logic tick. */
Expand Down
1 change: 0 additions & 1 deletion Menu_Character.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ class Menu_Characters: public GUI_Interface

void eventResize()
{

guiTableCharacters.setPanel(panelX1,panelY1,panelX2,panelY2-30);
buttonClose.setPanel(panelX2-40, panelY2-40, panelX2-20, panelY2-20);
buttonCharacterDetails.setPanel(panelX2-150, panelY1+40, panelX2-20, panelY1+20);
Expand Down
2 changes: 1 addition & 1 deletion Menu_WorldGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class Menu_WorldGenerator: public GUI_Interface
guiWrapX.wrap=true;

/* WrapY */
guiWrapY.currentOption=0;
guiWrapY.currentOption=1;
guiWrapY.addOption("Yes");
guiWrapY.addOption("No");
guiWrapY.texCycleButton=&TEX_GUI_DECREMENT;
Expand Down
16 changes: 8 additions & 8 deletions Settlement_Dwarven.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ void Settlement_Dwarven::incrementTicks ( int nTicks )

while (monthlyCounter >= 2592000)
{
// if ( world->aWorldTile(worldX,worldY).baseMetal > 0 )
// {
// //nMetalStockpile+=30;
// }
if ( world->aWorldTile(worldX,worldY).baseMetal > 0 )
{
nMetalStockpile+=30;
}

monthlyCounter-=2592000;
}

while ( dailyCounter >= 86400 )
{
if ( world->aWorldTile(worldX,worldY).baseMetal > 0 )
{
++nMetalStockpile;
}
// if ( world->aWorldTile(worldX,worldY).baseMetal > 0 )
// {
// ++nMetalStockpile;
// }
dailyCounter-=86400;
}

Expand Down
3 changes: 3 additions & 0 deletions Tribe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class Tribe: public WorldObjectGlobal, public TableInterface
Vector <Character*> vCharacter;
//std::string name;
//World* world;

// Any Character that dies gets moved here */
Vector <Character*> vDeceased;

Vector <HasXY*> vTerritory;

Expand Down
3 changes: 2 additions & 1 deletion Tribe_Human.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,10 @@ void Tribe_Human::incrementTicks ( int nTicks )
if(v->isAlive==false)
{
vCharacter.erase(v);
vDeceased.add(v);
}
}
vCharacter.shrinkToFit();
//vCharacter.shrinkToFit();

if ( vCharacter.size() == 0 )
{
Expand Down
39 changes: 30 additions & 9 deletions World_Viewer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void switchTarget(World_Local* _worldLocal)

if (mouse->isRightClick)
{
std::cout<<"Adding tile: "<<hoveredXTile<<", "<<hoveredYTile<<" to render.\n";
//std::cout<<"Adding tile: "<<hoveredXTile<<", "<<hoveredYTile<<" to render.\n";
world->generateLocal(hoveredXTile,hoveredYTile);
localX=hoveredXTile;
localY=hoveredYTile;
Expand Down Expand Up @@ -717,8 +717,11 @@ void switchTarget(World_Local* _worldLocal)
int subTileSize = pixelsPerLocalTile;
if (subTileSize < 1) { subTileSize = 1; }

// First we must seed the RNG with the seed for this local tile.
Random r1;
r1.seed (42);
r1.seed (world->aSeed(localX,localY));

const enumBiome localBaseBiome = world->aTerrain(localX,localY);

for (int localYTile = 0; localYTile<LOCAL_MAP_SIZE;++localYTile)
{
Expand All @@ -732,17 +735,33 @@ void switchTarget(World_Local* _worldLocal)
{
if ( nextPixel>=mainViewX1 && currentPixel <= mainViewX2 && floor(currentPixel) != floor(nextPixel) )
{

if ( localBaseBiome == OCEAN )
{
Renderer::placeTexture4(floor(currentPixel), floor(currentSubY), floor(nextPixel), floor(nextSubY), &TEX_WORLD_TERRAIN_OCEAN_00, false);
}
else
{
Renderer::placeTexture4(floor(currentPixel), floor(currentSubY), floor(nextPixel), floor(nextSubY), &TEX_WORLD_TERRAIN_GRASS_00, false);

if ( r1.oneIn(10) )
{
Renderer::placeTexture4(floor(currentPixel), floor(currentSubY), floor(nextPixel), floor(nextSubY), &TEX_ALCHEMY, false);
}
}

//std::cout<<".";
Renderer::placeTexture4(floor(currentPixel), floor(currentSubY), floor(nextPixel), floor(nextSubY), &TEX_WORLD_TERRAIN_GRASS_00, false);

if ( r1.oneIn(10) )
{
Renderer::placeTexture4(floor(currentPixel), floor(currentSubY), floor(nextPixel), floor(nextSubY), &TEX_ALCHEMY, false);
}


//Renderer::placeTexture4(floor(currentPixel), floor(currentSubY), floor(nextPixel), floor(nextSubY), &TEX_WORLD_TERRAIN_OCEAN_00, false);



}
else
{
r1.oneIn(10);
//r1.oneIn(10);
}

currentPixel=nextPixel;
Expand All @@ -753,7 +772,7 @@ void switchTarget(World_Local* _worldLocal)
{
for (int localXTile = 0; localXTile<LOCAL_MAP_SIZE;++localXTile)
{
r1.oneIn(10);
//r1.oneIn(10);
}
}
currentSubY=nextSubY;
Expand All @@ -770,6 +789,8 @@ void switchTarget(World_Local* _worldLocal)
// {
// //Renderer::placeTexture4(currentX, currentY, currentX+tileSize, currentY+tileSize, world->aWorldTile(tileX,tileY).currentTexture(), false);
// }



if(world->isSafe(tileX,tileY)==true && world->isLand(tileX,tileY))
{
Expand Down

0 comments on commit cb72bf3

Please sign in to comment.