1
0
Fork 0

Merged branch 'master' into SslWebAdmin.

This commit is contained in:
madmaxoft 2014-05-01 23:20:00 +02:00
commit 6bdd3ee35e
17 changed files with 34 additions and 31 deletions

View File

@ -2005,7 +2005,7 @@ void cBlockArea::ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, i
int NewSizeX = m_Size.x + a_SubMinX + a_AddMaxX;
int NewSizeY = m_Size.y + a_SubMinY + a_AddMaxY;
int NewSizeZ = m_Size.z + a_SubMinZ + a_AddMaxZ;
size_t BlockCount = (size_t)NewSizeX * NewSizeY * NewSizeZ;
size_t BlockCount = (size_t)(NewSizeX * NewSizeY * NewSizeZ);
BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[BlockCount];
memset(NewBlockTypes, 0, BlockCount * sizeof(BLOCKTYPE));
int OldIndex = 0;
@ -2035,7 +2035,7 @@ void cBlockArea::ExpandNibbles(NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMa
int NewSizeX = m_Size.x + a_SubMinX + a_AddMaxX;
int NewSizeY = m_Size.y + a_SubMinY + a_AddMaxY;
int NewSizeZ = m_Size.z + a_SubMinZ + a_AddMaxZ;
size_t BlockCount = (size_t)NewSizeX * NewSizeY * NewSizeZ;
size_t BlockCount = (size_t)(NewSizeX * NewSizeY * NewSizeZ);
NIBBLETYPE * NewNibbles = new NIBBLETYPE[BlockCount];
memset(NewNibbles, 0, BlockCount * sizeof(NIBBLETYPE));
int OldIndex = 0;

View File

@ -294,7 +294,7 @@ public:
NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block!
NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block!
NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight; } // NOTE: one byte per block!
size_t GetBlockCount(void) const { return m_Size.x * m_Size.y * m_Size.z; }
size_t GetBlockCount(void) const { return (size_t)(m_Size.x * m_Size.y * m_Size.z); }
int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const;
protected:

View File

