Procházet zdrojové kódy

Switch entire codebase to use ce_assert

Daniele Bartolini před 12 roky
rodič
revize
f797080ace
62 změnil soubory, kde provedl 314 přidání a 418 odebrání
  1. 4 4
      CMakeLists.txt
  2. 0 2
      samples/lua/lua.cpp
  3. 0 7
      samples/terrain/Terrain.cpp
  4. 2 2
      src/Device.cpp
  5. 4 4
      src/Filesystem.cpp
  6. 5 5
      src/ResourceManager.cpp
  7. 2 2
      src/ScriptResource.cpp
  8. 11 14
      src/TextResource.cpp
  9. 15 18
      src/TextureResource.cpp
  10. 2 5
      src/core/Args.cpp
  11. 1 1
      src/core/Args.h
  12. 5 7
      src/core/Assert.h
  13. 2 2
      src/core/bv/Box.h
  14. 1 1
      src/core/bv/Frustum.cpp
  15. 2 1
      src/core/bv/Rect.cpp
  16. 0 2
      src/core/bv/Rect.h
  17. 3 2
      src/core/compressors/ZipCompressor.cpp
  18. 4 8
      src/core/containers/IdTable.h
  19. 8 8
      src/core/containers/List.h
  20. 7 7
      src/core/containers/Queue.h
  21. 7 7
      src/core/containers/RBTree.h
  22. 4 4
      src/core/math/Mat3.cpp
  23. 4 4
      src/core/math/Mat4.cpp
  24. 2 2
      src/core/math/MathUtils.h
  25. 5 5
      src/core/math/Point2.h
  26. 5 5
      src/core/math/Vec2.h
  27. 5 5
      src/core/math/Vec3.h
  28. 5 5
      src/core/math/Vec4.h
  29. 0 1
      src/core/mem/Memory.h
  30. 2 1
      src/core/mem/ProxyAllocator.cpp
  31. 7 12
      src/core/streams/FileStream.cpp
  32. 3 3
      src/core/streams/FileStream.h
  33. 4 4
      src/core/streams/MemoryStream.cpp
  34. 5 5
      src/core/streams/MemoryStream.h
  35. 2 4
      src/core/streams/NullStream.h
  36. 7 13
      src/core/streams/Stream.cpp
  37. 3 3
      src/core/streams/Stream.h
  38. 4 4
      src/core/strings/Hash.h
  39. 16 16
      src/core/strings/Path.h
  40. 12 12
      src/core/strings/String.h
  41. 4 4
      src/input/EventDispatcher.cpp
  42. 2 4
      src/network/BitMessage.cpp
  43. 1 1
      src/network/BitMessage.h
  44. 8 27
      src/os/android/File.cpp
  45. 1 1
      src/os/linux/GLXRenderWindow.cpp
  46. 3 3
      src/os/linux/LinuxOS.cpp
  47. 10 28
      src/os/posix/File.cpp
  48. 3 5
      src/os/posix/TCPSocket.cpp
  49. 4 8
      src/os/posix/UDPSocket.cpp
  50. 5 5
      src/os/win/WinTCPSocket.cpp
  51. 8 8
      src/os/win/WinUDPSocket.cpp
  52. 12 14
      src/renderers/gl/GLRenderer.cpp
  53. 0 17
      src/renderers/gl/GLUtils.h
  54. 2 2
      src/renderers/gles/GLESRenderer.cpp
  55. 7 7
      src/renderers/gles/GLESUtils.h
  56. 3 3
      tests/allocators.cpp
  57. 9 9
      tests/containers.cpp
  58. 33 33
      tests/paths.cpp
  59. 13 13
      tests/strings.cpp
  60. 3 3
      tools/editors/fontgen/fontgen.cpp
  61. 1 1
      tools/editors/world-editor/CrownDrawingArea.cpp
  62. 2 5
      tools/editors/world-editor/terrain/Heightfield.cpp

+ 4 - 4
CMakeLists.txt

@@ -33,6 +33,9 @@ set (INCLUDES
 	${CMAKE_SOURCE_DIR}/game
 )
 
+# always debug mode for now
+set (CROWN_DEBUG 1)
+
 # detect architecture
 if (CROWN_ARCH MATCHES "x86")
 	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/third/x86)
@@ -67,7 +70,7 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 
 include_directories(${INCLUDES} ${CROWN_LUAJIT_INCLUDES})
 link_directories(${CROWN_LUAJIT_LIBS})
-add_definitions(-pipe -ansi -W -Wall -Wextra -Wno-long-long -pedantic -fPIC -g -pg)
+add_definitions(-pipe -ansi -W -Wall -Wextra -Wno-long-long -Wno-variadic-macros -fPIC -g -pg)
 
 # add build directories
 add_subdirectory(src)
@@ -101,6 +104,3 @@ if (CROWN_BUILD_TESTS)
 	add_subdirectory(tests)
 endif (CROWN_BUILD_TESTS)
 
-# always debug mode for now
-set (CROWN_DEBUG)
-

+ 0 - 2
samples/lua/lua.cpp

@@ -39,8 +39,6 @@ int main(int argc, char** argv)
       lua_state = luaL_newstate();
       luaL_openlibs(lua_state);
 
-      assert(res_manager.data(script) != NULL);
-
       ScriptResource* resource = (ScriptResource*)res_manager.data(script);
 
       int s = luaL_loadbuffer(lua_state, (char*)resource->data(), 47, "");

+ 0 - 7
samples/terrain/Terrain.cpp

@@ -61,10 +61,6 @@ Terrain::~Terrain()
 
 void Terrain::CreateTerrain(uint32_t xSize, uint32_t zSize, uint32_t tilePerMeter, float initialHeight)
 {
-	assert(xSize > 0);
-	assert(zSize > 0);
-	assert(tilePerMeter > 0);
-
 	mSizeX = xSize;
 	mSizeZ = zSize;
 	mTilePerMeter = tilePerMeter;
@@ -305,9 +301,6 @@ float Terrain::GaussDist(float x, float y, float sigma)
 
 void Terrain::BuildBrush(uint32_t width, uint32_t height, float smooth)
 {
-	assert(width < MAX_BRUSH_SIZE);
-	assert(height < MAX_BRUSH_SIZE);
-
 	mBrushWidth = width;
 	mBrushHeight = height;
 

+ 2 - 2
src/Device.cpp

@@ -439,7 +439,7 @@ void Device::create_renderer()
 		m_renderer = new GLRenderer;
 		#else
 		Log::e("Crown Engine was not built with OpenGL support.");
-		assert(false);
+		exit(EXIT_FAILURE);
 		#endif
 	}
 	else if (m_preferred_renderer == RENDERER_GLES)
@@ -448,7 +448,7 @@ void Device::create_renderer()
 		m_renderer = new GLESRenderer;
 		#else
 		Log::e("Crown Engine was not built with OpenGL|ES support.");
-		assert(false);
+		exit(EXIT_FAILURE);
 		#endif
 	}
 }

+ 4 - 4
src/Filesystem.cpp

@@ -34,8 +34,8 @@ namespace crown
 //-----------------------------------------------------------------------------
 Filesystem::Filesystem(const char* root_path)
 {
-	assert(root_path != NULL);
-	assert(os::is_absolute_path(root_path));
+	ce_assert(root_path != NULL, "Root path must be != NULL");
+	ce_assert(os::is_absolute_path(root_path), "Root path must be absolute");
 
 	string::strncpy(m_root_path, root_path, os::MAX_PATH_LENGTH);
 }
@@ -188,8 +188,8 @@ FileStream* Filesystem::open(const char* relative_path, StreamOpenMode mode)
 {
 	FilesystemEntry info;
 
-	assert(get_info(relative_path, info));
-	assert(info.type == FilesystemEntry::FILE);
+	ce_assert(get_info(relative_path, info), "File does not exist: %s", relative_path);
+	ce_assert(info.type == FilesystemEntry::FILE, "File is not a regular file: %s", relative_path);
 
 	return new FileStream(mode, info.os_path);
 }

+ 5 - 5
src/ResourceManager.cpp

