Просмотр исходного кода

Merge branch 'master' into rendering-2

Conflicts:
	samples/lua/CMakeLists.txt
	samples/terrain/CMakeLists.txt
	samples/terrain/terrain_main.cpp
	src/CMakeLists.txt
	src/Device.cpp
	src/os/win/Mutex.h
	src/os/win/Thread.h
	src/renderers/gl/GLRenderer.h
mikymod 12 лет назад
Родитель
Сommit
175c842e71
58 измененных файлов с 698 добавлено и 445 удалено
  1. 1 2
      CMakeLists.txt
  2. 10 0
      samples/lua/CMakeLists.txt
  3. 12 0
      samples/lua/lua/lua/game.lua
  4. 3 6
      samples/terrain/CMakeLists.txt
  5. 2 2
      samples/terrain/Terrain.h
  6. 6 12
      samples/terrain/terrain_main.cpp
  7. 4 4
      src/ArchiveBundle.h
  8. 15 18
      src/CMakeLists.txt
  9. 3 2
      src/Crown.h
  10. 21 20
      src/Device.cpp
  11. 7 2
      src/Device.h
  12. 2 2
      src/FileBundle.h
  13. 3 3
      src/ResourceManager.h
  14. 0 176
      src/Skybox.cpp
  15. 26 0
      src/TextResource.cpp
  16. 26 0
      src/TextResource.h
  17. 26 0
      src/TextureResource.cpp
  18. 3 0
      src/core/Assert.h
  19. 2 2
      src/core/compressors/ZipCompressor.h
  20. 14 14
      src/core/filesystem/DiskFile.h
  21. 3 3
      src/core/filesystem/File.cpp
  22. 3 5
      src/core/filesystem/Filesystem.cpp
  23. 2 2
      src/core/filesystem/Filesystem.h
  24. 16 16
      src/core/filesystem/MemoryFile.h
  25. 16 16
      src/core/filesystem/NullFile.h
  26. 2 2
      src/core/mem/Allocator.cpp
  27. 15 15
      src/core/mem/HeapAllocator.cpp
  28. 6 6
      src/core/mem/HeapAllocator.h
  29. 82 0
      src/core/mem/LinearAllocator.cpp
  30. 66 0
      src/core/mem/LinearAllocator.h
  31. 1 1
      src/core/mem/Memory.cpp
  32. 30 2
      src/core/mem/Memory.h
  33. 2 2
      src/core/mem/ProxyAllocator.h
  34. 97 0
      src/core/mem/StackAllocator.cpp
  35. 26 31
      src/core/mem/StackAllocator.h
  36. 2 0
      src/lua/CMakeLists.txt
  37. 27 0
      src/lua/DeviceBinds.cpp
  38. 2 0
      src/lua/LuaEnvironment.cpp
  39. 2 0
      src/lua/LuaEnvironment.h
  40. 2 2
      src/os/OS.h
  41. 2 0
      src/os/posix/Cond.cpp
  42. 2 0
      src/os/posix/Mutex.cpp
  43. 3 1
      src/os/posix/Thread.cpp
  44. 1 3
      src/os/win/Mutex.h
  45. 3 3
      src/renderers/gl/GLRenderer.h
  46. 14 4
      tests/allocators.cpp
  47. 2 2
      tests/compressors.cpp
  48. 1 1
      tests/containers.cpp
  49. 14 13
      tests/messages.cpp
  50. 32 32
      tests/paths.cpp
  51. 12 12
      tests/strings.cpp
  52. 2 1
      tools/compilers/CMakeLists.txt
  53. 6 0
      tools/compilers/Compiler.cpp
  54. 3 1
      tools/compilers/Compiler.h
  55. 5 0
      tools/compilers/resource-compiler.py
  56. 3 1
      tools/editors/resource-browser/CMakeLists.txt
  57. 3 1
      tools/editors/toolchain/CMakeLists.txt
  58. 2 2
      tools/editors/world-editor/terrain/Heightfield.h

+ 1 - 2
CMakeLists.txt

@@ -26,9 +26,9 @@ set (CROWN_INCLUDES
 	${CMAKE_SOURCE_DIR}/src/input
 	${CMAKE_SOURCE_DIR}/src/renderers
 	${CMAKE_SOURCE_DIR}/src/network
+	${CMAKE_SOURCE_DIR}/src/lua
 
 	${CMAKE_SOURCE_DIR}/game
-	${CMAKE_SOURCE_DIR}/lua
 )
 
 # always debug mode for now
@@ -83,7 +83,6 @@ link_directories(${CROWN_THIRD_LIBS})
 
 # add build directories
 add_subdirectory(src)
-add_subdirectory(lua)
 add_subdirectory(${CROWN_THIRD})
 
 if (CROWN_BUILD_TOOLS)

+ 10 - 0
samples/lua/CMakeLists.txt

@@ -4,10 +4,20 @@ set (SRC
 	lua.cpp
 )
 
+<<<<<<< HEAD
 #add_definitions(-Wl,-E)
 #add_library (game SHARED ${SRC})
 #target_link_libraries(game crown)
 
 
 #install (TARGETS game DESTINATION bin/lua_sample)
+=======
+add_definitions(-Wl,-E)
+add_library (game-lua SHARED ${SRC})
+target_link_libraries(game-lua crown crownlua)
 
+set_target_properties (game-lua PROPERTIES OUTPUT_NAME game)
+>>>>>>> master
+
+install (DIRECTORY lua DESTINATION samples)
+install (TARGETS game-lua DESTINATION samples/lua)

+ 12 - 0
samples/lua/lua/lua/game.lua

@@ -0,0 +1,12 @@
+function init()
+	print("Hello from lua!!!")
+end
+
+function shutdown()
+end
+
+function frame(dt)
+	if Keyboard.key_pressed(65) then
+		Device.stop()
+	end
+end

+ 3 - 6
samples/terrain/CMakeLists.txt

@@ -1,7 +1,5 @@
 cmake_minimum_required(VERSION 2.8)
 
-project(sample-terrain)
-
 set (SRC
 	terrain_main.cpp
 	Terrain.cpp
@@ -11,9 +9,8 @@ set (HEADERS
 	Terrain.h
 )
 
-add_library (game SHARED ${SRC} ${HEADERS})
-target_link_libraries(game crown)
+add_executable(${CROWN_EXECUTABLE_NAME} ${CROWN_MAIN_SRC} ${SRC} ${HEADERS})
+target_link_libraries(${CROWN_EXECUTABLE_NAME} crown)
 
 install (DIRECTORY terrain DESTINATION samples)
-install (TARGETS game DESTINATION samples/terrain)
-
+install (TARGETS ${CROWN_EXECUTABLE_NAME} DESTINATION samples/terrain)

+ 2 - 2
samples/terrain/Terrain.h

@@ -31,7 +31,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Intersection.h"
 #include "Ray.h"
 #include "Renderer.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 
 #define MAX_BRUSH_SIZE 256
 
@@ -74,7 +74,7 @@ public:
 
 private:
 
-	MallocAllocator	m_allocator;
+	HeapAllocator	m_allocator;
 
 	uint32_t		mSizeX;				// X in meters
 	uint32_t		mSizeZ;				// Z in meters

+ 6 - 12
samples/terrain/terrain_main.cpp

@@ -85,8 +85,6 @@ public:
 		// Add a movable camera
 		cam = CE_NEW(m_allocator, Camera)(start, 90.0f, 1.6f);
 		system = CE_NEW(m_allocator, FPSSystem)(cam, 10.0f, 2.5f);
-		// Add a skybox
-		skybox = CE_NEW(m_allocator, Skybox)(Vec3::ZERO, true);
 
 		terrain.CreateTerrain(64, 64, 1, 0.0f);
 		terrain.PlotCircle(4, 4, 4, 2);
@@ -117,7 +115,6 @@ public:
 		device()->unload(red_up);
 		device()->unload(red_down);
 
-		CE_DELETE(m_allocator, skybox);
 		CE_DELETE(m_allocator, system);
 		CE_DELETE(m_allocator, cam);
 	}
@@ -136,10 +133,8 @@ public:
 		}
 		system->update(dt);
 
-		if (skybox)
-		{
-			skybox->Render();
-		}
+		renderer->set_lighting(false);
+		renderer->set_texturing(0, false);
 
 		ray.set_origin(cam->position());
 		ray.set_direction(cam->look_at());
@@ -180,10 +175,9 @@ public:
 
 private:
 
-	MallocAllocator m_allocator;
+	HeapAllocator m_allocator;
 	FPSSystem* system;
 	Camera* cam;
-	Skybox* skybox;
 	Mat4 ortho;
 	Terrain terrain;
 
