1
0

Fixed MSVC 64-bit build warnings.

This commit is contained in:
Mattes D 2014-05-08 20:16:35 +02:00
parent 17c7c31130
commit fb58ef55be
47 changed files with 178 additions and 161 deletions

View File

@ -243,7 +243,7 @@ int cIniFile::FindKey(const AString & a_KeyName) const
{
if (CheckCase(names[keyID]) == CaseKeyName)
{
return keyID;
return (int)keyID;
}
}
return noID;
@ -279,7 +279,7 @@ int cIniFile::AddKeyName(const AString & keyname)
{
names.resize(names.size() + 1, keyname);
keys.resize(keys.size() + 1);
return names.size() - 1;
return (int)names.size() - 1;
}
@ -683,7 +683,7 @@ int cIniFile::GetNumKeyComments(const int keyID) const
{
if (keyID < (int)keys.size())
{
return keys[keyID].comments.size();
return (int)keys[keyID].comments.size();
}
return 0;
}

View File

@ -143,13 +143,14 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
}
}
if (GetNumPlugins() == 0)
size_t NumLoadedPlugins = GetNumPlugins();
if (NumLoadedPlugins)
{
LOG("-- No Plugins Loaded --");
}
else if (GetNumPlugins() > 1)
else if (NumLoadedPlugins > 1)
{
LOG("-- Loaded %i Plugins --", GetNumPlugins());
LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
}
else
{
@ -1869,7 +1870,7 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook)
unsigned int cPluginManager::GetNumPlugins() const
size_t cPluginManager::GetNumPlugins() const
{
return m_Plugins.size();
}

View File

@ -159,7 +159,7 @@ public: // tolua_export
/** Adds the plugin to the list of plugins called for the specified hook type. Handles multiple adds as a single add */
void AddHook(cPlugin * a_Plugin, int a_HookType);
unsigned int GetNumPlugins() const; // tolua_export
size_t GetNumPlugins() const; // tolua_export
// Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort
bool CallHookBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source);

View File

