summaryrefslogtreecommitdiffstats
path: root/src/Generating
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-07-07 11:50:06 +0200
committerMattes D <github@xoft.cz>2015-07-07 11:50:06 +0200
commitbebd4de14457fbbc7fd49900cfdc36c8d5efb755 (patch)
treefb2000f4483f97bda0080ae3e87b6701d37464b9 /src/Generating
parentMerge pull request #2319 from SamJBarney/master (diff)
downloadcuberite-bebd4de14457fbbc7fd49900cfdc36c8d5efb755.tar
cuberite-bebd4de14457fbbc7fd49900cfdc36c8d5efb755.tar.gz
cuberite-bebd4de14457fbbc7fd49900cfdc36c8d5efb755.tar.bz2
cuberite-bebd4de14457fbbc7fd49900cfdc36c8d5efb755.tar.lz
cuberite-bebd4de14457fbbc7fd49900cfdc36c8d5efb755.tar.xz
cuberite-bebd4de14457fbbc7fd49900cfdc36c8d5efb755.tar.zst
cuberite-bebd4de14457fbbc7fd49900cfdc36c8d5efb755.zip
Diffstat (limited to 'src/Generating')
-rw-r--r--src/Generating/BioGen.cpp4
-rw-r--r--src/Generating/BioGen.h6
-rw-r--r--src/Generating/CMakeLists.txt2
-rw-r--r--src/Generating/HeiGen.cpp20
-rw-r--r--src/Generating/HeiGen.h12
5 files changed, 22 insertions, 22 deletions
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index eb9129c60..ee8368b36 100644
--- a/src/Generating/BioGen.cpp
+++ b/src/Generating/BioGen.cpp
@@ -86,8 +86,8 @@ void cBioGenCache::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a
{
if (((m_NumHits + m_NumMisses) % 1024) == 10)
{
- LOGD("BioGenCache: %d hits, %d misses, saved %.2f %%", m_NumHits, m_NumMisses, 100.0 * m_NumHits / (m_NumHits + m_NumMisses));
- LOGD("BioGenCache: Avg cache chain length: %.2f", (float)m_TotalChain / m_NumHits);
+ LOGD("BioGenCache: %u hits, %u misses, saved %.2f %%", static_cast<unsigned>(m_NumHits), static_cast<unsigned>(m_NumMisses), 100.0 * m_NumHits / (m_NumHits + m_NumMisses));
+ LOGD("BioGenCache: Avg cache chain length: %.2f", static_cast<double>(m_TotalChain) / m_NumHits);
}
for (size_t i = 0; i < m_CacheSize; i++)
diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h
index 2580bf53a..44f1dfd2a 100644
--- a/src/Generating/BioGen.h
+++ b/src/Generating/BioGen.h
@@ -68,9 +68,9 @@ protected:
sCacheData * m_CacheData; // m_CacheData[m_CacheOrder[0]] is the most recently used
// Cache statistics
- int m_NumHits;
- int m_NumMisses;
- int m_TotalChain; // Number of cache items walked to get to a hit (only added for hits)
+ size_t m_NumHits;
+ size_t m_NumMisses;
+ size_t m_TotalChain; // Number of cache items walked to get to a hit (only added for hits)
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
virtual void InitializeBiomeGen(cIniFile & a_IniFile) override;
diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt
index f3fe5c55c..de74f8734 100644
--- a/src/Generating/CMakeLists.txt
+++ b/src/Generating/CMakeLists.txt
@@ -73,7 +73,7 @@ SET (HDRS
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(BioGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast")
+ set_source_files_properties(BioGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
set_source_files_properties(Caves.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(ChunkGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(CompoGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index aa1c1893b..6cfd53837 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -102,16 +102,16 @@ void cHeiGenFlat::InitializeHeightGen(cIniFile & a_IniFile)
////////////////////////////////////////////////////////////////////////////////
// cHeiGenCache:
-cHeiGenCache::cHeiGenCache(cTerrainHeightGenPtr a_HeiGenToCache, int a_CacheSize) :
+cHeiGenCache::cHeiGenCache(cTerrainHeightGenPtr a_HeiGenToCache, size_t a_CacheSize) :
m_HeiGenToCache(a_HeiGenToCache),
m_CacheSize(a_CacheSize),
- m_CacheOrder(new int[a_CacheSize]),
+ m_CacheOrder(new size_t[a_CacheSize]),
m_CacheData(new sCacheData[a_CacheSize]),
m_NumHits(0),
m_NumMisses(0),
m_TotalChain(0)
{
- for (int i = 0; i < m_CacheSize; i++)
+ for (size_t i = 0; i < m_CacheSize; i++)
{
m_CacheOrder[i] = i;
m_CacheData[i].m_ChunkX = 0x7fffffff;
@@ -141,11 +141,11 @@ void cHeiGenCache::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap
if (((m_NumHits + m_NumMisses) % 1024) == 10)
{
LOGD("HeiGenCache: %d hits, %d misses, saved %.2f %%", m_NumHits, m_NumMisses, 100.0 * m_NumHits / (m_NumHits + m_NumMisses));
- LOGD("HeiGenCache: Avg cache chain length: %.2f", (float)m_TotalChain / m_NumHits);
+ LOGD("HeiGenCache: Avg cache chain length: %.2f", static_cast<double>(m_TotalChain) / m_NumHits);
}
//*/
- for (int i = 0; i < m_CacheSize; i++)
+ for (size_t i = 0; i < m_CacheSize; i++)
{
if (
(m_CacheData[m_CacheOrder[i]].m_ChunkX != a_ChunkX) ||
@@ -155,10 +155,10 @@ void cHeiGenCache::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap
continue;
}
// Found it in the cache
- int Idx = m_CacheOrder[i];
+ auto Idx = m_CacheOrder[i];
// Move to front:
- for (int j = i; j > 0; j--)
+ for (size_t j = i; j > 0; j--)
{
m_CacheOrder[j] = m_CacheOrder[j - 1];
}
@@ -177,8 +177,8 @@ void cHeiGenCache::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap
m_HeiGenToCache->GenHeightMap(a_ChunkX, a_ChunkZ, a_HeightMap);
// Insert it as the first item in the MRU order:
- int Idx = m_CacheOrder[m_CacheSize - 1];
- for (int i = m_CacheSize - 1; i > 0; i--)
+ auto Idx = m_CacheOrder[m_CacheSize - 1];
+ for (auto i = m_CacheSize - 1; i > 0; i--)
{
m_CacheOrder[i] = m_CacheOrder[i - 1];
} // for i - m_CacheOrder[]
@@ -194,7 +194,7 @@ void cHeiGenCache::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap
bool cHeiGenCache::GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, HEIGHTTYPE & a_Height)
{
- for (int i = 0; i < m_CacheSize; i++)
+ for (size_t i = 0; i < m_CacheSize; i++)
{
if ((m_CacheData[i].m_ChunkX == a_ChunkX) && (m_CacheData[i].m_ChunkZ == a_ChunkZ))
{
diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h
index e2998bfb8..0dc9c814b 100644
--- a/src/Generating/HeiGen.h
+++ b/src/Generating/HeiGen.h
@@ -28,7 +28,7 @@ class cHeiGenCache :
public cTerrainHeightGen
{
public:
- cHeiGenCache(cTerrainHeightGenPtr a_HeiGenToCache, int a_CacheSize);
+ cHeiGenCache(cTerrainHeightGenPtr a_HeiGenToCache, size_t a_CacheSize);
~cHeiGenCache();
// cTerrainHeightGen overrides:
@@ -49,14 +49,14 @@ protected:
cTerrainHeightGenPtr m_HeiGenToCache;
// To avoid moving large amounts of data for the MRU behavior, we MRU-ize indices to an array of the actual data
- int m_CacheSize;
- int * m_CacheOrder; // MRU-ized order, indices into m_CacheData array
+ size_t m_CacheSize;
+ size_t * m_CacheOrder; // MRU-ized order, indices into m_CacheData array
sCacheData * m_CacheData; // m_CacheData[m_CacheOrder[0]] is the most recently used
// Cache statistics
- int m_NumHits;
- int m_NumMisses;
- int m_TotalChain; // Number of cache items walked to get to a hit (only added for hits)
+ size_t m_NumHits;
+ size_t m_NumMisses;
+ size_t m_TotalChain; // Number of cache items walked to get to a hit (only added for hits)
} ;