@@ -218,17 +212,17 @@ WndCtrl m_ctrl;
 
 extern "C"
 {
-	__declspec(dllexport) void init_1()
+	void init()
 	{
 		m_scene.on_load();
 	}
 
-	__declspec(dllexport) void shutdown_1()
+	void shutdown()
 	{
 		m_scene.on_unload();
 	}
 
-	__declspec(dllexport) void frame_1(float dt)
+	void frame(float dt)
 	{
 		m_scene.update(dt);
 	}

+ 4 - 4
src/ArchiveBundle.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Bundle.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 
 namespace crown
 {
@@ -63,15 +63,15 @@ public:
 					ArchiveBundle(Filesystem& fs);
 					~ArchiveBundle();
 
-	/// @a copydoc Bundle::open()
+	/// @copydoc Bundle::open()
 	DiskFile*		open(ResourceId name);
 
-	/// @a copydoc Bundle::close()
+	/// @copydoc Bundle::close()
 	void			close(DiskFile* resource);
 
 private:
 
-	MallocAllocator	m_allocator;
+	HeapAllocator	m_allocator;
 
 	Filesystem&		m_filesystem;
 

+ 15 - 18
src/CMakeLists.txt

@@ -3,7 +3,6 @@ set (SRC
 	Device.cpp
 	MaterialResource.cpp
 	ResourceManager.cpp
-	Skybox.cpp
 
 	TextureResource.cpp
 	TextResource.cpp
@@ -27,7 +26,6 @@ set (HEADERS
 	Resource.h
 	ResourceManager.h
 	Bundle.h
-	Skybox.h
 
 	TextureResource.h
 	TextResource.h
@@ -153,7 +151,9 @@ set (MEM_SRC
 	core/mem/malloc.c
 	core/mem/Memory.cpp
 	core/mem/Allocator.cpp
-	core/mem/MallocAllocator.cpp
+	core/mem/HeapAllocator.cpp
+	core/mem/LinearAllocator.cpp
+	core/mem/StackAllocator.cpp
 	core/mem/ProxyAllocator.cpp
 )
 
@@ -161,7 +161,9 @@ set (MEM_HEADERS
 	core/mem/malloc.h
 	core/mem/Memory.h
 	core/mem/Allocator.h
-	core/mem/MallocAllocator.h
+	core/mem/HeapAllocator.h
+	core/mem/LinearAllocator.h
+	core/mem/StackAllocator.h
 	core/mem/ProxyAllocator.h
 )
 
@@ -400,6 +402,9 @@ set (CROWN_HEADERS
 
 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/Config.h)
 
+# Lua bindings and systems
+add_subdirectory(lua)
+
 include_directories(${CROWN_INCLUDES} ${CROWN_THIRD_INCLUDES})
 link_directories(${CROWN_THIRD_LIBS})
 
@@ -411,27 +416,19 @@ if (WINDOWS)
 add_definitions(/link /OPT:NOREF)
 endif (WINDOWS)
 
-#add_library(crown SHARED ${CROWN_SOURCES} ${CROWN_HEADERS})
+add_library(crown SHARED ${CROWN_SOURCES} ${CROWN_HEADERS})
 
 # TEST - generates .lib 
 
-#add_library(crown-static STATIC ${CROWN_SOURCES} ${CROWN_HEADERS})
-#set_target_properties(crown-static PROPERTIES OUTPUT_NAME "crown")
+add_library(crown-static STATIC ${CROWN_SOURCES} ${CROWN_HEADERS})
+set_target_properties(crown-static PROPERTIES OUTPUT_NAME "crown")
 #set_target_properties(crown-static PROPERTIES PREFIX "lib")
-#set_target_properties(crown PROPERTIES CLEAN_DIRECT_OUTPUT 1)
-#set_target_properties(crown-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+set_target_properties(crown PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+set_target_properties(crown-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
 
 # ENDTEST
 
-add_executable(${CROWN_EXECUTABLE_NAME} ${CROWN_MAIN_SRC} ${CROWN_SOURCES} ${CROWN_HEADERS})
-#target_link_libraries(${CROWN_EXECUTABLE_NAME} crown)
-
-#install (TARGETS crown DESTINATION lib/${CMAKE_PROJECT_NAME})
-
-#------------------------------------------------------------------------------
-# Installing executable
-#------------------------------------------------------------------------------
-install (TARGETS ${CROWN_EXECUTABLE_NAME} DESTINATION bin)
+install (TARGETS crown DESTINATION lib/${CMAKE_PROJECT_NAME})
 
 #------------------------------------------------------------------------------
 #Installing headers

+ 3 - 2
src/Crown.h

@@ -73,7 +73,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 // Core/Mem
 #include "Memory.h"
 #include "Allocator.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
+#include "LinearAllocator.h"
+#include "StackAllocator.h"
 #include "ProxyAllocator.h"
 
 // Core/Filesystem
@@ -105,7 +107,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "ArchiveBundle.h"
 #include "FileBundle.h"
 #include "ResourceManager.h"
-#include "Skybox.h"
 
 #include "TextResource.h"
 #include "TextureResource.h"

+ 21 - 20
src/Device.cpp

@@ -61,11 +61,15 @@ static void (*game_frame)(float) = NULL;
 
 //-----------------------------------------------------------------------------
 Device::Device() :
+	m_allocator(m_subsystems_heap, MAX_SUBSYSTEMS_HEAP),
+
 	m_preferred_window_width(1000),
 	m_preferred_window_height(625),
 	m_preferred_window_fullscreen(0),
 	m_preferred_mode(MODE_RELEASE),
 
+	m_quit_after_init(0),
+
 	m_is_init(false),
 	m_is_running(false),
 
@@ -156,6 +160,11 @@ bool Device::init(int argc, char** argv)
 
 	start();
 
+	if (m_quit_after_init == 1)
+	{
+		shutdown();
+	}
+
 	return true;
 }
 
@@ -219,6 +228,8 @@ void Device::shutdown()
 		CE_DELETE(m_allocator, m_filesystem);
 	}
 
+	m_allocator.clear();
+
 	m_is_init = false;
 }
 
@@ -457,12 +468,13 @@ void Device::parse_command_line(int argc, char** argv)
 {
 	static ArgsOption options[] = 
 	{
-		"help",       AOA_NO_ARGUMENT,       NULL,        'i',
-		"root-path",  AOA_REQUIRED_ARGUMENT, NULL,        'r',
-		"width",      AOA_REQUIRED_ARGUMENT, NULL,        'w',
-		"height",     AOA_REQUIRED_ARGUMENT, NULL,        'h',
-		"fullscreen", AOA_NO_ARGUMENT,       &m_preferred_window_fullscreen, 1,
-		"dev",        AOA_NO_ARGUMENT,       &m_preferred_mode, MODE_DEVELOPMENT,
+
+		"help",             AOA_NO_ARGUMENT,       NULL,        'i',
+		"root-path",        AOA_REQUIRED_ARGUMENT, NULL,        'r',
+		"width",            AOA_REQUIRED_ARGUMENT, NULL,        'w',
+		"height",           AOA_REQUIRED_ARGUMENT, NULL,        'h',
+		"fullscreen",       AOA_NO_ARGUMENT,       &m_preferred_window_fullscreen, 1,
+		"quit-after-init",  AOA_NO_ARGUMENT,       &m_quit_after_init, 1,
 		NULL, 0, NULL, 0
 	};
 
@@ -526,21 +538,8 @@ void Device::check_preferred_settings()
 //-----------------------------------------------------------------------------
 void Device::read_engine_settings()
 {
-	/*
-	DiskFile* file = m_filesystem->open("crown.cfg", FOM_READ);
-	MallocAllocator allocator;
-	JSONParser json(allocator, file);
-
-	char value[128];
-	int  width;
-	json.get_root().get_array("crown", 0).get_string("boot").to_string(value);
-	json.get_root().get_number("width").to_int(width);
-	os::printf("value = %s\n", value);
-	os::printf("width = %d\n", width);
-	*/
 }
 
-
 //-----------------------------------------------------------------------------
 void Device::print_help_message()
 {
@@ -556,7 +555,9 @@ void Device::print_help_message()
 	"  --width <width>       Set the <width> of the render window.\n"
 	"  --height <width>      Set the <height> of the render window.\n"
 	"  --fullscreen          Start in fullscreen.\n"
-	"  --dev                 Run the engine in development mode\n");
+	"  --dev                 Run the engine in development mode\n"
+	"  --quit-after-init     Quit the engine immediately after the\n"
+	"                        initialization. Used only for debugging.\n");
 }
 
 Device g_device;

+ 7 - 2
src/Device.h

@@ -29,9 +29,11 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Types.h"
 #include "Config.h"
 #include "OS.h"
-#include "MallocAllocator.h"
+#include "LinearAllocator.h"
 #include "Resource.h"
 
