diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/Globals.h | 8 | ||||
-rw-r--r-- | source/WorldStorage.cpp | 2 | ||||
-rw-r--r-- | source/cAuthenticator.cpp | 2 | ||||
-rw-r--r-- | source/cBlockingTCPLink.cpp | 8 | ||||
-rw-r--r-- | source/cChunk.cpp | 10 | ||||
-rw-r--r-- | source/cChunkMap.cpp | 2 | ||||
-rw-r--r-- | source/cClientHandle.cpp | 10 | ||||
-rw-r--r-- | source/cCriticalSection.cpp | 4 | ||||
-rw-r--r-- | source/cEntity.cpp | 2 | ||||
-rw-r--r-- | source/cEntity.h | 2 | ||||
-rw-r--r-- | source/cEvent.cpp | 2 | ||||
-rw-r--r-- | source/cFile.cpp | 20 | ||||
-rw-r--r-- | source/cIsThread.cpp | 4 | ||||
-rw-r--r-- | source/cMCLogger.h | 4 | ||||
-rw-r--r-- | source/cSocket.cpp | 2 | ||||
-rw-r--r-- | source/cSocketThreads.cpp | 14 | ||||
-rw-r--r-- | source/cWorldGenerator.cpp | 2 | ||||
-rw-r--r-- | source/packets/cPacket.h | 4 | ||||
-rw-r--r-- | source/packets/cPacket_CreativeInventoryAction.cpp | 2 | ||||
-rw-r--r-- | source/packets/cPacket_MapChunk.cpp | 2 | ||||
-rw-r--r-- | source/packets/cPacket_NamedEntitySpawn.cpp | 2 |
21 files changed, 49 insertions, 59 deletions
diff --git a/source/Globals.h b/source/Globals.h index 1ede57bd4..c2aa3753c 100644 --- a/source/Globals.h +++ b/source/Globals.h @@ -75,13 +75,6 @@ -// Compatibility:
-#define ASSERT assert
-
-
-
-
-
// STL stuff:
#include <vector>
#include <list>
@@ -127,6 +120,7 @@ /// Faster than (int)floorf((float)x / (float)div)
#define FAST_FLOOR_DIV( x, div ) ( (x) < 0 ? (((int)x / div) - 1) : ((int)x / div) )
+#define ASSERT( x ) { if( !(x) ) { LOGERROR("Assertion failed: \"%s\", file %s, line %i", #x, __FILE__, __LINE__ ); assert( !#x ); } }
diff --git a/source/WorldStorage.cpp b/source/WorldStorage.cpp index bc830c272..58c6527ca 100644 --- a/source/WorldStorage.cpp +++ b/source/WorldStorage.cpp @@ -81,7 +81,7 @@ void cJsonChunkSerializer::BlockEntity(cBlockEntity * a_BlockEntity) default:
{
- assert(!"Unhandled blocktype in BlockEntities list while saving to JSON");
+ ASSERT(!"Unhandled blocktype in BlockEntities list while saving to JSON");
break;
}
} // switch (BlockEntity->GetBlockType())
diff --git a/source/cAuthenticator.cpp b/source/cAuthenticator.cpp index 0c482a9a1..8fe19ba90 100644 --- a/source/cAuthenticator.cpp +++ b/source/cAuthenticator.cpp @@ -125,7 +125,7 @@ void cAuthenticator::Execute(void) {
return;
}
- assert(mQueue.size() > 0);
+ ASSERT(mQueue.size() > 0);
AString UserName = mQueue.front().mName;
AString ActualAddress = mAddress;
diff --git a/source/cBlockingTCPLink.cpp b/source/cBlockingTCPLink.cpp index 341c71a2b..da82f3801 100644 --- a/source/cBlockingTCPLink.cpp +++ b/source/cBlockingTCPLink.cpp @@ -50,7 +50,7 @@ void cBlockingTCPLink::CloseSocket() bool cBlockingTCPLink::Connect(const char * iAddress, unsigned int iPort)
{
- assert(!m_Socket.IsValid());
+ ASSERT(!m_Socket.IsValid());
if (m_Socket.IsValid())
{
LOGWARN("WARNING: cTCPLink Connect() called while still connected.");
@@ -101,7 +101,7 @@ bool cBlockingTCPLink::Connect(const char * iAddress, unsigned int iPort) int cBlockingTCPLink::Send(char * a_Data, unsigned int a_Size, int a_Flags /* = 0 */ )
{
- assert(m_Socket.IsValid());
+ ASSERT(m_Socket.IsValid());
if (!m_Socket.IsValid())
{
LOGERROR("cBlockingTCPLink: Trying to send data without a valid connection!");
@@ -116,7 +116,7 @@ int cBlockingTCPLink::Send(char * a_Data, unsigned int a_Size, int a_Flags /* = int cBlockingTCPLink::SendMessage( const char* a_Message, int a_Flags /* = 0 */ )
{
- assert(m_Socket.IsValid());
+ ASSERT(m_Socket.IsValid());
if (!m_Socket.IsValid())
{
LOGWARN("cBlockingTCPLink: Trying to send message without a valid connection!");
@@ -131,7 +131,7 @@ int cBlockingTCPLink::SendMessage( const char* a_Message, int a_Flags /* = 0 */ void cBlockingTCPLink::ReceiveData(AString & oData)
{
- assert(m_Socket.IsValid());
+ ASSERT(m_Socket.IsValid());
if (!m_Socket.IsValid())
{
return;
diff --git a/source/cChunk.cpp b/source/cChunk.cpp index d070e82aa..827e97cb9 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -833,7 +833,7 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block return; // Clip
}
- assert(IsValid()); // Is this chunk loaded / generated?
+ ASSERT(IsValid()); // Is this chunk loaded / generated?
int index = a_Y + (a_Z * 128) + (a_X * 128 * 16);
char OldBlockMeta = GetLight( m_BlockMeta, index );
@@ -894,9 +894,9 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta)
{
- assert(!((a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16)));
+ ASSERT(!((a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16)));
- assert(IsValid());
+ ASSERT(IsValid());
const int index = a_Y + (a_Z * 128) + (a_X * 128 * 16);
const char OldBlock = m_BlockType[index];
@@ -1271,7 +1271,7 @@ bool cChunk::LoadFromDisk() default:
{
- assert(!"Unhandled block entity in file");
+ ASSERT(!"Unhandled block entity in file");
break;
}
}
@@ -1425,7 +1425,7 @@ void cChunk::SaveToJson( Json::Value & a_Value ) default:
{
- assert(!"Unhandled blocktype in BlockEntities list while saving to JSON");
+ ASSERT(!"Unhandled blocktype in BlockEntities list while saving to JSON");
break;
}
} // switch (BlockEntity->GetBlockType())
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp index 0657f51d3..10577dc6f 100644 --- a/source/cChunkMap.cpp +++ b/source/cChunkMap.cpp @@ -466,7 +466,7 @@ cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_Ch if (!((LocalX < LAYER_SIZE) && (LocalZ < LAYER_SIZE) && (LocalX > -1) && (LocalZ > -1)))
{
- assert(!"Asking a cChunkLayer for a chunk that doesn't belong to it!");
+ ASSERT(!"Asking a cChunkLayer for a chunk that doesn't belong to it!");
return cChunkPtr();
}
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 6edddac6b..e3662f5ed 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -315,7 +315,7 @@ void cClientHandle::StreamChunks(void) return;
}
- assert(m_Player != NULL);
+ ASSERT(m_Player != NULL);
int ChunkPosX = FAST_FLOOR_DIV(m_Player->GetPosX(), 16);
int ChunkPosZ = FAST_FLOOR_DIV(m_Player->GetPosZ(), 16);
@@ -331,7 +331,7 @@ void cClientHandle::StreamChunks(void) LOGINFO("Streaming chunks centered on [%d, %d]", ChunkPosX, ChunkPosZ);
cWorld * World = m_Player->GetWorld();
- assert(World != NULL);
+ ASSERT(World != NULL);
// Remove all loaded chunks that are no longer in range:
{
@@ -405,7 +405,7 @@ void cClientHandle::StreamChunks(void) void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
cWorld * World = m_Player->GetWorld();
- assert(World != NULL);
+ ASSERT(World != NULL);
cChunkPtr Chunk = World->GetChunk(a_ChunkX, 0, a_ChunkZ);
if (!Chunk->HasClient(this))
@@ -1829,7 +1829,7 @@ void cClientHandle::SendThread(void *lpParam) if (NrmSendPackets.size() == 0 && LowSendPackets.size() == 0)
{
- assert(!self->m_bKeepThreadGoing);
+ ASSERT(!self->m_bKeepThreadGoing);
if (self->m_bKeepThreadGoing)
{
LOGERROR("ERROR: Semaphore was signaled while no packets to send");
@@ -1939,7 +1939,7 @@ void cClientHandle::DataReceived(const char * a_Data, int a_Size) // Packet parsed successfully, add it to internal queue:
HandlePacket(pPacket);
// Erase the packet from the buffer:
- assert(m_ReceivedData.size() > (size_t)NumBytes);
+ ASSERT(m_ReceivedData.size() > (size_t)NumBytes);
m_ReceivedData.erase(0, NumBytes + 1);
}
} // while (!Received.empty())
diff --git a/source/cCriticalSection.cpp b/source/cCriticalSection.cpp index db182c299..f66e6b878 100644 --- a/source/cCriticalSection.cpp +++ b/source/cCriticalSection.cpp @@ -114,7 +114,7 @@ cCSLock::~cCSLock() void cCSLock::Lock(void)
{
- assert(!m_IsLocked);
+ ASSERT(!m_IsLocked);
m_IsLocked = true;
m_CS->Lock();
}
@@ -125,7 +125,7 @@ void cCSLock::Lock(void) void cCSLock::Unlock(void)
{
- assert(m_IsLocked);
+ ASSERT(m_IsLocked);
m_IsLocked = false;
m_CS->Unlock();
}
diff --git a/source/cEntity.cpp b/source/cEntity.cpp index 25d10fab4..00faf5baa 100644 --- a/source/cEntity.cpp +++ b/source/cEntity.cpp @@ -96,7 +96,7 @@ void cEntity::WrapRotation() void cEntity::MoveToCorrectChunk(bool a_bIgnoreOldChunk)
{
- assert(m_World != NULL); // Entity needs a world to move to a chunk
+ ASSERT(m_World != NULL); // Entity needs a world to move to a chunk
if( !m_World ) return;
int ChunkX = 0, ChunkY = 0, ChunkZ = 0;
diff --git a/source/cEntity.h b/source/cEntity.h index f08a9f337..84d9c766d 100644 --- a/source/cEntity.h +++ b/source/cEntity.h @@ -98,7 +98,7 @@ public: //tolua_export virtual void Tick(float a_Dt) = 0; //tolua_export
- virtual cPacket * GetSpawnPacket(void) const {assert(!"GetSpawnedPacket unimplemented!"); return NULL; }; // _X: Needs to be implemented due to Lua bindings
+ virtual cPacket * GetSpawnPacket(void) const {ASSERT(!"GetSpawnedPacket unimplemented!"); return NULL; }; // _X: Needs to be implemented due to Lua bindings
void SpawnOn (cClientHandle * a_Client); // tolua_export
void WrapRotation();
diff --git a/source/cEvent.cpp b/source/cEvent.cpp index bf3109cf4..c52a8a226 100644 --- a/source/cEvent.cpp +++ b/source/cEvent.cpp @@ -29,7 +29,7 @@ cEvent::cEvent(void) LOGWARN("WARNING cEvent: Could not create unnamed semaphore, fallback to named.");
// _X: I'm unconvinced about using sem_unlink() just after a successful sem_open(), it seems wrong - why destroy the object just after creating?
- assert(!"This codepath is really weird, if it is ever used, please check that everything works.");
+ ASSERT(!"This codepath is really weird, if it is ever used, please check that everything works.");
delete m_Event;
m_bIsNamed = true;
diff --git a/source/cFile.cpp b/source/cFile.cpp index 019b125ee..5ea71107a 100644 --- a/source/cFile.cpp +++ b/source/cFile.cpp @@ -57,7 +57,7 @@ cFile::~cFile() bool cFile::Open(const AString & iFileName, EMode iMode)
{
- assert(!IsOpen()); // You should close the file before opening another one
+ ASSERT(!IsOpen()); // You should close the file before opening another one
if (IsOpen())
{
@@ -72,7 +72,7 @@ bool cFile::Open(const AString & iFileName, EMode iMode) case fmReadWrite: Mode = "ab+"; break;
default:
{
- assert(!"Unhandled file mode");
+ ASSERT(!"Unhandled file mode");
return false;
}
}
@@ -86,7 +86,7 @@ bool cFile::Open(const AString & iFileName, EMode iMode) void cFile::Close(void)
{
- assert(IsOpen()); // You should not close file objects that don't have an open file.
+ ASSERT(IsOpen()); // You should not close file objects that don't have an open file.
if (!IsOpen())
{
@@ -112,7 +112,7 @@ bool cFile::IsOpen(void) const bool cFile::IsEOF(void) const
{
- assert(IsOpen());
+ ASSERT(IsOpen());
if (!IsOpen())
{
@@ -130,7 +130,7 @@ bool cFile::IsEOF(void) const /// Reads up to iNumBytes bytes into iBuffer, returns the number of bytes actually read, or -1 on failure; asserts if not open
int cFile::Read (void * iBuffer, int iNumBytes)
{
- assert(IsOpen());
+ ASSERT(IsOpen());
if (!IsOpen())
{
@@ -147,7 +147,7 @@ int cFile::Read (void * iBuffer, int iNumBytes) /// Writes up to iNumBytes bytes from iBuffer, returns the number of bytes actually written, or -1 on failure; asserts if not open
int cFile::Write(const void * iBuffer, int iNumBytes)
{
- assert(IsOpen());
+ ASSERT(IsOpen());
if (!IsOpen())
{
@@ -165,7 +165,7 @@ int cFile::Write(const void * iBuffer, int iNumBytes) /// Seeks to iPosition bytes from file start, returns old position or -1 for failure
int cFile::Seek (int iPosition)
{
- assert(IsOpen());
+ ASSERT(IsOpen());
if (!IsOpen())
{
@@ -187,7 +187,7 @@ int cFile::Seek (int iPosition) /// Returns the current position (bytes from file start)
int cFile::Tell (void) const
{
- assert(IsOpen());
+ ASSERT(IsOpen());
if (!IsOpen())
{
@@ -204,7 +204,7 @@ int cFile::Tell (void) const /// Returns the size of file, in bytes, or -1 for failure; asserts if not open
int cFile::GetSize(void) const
{
- assert(IsOpen());
+ ASSERT(IsOpen());
if (!IsOpen())
{
@@ -234,7 +234,7 @@ int cFile::GetSize(void) const int cFile::ReadRestOfFile(AString & a_Contents)
{
- assert(IsOpen());
+ ASSERT(IsOpen());
if (!IsOpen())
{
diff --git a/source/cIsThread.cpp b/source/cIsThread.cpp index 13e9a0a07..61dd23b2a 100644 --- a/source/cIsThread.cpp +++ b/source/cIsThread.cpp @@ -78,7 +78,7 @@ cIsThread::~cIsThread() bool cIsThread::Start(void)
{
#ifdef _WIN32
- assert(mHandle == NULL); // Has already started one thread?
+ ASSERT(mHandle == NULL); // Has already started one thread?
// Create the thread suspended, so that the mHandle variable is valid in the thread procedure
DWORD ThreadID = 0;
@@ -99,7 +99,7 @@ bool cIsThread::Start(void) #endif // _DEBUG and _MSC_VER
#else // _WIN32
- assert(!mHasStarted);
+ ASSERT(!mHasStarted);
if (pthread_create(&mHandle, NULL, thrExecute, this))
{
diff --git a/source/cMCLogger.h b/source/cMCLogger.h index 3157ce6a8..b483fb0b8 100644 --- a/source/cMCLogger.h +++ b/source/cMCLogger.h @@ -12,10 +12,6 @@ class cLog; class cMCLogger //tolua_export
{ //tolua_export
-private:
-#ifdef _WIN32
- typedef char* va_list;
-#endif
public: //tolua_export
cMCLogger();
cMCLogger( char* a_File ); //tolua_export
diff --git a/source/cSocket.cpp b/source/cSocket.cpp index 7e45d0b67..0e3d2730c 100644 --- a/source/cSocket.cpp +++ b/source/cSocket.cpp @@ -337,7 +337,7 @@ int cSocket::Send(const cPacket & a_Packet) unsigned short cSocket::GetPort(void) const
{
- assert(IsValid());
+ ASSERT(IsValid());
sockaddr_in Addr;
socklen_t AddrSize = sizeof(Addr);
diff --git a/source/cSocketThreads.cpp b/source/cSocketThreads.cpp index 9d9258499..aa0aba678 100644 --- a/source/cSocketThreads.cpp +++ b/source/cSocketThreads.cpp @@ -156,7 +156,7 @@ cSocketThreads::cSocketThread::~cSocketThread() void cSocketThreads::cSocketThread::AddClient(cSocket * a_Socket, cCallback * a_Client)
{
- assert(m_NumSlots < MAX_SLOTS); // Use HasEmptySlot() to check before adding
+ ASSERT(m_NumSlots < MAX_SLOTS); // Use HasEmptySlot() to check before adding
m_Slots[m_NumSlots].m_Client = a_Client;
m_Slots[m_NumSlots].m_Socket = a_Socket;
@@ -164,7 +164,7 @@ void cSocketThreads::cSocketThread::AddClient(cSocket * a_Socket, cCallback * a_ m_NumSlots++;
// Notify the thread of the change:
- assert(m_ControlSocket2.IsValid());
+ ASSERT(m_ControlSocket2.IsValid());
m_ControlSocket2.Send("a", 1);
}
@@ -193,7 +193,7 @@ bool cSocketThreads::cSocketThread::RemoveClient(const cCallback * a_Client) m_NumSlots--;
// Notify the thread of the change:
- assert(m_ControlSocket2.IsValid());
+ ASSERT(m_ControlSocket2.IsValid());
m_ControlSocket2.Send("r", 1);
return true;
} // for i - m_Slots[]
@@ -227,7 +227,7 @@ bool cSocketThreads::cSocketThread::RemoveSocket(const cSocket * a_Socket) m_NumSlots--;
// Notify the thread of the change:
- assert(m_ControlSocket2.IsValid());
+ ASSERT(m_ControlSocket2.IsValid());
m_ControlSocket2.Send("r", 1);
return true;
} // for i - m_Slots[]
@@ -245,7 +245,7 @@ bool cSocketThreads::cSocketThread::NotifyWrite(const cCallback * a_Client) if (HasClient(a_Client))
{
// Notify the thread that there's another packet in the queue:
- assert(m_ControlSocket2.IsValid());
+ ASSERT(m_ControlSocket2.IsValid());
m_ControlSocket2.Send("q", 1);
return true;
}
@@ -354,7 +354,7 @@ void cSocketThreads::cSocketThread::Execute(void) Addr.Family = cSocket::ADDRESS_FAMILY_INTERNET;
Addr.Address = cSocket::INTERNET_ADDRESS_LOCALHOST();
Addr.Port = m_ControlSocket2.GetPort();
- assert(Addr.Port != 0); // We checked in the Start() method, but let's be sure
+ ASSERT(Addr.Port != 0); // We checked in the Start() method, but let's be sure
if (m_ControlSocket1.Connect(Addr) != 0)
{
LOGERROR("Cannot connect Control sockets for a cSocketThread (\"%s\"); continuing, but the server may be unreachable from now on.", cSocket::GetLastErrorString().c_str());
@@ -509,7 +509,7 @@ void cSocketThreads::cSocketThread::WriteToSockets(fd_set * a_Write) // If there's any data left, signalize the Control socket:
if (!m_Slots[i].m_Outgoing.empty())
{
- assert(m_ControlSocket2.IsValid());
+ ASSERT(m_ControlSocket2.IsValid());
m_ControlSocket2.Send("q", 1);
}
*/
diff --git a/source/cWorldGenerator.cpp b/source/cWorldGenerator.cpp index b1f868cad..6fecfc2e6 100644 --- a/source/cWorldGenerator.cpp +++ b/source/cWorldGenerator.cpp @@ -154,7 +154,7 @@ static float GetOreNoise( float x, float y, float z, cNoise & a_Noise ) unsigned int cWorldGenerator::MakeIndex(int x, int y, int z )
{
- assert((x < 16) && (x > -1) && (y < 128) && (y > -1) && (z < 16) && (z > -1));
+ ASSERT((x < 16) && (x > -1) && (y < 128) && (y > -1) && (z < 16) && (z > -1));
return y + (z * 128) + (x * 128 * 16);
}
diff --git a/source/packets/cPacket.h b/source/packets/cPacket.h index fbdde5ac3..7eb224c9e 100644 --- a/source/packets/cPacket.h +++ b/source/packets/cPacket.h @@ -42,7 +42,7 @@ public: virtual int Parse(const char * a_Data, int a_Size)
{
LOGERROR("Undefined Parse function for packet type 0x%x\n", m_PacketID );
- assert(!"Undefined Parse function");
+ ASSERT(!"Undefined Parse function");
return -1;
}
@@ -50,7 +50,7 @@ public: virtual void Serialize(AString & a_Data) const
{
LOGERROR("Undefined Serialize function for packet type 0x%x\n", m_PacketID );
- assert(!"Undefined Serialize function");
+ ASSERT(!"Undefined Serialize function");
}
virtual cPacket * Clone() const = 0;
diff --git a/source/packets/cPacket_CreativeInventoryAction.cpp b/source/packets/cPacket_CreativeInventoryAction.cpp index 14d544877..af500e503 100644 --- a/source/packets/cPacket_CreativeInventoryAction.cpp +++ b/source/packets/cPacket_CreativeInventoryAction.cpp @@ -48,7 +48,7 @@ int cPacket_CreativeInventoryAction::Parse(const char * a_Data, int a_Size) void cPacket_CreativeInventoryAction::Serialize(AString & a_Data) const
{
short ItemID = m_ItemID;
- assert(ItemID >= -1); // Check validity of packets in debug runtime
+ ASSERT(ItemID >= -1); // Check validity of packets in debug runtime
if (ItemID <= 0)
{
ItemID = -1;
diff --git a/source/packets/cPacket_MapChunk.cpp b/source/packets/cPacket_MapChunk.cpp index 522842d32..54ebc6be5 100644 --- a/source/packets/cPacket_MapChunk.cpp +++ b/source/packets/cPacket_MapChunk.cpp @@ -21,7 +21,7 @@ cPacket_MapChunk::~cPacket_MapChunk() cPacket_MapChunk::cPacket_MapChunk(cChunk * a_Chunk)
{
- assert(a_Chunk->IsValid());
+ ASSERT(a_Chunk->IsValid());
m_PacketID = E_MAP_CHUNK;
m_PosX = a_Chunk->GetPosX() * 16; // It has to be block coordinates
diff --git a/source/packets/cPacket_NamedEntitySpawn.cpp b/source/packets/cPacket_NamedEntitySpawn.cpp index 19d12e4bd..8b4b912d8 100644 --- a/source/packets/cPacket_NamedEntitySpawn.cpp +++ b/source/packets/cPacket_NamedEntitySpawn.cpp @@ -10,7 +10,7 @@ void cPacket_NamedEntitySpawn::Serialize(AString & a_Data) const
{
short CurrentItem = m_CurrentItem;
- assert(CurrentItem >= 0);
+ ASSERT(CurrentItem >= 0);
if (CurrentItem <= 0)
{
CurrentItem = 0;
|