@ -738,31 +738,31 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block
a_DataTypes = a_DataTypes & GetDataTypes();
}
int BlockCount = GetBlockCount();
size_t BlockCount = GetBlockCount();
if ((a_DataTypes & baTypes) != 0)
{
for (int i = 0; i < BlockCount; i++)
for (size_t i = 0; i < BlockCount; i++)
{
m_BlockTypes[i] = a_BlockType;
}
}
if ((a_DataTypes & baMetas) != 0)
{
for (int i = 0; i < BlockCount; i++)
for (size_t i = 0; i < BlockCount; i++)
{
m_BlockMetas[i] = a_BlockMeta;
}
}
if ((a_DataTypes & baLight) != 0)
{
for (int i = 0; i < BlockCount; i++)
for (size_t i = 0; i < BlockCount; i++)
{
m_BlockLight[i] = a_BlockLight;
}
}
if ((a_DataTypes & baSkyLight) != 0)
{
for (int i = 0; i < BlockCount; i++)
for (size_t i = 0; i < BlockCount; i++)
{
m_BlockSkyLight[i] = a_BlockSkyLight;
}

View File

@ -52,9 +52,9 @@ public:
return;
}
int NumBlocks = Area.GetBlockCount();
size_t NumBlocks = Area.GetBlockCount();
BLOCKTYPE * BlockTypes = Area.GetBlockTypes();
for (int i = 0; i < NumBlocks; i++)
for (size_t i = 0; i < NumBlocks; i++)
{
if (
(BlockTypes[i] == E_BLOCK_WATER) ||

View File

@ -138,14 +138,14 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ)
{
// Filter the blocks into a {leaves, log, other (air)} set:
BLOCKTYPE * Types = a_Area.GetBlockTypes();
for (int i = a_Area.GetBlockCount() - 1; i > 0; i--)
for (size_t i = a_Area.GetBlockCount() - 1; i > 0; i--)
{
switch (Types[i])
{
case E_BLOCK_NEW_LEAVES:
case E_BLOCK_NEW_LOG:
case E_BLOCK_LEAVES:
case E_BLOCK_LOG:
case E_BLOCK_NEW_LEAVES:
case E_BLOCK_NEW_LOG:
{
break;
}

View File

@ -100,7 +100,7 @@ public:
virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
{
return (a_Meta & 0x8);
return ((a_Meta & 0x8) != 0);
}

View File

@ -239,9 +239,15 @@ void cCaveTunnel::Randomize(cNoise & a_Noise)
bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst)
{
if (a_Src.size() < 2)
{
// There are no midpoints, nothing to smooth
return true;
}
// Smoothing: for each line segment, add points on its 1/4 lengths
bool res = false;
int Num = a_Src.size() - 2; // this many intermediary points
size_t Num = a_Src.size() - 2; // this many intermediary points
a_Dst.clear();
a_Dst.reserve(Num * 2 + 2);
cCaveDefPoints::const_iterator itr = a_Src.begin() + 1;
@ -251,7 +257,7 @@ bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints &
int PrevY = Source.m_BlockY;
int PrevZ = Source.m_BlockZ;
int PrevR = Source.m_Radius;
for (int i = 0; i <= Num; ++i, ++itr)
for (size_t i = 0; i <= Num; ++i, ++itr)
{
int dx = itr->m_BlockX - PrevX;
int dy = itr->m_BlockY - PrevY;

View File

@ -543,7 +543,7 @@ cMineShaft * cMineShaftCorridor::CreateAndFit(
{
cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ);
BoundingBox.p2.y += 3;
int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
int NumSegments = 2 + (rnd) % (MAX_SEGMENTS - 1); // 2 .. MAX_SEGMENTS
switch (a_Direction)
{
@ -985,7 +985,7 @@ cMineShaft * cMineShaftCrossing::CreateAndFit(
)
{
cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ);
int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
BoundingBox.p2.y += 3;
if ((rnd % 4) < 2)
{
@ -1127,7 +1127,7 @@ cMineShaft * cMineShaftStaircase::CreateAndFit(
cNoise & a_Noise
)
{
int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
cCuboid Box;
switch (a_Direction)
{

View File

@ -339,9 +339,9 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i
int NumRotations = 1;
for (size_t i = 1; i < ARRAYCOUNT(Rotations); i++)
{
if (StartingPiece->CanRotateCCW(i))
if (StartingPiece->CanRotateCCW((int)i))
{
Rotations[NumRotations] = i;
Rotations[NumRotations] = (int)i;
NumRotations += 1;
}
}

View File

@ -306,8 +306,14 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block
void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst)
{
if (a_Src.size() < 2)
{
// No midpoints, nothing to refine
return;
}
// Smoothing: for each line segment, add points on its 1/4 lengths
int Num = a_Src.size() - 2; // this many intermediary points
size_t Num = a_Src.size() - 2; // this many intermediary points
a_Dst.clear();
a_Dst.reserve(Num * 2 + 2);
cRavDefPoints::const_iterator itr = a_Src.begin() + 1;
@ -318,7 +324,7 @@ void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cR
int PrevR = Source.m_Radius;
int PrevT = Source.m_Top;
int PrevB = Source.m_Bottom;
for (int i = 0; i <= Num; ++i, ++itr)
for (size_t i = 0; i <= Num; ++i, ++itr)
{
int dx = itr->m_BlockX - PrevX;
int dz = itr->m_BlockZ - PrevZ;

View File

@ -136,7 +136,7 @@ inline void PushSomeColumns(int a_BlockX, int a_Height, int a_BlockZ, int a_Colu
{
int x = a_BlockX + a_Coords[i].x;
int z = a_BlockZ + a_Coords[i].z;
if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + i, z + 64 * a_Seq) <= a_Chance)
if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + (int)i, z + 64 * a_Seq) <= a_Chance)
{
for (int j = 0; j < a_ColumnHeight; j++)
{

View File

@ -79,23 +79,24 @@ void cGroupManager::CheckUsers(void)
return;
}
unsigned int NumKeys = IniFile.GetNumKeys();
for (size_t i = 0; i < NumKeys; i++)
int NumKeys = IniFile.GetNumKeys();
for (int i = 0; i < NumKeys; i++)
{
AString Player = IniFile.GetKeyName( i );
AString Player = IniFile.GetKeyName(i);
AString Groups = IniFile.GetValue(Player, "Groups", "");
if (!Groups.empty())
if (Groups.empty())
{
AStringVector Split = StringSplit( Groups, "," );
for( unsigned int i = 0; i < Split.size(); i++ )
{
if (!ExistsGroup(Split[i]))
{
LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str());
}
}
continue;
}
}
AStringVector Split = StringSplitAndTrim(Groups, ",");
for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
{
if (!ExistsGroup(*itr))
{
LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str());
}
} // for itr - Split[]
} // for i - ini file keys
}
@ -128,15 +129,15 @@ void cGroupManager::LoadGroups()
IniFile.WriteFile("groups.ini");
}
unsigned int NumKeys = IniFile.GetNumKeys();
for (size_t i = 0; i < NumKeys; i++)
int NumKeys = IniFile.GetNumKeys();
for (int i = 0; i < NumKeys; i++)
{
AString KeyName = IniFile.GetKeyName( i );
cGroup* Group = GetGroup( KeyName.c_str() );
AString KeyName = IniFile.GetKeyName(i);
cGroup * Group = GetGroup(KeyName.c_str());
Group->ClearPermission(); // Needed in case the groups are reloaded.
LOGD("Loading group: %s", KeyName.c_str() );
LOGD("Loading group %s", KeyName.c_str());
Group->SetName(KeyName);
AString Color = IniFile.GetValue(KeyName, "Color", "-");

View File

@ -97,7 +97,7 @@ void cNameValueParser::Parse(const char * a_Data, size_t a_Size)
{
ASSERT(m_State != psFinished); // Calling Parse() after Finish() is wrong!
int Last = 0;
size_t Last = 0;
for (size_t i = 0; i < a_Size;)
{
switch (m_State)

View File

@ -614,7 +614,7 @@ unsigned int cMap::GetNumPixels(void) const
unsigned int cMap::GetNumDecorators(void) const
size_t cMap::GetNumDecorators(void) const
{
return m_Decorators.size();
}

View File

@ -181,7 +181,7 @@ public:
// tolua_end
unsigned int GetNumDecorators(void) const;
size_t GetNumDecorators(void) const;
const cColorList & GetData(void) const { return m_Data; }

View File

@ -86,7 +86,7 @@ cMap * cMapManager::CreateMap(int a_CenterX, int a_CenterY, int a_Scale)
return NULL;
}
cMap Map(m_MapData.size(), a_CenterX, a_CenterY, m_World, a_Scale);
cMap Map((unsigned)m_MapData.size(), a_CenterX, a_CenterY, m_World, a_Scale);
m_MapData.push_back(Map);
@ -97,7 +97,7 @@ cMap * cMapManager::CreateMap(int a_CenterX, int a_CenterY, int a_Scale)
unsigned int cMapManager::GetNumMaps(void) const
size_t cMapManager::GetNumMaps(void) const
{
return m_MapData.size();
}
@ -151,7 +151,7 @@ void cMapManager::SaveMapData(void)
cIDCountSerializer IDSerializer(m_World->GetName());
IDSerializer.SetMapCount(m_MapData.size());
IDSerializer.SetMapCount((unsigned)m_MapData.size());
if (!IDSerializer.Save())
{

View File

@ -53,7 +53,7 @@ public:
*/
bool ForEachMap(cMapCallback & a_Callback);
unsigned int GetNumMaps(void) const; // tolua_export
size_t GetNumMaps(void) const; // tolua_export
/** Loads the map data from the disk */
void LoadMapData(void);

View File

@ -64,7 +64,7 @@ void cMobCensus::CollectSpawnableChunk(cChunk & a_Chunk)
int cMobCensus::GetNumChunks(void)
{
return m_EligibleForSpawnChunks.size();
return (int)m_EligibleForSpawnChunks.size();
}

View File

@ -18,7 +18,7 @@ void cMobFamilyCollecter::CollectMob(cMonster & a_Monster)
int cMobFamilyCollecter::GetNumberOfCollectedMobs(cMonster::eFamily a_Family)
{
return m_Mobs[a_Family].size();
return (int)m_Mobs[a_Family].size();
}

View File

@ -104,13 +104,13 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
}
}
int allowedMobsSize = allowedMobs.size();
size_t allowedMobsSize = allowedMobs.size();
if (allowedMobsSize > 0)
{
std::set<cMonster::eType>::iterator itr = allowedMobs.begin();
int iRandom = m_Random.NextInt(allowedMobsSize,a_Biome);
int iRandom = m_Random.NextInt((int)allowedMobsSize, a_Biome);
for(int i = 0; i < iRandom; i++)
for (int i = 0; i < iRandom; i++)
{
++itr;
}

View File

@ -814,7 +814,7 @@ void cPerlinNoise::SetSeed(int a_Seed)
void cPerlinNoise::AddOctave(float a_Frequency, float a_Amplitude)
{
m_Octaves.push_back(cOctave(m_Seed * (m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude));
m_Octaves.push_back(cOctave(m_Seed * ((int)m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude));
}

View File

@ -214,7 +214,7 @@ void cListenThread::Execute(void)
timeval tv; // On Linux select() doesn't seem to wake up when socket is closed, so let's kinda busy-wait:
tv.tv_sec = 1;
tv.tv_usec = 0;
if (select(Highest + 1, &fdRead, NULL, NULL, &tv) == -1)
if (select((int)Highest + 1, &fdRead, NULL, NULL, &tv) == -1)
{
LOG("select(R) call failed in cListenThread: \"%s\"", cSocket::GetLastErrorString().c_str());
continue;

View File

@ -328,18 +328,18 @@ bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Por
int cSocket::Receive(char * a_Buffer, unsigned int a_Length, unsigned int a_Flags)
int cSocket::Receive(char * a_Buffer, size_t a_Length, unsigned int a_Flags)
{
return recv(m_Socket, a_Buffer, a_Length, a_Flags);
return recv(m_Socket, a_Buffer, (int)a_Length, a_Flags);
}
int cSocket::Send(const char * a_Buffer, unsigned int a_Length)
int cSocket::Send(const char * a_Buffer, size_t a_Length)
{
return send(m_Socket, a_Buffer, a_Length, MSG_NOSIGNAL);
return send(m_Socket, a_Buffer, (int)a_Length, MSG_NOSIGNAL);
}

View File

@ -110,8 +110,8 @@ public:
/// Connects to the specified host or string IP address and port, using IPv4. Returns true if successful.
bool ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Port);
int Receive(char * a_Buffer, unsigned int a_Length, unsigned int a_Flags);
int Send (const char * a_Buffer, unsigned int a_Length);
int Receive(char * a_Buffer, size_t a_Length, unsigned int a_Flags);
int Send (const char * a_Buffer, size_t a_Length);
unsigned short GetPort(void) const; // Returns 0 on failure

View File

@ -406,7 +406,7 @@ void cSocketThreads::cSocketThread::Execute(void)
timeval Timeout;
Timeout.tv_sec = 5;
Timeout.tv_usec = 0;
if (select(Highest + 1, &fdRead, &fdWrite, NULL, &Timeout) == -1)
if (select((int)Highest + 1, &fdRead, &fdWrite, NULL, &Timeout) == -1)
{
LOG("select() call failed in cSocketThread: \"%s\"", cSocket::GetLastErrorString().c_str());
continue;

View File

@ -118,7 +118,7 @@ int cProbabDistrib::MapValue(int a_OrigValue) const
size_t Hi = m_Cumulative.size() - 1;
while (Hi - Lo > 1)
{
int Mid = (Lo + Hi) / 2;
size_t Mid = (Lo + Hi) / 2;
int MidProbab = m_Cumulative[Mid].m_Probability;
if (MidProbab < a_OrigValue)
{

View File

@ -197,7 +197,7 @@ void cProtocol172::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV
Pkt.WriteInt(a_ChunkX);
Pkt.WriteInt(a_ChunkZ);
Pkt.WriteShort((short)a_Changes.size());
Pkt.WriteInt(a_Changes.size() * 4);
Pkt.WriteInt((int)a_Changes.size() * 4);
for (sSetBlockVector::const_iterator itr = a_Changes.begin(), end = a_Changes.end(); itr != end; ++itr)
{
unsigned int Coords = itr->y | (itr->z << 8) | (itr->x << 12);
@ -532,7 +532,7 @@ void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc
Pkt.WriteFloat((float)a_BlockY);
Pkt.WriteFloat((float)a_BlockZ);
Pkt.WriteFloat((float)a_Radius);
Pkt.WriteInt(a_BlocksAffected.size());
Pkt.WriteInt((int)a_BlocksAffected.size());
for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(), end = a_BlocksAffected.end(); itr != end; ++itr)
{
Pkt.WriteChar((char)itr->x);
@ -698,7 +698,7 @@ void cProtocol172::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decor
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt(a_ID);
Pkt.WriteShort (1 + (3 * a_Decorators.size()));
Pkt.WriteShort ((short)(1 + (3 * a_Decorators.size())));
Pkt.WriteByte(1);
@ -1174,7 +1174,7 @@ void cProtocol172::SendTabCompletionResults(const AStringVector & a_Results)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet
Pkt.WriteVarInt(a_Results.size());
Pkt.WriteVarInt((int)a_Results.size());
for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr)
{
@ -1743,7 +1743,7 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
cPacketizer Pkt(*this, 0x01);
Pkt.WriteString(Server->GetServerID());
const AString & PubKeyDer = Server->GetPublicKeyDER();
Pkt.WriteShort(PubKeyDer.size());
Pkt.WriteShort((short)PubKeyDer.size());
Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size());
Pkt.WriteShort(4);
Pkt.WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
@ -2138,7 +2138,7 @@ void cProtocol172::WritePacket(cByteBuffer & a_Packet)
cCSLock Lock(m_CSPacket);
AString Pkt;
a_Packet.ReadAll(Pkt);
WriteVarInt(Pkt.size());
WriteVarInt((UInt32)Pkt.size());
SendData(Pkt.data(), Pkt.size());
Flush();
}
@ -2403,7 +2403,7 @@ cProtocol172::cPacketizer::~cPacketizer()
AString DataToSend;
// Send the packet length
UInt32 PacketLen = m_Out.GetUsedSpace();
UInt32 PacketLen = (UInt32)m_Out.GetUsedSpace();
m_Protocol.m_OutPacketLenBuffer.WriteVarInt(PacketLen);
m_Protocol.m_OutPacketLenBuffer.ReadAll(DataToSend);
m_Protocol.SendData(DataToSend.data(), DataToSend.size());
@ -2500,7 +2500,7 @@ void cProtocol172::cPacketizer::WriteItem(const cItem & a_Item)
Writer.Finish();
AString Compressed;
CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed);
WriteShort(Compressed.size());
WriteShort((short)Compressed.size());
WriteBuf(Compressed.data(), Compressed.size());
}
@ -2570,7 +2570,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt
AString Compressed;
CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed);
WriteShort(Compressed.size());
WriteShort((short)Compressed.size());
WriteBuf(Compressed.data(), Compressed.size());
}

View File

@ -871,7 +871,7 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void)
// Not enough bytes for the packet length, keep waiting
return false;
}
ReadSoFar -= m_Buffer.GetReadableSpace();
ReadSoFar -= (UInt32)m_Buffer.GetReadableSpace();
if (!m_Buffer.CanReadBytes(PacketLen))
{
// Not enough bytes for the packet, keep waiting
@ -961,7 +961,7 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema
{
return false;
}
NumBytesRead -= m_Buffer.GetReadableSpace();
NumBytesRead -= (UInt32)m_Buffer.GetReadableSpace();
switch (ProtocolVersion)
{
case PROTO_VERSION_1_7_2:

View File

@ -59,7 +59,7 @@ public:
virtual void Finished(void) override
{
m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, m_Buffer.size(), m_Buffer.c_str());
m_Connection.SendResponse(m_RequestID, RCON_PACKET_RESPONSE, (int)m_Buffer.size(), m_Buffer.c_str());
delete this;
}

View File

@ -590,13 +590,13 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
{
class cCallback : public cPlayerListCallback
{
unsigned m_BestRating;
unsigned m_NameLength;
size_t m_BestRating;
size_t m_NameLength;
const AString m_PlayerName;
virtual bool Item (cPlayer * a_pPlayer)
{
unsigned int Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName());
size_t Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName());
if ((Rating > 0) && (Rating >= m_BestRating))
{
m_BestMatch = a_pPlayer;
@ -626,7 +626,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
cPlayer * m_BestMatch;
unsigned m_NumMatches;
} Callback (a_PlayerName);
ForEachPlayer( Callback );
ForEachPlayer(Callback);
if (Callback.m_NumMatches == 1)
{
@ -763,8 +763,8 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output)
{
cWorld * World = itr->second;
int NumInGenerator = World->GetGeneratorQueueLength();
int NumInSaveQueue = World->GetStorageSaveQueueLength();
int NumInLoadQueue = World->GetStorageLoadQueueLength();
int NumInSaveQueue = (int)World->GetStorageSaveQueueLength();
int NumInLoadQueue = (int)World->GetStorageLoadQueueLength();
int NumValid = 0;
int NumDirty = 0;
int NumInLighting = 0;
@ -784,8 +784,6 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output)
a_Output.Out(" block lighting: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", 2 * sizeof(cChunkDef::BlockNibbles), (2 * sizeof(cChunkDef::BlockNibbles) + 1023) / 1024);
a_Output.Out(" heightmap: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", sizeof(cChunkDef::HeightMap), (sizeof(cChunkDef::HeightMap) + 1023) / 1024);
a_Output.Out(" biomemap: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", sizeof(cChunkDef::BiomeMap), (sizeof(cChunkDef::BiomeMap) + 1023) / 1024);
int Rest = sizeof(cChunk) - sizeof(cChunkDef::BlockTypes) - 3 * sizeof(cChunkDef::BlockNibbles) - sizeof(cChunkDef::HeightMap) - sizeof(cChunkDef::BiomeMap);
a_Output.Out(" other: %6d bytes (%3d KiB)", Rest, (Rest + 1023) / 1024);
SumNumValid += NumValid;
SumNumDirty += NumDirty;
SumNumInLighting += NumInLighting;

View File

@ -261,7 +261,7 @@ void cTeam::SetDisplayName(const AString & a_Name)
unsigned int cTeam::GetNumPlayers(void) const
size_t cTeam::GetNumPlayers(void) const
{
return m_Players.size();
}
@ -569,7 +569,7 @@ void cScoreboard::SendTo(cClientHandle & a_Client)
unsigned int cScoreboard::GetNumObjectives(void) const
size_t cScoreboard::GetNumObjectives(void) const
{
return m_Objectives.size();
}
@ -578,7 +578,7 @@ unsigned int cScoreboard::GetNumObjectives(void) const
unsigned int cScoreboard::GetNumTeams(void) const
size_t cScoreboard::GetNumTeams(void) const
{
return m_Teams.size();
}

View File

@ -153,7 +153,7 @@ public:
// tolua_begin
/** Returns the number of registered players */
unsigned int GetNumPlayers(void) const;
size_t GetNumPlayers(void) const;
bool AllowsFriendlyFire(void) const { return m_AllowsFriendlyFire; }
bool CanSeeFriendlyInvisible(void) const { return m_CanSeeFriendlyInvisible; }
@ -248,9 +248,9 @@ public:
cObjective * GetObjectiveIn(eDisplaySlot a_Slot);
unsigned int GetNumObjectives(void) const;
size_t GetNumObjectives(void) const;
unsigned int GetNumTeams(void) const;
size_t GetNumTeams(void) const;
void AddPlayerScore(const AString & a_Name, cObjective::eType a_Type, cObjective::Score a_Value = 1);

View File

@ -148,7 +148,7 @@ void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_Chunk
{
SimulateBlock(a_Chunk, itr->x, itr->y, itr->z);
}
m_TotalBlocks -= Blocks.size();
m_TotalBlocks -= (int)Blocks.size();
Blocks.clear();
}
}

View File

@ -64,7 +64,7 @@ void cSandSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0);
}
}
m_TotalBlocks -= ChunkData.size();
m_TotalBlocks -= (int)ChunkData.size();
ChunkData.clear();
}

View File

@ -11,15 +11,15 @@
/// Compresses a_Data into a_Compressed; returns Z_XXX error constants same as zlib's compress2()
int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, int a_Factor)
int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor)
{
uLongf CompressedSize = compressBound(a_Length);
uLongf CompressedSize = compressBound((uLong)a_Length);
// HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer!
// It saves us one allocation and one memcpy of the entire compressed data
// It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010)
a_Compressed.resize(CompressedSize);
int errorcode = compress2( (Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef*)a_Data, a_Length, a_Factor);
int errorcode = compress2((Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef *)a_Data, (uLong)a_Length, a_Factor);
if (errorcode != Z_OK)
{
return errorcode;
@ -33,14 +33,14 @@ int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, in
/// Uncompresses a_Data into a_Decompressed; returns Z_XXX error constants same as zlib's uncompress()
int UncompressString(const char * a_Data, int a_Length, AString & a_Uncompressed, int a_UncompressedSize)
int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompressed, size_t a_UncompressedSize)
{
// HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer!
// It saves us one allocation and one memcpy of the entire compressed data
// It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010)
a_Uncompressed.resize(a_UncompressedSize);
uLongf UncompressedSize = (uLongf)a_UncompressedSize; // On some architectures the uLongf is different in size to int, that may be the cause of the -5 error
int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, a_Length);
int errorcode = uncompress((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, (uLong)a_Length);
if (errorcode != Z_OK)
{
return errorcode;
@ -63,7 +63,7 @@ int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compres
z_stream strm;
memset(&strm, 0, sizeof(strm));
strm.next_in = (Bytef *)a_Data;
strm.avail_in = a_Length;
strm.avail_in = (uInt)a_Length;
strm.next_out = (Bytef *)Buffer;
strm.avail_out = sizeof(Buffer);
@ -127,7 +127,7 @@ extern int UncompressStringGZIP(const char * a_Data, size_t a_Length, AString &
z_stream strm;
memset(&strm, 0, sizeof(strm));
strm.next_in = (Bytef *)a_Data;
strm.avail_in = a_Length;
strm.avail_in = (uInt)a_Length;
strm.next_out = (Bytef *)Buffer;
strm.avail_out = sizeof(Buffer);

View File

@ -10,10 +10,10 @@
/// Compresses a_Data into a_Compressed using ZLIB; returns Z_XXX error constants same as zlib's compress2()
extern int CompressString(const char * a_Data, int a_Length, AString & a_Compressed, int a_Factor);
extern int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor);
/// Uncompresses a_Data into a_Uncompressed; returns Z_XXX error constants same as zlib's decompress()
extern int UncompressString(const char * a_Data, int a_Length, AString & a_Uncompressed, int a_UncompressedSize);
extern int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompressed, size_t a_UncompressedSize);
/// Compresses a_Data into a_Compressed using GZIP; returns Z_OK for success or Z_XXX error constants same as zlib
extern int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compressed);

View File

@ -247,18 +247,22 @@ int NoCaseCompare(const AString & s1, const AString & s2)
unsigned int RateCompareString(const AString & s1, const AString & s2 )
size_t RateCompareString(const AString & s1, const AString & s2)
{
unsigned int MatchedLetters = 0;
unsigned int s1Length = s1.length();
size_t MatchedLetters = 0;
size_t s1Length = s1.length();
if( s1Length > s2.length() ) return 0; // Definitely not a match
for (unsigned int i = 0; i < s1Length; i++)
if (s1Length > s2.length())
{
char c1 = (char)toupper( s1[i] );
char c2 = (char)toupper( s2[i] );
if( c1 == c2 )
// Definitely not a match
return 0;
}
for (size_t i = 0; i < s1Length; i++)
{
char c1 = (char)toupper(s1[i]);
char c2 = (char)toupper(s2[i]);
if (c1 == c2)
{
++MatchedLetters;
}
@ -288,11 +292,11 @@ void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString &
// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8
AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8)
AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UTF8)
{
a_UTF8.clear();
a_UTF8.reserve(3 * a_NumShorts / 2); // a quick guess of the resulting size
for (int i = 0; i < a_NumShorts; i++)
for (size_t i = 0; i < a_NumShorts; i++)
{
int c = GetBEShort(&a_RawData[i * 2]);
if (c < 0x80)

View File

@ -52,13 +52,13 @@ extern AString & StrToLower(AString & s);
extern int NoCaseCompare(const AString & s1, const AString & s2); // tolua_export
/// Case-insensitive string comparison that returns a rating of equal-ness between [0 - s1.length()]
extern unsigned int RateCompareString(const AString & s1, const AString & s2 );
extern size_t RateCompareString(const AString & s1, const AString & s2);
/// Replaces *each* occurence of iNeedle in iHayStack with iReplaceWith
extern void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith); // tolua_export
/// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8
extern AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8);
extern AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UTF8);
/// Converts a UTF-8 string into a UTF-16 BE string, packing that back into AString; return a ref to a_UTF16
extern AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a_UTF16);