+#define MAX_SUBSYSTEMS_HEAP 1024 * 1024
+
 namespace crown
 {
 
@@ -128,7 +130,8 @@ private:
 private:
 
 	// Used to allocate all subsystems
-	MallocAllocator			m_allocator;
+	uint8_t					m_subsystems_heap[MAX_SUBSYSTEMS_HEAP];
+	LinearAllocator			m_allocator;
 
 	// Preferred settings from command line
 	int32_t					m_preferred_window_width;
@@ -137,6 +140,8 @@ private:
 	int32_t					m_preferred_mode;
 	char					m_preferred_root_path[MAX_PATH_LENGTH];
 
+	int32_t					m_quit_after_init;
+
 	bool					m_is_init		: 1;
 	bool					m_is_running	: 1;
 

+ 2 - 2
src/FileBundle.h

@@ -54,10 +54,10 @@ public:
 					FileBundle(Filesystem& fs);
 					~FileBundle();
 
-	/// @a copydoc Bundle::open()
+	/// @copydoc Bundle::open()
 	DiskFile*		open(ResourceId name);
 
-	/// @a copydoc Bundle::close()
+	/// @copydoc Bundle::close()
 	void			close(DiskFile* resource);
 
 

+ 3 - 3
src/ResourceManager.h

@@ -30,7 +30,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "List.h"
 #include "Queue.h"
 #include "Resource.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 #include "Thread.h"
 #include "Mutex.h"
 #include "Cond.h"
@@ -150,9 +150,9 @@ private:
 	// Archive whether to look for resources
 	Bundle&					m_resource_bundle;
 	// Used to strore resource memory
-	MallocAllocator			m_resource_allocator;
+	HeapAllocator			m_resource_allocator;
 
-	MallocAllocator			m_allocator;
+	HeapAllocator			m_allocator;
 	// The master lookup table
 	List<ResourceEntry>		m_resources;
 

+ 0 - 176
src/Skybox.cpp

@@ -1,176 +0,0 @@
-/*
-Copyright (c) 2013 Daniele Bartolini, Michele Rossi
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "Skybox.h"
-#include "Device.h"
-#include "Types.h"
-#include "Mat4.h"
-#include "Camera.h"
-#include "TextureResource.h"
-#include "Material.h"
-#include "VertexBuffer.h"
-#include "IndexBuffer.h"
-#include "Renderer.h"
-
-namespace crown
-{
-
-Skybox::Skybox(const Vec3& position, bool visible)
-{
-//	// Setup bounding box
-////	mBoundingBox.SetMin(Vec3(0.0f, 0.0f, 0.0f));
-////	mBoundingBox.SetMax(Vec3(0.0f, 0.0f, 0.0f));
-
-//	// North face
-//	mVertexData[0] = VertexData(Vec3(-1.0f, -1.0f, -1.0f), Vec3(0, 0, 0), Vec2(0.0f, 0.0f), Color4::WHITE);
-//	mVertexData[1] = VertexData(Vec3(1.0f, -1.0f, -1.0f), Vec3(0, 0, 0), Vec2(1.0f, 0.0f), Color4::WHITE);
-//	mVertexData[2] = VertexData(Vec3(1.0f, 1.0f, -1.0f), Vec3(0, 0, 0), Vec2(1.0f, 1.0f), Color4::WHITE);
-//	mVertexData[3] = VertexData(Vec3(-1.0f, 1.0f, -1.0f), Vec3(0, 0, 0), Vec2(0.0f, 1.0f), Color4::WHITE);
-
-//	// South face
-//	mVertexData[4] = VertexData(Vec3(1.0f, -1.0f, 1.0f), Vec3(0, 0, 0), Vec2(0.0f, 0.0f), Color4::WHITE);
-//	mVertexData[5] = VertexData(Vec3(-1.0f, -1.0f, 1.0f), Vec3(0, 0, 0), Vec2(1.0f, 0.0f), Color4::WHITE);
-//	mVertexData[6] = VertexData(Vec3(-1.0f, 1.0f, 1.0f), Vec3(0, 0, 0), Vec2(1.0f, 1.0f), Color4::WHITE);
-//	mVertexData[7] = VertexData(Vec3(1.0f, 1.0f, 1.0f), Vec3(0, 0, 0), Vec2(0.0f, 1.0f), Color4::WHITE);
-
-//	// West face
-//	mVertexData[8] = VertexData(Vec3(-1.0f, -1.0f, 1.0f), Vec3(0, 0, 0), Vec2(0.0f, 0.0f), Color4::WHITE);
-//	mVertexData[9] = VertexData(Vec3(-1.0f, -1.0f, -1.0f), Vec3(0, 0, 0), Vec2(1.0f, 0.0f), Color4::WHITE);
-//	mVertexData[10] = VertexData(Vec3(-1.0f, 1.0f, -1.0f), Vec3(0, 0, 0), Vec2(1.0f, 1.0f), Color4::WHITE);
-//	mVertexData[11] = VertexData(Vec3(-1.0f, 1.0f, 1.0f), Vec3(0, 0, 0), Vec2(0.0f, 1.0f), Color4::WHITE);
-
-//	// East face
-//	mVertexData[12] = VertexData(Vec3(1.0f, -1.0f, -1.0f), Vec3(0, 0, 0), Vec2(0.0f, 0.0f), Color4::WHITE);
-//	mVertexData[13] = VertexData(Vec3(1.0f, -1.0f, 1.0f), Vec3(0, 0, 0), Vec2(1.0f, 0.0f), Color4::WHITE);
-//	mVertexData[14] = VertexData(Vec3(1.0f, 1.0f, 1.0f), Vec3(0, 0, 0), Vec2(1.0f, 1.0f), Color4::WHITE);
-//	mVertexData[15] = VertexData(Vec3(1.0f, 1.0f, -1.0f), Vec3(0, 0, 0), Vec2(0.0f, 1.0f), Color4::WHITE);
-
-//	// Up face
-//	mVertexData[16] = VertexData(Vec3(-1.0f, 1.0f, -1.0f), Vec3(0, 0, 0), Vec2(0.0f, 0.0f), Color4::WHITE);
-//	mVertexData[17] = VertexData(Vec3(1.0f, 1.0f, -1.0f), Vec3(0, 0, 0), Vec2(1.0f, 0.0f), Color4::WHITE);
-//	mVertexData[18] = VertexData(Vec3(1.0f, 1.0f, 1.0f), Vec3(0, 0, 0), Vec2(1.0f, 1.0f), Color4::WHITE);
-//	mVertexData[19] = VertexData(Vec3(-1.0f, 1.0f, 1.0f), Vec3(0, 0, 0), Vec2(0.0f, 1.0f), Color4::WHITE);
-
-//	// Down face
-//	mVertexData[20] = VertexData(Vec3(-1.0f, -1.0f, 1.0f), Vec3(0, 0, 0), Vec2(0.0f, 0.0f), Color4::WHITE);
-//	mVertexData[21] = VertexData(Vec3(1.0f, -1.0f, 1.0f), Vec3(0, 0, 0), Vec2(1.0f, 0.0f), Color4::WHITE);
-//	mVertexData[22] = VertexData(Vec3(1.0f, -1.0f, -1.0f), Vec3(0, 0, 0), Vec2(1.0f, 1.0f), Color4::WHITE);
-//	mVertexData[23] = VertexData(Vec3(-1.0f, -1.0f, -1.0f), Vec3(0, 0, 0), Vec2(0.0f, 1.0f), Color4::WHITE);
-
-//	mFaceData[0] = FaceData(0, 1, 2);
-//	mFaceData[1] = FaceData(0, 2, 3);
-
-//	mFaceData[2] = FaceData(4, 5, 6);
-//	mFaceData[3] = FaceData(4, 6, 7);
-
-//	mFaceData[4] = FaceData(8, 9, 10);
-//	mFaceData[5] = FaceData(8, 10, 11);
-
-//	mFaceData[6] = FaceData(12, 13, 14);
-//	mFaceData[7] = FaceData(12, 14, 15);
-
-//	mFaceData[8] = FaceData(16, 17, 18);
-//	mFaceData[9] = FaceData(16, 18, 19);
-
-//	mFaceData[10] = FaceData(20, 21, 22);
-//	mFaceData[11] = FaceData(20, 22, 23);
-
-//	mVertexBuffer = GetDevice()->GetRenderer()->CreateVertexBuffer();
-//	mIndexBuffer[0] = GetDevice()->GetRenderer()->CreateIndexBuffer();
-//	mIndexBuffer[1] = GetDevice()->GetRenderer()->CreateIndexBuffer();
-//	mIndexBuffer[2] = GetDevice()->GetRenderer()->CreateIndexBuffer();
-//	mIndexBuffer[3] = GetDevice()->GetRenderer()->CreateIndexBuffer();
-//	mIndexBuffer[4] = GetDevice()->GetRenderer()->CreateIndexBuffer();
-//	mIndexBuffer[5] = GetDevice()->GetRenderer()->CreateIndexBuffer();
-
-//	mVertexBuffer->SetVertexData((VertexBufferMode) (VBM_TEXTURE_COORDS | VBM_NORMAL_COORDS | VBM_COLOR_COORDS), (float*) &mVertexData[0], 24);
-//	mIndexBuffer[0]->SetIndexData(&mFaceData[0].vertex[0], 6);
-//	mIndexBuffer[1]->SetIndexData(&mFaceData[2].vertex[0], 6);
-//	mIndexBuffer[2]->SetIndexData(&mFaceData[4].vertex[0], 6);
-//	mIndexBuffer[3]->SetIndexData(&mFaceData[6].vertex[0], 6);
-//	mIndexBuffer[4]->SetIndexData(&mFaceData[8].vertex[0], 6);
-//	mIndexBuffer[5]->SetIndexData(&mFaceData[10].vertex[0], 6);
-}
-
-Skybox::~Skybox()
-{
-}
-
-void Skybox::Render()
-{
-//	Renderer* renderer = GetDevice()->GetRenderer();
-
-////	Camera* camera = mCreator->GetCurrentCamera();
-//	Mat4 mat;// = camera->GetAbsoluteTransformation();
-//	mat.load_identity();
-//	Mat4 mat2;
-
-//	mat2.load_identity();
-//	mat2.set_translation(mat.get_translation());
-
-//	float near;
-//	float far;
-//	float scale;
-
-//	near = 0.1f;//camera->GetNearClipDistance();
-//	far = 100.0f;//camera->GetFarClipDistance();
-//	scale = (near + far) * 0.5f;
-
-//	mat2.set_scale(Vec3(scale, scale, scale));
-
-//	renderer->_SetDepthTest(false);
-//	renderer->_SetDepthWrite(false);
-
-//	renderer->_SetTexturing(0, true);
-
-//	renderer->SetMatrix(MT_MODEL, mat2);
-
-//	renderer->SetTexture(0, mSkyboxFace[SF_NORTH]);
-//	renderer->RenderVertexIndexBuffer(mVertexBuffer, mIndexBuffer[0]);
-
-//	renderer->SetTexture(0, mSkyboxFace[SF_SOUTH]);
-//	renderer->RenderVertexIndexBuffer(mVertexBuffer, mIndexBuffer[1]);
-
-//	renderer->SetTexture(0, mSkyboxFace[SF_WEST]);
-//	renderer->RenderVertexIndexBuffer(mVertexBuffer, mIndexBuffer[2]);
-
-//	renderer->SetTexture(0, mSkyboxFace[SF_EAST]);
-//	renderer->RenderVertexIndexBuffer(mVertexBuffer, mIndexBuffer[3]);
-
-//	renderer->SetTexture(0, mSkyboxFace[SF_UP]);
-//	renderer->RenderVertexIndexBuffer(mVertexBuffer, mIndexBuffer[4]);
-
-//	renderer->SetTexture(0, mSkyboxFace[SF_DOWN]);
-//	renderer->RenderVertexIndexBuffer(mVertexBuffer, mIndexBuffer[5]);
-
-//	renderer->_SetDepthTest(true);
-//	renderer->_SetDepthWrite(true);
-
-//	renderer->_SetTexturing(0, false);
-}
-
-} // namespace crown
-

+ 26 - 0
src/TextResource.cpp

@@ -1,3 +1,29 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
 #include "TextResource.h"
 #include "DiskFile.h"
 #include "Bundle.h"

+ 26 - 0
src/TextResource.h

@@ -1,3 +1,29 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
 #pragma once
 
 #include "Types.h"

+ 26 - 0
src/TextureResource.cpp

@@ -1,3 +1,29 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
 #include "TextureResource.h"
 #include "Bundle.h"
 #include "Log.h"

+ 3 - 0
src/core/Assert.h

@@ -38,3 +38,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #else
 	#define CE_ASSERT(condition, message, ...) ((void)0)
 #endif
+
+#define CE_ASSERT_NOT_NULL(x) CE_ASSERT(x != NULL, "Parameter must be not null")
+

+ 2 - 2
src/core/compressors/ZipCompressor.h

@@ -39,10 +39,10 @@ public:
 				ZipCompressor(Allocator& allocator);
 				~ZipCompressor();
 	
-	/// @a copydoc Compressor::compress()
+	/// @copydoc Compressor::compress()
 	uint8_t* 	compress(const void* data, size_t in_size, size_t& out_size);
 
-	/// @a copydoc Compressor::uncompress()
+	/// @copydoc Compressor::uncompress()
 	uint8_t* 	uncompress(const void* data, size_t in_size, size_t& out_size);
 };
 

+ 14 - 14
src/core/filesystem/DiskFile.h

@@ -42,46 +42,46 @@ public:
 					DiskFile(FileOpenMode mode, const char* filename);
 	virtual			~DiskFile();
 
-	/// @a copydoc File::seek() 
+	/// @copydoc File::seek() 
 	void			seek(size_t position);
 
-	/// @a copydoc File::seek_to_end() 
+	/// @copydoc File::seek_to_end() 
 	void			seek_to_end();
 
-	/// @a copydoc File::skip() 
+	/// @copydoc File::skip() 
 	void			skip(size_t bytes);
 
-	/// @a copydoc File::read() 
+	/// @copydoc File::read() 
 	void			read(void* buffer, size_t size);
 
-	/// @a copydoc File::write() 
+	/// @copydoc File::write() 
 	void			write(const void* buffer, size_t size);
 
-	/// @a copydoc File::copy_to() 
+	/// @copydoc File::copy_to() 
 	bool			copy_to(File& file, size_t size = 0);
 
-	/// @a copydoc File::flush() 
+	/// @copydoc File::flush() 
 	void			flush();
 
-	/// @a copydoc File::end_of_file() 
+	/// @copydoc File::end_of_file() 
 	bool			end_of_file() const;
 
-	/// @a copydoc File::is_valid() 
+	/// @copydoc File::is_valid() 
 	bool			is_valid() const;
 
-	/// @a copydoc File::size() 
+	/// @copydoc File::size() 
 	size_t			size() const;
 
-	/// @a copydoc File::position() 
+	/// @copydoc File::position() 
 	size_t			position() const;
 
-	/// @a copydoc File::can_read() 
+	/// @copydoc File::can_read() 
 	bool			can_read() const;
 
-	/// @a copydoc File::can_write() 
+	/// @copydoc File::can_write() 
 	bool			can_write() const;
 
-	/// @a copydoc File::can_seek() 
+	/// @copydoc File::can_seek() 
 	bool			can_seek() const;
 
 protected:

+ 3 - 3
src/core/filesystem/File.cpp

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "File.h"
 #include "Types.h"
 #include "Compressor.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 
 namespace crown
 {
@@ -35,7 +35,7 @@ namespace crown
 //-----------------------------------------------------------------------------
 bool File::compress_to(File& file, size_t size, size_t& zipped_size, Compressor& compressor)
 {
-	MallocAllocator allocator;
+	HeapAllocator allocator;
 	void* in_buffer = (void*)allocator.allocate(size);
 
 	read(in_buffer, size);
@@ -50,7 +50,7 @@ bool File::compress_to(File& file, size_t size, size_t& zipped_size, Compressor&
 //-----------------------------------------------------------------------------
 bool File::uncompress_to(File& file, size_t& unzipped_size, Compressor& compressor)
 {
-	MallocAllocator allocator;
+	HeapAllocator allocator;
 
 	size_t file_size = size();
 	void* in_buffer = (void*)allocator.allocate(file_size);

+ 3 - 5
src/core/filesystem/Filesystem.cpp

@@ -188,12 +188,10 @@ const char* Filesystem::os_path(const char* relative_path)
 //-----------------------------------------------------------------------------
 DiskFile* Filesystem::open(const char* relative_path, FileOpenMode mode)
 {
-	FilesystemEntry info;
-
-	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);
+	CE_ASSERT(exists(relative_path), "File does not exist: %s", relative_path);
+	CE_ASSERT(is_file(relative_path), "File is not a regular file: %s", relative_path);
 
-	return CE_NEW(m_allocator, DiskFile)(mode, info.os_path);
+	return CE_NEW(m_allocator, DiskFile)(mode, os_path(relative_path));
 }
 
 //-----------------------------------------------------------------------------

+ 2 - 2
src/core/filesystem/Filesystem.h

@@ -29,7 +29,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "StringUtils.h"
 #include "OS.h"
 #include "File.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 
 namespace crown
 {
@@ -153,7 +153,7 @@ private:
 	
 private:
 
-	MallocAllocator		m_allocator;
+	HeapAllocator		m_allocator;
 
 	char				m_root_path[MAX_PATH_LENGTH];
 

+ 16 - 16
src/core/filesystem/MemoryFile.h

@@ -85,52 +85,52 @@ class MemoryFile: public File
 {
 public:
 
-	/// @a copydoc File::File()
+	/// @copydoc File::File()
 						MemoryFile(MemoryBuffer* buffer, FileOpenMode mode);
 
-	/// @a copydoc File::~File()
+	/// @copydoc File::~File()
 	virtual				~MemoryFile();
 
-	/// @a copydoc File::seek()
+	/// @copydoc File::seek()
 	void				seek(size_t position);
 
-	/// @a copydoc File::seek_to_end()
+	/// @copydoc File::seek_to_end()
 	void				seek_to_end();
 
-	/// @a copydoc File::skip()
+	/// @copydoc File::skip()
 	void				skip(size_t bytes);
 
-	/// @a copydoc File::read()
+	/// @copydoc File::read()
 	void				read(void* buffer, size_t size);
 
-	/// @a copydoc File::write()
+	/// @copydoc File::write()
 	void				write(const void* buffer, size_t size);
 
-	/// @a copydoc File::copy_to()
+	/// @copydoc File::copy_to()
 	bool				copy_to(File& file, size_t size = 0);
 
-	/// @a copydoc File::flush()
+	/// @copydoc File::flush()
 	void				flush();
 
-	/// @a copydoc File::end_of_file()
+	/// @copydoc File::end_of_file()
 	bool				end_of_file() const { return size() == m_memory_offset; }
 
-	/// @a copydoc File::is_valid()
+	/// @copydoc File::is_valid()
 	bool				is_valid() const { CE_ASSERT(m_memory != NULL, "Memory is NULL"); return m_memory->is_valid(); }
 
-	/// @a copydoc File::size()
+	/// @copydoc File::size()
 	size_t				size() const { CE_ASSERT(m_memory != NULL, "Memory is NULL"); return m_memory->size(); }
 
-	/// @a copydoc File::position()
+	/// @copydoc File::position()
 	size_t				position() const { return m_memory_offset; }
 
-	/// @a copydoc File::can_read()
+	/// @copydoc File::can_read()
 	bool				can_read() const { return true; }
 
-	/// @a copydoc File::can_write()
+	/// @copydoc File::can_write()
 	bool				can_write() const { return true; }
 
-	/// @a copydoc File::can_seek()
+	/// @copydoc File::can_seek()
 	bool				can_seek() const { return true; }
 
 	/// Dumps the data to the console.

+ 16 - 16
src/core/filesystem/NullFile.h

@@ -38,22 +38,22 @@ class NullFile: public File
 {
 public:
 
-	/// @a copydoc File::File()
+	/// @copydoc File::File()
 				NullFile(FileOpenMode mode) : File(mode) {}
 
-	/// @a copydoc File::~File()
+	/// @copydoc File::~File()
 	virtual		~NullFile() {}
 
-	/// @a copydoc File::seek()
+	/// @copydoc File::seek()
 	void		seek(size_t position) { (void)position; }
 
-	/// @a copydoc File::seek_to_end()
+	/// @copydoc File::seek_to_end()
 	void		seek_to_end() {}
 
-	/// @a copydoc File::skip()
+	/// @copydoc File::skip()
 	void		skip(size_t bytes) { (void)bytes; }
 				
-	/// @a copydoc File::read()
+	/// @copydoc File::read()
 	/// @note
 	///	Fills buffer with zeroes
 	void		read(void* buffer, size_t size)
@@ -64,10 +64,10 @@ public:
 		}
 	}
 
-	/// @a copydoc File::write()
+	/// @copydoc File::write()
 	void		write(const void* buffer, size_t size) { (void)buffer; (void)size; }
 
-	/// @a copydoc File::copy_to()
+	/// @copydoc File::copy_to()
 	/// @note
 	///	Returns always true
 	bool		copy_to(File& file, size_t size = 0)
@@ -77,40 +77,40 @@ public:
 		return true;
 	}
 
-	/// @a copydoc File::flush()
+	/// @copydoc File::flush()
 	void		flush() {};
 				
-	/// @a copydoc File::is_valid()
+	/// @copydoc File::is_valid()
 	/// @note
 	///	Returns always true
 	bool		is_valid() { return true; }
 				
-	/// @a copydoc File::end_of_file()
+	/// @copydoc File::end_of_file()
 	/// @note
 	///	Returns always false
 	bool		end_of_file() { return false; }
 				
-	/// @a copydoc File::size()
+	/// @copydoc File::size()
 	/// @note
 	///	Returns always 0xFFFFFFFF
 	size_t		size() { return ~0; }
 				
-	/// @a copydoc File::position()
+	/// @copydoc File::position()
 	/// @note
 	///	Returns always zero
 	size_t		position() { return 0; }
 				
-	/// @a copydoc File::can_read()
+	/// @copydoc File::can_read()
 	/// @note
 	///	Returns always true
 	bool		can_read() { return true; }
 				
-	/// @a copydoc File::can_write()
+	/// @copydoc File::can_write()
 	/// @note
 	///	Returns always true
 	bool		can_write() { return true; }
 				
-	/// @a copydoc File::can_seek()
+	/// @copydoc File::can_seek()
 	/// @note
 	///	Returns always true
 	bool		can_seek() { return true; }

+ 2 - 2
src/core/mem/Allocator.cpp

@@ -24,12 +24,12 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 
 namespace crown
 {
 
-MallocAllocator g_default_allocator;
+HeapAllocator g_default_allocator;
 Allocator& default_allocator()
 {
 	return g_default_allocator;

+ 15 - 15
src/core/mem/MallocAllocator.cpp → src/core/mem/HeapAllocator.cpp

@@ -24,7 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 #include "Assert.h"
 #include "malloc.h"
 
@@ -32,28 +32,28 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-MallocAllocator::MallocAllocator() :
+HeapAllocator::HeapAllocator() :
 	m_allocated_size(0),
 	m_allocation_count(0)
 {
 }
 
 //-----------------------------------------------------------------------------
-MallocAllocator::~MallocAllocator()
+HeapAllocator::~HeapAllocator()
 {
-	CE_ASSERT(m_allocation_count == 0, "Missing %d deallocations", m_allocation_count);
-	CE_ASSERT(m_allocated_size == 0, "Memory leak of %d bytes", m_allocated_size);
+	CE_ASSERT(m_allocation_count == 0 && allocated_size() == 0,
+		"Missing %d deallocations causing a leak of %d bytes", m_allocation_count, allocated_size());
 }
 
 //-----------------------------------------------------------------------------
-void* MallocAllocator::allocate(size_t size, size_t align)
+void* HeapAllocator::allocate(size_t size, size_t align)
 {
 	size_t actual_size = actual_allocation_size(size, align);
 
 	Header* h = (Header*)dlmalloc(actual_size);
 	h->size = actual_size;
 
-	void* data = memory::align(h + 1, align);
+	void* data = memory::align_top(h + 1, align);
 
 	pad(h, data);
 
@@ -64,7 +64,7 @@ void* MallocAllocator::allocate(size_t size, size_t align)
 }
 
 //-----------------------------------------------------------------------------
-void MallocAllocator::deallocate(void* data)
+void HeapAllocator::deallocate(void* data)
 {
 	Header* h = header(data);
 
@@ -75,13 +75,13 @@ void MallocAllocator::deallocate(void* data)
 }
 
 //-----------------------------------------------------------------------------
-size_t MallocAllocator::allocated_size()
+size_t HeapAllocator::allocated_size()
 {
 	return m_allocated_size;
 }
 
 //-----------------------------------------------------------------------------
-size_t MallocAllocator::get_size(void* data)
+size_t HeapAllocator::get_size(void* data)
 {
 	Header* h = header(data);
 
@@ -89,13 +89,13 @@ size_t MallocAllocator::get_size(void* data)
 }
 
 //-----------------------------------------------------------------------------
-size_t MallocAllocator::actual_allocation_size(size_t size, size_t align)
+size_t HeapAllocator::actual_allocation_size(size_t size, size_t align)
 {
 	return size + align + sizeof(Header);
 }
 
 //-----------------------------------------------------------------------------
-MallocAllocator::Header* MallocAllocator::header(void* data)
+HeapAllocator::Header* HeapAllocator::header(void* data)
 {
 	uint32_t* ptr = (uint32_t*)data;
 	ptr--;
@@ -109,13 +109,13 @@ MallocAllocator::Header* MallocAllocator::header(void* data)
 }
 
 //-----------------------------------------------------------------------------
-void* MallocAllocator::data(Header* header, size_t align)
+void* HeapAllocator::data(Header* header, size_t align)
 {
-	return memory::align(header + 1, align);
+	return memory::align_top(header + 1, align);
 }
 
 //-----------------------------------------------------------------------------
-void MallocAllocator::pad(Header* header, void* data)
+void HeapAllocator::pad(Header* header, void* data)
 {
 	uint32_t* p = (uint32_t*)(header + 1);
 

+ 6 - 6
src/core/mem/MallocAllocator.h → src/core/mem/HeapAllocator.h

@@ -32,20 +32,20 @@ namespace crown
 {
 
 /// Allocator based on C malloc().
-class MallocAllocator : public Allocator
+class HeapAllocator : public Allocator
 {
 public:
 
-				MallocAllocator();
-				~MallocAllocator();
+				HeapAllocator();
+				~HeapAllocator();
 
-	/// @a copydoc Allocator::allocate()
+	/// @copydoc Allocator::allocate()
 	void*		allocate(size_t size, size_t align = memory::DEFAULT_ALIGN);
 
-	/// @a copydoc Allocator::deallocate()
+	/// @copydoc Allocator::deallocate()
 	void		deallocate(void* data);
 
-	/// @a copydoc Allocator::allocated_size()
+	/// @copydoc Allocator::allocated_size()
 	size_t		allocated_size();
 
 	/// Returns the size in bytes of the block of memory pointed by @a data

+ 82 - 0
src/core/mem/LinearAllocator.cpp

@@ -0,0 +1,82 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include "LinearAllocator.h"
+
+namespace crown
+{
+
+//-----------------------------------------------------------------------------
+LinearAllocator::LinearAllocator(void* start, size_t size) :
+	m_physical_start(start),
+	m_total_size(size),
+	m_offset(0)
+{
+}
+
+//-----------------------------------------------------------------------------
+LinearAllocator::~LinearAllocator()
+{
+	CE_ASSERT(m_offset == 0, "Memory leak of %d bytes", m_offset);
+}
+
+//-----------------------------------------------------------------------------
+void* LinearAllocator::allocate(size_t size, size_t align)
+{
+	const size_t actual_size = size + align;
+
+	// Memory exhausted
+	if (m_offset + actual_size > m_total_size)
+	{
+		return NULL;
+	}
+
+	void* user_ptr = memory::align_top((char*) m_physical_start + m_offset, align);
+
+	m_offset += actual_size;
+
+	return user_ptr;
+}
+
+//-----------------------------------------------------------------------------
+void LinearAllocator::deallocate(void* /*data*/)
+{
+	// Single deallocations not supported. Use clear().
+}
+
+//-----------------------------------------------------------------------------
+void LinearAllocator::clear()
+{
+	m_offset = 0;
+}
+
+//-----------------------------------------------------------------------------
+size_t LinearAllocator::allocated_size()
+{
+	return m_offset;
+}
+
+} // namespace crown

