Jelajahi Sumber

Merge branch 'master' into console

Conflicts:
	src/lua/LuaEnvironment.cpp
Daniele Bartolini 12 tahun lalu
induk
melakukan
49f5f4c87e

+ 87 - 17
BUILD.txt

@@ -1,25 +1,95 @@
-//-----------------------------------------------------------------------------
-How to build Crown:
+This file contains informations about how to correctly build the
+engine on the currently supported platforms.
 
-Type these commands in the root directory (i.e. the same as this file):
+1. Dependencies
 
-1. $ mkdir build
-2. $ cd build
-3. $ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/your/install/directory -DCROWN_ARCH="..."
-4. $ make
-5. $ make install
+	Crown Engine depends on a number of third-party libraries.
+	Some of them, like luajit, are included in this SDK, so you
+	do not need to worry too much.
 
-N.B: CROWN_ARCH valid values right now: "x86", "x86_64"
+	However, some other libraries are not included due to their
+	excessive size or for some other particular reasons.
+	In order to be able to successfully build the engine, you
+	have to install and/or properly configure the following packages:
 
-//-----------------------------------------------------------------------------
-In order to select different build configurations you have to do the following:
+	- Linux
 
-In the root directory
+		* zlib
+		* GLEW
+		* Xlib
+		* Xrandr
 
-1. $ mkdir build
-2. $ cd build
-3. $ cmake-gui ..
+	- Android
 
-//-----------------------------------------------------------------------------
-Enjoy!
+		* Android NDK and SDK
 
+	- Windows:
+
+		* zlib
+		* GLEW
+
+2. Building
+
+	The steps required for building the engine in a default and pretty
+	safe manner are summarized below for each supported platform.
+
+	All the commands and/or operations must be performed in the root
+	directory of the project (i.e. the same as this file):
+
+	- Linux
+
+		1. $ mkdir build
+		2. $ cd build
+		3. $ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/your/install/dir -DCROWN_ARCH=<arch>
+		   (read below for valid architecture strings)
+		4. $ make
+		5. $ make install
+
+		'CROWN_ARCH' valid values right now are:
+
+	 		* Linux: "x86" or "x86_64"
+
+	- Windows
+
+		1. Create a folder named 'build'
+		2. Open a terminal and:
+		3. cd build
+		4. cmake.exe .. -DCMAKE_INSTALL_PREFIX=C:/your/install/dir -DCROWN_ARCH=win64
+		5. Open the generated Visual Studio solution and build/install from there
+
+	- Android
+
+		Building for Android is a bit involved process at the moment, we are working hard
+		to improve the system.
+
+	You can also use the GUI front-end of CMake which can, less or more, simplify
+	the overall 'complexity' of building from the terminal.
+
+ 3. System requirements
+
+ 	In order to be able to run the engine, no particular configurations are needed:
+
+ 	- Linux
+
+ 		* 32/64-bit distribution
+ 		* x86/x86_64 CPU
+ 		* The latest driver for your GPU (OpenGL >= 2.1)
+
+ 	- Windows
+
+ 		* 64-bit Windows version (Windows 7+)
+ 		* x86_64 CPU
+ 		* The latest driver for your GPU (OpenGL >= 2.1)
+
+ 	- Android
+
+ 		* Android 2.3.3+
+ 		* ARMv7 CPU
+ 		* OpenGL|ES 2 compatible GPU
+
+ 4. Known issues
+
+ 	- Linux
+
+ 		* Some open-source GPU drivers, like the Intel one, make call to 'operator new'
+ 		  and thus do not work at the moment with Crown Engine.

+ 1 - 1
CMakeLists.txt

@@ -4,7 +4,7 @@ project(crown)
 
 set (CROWN_VERSION_MAJOR 0)
 set (CROWN_VERSION_MINOR 1)
-set (CROWN_VERSION_MICRO 4)
+set (CROWN_VERSION_MICRO 6)
 
 option (CROWN_BUILD_SAMPLES "Whether to build the samples" ON)
 option (CROWN_BUILD_TOOLS "Whether to build the tools" ON)

+ 2 - 2
samples/CMakeLists.txt

@@ -40,10 +40,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 	)
 endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 
-include_directories(${CROWN_INCLUDES})
+include_directories(${CROWN_INCLUDES} ${CROWN_THIRD_INCLUDES})
 link_directories(${CROWN_BINARY_DIR} ${CROWN_THIRD_LIBS})
 
-add_subdirectory(terrain)
+#add_subdirectory(terrain)
 
 # Install samples
 install (DIRECTORY 01.hello-world DESTINATION samples)

+ 4 - 2
src/Android.mk

@@ -93,6 +93,9 @@ LOCAL_SRC_FILES :=\
 	lua/Vec2Binds.cpp\
 	lua/Vec3Binds.cpp\
 	lua/WindowBinds.cpp\
+	lua/IntSettingBinds.cpp\
+	lua/FloatSettingBinds.cpp\
+	lua/StringSettingBinds.cpp\
 \
 	ArchiveBundle.cpp\
 	Camera.cpp\
@@ -133,9 +136,8 @@ LOCAL_C_INCLUDES	:=\
 	$(LOCAL_PATH)/renderers/gles\
 	$(LOCAL_PATH)/renderers/gles/egl\
 	$(LOCAL_PATH)/third/luajit/include/luajit-2.0\
-\
 
-LOCAL_CPPFLAGS	:= -g -fexceptions
+LOCAL_CPPFLAGS	:= -g -fexceptions -std=c++03 -ansi -pedantic -Wall -Wextra -Wno-long-long -Wno-variadic-macros
 LOCAL_LDLIBS	:= -llog -landroid -lEGL -lGLESv2 -lz 
 LOCAL_SHARED_LIBRARIES := luajit-5.1
 LOCAL_STATIC_LIBRARIES := android_native_app_glue