@@ -91,7 +91,7 @@ ResourceId ResourceManager::load(const char* name)
 //-----------------------------------------------------------------------------
 void ResourceManager::unload(ResourceId name)
 {
-	assert(has(name));
+	ce_assert(has(name), "Resource not loaded: %.8X%.8X", name.name, name.type);
 	
 	m_resources_mutex.lock();
 
@@ -115,7 +115,7 @@ void ResourceManager::unload(ResourceId name)
 //-----------------------------------------------------------------------------
 void ResourceManager::reload(ResourceId name)
 {
-	assert(has(name));
+	ce_assert(has(name), "Resource not loaded: %.8X%.8X", name.name, name.type);
 	
 	m_resources_mutex.lock();
 
@@ -155,7 +155,7 @@ bool ResourceManager::has(ResourceId name) const
 //-----------------------------------------------------------------------------
 const void* ResourceManager::data(ResourceId name) const
 {
-	assert(has(name));
+	ce_assert(has(name), "Resource not loaded: %.8X%.8X", name.name, name.type);
 	
 	m_resources_mutex.lock();
 
@@ -169,7 +169,7 @@ const void* ResourceManager::data(ResourceId name) const
 //-----------------------------------------------------------------------------
 bool ResourceManager::is_loaded(ResourceId name) const
 {
-	assert(has(name));
+	ce_assert(has(name), "Resource not loaded: %.8X%.8X", name.name, name.type);
 
 	m_resources_mutex.lock();
 
@@ -183,7 +183,7 @@ bool ResourceManager::is_loaded(ResourceId name) const
 //-----------------------------------------------------------------------------
 uint32_t ResourceManager::references(ResourceId name) const
 {
-	assert(has(name));
+	ce_assert(has(name), "Resource not loaded: %.8X%.8X", name.name, name.type);
 
 	m_resources_mutex.lock();
 

+ 2 - 2
src/ScriptResource.cpp

@@ -1,4 +1,4 @@
-#include <cassert>
+#include "Assert.h"
 
 #include "ScriptResource.h"
 #include "ResourceArchive.h"
@@ -41,7 +41,7 @@ void ScriptResource::online(void* resource)
 //-----------------------------------------------------------------------------
 void ScriptResource::unload(Allocator& allocator, void* resource)
 {
-	assert(resource != NULL);
+	ce_assert(resource != NULL, "");
 
 	allocator.deallocate(((ScriptResource*)resource)->m_data);
 	allocator.deallocate(resource);

+ 11 - 14
src/TextResource.cpp

@@ -12,30 +12,27 @@ void* TextResource::load(Allocator& allocator, ResourceArchive& archive, Resourc
 {
 	FileStream* stream = archive.open(id);
 
-	if (stream != NULL)
-	{
-		TextResource* resource = (TextResource*)allocator.allocate(sizeof(TextResource));
+	ce_assert(stream != NULL, "Resource does not exist: %.8X%.8X", id.name, id.type);
 
-		stream->read(&resource->length, sizeof(uint32_t));
-		
-		resource->data = (char*)allocator.allocate(sizeof(char) * (resource->length + 1));
+	TextResource* resource = (TextResource*)allocator.allocate(sizeof(TextResource));
 
-		stream->read(resource->data, (size_t)resource->length);
-		
-		resource->data[resource->length] = '\0';
+	stream->read(&resource->length, sizeof(uint32_t));
+	
+	resource->data = (char*)allocator.allocate(sizeof(char) * (resource->length + 1));
 
-		archive.close(stream);
+	stream->read(resource->data, (size_t)resource->length);
+	
+	resource->data[resource->length] = '\0';
 
-		return resource;
-	}
+	archive.close(stream);
 
-	return NULL;
+	return resource;
 }
 
 //-----------------------------------------------------------------------------
 void TextResource::unload(Allocator& allocator, void* resource)
 {
-	assert(resource != NULL);
+	ce_assert(resource != NULL, "Resource not loaded");
 
 	((TextResource*)resource)->length = 0;
 

+ 15 - 18
src/TextureResource.cpp

@@ -2,7 +2,7 @@
 #include "ResourceArchive.h"
 #include "Log.h"
 #include "FileStream.h"
-#include <cassert>
+#include "Assert.h"
 #include "Allocator.h"
 #include "Device.h"
 #include "Renderer.h"
@@ -15,38 +15,35 @@ void* TextureResource::load(Allocator& allocator, ResourceArchive& archive, Reso
 {
 	FileStream* stream = archive.open(id);
 
-	if (stream != NULL)
-	{
-		TextureResource* resource = (TextureResource*)allocator.allocate(sizeof(TextureResource));
-	
-		stream->read(&resource->m_format, sizeof(PixelFormat));
-		stream->read(&resource->m_width, sizeof(uint16_t));
-		stream->read(&resource->m_height, sizeof(uint16_t));
-	
-		size_t size = resource->m_width * resource->m_height * Pixel::bytes_per_pixel(resource->m_format);
+	ce_assert(stream != NULL, "Resource does not exist: %.8X%.8X", id.name, id.type);
 
-		resource->m_data = (uint8_t*)allocator.allocate(sizeof(uint8_t) * size);
+	TextureResource* resource = (TextureResource*)allocator.allocate(sizeof(TextureResource));
 
-		stream->read(resource->m_data, size);
+	stream->read(&resource->m_format, sizeof(PixelFormat));
+	stream->read(&resource->m_width, sizeof(uint16_t));
+	stream->read(&resource->m_height, sizeof(uint16_t));
 
-		archive.close(stream);
+	size_t size = resource->m_width * resource->m_height * Pixel::bytes_per_pixel(resource->m_format);
 
-		return resource;
-	}
+	resource->m_data = (uint8_t*)allocator.allocate(sizeof(uint8_t) * size);
 
-	return NULL;
+	stream->read(resource->m_data, size);
+
+	archive.close(stream);
+
+	return resource;
 }
 
 //-----------------------------------------------------------------------------
 void TextureResource::online(void* resource)
 {
-	assert(resource != NULL);
+	ce_assert(resource != NULL, "Resource not loaded");
 }
 
 //-----------------------------------------------------------------------------
 void TextureResource::unload(Allocator& allocator, void* resource)
 {
-	assert(resource != NULL);
+	ce_assert(resource != NULL, "Resource not loaded");
 
 	allocator.deallocate(((TextureResource*)resource)->m_data);
 	allocator.deallocate(resource);

+ 2 - 5
src/core/Args.cpp

@@ -39,8 +39,8 @@ Args::Args(int argc, char** argv, const char* shortopts, const ArgsOption* longo
 	m_scope(argc),
 	m_optarg(NULL)
 {
-	assert(argv != NULL);
-	assert(shortopts != NULL);
+	ce_assert(argv != NULL, "Argument vector must be != NULL");
+	ce_assert(shortopts != NULL, "Short argument list must be != NULL");
 	// longopts could be NULL
 }
 
@@ -121,9 +121,6 @@ ArgsOptionType Args::option_type(const char* option)
 //-----------------------------------------------------------------------------
 int32_t Args::long_option(const char* option)
 {
-	// Long argument detected, but it is not so.
-	assert(string::strlen(option) > 2);
-
 	const ArgsOption* current_option = m_longopts;
 
 	// Loop through all the long options

+ 1 - 1
src/core/Args.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 #include "Types.h"
 #include "String.h"
 

+ 5 - 7
src/core/Assert.h

@@ -24,18 +24,16 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include <cstdlib>
+#include <cstdio>
 #include "Config.h"
-#include "OS.h"
 
 #pragma once
 
 #ifdef CROWN_DEBUG
-
-	#define ce_error(file, line, message, ...) do { os::printf(message, __VA_ARGS__);\
-		os::printf("\n\tIn %s:%d\n", file, line); abort(); } while(0)
-
-	#define ce_assert(condition, message, ...) do { if ((!condition)) { ce_error(__FILE__, __LINE__,\
-		"Assertion failed: %s\n\t" message, #condition, __VA_ARGS__); } } while(0)
+	#define ce_error(file, line, message, ...) do { printf(message, __VA_ARGS__);\
+				printf("\n\tIn %s:%d\n\n", file, line); abort(); } while(0)
+	#define ce_assert(condition, message, ...) do { if (!(condition)) { ce_error(__FILE__, __LINE__,\
+				"Assertion failed: %s\n\t" message, #condition, ##__VA_ARGS__); } } while(0)
 #else
 	#define ce_assert(condition, message, ...) ((void)0)
 #endif

+ 2 - 2
src/core/bv/Box.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 #include "Types.h"
 #include "Mat4.h"
 #include "Vec3.h"
@@ -271,7 +271,7 @@ inline void Box::to_vertices(Vec3 v[8]) const
 //-----------------------------------------------------------------------------
 inline Vec3 Box::vertex(uint32_t index) const
 {
-	assert(index < 8);
+	ce_assert(index < 8, "Index must be < 8");
 
 	switch (index)
 	{

+ 1 - 1
src/core/bv/Frustum.cpp

@@ -63,7 +63,7 @@ bool Frustum::contains_point(const Vec3& point) const
 //-----------------------------------------------------------------------------
 Vec3 Frustum::vertex(uint32_t index) const
 {
-	assert(index < 8);
+	ce_assert(index < 8, "Index must be < 8");
 
 	// 0 = Near bottom left
 	// 1 = Near bottom right

+ 2 - 1
src/core/bv/Rect.cpp

@@ -23,6 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
+#include "Assert.h"
 #include "Rect.h"
 #include "Circle.h"
 #include "MathUtils.h"
@@ -74,7 +75,7 @@ void Rect::vertices(Vec2 v[4]) const
 //-----------------------------------------------------------------------------
 Vec2 Rect::vertex(uint32_t index) const
 {
-	assert(index < 4);
+	ce_assert(index < 4, "Index must be < 4");
 
 	switch (index)
 	{

+ 0 - 2
src/core/bv/Rect.h

@@ -25,11 +25,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
 #include "Types.h"
 #include "Vec2.h"
 
-
 namespace crown
 {
 

+ 3 - 2
src/core/compressors/ZipCompressor.cpp

@@ -26,6 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include <cstring>
 
 #include "zlib.h"
+#include "Assert.h"
 #include "ZipCompressor.h"
 
 namespace crown
@@ -51,7 +52,7 @@ uint8_t* ZipCompressor::compress(const void* data, size_t in_size, size_t& out_s
 	
 	int32_t ret = ::compress((Bytef*)dest, (uLongf*)&out_size, (const Bytef*)data, (uLongf)in_size);
 	
-	assert(ret == Z_OK);
+	ce_assert(ret == Z_OK, "Failed to compress the data");
 	
 	return dest;
 }
@@ -65,7 +66,7 @@ uint8_t* ZipCompressor::uncompress(const void* data, size_t in_size, size_t& out
 	
 	int32_t ret = ::uncompress((Bytef*)dest, (uLongf*)&out_size, (const Bytef*)data, (uLongf)in_size);
 	
-	assert(ret == Z_OK);
+	ce_assert(ret == Z_OK, "Failed to uncompress the data");
 	
 	return dest;
 }

+ 4 - 8
src/core/containers/IdTable.h

@@ -25,6 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
+#include "Assert.h"
 #include "Allocator.h"
 #include "Types.h"
 
@@ -110,9 +111,6 @@ inline IdTable::~IdTable()
 //-----------------------------------------------------------------------------
 inline Id IdTable::create()
 {
-	// We have reached maximum number of ids
-	assert(m_next_id != m_max_ids);
-
 	// Obtain a new id
 	Id id;
 	id.id = next_id();
@@ -136,7 +134,7 @@ inline Id IdTable::create()
 //-----------------------------------------------------------------------------
 inline void IdTable::destroy(Id id)
 {
-	assert(has(id));
+	ce_assert(has(id), "IdTable does not have ID: %d,%d", id.id, id.index);
 
 	m_ids[id.index].next = m_freelist;
 	m_freelist = id.index;
@@ -145,15 +143,13 @@ inline void IdTable::destroy(Id id)
 //-----------------------------------------------------------------------------
 inline bool IdTable::has(Id id) const
 {
-	assert (id.index < m_max_ids);
-
-	return m_ids[id.index].id == id.id;
+	return id.index < m_max_ids && m_ids[id.index].id == id.id;
 }
 
 //-----------------------------------------------------------------------------
 inline uint16_t IdTable::next_id()
 {
-	assert(m_next_id < m_max_ids);
+	ce_assert(m_next_id < m_max_ids, "Maximum number of IDs reached");
 
 	return m_next_id++;
 }

+ 8 - 8
src/core/containers/List.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Allocator.h"
 #include "Types.h"
-#include <cassert>
+#include "Assert.h"
 #include <cstring>
 
 namespace crown
@@ -165,7 +165,7 @@ inline List<T>::~List()
 template <typename T>
 inline T& List<T>::operator[](uint32_t index)
 {
-	//assert(index < m_size);
+	//ce_assert(index < m_size);
 
 	return m_array[index];
 }
@@ -174,7 +174,7 @@ inline T& List<T>::operator[](uint32_t index)
 template <typename T>
 inline const T& List<T>::operator[](uint32_t index) const
 {
-	//assert(index < m_size);
+	//ce_assert(index < m_size);
 
 	return m_array[index];
 }
@@ -291,7 +291,7 @@ inline uint32_t List<T>::push_back(const T& item)
 template <typename T>
 inline void List<T>::pop_back()
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The list is empty");
 
 	m_size--;
 }
@@ -372,7 +372,7 @@ inline T* List<T>::end()
 template <typename T>
 inline T& List<T>::front()
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The list is empty");
 
 	return m_array[0];
 }
@@ -381,7 +381,7 @@ inline T& List<T>::front()
 template <typename T>
 inline const T& List<T>::front() const
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The list is empty");
 
 	return m_array[0];
 }
@@ -390,7 +390,7 @@ inline const T& List<T>::front() const
 template <typename T>
 inline T& List<T>::back()
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The list is empty");
 
 	return m_array[m_size - 1];
 }
@@ -399,7 +399,7 @@ inline T& List<T>::back()
 template <typename T>
 inline const T& List<T>::back() const
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The list is empty");
 
 	return m_array[m_size - 1];
 }

+ 7 - 7
src/core/containers/Queue.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Types.h"
 #include "List.h"
 #include "Allocator.h"
-#include <cassert>
+#include "Assert.h"
 #include <cstring>
 
 namespace crown
@@ -207,7 +207,7 @@ inline void Queue<T>::push_back(const T& item)
 template <typename T>
 inline void Queue<T>::pop_back()
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The queue is empty");
 
 	m_size--;
 }
@@ -232,7 +232,7 @@ inline void Queue<T>::push_front(const T& item)
 template <typename T>
 inline void Queue<T>::pop_front()
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The queue is empty");
 
 	m_read = (m_read + 1) % m_queue.size();
 
@@ -283,7 +283,7 @@ inline const T* Queue<T>::end() const
 template <typename T>
 inline T& Queue<T>::front()
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The queue is empty");
 
 	return m_queue[m_read];
 }
@@ -292,7 +292,7 @@ inline T& Queue<T>::front()
 template <typename T>
 inline const T& Queue<T>::front() const
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The queue is empty");
 
 	return m_queue[m_read];
 }
@@ -301,7 +301,7 @@ inline const T& Queue<T>::front() const
 template <typename T>
 inline T& Queue<T>::back()
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The queue is empty");
 
 	return (*this)[m_size - 1];
 }
@@ -310,7 +310,7 @@ inline T& Queue<T>::back()
 template <typename T>
 inline const T& Queue<T>::back() const
 {
-	assert(m_size > 0);
+	ce_assert(m_size > 0, "The queue is empty");
 
 	return (*this)[m_size - 1];
 }

+ 7 - 7
src/core/containers/RBTree.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include <cstdlib>
-#include <cassert>
+#include "Assert.h"
 #include "Types.h"
 
 namespace crown
@@ -656,19 +656,19 @@ int32_t RBTree<TKey, TValue>::dbg_verify(Node* n) const
 
 	if (n->left != m_sentinel)
 	{
-		assert(n->left->parent == n);
-		assert(n->item.key > n->left->item.key);
+		ce_assert(n->left->parent == n);
+		ce_assert(n->item.key > n->left->item.key);
 	}
 
 	if (n->right != m_sentinel)
 	{
-		assert(n->right->parent == n);
-		assert(n->item.key < n->right->item.key);
+		ce_assert(n->right->parent == n);
+		ce_assert(n->item.key < n->right->item.key);
 	}
 
 	int32_t bhL = dbg_verify(n->left);
 	int32_t bhR = dbg_verify(n->right);
-	assert(bhL == bhR);
+	ce_assert(bhL == bhR);
 
 	if (n->color == BLACK)
 	{
@@ -678,7 +678,7 @@ int32_t RBTree<TKey, TValue>::dbg_verify(Node* n) const
 	{
 		if (n->parent != NULL && n->parent->color == RED)
 		{
-			assert(false);
+			ce_assert(false);
 		}
 	}
 

+ 4 - 4
src/core/math/Mat3.cpp

@@ -23,7 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include <cassert>
+#include "Assert.h"
 #include "Mat3.h"
 #include "Types.h"
 #include "Mat4.h"
@@ -103,7 +103,7 @@ Mat3& Mat3::operator=(const Mat3& a)
 //-----------------------------------------------------------------------------
 real Mat3::operator[](uint32_t i) const
 {
-	assert(i < 9);
+	ce_assert(i < 9, "Index must be < 9");
 
 	return m[i];
 }
@@ -111,7 +111,7 @@ real Mat3::operator[](uint32_t i) const
 //-----------------------------------------------------------------------------
 real& Mat3::operator[](uint32_t i)
 {
-	assert(i < 9);
+	ce_assert(i < 9, "Index must be < 9");
 
 	return m[i];
 }
@@ -119,7 +119,7 @@ real& Mat3::operator[](uint32_t i)
 //-----------------------------------------------------------------------------
 real Mat3::operator()(uint32_t row, uint32_t column) const
 {
-	assert(row < 3 && column < 3);
+	ce_assert(row < 3 && column < 3, "Row and column must be < 3");
 
 	return m[row + column * 3];
 }

+ 4 - 4
src/core/math/Mat4.cpp

@@ -23,7 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include <cassert>
+#include "Assert.h"
 #include "Mat3.h"
 #include "Types.h"
 #include "Mat4.h"
@@ -132,7 +132,7 @@ Mat4& Mat4::operator=(const Mat4& a)
 //-----------------------------------------------------------------------------
 real Mat4::operator[](uint32_t i) const
 {
-	assert(i < 16);
+	ce_assert(i < 16, "Index must be < 16");
 
 	return m[i];
 }
@@ -140,7 +140,7 @@ real Mat4::operator[](uint32_t i) const
 //-----------------------------------------------------------------------------
 real& Mat4::operator[](uint32_t i)
 {
-	assert(i < 16);
+	ce_assert(i < 16, "Index must be < 16");
 
 	return m[i];
 }
@@ -148,7 +148,7 @@ real& Mat4::operator[](uint32_t i)
 //-----------------------------------------------------------------------------
 real Mat4::operator()(uint32_t row, uint32_t column) const
 {
-	assert(row < 4 && column < 4);
+	ce_assert(row < 4 && column < 4, "Row and column must be < 4");
 
 	return m[row + column * 4];
 }

+ 2 - 2
src/core/math/MathUtils.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 #include <cmath>
 #include "Types.h"
 #include <cstdio>
@@ -190,7 +190,7 @@ inline T avg(const T& a, const T& b)
 template <typename T>
 inline T clamp_to_range(const T& min, const T& max, const T& value)
 {
-	assert(min < max);
+	ce_assert(min < max, "Min must be < max");
 
 	if (value > max)
 	{

+ 5 - 5
src/core/math/Point2.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 #include "Types.h"
 #include "MathUtils.h"
 #include "Vec2.h"
@@ -119,7 +119,7 @@ inline Point2::~Point2()
 //-----------------------------------------------------------------------------
 inline int32_t Point2::operator[](uint32_t i) const
 {
-	assert(i < 2);
+	ce_assert(i < 2, "Index must be < 2");
 
 	return (&x)[i];
 }
@@ -127,7 +127,7 @@ inline int32_t Point2::operator[](uint32_t i) const
 //-----------------------------------------------------------------------------
 inline int32_t& Point2::operator[](uint32_t i)
 {
-	assert(i < 2);
+	ce_assert(i < 2, "Index must be < 2");
 
 	return (&x)[i];
 }
@@ -180,7 +180,7 @@ inline Point2& Point2::operator*=(int32_t k)
 //-----------------------------------------------------------------------------
 inline Point2 Point2::operator/(int32_t k) const
 {
-	assert(k != 0);
+	ce_assert(k != 0, "Division by zero");
 
 	return Point2(x / k, y / k);
 }
@@ -188,7 +188,7 @@ inline Point2 Point2::operator/(int32_t k) const
 //-----------------------------------------------------------------------------
 inline Point2& Point2::operator/=(int32_t k)
 {
-	assert(k != 0);
+	ce_assert(k != 0, "Division by zero");
 
 	x /= k;
 	y /= k;

+ 5 - 5
src/core/math/Vec2.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 #include "Types.h"
 #include "MathUtils.h"
 
@@ -154,7 +154,7 @@ inline Vec2::Vec2(const Vec2& a) : x(a.x), y(a.y)
 //-----------------------------------------------------------------------------
 inline real Vec2::operator[](uint32_t i) const
 {
-	assert(i < 2);
+	ce_assert(i < 2, "Index must be < 2");
 
 	return (&x)[i];
 }
@@ -162,7 +162,7 @@ inline real Vec2::operator[](uint32_t i) const
 //-----------------------------------------------------------------------------
 inline real& Vec2::operator[](uint32_t i)
 {
-	assert(i < 2);
+	ce_assert(i < 2, "Index must be < 2");
 
 	return (&x)[i];
 }
@@ -215,7 +215,7 @@ inline Vec2& Vec2::operator*=(real k)
 //-----------------------------------------------------------------------------
 inline Vec2 Vec2::operator/(real k) const
 {
-	assert(k != (real)0.0);
+	ce_assert(k != (real)0.0, "Division by zero");
 
 	real inv = (real)(1.0 / k);
 
@@ -225,7 +225,7 @@ inline Vec2 Vec2::operator/(real k) const
 //-----------------------------------------------------------------------------
 inline Vec2& Vec2::operator/=(real k)
 {
-	assert(k != (real)0.0);
+	ce_assert(k != (real)0.0, "Division by zero");
 
 	real inv = (real)(1.0 / k);
 

+ 5 - 5
src/core/math/Vec3.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 #include "Types.h"
 #include "MathUtils.h"
 #include "Vec2.h"
@@ -160,7 +160,7 @@ inline Vec3::Vec3(const Vec3& a) : x(a.x), y(a.y), z(a.z)
 //-----------------------------------------------------------------------------
 inline real Vec3::operator[](uint32_t i) const
 {
-	assert(i < 3);
+	ce_assert(i < 3, "Index must be < 3");
 
 	return (&x)[i];
 }
@@ -168,7 +168,7 @@ inline real Vec3::operator[](uint32_t i) const
 //-----------------------------------------------------------------------------
 inline real& Vec3::operator[](uint32_t i)
 {
-	assert(i < 3);
+	ce_assert(i < 3, "Index must be < 3");
 
 	return (&x)[i];
 }
@@ -224,7 +224,7 @@ inline Vec3& Vec3::operator*=(real k)
 //-----------------------------------------------------------------------------
 inline Vec3 Vec3::operator/(real k) const
 {
-	assert(k != (real)0.0);
+	ce_assert(k != (real)0.0, "Division by zero");
 
 	real inv = (real)(1.0 / k);
 
@@ -234,7 +234,7 @@ inline Vec3 Vec3::operator/(real k) const
 //-----------------------------------------------------------------------------
 inline Vec3& Vec3::operator/=(real k)
 {
-	assert(k != (real)0.0);
+	ce_assert(k != (real)0.0, "Division by zero");
 
 	real inv = (real)(1.0 / k);
 

+ 5 - 5
src/core/math/Vec4.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 #include "Types.h"
 #include "MathUtils.h"
 
@@ -154,7 +154,7 @@ inline Vec4::Vec4(const Vec4& a) : x(a.x), y(a.y), z(a.z), w(a.w)
 //-----------------------------------------------------------------------------
 inline real Vec4::operator[](uint32_t i) const
 {
-	assert(i < 4);
+	ce_assert(i < 4, "Index must be < 4");
 
 	return (&x)[i];
 }
@@ -162,7 +162,7 @@ inline real Vec4::operator[](uint32_t i) const
 //-----------------------------------------------------------------------------
 inline real& Vec4::operator[](uint32_t i)
 {
-	assert(i < 4);
+	ce_assert(i < 4, "Index must be < 4");
 
 	return (&x)[i];
 }
@@ -221,7 +221,7 @@ inline Vec4& Vec4::operator*=(real k)
 //-----------------------------------------------------------------------------
 inline Vec4 Vec4::operator/(real k) const
 {
-	assert(k != (real)0.0);
+	ce_assert(k != (real)0.0, "Division by zero");
 
 	real inv = (real)(1.0 / k);
 
@@ -231,7 +231,7 @@ inline Vec4 Vec4::operator/(real k) const
 //-----------------------------------------------------------------------------
 inline Vec4& Vec4::operator/=(real k)
 {
-	assert(k != (real)0.0);
+	ce_assert(k != (real)0.0, "Division by zero");
 
 	real inv = (real)(1.0 / k);
 

+ 0 - 1
src/core/mem/Memory.h

@@ -26,7 +26,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include <stdint.h>
-#include <cassert>
 #include <cstdio>
 #include "Types.h"
 

+ 2 - 1
src/core/mem/ProxyAllocator.cpp

@@ -23,6 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
+#include "Assert.h"
 #include "ProxyAllocator.h"
 #include "Allocator.h"
 
@@ -34,7 +35,7 @@ ProxyAllocator::ProxyAllocator(Allocator& allocator, const char* name) :
 	m_allocator(allocator),
 	m_name(name)
 {
-	assert(name != NULL);
+	ce_assert(name != NULL, "Name must be != NULL");
 }
 
 //-----------------------------------------------------------------------------

+ 7 - 12
src/core/streams/FileStream.cpp

@@ -82,7 +82,7 @@ uint8_t FileStream::read_byte()
 
 	uint8_t buffer;
 
-	assert(m_file.read(&buffer, 1));
+	ce_assert(m_file.read(&buffer, 1) == 1, "Failed to read from file");
 
 	return buffer;
 }
@@ -98,19 +98,14 @@ void FileStream::read(void* buffer, size_t size)
 		m_file.seek(0);
 	}
 
-	assert(m_file.read(buffer, size));
+	ce_assert(m_file.read(buffer, size) == size, "Failed to read from file");
 }
 
 //-----------------------------------------------------------------------------
-bool FileStream::copy_to(Stream* stream, size_t size)
+bool FileStream::copy_to(Stream& stream, size_t size)
 {
 	check_valid();
 
-	if (stream == 0)
-		return false;
-	if (size == 0)
-		return true;
-
 	const size_t chunksize = 1024*1024;
 
 	char* buff = new char[chunksize];
@@ -130,7 +125,7 @@ bool FileStream::copy_to(Stream* stream, size_t size)
 			{
 				if (read_bytes != 0)
 				{
-					stream->write(buff, read_bytes);
+					stream.write(buff, read_bytes);
 				}
 			}
 
@@ -139,7 +134,7 @@ bool FileStream::copy_to(Stream* stream, size_t size)
 			return false;
 		}
 
-		stream->write(buff, read_bytes);
+		stream.write(buff, read_bytes);
 		tot_read_bytes += read_bytes;
 	}
 
@@ -170,7 +165,7 @@ void FileStream::write_byte(uint8_t val)
 		m_file.seek(0);
 	}
 
-	assert(m_file.write(&val, 1) == 1);
+	ce_assert(m_file.write(&val, 1) == 1, "Failed to write to file");
 }
 
 //-----------------------------------------------------------------------------
@@ -184,7 +179,7 @@ void FileStream::write(const void* buffer, size_t size)
 		m_file.seek(0);
 	}
 
-	assert(m_file.write(buffer, size) == size);
+	ce_assert(m_file.write(buffer, size) == size, "Failed to write to file");
 }
 
 //-----------------------------------------------------------------------------

+ 3 - 3
src/core/streams/FileStream.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 
 #include "Stream.h"
 #include "File.h"
@@ -66,7 +66,7 @@ public:
 	void			write(const void* buffer, size_t size);
 
 	/// @copydoc Stream::copy_to() 
-	bool			copy_to(Stream* stream, size_t size = 0);
+	bool			copy_to(Stream& stream, size_t size = 0);
 
 	/// @copydoc Stream::flush() 
 	void			flush();
@@ -101,7 +101,7 @@ protected:
 
 	inline void		check_valid() const
 	{
-		assert(m_file.is_open());
+		ce_assert(m_file.is_open(), "File is not open");
 	}
 };
 

+ 4 - 4
src/core/streams/MemoryStream.cpp

@@ -122,7 +122,7 @@ void MemoryStream::seek(size_t position)
 
 	// Allow seek to m_memory->size() position, that means end of stream,
 	// reading not allowed but you can write if it's dynamic
-	assert(m_memory_offset <= m_memory->size());
+	ce_assert(m_memory_offset <= m_memory->size(), "Trying to seek beyond end of stream");
 }
 
 //-----------------------------------------------------------------------------
@@ -141,7 +141,7 @@ void MemoryStream::skip(size_t bytes)
 	m_memory_offset += bytes;
 
 	//Allow seek to m_memory->getSize() position, that means end of stream, reading not allowed but you can write if it's dynamic
-	assert(m_memory_offset <= m_memory->size());
+	ce_assert(m_memory_offset <= m_memory->size(), "Trying to skip beyond end of stream");
 }
 
 //-----------------------------------------------------------------------------
@@ -178,11 +178,11 @@ void MemoryStream::read(void* buffer, size_t size)
 }
 
 //-----------------------------------------------------------------------------
-bool MemoryStream::copy_to(Stream* stream, size_t size)
+bool MemoryStream::copy_to(Stream& stream, size_t size)
 {
 	check_valid();
 
-	stream->write(&(m_memory->data()[m_memory_offset]), math::min(m_memory->size()-m_memory_offset, size));
+	stream.write(&(m_memory->data()[m_memory_offset]), math::min(m_memory->size()-m_memory_offset, size));
 
 	return true;
 }

+ 5 - 5
src/core/streams/MemoryStream.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Types.h"
 #include "Stream.h"
 #include "Allocator.h"
-#include <cassert>
+#include "Assert.h"
 
 namespace crown
 {
@@ -112,7 +112,7 @@ public:
 	void				write(const void* buffer, size_t size);
 
 	/// @copydoc Stream::copy_to()
-	bool				copy_to(Stream* stream, size_t size = 0);
+	bool				copy_to(Stream& stream, size_t size = 0);
 
 	/// @copydoc Stream::flush()
 	void				flush();
@@ -121,10 +121,10 @@ public:
 	bool				end_of_stream() const { return size() == m_memory_offset; }
 
 	/// @copydoc Stream::is_valid()
-	bool				is_valid() const { assert(m_memory != NULL); return m_memory->is_valid(); }
+	bool				is_valid() const { ce_assert(m_memory != NULL, "Memory is NULL"); return m_memory->is_valid(); }
 
 	/// @copydoc Stream::size()
-	size_t				size() const { assert(m_memory != NULL); return m_memory->size(); }
+	size_t				size() const { ce_assert(m_memory != NULL, "Memory is NULL"); return m_memory->size(); }
 
 	/// @copydoc Stream::position()
 	size_t				position() const { return m_memory_offset; }
@@ -143,7 +143,7 @@ public:
 
 protected:
 
-	inline void			check_valid() { assert(m_memory != NULL); }
+	inline void			check_valid() { ce_assert(m_memory != NULL, "Memory is NULL"); }
 
 	MemoryBuffer*		m_memory;
 	size_t				m_memory_offset;

+ 2 - 4
src/core/streams/NullStream.h

@@ -77,13 +77,11 @@ public:
 	/// @copydoc Stream::copy_to()
 	/// @note
 	///	Returns always true
-	bool		copy_to(Stream* stream, size_t size = 0)
+	bool		copy_to(Stream& stream, size_t size = 0)
 	{
-		assert(stream != NULL);
-		
 		for (size_t i = 0; i < size; i++)
 		{
-			stream->write_byte(0);
+			stream.write_byte(0);
 		}
 		
 		return true;

+ 7 - 13
src/core/streams/Stream.cpp

@@ -32,39 +32,33 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-bool Stream::compress_to(Stream* stream, size_t size, size_t& zipped_size, Compressor* compressor)
+bool Stream::compress_to(Stream& stream, size_t size, size_t& zipped_size, Compressor& compressor)
 {
-	assert(stream != NULL);
-	assert(compressor != NULL);
-
 	MallocAllocator allocator;
 	void* in_buffer = (void*)allocator.allocate(size);
 
 	read(in_buffer, size);
 
-	void* compressed_buffer = compressor->compress(in_buffer, size, zipped_size);
+	void* compressed_buffer = compressor.compress(in_buffer, size, zipped_size);
 
-	stream->write(compressed_buffer, zipped_size);
+	stream.write(compressed_buffer, zipped_size);
 
 	return true;
 }
 
 //-----------------------------------------------------------------------------
-bool Stream::uncompress_to(Stream* stream, size_t& unzipped_size, Compressor* compressor)
+bool Stream::uncompress_to(Stream& stream, size_t& unzipped_size, Compressor& compressor)
 {
-	assert(stream != NULL);
-	assert(compressor != NULL);
-
 	MallocAllocator allocator;
 
 	size_t stream_size = size();
-	void* in_buffer = (void*)allocator.allocate(stream_size); 
+	void* in_buffer = (void*)allocator.allocate(stream_size);
 
 	read(in_buffer, stream_size);
 
-	void* uncompressed_buffer = compressor->uncompress(in_buffer, stream_size, unzipped_size);
+	void* uncompressed_buffer = compressor.uncompress(in_buffer, stream_size, unzipped_size);
 
-	stream->write(uncompressed_buffer, unzipped_size);
+	stream.write(uncompressed_buffer, unzipped_size);
 
 	return true;
 }

+ 3 - 3
src/core/streams/Stream.h

@@ -77,13 +77,13 @@ public:
 	virtual void		write(const void* buffer, size_t size) = 0;
 
 	/// Copies a chunk of 'size' bytes of data from this to another stream.
-	virtual bool		copy_to(Stream* stream, size_t size = 0) = 0;
+	virtual bool		copy_to(Stream& stream, size_t size = 0) = 0;
 
 	/// Zips a chunk of 'size' bytes of data from this to another stream using compressor.
-	virtual bool		compress_to(Stream* stream, size_t size, size_t& compressed_size, Compressor* compressor);
+	virtual bool		compress_to(Stream& stream, size_t size, size_t& compressed_size, Compressor& compressor);
 
 	/// Unzip a zipped stream of data from this to another stream using compressor.
-	virtual bool		uncompress_to(Stream* stream, size_t& uncompressed_size, Compressor* compressor);
+	virtual bool		uncompress_to(Stream& stream, size_t& uncompressed_size, Compressor& compressor);
 
 	/// Forces the previouses write operations to complete.
 	/// Generally, when a Stream is attached to a file,

+ 4 - 4
src/core/strings/Hash.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 #include "Types.h"
 
 namespace crown
@@ -62,7 +62,7 @@ uint64_t fnv1a_64(const void* key, size_t len);
 ///    machines.
 inline uint32_t murmur2_32(const void* key, size_t len, uint32_t seed)
 {
-	assert(key != NULL);
+	ce_assert(key != NULL, "Key must be != NULL");
 
 	// 'm' and 'r' are mixing constants generated offline.
 	// They're not really 'magic', they just happen to work well.
@@ -112,7 +112,7 @@ inline uint32_t murmur2_32(const void* key, size_t len, uint32_t seed)
 /// FNV-1a hash, 32 bit
 inline uint32_t fnv1a_32(const void* key, size_t len)
 {
-	assert(key != NULL);
+	ce_assert(key != NULL, "Key must be != NULL");
 
 	// FNV-1a
 	uint32_t hash = FNV1A_OFFSET_BASIS_32;
@@ -132,7 +132,7 @@ inline uint32_t fnv1a_32(const void* key, size_t len)
 /// FNV-1a hash, 64 bit
 inline uint64_t fnv1a_64(const void* key, size_t len)
 {
-	assert(key != NULL);
+	ce_assert(key != NULL, "Key must be != NULL");
 
 	// FNV-1a
 	uint64_t hash = FNV1A_OFFSET_BASIS_64;

+ 16 - 16
src/core/strings/Path.h

@@ -56,7 +56,7 @@ inline void strip_trailing_separator(const char* path, char* ret, size_t len);
 /// (Thanks org.eclipse.core.runtime for the documentation ;D).
 inline bool is_valid_segment(const char* segment)
 {
-	assert(segment != NULL);
+	ce_assert(segment != NULL, "Segment must be != NULL");
 	
 	size_t segment_len = string::strlen(segment);
 
@@ -146,8 +146,8 @@ inline bool is_valid_path(const char* path)
 /// The @path must be valid.
 inline void pathname(const char* path, char* str, size_t len)
 {
-	assert(path != NULL);
-	assert(str != NULL);
+	ce_assert(path != NULL, "Path must be != NULL");
+	ce_assert(str != NULL, "Str must be != NULL");
 
 	const char* last_separator = string::find_last(path, '/');
 
@@ -171,8 +171,8 @@ inline void pathname(const char* path, char* str, size_t len)
 /// The @path must be valid.
 inline void filename(const char* path, char* str, size_t len)
 {
-	assert(path != NULL);
-	assert(str != NULL);
+	ce_assert(path != NULL, "Path must be != NULL");
+	ce_assert(str != NULL, "Str must be != NULL");
 
 	const char* last_separator = string::find_last(path, '/');
 	
@@ -195,8 +195,8 @@ inline void filename(const char* path, char* str, size_t len)
 /// The @path must be valid.
 inline void basename(const char* path, char* str, size_t len)
 {
-	assert(path != NULL);
-	assert(str != NULL);
+	ce_assert(path != NULL, "Path must be != NULL");
+	ce_assert(str != NULL, "Str must be != NULL");
 
 	const char* last_separator = string::find_last(path, '/');
 	const char* last_dot = string::find_last(path, '.');
@@ -227,8 +227,8 @@ inline void basename(const char* path, char* str, size_t len)
 /// The @path must be valid.
 inline void extension(const char* path, char* str, size_t len)
 {
-	assert(path != NULL);
-	assert(str != NULL);
+	ce_assert(path != NULL, "Path must be != NULL");
+	ce_assert(str != NULL, "Str must be != NULL");
 	
 	const char* last_dot = string::find_last(path, '.');
 	
@@ -250,8 +250,8 @@ inline void extension(const char* path, char* str, size_t len)
 /// The @path must be valid.
 inline void filename_without_extension(const char* path, char* str, size_t len)
 {
-	assert(path != NULL);
-	assert(str != NULL);
+	ce_assert(path != NULL, "Path must be != NULL");
+	ce_assert(str != NULL, "Str must be != NULL");
 	
 	const char* last_dot = string::find_last(path, '.');
 	
@@ -277,20 +277,20 @@ inline void filename_without_extension(const char* path, char* str, size_t len)
 /// e.g. "/home/project/texture.tga" -> "/home/project/texture.tga"
 ///
 /// The @path must be valid.
-inline void strip_trailing_separator(const char* path, char* ret, size_t len)
+inline void strip_trailing_separator(const char* path, char* str, size_t len)
 {
-	assert(path != NULL);
-	assert(ret != NULL);
+	ce_assert(path != NULL, "Path must be != NULL");
+	ce_assert(str != NULL, "Str must be != NULL");
 	
 	size_t path_len = string::strlen(path);
 	
 	if (path[path_len - 1] == '/')
 	{
-		string::substring(string::begin(path), string::end(path) - 2, ret, len);
+		string::substring(string::begin(path), string::end(path) - 2, str, len);
 	}
 	else
 	{
-		string::substring(string::begin(path), string::end(path), ret, len);
+		string::substring(string::begin(path), string::end(path), str, len);
 	}
 }
 

+ 12 - 12
src/core/strings/String.h

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include <cassert>
+#include "Assert.h"
 #include <cstdio>
 #include <cstring>
 #include "List.h"
@@ -142,9 +142,9 @@ void				substring(const char* begin, const char* end, char* out, size_t len);
 
 //inline void Remove(uint32_t start, uint32_t end)
 //{
-//	assert(start <= mLength);
-//	assert(end <= mLength);
-//	assert(start <= end);
+//	ce_assert(start <= mLength);
+//	ce_assert(end <= mLength);
+//	ce_assert(start <= end);
 //	uint32_t len = end - start;
 //	char* tmp = new char[mLength - len + 1];
 
@@ -177,7 +177,7 @@ void				substring(const char* begin, const char* end, char* out, size_t len);
 ////! Replaces all the occurencies of the given Str with the new one
 //inline void Replace(const Str& toFind, const Str& toReplace)
 //{
-//	assert(toReplace.mLength > 0);
+//	ce_assert(toReplace.mLength > 0);
 //	if (mLength < toReplace.mLength)
 //		return;
 
@@ -357,7 +357,7 @@ inline char* strncat(char* dest, const char* src, size_t len)
 //-----------------------------------------------------------------------------
 inline const char* begin(const char* str)
 {
-	assert(str != NULL);
+	ce_assert(str != NULL, "Str must be != NULL");
 	
 	return str;
 }
@@ -365,7 +365,7 @@ inline const char* begin(const char* str)
 //-----------------------------------------------------------------------------
 inline const char* end(const char* str)
 {
-	assert(str != NULL);
+	ce_assert(str != NULL, "Str must be != NULL");
 	
 	return str + string::strlen(str) + 1;
 }
@@ -373,7 +373,7 @@ inline const char* end(const char* str)
 //-----------------------------------------------------------------------------
 inline const char* find_first(const char* str, char c)
 {
-	assert(str != NULL);
+	ce_assert(str != NULL, "Str must be != NULL");
 
 	const char* str_begin = string::begin(str);
 	
@@ -393,7 +393,7 @@ inline const char* find_first(const char* str, char c)
 //-----------------------------------------------------------------------------
 inline const char* find_last(const char* str, char c)
 {
-	assert(str != NULL);
+	ce_assert(str != NULL, "Str must be != NULL");
 	
 	const char* str_end = string::end(str) - 1;
 	
@@ -413,9 +413,9 @@ inline const char* find_last(const char* str, char c)
 //-----------------------------------------------------------------------------
 inline void substring(const char* begin, const char* end, char* out, size_t len)
 {
-	assert(begin != NULL);
-	assert(end != NULL);
-	assert(out != NULL);
+	ce_assert(begin != NULL, "Begin must be != NULL");
+	ce_assert(end != NULL, "End must be != NULL");
+	ce_assert(out != NULL, "Out must be != NULL");
 	
 	size_t i = 0;
 	

+ 4 - 4
src/input/EventDispatcher.cpp

@@ -47,7 +47,7 @@ EventDispatcher::~EventDispatcher()
 //-----------------------------------------------------------------------------
 void EventDispatcher::add_mouse_listener(MouseListener* listener)
 {
-	assert(listener != NULL);
+	ce_assert(listener != NULL, "Listener must be != NULL");
 
 	m_mouse_listener_list.push_back(listener);
 }
@@ -55,7 +55,7 @@ void EventDispatcher::add_mouse_listener(MouseListener* listener)
 //-----------------------------------------------------------------------------
 void EventDispatcher::add_keyboard_listener(KeyboardListener* listener)
 {
-	assert(listener != NULL);
+	ce_assert(listener != NULL, "Listener must be != NULL");
 
 	m_keyboard_listener_list.push_back(listener);
 }
@@ -63,14 +63,14 @@ void EventDispatcher::add_keyboard_listener(KeyboardListener* listener)
 //-----------------------------------------------------------------------------
 void EventDispatcher::add_touch_listener(TouchListener* listener)
 {
-	assert(listener != NULL);
+	ce_assert(listener != NULL, "Listener must be != NULL");
 
 	m_touch_listener_list.push_back(listener);
 }
 
 void EventDispatcher::add_accelerometer_listener(AccelerometerListener* listener)
 {
-	assert(listener != NULL);
+	ce_assert(listener != NULL, "Listener must be != NULL");
 	m_acc_listener_list.push_back(listener);
 }
 

+ 2 - 4
src/network/BitMessage.cpp

@@ -23,7 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include <cassert>
+#include "Assert.h"
 #include <cstring>
 
 #include "NetAddress.h"
@@ -88,10 +88,8 @@ uint8_t* BitMessage::get_byte_space(int32_t len)
 }
 
 //---------------------------------------------------------------------------------------------
-bool BitMessage::check_overflow(int32_t num_bits)
+bool BitMessage::check_overflow(uint32_t num_bits)
 {
-	assert(num_bits >= 0);
-	
 	if (num_bits > get_remaining_write_bits()) 
 	{
 		if (num_bits > (m_max_size << 3)) 

+ 1 - 1
src/network/BitMessage.h

@@ -108,7 +108,7 @@ public:
 private:
   
 	uint8_t*			get_byte_space(int32_t len);
-	bool 				check_overflow(int32_t num_bits);			// check buffer overflow	
+	bool 				check_overflow(uint32_t num_bits);			// check buffer overflow	
 	
 private:
 	

+ 8 - 27
src/os/android/File.cpp

@@ -23,7 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include <cassert>
+#include "Assert.h"
 #include <stdio.h>
 
 #include "OS.h"
@@ -71,15 +71,13 @@ StreamOpenMode File::mode()
 //-----------------------------------------------------------------------------
 size_t File::size() const
 {
-	assert(m_asset != NULL);
-	
 	return AAsset_getLength(m_asset);
 }
 
 //-----------------------------------------------------------------------------
 bool File::open(const char* path, StreamOpenMode mode)
 {
-	assert(!is_open());
+	ce_assert(!is_open(), "Asset is already open: %s", path);
 
 	// Android assets are always read-only
 	(void) mode;
@@ -87,12 +85,7 @@ bool File::open(const char* path, StreamOpenMode mode)
 
 	m_asset = AAssetManager_open(os::get_android_asset_manager(), path, AASSET_MODE_RANDOM);
 
-	if (m_asset == NULL)
-	{
-		os::printf("Could not open asset %s", path);
-
-		return false;
-	}
+	ce_assert(m_asset != NULL, "Unable to open asset: %s", path)
 
 	return true;
 }
@@ -100,8 +93,7 @@ bool File::open(const char* path, StreamOpenMode mode)
 //-----------------------------------------------------------------------------
 size_t File::read(void* data, size_t size)
 {
-	assert(m_asset != NULL);
-	assert(data != NULL);
+	ce_assert(data != NULL, "Data must be != NULL");
 
 	return (size_t)AAsset_read(m_asset, data, size);
 }
@@ -109,8 +101,7 @@ size_t File::read(void* data, size_t size)
 //-----------------------------------------------------------------------------
 size_t File::write(const void* data, size_t size)
 {
-	assert(m_asset != NULL);
-	assert(data != NULL);
+	ce_assert(data != NULL, "Data must be != NULL");
 
 	os::printf("Android asset directory is read-only!");
 
@@ -120,40 +111,30 @@ size_t File::write(const void* data, size_t size)
 //-----------------------------------------------------------------------------
 void File::seek(size_t position)
 {
-	assert(m_asset != NULL);
-
-	assert(AAsset_seek(m_asset, (off_t)position, SEEK_SET) != (off_t) -1);
+	ce_assert(AAsset_seek(m_asset, (off_t)position, SEEK_SET) != (off_t) -1);
 }
 
 //-----------------------------------------------------------------------------
 void File::seek_to_end()
 {
-	assert(m_asset != NULL);
-
-	assert(AAsset_seek(m_asset, 0, SEEK_END) != (off_t) -1);
+	ce_assert(AAsset_seek(m_asset, 0, SEEK_END) != (off_t) -1);
 }
 
 //-----------------------------------------------------------------------------
 void File::skip(size_t bytes)
 {
-	assert(m_asset != NULL);
-
-	assert(AAsset_seek(m_asset, (off_t) bytes, SEEK_CUR) != (off_t) -1);
+	ce_assert(AAsset_seek(m_asset, (off_t) bytes, SEEK_CUR) != (off_t) -1);
 }
 
 //-----------------------------------------------------------------------------
 size_t File::position() const
 {
-	assert(m_asset != NULL);
-	
 	return (size_t) (AAsset_getLength(m_asset) - AAsset_getRemainingLength(m_asset));
 }
 
 //-----------------------------------------------------------------------------
 bool File::eof() const
 {
-	assert(m_asset != NULL);
-	
 	return AAsset_getRemainingLength(m_asset) == 0;
 }
 

+ 1 - 1
src/os/linux/GLXRenderWindow.cpp

@@ -51,7 +51,7 @@ bool create_render_window(uint32_t x, uint32_t y, uint32_t width, uint32_t heigh
 {
 	(void)fullscreen;
 
-	assert(width != 0 && height != 0);
+	ce_assert(width != 0 && height != 0, "Width and height must be != 0");
 
 	display = XOpenDisplay(NULL);
 

+ 3 - 3
src/os/linux/LinuxOS.cpp

@@ -95,7 +95,7 @@ void log_info(const char* string, va_list arg)
 //-----------------------------------------------------------------------------
 bool is_root_path(const char* path)
 {
-	assert(path != NULL);
+	ce_assert(path != NULL, "Path must be != NULL");
 
 	if (string::strlen(path) == 1)
 	{
@@ -111,7 +111,7 @@ bool is_root_path(const char* path)
 //-----------------------------------------------------------------------------
 bool is_absolute_path(const char* path)
 {
-	assert(path != NULL);
+	ce_assert(path != NULL, "Path must be != NULL");
 
 	if (string::strlen(path) > 0)
 	{
@@ -280,7 +280,7 @@ void* open_library(const char* path)
 //-----------------------------------------------------------------------------
 void close_library(void* library)
 {
-	assert(dlclose(library) == 0);
+	ce_assert(dlclose(library) == 0, "Failed to close library");
 }
 
 //-----------------------------------------------------------------------------

+ 10 - 28
src/os/posix/File.cpp

@@ -23,7 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include <cassert>
+#include "Assert.h"
 #include <stdio.h>
 
 #include "OS.h"
@@ -84,22 +84,16 @@ size_t File::size() const
 //-----------------------------------------------------------------------------
 bool File::open(const char* path, StreamOpenMode mode)
 {
-	assert(!is_open());
+	ce_assert(!is_open(), "File is already open: %s", path);
 
 	const char* c_mode = mode == SOM_READ ? "rb" : SOM_WRITE ? "wb" : "x";
 
-	assert(c_mode[0] != 'x');
+	ce_assert(c_mode[0] != 'x', "Open mode not valid");
 
+	m_mode = mode;
 	m_file_handle = fopen(path, c_mode);
 
-	if (m_file_handle == NULL)
-	{
-		os::printf("Could not open file %s", path);
-
-		return false;
-	}
-
-	m_mode = mode;
+	ce_assert(m_file_handle != NULL, "Unable to open file: %s", path);
 
 	return true;
 }
@@ -107,8 +101,7 @@ bool File::open(const char* path, StreamOpenMode mode)
 //-----------------------------------------------------------------------------
 size_t File::read(void* data, size_t size)
 {
-	assert(m_file_handle != NULL);
-	assert(data != NULL);
+	ce_assert(data != NULL, "Data must be != NULL");
 
 	return fread(data, 1, size, m_file_handle);
 }
@@ -116,8 +109,7 @@ size_t File::read(void* data, size_t size)
 //-----------------------------------------------------------------------------
 size_t File::write(const void* data, size_t size)
 {
-	assert(m_file_handle != NULL);
-	assert(data != NULL);
+	ce_assert(data != NULL, "Data must be != NULL");
 
 	return fwrite(data, 1, size, m_file_handle);
 }
@@ -125,40 +117,30 @@ size_t File::write(const void* data, size_t size)
 //-----------------------------------------------------------------------------
 void File::seek(size_t position)
 {
-	assert(m_file_handle != NULL);
-
-	assert(fseek(m_file_handle, (long) position, SEEK_SET) == 0);
+	ce_assert(fseek(m_file_handle, (long) position, SEEK_SET) == 0, "Failed to seek");
 }
 
 //-----------------------------------------------------------------------------
 void File::seek_to_end()
 {
-	assert(m_file_handle != NULL);
-
-	assert(fseek(m_file_handle, 0, SEEK_END) == 0);
+	ce_assert(fseek(m_file_handle, 0, SEEK_END) == 0, "Failed to seek");
 }
 
 //-----------------------------------------------------------------------------
 void File::skip(size_t bytes)
 {
-	assert(m_file_handle != NULL);
-
-	assert(fseek(m_file_handle, bytes, SEEK_CUR) == 0);
+	ce_assert(fseek(m_file_handle, bytes, SEEK_CUR) == 0, "Failed to seek");
 }
 
 //-----------------------------------------------------------------------------
 size_t File::position() const
 {
-	assert(m_file_handle != NULL);
-
 	return (size_t) ftell(m_file_handle);
 }
 
 //-----------------------------------------------------------------------------
 bool File::eof() const
 {
-	assert(m_file_handle != NULL);
-
 	return feof(m_file_handle) != 0;
 }
 

+ 3 - 5
src/os/posix/TCPSocket.cpp

@@ -28,8 +28,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include <netinet/in.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <cassert>
 
+#include "Assert.h"
 #include "Types.h"
 #include "OS.h"
 #include "TCPSocket.h"
@@ -153,8 +153,7 @@ void TCPSocket::close()
 //-----------------------------------------------------------------------------
 bool TCPSocket::send(const void* data, size_t size)
 {
-	assert(data != NULL);
-	assert(size > 0);
+	ce_assert(data != NULL, "Data must be != NULL");
 
 	if (m_active_socket <= 0)
 	{
@@ -177,8 +176,7 @@ bool TCPSocket::send(const void* data, size_t size)
 //-----------------------------------------------------------------------------
 size_t TCPSocket::receive(void* data, size_t size)
 {
-	assert(data);
-	assert(size > 0);
+	ce_assert(data != NULL, "Data must be != NULL");
 
 	if (m_active_socket <= 0)
 	{

+ 4 - 8
src/os/posix/UDPSocket.cpp

@@ -28,8 +28,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include <netinet/in.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <cassert>
 
+#include "Assert.h"
 #include "Types.h"
 #include "OS.h"
 #include "UDPSocket.h"
@@ -55,7 +55,7 @@ UDPSocket::~UDPSocket()
 //-----------------------------------------------------------------------------
 bool UDPSocket::open(uint16_t port)
 {
-	assert(!is_open());
+	ce_assert(!is_open(), "Socket is already open");
 
 	m_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
 
@@ -97,9 +97,7 @@ bool UDPSocket::open(uint16_t port)
 //-----------------------------------------------------------------------------
 bool UDPSocket::send(const NetAddress &receiver, const void* data, size_t size)
 {
-	assert(is_open());
-	assert(data != NULL);
-	assert(size > 0);
+	ce_assert(data != NULL, "Data must be != NULL");
 
 	sockaddr_in address;
 	address.sin_family = AF_INET;
@@ -119,9 +117,7 @@ bool UDPSocket::send(const NetAddress &receiver, const void* data, size_t size)
 //-----------------------------------------------------------------------------
 size_t UDPSocket::receive(NetAddress& sender, void* data, size_t size)
 {
-	assert(is_open());
-	assert(data);
-	assert(size > 0);
+	ce_assert(data != NULL, "Data must be != NULL");
 
 	sockaddr_in from;
 	socklen_t from_length = sizeof(from);

+ 5 - 5
src/os/win/WinTCPSocket.cpp

@@ -1,4 +1,4 @@
-#include <cassert>
+#include "Assert.h"
 #include <winsock2.h>
 #pragma comment(lib, "wsock32.lib")
 
@@ -109,8 +109,8 @@ int32_t	TCPSocket::close()
 
 bool TCPSocket::send(const void* data, int32_t size)
 {
-	assert(data);
-	assert(size > 0);
+	ce_assert(data);
+	ce_assert(size > 0);
 
 	int32_t sd = get_active_socket_id();
 	if (sd <= 0)
@@ -132,8 +132,8 @@ bool TCPSocket::send(const void* data, int32_t size)
 
 int32_t	TCPSocket::receive(void* data, int32_t size)
 {
-	assert(data);
-	assert(size > 0);
+	ce_assert(data);
+	ce_assert(size > 0);
 
 	int32_t sd = get_active_socket_id();
 

+ 8 - 8
src/os/win/WinUDPSocket.cpp

@@ -1,4 +1,4 @@
-#include <cassert>
+#include "Assert.h"
 #include <winsock2.h>
 #pragma comment(lib, "wsock32.lib")
 
@@ -22,7 +22,7 @@ UDPSocket::~UDPSocket()
 
 bool UDPSocket::open(uint16_t port)
 {
-	assert(!is_open());
+	ce_assert(!is_open());
 
 	m_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
 	if (m_socket <= 0)
@@ -59,16 +59,16 @@ bool UDPSocket::open(uint16_t port)
 
 bool UDPSocket::send(IPv4Address &receiver, const void* data, int32_t size )
 {
-	assert(data);
-	assert(size > 0);
+	ce_assert(data);
+	ce_assert(size > 0);
 
 	if (m_socket == 0)
 	{
 		return false;
 	}
 	
-	assert(receiver.get_address() != 0);
-	assert(receiver.get_port() != 0);
+	ce_assert(receiver.get_address() != 0);
+	ce_assert(receiver.get_port() != 0);
 
 	sockaddr_in address;
 	address.sin_family = AF_INET;
@@ -82,8 +82,8 @@ bool UDPSocket::send(IPv4Address &receiver, const void* data, int32_t size )
 
 int32_t UDPSocket::receive(IPv4Address &sender, void* data, int32_t size)
 {
-	assert(data);
-	assert(size > 0);
+	ce_assert(data);
+	ce_assert(size > 0);
 
 	if (m_socket == 0)
 	{

+ 12 - 14
src/renderers/gl/GLRenderer.cpp

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Config.h"
 
 #include <GL/glew.h>
-#include <cassert>
+#include "Assert.h"
 #include <algorithm>
 
 #include "Types.h"
@@ -95,9 +95,7 @@ GLRenderer::GLRenderer() :
 		m_matrix[i].load_identity();
 	}
 
-	GLenum err = glewInit();
-
-	assert(err == GLEW_OK);
+	ce_assert(glewInit() == GLEW_OK, "Failed to initialize GLEW");
 
 	Log::i("GLEW initialized.");
 
@@ -226,7 +224,7 @@ VertexBufferId GLRenderer::create_dynamic_vertex_buffer(size_t count, VertexForm
 //-----------------------------------------------------------------------------
 void GLRenderer::update_vertex_buffer(VertexBufferId id, size_t offset, size_t count, const void* vertices)
 {
-	assert(m_vertex_buffers_id_table.has(id));
+	ce_assert(m_vertex_buffers_id_table.has(id), "Vertex buffer does not exist");
 
 	GLVertexBuffer& buffer = m_vertex_buffers[id.index];
 
@@ -238,7 +236,7 @@ void GLRenderer::update_vertex_buffer(VertexBufferId id, size_t offset, size_t c
 //-----------------------------------------------------------------------------
 void GLRenderer::destroy_vertex_buffer(VertexBufferId id)
 {
-	assert(m_vertex_buffers_id_table.has(id));
+	ce_assert(m_vertex_buffers_id_table.has(id), "Vertex buffer does not exist");
 
 	GLVertexBuffer& buffer = m_vertex_buffers[id.index];
 
@@ -267,7 +265,7 @@ IndexBufferId GLRenderer::create_index_buffer(size_t count, const void* indices)
 //-----------------------------------------------------------------------------
 void GLRenderer::destroy_index_buffer(IndexBufferId id)
 {
-	assert(m_index_buffers_id_table.has(id));
+	ce_assert(m_index_buffers_id_table.has(id), "Index buffer does not exist");
 
 	GLIndexBuffer& buffer = m_index_buffers[id.index];
 
@@ -301,7 +299,7 @@ TextureId GLRenderer::create_texture(uint32_t width, uint32_t height, PixelForma
 //-----------------------------------------------------------------------------
 void GLRenderer::update_texture(TextureId id, uint32_t x, uint32_t y, uint32_t width, uint32_t height, const void* data)
 {
-	assert(m_textures_id_table.has(id));
+	ce_assert(m_textures_id_table.has(id), "Texture does not exist");
 
 	GLTexture& gl_texture = m_textures[id.index];
 
@@ -314,7 +312,7 @@ void GLRenderer::update_texture(TextureId id, uint32_t x, uint32_t y, uint32_t w
 //-----------------------------------------------------------------------------
 void GLRenderer::destroy_texture(TextureId id)
 {
-	assert(m_textures_id_table.has(id));
+	ce_assert(m_textures_id_table.has(id), "Texture does not exist");
 
 	GLTexture& gl_texture = m_textures[id.index];
 
@@ -399,7 +397,7 @@ void GLRenderer::set_lighting(bool lighting)
 //-----------------------------------------------------------------------------
 void GLRenderer::bind_texture(uint32_t unit, TextureId texture)
 {
-	assert(m_textures_id_table.has(texture));
+	ce_assert(m_textures_id_table.has(texture), "Texture does not exist");
 
 	if (!activate_texture_unit(unit))
 	{
@@ -792,7 +790,7 @@ void GLRenderer::set_matrix(MatrixType type, const Mat4& matrix)
 //-----------------------------------------------------------------------------
 void GLRenderer::bind_vertex_buffer(VertexBufferId vb) const
 {
-	assert(m_vertex_buffers_id_table.has(vb));
+	ce_assert(m_vertex_buffers_id_table.has(vb), "Vertex buffer does not exist");
 
 	const GLVertexBuffer& vertex_buffer = m_vertex_buffers[vb.index];
 
@@ -842,7 +840,7 @@ void GLRenderer::bind_vertex_buffer(VertexBufferId vb) const
 		}
 		default:
 		{
-			assert(0);
+			ce_assert(0, "Vertex format unknown");
 			break;
 		}
 	}
@@ -851,7 +849,7 @@ void GLRenderer::bind_vertex_buffer(VertexBufferId vb) const
 //-----------------------------------------------------------------------------
 void GLRenderer::draw_triangles(IndexBufferId id) const
 {
-	assert(m_index_buffers_id_table.has(id));
+	ce_assert(m_index_buffers_id_table.has(id), "Index buffer does not exist");
 
 	const GLIndexBuffer& index_buffer = m_index_buffers[id.index];
 
@@ -863,7 +861,7 @@ void GLRenderer::draw_triangles(IndexBufferId id) const
 //-----------------------------------------------------------------------------
 // void GLRenderer::bind_render_buffer(RenderBufferId id) const
 // {
-// 	assert(m_render_buffers_id_table.has(id));
+// 	ce_assert(m_render_buffers_id_table.has(id), "Render buffer does not exist");
 
 // 	const GLRenderBuffer& render_buffer = m_render_buffers[id.index];
 // }

+ 0 - 17
src/renderers/gl/GLUtils.h

@@ -26,7 +26,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include <GL/glew.h>
-#include <cassert>
 #include "Texture.h"
 #include "Material.h"
 #include "PixelFormat.h"
@@ -69,48 +68,36 @@ private:
 //-----------------------------------------------------------------------------
 inline GLenum GL::compare_function(CompareFunction function)
 {
-	assert(function < CF_COUNT);
-
 	return COMPARE_FUNCTION_TABLE[function];
 }
 
 //-----------------------------------------------------------------------------
 inline GLenum GL::blend_function(BlendFunction function)
 {
-	assert(function < BF_COUNT);
-
 	return BLEND_FUNCTION_TABLE[function];
 }
 
 //-----------------------------------------------------------------------------
 inline GLenum GL::blend_equation(BlendEquation equation)
 {
-	assert(equation < BE_COUNT);
-
 	return BLEND_EQUATION_TABLE[equation];
 }
 
 //-----------------------------------------------------------------------------
 inline GLenum GL::texture_mode(TextureMode mode)
 {
-	assert(mode < TM_COUNT);
-
 	return TEXTURE_MODE_TABLE[mode];
 }
 
 //-----------------------------------------------------------------------------
 inline GLenum GL::texture_wrap(TextureWrap wrap)
 {
-	assert(wrap < TW_COUNT);
-
 	return TEXTURE_WRAP_TABLE[wrap];
 }
 
 //-----------------------------------------------------------------------------
 inline void GL::texture_filter(TextureFilter filter, GLint& minFilter, GLint& magFilter)
 {
-	assert(filter < TF_COUNT);
-
 	minFilter = TEXTURE_MIN_FILTER_TABLE[filter];
 	magFilter = TEXTURE_MAG_FILTER_TABLE[filter];
 }
@@ -118,16 +105,12 @@ inline void GL::texture_filter(TextureFilter filter, GLint& minFilter, GLint& ma
 //-----------------------------------------------------------------------------
 inline GLenum GL::fog_mode(FogMode mode)
 {
-	assert(mode < FM_COUNT);
-
 	return FOG_MODE_TABLE[mode];
 }
 
 //-----------------------------------------------------------------------------
 inline GLenum GL::polygon_mode(PolygonMode mode)
 {
-	assert(mode < PM_COUNT);
-
 	return POLYGON_MODE_TABLE[mode];
 }
 

+ 2 - 2
src/renderers/gles/GLESRenderer.cpp

@@ -567,8 +567,8 @@ void GLESRenderer::set_matrix(MatrixType type, const Mat4& matrix)
 //-----------------------------------------------------------------------------
 void GLESRenderer::draw_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices)
 {
-	assert(vertices != NULL);
-	assert(indices != NULL);
+	ce_assert(vertices != NULL);
+	ce_assert(indices != NULL);
 
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glEnableClientState(GL_NORMAL_ARRAY);

+ 7 - 7
src/renderers/gles/GLESUtils.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include <GLES/gl.h>
-#include <cassert>
+#include "Assert.h"
 #include "Texture.h"
 #include "Material.h"
 #include "Pixel.h"
@@ -65,7 +65,7 @@ private:
 //-----------------------------------------------------------------------------
 inline GLenum GLES::compare_function(CompareFunction function)
 {
-	assert(function < CF_COUNT);
+	ce_assert(function < CF_COUNT);
 
 	return COMPARE_FUNCTION_TABLE[function];
 }
@@ -73,7 +73,7 @@ inline GLenum GLES::compare_function(CompareFunction function)
 //-----------------------------------------------------------------------------
 inline GLenum GLES::blend_function(BlendFunction function)
 {
-	assert(function < BF_COUNT);
+	ce_assert(function < BF_COUNT);
 
 	return BLEND_FUNCTION_TABLE[function];
 }
@@ -81,7 +81,7 @@ inline GLenum GLES::blend_function(BlendFunction function)
 //-----------------------------------------------------------------------------
 inline GLenum GLES::texture_mode(TextureMode mode)
 {
-	assert(mode < TM_COUNT);
+	ce_assert(mode < TM_COUNT);
 
 	return TEXTURE_MODE_TABLE[mode];
 }
@@ -89,7 +89,7 @@ inline GLenum GLES::texture_mode(TextureMode mode)
 //-----------------------------------------------------------------------------
 inline GLenum GLES::texture_wrap(TextureWrap wrap)
 {
-	assert(wrap < TW_COUNT);
+	ce_assert(wrap < TW_COUNT);
 
 	return TEXTURE_WRAP_TABLE[wrap];
 }
@@ -97,7 +97,7 @@ inline GLenum GLES::texture_wrap(TextureWrap wrap)
 //-----------------------------------------------------------------------------
 inline void GLES::texture_filter(TextureFilter filter, GLint& minFilter, GLint& magFilter)
 {
-	assert(filter < TF_COUNT);
+	ce_assert(filter < TF_COUNT);
 
 	minFilter = TEXTURE_MIN_FILTER_TABLE[filter];
 	magFilter = TEXTURE_MAG_FILTER_TABLE[filter];
@@ -106,7 +106,7 @@ inline void GLES::texture_filter(TextureFilter filter, GLint& minFilter, GLint&
 //-----------------------------------------------------------------------------
 inline GLenum GLES::fog_mode(FogMode mode)
 {
-	assert(mode < FM_COUNT);
+	ce_assert(mode < FM_COUNT);
 
 	return FOG_MODE_TABLE[mode];
 }

+ 3 - 3
tests/allocators.cpp

@@ -1,7 +1,7 @@
 #include "Allocator.h"
 #include "MallocAllocator.h"
 #include <cstdio>
-#include <cassert>
+#include "Assert.h"
 
 using namespace crown;
 
@@ -10,13 +10,13 @@ int main()
 	MallocAllocator malloc_allocator;
 
 	char* char_buffer = (char*)malloc_allocator.allocate(128);
-	assert(malloc_allocator.allocated_size() >= 128);
+	ce_assert(malloc_allocator.allocated_size() >= 128, "Allocated size differs from requested size");
 
 	printf("MallocAllocator::get_allocated_size(): %d\n", malloc_allocator.allocated_size());
 
 	malloc_allocator.deallocate(char_buffer);
 
 	printf("MallocAllocator::get_allocated_size(): %d\n", malloc_allocator.allocated_size());
-	//assert(malloc_allocator.get_allocated_size() == 0);
+	//ce_assert(malloc_allocator.get_allocated_size() == 0);
 }
 

+ 9 - 9
tests/containers.cpp

@@ -1,6 +1,6 @@
 #include "Crown.h"
 #include <cstdio>
-#include <cassert>
+#include "Assert.h"
 
 using namespace crown;
 
@@ -10,7 +10,7 @@ int main()
 
 	List<int> int_list(allocator);
 
-	assert(int_list.size() == 0);
+	ce_assert(int_list.size() == 0, "Size differs from expected value");
 
 	int_list.push_back(10);
 	int_list.push_back(20);
@@ -19,19 +19,19 @@ int main()
 	int_list.push_back(50);
 	int_list.push_back(60);
 
-	assert(int_list.size() == 6);
-	assert(int_list.front() == 10);
-	assert(int_list.back() == 60);
+	ce_assert(int_list.size() == 6, "Size differs from expected value");
+	ce_assert(int_list.front() == 10, "Front differs from expected value");
+	ce_assert(int_list.back() == 60, "Back differs from expected value");
 
 	int_list.pop_back();
 
-	assert(int_list.size() == 5);
-	assert(int_list.front() == 10);
-	assert(int_list.back() == 50);
+	ce_assert(int_list.size() == 5, "Size differs from expected value");
+	ce_assert(int_list.front() == 10, "Front differs from expected value");
+	ce_assert(int_list.back() == 50, "Back differs from expected value");
 
 	int_list.clear();
 
-	assert(int_list.size() == 0);
+	ce_assert(int_list.size() == 0, "Size differs from expected value");
 
 	return 0;
 }

+ 33 - 33
tests/paths.cpp

@@ -1,6 +1,6 @@
 #include "String.h"
 #include "Path.h"
-#include <cassert>
+#include "Assert.h"
 #include <stdio.h>
 
 using namespace crown;
@@ -10,99 +10,99 @@ int main()
 	char path_output[128];
 	
 	// Test is_valid_segment
-	assert(path::is_valid_segment(".") == false);
+	ce_assert(path::is_valid_segment(".") == false);
 	
-	assert(path::is_valid_segment("/") == false);
+	ce_assert(path::is_valid_segment("/") == false);
 	
-	assert(path::is_valid_segment("\\") == false);
+	ce_assert(path::is_valid_segment("\\") == false);
 
-	assert(path::is_valid_segment(":") == false);
+	ce_assert(path::is_valid_segment(":") == false);
 	
-	assert(path::is_valid_segment("tga/") == false);
+	ce_assert(path::is_valid_segment("tga/") == false);
 	
-	assert(path::is_valid_segment("tga\\foo") == false);
+	ce_assert(path::is_valid_segment("tga\\foo") == false);
 	
-	assert(path::is_valid_segment("tga") == true);
+	ce_assert(path::is_valid_segment("tga") == true);
 	
-	assert(path::is_valid_segment("back_texture") == true);
+	ce_assert(path::is_valid_segment("back_texture") == true);
 	
 	// Test pathname
 	path::pathname("/home/project/texture.tga", path_output, 128);
-	assert(string::strcmp("/home/project", path_output) == 0);
+	ce_assert(string::strcmp("/home/project", path_output) == 0);
 
 	path::pathname("/home/project", path_output, 128);
-	assert(string::strcmp("/home", path_output) == 0);
+	ce_assert(string::strcmp("/home", path_output) == 0);
 	
 	path::pathname("/home", path_output, 128);
-	assert(string::strcmp("", path_output) == 0);
+	ce_assert(string::strcmp("", path_output) == 0);
 	
 	path::pathname("/", path_output, 128);
-	assert(string::strcmp("", path_output) == 0);
+	ce_assert(string::strcmp("", path_output) == 0);
 	
 	path::pathname("", path_output, 128);
-	assert(string::strcmp("", path_output) == 0);
+	ce_assert(string::strcmp("", path_output) == 0);
 	
 	// Test filename
 	path::filename("/home/project/texture.tga", path_output, 128);
-	assert(string::strcmp("texture.tga", path_output) == 0);
+	ce_assert(string::strcmp("texture.tga", path_output) == 0);
 	
 	path::filename("/home/project/texture", path_output, 128);
-	assert(string::strcmp("texture", path_output) == 0);
+	ce_assert(string::strcmp("texture", path_output) == 0);
 	
 	path::filename("/home", path_output, 128);
-	assert(string::strcmp("home", path_output) == 0);
+	ce_assert(string::strcmp("home", path_output) == 0);
 	
 	path::filename("/", path_output, 128);
-	assert(string::strcmp("", path_output) == 0);
+	ce_assert(string::strcmp("", path_output) == 0);
 	
 	path::filename("", path_output, 128);
-	assert(string::strcmp("", path_output) == 0);
+	ce_assert(string::strcmp("", path_output) == 0);
 
 	// Test basename
 	path::basename("/home/project/texture.tga", path_output, 128);
-	assert(string::strcmp("texture", path_output) == 0);
+	ce_assert(string::strcmp("texture", path_output) == 0);
 	
 	path::basename("/home/project/textureabc", path_output, 128);
 	printf(path_output);
-	assert(string::strcmp("textureabc", path_output) == 0);
+	ce_assert(string::strcmp("textureabc", path_output) == 0);
 	
 	path::basename("/hom.e/proj./e.ct/textu.reabc", path_output, 128);
-	assert(string::strcmp("textu", path_output) == 0);
+	ce_assert(string::strcmp("textu", path_output) == 0);
 	
 	path::basename("texture.tga", path_output, 128);
-	assert(string::strcmp("texture", path_output) == 0);
+	ce_assert(string::strcmp("texture", path_output) == 0);
 	
 	path::basename("/home", path_output, 128);
-	assert(string::strcmp("home", path_output) == 0);
+	ce_assert(string::strcmp("home", path_output) == 0);
 	
 	path::basename("/", path_output, 128);
-	assert(string::strcmp("", path_output) == 0);
+	ce_assert(string::strcmp("", path_output) == 0);
 	
 	path::basename("", path_output, 128);
-	assert(string::strcmp("", path_output) == 0);
+	ce_assert(string::strcmp("", path_output) == 0);
 	
 	// Test extension
 	path::extension("/home/project/texture.tga", path_output, 128);
-	assert(string::strcmp("tga", path_output) == 0);
+	ce_assert(string::strcmp("tga", path_output) == 0);
 	
 	path::extension("/home/project/texture", path_output, 128);
-	assert(string::strcmp("", path_output) == 0);
+	ce_assert(string::strcmp("", path_output) == 0);
 	
 	path::extension("/home/project.x/texture.tga", path_output, 128);
-	assert(string::strcmp("tga", path_output) == 0);
+	ce_assert(string::strcmp("tga", path_output) == 0);
 	
 	// Test filename_without_extension
 	path::filename_without_extension("/home/project/texture.tga", path_output, 128);
-	assert(string::strcmp("/home/project/texture", path_output) == 0);
+	ce_assert(string::strcmp("/home/project/texture", path_output) == 0);
 	
 	// Test strip_trailing_separator
 	path::strip_trailing_separator("/home/project/texture.tga", path_output, 128);
-	assert(string::strcmp("/home/project/texture.tga", path_output) == 0);
+	ce_assert(string::strcmp("/home/project/texture.tga", path_output) == 0);
 	
 	path::strip_trailing_separator("/home/project/texture2.tga/", path_output, 128);
-	assert(string::strcmp("/home/project/texture2.tga", path_output) == 0);
+	ce_assert(string::strcmp("/home/project/texture2.tga", path_output) == 0);
 	
 	path::strip_trailing_separator("texture.tga", path_output, 128);
-	assert(string::strcmp("texture.tga", path_output) == 0);
+	ce_assert(string::strcmp("texture.tga", path_output) == 0);
 }
 

+ 13 - 13
tests/strings.cpp

@@ -1,5 +1,5 @@
 #include "String.h"
-#include <cassert>
+#include "Assert.h"
 #include <stdio.h>
 
 using namespace crown;
@@ -10,40 +10,40 @@ const char* path_string = "/home/project/texture.tga";
 int main()
 {
 	// Test strlen
-	assert(string::strlen("ciao") == 4);
+	ce_assert(string::strlen("ciao") == 4);
 	// FIXME add UTF-8 test case
 
 	// Test begin/end
-	assert(string::begin(hello_string) == &hello_string[0]);
+	ce_assert(string::begin(hello_string) == &hello_string[0]);
 	
-	assert(string::end(hello_string) == &hello_string[24] + 2);
+	ce_assert(string::end(hello_string) == &hello_string[24] + 2);
 	
 	// Test find_first/find_last
-	assert(string::find_first(hello_string, '.') == &hello_string[2]);
+	ce_assert(string::find_first(hello_string, '.') == &hello_string[2]);
 	
-	assert(string::find_last(hello_string, '.') == &hello_string[17]);
+	ce_assert(string::find_last(hello_string, '.') == &hello_string[17]);
 	
-	assert(string::find_first(hello_string, '?') == string::end(hello_string));
+	ce_assert(string::find_first(hello_string, '?') == string::end(hello_string));
 	
-	assert(string::find_last(hello_string, '?') == string::end(hello_string));
+	ce_assert(string::find_last(hello_string, '?') == string::end(hello_string));
 	
-	assert(string::find_last(hello_string, '/') == &hello_string[22]);
+	ce_assert(string::find_last(hello_string, '/') == &hello_string[22]);
 	
-	assert(string::find_last(path_string, '/') == &path_string[13]);
+	ce_assert(string::find_last(path_string, '/') == &path_string[13]);
 	
 	// Test substring
 	char string_buffer[64];
 	
 	memset(string_buffer, 'a', 64);
 	string::substring(string::begin(hello_string), string::end(hello_string), string_buffer, 64);
-	assert(string::strcmp(hello_string, string_buffer) == 0);
+	ce_assert(string::strcmp(hello_string, string_buffer) == 0);
 	
 	memset(string_buffer, 'a', 64);
 	string::substring(string::begin(hello_string), &hello_string[11], string_buffer, 64);
-	assert(string::strcmp(string_buffer, "/h.ello.eve") == 0);
+	ce_assert(string::strcmp(string_buffer, "/h.ello.eve") == 0);
 	
 	memset(string_buffer, 'a', 64);
 	string::substring(string::begin(hello_string), string::end(hello_string), string_buffer, 5);
-	assert(string::strcmp(string_buffer, "/h.el") == 0);
+	ce_assert(string::strcmp(string_buffer, "/h.el") == 0);
 }
 

+ 3 - 3
tools/editors/fontgen/fontgen.cpp

@@ -111,7 +111,7 @@ Image* BuildFontImage(const char* ttfFont, ushort ttfSize, ushort ttfResolution)
 
 	// Find the biggest character
 	// For each range
-	assert(mCodePointRangeList.GetSize() % 2 == 0);
+	ce_assert(mCodePointRangeList.GetSize() % 2 == 0);
 	for (int i = 0; i < mCodePointRangeList.GetSize(); i += 2)
 	{
 		uint j = mCodePointRangeList[i + 0];
@@ -174,7 +174,7 @@ Image* BuildFontImage(const char* ttfFont, ushort ttfSize, ushort ttfResolution)
 	FileStream fileStream(SOM_WRITE, Str(ttfFont) + Str(".txt"));
 	TextWriter fileWriter(&fileStream);
 
-	assert(mCodePointRangeList.GetSize() % 2 == 0);
+	ce_assert(mCodePointRangeList.GetSize() % 2 == 0);
 	// For each range
 	for (int i = 0; i < mCodePointRangeList.GetSize(); i += 2)
 	{
@@ -254,7 +254,7 @@ Image* BuildFontImage(const char* ttfFont, ushort ttfSize, ushort ttfResolution)
 
 void AddCodePointRange(uint min, uint max)
 {
-	assert(min <= max);
+	ce_assert(min <= max);
 
 	mCodePointRangeList.Append(min);
 	mCodePointRangeList.Append(max);

+ 1 - 1
tools/editors/world-editor/CrownDrawingArea.cpp

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "CrownDrawingArea.h"
 #include <iostream>
 #include <gdk/gdkx.h>
-#include <cassert>
+#include "Assert.h"
 #include <cstdio>
 #include <GL/gl.h>
 #include <gtkmm/window.h>

+ 2 - 5
tools/editors/world-editor/terrain/Heightfield.cpp

@@ -136,9 +136,6 @@ void Heightfield::set_max_altitude(float max)
 //-----------------------------------------------------------------------------
 float Heightfield::altitude(uint32_t x, uint32_t y) const
 {
-	assert(x < m_width);
-	assert(y < m_height);
-
 	return m_altitudes[coords_to_index(x, y)];
 }
 
@@ -165,8 +162,8 @@ void Heightfield::set_altitudes(float altitude)
 //-----------------------------------------------------------------------------
 uint32_t Heightfield::coords_to_index(uint32_t x, uint32_t y) const
 {
-	assert(x < m_width);
-	assert(y < m_height);
+	ce_assert(x < m_width, "X coordinates beyond heightfield width");
+	ce_assert(y < m_height, "Y coordinates beyond heightfield height");
 
 	return m_width * y + x;
 }