+ 66 - 0
src/core/mem/LinearAllocator.h

@@ -0,0 +1,66 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#pragma once
+
+#include "Allocator.h"
+
+namespace crown
+{
+
+/// Allocates memory linearly from a predefined chunk
+/// and frees all the allocations with a single call to clear()
+class LinearAllocator : public Allocator
+{
+public:
+
+				LinearAllocator(void* start, size_t size);
+				~LinearAllocator();
+
+	/// @copydoc Allocator::allocate()
+	void*		allocate(size_t size, size_t align = memory::DEFAULT_ALIGN);
+
+	/// @copydoc Allocator::deallocate()
+	/// @note
+	/// The linear allocator does not support deallocating
+	/// individual allocations, rather you have to call
+	/// clear() to free all memory at once.
+	void		deallocate(void* data);
+
+	/// Frees all the allocations made by allocate()
+	void		clear();
+
+	/// @copydoc Allocator::allocated_size()
+	size_t		allocated_size();
+
+private:
+
+	void*		m_physical_start;
+	size_t		m_total_size;
+	size_t		m_offset;
+};
+
+} // namespace crown

+ 1 - 1
src/core/mem/Memory.cpp

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "Memory.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 
 //-----------------------------------------------------------------------------
 void* operator new(size_t)

+ 30 - 2
src/core/mem/Memory.h