+ 28 - 20
src/CMakeLists.txt

@@ -268,6 +268,9 @@ set (OS_HEADERS
 set(LUA_SRC
 	lua/LuaStack.cpp
 	lua/LuaEnvironment.cpp
+	lua/IntSettingBinds.cpp
+	lua/FloatSettingBinds.cpp
+	lua/StringSettingBinds.cpp
 	lua/Vec2Binds.cpp
 	lua/Vec3Binds.cpp
 	lua/Mat4Binds.cpp
@@ -292,7 +295,7 @@ set (COMPILER_FLAGS
 	-pipe
 	-std=c++03
 	-ansi
-	-W    	
+	-pedantic-errors
 	-Wall
 	-Wextra
 	-Wno-long-long
@@ -321,7 +324,6 @@ if (LINUX)
 	)
 
 	list (APPEND OS_SRC
-		os/linux/main.cpp
 		os/linux/LinuxOS.cpp
 		os/linux/OsWindow.cpp
 		os/posix/TCPSocket.cpp
@@ -361,6 +363,11 @@ if (LINUX)
 endif (LINUX)
 
 if (WINDOWS)
+	list (APPEND CROWN_INCLUDES
+		${CMAKE_SOURCE_DIR}/src/os/win
+		${CMAKE_SOURCE_DIR}/src/renderers/gl/wgl
+	)
+
 	list (APPEND OS_HEADERS
 		os/win/OsWindow.h
 		os/win/OsFile.h
@@ -457,26 +464,27 @@ add_definitions(${COMPILER_FLAGS})
 
 add_library(crown SHARED ${CROWN_SOURCES} ${CROWN_HEADERS})
 
+set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:$ORIGIN")
 add_executable(${CROWN_EXECUTABLE_NAME} ${CROWN_MAIN_SRC})
 target_link_libraries(${CROWN_EXECUTABLE_NAME} crown)
 
-install (TARGETS crown DESTINATION lib/${CMAKE_PROJECT_NAME})
+install (TARGETS crown DESTINATION bin)
 install (TARGETS ${CROWN_EXECUTABLE_NAME} DESTINATION bin)
 
-install (FILES ${HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME})
-
-install (FILES ${CORE_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core)
-install (FILES ${BV_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/bv)
-install (FILES ${CONTAINERS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/containers)
-install (FILES ${MATH_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/math)
-install (FILES ${FILESYSTEM_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/filesystem)
-install (FILES ${MEM_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/mem)
-install (FILES ${COMPRESSORS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/compressors)
-install (FILES ${THREADS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/threads)
-install (FILES ${SETTINGS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/settings)
-
-install (FILES ${INPUT_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/input)
-install (FILES ${RENDERERS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/renderers)
-install (FILES ${NETWORK_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/network)
-install (FILES ${OS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/os)
-install (FILES ${LUA_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/lua)
+#install (FILES ${HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME})
+
+#install (FILES ${CORE_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core)
+#install (FILES ${BV_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/bv)
+#install (FILES ${CONTAINERS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/containers)
+#install (FILES ${MATH_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/math)
+#install (FILES ${FILESYSTEM_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/filesystem)
+#install (FILES ${MEM_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/mem)
+#install (FILES ${COMPRESSORS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/compressors)
+#install (FILES ${THREADS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/threads)
+#install (FILES ${SETTINGS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/settings)
+#
+#install (FILES ${INPUT_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/input)
+#install (FILES ${RENDERERS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/renderers)
+#install (FILES ${NETWORK_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/network)
+#install (FILES ${OS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/os)
+#install (FILES ${LUA_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/lua)

+ 1 - 1
src/Device.cpp

@@ -518,7 +518,7 @@ void Device::parse_command_line(int argc, char** argv)
 			// Root path
 			case 'r':
 			{
-				string::strcpy(m_preferred_root_path, args.optarg());
+				string::strncpy(m_preferred_root_path, args.optarg(), MAX_PATH_LENGTH);
 				break;
 			}
 			// Window width

+ 2 - 2
src/JSONParser.cpp

@@ -351,7 +351,7 @@ void JSONParser::fill_token(JSONToken* token, JSONType type, int32_t start, int3
 	m_file->seek(token->m_start);
 	m_file->read(tmp, token->m_size);
 	tmp[token->m_size] = '\0';
-	string::strcpy(token->m_value, tmp);
+	string::strncpy(token->m_value, tmp, 1024);
 
 	m_file->seek(cur_pos);
 }
@@ -585,7 +585,7 @@ JSONParser& JSONParser::get_bool(const char* key)
 //--------------------------------------------------------------------------
 void JSONParser::to_string(char* value)
 {
-	string::strcpy(value, m_tokens[m_nodes[m_nodes_count-1].m_id].m_value);
+	string::strncpy(value, m_tokens[m_nodes[m_nodes_count-1].m_id].m_value, JSONToken::MAX_TOKEN_LEN);
 
 	reset_nodes();
 }

+ 5 - 6
src/core/Assert.h

@@ -32,13 +32,12 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Log.h"
 
 #ifdef CROWN_DEBUG
-	#define CE_ERROR(file, line, message, ...) do { crown::Log::e(message, __VA_ARGS__);\
-				crown::Log::e("\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)
+	#define CE_ASSERT(condition, ...) do { if (!(condition)) {\
+		crown::Log::e("Assertion failed: %s", #condition);\
+		crown::Log::e("\t" __VA_ARGS__);\
+		crown::Log::e("\n\tIn %s:%d\n\n", __FILE__, __LINE__); abort();} } while (0)
 #else
-	#define CE_ASSERT(condition, message, ...) ((void)0)
+	#define CE_ASSERT(...) ((void)0)
 #endif
 
 #define CE_ASSERT_NOT_NULL(x) CE_ASSERT(x != NULL, "Parameter must be not null")
-

+ 2 - 1
src/core/filesystem/Filesystem.cpp

@@ -63,8 +63,9 @@ const char* Filesystem::build_os_path(const char* base_path, const char* relativ
 	size_t base_path_len = string::strlen(base_path);
 
 	os_path[base_path_len] = PATH_SEPARATOR;
+	os_path[base_path_len + 1] = '\0';
 
-	string::strncpy(&os_path[base_path_len + 1], relative_path, MAX_PATH_LENGTH);
+	string::strcat(os_path, relative_path);
 
 	// FIXME FIXME FIXME Replace Crown-specific path separator with OS-speficic one
 	for (size_t j = 0; j < string::strlen(os_path); j++)

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

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "HeapAllocator.h"
 
 //-----------------------------------------------------------------------------
-void* operator new(size_t)
+void* operator new(size_t) throw (std::bad_alloc)
 {
 	CE_ASSERT(false, "operator new forbidden");
 
@@ -36,7 +36,7 @@ void* operator new(size_t)
 }
 
 //-----------------------------------------------------------------------------
-void* operator new[](size_t)
+void* operator new[](size_t) throw (std::bad_alloc)
 {
 	CE_ASSERT(false, "operator new[] forbidden");
 
@@ -44,13 +44,13 @@ void* operator new[](size_t)
 }
 
 //-----------------------------------------------------------------------------
-void operator delete(void*)
+void operator delete(void*) throw ()
 {
 	CE_ASSERT(false, "operator delete forbidden");
 }
 
 //-----------------------------------------------------------------------------
-void operator delete[](void*)
+void operator delete[](void*) throw ()
 {
 	CE_ASSERT(false, "operator delete[] forbidden");
 }

+ 19 - 0
src/core/settings/FloatSetting.cpp

@@ -25,6 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "FloatSetting.h"
+#include "StringUtils.h"
 
 namespace crown
 {
@@ -109,5 +110,23 @@ FloatSetting& FloatSetting::operator=(const float value)
 	return *this;
 }
 
+//-----------------------------------------------------------------------------
+FloatSetting* FloatSetting::find_setting(const char* name)
+{
+	FloatSetting* head = g_float_settings_head;
+
+	while (head != NULL)
+	{
+		if (string::strcmp(name, head->name()) == 0)
+		{
+			return head;
+		}
+
+		head = head->m_next;
+	}
+
+	return NULL;
+}
+
 } // namespace crown
 

+ 19 - 14
src/core/settings/FloatSetting.h

@@ -38,29 +38,34 @@ class FloatSetting
 {
 public:
 
-						FloatSetting(const char* name, const char* synopsis, float value, float min, float max);
+							FloatSetting(const char* name, const char* synopsis, float value, float min, float max);
 
-	const char*			name() const;
-	const char*			synopsis() const;
+	const char*				name() const;
+	const char*				synopsis() const;
 
-	float				value() const;
-	float				min() const;
-	float				max() const;
+	float					value() const;
+	float					min() const;
+	float					max() const;
 
-						operator float();
+							operator float();
 
-	FloatSetting&		operator=(const float value);
+	FloatSetting&			operator=(const float value);
+
+public:
+
+	/// Returns the setting @name or NULL if not found.
+	static FloatSetting*	find_setting(const char* name);
 
 private:
 
-	const char*			m_name;
-	const char*			m_synopsis;
+	const char*				m_name;
+	const char*				m_synopsis;
 
-	float				m_value;
-	float				m_min;
-	float				m_max;
+	float					m_value;
+	float					m_min;
+	float					m_max;
 
-	FloatSetting*		m_next;
+	FloatSetting*			m_next;
 };
 
 } // namespace crown

+ 19 - 0
src/core/settings/IntSetting.cpp

@@ -25,6 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "IntSetting.h"
+#include "StringUtils.h"
 
 namespace crown
 {
@@ -109,5 +110,23 @@ IntSetting& IntSetting::operator=(const int32_t value)
 	return *this;
 }
 
+//-----------------------------------------------------------------------------
+IntSetting*	IntSetting::find_setting(const char* name)
+{
+	IntSetting* head = g_int_settings_head;
+
+	while (head != NULL)
+	{
+		if (string::strcmp(name, head->name()) == 0)
+		{
+			return head;
+		}
+
+		head = head->m_next;
+	}
+
+	return NULL;
+}
+
 } // namespace crown
 

+ 5 - 0
src/core/settings/IntSetting.h

@@ -51,6 +51,11 @@ public:
 
 	IntSetting&			operator=(const int32_t value);
 
+public:
+
+	/// Returns the setting @name or NULL if not found.
+	static IntSetting*	find_setting(const char* name);
+
 private:
 
 	const char*			m_name;

+ 51 - 1
src/core/settings/StringSetting.cpp

@@ -1,10 +1,38 @@
+/*
+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 "StringSetting.h"
+#include "StringUtils.h"
 
 namespace crown
 {
 
 static StringSetting* g_string_settings_head = NULL;
 
+//-----------------------------------------------------------------------------
 StringSetting::StringSetting(const char* name, const char* synopsis, const char* value) :
 	m_name(name),
 	m_synopsis(synopsis),
@@ -25,26 +53,48 @@ StringSetting::StringSetting(const char* name, const char* synopsis, const char*
 	}
 }
 
+//-----------------------------------------------------------------------------
 const char* StringSetting::name() const
 {
 	return m_name;
 }
 
+//-----------------------------------------------------------------------------
 const char* StringSetting::synopsis() const
 {
 	return m_synopsis;
 }
 
+//-----------------------------------------------------------------------------
 const char*	StringSetting::value() const
 {
 	return m_value;
 }
 
-StringSetting&	StringSetting::operator=(const char* value)
+//-----------------------------------------------------------------------------
+StringSetting& StringSetting::operator=(const char* value)
 {
 	m_value = value;
 
 	return *this;
 }
 
+//-----------------------------------------------------------------------------
+StringSetting* StringSetting::find_setting(const char* name)
+{
+	StringSetting* head = g_string_settings_head;
+
+	while (head != NULL)
+	{
+		if (string::strcmp(name, head->name()) == 0)
+		{
+			return head;
+		}
+
+		head = head->m_next;
+	}
+
+	return NULL;
+}
+
 } // namespace crown

+ 40 - 9
src/core/settings/StringSetting.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"
@@ -10,22 +36,27 @@ class StringSetting
 {
 public:
 
-						StringSetting(const char* name, const char* synopsis, const char* value);
+							StringSetting(const char* name, const char* synopsis, const char* value);
+
+	const char*				name() const;
+	const char*				synopsis() const;
 
-	const char*			name() const;
-	const char*			synopsis() const;
+	const char*				value() const;
 
-	const char*			value() const;
+	StringSetting&			operator=(const char* value);
+
+public:
 
-	StringSetting&		operator=(const char* value);
+	/// Returns the setting @name or NULL if not found.
+	static StringSetting*	find_setting(const char* name);
 
 private:
 
-	const char*			m_name;
-	const char*			m_synopsis;
-	const char*			m_value;
+	const char*				m_name;
+	const char*				m_synopsis;
+	const char*				m_value;
 
-	StringSetting*		m_next;
+	StringSetting*			m_next;
 };
 
 } // namespace crown

+ 4 - 240
src/core/strings/StringUtils.h

@@ -39,239 +39,6 @@ namespace string
 
 const char* const	EMPTY = "";
 
-bool				is_alpha(char c);
-bool				is_digit(char c);
-bool				is_upper(char c);
-bool				is_lower(char c);
-bool				is_whitespace(char c);
-
-size_t				strlen(const char* str);
-const char*			strstr(const char* str1, const char* str2);
-int32_t				strcmp(const char* str1, const char* str2);
-char*				strcpy(char* dest, const char* src);
-char*				strncpy(char* dest, const char* src, size_t len);
-char* 				strcat(char* dest, const char* src);
-char*				strncat(char* dest, const char* src, size_t len);
-
-const char*			begin(const char* str);
-const char*			end(const char* str);
-
-const char*			find_first(const char* str, char c);
-const char*			find_last(const char* str, char c);
-void				substring(const char* begin, const char* end, char* out, size_t len);
-
-//inline void MakeLower()
-//{
-//	for (uint32_t i = 0; i < mLength; i++)
-//	{
-//		if (is_upper(mText[i]))
-//		{
-//			mText[i] += 32;
-//		}
-//	}
-//}
-
-//inline void MakeUpper()
-//{
-//	for (uint32_t i = 0; i < mLength; i++)
-//	{
-//		if (is_lower(mText[i]))
-//		{
-//			mText[i] -= 32;
-//		}
-//	}
-//}
-
-//inline bool StartsWith(const Str& begin) const
-//{
-//	if (mLength < begin.mLength)
-//		return false;
-
-//	for (uint32_t i = 0; i < begin.mLength; i++)
-//	{
-//		if (mText[i] != begin.mText[i])
-//			return false;
-//	}
-
-//	return true;
-//}
-
-//inline bool EndsWith(const Str& end) const
-//{
-//	if (mLength < end.mLength)
-//		return false;
-
-//	uint32_t beginIndex = mLength - end.mLength;
-//	for (uint32_t i = beginIndex; i < mLength; i++)
-//	{
-//		if (mText[i] != end.mText[i - beginIndex])
-//			return false;
-//	}
-
-//	return true;
-//}
-
-//inline int32_t Find(const Str& Str) const
-//{
-//	bool found = true;
-
-//	for (uint32_t i = 0; i < mLength; i++)
-//	{
-//		if (mLength - i < Str.mLength)
-//		{
-//			return -1;
-//		}
-
-//		for (uint32_t j = 0; j < Str.mLength; j++)
-//		{
-//			if (mText[i + j] != Str.mText[j])
-//			{
-//				found = false;
-//			}
-//		}
-
-//		if (found)
-//		{
-//			return i;
-//		}
-
-//		found = true;
-//	}
-
-//	return -1;
-//}
-
-//inline void Remove(uint32_t start, uint32_t 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];
-
-//	uint32_t i;
-//	for (i = 0; i < start; i++)
-//	{
-//		tmp[i] = mText[i];
-//	}
-//	i += len;
-//	for (; i < mLength; i++)
-//	{
-//		tmp[i - len] = mText[i];
-//	}
-//	mLength = mLength - len;
-//	tmp[mLength] = '\0';
-//	delete[] mText;
-//	mText = tmp;
-//}
-
-////! Replaces all the occurencies of the given character with the new one
-//inline void Replace(char toFind, char toReplace)
-//{
-//	for (uint32_t i = 0; i < mLength; i++)
-//	{
-//		if (mText[i] == toFind)
-//			mText[i] = toReplace;
-//	}
-//}
-
-////! Replaces all the occurencies of the given Str with the new one
-//inline void Replace(const Str& toFind, const Str& toReplace)
-//{
-//	CE_ASSERT(toReplace.mLength > 0);
-//	if (mLength < toReplace.mLength)
-//		return;
-
-//	List<char> tmp(get_default_allocator());
-
-//	uint32_t i;
-//	for (i = 0; i < mLength - (toFind.mLength - 1); i++)
-//	{
-//		bool found = true;
-//		for(uint32_t j = 0; j < toFind.mLength; j++)
-//			if (mText[i + j] != toFind.mText[j])
-//			{
-//				found = false;
-//				break;
-//			}
-//		if (found)
-//		{
-//			for(uint32_t j = 0; j < toReplace.mLength; j++)
-//				tmp.push_back(toReplace.mText[j]);
-//			i += toFind.mLength-1;
-//		}
-//		else
-//			tmp.push_back(mText[i]);
-//	}
-
-//	while(i <= mLength)
-//	{
-//		tmp.push_back(mText[i]);
-//		i++;
-//	}
-
-//	*this = tmp.begin();
-//}
-
-//inline void Split(char ch, List<Str>& split) const
-//{
-//	uint32_t lastChar = 0;
-//	uint32_t strPtr = 0;
-//	uint32_t charCount = 0;
-
-//	while (strPtr <= mLength)
-//	{
-//		lastChar = strPtr;
-
-//		while (mText[strPtr] != ch && mText[strPtr] != '\0')
-//		{
-//			strPtr++;
-//			charCount++;
-//		}
-
-//		if (charCount > 0)
-//		{
-//			split.push_back(this->GetSubstring(lastChar, lastChar + charCount));
-//		}
-
-//		charCount = 0;
-//		strPtr++;
-//	}
-//}
-
-//inline Str Trim()
-//{
-//	int32_t beginIndex = 0;
-//	int32_t endIndex = mLength - 1;
-
-//	while (is_whitespace(mText[beginIndex]))
-//	{
-//		beginIndex++;
-//	}
-
-//	while (is_whitespace(mText[endIndex]))
-//	{
-//		endIndex--;
-//	}
-
-//	return GetSubstring(beginIndex, endIndex + 1);
-//}
-
-//inline int32_t GetOccurrenceCount(char ch) const
-//{
-//	int32_t count = 0;
-
-//	for (uint32_t i = 0; i < mLength; i++)
-//	{
-//		if (mText[i] == ch)
-//		{
-//			count++;
-//		}
-//	}
-
-//	return count;
-//}
-
 //-----------------------------------------------------------------------------
 inline bool is_alpha(char c)
 {
@@ -331,16 +98,13 @@ inline int32_t strcmp(const char* str1, const char* str2)
 	return ::strcmp(str1, str2);
 }
 
-//-----------------------------------------------------------------------------
-inline char* strcpy(char* dest, const char* src)
-{
-	return ::strcpy(dest, src);
-}
-
 //-----------------------------------------------------------------------------
 inline char* strncpy(char* dest, const char* src, size_t len)
 {
-	return ::strncpy(dest, src, len);
+	char* ret = ::strncpy(dest, src, len);
+	dest[len - 1] = '\0';
+
+	return ret;
 }
 
 //-----------------------------------------------------------------------------

+ 147 - 0
src/lua/FloatSettingBinds.cpp

@@ -0,0 +1,147 @@
+/*
+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 "FloatSetting.h"
+#include "LuaStack.h"
+#include "LuaEnvironment.h"
+#include "StringUtils.h"
+
+namespace crown
+{
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t float_setting_value(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	FloatSetting* setting = FloatSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_float(setting->value());
+	}
+	else
+	{
+		stack.push_float(0.0f);
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t float_setting_synopsis(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	FloatSetting* setting = FloatSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_string(setting->synopsis(), string::strlen(setting->synopsis()));
+	}
+	else
+	{
+		stack.push_string("", string::strlen(""));
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t float_setting_min(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	FloatSetting* setting = FloatSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_float(setting->min());
+	}
+	else
+	{
+		stack.push_float(0);
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t float_setting_max(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	FloatSetting* setting = FloatSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_float(setting->max());
+	}
+	else
+	{
+		stack.push_float(0);
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t float_setting_update(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+	const float setting_value = stack.get_float(2);
+
+	FloatSetting* setting = FloatSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		(*setting) = setting_value;
+	}
+
+	return 0;
+}
+
+//-----------------------------------------------------------------------------
+void load_float_setting(LuaEnvironment& env)
+{
+	env.load_module_function("FloatSetting", "value",		float_setting_value);
+	env.load_module_function("FloatSetting", "synopsis",	float_setting_synopsis);
+	env.load_module_function("FloatSetting", "min",			float_setting_min);
+	env.load_module_function("FloatSetting", "max",			float_setting_max);
+	env.load_module_function("FloatSetting", "update",		float_setting_update);
+}
+
+} // namespace crown

+ 147 - 0
src/lua/IntSettingBinds.cpp

@@ -0,0 +1,147 @@
+/*
+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 "IntSetting.h"
+#include "LuaStack.h"
+#include "LuaEnvironment.h"
+#include "StringUtils.h"
+
+namespace crown
+{
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t int_setting_query_value(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	IntSetting* setting = IntSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_int32(setting->value());
+	}
+	else
+	{
+		stack.push_int32(0);
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t int_setting_query_synopsis(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	IntSetting* setting = IntSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_string(setting->synopsis(), string::strlen(setting->synopsis()));
+	}
+	else
+	{
+		stack.push_string("", string::strlen(""));
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t int_setting_query_min(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	IntSetting* setting = IntSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_int32(setting->min());
+	}
+	else
+	{
+		stack.push_int32(0);
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t int_setting_query_max(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	IntSetting* setting = IntSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_int32(setting->max());
+	}
+	else
+	{
+		stack.push_int32(0);
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t int_setting_update(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+	const int32_t setting_value = stack.get_int(2);
+
+	IntSetting* setting = IntSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		(*setting) = setting_value;
+	}
+
+	return 0;
+}
+
+//-----------------------------------------------------------------------------
+void load_int_setting(LuaEnvironment& env)
+{
+	env.load_module_function("IntSetting", "value",		int_setting_query_value);
+	env.load_module_function("IntSetting", "synopsis",	int_setting_query_synopsis);
+	env.load_module_function("IntSetting", "min",		int_setting_query_min);
+	env.load_module_function("IntSetting", "max",		int_setting_query_max);
+	env.load_module_function("IntSetting", "update",	int_setting_update);
+}
+
+} // namespace crown

+ 5 - 1
src/lua/LuaEnvironment.cpp

@@ -140,7 +140,7 @@ void LuaEnvironment::execute(int32_t args, int32_t results)
 //-----------------------------------------------------------------------------
 void LuaEnvironment::lua_error()
 {
-	string::strcpy(m_error_buffer, lua_tostring(m_stack.state(), -1));
+	string::strncpy(m_error_buffer, lua_tostring(m_stack.state(), -1), 1024);
 
 	m_status = true;
 }
@@ -164,6 +164,10 @@ CE_EXPORT int32_t luaopen_libcrown(lua_State* L)
 {
 	LuaEnvironment* env = device()->lua_environment();
 
+	load_int_setting(*env);
+	load_float_setting(*env);
+	load_string_setting(*env);
+
 	load_vec2(*env);
 	load_vec3(*env);
 	load_mat4(*env);

+ 4 - 0
src/lua/LuaEnvironment.h

@@ -91,6 +91,10 @@ private:
 	bool			m_status;
 };
 
+void load_int_setting(LuaEnvironment& env);
+void load_float_setting(LuaEnvironment& env);
+void load_string_setting(LuaEnvironment& env);
+
 void load_vec2(LuaEnvironment& env);
 void load_vec3(LuaEnvironment& env);
 void load_mat4(LuaEnvironment& env);

+ 4 - 0
src/lua/LuaStack.cpp

@@ -26,6 +26,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "LuaStack.h"
 #include "Assert.h"
+#include "Vec2.h"
+#include "Vec3.h"
+#include "Mat4.h"
+#include "Quat.h"
 
 namespace crown
 {

+ 5 - 4
src/lua/LuaStack.h

@@ -28,14 +28,15 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "lua.hpp"
 #include "Types.h"
-#include "Vec2.h"
-#include "Vec3.h"
-#include "Mat4.h"
-#include "Quat.h"
 
 namespace crown
 {
 
+class Vec2;
+class Vec3;
+class Mat4;
+class Quat;
+
 Vec2* next_vec2();
 Vec3* next_vec3();
 

+ 103 - 0
src/lua/StringSettingBinds.cpp

@@ -0,0 +1,103 @@
+/*
+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 "StringSetting.h"
+#include "LuaStack.h"
+#include "LuaEnvironment.h"
+#include "StringUtils.h"
+
+namespace crown
+{
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t string_setting_value(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	StringSetting* setting = StringSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_string(setting->value(), string::strlen(setting->value()));
+	}
+	else
+	{
+		stack.push_string("", string::strlen(""));
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t string_setting_synopsis(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+
+	StringSetting* setting = StringSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		stack.push_string(setting->synopsis(), string::strlen(setting->synopsis()));
+	}
+	else
+	{
+		stack.push_string("", string::strlen(""));
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t string_setting_update(lua_State* L)
+{
+	LuaStack stack(L);
+
+	const char* setting_name = stack.get_string(1);
+	const char* setting_value = stack.get_string(2);
+
+	StringSetting* setting = StringSetting::find_setting(setting_name);
+
+	if (setting != NULL)
+	{
+		(*setting) = setting_value;
+	}
+
+	return 0;
+}
+
+//-----------------------------------------------------------------------------
+void load_string_setting(LuaEnvironment& env)
+{
+	env.load_module_function("StringSetting", "value",		string_setting_value);
+	env.load_module_function("StringSetting", "synopsis",	string_setting_synopsis);
+	env.load_module_function("StringSetting", "update",		string_setting_update);
+}
+
+} // namespace crown

+ 2 - 2
src/os/win/OsWindow.cpp

@@ -99,7 +99,7 @@ OsWindow::OsWindow(uint32_t width, uint32_t height) :
 {
 	CE_ASSERT(width != 0 || height != 0, "Width and height must differ from 0.");
 
-	string::strcpy(m_window_name, "CrownWindowClass");
+	string::strncpy(m_window_name, "CrownWindowClass", 32);
 	WNDCLASSEX wcex;
 	wcex.cbSize = sizeof(WNDCLASSEX);
 	wcex.style = CS_OWNDC;
@@ -278,7 +278,7 @@ char* OsWindow::title()
 //-----------------------------------------------------------------------------
 void OsWindow::set_title(const char* title)
 {
-	string::strcpy(m_window_name, title);
+	string::strncpy(m_window_name, title, 32);
 	SetWindowText(m_window_handle, m_window_name);
 }
 

+ 12 - 13
third/ARMv7/CMakeLists.txt

@@ -1,17 +1,16 @@
 cmake_minimum_required(VERSION 2.8)
 
-# must be revised
-install (FILES 	luajit/include/luajit-2.0/lua.hpp
-				luajit/include/luajit-2.0/lauxlib.h
-				luajit/include/luajit-2.0/lua.h
-				luajit/include/luajit-2.0/luaconf.h
-				luajit/include/luajit-2.0/luajit.h
-				luajit/include/luajit-2.0/lualib.h DESTINATION include/crown/luajit)
+#install (FILES 	luajit/include/luajit-2.0/lua.hpp
+#				luajit/include/luajit-2.0/lauxlib.h
+#				luajit/include/luajit-2.0/lua.h
+#				luajit/include/luajit-2.0/luaconf.h
+#				luajit/include/luajit-2.0/luajit.h
+#				luajit/include/luajit-2.0/lualib.h DESTINATION include/crown/luajit)
 				
-install (DIRECTORY luajit/lib/pkgconfig DESTINATION lib/crown)
-install (FILES luajit/lib/libluajit-5.1.so.2.0.2 
-			   luajit/lib/libluajit-5.1.so.2.0.1 DESTINATION lib/crown)
+#install (DIRECTORY luajit/lib/pkgconfig DESTINATION lib/crown)
+install (FILES luajit/lib/libluajit-5.1.so.2.0.1 
+			   luajit/lib/libluajit-5.1.so.2 DESTINATION bin)
 
-install (PROGRAMS luajit/bin/luajit-2.0.1 DESTINATION bin)
-install (FILES luajit/bin/luajit DESTINATION bin)
-install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION bin)
+install (PROGRAMS luajit/bin/luajit-2.0.1 DESTINATION tools)
+install (FILES luajit/bin/luajit DESTINATION tools)
+install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION tools)

+ 12 - 13
third/win64/CMakeLists.txt

@@ -1,19 +1,18 @@
 cmake_minimum_required(VERSION 2.8)
 
-install (FILES 	luajit/include/luajit-2.0/lua.hpp
-				luajit/include/luajit-2.0/lauxlib.h
-				luajit/include/luajit-2.0/lua.h
-				luajit/include/luajit-2.0/luaconf.h
-				luajit/include/luajit-2.0/luajit.h
-				luajit/include/luajit-2.0/lualib.h DESTINATION include/crown/luajit)
+#install (FILES 	luajit/include/luajit-2.0/lua.hpp
+#				luajit/include/luajit-2.0/lauxlib.h
+#				luajit/include/luajit-2.0/lua.h
+#				luajit/include/luajit-2.0/luaconf.h
+#				luajit/include/luajit-2.0/luajit.h
+#				luajit/include/luajit-2.0/lualib.h DESTINATION include/crown/luajit)
 				
-install (FILES luajit/lib/lua51.dll DESTINATION lib/crown)
 if (WINDOWS)
-install (FILES luajit/lib/lua51.dll DESTINATION bin)
-# HACK !!!
-# Don't know why, but crown-win.exe need this...
-install (FILES luajit/lib/luajit-5.1.dll DESTINATION bin)	
+	install (FILES luajit/lib/lua51.dll DESTINATION bin)
+	# HACK !!!
+	# Don't know why, but crown-win.exe need this...
+	install (FILES luajit/lib/luajit-5.1.dll DESTINATION bin)	
 endif (WINDOWS)
 
-install (PROGRAMS luajit/bin/luajit.exe DESTINATION bin)
-install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION bin)
+install (PROGRAMS luajit/bin/luajit.exe DESTINATION tools)
+install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION tools)

+ 11 - 11
third/x86/CMakeLists.txt

@@ -1,16 +1,16 @@
 cmake_minimum_required(VERSION 2.8)
 
-install (FILES 	luajit/include/luajit-2.0/lua.hpp
-				luajit/include/luajit-2.0/lauxlib.h
-				luajit/include/luajit-2.0/lua.h
-				luajit/include/luajit-2.0/luaconf.h
-				luajit/include/luajit-2.0/luajit.h
-				luajit/include/luajit-2.0/lualib.h DESTINATION include/crown/luajit)
+#install (FILES 	luajit/include/luajit-2.0/lua.hpp
+#				luajit/include/luajit-2.0/lauxlib.h
+#				luajit/include/luajit-2.0/lua.h
+#				luajit/include/luajit-2.0/luaconf.h
+#				luajit/include/luajit-2.0/luajit.h
+#				luajit/include/luajit-2.0/lualib.h DESTINATION include/crown/luajit)
 				
-install (DIRECTORY luajit/lib/pkgconfig DESTINATION lib/crown)
+#install (DIRECTORY luajit/lib/pkgconfig DESTINATION lib/crown)
 install (FILES luajit/lib/libluajit-5.1.so.2.0.1 
-			   luajit/lib/libluajit-5.1.so.2 DESTINATION lib/crown)
+			   luajit/lib/libluajit-5.1.so.2 DESTINATION bin)
 
-install (PROGRAMS luajit/bin/luajit-2.0.1 DESTINATION bin)
-install (FILES luajit/bin/luajit DESTINATION bin)
-install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION bin)
+install (PROGRAMS luajit/bin/luajit-2.0.1 DESTINATION tools)
+install (FILES luajit/bin/luajit DESTINATION tools)
+install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION tools)

+ 11 - 11
third/x86_64/CMakeLists.txt

@@ -1,16 +1,16 @@
 cmake_minimum_required(VERSION 2.8)
 
-install (FILES 	luajit/include/luajit-2.0/lua.hpp
-				luajit/include/luajit-2.0/lauxlib.h
-				luajit/include/luajit-2.0/lua.h
-				luajit/include/luajit-2.0/luaconf.h
-				luajit/include/luajit-2.0/luajit.h
-				luajit/include/luajit-2.0/lualib.h DESTINATION include/crown/luajit)
+#install (FILES 	luajit/include/luajit-2.0/lua.hpp
+#				luajit/include/luajit-2.0/lauxlib.h
+#				luajit/include/luajit-2.0/lua.h
+#				luajit/include/luajit-2.0/luaconf.h
+#				luajit/include/luajit-2.0/luajit.h
+#				luajit/include/luajit-2.0/lualib.h DESTINATION include/crown/luajit)
 				
-install (DIRECTORY luajit/lib/pkgconfig DESTINATION lib/crown)
+#install (DIRECTORY luajit/lib/pkgconfig DESTINATION lib/crown)
 install (FILES luajit/lib/libluajit-5.1.so.2.0.1 
-			   luajit/lib/libluajit-5.1.so.2 DESTINATION lib/crown)
+			   luajit/lib/libluajit-5.1.so.2 DESTINATION bin)
 
-install (PROGRAMS luajit/bin/luajit-2.0.1 DESTINATION bin)
-install (FILES luajit/bin/luajit DESTINATION bin)
-install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION bin)
+install (PROGRAMS luajit/bin/luajit-2.0.1 DESTINATION tools)
+install (FILES luajit/bin/luajit DESTINATION tools)
+install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION tools)

+ 5 - 4
tools/CMakeLists.txt

@@ -68,12 +68,13 @@ target_link_libraries(resource-hash crown-tools)
 add_executable(resource-compiler cli/resource-compiler.cpp)
 target_link_libraries(resource-compiler crown-tools)
 
-install (TARGETS crown-tools DESTINATION lib/${CMAKE_PROJECT_NAME})
+# Install tools
+install (TARGETS crown-tools DESTINATION tools)
 
-install (TARGETS resource-hash DESTINATION bin)
-install (TARGETS resource-compiler DESTINATION bin)
+install (TARGETS resource-hash DESTINATION tools)
+install (TARGETS resource-compiler DESTINATION tools)
 install (FILES cli/resource-compiler.py PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
-	GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION bin)
+	GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION tools)
 
 add_subdirectory(gui/resource-browser)
 add_subdirectory(gui/toolchain)

+ 4 - 28
tools/core/strings/StringUtils.h

@@ -39,27 +39,6 @@ namespace string
 
 const char* const	EMPTY = "";
 
-bool				is_alpha(char c);
-bool				is_digit(char c);
-bool				is_upper(char c);
-bool				is_lower(char c);
-bool				is_whitespace(char c);
-
-size_t				strlen(const char* str);
-const char*			strstr(const char* str1, const char* str2);
-int32_t				strcmp(const char* str1, const char* str2);
-char*				strcpy(char* dest, const char* src);
-char*				strncpy(char* dest, const char* src, size_t len);
-char* 				strcat(char* dest, const char* src);
-char*				strncat(char* dest, const char* src, size_t len);
-
-const char*			begin(const char* str);
-const char*			end(const char* str);
-
-const char*			find_first(const char* str, char c);
-const char*			find_last(const char* str, char c);
-void				substring(const char* begin, const char* end, char* out, size_t len);
-
 //-----------------------------------------------------------------------------
 inline bool is_alpha(char c)
 {
@@ -119,16 +98,13 @@ inline int32_t strcmp(const char* str1, const char* str2)
 	return ::strcmp(str1, str2);
 }
 
-//-----------------------------------------------------------------------------
-inline char* strcpy(char* dest, const char* src)
-{
-	return ::strcpy(dest, src);
-}
-
 //-----------------------------------------------------------------------------
 inline char* strncpy(char* dest, const char* src, size_t len)
 {
-	return ::strncpy(dest, src, len);
+	char* ret = ::strncpy(dest, src, len);
+	dest[len - 1] = '\0';
+
+	return ret;
 }
 
 //-----------------------------------------------------------------------------

+ 2 - 2
tools/gui/resource-browser/CMakeLists.txt

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

+ 2 - 2
tools/gui/toolchain/CMakeLists.txt

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

+ 1 - 1
tools/gui/toolchain/toolchain.py

@@ -77,7 +77,7 @@ class Toolchain:
 		dest_path = root_path + "_" + self.m_current_platform
 
 		comp = subprocess.call(["python", "resource-compiler.py", str(self.m_root_path), self.m_current_platform])
-		crown = subprocess.call(["crown-linux", "--root-path", dest_path, "--dev"])
+		crown = subprocess.call(["../bin/crown-linux", "--root-path", dest_path, "--dev"])
 
 	def on_browser_button_clicked(self, button):
 		browser = subprocess.call(["python", "resource-browser.py", str(self.m_root_path)])

+ 1 - 1
tools/pycrown/CMakeLists.txt

@@ -8,5 +8,5 @@ set (PYFILES
 	Compiler.py
 )
 
-install (FILES ${PYFILES} DESTINATION lib/pycrown)
+install (FILES ${PYFILES} DESTINATION tools/pycrown)
 

+ 3 - 3
tools/pycrown/Compiler.py

@@ -25,10 +25,10 @@
 import subprocess
 import os
 
-LUAJIT = "luajit"
+LUAJIT = "./luajit"
 OPTION = "-b"
-COMPILER_NAME = "resource-compiler"
-RES_H = "resource-hash"
+COMPILER_NAME = "./resource-compiler"
+RES_H = "./resource-hash"
 
 ROOT_P = "--root-path"
 DEST_P = "--dest-path"