View File

@ -891,7 +891,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount))
{
Input.m_ItemDamage -= DamageDiff;
NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Count();
NeedExp += std::max(1, DamageDiff / 100) + (int)Input.m_Enchantments.Count();
DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
++x;

View File

@ -591,7 +591,7 @@ void cWindow::OnLeftPaintEnd(cPlayer & a_Player)
const cSlotNums & SlotNums = a_Player.GetInventoryPaintSlots();
cItem ToDistribute(a_Player.GetDraggingItem());
int ToEachSlot = (int)ToDistribute.m_ItemCount / SlotNums.size();
int ToEachSlot = (int)ToDistribute.m_ItemCount / (int)SlotNums.size();
int NumDistributed = DistributeItemToSlots(a_Player, ToDistribute, ToEachSlot, SlotNums);

View File

@ -2402,13 +2402,13 @@ bool cWorld::DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_
bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback)
{
cPlayer * BestMatch = NULL;
unsigned int BestRating = 0;
unsigned int NameLength = a_PlayerNameHint.length();
size_t BestRating = 0;
size_t NameLength = a_PlayerNameHint.length();
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
unsigned int Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName());
size_t Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName());
if (Rating >= BestRating)
{
BestMatch = *itr;
@ -2422,7 +2422,6 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa
if (BestMatch != NULL)
{
LOG("Compared %s and %s with rating %i", a_PlayerNameHint.c_str(), BestMatch->GetName().c_str(), BestRating);
return a_Callback.Item (BestMatch);
}
return false;

View File

@ -38,7 +38,7 @@
cParsedNBT::cParsedNBT(const char * a_Data, int a_Length) :
cParsedNBT::cParsedNBT(const char * a_Data, size_t a_Length) :
m_Data(a_Data),
m_Length(a_Length),
m_Pos(0)
@ -99,8 +99,10 @@ bool cParsedNBT::ReadString(int & a_StringStart, int & a_StringLen)
bool cParsedNBT::ReadCompound(void)
{
ASSERT(m_Tags.size() > 0);
// Reads the latest tag as a compound
int ParentIdx = m_Tags.size() - 1;
int ParentIdx = (int)m_Tags.size() - 1;
int PrevSibling = -1;
for (;;)
{
@ -114,13 +116,13 @@ bool cParsedNBT::ReadCompound(void)
m_Tags.push_back(cFastNBTTag(TagType, ParentIdx, PrevSibling));
if (PrevSibling >= 0)
{
m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1;
m_Tags[PrevSibling].m_NextSibling = (int)m_Tags.size() - 1;
}
else
{
m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1;
m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1;
}
PrevSibling = m_Tags.size() - 1;
PrevSibling = (int)m_Tags.size() - 1;
RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength));
RETURN_FALSE_IF_FALSE(ReadTag());
} // while (true)
@ -146,20 +148,20 @@ bool cParsedNBT::ReadList(eTagType a_ChildrenType)
}
// Read items:
int ParentIdx = m_Tags.size() - 1;
int ParentIdx = (int)m_Tags.size() - 1;
int PrevSibling = -1;
for (int i = 0; i < Count; i++)
{
m_Tags.push_back(cFastNBTTag(a_ChildrenType, ParentIdx, PrevSibling));
if (PrevSibling >= 0)
{
m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1;
m_Tags[PrevSibling].m_NextSibling = (int)m_Tags.size() - 1;
}
else
{
m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1;
m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1;
}
PrevSibling = m_Tags.size() - 1;
PrevSibling = (int)m_Tags.size() - 1;
RETURN_FALSE_IF_FALSE(ReadTag());
} // for (i)
m_Tags[ParentIdx].m_LastChild = PrevSibling;
@ -336,7 +338,7 @@ cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) :
m_Stack[0].m_Type = TAG_Compound;
m_Result.reserve(100 * 1024);
m_Result.push_back(TAG_Compound);
WriteString(a_RootTagName.data(), a_RootTagName.size());
WriteString(a_RootTagName.data(), (UInt16)a_RootTagName.size());
}
@ -389,7 +391,7 @@ void cFastNBTWriter::BeginList(const AString & a_Name, eTagType a_ChildrenType)
++m_CurrentStack;
m_Stack[m_CurrentStack].m_Type = TAG_List;
m_Stack[m_CurrentStack].m_Pos = m_Result.size() - 4;
m_Stack[m_CurrentStack].m_Pos = (int)m_Result.size() - 4;
m_Stack[m_CurrentStack].m_Count = 0;
m_Stack[m_CurrentStack].m_ItemType = a_ChildrenType;
}
@ -493,7 +495,7 @@ void cFastNBTWriter::AddString(const AString & a_Name, const AString & a_Value)
void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value, size_t a_NumElements)
{
TagCommon(a_Name, TAG_ByteArray);
Int32 len = htonl(a_NumElements);
u_long len = htonl((u_long)a_NumElements);
m_Result.append((const char *)&len, 4);
m_Result.append(a_Value, a_NumElements);
}
@ -505,7 +507,7 @@ void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value,
void cFastNBTWriter::AddIntArray(const AString & a_Name, const int * a_Value, size_t a_NumElements)
{
TagCommon(a_Name, TAG_IntArray);
Int32 len = htonl(a_NumElements);
u_long len = htonl((u_long)a_NumElements);
size_t cap = m_Result.capacity();
size_t size = m_Result.length();
if ((cap - size) < (4 + a_NumElements * 4))
@ -534,7 +536,7 @@ void cFastNBTWriter::Finish(void)
void cFastNBTWriter::WriteString(const char * a_Data, short a_Length)
void cFastNBTWriter::WriteString(const char * a_Data, UInt16 a_Length)
{
Int16 Len = htons(a_Length);
m_Result.append((const char *)&Len, 2);

View File

@ -114,7 +114,7 @@ Each primitive tag also stores the length of the contained data, in bytes.
class cParsedNBT
{
public:
cParsedNBT(const char * a_Data, int a_Length);
cParsedNBT(const char * a_Data, size_t a_Length);
bool IsValid(void) const {return m_IsValid; }
@ -251,7 +251,7 @@ public:
protected:
const char * m_Data;
int m_Length;
size_t m_Length;
std::vector<cFastNBTTag> m_Tags;
bool m_IsValid; // True if parsing succeeded
@ -319,7 +319,7 @@ protected:
bool IsStackTopCompound(void) const { return (m_Stack[m_CurrentStack].m_Type == TAG_Compound); }
void WriteString(const char * a_Data, short a_Length);
void WriteString(const char * a_Data, UInt16 a_Length);
inline void TagCommon(const AString & a_Name, eTagType a_Type)
{
@ -330,7 +330,7 @@ protected:
{
// Compound: add the type and name:
m_Result.push_back((char)a_Type);
WriteString(a_Name.c_str(), (short)a_Name.length());
WriteString(a_Name.c_str(), (UInt16)a_Name.length());
}
else
{

View File

@ -230,7 +230,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
}
// Copy the block types and metas:
int NumBytes = a_BlockArea.GetBlockCount();
int NumBytes = (int)a_BlockArea.GetBlockCount();
if (a_NBT.GetDataLength(TBlockTypes) < NumBytes)
{
LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.",
@ -242,7 +242,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
if (AreMetasPresent)
{
int NumBytes = a_BlockArea.GetBlockCount();
int NumBytes = (int)a_BlockArea.GetBlockCount();
if (a_NBT.GetDataLength(TBlockMetas) < NumBytes)
{
LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.",

View File

@ -96,7 +96,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
gzFile gz = gzopen((FILE_IO_PREFIX + fnam).c_str(), "wb");
if (gz != NULL)
{
gzwrite(gz, Writer.GetResult().data(), Writer.GetResult().size());
gzwrite(gz, Writer.GetResult().data(), (unsigned)Writer.GetResult().size());
}
gzclose(gz);
}
@ -252,7 +252,7 @@ bool cWSSAnvil::LoadChunkFromData(const cChunkCoords & a_Chunk, const AString &
strm.next_out = (Bytef *)Uncompressed;
strm.avail_out = sizeof(Uncompressed);
strm.next_in = (Bytef *)a_Data.data();
strm.avail_in = a_Data.size();
strm.avail_in = (uInt)a_Data.size();
int res = inflate(&strm, Z_FINISH);
inflateEnd(&strm);
if (res != Z_STREAM_END)
@ -2682,7 +2682,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
// Store the chunk data:
m_File.Seek(ChunkSector * 4096);
unsigned ChunkSize = htonl(a_Data.size() + 1);
u_long ChunkSize = htonl((u_long)a_Data.size() + 1);
if (m_File.Write(&ChunkSize, 4) != 4)
{
LOGWARNING("Cannot save chunk [%d, %d], writing(1) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
@ -2706,7 +2706,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
m_File.Write(Padding, 4096 - (BytesWritten % 4096));
// Store the header:
ChunkSize = (a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number
ChunkSize = ((u_long)a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number
ASSERT(ChunkSize < 256);
m_Header[LocalX + 32 * LocalZ] = htonl((ChunkSector << 8) | ChunkSize);
if (m_File.Seek(0) < 0)

View File

@ -601,7 +601,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
// Decompress the data:
AString UncompressedData;
{
int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize);
int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize);
if (errorcode != Z_OK)
{
LOGERROR("Error %d decompressing data for chunk [%d, %d]",
@ -681,7 +681,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
// Re-compress data
AString CompressedData;
{
int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData,m_CompressionFactor);
int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor);
if (errorcode != Z_OK)
{
LOGERROR("Error %d compressing data for chunk [%d, %d]",
@ -693,9 +693,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
}
// Save into file's cache
Header->m_UncompressedSize = Converted.size();
Header->m_CompressedSize = CompressedData.size();
NewDataContents.append( CompressedData );
Header->m_UncompressedSize = (int)Converted.size();
Header->m_CompressedSize = (int)CompressedData.size();
NewDataContents.append(CompressedData);
}
// Done converting
@ -731,7 +731,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
Offset += Header->m_CompressedSize;
// Crude data integrity check:
const int ExpectedSize = (16*256*16)*2 + (16*256*16)/2; // For version 2
const int ExpectedSize = (16 * 256 * 16) * 2 + (16 * 256 * 16) / 2; // For version 2
if (UncompressedSize < ExpectedSize)
{
LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing",
@ -745,7 +745,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
// Decompress the data:
AString UncompressedData;
{
int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize);
int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize);
if (errorcode != Z_OK)
{
LOGERROR("Error %d decompressing data for chunk [%d, %d]",
@ -829,9 +829,9 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
}
// Save into file's cache
Header->m_UncompressedSize = Converted.size();
Header->m_CompressedSize = CompressedData.size();
NewDataContents.append( CompressedData );
Header->m_UncompressedSize = (int)Converted.size();
Header->m_CompressedSize = (int)CompressedData.size();
NewDataContents.append(CompressedData);
}
// Done converting
@ -861,7 +861,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
// Decompress the data:
AString UncompressedData;
int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, a_UncompressedSize);
int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, (size_t)a_UncompressedSize);
if (errorcode != Z_OK)
{
LOGERROR("Error %d decompressing data for chunk [%d, %d]",
@ -873,7 +873,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
if (a_UncompressedSize != (int)UncompressedData.size())
{
LOGWARNING("Uncompressed data size differs (exp %d bytes, got " SIZE_T_FMT ") for chunk [%d, %d]",
LOGWARNING("Uncompressed data size differs (exp %d bytes, got " SIZE_T_FMT ") for chunk [%d, %d]",
a_UncompressedSize, UncompressedData.size(),
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ
);