@@ -28,6 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Assert.h"
+#include "OS.h"
 
 namespace crown
 {
@@ -38,13 +39,40 @@ const uint32_t	PADDING_VALUE	= 0xFFFFFFFFu;	//!< Value used to fill unused memor
 const size_t	DEFAULT_ALIGN	= 4;			//!< Default memory alignment in bytes
 
 /// Returns the pointer @a p aligned to the desired @a align byte
-inline void* align(void* p, size_t align)
+inline void* align_top(void* p, size_t align)
 {
+	CE_ASSERT(align > 1, "Alignment must be > 1");
 	CE_ASSERT(align % 2 == 0, "Alignment must be a power of two");
 
 	uintptr_t ptr = (uintptr_t)p;
 
-	return (void*)(ptr + (align - ptr % align));
+	const size_t mod = ptr % align;
+
+	if (mod)
+	{
+		ptr += align - mod;
+	}
+
+	return (void*) ptr;
+}
+
+/// Dumps the memory content pointed by @a p
+inline void dump(void* p, size_t size, size_t word_size)
+{
+	uint8_t* mem = (uint8_t*) p;
+
+	for (size_t i = 0; i < size; i++, mem++)
+	{
+		if (i % word_size == 0)
+		{
+			os::printf("\n");
+			os::printf("[.. %.4X] ", (size_t)mem);
+		}
+
+		os::printf("%.2X ", *mem);
+	}
+
+	os::printf("\n");
 }
 
 } // namespace memory

