From 4cb0b82d1df560ad32c92eede91f466c75a87c87 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 9 Mar 2014 05:05:37 -0700 Subject: Fixed some warnings --- src/ChunkDef.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/ChunkDef.h') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 7be2fa2df..63431f211 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -65,8 +65,8 @@ public: enum { // Chunk dimensions: - Width = 16, - Height = 256, + Width = 16U, + Height = 256U, NumBlocks = Width * Height * Width, /// If the data is collected into a single buffer, how large it needs to be: @@ -132,7 +132,7 @@ public: } - inline static unsigned int MakeIndexNoCheck(int x, int y, int z) + inline static unsigned int MakeIndexNoCheck(unsigned int x, unsigned int y, unsigned int z) { #if AXIS_ORDER == AXIS_ORDER_XZY // For some reason, NOT using the Horner schema is faster. Weird. @@ -240,7 +240,7 @@ public: { if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1)) { - int Index = MakeIndexNoCheck(x, y, z); + unsigned int Index = MakeIndexNoCheck(x, y, z); return (a_Buffer[Index / 2] >> ((Index & 1) * 4)) & 0x0f; } ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!"); @@ -256,7 +256,7 @@ public: return; } a_Buffer[a_BlockIdx / 2] = ( - (a_Buffer[a_BlockIdx / 2] & (0xf0 >> ((a_BlockIdx & 1) * 4))) | // The untouched nibble + (a_Buffer[a_BlockIdx / 2] & (0xf0 >> (static_cast(a_BlockIdx & 1) * 4))) | // The untouched nibble ((a_Nibble & 0x0f) << ((a_BlockIdx & 1) * 4)) // The nibble being set ); } @@ -282,13 +282,13 @@ public: } - inline static char GetNibble(const NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos ) + inline static NIBBLETYPE GetNibble(const NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos ) { return GetNibble(a_Buffer, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z ); } - inline static void SetNibble(NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos, char a_Value ) + inline static void SetNibble(NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos, NIBBLETYPE a_Value ) { SetNibble( a_Buffer, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Value ); } @@ -306,6 +306,9 @@ The virtual methods are called in the same order as they're declared here. class cChunkDataCallback abstract { public: + + virtual ~cChunkDataCallback() {} + /** Called before any other callbacks to inform of the current coords (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()). If false is returned, the chunk is skipped. -- cgit v1.2.3 From 676dcfd1c74a36882b5b9bb75749e3bd86b75d9e Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 9 Mar 2014 10:32:56 -0700 Subject: Globals.h is now warnings free again. Also turned off Wpadded as it is indicates potental performance issues rather than potential bugs --- src/ChunkDef.h | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'src/ChunkDef.h') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 63431f211..a5059348c 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -124,7 +124,9 @@ public: (z < Width) && (z > -1) ) { - return MakeIndexNoCheck(x, y, z); + return MakeIndexNoCheck(static_cast(x), + static_cast(y), + static_cast(z)); } LOGERROR("cChunkDef::MakeIndex(): coords out of range: {%d, %d, %d}; returning fake index 0", x, y, z); ASSERT(!"cChunkDef::MakeIndex(): coords out of chunk range!"); @@ -166,7 +168,9 @@ public: ASSERT((a_X >= 0) && (a_X < Width)); ASSERT((a_Y >= 0) && (a_Y < Height)); ASSERT((a_Z >= 0) && (a_Z < Width)); - a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)] = a_Type; + a_BlockTypes[MakeIndexNoCheck(static_cast(a_X), + static_cast(a_Y), + static_cast(a_Z))] = a_Type; } @@ -182,7 +186,9 @@ public: ASSERT((a_X >= 0) && (a_X < Width)); ASSERT((a_Y >= 0) && (a_Y < Height)); ASSERT((a_Z >= 0) && (a_Z < Width)); - return a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)]; + return a_BlockTypes[MakeIndexNoCheck(static_cast(a_X), + static_cast(a_Y), + static_cast(a_Z))]; } @@ -240,7 +246,9 @@ public: { if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1)) { - unsigned int Index = MakeIndexNoCheck(x, y, z); + unsigned int Index = MakeIndexNoCheck(static_cast(x), + static_cast(y), + static_cast(z)); return (a_Buffer[Index / 2] >> ((Index & 1) * 4)) & 0x0f; } ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!"); @@ -255,8 +263,8 @@ public: ASSERT(!"cChunkDef::SetNibble(): index out of range!"); return; } - a_Buffer[a_BlockIdx / 2] = ( - (a_Buffer[a_BlockIdx / 2] & (0xf0 >> (static_cast(a_BlockIdx & 1) * 4))) | // The untouched nibble + a_Buffer[a_BlockIdx / 2] = static_cast( + (a_Buffer[a_BlockIdx / 2] & (0xf0 >> ((a_BlockIdx & 1) * 4))) | // The untouched nibble ((a_Nibble & 0x0f) << ((a_BlockIdx & 1) * 4)) // The nibble being set ); } @@ -274,8 +282,10 @@ public: return; } - int Index = MakeIndexNoCheck(x, y, z); - a_Buffer[Index / 2] = ( + unsigned int Index = MakeIndexNoCheck(static_cast(x), + static_cast(y), + static_cast(z)); + a_Buffer[Index / 2] = static_cast( (a_Buffer[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set ); @@ -435,6 +445,9 @@ Used primarily for entity moving while both chunks are locked. class cClientDiffCallback { public: + + virtual ~cClientDiffCallback() {} + /// Called for clients that are in Chunk1 and not in Chunk2, virtual void Removed(cClientHandle * a_Client) = 0; @@ -495,6 +508,9 @@ typedef std::vector cChunkCoordsVector; class cChunkCoordCallback { public: + + virtual ~cChunkCoordCallback() {} + virtual void Call(int a_ChunkX, int a_ChunkZ) = 0; } ; -- cgit v1.2.3 From 81bf846e648bf757a67699c57f2a9e66f6850416 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 9 Mar 2014 21:58:12 +0100 Subject: ChunkDef: Replaced enums with static const ints. This makes them easier to use in std::min et al. --- src/ChunkDef.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/ChunkDef.h') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 7be2fa2df..7876c58e7 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -62,16 +62,12 @@ typedef unsigned char HEIGHTTYPE; class cChunkDef { public: - enum - { - // Chunk dimensions: - Width = 16, - Height = 256, - NumBlocks = Width * Height * Width, - - /// If the data is collected into a single buffer, how large it needs to be: - BlockDataSize = cChunkDef::NumBlocks * 2 + (cChunkDef::NumBlocks / 2), // 2.5 * numblocks - } ; + // Chunk dimensions: + static const int Width = 16; + static const int Height = 256; + static const int NumBlocks = Width * Height * Width; + /// If the data is collected into a single buffer, how large it needs to be: + static const int BlockDataSize = cChunkDef::NumBlocks * 2 + (cChunkDef::NumBlocks / 2); // 2.5 * numblocks /// The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column typedef HEIGHTTYPE HeightMap[Width * Width]; -- cgit v1.2.3 From 98e15a34a416c31d4689836f4f38161f1270513c Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 10 Mar 2014 13:18:53 -0700 Subject: Fixed xofts issues --- src/ChunkDef.h | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'src/ChunkDef.h') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index a5059348c..fcda64f5c 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -124,9 +124,7 @@ public: (z < Width) && (z > -1) ) { - return MakeIndexNoCheck(static_cast(x), - static_cast(y), - static_cast(z)); + return MakeIndexNoCheck(x, y, z); } LOGERROR("cChunkDef::MakeIndex(): coords out of range: {%d, %d, %d}; returning fake index 0", x, y, z); ASSERT(!"cChunkDef::MakeIndex(): coords out of chunk range!"); @@ -134,13 +132,13 @@ public: } - inline static unsigned int MakeIndexNoCheck(unsigned int x, unsigned int y, unsigned int z) + inline static unsigned int MakeIndexNoCheck(int x, int y, int z) { #if AXIS_ORDER == AXIS_ORDER_XZY // For some reason, NOT using the Horner schema is faster. Weird. - return x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width); // 1.2 is XZY + return static_cast(x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width)); // 1.2 is XZY #elif AXIS_ORDER == AXIS_ORDER_YZX - return y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width); // 1.1 is YZX + return static_cast(y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width)); // 1.1 is YZX #endif } @@ -168,9 +166,7 @@ public: ASSERT((a_X >= 0) && (a_X < Width)); ASSERT((a_Y >= 0) && (a_Y < Height)); ASSERT((a_Z >= 0) && (a_Z < Width)); - a_BlockTypes[MakeIndexNoCheck(static_cast(a_X), - static_cast(a_Y), - static_cast(a_Z))] = a_Type; + a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)] = a_Type; } @@ -186,9 +182,7 @@ public: ASSERT((a_X >= 0) && (a_X < Width)); ASSERT((a_Y >= 0) && (a_Y < Height)); ASSERT((a_Z >= 0) && (a_Z < Width)); - return a_BlockTypes[MakeIndexNoCheck(static_cast(a_X), - static_cast(a_Y), - static_cast(a_Z))]; + return a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)]; } @@ -246,9 +240,7 @@ public: { if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1)) { - unsigned int Index = MakeIndexNoCheck(static_cast(x), - static_cast(y), - static_cast(z)); + unsigned int Index = MakeIndexNoCheck(x, y, z); return (a_Buffer[Index / 2] >> ((Index & 1) * 4)) & 0x0f; } ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!"); @@ -282,9 +274,7 @@ public: return; } - unsigned int Index = MakeIndexNoCheck(static_cast(x), - static_cast(y), - static_cast(z)); + unsigned int Index = MakeIndexNoCheck(x, y, z); a_Buffer[Index / 2] = static_cast( (a_Buffer[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set -- cgit v1.2.3 From b4bf13aa4f004a7819e262679a295d8ca886557b Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 11 Mar 2014 16:01:17 +0200 Subject: Unified Vector classes --- src/ChunkDef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ChunkDef.h') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 7876c58e7..04a7f5af2 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -9,7 +9,7 @@ #pragma once -#include "Vector3i.h" +#include "Vector3.h" #include "BiomeDef.h" -- cgit v1.2.3 From 80cc824c0cf8634439dfb3913cf17af714b03d99 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 11 Mar 2014 12:41:18 -0700 Subject: Fixed Chunkdef warnings --- src/ChunkDef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ChunkDef.h') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 5dd64e1b5..61ad49ad0 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -112,7 +112,7 @@ public: } - inline static unsigned int MakeIndex(int x, int y, int z ) + inline static int MakeIndex(int x, int y, int z ) { if ( (x < Width) && (x > -1) && @@ -271,7 +271,7 @@ public: } int Index = MakeIndexNoCheck(x, y, z); - a_Buffer[Index / 2] = ( + a_Buffer[Index / 2] = static_cast( (a_Buffer[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set ); -- cgit v1.2.3