diff options
author | Mattes D <github@xoft.cz> | 2015-07-07 11:50:06 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-07-07 11:50:06 +0200 |
commit | bebd4de14457fbbc7fd49900cfdc36c8d5efb755 (patch) | |
tree | fb2000f4483f97bda0080ae3e87b6701d37464b9 | |
parent | Merge pull request #2319 from SamJBarney/master (diff) | |
download | cuberite-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 |
-rw-r--r-- | src/ClientHandle.cpp | 4 | ||||
-rw-r--r-- | src/Generating/BioGen.cpp | 4 | ||||
-rw-r--r-- | src/Generating/BioGen.h | 6 | ||||
-rw-r--r-- | src/Generating/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Generating/HeiGen.cpp | 20 | ||||
-rw-r--r-- | src/Generating/HeiGen.h | 12 | ||||
-rw-r--r-- | src/Protocol/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Protocol/Protocol18x.cpp | 14 |
8 files changed, 32 insertions, 32 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9ed89e0a3..6ca43da6f 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -440,9 +440,9 @@ bool cClientHandle::StreamNextChunk(void) int RangeX, RangeZ = 0; cChunkDef::BlockToChunk(FloorC(Vector.x), FloorC(Vector.z), RangeX, RangeZ); - for (size_t X = 0; X < 7; X++) + for (int X = 0; X < 7; X++) { - for (size_t Z = 0; Z < 7; Z++) + for (int Z = 0; Z < 7; Z++) { int ChunkX = RangeX + ((X >= 4) ? (3 - X) : X); int ChunkZ = RangeZ + ((Z >= 4) ? (3 - Z) : Z); 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) } ; diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt index fdc98b960..5adf6bd5e 100644 --- a/src/Protocol/CMakeLists.txt +++ b/src/Protocol/CMakeLists.txt @@ -29,7 +29,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set_source_files_properties(ChunkDataSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") set_source_files_properties(MojangAPI.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") set_source_files_properties(Packetizer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") - set_source_files_properties(Protocol18x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch-enum -Wno-error=switch -Wno-error=old-style-cast") + set_source_files_properties(Protocol18x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch-enum -Wno-error=switch") set_source_files_properties(Protocol17x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast") set_source_files_properties(ProtocolRecognizer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") endif() diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index d5dd328a4..99bba63e3 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -747,7 +747,7 @@ void cProtocol180::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decor cPacketizer Pkt(*this, 0x34); Pkt.WriteVarInt32(a_ID); Pkt.WriteBEUInt8(m_Scale); - Pkt.WriteVarInt32(a_Decorators.size()); + Pkt.WriteVarInt32(static_cast<UInt32>(a_Decorators.size())); for (cMapDecoratorList::const_iterator it = a_Decorators.begin(); it != a_Decorators.end(); ++it) { @@ -1715,7 +1715,7 @@ bool cProtocol180::CompressPacket(const AString & a_Packet, AString & a_Compress // Compress the data: char CompressedData[MAX_COMPRESSED_PACKET_LEN]; - uLongf CompressedSize = compressBound(a_Packet.size()); + uLongf CompressedSize = compressBound(static_cast<uLongf>(a_Packet.size())); if (CompressedSize >= MAX_COMPRESSED_PACKET_LEN) { ASSERT(!"Too high packet size."); @@ -1724,7 +1724,7 @@ bool cProtocol180::CompressPacket(const AString & a_Packet, AString & a_Compress int Status = compress2( reinterpret_cast<Bytef *>(CompressedData), &CompressedSize, - reinterpret_cast<const Bytef *>(a_Packet.data()), a_Packet.size(), Z_DEFAULT_COMPRESSION + reinterpret_cast<const Bytef *>(a_Packet.data()), static_cast<uLongf>(a_Packet.size()), Z_DEFAULT_COMPRESSION ); if (Status != Z_OK) { @@ -1737,7 +1737,7 @@ bool cProtocol180::CompressPacket(const AString & a_Packet, AString & a_Compress Buffer.ReadAll(LengthData); Buffer.CommitRead(); - Buffer.WriteVarInt32(CompressedSize + LengthData.size()); + Buffer.WriteVarInt32(static_cast<UInt32>(CompressedSize + LengthData.size())); Buffer.WriteVarInt32(static_cast<UInt32>(a_Packet.size())); Buffer.ReadAll(LengthData); Buffer.CommitRead(); @@ -1910,7 +1910,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size) AString UncompressedData; if (m_State == 3) { - UInt32 NumBytesRead = m_ReceivedData.GetReadableSpace(); + UInt32 NumBytesRead = static_cast<UInt32>(m_ReceivedData.GetReadableSpace()); m_ReceivedData.ReadVarInt(CompressedSize); if (CompressedSize > PacketLen) { @@ -1926,11 +1926,11 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size) m_Client->Kick("Compression failure"); return; } - PacketLen = UncompressedData.size(); + PacketLen = static_cast<UInt32>(UncompressedData.size()); } else { - NumBytesRead -= m_ReceivedData.GetReadableSpace(); // How many bytes has the CompressedSize taken up? + NumBytesRead -= static_cast<UInt32>(m_ReceivedData.GetReadableSpace()); // How many bytes has the CompressedSize taken up? ASSERT(PacketLen > NumBytesRead); PacketLen -= NumBytesRead; } |