+ 2 - 2
src/core/mem/ProxyAllocator.h

@@ -42,10 +42,10 @@ public:
 	/// Tag all allocations made with @a allocator by the given @a name
 					ProxyAllocator(const char* name, Allocator& allocator);
 
-	/// @a copydoc Allocator::allocate()
+	/// @copydoc Allocator::allocate()
 	void*			allocate(size_t size, size_t align = memory::DEFAULT_ALIGN);
 
-	/// @a copydoc Allocator::deallocate()
+	/// @copydoc Allocator::deallocate()
 	void			deallocate(void* data);
 
 	/// Returns the name of the proxy allocator

+ 97 - 0
src/core/mem/StackAllocator.cpp

@@ -0,0 +1,97 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include "StackAllocator.h"
+#include "OS.h"
+
+namespace crown
+{
+
+//-----------------------------------------------------------------------------
+StackAllocator::StackAllocator(void* start, size_t size) :
+	m_physical_start(start),
+	m_total_size(size),
+	m_top(start),
+	m_allocation_count(0)
+{
+}
+
+//-----------------------------------------------------------------------------
+StackAllocator::~StackAllocator()
+{
+	CE_ASSERT(m_allocation_count == 0 && allocated_size() == 0,
+		"Missing %d deallocations causing a leak of %d bytes", m_allocation_count, allocated_size());
+}
+
+//-----------------------------------------------------------------------------
+void* StackAllocator::allocate(size_t size, size_t align)
+{
+	const size_t actual_size = sizeof(Header) + size + align;
+
+	// Memory exhausted
+	if ((char*) m_top + actual_size > (char*) m_physical_start + m_total_size)
+	{
+		return NULL;
+	}
+
+	// The offset from TOS to the start of the buffer
+	uint32_t offset = (char*) m_top - (char*) m_physical_start;
+
+	// Align user data only, ignore header alignment
+	m_top = (char*) memory::align_top((char*) m_top + sizeof(Header), align) - sizeof(Header);
+
+	Header* header = (Header*) m_top;
+	header->offset = offset;
+	header->alloc_id = m_allocation_count;
+
+	void* user_ptr = (char*) m_top + sizeof(Header);
+	m_top = (char*) m_top + actual_size;
+
+	m_allocation_count++;
+
+	return user_ptr;
+}
+
+//-----------------------------------------------------------------------------
+void StackAllocator::deallocate(void* data)
+{
+	Header* data_header = (Header*) ((char*)data - sizeof(Header));
+
+	CE_ASSERT(data_header->alloc_id == m_allocation_count - 1,
+		"Deallocations must occur in LIFO order");
+
+	m_top = (char*) m_physical_start + data_header->offset;
+
+	m_allocation_count--;
+}
+
+//-----------------------------------------------------------------------------
+size_t StackAllocator::allocated_size()
+{
+	return (char*) m_top - (char*) m_physical_start;
+}
+
+} // namespace crown

+ 26 - 31
src/Skybox.h → src/core/mem/StackAllocator.h

@@ -26,52 +26,47 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include "Types.h"
-#include "TextureResource.h"
-#include "Vec3.h"
+#include "Allocator.h"
 
 namespace crown
 {
 
-class VertexBuffer;
-class IndexBuffer;
-
-enum SkyboxFace
-{
-	SF_NORTH	= 0,
-	SF_SOUTH	= 1,
-	SF_EAST		= 2,
-	SF_WEST		= 3,
-	SF_UP		= 4,
-	SF_DOWN		= 5,
-	SF_COUNT
-};
-
-class Skybox
+/// Allocates memory linearly in a stack-like fashion from a
+/// predefined chunk. All deallocations must occur in LIFO
+/// order.
+class StackAllocator : public Allocator
 {
-
 public:
 
-	//! Constructor
-	Skybox(const Vec3& position, bool visible);
+				StackAllocator(void* start, size_t size);
+				~StackAllocator();
 
-	//! Destructor
-	~Skybox();
+	/// @copydoc Allocator::allocate()
+	void*		allocate(size_t size, size_t align = memory::DEFAULT_ALIGN);
 
-//	void SetFace(SkyboxFace face, Texture* texture);
+	/// @copydoc Allocator::deallocate()
+	/// @note
+	/// Deallocations must occur in LIFO order i.e. the
+	/// last allocation must be freed for first.
+	void		deallocate(void* data);
 
-	virtual void Render();
+	/// @copydoc Allocator::allocated_size()
+	size_t		allocated_size();
 
 private:
 
-//	VertexData mVertexData[24];
-//	FaceData mFaceData[12];
+	struct Header
+	{
+		uint32_t offset;
+		uint32_t alloc_id;
+	};
+
+	void*		m_physical_start;
+	size_t		m_total_size;
 
-//	VertexBuffer* mVertexBuffer;
-//	IndexBuffer* mIndexBuffer[6];
+	void*		m_top;
 
-//	Texture* mSkyboxFace[6];
+	uint32_t	m_allocation_count;
 };
 
 } // namespace crown
-

+ 2 - 0
src/lua/CMakeLists.txt

