1
0

Fixed issues with int vs size_t and a few other warnings

This commit is contained in:
Tycho 2014-03-08 08:33:38 -08:00
parent 9b47366d03
commit 307fad0f25
10 changed files with 26 additions and 28 deletions

View File

@ -42,8 +42,6 @@ cBlockInfo::~cBlockInfo()
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
{
ASSERT(a_Type < 256);
return ms_Info[a_Type];
}

View File

@ -23,6 +23,8 @@ class cBlockHandler
{
public:
cBlockHandler(BLOCKTYPE a_BlockType);
virtual ~cBlockHandler() {}
/// Called when the block gets ticked either by a random tick or by a queued tick.
/// Note that the coords are chunk-relative!

View File

@ -177,15 +177,15 @@ bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count)
CheckValid();
// Store the current free space for a check after writing:
int CurFreeSpace = GetFreeSpace();
int CurReadableSpace = GetReadableSpace();
int WrittenBytes = 0;
size_t CurFreeSpace = GetFreeSpace();
size_t CurReadableSpace = GetReadableSpace();
size_t WrittenBytes = 0;
if (CurFreeSpace < a_Count)
{
return false;
}
int TillEnd = m_BufferSize - m_WritePos;
size_t TillEnd = m_BufferSize - m_WritePos;
if (TillEnd <= a_Count)
{
// Need to wrap around the ringbuffer end
@ -216,7 +216,7 @@ bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count)
int cByteBuffer::GetFreeSpace(void) const
size_t cByteBuffer::GetFreeSpace(void) const
{
CHECK_THREAD;
CheckValid();
@ -234,7 +234,7 @@ int cByteBuffer::GetFreeSpace(void) const
/// Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes()
int cByteBuffer::GetUsedSpace(void) const
size_t cByteBuffer::GetUsedSpace(void) const
{
CHECK_THREAD;
CheckValid();
@ -246,7 +246,7 @@ int cByteBuffer::GetUsedSpace(void) const
/// Returns the number of bytes that are currently available for reading (may be less than UsedSpace due to some data having been read already)
int cByteBuffer::GetReadableSpace(void) const
size_t cByteBuffer::GetReadableSpace(void) const
{
CHECK_THREAD;
CheckValid();
@ -657,7 +657,7 @@ bool cByteBuffer::ReadBuf(void * a_Buffer, size_t a_Count)
ASSERT(a_Count >= 0);
NEEDBYTES(a_Count);
char * Dst = (char *)a_Buffer; // So that we can do byte math
int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
size_t BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
if (BytesToEndOfBuffer <= a_Count)
{
@ -691,7 +691,7 @@ bool cByteBuffer::WriteBuf(const void * a_Buffer, size_t a_Count)
ASSERT(a_Count >= 0);
PUTBYTES(a_Count);
char * Src = (char *)a_Buffer; // So that we can do byte math
int BytesToEndOfBuffer = m_BufferSize - m_WritePos;
size_t BytesToEndOfBuffer = m_BufferSize - m_WritePos;
if (BytesToEndOfBuffer <= a_Count)
{
// Reading across the ringbuffer end, read the first part and adjust parameters:
@ -722,7 +722,7 @@ bool cByteBuffer::ReadString(AString & a_String, size_t a_Count)
NEEDBYTES(a_Count);
a_String.clear();
a_String.reserve(a_Count);
int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
size_t BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
if (BytesToEndOfBuffer <= a_Count)
{

View File

@ -34,13 +34,13 @@ public:
bool Write(const char * a_Bytes, size_t a_Count);
/// Returns the number of bytes that can be successfully written to the ringbuffer
int GetFreeSpace(void) const;
size_t GetFreeSpace(void) const;
/// Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes()
int GetUsedSpace(void) const;
size_t GetUsedSpace(void) const;
/// Returns the number of bytes that are currently available for reading (may be less than UsedSpace due to some data having been read already)
int GetReadableSpace(void) const;
size_t GetReadableSpace(void) const;
/// Returns the current data start index. For debugging purposes.
int GetDataStart(void) const { return m_DataStart; }

View File

@ -96,8 +96,8 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
m_ShouldCheckDownloaded(false),
m_NumExplosionsThisTick(0),
m_UniqueID(0),
m_Locale("en_GB"),
m_HasSentPlayerChunk(false)
m_HasSentPlayerChunk(false),
m_Locale("en_GB")
{
m_Protocol = new cProtocolRecognizer(this);

View File

@ -1031,9 +1031,9 @@ cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
void cMinecartWithChest::SetSlot(int a_Idx, const cItem & a_Item)
void cMinecartWithChest::SetSlot(size_t a_Idx, const cItem & a_Item)
{
ASSERT((a_Idx >= 0) && (a_Idx < ARRAYCOUNT(m_Items)));
ASSERT(a_Idx < ARRAYCOUNT(m_Items));
m_Items[a_Idx] = a_Item;
}

View File

@ -122,7 +122,7 @@ public:
const cItem & GetSlot(int a_Idx) const { return m_Items[a_Idx]; }
cItem & GetSlot(int a_Idx) { return m_Items[a_Idx]; }
void SetSlot(int a_Idx, const cItem & a_Item);
void SetSlot(size_t a_Idx, const cItem & a_Item);
protected:
@ -193,4 +193,4 @@ public:
CLASS_PROTODEF(cMinecartWithHopper);
cMinecartWithHopper(double a_X, double a_Y, double a_Z);
} ;
} ;

View File

@ -1244,7 +1244,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
if (m_ReceivedData.GetReadableSpace() > 0)
{
AString AllData;
int OldReadableSpace = m_ReceivedData.GetReadableSpace();
size_t OldReadableSpace = m_ReceivedData.GetReadableSpace();
m_ReceivedData.ReadAll(AllData);
m_ReceivedData.ResetRead();
m_ReceivedData.SkipRead(m_ReceivedData.GetReadableSpace() - OldReadableSpace);
@ -1366,7 +1366,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
if (g_ShouldLogCommIn && (m_ReceivedData.GetReadableSpace() > 0))
{
AString AllData;
int OldReadableSpace = m_ReceivedData.GetReadableSpace();
size_t OldReadableSpace = m_ReceivedData.GetReadableSpace();
m_ReceivedData.ReadAll(AllData);
m_ReceivedData.ResetRead();
m_ReceivedData.SkipRead(m_ReceivedData.GetReadableSpace() - OldReadableSpace);

View File

@ -593,7 +593,6 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
unsigned m_NameLength;
const AString m_PlayerName;
cPlayerListCallback & m_Callback;
virtual bool Item (cPlayer * a_pPlayer)
{
unsigned int Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName());
@ -615,18 +614,17 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
}
public:
cCallback (const AString & a_PlayerName, cPlayerListCallback & a_Callback) :
cCallback (const AString & a_PlayerName) :
m_BestRating(0),
m_NameLength(a_PlayerName.length()),
m_PlayerName(a_PlayerName),
m_Callback(a_Callback),
m_BestMatch(NULL),
m_NumMatches(0)
{}
cPlayer * m_BestMatch;
unsigned m_NumMatches;
} Callback (a_PlayerName, a_Callback);
} Callback (a_PlayerName);
ForEachPlayer( Callback );
if (Callback.m_NumMatches == 1)

View File

@ -20,7 +20,7 @@
bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ)
{
ASSERT(a_RelZ >= 0);
ASSERT(a_RelZ < ARRAYCOUNT(m_Blocks));
ASSERT(a_RelZ < static_cast<int>(ARRAYCOUNT(m_Blocks)));
cCoordWithIntVector & Blocks = m_Blocks[a_RelZ];
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);