@ -102,7 +102,7 @@ public:
return true;
}
a_Item.m_ItemDamage = atoi(Split[1].c_str());
a_Item.m_ItemDamage = (short)atoi(Split[1].c_str());
if ((a_Item.m_ItemDamage == 0) && (Split[1] != "0"))
{
// Parsing the number failed

View File

@ -327,7 +327,7 @@ bool cByteBuffer::ReadBEShort(short & a_Value)
CheckValid();
NEEDBYTES(2);
ReadBuf(&a_Value, 2);
a_Value = ntohs(a_Value);
a_Value = (short)ntohs((u_short)a_Value);
return true;
}
@ -341,7 +341,7 @@ bool cByteBuffer::ReadBEInt(int & a_Value)
CheckValid();
NEEDBYTES(4);
ReadBuf(&a_Value, 4);
a_Value = ntohl(a_Value);
a_Value = (int)ntohl((u_long)a_Value);
return true;
}
@ -420,7 +420,7 @@ bool cByteBuffer::ReadBEUTF16String16(AString & a_Value)
ASSERT(!"Negative string length? Are you sure?");
return true;
}
return ReadUTF16String(a_Value, Length);
return ReadUTF16String(a_Value, (size_t)Length);
}
@ -438,7 +438,7 @@ bool cByteBuffer::ReadVarInt(UInt32 & a_Value)
{
NEEDBYTES(1);
ReadBuf(&b, 1);
Value = Value | (((Int64)(b & 0x7f)) << Shift);
Value = Value | (((UInt32)(b & 0x7f)) << Shift);
Shift += 7;
} while ((b & 0x80) != 0);
a_Value = Value;
@ -462,7 +462,7 @@ bool cByteBuffer::ReadVarUTF8String(AString & a_Value)
{
LOGWARNING("%s: String too large: %u (%u KiB)", __FUNCTION__, Size, Size / 1024);
}
return ReadString(a_Value, (int)Size);
return ReadString(a_Value, (size_t)Size);
}
@ -517,7 +517,7 @@ bool cByteBuffer::WriteBEShort(short a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(2);
short Converted = htons(a_Value);
u_short Converted = htons((u_short)a_Value);
return WriteBuf(&Converted, 2);
}
@ -530,7 +530,7 @@ bool cByteBuffer::WriteBEInt(int a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(4);
int Converted = HostToNetwork4(&a_Value);
UInt32 Converted = HostToNetwork4(&a_Value);
return WriteBuf(&Converted, 4);
}
@ -543,7 +543,7 @@ bool cByteBuffer::WriteBEInt64(Int64 a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(8);
Int64 Converted = HostToNetwork8(&a_Value);
UInt64 Converted = HostToNetwork8(&a_Value);
return WriteBuf(&Converted, 8);
}
@ -556,7 +556,7 @@ bool cByteBuffer::WriteBEFloat(float a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(4);
int Converted = HostToNetwork4(&a_Value);
UInt32 Converted = HostToNetwork4(&a_Value);
return WriteBuf(&Converted, 4);
}
@ -569,7 +569,7 @@ bool cByteBuffer::WriteBEDouble(double a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(8);
Int64 Converted = HostToNetwork8(&a_Value);
UInt64 Converted = HostToNetwork8(&a_Value);
return WriteBuf(&Converted, 8);
}
@ -613,7 +613,7 @@ bool cByteBuffer::WriteVarInt(UInt32 a_Value)
// A 32-bit integer can be encoded by at most 5 bytes:
unsigned char b[5];
int idx = 0;
size_t idx = 0;
do
{
b[idx] = (a_Value & 0x7f) | ((a_Value > 0x7f) ? 0x80 : 0x00);
@ -632,7 +632,7 @@ bool cByteBuffer::WriteVarUTF8String(const AString & a_Value)
CHECK_THREAD;
CheckValid();
PUTBYTES(a_Value.size() + 1); // This is a lower-bound on the bytes that will be actually written. Fail early.
bool res = WriteVarInt(a_Value.size());
bool res = WriteVarInt((UInt32)(a_Value.size()));
if (!res)
{
return false;
@ -757,7 +757,7 @@ bool cByteBuffer::ReadString(AString & a_String, size_t a_Count)
bool cByteBuffer::ReadUTF16String(AString & a_String, int a_NumChars)
bool cByteBuffer::ReadUTF16String(AString & a_String, size_t a_NumChars)
{
// Reads 2 * a_NumChars bytes and interprets it as a UTF16 string, converting it into UTF8 string a_String
CHECK_THREAD;

View File

@ -101,7 +101,7 @@ public:
bool ReadString(AString & a_String, size_t a_Count);
/** Reads 2 * a_NumChars bytes and interprets it as a UTF16-BE string, converting it into UTF8 string a_String */
bool ReadUTF16String(AString & a_String, int a_NumChars);
bool ReadUTF16String(AString & a_String, size_t a_NumChars);
/** Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer */
bool SkipRead(size_t a_Count);

View File

@ -716,7 +716,7 @@ void cClientHandle::UnregisterPluginChannels(const AStringVector & a_ChannelList
void cClientHandle::HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length)
void cClientHandle::HandleCommandBlockMessage(const char * a_Data, size_t a_Length)
{
if (a_Length < 14)
{
@ -1658,7 +1658,7 @@ void cClientHandle::SendData(const char * a_Data, size_t a_Size)
{
// There is a queued overflow. Append to it, then send as much from its front as possible
m_OutgoingDataOverflow.append(a_Data, a_Size);
int CanFit = m_OutgoingData.GetFreeSpace();
size_t CanFit = m_OutgoingData.GetFreeSpace();
if (CanFit > 128)
{
// No point in moving the data over if it's not large enough - too much effort for too little an effect

View File

@ -384,7 +384,7 @@ private:
void UnregisterPluginChannels(const AStringVector & a_ChannelList);
/** Handles the "MC|AdvCdm" plugin message */
void HandleCommandBlockMessage(const char * a_Data, unsigned int a_Length);
void HandleCommandBlockMessage(const char * a_Data, size_t a_Length);
// cSocketThreads::cCallback overrides:
virtual bool DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client

View File

@ -280,7 +280,7 @@ NOISE_DATATYPE cNoise::CubicInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B,
NOISE_DATATYPE cNoise::CosineInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, NOISE_DATATYPE a_Pct)
{
const NOISE_DATATYPE ft = a_Pct * (NOISE_DATATYPE)3.1415927;
const NOISE_DATATYPE f = (1 - cos(ft)) * (NOISE_DATATYPE)0.5;
const NOISE_DATATYPE f = (NOISE_DATATYPE)((NOISE_DATATYPE)(1 - cos(ft)) * (NOISE_DATATYPE)0.5);
return a_A * (1 - f) + a_B * f;
}

View File

@ -23,6 +23,9 @@ public:
class cDataCallbacks
{
public:
// Force a virtual destructor in descendants:
virtual ~cDataCallbacks() {}
/** Called when PolarSSL wants to read encrypted data from the SSL peer.
The returned value is the number of bytes received, or a PolarSSL error on failure.
The implementation can return POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE to indicate

View File

@ -123,7 +123,7 @@ public:
virtual void SendWholeInventory (const cWindow & a_Window) = 0;
virtual void SendWindowClose (const cWindow & a_Window) = 0;
virtual void SendWindowOpen (const cWindow & a_Window) = 0;
virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) = 0;
virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) = 0;
/// Returns the ServerID used for authentication through session.minecraft.net
virtual AString GetAuthServerID(void) = 0;

View File

@ -1175,7 +1175,7 @@ void cProtocol125::SendWindowOpen(const cWindow & a_Window)
void cProtocol125::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
void cProtocol125::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value)
{
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_WINDOW_PROPERTY);

View File

@ -96,7 +96,7 @@ public:
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override;
virtual AString GetAuthServerID(void) override;

View File

@ -1383,7 +1383,7 @@ void cProtocol172::SendWindowOpen(const cWindow & a_Window)
void cProtocol172::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
void cProtocol172::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value)
{
ASSERT(m_State == 3); // In game mode?

View File

@ -128,7 +128,7 @@ public:
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override;
virtual AString GetAuthServerID(void) override { return m_AuthServerID; }

View File

@ -357,7 +357,7 @@ void cProtocolRecognizer::SendHealth(void)
void cProtocolRecognizer::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
void cProtocolRecognizer::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value)
{
ASSERT(m_Protocol != NULL);
m_Protocol->SendWindowProperty(a_Window, a_Property, a_Value);

View File

@ -131,7 +131,7 @@ public:
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override;
virtual AString GetAuthServerID(void) override;

View File

@ -237,7 +237,7 @@ public:
{
ASSERT(m_Tags[(size_t)a_Tag].m_Type == TAG_String);
AString res;
res.assign(m_Data + m_Tags[(size_t)a_Tag].m_DataStart, m_Tags[(size_t)a_Tag].m_DataLength);
res.assign(m_Data + m_Tags[(size_t)a_Tag].m_DataStart, (size_t)m_Tags[(size_t)a_Tag].m_DataLength);
return res;
}
@ -245,7 +245,7 @@ public:
inline AString GetName(int a_Tag) const
{
AString res;
res.assign(m_Data + m_Tags[(size_t)a_Tag].m_NameStart, m_Tags[(size_t)a_Tag].m_NameLength);
res.assign(m_Data + m_Tags[(size_t)a_Tag].m_NameStart, (size_t)m_Tags[(size_t)a_Tag].m_NameLength);
return res;
}