@@ -14,6 +14,8 @@ set(LUA_SRC
 	MouseBinds.cpp
 	KeyboardBinds.cpp
 	AccelerometerBinds.cpp
+
+	DeviceBinds.cpp
 )
 
 set(LUA_HEADERS

+ 27 - 0
src/lua/DeviceBinds.cpp

@@ -0,0 +1,27 @@
+#include "Device.h"
+#include "LuaEnvironment.h"
+#include "LuaStack.h"
+
+namespace crown
+{
+
+extern "C"
+{
+
+//-----------------------------------------------------------------------------
+int32_t device_stop(lua_State* L)
+{
+	device()->stop();
+
+	return 0;
+}
+
+} // extern "C"
+
+//-----------------------------------------------------------------------------
+void load_device(LuaEnvironment& env)
+{
+	env.load_module_function("Device", "stop", device_stop);
+}
+
+} // namespace crown

+ 2 - 0
src/lua/LuaEnvironment.cpp

@@ -40,6 +40,8 @@ int32_t luaopen_libcrownlua(lua_State* L)
 	load_keyboard(env);
 	load_accelerometer(env);
 
+	load_device(env);
+
 	return 1;
 }
 

+ 2 - 0
src/lua/LuaEnvironment.h

@@ -35,6 +35,8 @@ void load_accelerometer(LuaEnvironment& env);
 
 void load_camera(LuaEnvironment& env);
 
+void load_device(LuaEnvironment& env);
+
 extern "C"
 {
 	int32_t luaopen_libcrownlua(lua_State* L);

+ 2 - 2
src/os/OS.h

@@ -26,9 +26,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include "Config.h"
-#include "List.h"
 #include <cstdarg>
+
+#include "Config.h"
 #include "Types.h"
 
 namespace crown

+ 2 - 0
src/os/posix/Cond.cpp

@@ -24,6 +24,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
+#include <string.h>
+
 #include "Cond.h"
 
 namespace crown

+ 2 - 0
src/os/posix/Mutex.cpp

@@ -24,6 +24,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
+#include <string.h>
+
 #include "Mutex.h"
 
 namespace crown

+ 3 - 1
src/os/posix/Thread.cpp

@@ -24,8 +24,10 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Thread.h"
 #include <stdlib.h>
+#include <string.h>
+
+#include "Thread.h"
 
 namespace crown
 {

+ 1 - 3
src/os/win/Mutex.h

@@ -38,15 +38,13 @@ namespace os
 class Mutex
 {
 public:
-
+	
 						Mutex();
 						~Mutex();
 
 	void				lock();
 	void				unlock();
 
-	CRITICAL_SECTION	handle();
-
 private:
 
 	CRITICAL_SECTION	m_cs;

+ 3 - 3
src/renderers/gl/GLRenderer.h

@@ -36,9 +36,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "VertexShader.h"
 #include "PixelShader.h"
 #include "IdTable.h"
-#include "MallocAllocator.h"
 #include "Resource.h"
 #include "GLContext.h"
+#include "HeapAllocator.h"
 
 namespace crown
 {
@@ -209,9 +209,9 @@ private:
 
 private:
 
-	GLContext			m_context;
+	HeapAllocator		m_allocator;
 
-	MallocAllocator		m_allocator;
+	GLContext			m_context;
 
 	// Matrices
 	Mat4				m_matrix[MT_COUNT];

+ 14 - 4
tests/allocators.cpp

@@ -1,5 +1,6 @@
 #include "Allocator.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
+#include "StackAllocator.h"
 #include <cstdio>
 #include "Assert.h"
 
@@ -7,16 +8,25 @@ using namespace crown;
 
 int main()
 {
-	MallocAllocator malloc_allocator;
+	HeapAllocator malloc_allocator;
 
 	char* char_buffer = (char*)malloc_allocator.allocate(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());
+	printf("HeapAllocator::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());
+	printf("HeapAllocator::get_allocated_size(): %d\n", malloc_allocator.allocated_size());
 	//CE_ASSERT(malloc_allocator.get_allocated_size() == 0);
+
+	uint8_t buffer[1024 * 1024];
+
+	StackAllocator stack(buffer, 1024 * 1024);
+
+	stack.allocate(12);
+	stack.allocate(5);
+
+	memory::dump(buffer, stack.allocated_size(), 4);
 }
 

+ 2 - 2
tests/compressors.cpp

@@ -1,6 +1,6 @@
 #include <cstdio>
 #include <cstring>
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 #include "ZipCompressor.h"
 
 using namespace crown;
@@ -8,7 +8,7 @@ using namespace crown;
 int main(int argc, char** argv)
 {
 	
-	MallocAllocator allocator;
+	HeapAllocator allocator;
 	ZipCompressor compressor(allocator);
 
 	const char* uncompressed_string = "letstry";

+ 1 - 1
tests/containers.cpp

@@ -6,7 +6,7 @@ using namespace crown;
 
 int main()
 {
-	MallocAllocator allocator;
+	HeapAllocator allocator;
 
 	List<int> int_list(allocator);
 

+ 14 - 13
tests/messages.cpp

@@ -2,8 +2,9 @@
 
 #include "Vec3.h"
 #include "OS.h"
+#include "NetAddress.h"
 #include "BitMessage.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 
 using namespace crown;
 
@@ -14,7 +15,7 @@ void test_int8()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 	
-	MallocAllocator allocator;
+	HeapAllocator allocator;
   	network::BitMessage m = network::BitMessage(allocator);
 	
 	int8_t res;
@@ -49,7 +50,7 @@ void test_uint8()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 	
-	MallocAllocator allocator;
+	HeapAllocator allocator;
   	network::BitMessage m = network::BitMessage(allocator);
 
 	uint8_t res;
@@ -84,7 +85,7 @@ void test_int16()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 	
-	MallocAllocator allocator;
+	HeapAllocator allocator;
   	network::BitMessage m = network::BitMessage(allocator);  
 	
 	int16_t res;
@@ -116,7 +117,7 @@ void test_uint16()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 
-	MallocAllocator allocator;
+	HeapAllocator allocator;
   	network::BitMessage m = network::BitMessage(allocator);
 
 	uint16_t res;
@@ -148,7 +149,7 @@ void test_int32()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 
-	MallocAllocator allocator;
+	HeapAllocator allocator;
   	network::BitMessage m = network::BitMessage(allocator);
 	
 	int32_t res;
@@ -181,7 +182,7 @@ void test_float()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 
-	MallocAllocator allocator;
+	HeapAllocator allocator;
   	network::BitMessage m = network::BitMessage(allocator);
 
 	float res;
@@ -215,7 +216,7 @@ void test_vec3()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 
-	MallocAllocator allocator;
+	HeapAllocator allocator;
   	network::BitMessage m = network::BitMessage(allocator);
 	
 	
@@ -249,7 +250,7 @@ void test_string()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 
-	MallocAllocator allocator;
+	HeapAllocator allocator;
   	network::BitMessage m = network::BitMessage(allocator);
 	
 	uint8_t tmp[16];
@@ -287,7 +288,7 @@ void test_data()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 
-	MallocAllocator allocator;
+	HeapAllocator allocator;
   	network::BitMessage m = network::BitMessage(allocator);
 	
 	uint8_t tmp[] = "test generic";
@@ -322,7 +323,7 @@ void test_net_address()
 	uint32_t bits_read;
 	uint32_t rem_read_bits; 
 	
-	MallocAllocator allocator;
+	HeapAllocator allocator;
 	network::BitMessage m = network::BitMessage(allocator);
 
 	uint8_t tmp[16];
@@ -344,7 +345,7 @@ void test_net_address()
 	
 	printf("-----------------------------\n");
 	printf("start write and read for NET_ADDRESS\n");
-	printf("a = %d, b = %d, c = %d, d = %d, p = %d\n", res.address[0], res.address[1], res.address[2], res.address[3], res.port);
+	printf("a = %d, b = %d, c = %d, d = %d, p = %d\n", res.m_address[0], res.m_address[1], res.m_address[2], res.m_address[3], res.m_port);
 	printf("bits written = %d\n", bits_written);
 	printf("remaining write bits = %d\n", rem_write_bits);
 	printf("bits read = %d\n", bits_read);
@@ -367,7 +368,7 @@ int main()
 	test_data();
 	test_net_address();
 */
-	MallocAllocator allocator;
+	HeapAllocator allocator;
 	network::BitMessage msg = network::BitMessage(allocator);
 	
 	uint32_t protocol_id = 0xFFFFFFFF;

+ 32 - 32
tests/paths.cpp

@@ -10,99 +10,99 @@ int main()
 	char path_output[128];
 	
 	// Test is_valid_segment
-	CE_ASSERT(path::is_valid_segment(".") == false);
+	CE_ASSERT(path::is_valid_segment(".") == false, "");
 	
-	CE_ASSERT(path::is_valid_segment("/") == false);
+	CE_ASSERT(path::is_valid_segment("/") == false, "");
 	
-	CE_ASSERT(path::is_valid_segment("\\") == false);
+	CE_ASSERT(path::is_valid_segment("\\") == false, "");
 
-	CE_ASSERT(path::is_valid_segment(":") == false);
+	CE_ASSERT(path::is_valid_segment(":") == false, "");
 	
-	CE_ASSERT(path::is_valid_segment("tga/") == false);
+	CE_ASSERT(path::is_valid_segment("tga/") == false, "");
 	
-	CE_ASSERT(path::is_valid_segment("tga\\foo") == false);
+	CE_ASSERT(path::is_valid_segment("tga\\foo") == false, "");
 	
-	CE_ASSERT(path::is_valid_segment("tga") == true);
+	CE_ASSERT(path::is_valid_segment("tga") == true, "");
 	
-	CE_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);
-	CE_ASSERT(string::strcmp("/home/project", path_output) == 0);
+	CE_ASSERT(string::strcmp("/home/project", path_output) == 0, "");
 
 	path::pathname("/home/project", path_output, 128);
-	CE_ASSERT(string::strcmp("/home", path_output) == 0);
+	CE_ASSERT(string::strcmp("/home", path_output) == 0, "");
 	
 	path::pathname("/home", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0);
+	CE_ASSERT(string::strcmp("", path_output) == 0, "");
 	
 	path::pathname("/", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0);
+	CE_ASSERT(string::strcmp("", path_output) == 0, "");
 	
 	path::pathname("", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0);
+	CE_ASSERT(string::strcmp("", path_output) == 0, "");
 	
 	// Test filename
 	path::filename("/home/project/texture.tga", path_output, 128);
-	CE_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);
-	CE_ASSERT(string::strcmp("texture", path_output) == 0);
+	CE_ASSERT(string::strcmp("texture", path_output) == 0, "");
 	
 	path::filename("/home", path_output, 128);
-	CE_ASSERT(string::strcmp("home", path_output) == 0);
+	CE_ASSERT(string::strcmp("home", path_output) == 0, "");
 	
 	path::filename("/", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0);
+	CE_ASSERT(string::strcmp("", path_output) == 0, "");
 	
 	path::filename("", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0);
+	CE_ASSERT(string::strcmp("", path_output) == 0, "");
 
 	// Test basename
 	path::basename("/home/project/texture.tga", path_output, 128);
-	CE_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);
-	CE_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);
-	CE_ASSERT(string::strcmp("textu", path_output) == 0);
+	CE_ASSERT(string::strcmp("textu", path_output) == 0, "");
 	
 	path::basename("texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("texture", path_output) == 0);
+	CE_ASSERT(string::strcmp("texture", path_output) == 0, "");
 	
 	path::basename("/home", path_output, 128);
-	CE_ASSERT(string::strcmp("home", path_output) == 0);
+	CE_ASSERT(string::strcmp("home", path_output) == 0, "");
 	
 	path::basename("/", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0);
+	CE_ASSERT(string::strcmp("", path_output) == 0, "");
 	
 	path::basename("", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0);
+	CE_ASSERT(string::strcmp("", path_output) == 0, "");
 	
 	// Test extension
 	path::extension("/home/project/texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("tga", path_output) == 0);
+	CE_ASSERT(string::strcmp("tga", path_output) == 0, "");
 	
 	path::extension("/home/project/texture", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0);
+	CE_ASSERT(string::strcmp("", path_output) == 0, "");
 	
 	path::extension("/home/project.x/texture.tga", path_output, 128);
-	CE_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);
-	CE_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);
-	CE_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);
-	CE_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);
-	CE_ASSERT(string::strcmp("texture.tga", path_output) == 0);
+	CE_ASSERT(string::strcmp("texture.tga", path_output) == 0, "");
 }
 

