Merged branch 'master' into GridStructGen.
This commit is contained in:
commit
839cff62ad
@ -15,6 +15,7 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
|
|||||||
m_IsCritical(false),
|
m_IsCritical(false),
|
||||||
m_Timer(0),
|
m_Timer(0),
|
||||||
m_HitGroundTimer(0),
|
m_HitGroundTimer(0),
|
||||||
|
m_HasTeleported(false),
|
||||||
m_bIsCollected(false),
|
m_bIsCollected(false),
|
||||||
m_HitBlockPos(Vector3i(0, 0, 0))
|
m_HitBlockPos(Vector3i(0, 0, 0))
|
||||||
{
|
{
|
||||||
|
@ -106,11 +106,13 @@ void cLightingThread::Stop(void)
|
|||||||
cCSLock Lock(m_CS);
|
cCSLock Lock(m_CS);
|
||||||
for (cChunkStays::iterator itr = m_PendingQueue.begin(), end = m_PendingQueue.end(); itr != end; ++itr)
|
for (cChunkStays::iterator itr = m_PendingQueue.begin(), end = m_PendingQueue.end(); itr != end; ++itr)
|
||||||
{
|
{
|
||||||
|
(*itr)->Disable();
|
||||||
delete *itr;
|
delete *itr;
|
||||||
}
|
}
|
||||||
m_PendingQueue.clear();
|
m_PendingQueue.clear();
|
||||||
for (cChunkStays::iterator itr = m_Queue.begin(), end = m_Queue.end(); itr != end; ++itr)
|
for (cChunkStays::iterator itr = m_Queue.begin(), end = m_Queue.end(); itr != end; ++itr)
|
||||||
{
|
{
|
||||||
|
(*itr)->Disable();
|
||||||
delete *itr;
|
delete *itr;
|
||||||
}
|
}
|
||||||
m_Queue.clear();
|
m_Queue.clear();
|
||||||
|
@ -394,10 +394,14 @@ void cWorld::InitializeSpawn(void)
|
|||||||
|
|
||||||
// For the debugging builds, don't make the server build too much world upon start:
|
// For the debugging builds, don't make the server build too much world upon start:
|
||||||
#if defined(_DEBUG) || defined(ANDROID_NDK)
|
#if defined(_DEBUG) || defined(ANDROID_NDK)
|
||||||
int ViewDist = 9;
|
const int DefaultViewDist = 9;
|
||||||
#else
|
#else
|
||||||
int ViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is
|
const int DefaultViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
|
cIniFile IniFile;
|
||||||
|
IniFile.ReadFile(m_IniFileName);
|
||||||
|
int ViewDist = IniFile.GetValueSetI("SpawnPosition", "PregenerateDistance", DefaultViewDist);
|
||||||
|
IniFile.WriteFile(m_IniFileName);
|
||||||
|
|
||||||
LOG("Preparing spawn area in world \"%s\"...", m_WorldName.c_str());
|
LOG("Preparing spawn area in world \"%s\"...", m_WorldName.c_str());
|
||||||
for (int x = 0; x < ViewDist; x++)
|
for (int x = 0; x < ViewDist; x++)
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
// cParsedNBT:
|
// cParsedNBT:
|
||||||
|
|
||||||
#define NEEDBYTES(N) \
|
#define NEEDBYTES(N) \
|
||||||
if (m_Length - m_Pos < N) \
|
if (m_Length - m_Pos < (size_t)N) \
|
||||||
{ \
|
{ \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
@ -79,14 +79,14 @@ bool cParsedNBT::Parse(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cParsedNBT::ReadString(int & a_StringStart, int & a_StringLen)
|
bool cParsedNBT::ReadString(size_t & a_StringStart, size_t & a_StringLen)
|
||||||
{
|
{
|
||||||
NEEDBYTES(2);
|
NEEDBYTES(2);
|
||||||
a_StringStart = m_Pos + 2;
|
a_StringStart = m_Pos + 2;
|
||||||
a_StringLen = GetBEShort(m_Data + m_Pos);
|
a_StringLen = (size_t)GetBEShort(m_Data + m_Pos);
|
||||||
if (a_StringLen < 0)
|
if (a_StringLen > 0xffff)
|
||||||
{
|
{
|
||||||
// Invalid string length
|
// Suspicious string length
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_Pos += 2 + a_StringLen;
|
m_Pos += 2 + a_StringLen;
|
||||||
@ -281,7 +281,7 @@ int cParsedNBT::FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLen
|
|||||||
for (int Child = m_Tags[a_Tag].m_FirstChild; Child != -1; Child = m_Tags[Child].m_NextSibling)
|
for (int Child = m_Tags[a_Tag].m_FirstChild; Child != -1; Child = m_Tags[Child].m_NextSibling)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
(m_Tags[Child].m_NameLength == (int)a_NameLength) &&
|
(m_Tags[Child].m_NameLength == a_NameLength) &&
|
||||||
(memcmp(m_Data + m_Tags[Child].m_NameStart, a_Name, a_NameLength) == 0)
|
(memcmp(m_Data + m_Tags[Child].m_NameStart, a_Name, a_NameLength) == 0)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -61,10 +61,10 @@ public:
|
|||||||
|
|
||||||
// The following members are indices into the data stream. m_DataLength == 0 if no data available
|
// The following members are indices into the data stream. m_DataLength == 0 if no data available
|
||||||
// They must not be pointers, because the datastream may be copied into another AString object in the meantime.
|
// They must not be pointers, because the datastream may be copied into another AString object in the meantime.
|
||||||
int m_NameStart;
|
size_t m_NameStart;
|
||||||
int m_NameLength;
|
size_t m_NameLength;
|
||||||
int m_DataStart;
|
size_t m_DataStart;
|
||||||
int m_DataLength;
|
size_t m_DataLength;
|
||||||
|
|
||||||
// The following members are indices into the array returned; -1 if not valid
|
// The following members are indices into the array returned; -1 if not valid
|
||||||
// They must not be pointers, because pointers would not survive std::vector reallocation
|
// They must not be pointers, because pointers would not survive std::vector reallocation
|
||||||
@ -135,7 +135,7 @@ public:
|
|||||||
|
|
||||||
/** Returns the length of the tag's data, in bytes.
|
/** Returns the length of the tag's data, in bytes.
|
||||||
Not valid for Compound or List tags! */
|
Not valid for Compound or List tags! */
|
||||||
int GetDataLength (int a_Tag) const
|
size_t GetDataLength (int a_Tag) const
|
||||||
{
|
{
|
||||||
ASSERT(m_Tags[(size_t)a_Tag].m_Type != TAG_List);
|
ASSERT(m_Tags[(size_t)a_Tag].m_Type != TAG_List);
|
||||||
ASSERT(m_Tags[(size_t)a_Tag].m_Type != TAG_Compound);
|
ASSERT(m_Tags[(size_t)a_Tag].m_Type != TAG_Compound);
|
||||||
@ -256,10 +256,10 @@ protected:
|
|||||||
bool m_IsValid; // True if parsing succeeded
|
bool m_IsValid; // True if parsing succeeded
|
||||||
|
|
||||||
// Used while parsing:
|
// Used while parsing:
|
||||||
int m_Pos;
|
size_t m_Pos;
|
||||||
|
|
||||||
bool Parse(void);
|
bool Parse(void);
|
||||||
bool ReadString(int & a_StringStart, int & a_StringLen); // Reads a simple string (2 bytes length + data), sets the string descriptors
|
bool ReadString(size_t & a_StringStart, size_t & a_StringLen); // Reads a simple string (2 bytes length + data), sets the string descriptors
|
||||||
bool ReadCompound(void); // Reads the latest tag as a compound
|
bool ReadCompound(void); // Reads the latest tag as a compound
|
||||||
bool ReadList(eTagType a_ChildrenType); // Reads the latest tag as a list of items of type a_ChildrenType
|
bool ReadList(eTagType a_ChildrenType); // Reads the latest tag as a list of items of type a_ChildrenType
|
||||||
bool ReadTag(void); // Reads the latest tag, depending on its m_Type setting
|
bool ReadTag(void); // Reads the latest tag, depending on its m_Type setting
|
||||||
|
@ -96,7 +96,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
|
|||||||
if (ExplosionName == "Colors")
|
if (ExplosionName == "Colors")
|
||||||
{
|
{
|
||||||
// Divide by four as data length returned in bytes
|
// Divide by four as data length returned in bytes
|
||||||
int DataLength = a_NBT.GetDataLength(explosiontag);
|
size_t DataLength = a_NBT.GetDataLength(explosiontag);
|
||||||
// round to the next highest multiple of four
|
// round to the next highest multiple of four
|
||||||
DataLength -= DataLength % 4;
|
DataLength -= DataLength % 4;
|
||||||
if (DataLength == 0)
|
if (DataLength == 0)
|
||||||
@ -105,14 +105,14 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char * ColourData = (a_NBT.GetData(explosiontag));
|
const char * ColourData = (a_NBT.GetData(explosiontag));
|
||||||
for (int i = 0; i < DataLength; i += 4 /* Size of network int*/)
|
for (size_t i = 0; i < DataLength; i += 4)
|
||||||
{
|
{
|
||||||
a_FireworkItem.m_Colours.push_back(GetBEInt(ColourData + i));
|
a_FireworkItem.m_Colours.push_back(GetBEInt(ColourData + i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ExplosionName == "FadeColors")
|
else if (ExplosionName == "FadeColors")
|
||||||
{
|
{
|
||||||
int DataLength = a_NBT.GetDataLength(explosiontag) / 4;
|
size_t DataLength = a_NBT.GetDataLength(explosiontag) / 4;
|
||||||
// round to the next highest multiple of four
|
// round to the next highest multiple of four
|
||||||
DataLength -= DataLength % 4;
|
DataLength -= DataLength % 4;
|
||||||
if (DataLength == 0)
|
if (DataLength == 0)
|
||||||
@ -121,7 +121,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char * FadeColourData = (a_NBT.GetData(explosiontag));
|
const char * FadeColourData = (a_NBT.GetData(explosiontag));
|
||||||
for (int i = 0; i < DataLength; i += 4 /* Size of network int*/)
|
for (size_t i = 0; i < DataLength; i += 4)
|
||||||
{
|
{
|
||||||
a_FireworkItem.m_FadeColours.push_back(GetBEInt(FadeColourData + i));
|
a_FireworkItem.m_FadeColours.push_back(GetBEInt(FadeColourData + i));
|
||||||
}
|
}
|
||||||
|
@ -230,11 +230,11 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy the block types and metas:
|
// Copy the block types and metas:
|
||||||
int NumBytes = (int)a_BlockArea.GetBlockCount();
|
size_t NumBytes = a_BlockArea.GetBlockCount();
|
||||||
if (a_NBT.GetDataLength(TBlockTypes) < NumBytes)
|
if (a_NBT.GetDataLength(TBlockTypes) < NumBytes)
|
||||||
{
|
{
|
||||||
LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.",
|
LOG("BlockTypes truncated in the schematic file (exp %d, got %d bytes). Loading partial.",
|
||||||
NumBytes, a_NBT.GetDataLength(TBlockTypes)
|
(int)NumBytes, (int)a_NBT.GetDataLength(TBlockTypes)
|
||||||
);
|
);
|
||||||
NumBytes = a_NBT.GetDataLength(TBlockTypes);
|
NumBytes = a_NBT.GetDataLength(TBlockTypes);
|
||||||
}
|
}
|
||||||
@ -242,11 +242,11 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
|
|||||||
|
|
||||||
if (AreMetasPresent)
|
if (AreMetasPresent)
|
||||||
{
|
{
|
||||||
int NumBytes = (int)a_BlockArea.GetBlockCount();
|
size_t NumBytes = a_BlockArea.GetBlockCount();
|
||||||
if (a_NBT.GetDataLength(TBlockMetas) < NumBytes)
|
if (a_NBT.GetDataLength(TBlockMetas) < NumBytes)
|
||||||
{
|
{
|
||||||
LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.",
|
LOG("BlockMetas truncated in the schematic file (exp %d, got %d bytes). Loading partial.",
|
||||||
NumBytes, a_NBT.GetDataLength(TBlockMetas)
|
(int)NumBytes, (int)a_NBT.GetDataLength(TBlockMetas)
|
||||||
);
|
);
|
||||||
NumBytes = a_NBT.GetDataLength(TBlockMetas);
|
NumBytes = a_NBT.GetDataLength(TBlockMetas);
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWSSAnvil::CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, int a_Length)
|
void cWSSAnvil::CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, size_t a_Length)
|
||||||
{
|
{
|
||||||
int Child = a_NBT.FindChildByName(a_Tag, a_ChildName);
|
int Child = a_NBT.FindChildByName(a_Tag, a_ChildName);
|
||||||
if ((Child >= 0) && (a_NBT.GetType(Child) == TAG_ByteArray) && (a_NBT.GetDataLength(Child) == a_Length))
|
if ((Child >= 0) && (a_NBT.GetType(Child) == TAG_ByteArray) && (a_NBT.GetDataLength(Child) == a_Length))
|
||||||
@ -440,8 +440,8 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_
|
|||||||
|
|
||||||
// Save blockdata:
|
// Save blockdata:
|
||||||
a_Writer.BeginList("Sections", TAG_Compound);
|
a_Writer.BeginList("Sections", TAG_Compound);
|
||||||
int SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16;
|
size_t SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16;
|
||||||
int SliceSizeNibble = SliceSizeBlock / 2;
|
size_t SliceSizeNibble = SliceSizeBlock / 2;
|
||||||
const char * BlockTypes = (const char *)(Serializer.m_BlockTypes);
|
const char * BlockTypes = (const char *)(Serializer.m_BlockTypes);
|
||||||
const char * BlockMetas = (const char *)(Serializer.m_BlockMetas);
|
const char * BlockMetas = (const char *)(Serializer.m_BlockMetas);
|
||||||
#ifdef DEBUG_SKYLIGHT
|
#ifdef DEBUG_SKYLIGHT
|
||||||
@ -1078,7 +1078,7 @@ void cWSSAnvil::LoadCommandBlockFromNBT(cBlockEntityList & a_BlockEntities, cons
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength)
|
void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, size_t a_IDTagLength)
|
||||||
{
|
{
|
||||||
if (strncmp(a_IDTag, "Boat", a_IDTagLength) == 0)
|
if (strncmp(a_IDTag, "Boat", a_IDTagLength) == 0)
|
||||||
{
|
{
|
||||||
@ -2630,14 +2630,14 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a
|
|||||||
unsigned ChunkLocation = ntohl(m_Header[LocalX + 32 * LocalZ]);
|
unsigned ChunkLocation = ntohl(m_Header[LocalX + 32 * LocalZ]);
|
||||||
unsigned ChunkOffset = ChunkLocation >> 8;
|
unsigned ChunkOffset = ChunkLocation >> 8;
|
||||||
|
|
||||||
m_File.Seek(ChunkOffset * 4096);
|
m_File.Seek((int)ChunkOffset * 4096);
|
||||||
|
|
||||||
int ChunkSize = 0;
|
int ChunkSize = 0;
|
||||||
if (m_File.Read(&ChunkSize, 4) != 4)
|
if (m_File.Read(&ChunkSize, 4) != 4)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ChunkSize = ntohl(ChunkSize);
|
ChunkSize = ntohl((u_long)ChunkSize);
|
||||||
char CompressionType = 0;
|
char CompressionType = 0;
|
||||||
if (m_File.Read(&CompressionType, 1) != 1)
|
if (m_File.Read(&CompressionType, 1) != 1)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ protected:
|
|||||||
void LoadMobHeadFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
void LoadMobHeadFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||||
void LoadCommandBlockFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
void LoadCommandBlockFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||||
|
|
||||||
void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength);
|
void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, size_t a_IDTagLength);
|
||||||
|
|
||||||
void LoadBoatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
|
void LoadBoatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||||
void LoadEnderCrystalFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
|
void LoadEnderCrystalFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||||
@ -221,7 +221,7 @@ protected:
|
|||||||
cMCAFile * LoadMCAFile(const cChunkCoords & a_Chunk);
|
cMCAFile * LoadMCAFile(const cChunkCoords & a_Chunk);
|
||||||
|
|
||||||
/// Copies a_Length bytes of data from the specified NBT Tag's Child into the a_Destination buffer
|
/// Copies a_Length bytes of data from the specified NBT Tag's Child into the a_Destination buffer
|
||||||
void CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, int a_Length);
|
void CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString & a_ChildName, char * a_Destination, size_t a_Length);
|
||||||
|
|
||||||
// cWSSchema overrides:
|
// cWSSchema overrides:
|
||||||
virtual bool LoadChunk(const cChunkCoords & a_Chunk) override;
|
virtual bool LoadChunk(const cChunkCoords & a_Chunk) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user