Fixed issues with int vs size_t and a few other warnings
This commit is contained in:
parent
9b47366d03
commit
307fad0f25
@ -42,8 +42,6 @@ cBlockInfo::~cBlockInfo()
|
|||||||
|
|
||||||
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
|
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
|
||||||
{
|
{
|
||||||
ASSERT(a_Type < 256);
|
|
||||||
|
|
||||||
return ms_Info[a_Type];
|
return ms_Info[a_Type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ class cBlockHandler
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cBlockHandler(BLOCKTYPE a_BlockType);
|
cBlockHandler(BLOCKTYPE a_BlockType);
|
||||||
|
|
||||||
|
virtual ~cBlockHandler() {}
|
||||||
|
|
||||||
/// Called when the block gets ticked either by a random tick or by a queued tick.
|
/// Called when the block gets ticked either by a random tick or by a queued tick.
|
||||||
/// Note that the coords are chunk-relative!
|
/// Note that the coords are chunk-relative!
|
||||||
|
@ -177,15 +177,15 @@ bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count)
|
|||||||
CheckValid();
|
CheckValid();
|
||||||
|
|
||||||
// Store the current free space for a check after writing:
|
// Store the current free space for a check after writing:
|
||||||
int CurFreeSpace = GetFreeSpace();
|
size_t CurFreeSpace = GetFreeSpace();
|
||||||
int CurReadableSpace = GetReadableSpace();
|
size_t CurReadableSpace = GetReadableSpace();
|
||||||
int WrittenBytes = 0;
|
size_t WrittenBytes = 0;
|
||||||
|
|
||||||
if (CurFreeSpace < a_Count)
|
if (CurFreeSpace < a_Count)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int TillEnd = m_BufferSize - m_WritePos;
|
size_t TillEnd = m_BufferSize - m_WritePos;
|
||||||
if (TillEnd <= a_Count)
|
if (TillEnd <= a_Count)
|
||||||
{
|
{
|
||||||
// Need to wrap around the ringbuffer end
|
// 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;
|
CHECK_THREAD;
|
||||||
CheckValid();
|
CheckValid();
|
||||||
@ -234,7 +234,7 @@ int cByteBuffer::GetFreeSpace(void) const
|
|||||||
|
|
||||||
|
|
||||||
/// Returns the number of bytes that are currently in the ringbuffer. Note GetReadableBytes()
|
/// 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;
|
CHECK_THREAD;
|
||||||
CheckValid();
|
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)
|
/// 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;
|
CHECK_THREAD;
|
||||||
CheckValid();
|
CheckValid();
|
||||||
@ -657,7 +657,7 @@ bool cByteBuffer::ReadBuf(void * a_Buffer, size_t a_Count)
|
|||||||
ASSERT(a_Count >= 0);
|
ASSERT(a_Count >= 0);
|
||||||
NEEDBYTES(a_Count);
|
NEEDBYTES(a_Count);
|
||||||
char * Dst = (char *)a_Buffer; // So that we can do byte math
|
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
|
ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
|
||||||
if (BytesToEndOfBuffer <= a_Count)
|
if (BytesToEndOfBuffer <= a_Count)
|
||||||
{
|
{
|
||||||
@ -691,7 +691,7 @@ bool cByteBuffer::WriteBuf(const void * a_Buffer, size_t a_Count)
|
|||||||
ASSERT(a_Count >= 0);
|
ASSERT(a_Count >= 0);
|
||||||
PUTBYTES(a_Count);
|
PUTBYTES(a_Count);
|
||||||
char * Src = (char *)a_Buffer; // So that we can do byte math
|
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)
|
if (BytesToEndOfBuffer <= a_Count)
|
||||||
{
|
{
|
||||||
// Reading across the ringbuffer end, read the first part and adjust parameters:
|
// 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);
|
NEEDBYTES(a_Count);
|
||||||
a_String.clear();
|
a_String.clear();
|
||||||
a_String.reserve(a_Count);
|
a_String.reserve(a_Count);
|
||||||
int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
|
size_t BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
|
||||||
ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
|
ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
|
||||||
if (BytesToEndOfBuffer <= a_Count)
|
if (BytesToEndOfBuffer <= a_Count)
|
||||||
{
|
{
|
||||||
|
@ -34,13 +34,13 @@ public:
|
|||||||
bool Write(const char * a_Bytes, size_t a_Count);
|
bool Write(const char * a_Bytes, size_t a_Count);
|
||||||
|
|
||||||
/// Returns the number of bytes that can be successfully written to the ringbuffer
|
/// 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()
|
/// 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)
|
/// 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.
|
/// Returns the current data start index. For debugging purposes.
|
||||||
int GetDataStart(void) const { return m_DataStart; }
|
int GetDataStart(void) const { return m_DataStart; }
|
||||||
|
@ -96,8 +96,8 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
|
|||||||
m_ShouldCheckDownloaded(false),
|
m_ShouldCheckDownloaded(false),
|
||||||
m_NumExplosionsThisTick(0),
|
m_NumExplosionsThisTick(0),
|
||||||
m_UniqueID(0),
|
m_UniqueID(0),
|
||||||
m_Locale("en_GB"),
|
m_HasSentPlayerChunk(false),
|
||||||
m_HasSentPlayerChunk(false)
|
m_Locale("en_GB")
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocolRecognizer(this);
|
m_Protocol = new cProtocolRecognizer(this);
|
||||||
|
|
||||||
|
@ -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;
|
m_Items[a_Idx] = a_Item;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public:
|
|||||||
const cItem & GetSlot(int a_Idx) const { return m_Items[a_Idx]; }
|
const cItem & GetSlot(int a_Idx) const { return m_Items[a_Idx]; }
|
||||||
cItem & GetSlot(int a_Idx) { 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:
|
protected:
|
||||||
|
|
||||||
@ -193,4 +193,4 @@ public:
|
|||||||
CLASS_PROTODEF(cMinecartWithHopper);
|
CLASS_PROTODEF(cMinecartWithHopper);
|
||||||
|
|
||||||
cMinecartWithHopper(double a_X, double a_Y, double a_Z);
|
cMinecartWithHopper(double a_X, double a_Y, double a_Z);
|
||||||
} ;
|
} ;
|
||||||
|
@ -1244,7 +1244,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
|
|||||||
if (m_ReceivedData.GetReadableSpace() > 0)
|
if (m_ReceivedData.GetReadableSpace() > 0)
|
||||||
{
|
{
|
||||||
AString AllData;
|
AString AllData;
|
||||||
int OldReadableSpace = m_ReceivedData.GetReadableSpace();
|
size_t OldReadableSpace = m_ReceivedData.GetReadableSpace();
|
||||||
m_ReceivedData.ReadAll(AllData);
|
m_ReceivedData.ReadAll(AllData);
|
||||||
m_ReceivedData.ResetRead();
|
m_ReceivedData.ResetRead();
|
||||||
m_ReceivedData.SkipRead(m_ReceivedData.GetReadableSpace() - OldReadableSpace);
|
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))
|
if (g_ShouldLogCommIn && (m_ReceivedData.GetReadableSpace() > 0))
|
||||||
{
|
{
|
||||||
AString AllData;
|
AString AllData;
|
||||||
int OldReadableSpace = m_ReceivedData.GetReadableSpace();
|
size_t OldReadableSpace = m_ReceivedData.GetReadableSpace();
|
||||||
m_ReceivedData.ReadAll(AllData);
|
m_ReceivedData.ReadAll(AllData);
|
||||||
m_ReceivedData.ResetRead();
|
m_ReceivedData.ResetRead();
|
||||||
m_ReceivedData.SkipRead(m_ReceivedData.GetReadableSpace() - OldReadableSpace);
|
m_ReceivedData.SkipRead(m_ReceivedData.GetReadableSpace() - OldReadableSpace);
|
||||||
|
@ -593,7 +593,6 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
|
|||||||
unsigned m_NameLength;
|
unsigned m_NameLength;
|
||||||
const AString m_PlayerName;
|
const AString m_PlayerName;
|
||||||
|
|
||||||
cPlayerListCallback & m_Callback;
|
|
||||||
virtual bool Item (cPlayer * a_pPlayer)
|
virtual bool Item (cPlayer * a_pPlayer)
|
||||||
{
|
{
|
||||||
unsigned int Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName());
|
unsigned int Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName());
|
||||||
@ -615,18 +614,17 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cCallback (const AString & a_PlayerName, cPlayerListCallback & a_Callback) :
|
cCallback (const AString & a_PlayerName) :
|
||||||
m_BestRating(0),
|
m_BestRating(0),
|
||||||
m_NameLength(a_PlayerName.length()),
|
m_NameLength(a_PlayerName.length()),
|
||||||
m_PlayerName(a_PlayerName),
|
m_PlayerName(a_PlayerName),
|
||||||
m_Callback(a_Callback),
|
|
||||||
m_BestMatch(NULL),
|
m_BestMatch(NULL),
|
||||||
m_NumMatches(0)
|
m_NumMatches(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
cPlayer * m_BestMatch;
|
cPlayer * m_BestMatch;
|
||||||
unsigned m_NumMatches;
|
unsigned m_NumMatches;
|
||||||
} Callback (a_PlayerName, a_Callback);
|
} Callback (a_PlayerName);
|
||||||
ForEachPlayer( Callback );
|
ForEachPlayer( Callback );
|
||||||
|
|
||||||
if (Callback.m_NumMatches == 1)
|
if (Callback.m_NumMatches == 1)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ)
|
bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ)
|
||||||
{
|
{
|
||||||
ASSERT(a_RelZ >= 0);
|
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];
|
cCoordWithIntVector & Blocks = m_Blocks[a_RelZ];
|
||||||
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
|
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
|
||||||
|
Loading…
Reference in New Issue
Block a user