+ 12 - 12
tests/strings.cpp

@@ -10,40 +10,40 @@ const char* path_string = "/home/project/texture.tga";
 int main()
 {
 	// Test strlen
-	CE_ASSERT(string::strlen("ciao") == 4);
+	CE_ASSERT(string::strlen("ciao") == 4, "");
 	// FIXME add UTF-8 test case
 
 	// Test begin/end
-	CE_ASSERT(string::begin(hello_string) == &hello_string[0]);
+	CE_ASSERT(string::begin(hello_string) == &hello_string[0], "");
 	
-	CE_ASSERT(string::end(hello_string) == &hello_string[24] + 2);
+	CE_ASSERT(string::end(hello_string) == &hello_string[24] + 2, "");
 	
 	// Test find_first/find_last
-	CE_ASSERT(string::find_first(hello_string, '.') == &hello_string[2]);
+	CE_ASSERT(string::find_first(hello_string, '.') == &hello_string[2], "");
 	
-	CE_ASSERT(string::find_last(hello_string, '.') == &hello_string[17]);
+	CE_ASSERT(string::find_last(hello_string, '.') == &hello_string[17], "");
 	
-	CE_ASSERT(string::find_first(hello_string, '?') == string::end(hello_string));
+	CE_ASSERT(string::find_first(hello_string, '?') == string::end(hello_string), "");
 	
-	CE_ASSERT(string::find_last(hello_string, '?') == string::end(hello_string));
+	CE_ASSERT(string::find_last(hello_string, '?') == string::end(hello_string), "");
 	
-	CE_ASSERT(string::find_last(hello_string, '/') == &hello_string[22]);
+	CE_ASSERT(string::find_last(hello_string, '/') == &hello_string[22], "");
 	
-	CE_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);
-	CE_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);
-	CE_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);
-	CE_ASSERT(string::strcmp(string_buffer, "/h.el") == 0);
+	CE_ASSERT(string::strcmp(string_buffer, "/h.el") == 0, "");
 }
 

+ 2 - 1
tools/compilers/CMakeLists.txt

@@ -37,4 +37,5 @@ install (TARGETS crown-compiler-utils DESTINATION lib/${CMAKE_PROJECT_NAME})
 install (TARGETS resource-linker DESTINATION bin)
 install (TARGETS resource-hash DESTINATION bin)
 install (TARGETS resource-compiler DESTINATION bin)
-install (FILES resource-compiler.py DESTINATION bin)
+install (FILES resource-compiler.py PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+	GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION bin)

+ 6 - 0
tools/compilers/Compiler.cpp

@@ -53,6 +53,7 @@ Compiler::~Compiler()
 size_t Compiler::compile(const char* resource, uint32_t name, uint32_t type)
 {
 	string::strncpy(m_resource_name, resource, MAX_RESOURCE_NAME_LENGTH);
+	string::strncpy(m_resource_path, m_root_fs.os_path(resource), MAX_RESOURCE_PATH_LENGTH);
 
 	char resource_name[MAX_RESOURCE_NAME_LENGTH];
 	char resource_type[MAX_RESOURCE_TYPE_LENGTH];
@@ -163,5 +164,10 @@ const char* Compiler::resource_name() const
 	return m_resource_name;
 }
 
+const char* Compiler::resource_path() const
+{
+	return m_resource_path;
+}
+
 } // namespace crown
 

+ 3 - 1
tools/compilers/Compiler.h

@@ -34,7 +34,7 @@ namespace crown
 
 const size_t	MAX_RESOURCE_NAME_LENGTH			= 1024;
 const size_t	MAX_RESOURCE_TYPE_LENGTH			= 64;
-const size_t	MAX_RESOURCE_PATH_LENGTH			= 1024;
+const size_t	MAX_RESOURCE_PATH_LENGTH			= 2048;
 
 const uint32_t	COMPILED_HEADER_MAGIC_NUMBER		= 0xCE010101;
 const uint32_t	COMPILER_VERSION					= 1;
@@ -76,6 +76,7 @@ public:
 	const char*				root_path() const;
 	const char*				dest_path() const;
 	const char*				resource_name() const;
+	const char*				resource_path() const;
 
 protected:
 
@@ -96,6 +97,7 @@ private:
 	uint32_t			m_type_expected;
 
 	char				m_resource_name[MAX_RESOURCE_NAME_LENGTH];
+	char 				m_resource_path[MAX_RESOURCE_PATH_LENGTH];
 };
 
 } // namespace crown

+ 5 - 0
tools/compilers/resource-compiler.py

@@ -26,11 +26,13 @@
 
 import sys
 import os
+import shutil
 
 from pycrown import Repository
 from pycrown import Compiler
 
 PERFECT_SEED_FILE = "seed.ini"
+GAME_LIBRARY_FILE = "libgame.so"
 
 # Helper for compiling resources
 class CompilerHelper:
@@ -83,6 +85,9 @@ class CompilerHelper:
 		print("Compiling resources...")
 		self.m_compiler.compile_all()
 
+		print("Copying game library...")
+		shutil.copy(self.root_path() + "/" + GAME_LIBRARY_FILE, self.dest_path())
+
 		print("Writing perfect seed...")
 		self.write_perfect_seed()
 

+ 3 - 1
tools/editors/resource-browser/CMakeLists.txt

@@ -1,4 +1,6 @@
 cmake_minimum_required(VERSION 2.8)
 
-install (FILES resource-browser.py DESTINATION bin)
+install (FILES resource-browser.py PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+	GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION bin)
+
 install (FILES ui/resource-browser.glade DESTINATION bin/ui)

+ 3 - 1
tools/editors/toolchain/CMakeLists.txt

@@ -1,4 +1,6 @@
 cmake_minimum_required(VERSION 2.8)
 
-install (FILES toolchain.py DESTINATION bin)
+install (FILES toolchain.py PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+	GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION bin)
+
 install (FILES ui/toolchain.glade DESTINATION bin/ui)

+ 2 - 2
tools/editors/world-editor/terrain/Heightfield.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 
 namespace crown
 {
@@ -72,7 +72,7 @@ private:
 
 private:
 
-	MallocAllocator	m_allocator;
+	HeapAllocator	m_allocator;
 
 	uint32_t		m_initial_width;
 	uint32_t		m_initial_height;