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

Merge branch 'world' of https://github.com/taylor001/crown into world

mikymod 12 лет назад
Родитель
Сommit
18df499314

+ 0 - 1
engine/Android.mk

@@ -121,7 +121,6 @@ LOCAL_SRC_FILES :=\
 	core/math/Vector3.cpp\
 	core/math/Vector4.cpp\
 \
-	core/mem/HeapAllocator.cpp\
 	core/mem/LinearAllocator.cpp\
 	core/mem/Memory.cpp\
 	core/mem/PoolAllocator.cpp\

+ 43 - 14
engine/CMakeLists.txt

@@ -212,7 +212,6 @@ set (STRINGS_HEADERS
 
 set (MEM_SRC
 	core/mem/Memory.cpp
-	core/mem/HeapAllocator.cpp
 	core/mem/LinearAllocator.cpp
 	core/mem/StackAllocator.cpp
 	core/mem/ProxyAllocator.cpp
@@ -222,7 +221,6 @@ set (MEM_SRC
 set (MEM_HEADERS
 	core/mem/Memory.h
 	core/mem/Allocator.h
-	core/mem/HeapAllocator.h
 	core/mem/TempAllocator.h
 	core/mem/LinearAllocator.h
 	core/mem/StackAllocator.h
@@ -497,17 +495,6 @@ if (LINUX)
 		openal
 		vorbisfile
 		luajit-5.1
-
-		LowLevel
-		LowLevelCloth
-		PhysX3
-		PhysX3CharacterKinematic
-		PhysX3Common
-		PhysX3Extensions
-		PhysXProfileSDK
-		PxTask
-		SceneQuery
-		SimulationController
 	)
 
 	set (COMPILER_FLAGS
@@ -529,9 +516,37 @@ if (LINUX)
 	)
 
 	if (CROWN_DEBUG)
-		list (APPEND COMPILER_FLAGS -g -pg -D_DEBUG)
+		list (APPEND COMPILER_FLAGS -g -D_DEBUG)
+		list (APPEND CROWN_LIBRARIES
+			LowLevelCHECKED
+			LowLevelClothCHECKED
+			PhysX3CharacterKinematicCHECKED
+			PhysX3CHECKED
+			PhysX3CommonCHECKED
+			PhysX3ExtensionsCHECKED
+			PhysXProfileSDKCHECKED
+			PhysXVisualDebuggerSDKCHECKED
+			PvdRuntimeCHECKED
+			PxTaskCHECKED
+			SceneQueryCHECKED
+			SimulationControllerCHECKED
+		)
 	elseif (CROWN_DEVELOPMENT)
 		list (APPEND COMPILER_FLAGS -O2 -DNDEBUG)
+		list (APPEND CROWN_LIBRARIES
+			LowLevelPROFILE
+			LowLevelClothPROFILE
+			PhysX3CharacterKinematicPROFILE
+			PhysX3PROFILE
+			PhysX3CommonPROFILE
+			PhysX3ExtensionsPROFILE
+			PhysXProfileSDKPROFILE
+			PhysXVisualDebuggerSDKPROFILE
+			PvdRuntimePROFILE
+			PxTaskPROFILE
+			SceneQueryPROFILE
+			SimulationControllerPROFILE
+		)
 	elseif (CROWN_RELEASE)
 		list (APPEND COMPILER_FLAGS
 			-DNDEBUG
@@ -542,6 +557,20 @@ if (LINUX)
 			-Wno-unused-but-set-variable
 			-Wno-unused-function
 		)
+		list (APPEND CROWN_LIBRARIES
+			LowLevel
+			LowLevelCloth
+			PhysX3CharacterKinematic
+			PhysX3
+			PhysX3Common
+			PhysX3Extensions
+			PhysXProfileSDK
+			PhysXVisualDebuggerSDK
+			PvdRuntime
+			PxTask
+			SceneQuery
+			SimulationController
+		)
 	else ()
 		message (FATAL_ERROR "Oops, you should not be here")
 	endif (CROWN_DEBUG)

+ 70 - 103
engine/ConsoleServer.cpp

@@ -42,9 +42,6 @@ namespace crown
 //-----------------------------------------------------------------------------
 ConsoleServer::ConsoleServer(uint16_t port)
 	: m_port(port)
-	, m_num_clients(0)
-	, m_receive_buffer(default_allocator())
-	, m_receive_callbacks(default_allocator())
 {
 }
 
@@ -56,8 +53,14 @@ void ConsoleServer::init(bool wait)
 
 	if (wait)
 	{
+		AcceptResult result;
 		TCPSocket client;
-		m_server.accept(client);
+		do
+		{
+			result = m_server.accept(client);
+		}
+		while (result.error != AcceptResult::NO_ERROR);
+
 		add_client(client);
 	}
 }
@@ -65,7 +68,7 @@ void ConsoleServer::init(bool wait)
 //-----------------------------------------------------------------------------
 void ConsoleServer::shutdown()
 {
-	for (uint32_t i = 0; i < MAX_CONSOLE_CLIENTS; i++)
+	for (uint32_t i = 0; i < m_clients.size(); i++)
 	{
 		m_clients[i].close();
 	}
@@ -94,151 +97,115 @@ void ConsoleServer::log_to_all(const char* message, LogSeverity::Enum severity)
 
 	json << "\"message\":\"" << buf << "\"}";
 
-	send_message_to_all(json.c_str());
+	send_to_all(json.c_str());
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::send_message_to(ClientId client, const char* message)
+void ConsoleServer::send(TCPSocket client, const char* message)
 {
 	uint32_t msg_len = string::strlen(message);
-	m_clients[client.index].write((const char*) &msg_len, 4);
-	m_clients[client.index].write(message, msg_len);
+	client.write((const char*) &msg_len, 4);
+	client.write(message, msg_len);
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::send_message_to_all(const char* message)
+void ConsoleServer::send_to_all(const char* message)
 {
-	// Update all clients
-	for (uint32_t i = 0; i < MAX_CONSOLE_CLIENTS; i++)
+	for (uint32_t i = 0; i < m_clients.size(); i++)
 	{
-		ClientId id = *(m_clients_table.begin() + i);
-		if (id.id != INVALID_ID)
-		{
-			send_message_to(id, message);
-		}
+		send(m_clients[i].socket, message);
 	}
 }
 
 //-----------------------------------------------------------------------------
 void ConsoleServer::update()
 {
-	// Check for new clients
-	TCPSocket client;
-	if (m_server.accept_nonblock(client))
+	// Check for new clients only if we have room for them
+	if (m_clients.size() < MAX_CONSOLE_CLIENTS - 1)
 	{
-		add_client(client);
+		TCPSocket client;
+		AcceptResult result = m_server.accept_nonblock(client);
+		if (result.error == AcceptResult::NO_ERROR)
+		{
+			add_client(client);
+		}
 	}
 
+	TempAllocator256 alloc;
+	List<Id> to_remove(alloc);
+
 	// Update all clients
-	for (uint32_t i = 0; i < MAX_CONSOLE_CLIENTS; i++)
+	for (uint32_t i = 0; i < m_clients.size(); i++)
 	{
-		ClientId id = *(m_clients_table.begin() + i);
-		if (id.id != INVALID_ID)
-		{
-			update_client(id);
-		}
+		ReadResult rr = update_client(m_clients[i].socket);
+		if (rr.error != ReadResult::NO_ERROR) to_remove.push_back(m_clients[i].id);
 	}
 
-	// Process all requests
-	process_requests();
+	// Remove clients
+	for (uint32_t i = 0; i < to_remove.size(); i++)
+	{
+		m_clients.lookup(to_remove[i]).socket.close();
+		m_clients.destroy(to_remove[i]);
+	}
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::process_requests()
+void ConsoleServer::add_client(TCPSocket socket)
 {
-	for (uint32_t i = 0; i < m_receive_callbacks.size(); i++)
-	{
-		RPCCallback cb = m_receive_callbacks.front();
-		m_receive_callbacks.pop_front();
-
-		const char* request = &m_receive_buffer[cb.message_index];
-		JSONParser parser(request);
-		JSONElement request_type = parser.root().key("type");
-		DynamicString type; 
-		request_type.string_value(type);
-
-		// Determine request type
-		if (type == "ping") process_ping(cb.client, request);
-		else if (type == "script") process_script(cb.client, request);
-		else if (type == "stats") process_stats(cb.client, request);
-		else if (type == "command") process_command(cb.client, request);
-		else if (type == "filesystem") processs_filesystem(cb.client, request);
-		else continue;
-	}
-
-	m_receive_callbacks.clear();
-	m_receive_buffer.clear();
+	Client client;
+	client.socket = socket;
+	Id id = m_clients.create(client);
+	m_clients.lookup(id).id = id;
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::update_client(ClientId id)
+ReadResult ConsoleServer::update_client(TCPSocket client)
 {
-	TCPSocket& client = m_clients[id.index];
-
 	uint32_t msg_len = 0;
 	ReadResult rr = client.read_nonblock(&msg_len, 4);
 
 	// If no data received, return
-	if (rr.error == ReadResult::NO_ERROR && rr.bytes_read == 0) return;
-	if (rr.error == ReadResult::REMOTE_CLOSED)
-	{
-		remove_client(id);
-		return;
-	}
+	if (rr.error == ReadResult::NO_ERROR && rr.bytes_read == 0) return rr;
+	if (rr.error == ReadResult::REMOTE_CLOSED) return rr;
+	if (rr.error != ReadResult::NO_ERROR) return rr;
 
 	// Else read the message
 	List<char> msg_buf(default_allocator());
 	msg_buf.resize(msg_len);
 	ReadResult msg_result = client.read(msg_buf.begin(), msg_len);
+	msg_buf.push_back('\0');
 
-	uint32_t message_index = m_receive_buffer.size();
-	m_receive_buffer.push(msg_buf.begin(), msg_result.bytes_read);
-	m_receive_buffer.push_back('\0');
-	add_request(id, message_index);
-}
-
-//-----------------------------------------------------------------------------
-void ConsoleServer::add_client(TCPSocket& client)
-{
-	if (m_num_clients < MAX_CONSOLE_CLIENTS)
-	{
-		ClientId id = m_clients_table.create();
-		m_clients[id.index] = client;
-		m_num_clients++;
-	}
-	else
-	{
-		Log::e("Too many clients, connection denied");
-	}
-}
-
-//-----------------------------------------------------------------------------
-void ConsoleServer::remove_client(ClientId id)
-{
-	CE_ASSERT(m_num_clients > 0, "No client connected");
+	if (msg_result.error == ReadResult::REMOTE_CLOSED) return msg_result;
+	if (msg_result.error != ReadResult::NO_ERROR) return msg_result;
 
-	m_clients[id.index].close();
-	m_clients_table.destroy(id);
-	m_num_clients--;
+	process(client, msg_buf.begin());
+	return msg_result;
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::add_request(ClientId client, uint32_t message_index)
+void ConsoleServer::process(TCPSocket client, const char* request)
 {
-	RPCCallback cb;
-	cb.client = client;
-	cb.message_index = message_index;
-	m_receive_callbacks.push_back(cb);
+	JSONParser parser(request);
+	DynamicString type; 
+	parser.root().key("type").string_value(type);
+
+	// Determine request type
+	if (type == "ping") process_ping(client, request);
+	else if (type == "script") process_script(client, request);
+	else if (type == "stats") process_stats(client, request);
+	else if (type == "command") process_command(client, request);
+	else if (type == "filesystem") processs_filesystem(client, request);
+	else CE_FATAL("Request unknown.");
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::process_ping(ClientId client, const char* /*msg*/)
+void ConsoleServer::process_ping(TCPSocket client, const char* /*msg*/)
 {
-	send_message_to(client, "{\"type\":\"pong\"}");
+	send(client, "{\"type\":\"pong\"}");
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::process_script(ClientId /*client*/, const char* msg)
+void ConsoleServer::process_script(TCPSocket /*client*/, const char* msg)
 {
 	JSONParser parser(msg);
 	JSONElement root = parser.root();
@@ -249,7 +216,7 @@ void ConsoleServer::process_script(ClientId /*client*/, const char* msg)
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::process_stats(ClientId client, const char* /*msg*/)
+void ConsoleServer::process_stats(TCPSocket client, const char* /*msg*/)
 {
 	TempAllocator2048 alloc;
 	StringStream response(alloc);
@@ -271,11 +238,11 @@ void ConsoleServer::process_stats(ClientId client, const char* /*msg*/)
 
 	response << "]" << "}";
 
-	send_message_to(client, response.c_str());
+	send(client, response.c_str());
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::process_command(ClientId /*client*/, const char* msg)
+void ConsoleServer::process_command(TCPSocket /*client*/, const char* msg)
 {
 	JSONParser parser(msg);
 	JSONElement root = parser.root();
@@ -311,7 +278,7 @@ void ConsoleServer::process_command(ClientId /*client*/, const char* msg)
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::processs_filesystem(ClientId client, const char* msg)
+void ConsoleServer::processs_filesystem(TCPSocket client, const char* msg)
 {
 	JSONParser parser(msg);
 	JSONElement root = parser.root();
@@ -333,7 +300,7 @@ void ConsoleServer::processs_filesystem(ClientId client, const char* msg)
 		StringStream response(alloc);
 		response << "{\"type\":\"file\",\"size\":" << file_size << "}";
 
-		send_message_to(client, response.c_str());
+		send(client, response.c_str());
 	}
 	else if (cmd == "read")
 	{
@@ -361,7 +328,7 @@ void ConsoleServer::processs_filesystem(ClientId client, const char* msg)
 		response << "{\"type\":\"file\",";
 		response << "\"data\":\"" << bytes_encoded << "\"}";
 
-		send_message_to(client, response.c_str());
+		send(client, response.c_str());
 
 		// Cleanup
 		default_allocator().deallocate(bytes_encoded);

+ 25 - 27
engine/ConsoleServer.h

@@ -29,21 +29,27 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "OsSocket.h"
 #include "List.h"
 #include "Queue.h"
-#include "IdTable.h"
+#include "IdArray.h"
 #include "Log.h"
 
+#define MAX_CONSOLE_CLIENTS 32
+
 namespace crown
 {
 
-typedef Id ClientId;
-#define MAX_CONSOLE_CLIENTS 100
-
-struct RPCCallback
+struct Client
 {
-	ClientId client;
-	uint32_t message_index;
+	Id id;
+	TCPSocket socket;
+
+	void close()
+	{
+		socket.close();
+	}
 };
 
+typedef IdArray<MAX_CONSOLE_CLIENTS, Client> ClientArray;
+
 class ConsoleServer
 {
 public:
@@ -58,37 +64,29 @@ public:
 
 	void						log_to_all(const char* message, LogSeverity::Enum severity);
 
-	void						send_message_to(ClientId client, const char* message);
-	void						send_message_to_all(const char* message);
-
 	/// Collects requests from clients and processes them all.
 	void						update();
 
 private:
 
-	void						process_requests();
-	void						update_client(ClientId id);
-	void						add_client(TCPSocket& client);
-	void						remove_client(ClientId id);
+	void						send(TCPSocket client, const char* message);
+	void						send_to_all(const char* message);
+
+	void						add_client(TCPSocket socket);
+	ReadResult					update_client(TCPSocket client);
+	void						process(TCPSocket client, const char* request);
 
-	void						add_request(ClientId client, uint32_t message_index);
-	void						process_ping(ClientId client, const char* msg);
-	void						process_script(ClientId client, const char* msg);
-	void						process_stats(ClientId client, const char* msg);
-	void						process_command(ClientId client, const char* msg);
-	void						processs_filesystem(ClientId client, const char* msg);
+	void						process_ping(TCPSocket client, const char* msg);
+	void						process_script(TCPSocket client, const char* msg);
+	void						process_stats(TCPSocket client, const char* msg);
+	void						process_command(TCPSocket client, const char* msg);
+	void						processs_filesystem(TCPSocket client, const char* msg);
 
 private:
 
 	uint16_t					m_port;
 	TCPServer					m_server;
-
-	uint8_t						m_num_clients;
-	IdTable<MAX_CONSOLE_CLIENTS>	m_clients_table;
-	TCPSocket					m_clients[MAX_CONSOLE_CLIENTS];
-
-	List<char>					m_receive_buffer;
-	Queue<RPCCallback>			m_receive_callbacks;
+	ClientArray					m_clients;
 };
 
 } // namespace crown

+ 0 - 1
engine/Crown.h

@@ -74,7 +74,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 // Core/Mem
 #include "Memory.h"
 #include "Allocator.h"
-#include "HeapAllocator.h"
 #include "TempAllocator.h"
 #include "LinearAllocator.h"
 #include "StackAllocator.h"

+ 8 - 12
engine/core/containers/IdArray.h

@@ -128,31 +128,28 @@ inline const T& IdArray<MAX_NUM_ID, T>::operator[](uint32_t i) const
 template <uint32_t MAX_NUM_ID, typename T>
 inline Id IdArray<MAX_NUM_ID, T>::create(const T& object)
 {
+	CE_ASSERT(m_num_objects < MAX_NUM_ID, "Object list full");
+
 	// Obtain a new id
 	Id id;
 	id.id = next_id();
 
-	uint16_t dense_index;
-
 	// Recycle slot if there are any
 	if (m_freelist != INVALID_ID)
 	{
 		id.index = m_freelist;
 		m_freelist = m_sparse[m_freelist].index;
-		m_objects[id.index] = object;
-		dense_index = id.index;
 	}
 	else
 	{
 		id.index = m_last_index++;
-		m_objects[m_num_objects] = object;
-		dense_index = m_num_objects;
 	}
 
-	m_num_objects++;
 	m_sparse[id.index] = id;
-	m_sparse_to_dense[id.index] = dense_index;
-	m_dense_to_sparse[dense_index] = id.index;
+	m_sparse_to_dense[id.index] = m_num_objects;
+	m_dense_to_sparse[m_num_objects] = id.index;
+	m_objects[m_num_objects] = object;
+	m_num_objects++;
 
 	return id;
 }
@@ -169,14 +166,15 @@ inline void IdArray<MAX_NUM_ID, T>::destroy(Id id)
 
 	// Swap with last element
 	const uint32_t last = m_num_objects - 1;
+	CE_ASSERT(last >= m_sparse_to_dense[id.index], "Swapping with previous item");
 	m_objects[m_sparse_to_dense[id.index]] = m_objects[last];
-	m_num_objects--;
 
 	// Update tables
 	uint16_t std = m_sparse_to_dense[id.index];
 	uint16_t dts = m_dense_to_sparse[last];
 	m_sparse_to_dense[dts] = std;
 	m_dense_to_sparse[std] = dts;
+	m_num_objects--;
 }
 
 //-----------------------------------------------------------------------------
@@ -206,8 +204,6 @@ inline uint32_t IdArray<MAX_NUM_ID, T>::size() const
 template <uint32_t MAX_NUM_ID, typename T>
 inline uint16_t IdArray<MAX_NUM_ID, T>::next_id()
 {
-	CE_ASSERT(m_next_id < MAX_NUM_ID, "Maximum number of IDs reached");
-
 	return m_next_id++;
 }
 

+ 2 - 6
engine/core/filesystem/File.cpp

@@ -27,7 +27,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "File.h"
 #include "Types.h"
 #include "Compressor.h"
-#include "HeapAllocator.h"
 
 namespace crown
 {
@@ -35,8 +34,7 @@ namespace crown
 //-----------------------------------------------------------------------------
 bool File::compress_to(File& file, size_t size, size_t& zipped_size, Compressor& compressor)
 {
-	HeapAllocator allocator;
-	void* in_buffer = (void*)allocator.allocate(size);
+	void* in_buffer = (void*) default_allocator().allocate(size);
 
 	read(in_buffer, size);
 
@@ -50,10 +48,8 @@ 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)
 {
-	HeapAllocator allocator;
-
 	size_t file_size = size();
-	void* in_buffer = (void*)allocator.allocate(file_size);
+	void* in_buffer = (void*) default_allocator().allocate(file_size);
 
 	read(in_buffer, file_size);
 

+ 0 - 1
engine/core/filesystem/NetworkFile.h

@@ -30,7 +30,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "File.h"
 #include "OsSocket.h"
 #include "File.h"
-#include "HeapAllocator.h"
 
 namespace crown
 {

+ 0 - 133
engine/core/mem/HeapAllocator.cpp

@@ -1,133 +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 <cstdlib>
-
-#include "HeapAllocator.h"
-#include "Assert.h"
-
-namespace crown
-{
-
-//-----------------------------------------------------------------------------
-HeapAllocator::HeapAllocator() :
-	m_allocated_size(0),
-	m_allocation_count(0)
-{
-}
-
-//-----------------------------------------------------------------------------
-HeapAllocator::~HeapAllocator()
-{
-	CE_ASSERT(m_allocation_count == 0 && allocated_size() == 0,
-		"Missing %d deallocations causing a leak of %ld bytes", m_allocation_count, allocated_size());
-}
-
-//-----------------------------------------------------------------------------
-void* HeapAllocator::allocate(size_t size, size_t align)
-{
-	size_t actual_size = actual_allocation_size(size, align);
-
-	Header* h = (Header*)malloc(actual_size);
-	h->size = actual_size;
-
-	void* data = memory::align_top(h + 1, align);
-
-	pad(h, data);
-
-	m_allocated_size += actual_size;
-	m_allocation_count++;
-
-	return data;
-}
-
-//-----------------------------------------------------------------------------
-void HeapAllocator::deallocate(void* data)
-{
-	if (!data) return;
-
-	Header* h = header(data);
-
-	m_allocated_size -= h->size;
-	m_allocation_count--;
-
-	free(h);
-}
-
-//-----------------------------------------------------------------------------
-size_t HeapAllocator::allocated_size()
-{
-	return m_allocated_size;
-}
-
-//-----------------------------------------------------------------------------
-size_t HeapAllocator::get_size(void* data)
-{
-	Header* h = header(data);
-
-	return h->size;
-}
-
-//-----------------------------------------------------------------------------
-size_t HeapAllocator::actual_allocation_size(size_t size, size_t align)
-{
-	return size + align + sizeof(Header);
-}
-
-//-----------------------------------------------------------------------------
-HeapAllocator::Header* HeapAllocator::header(void* data)
-{
-	uint32_t* ptr = (uint32_t*)data;
-	ptr--;
-
-	while (*ptr == memory::PADDING_VALUE)
-	{
-		ptr--;
-	}
-
-	return (Header*)ptr;
-}
-
-//-----------------------------------------------------------------------------
-void* HeapAllocator::data(Header* header, size_t align)
-{
-	return memory::align_top(header + 1, align);
-}
-
-//-----------------------------------------------------------------------------
-void HeapAllocator::pad(Header* header, void* data)
-{
-	uint32_t* p = (uint32_t*)(header + 1);
-
-	while (p != data)
-	{
-		*p = memory::PADDING_VALUE;
-		p++;
-	}
-}
-
-} // namespace crown
-

+ 0 - 72
engine/core/mem/HeapAllocator.h

@@ -1,72 +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.
-*/
-
-#pragma once
-
-#include "Allocator.h"
-
-namespace crown
-{
-
-/// Allocator based on C malloc().
-class HeapAllocator : public Allocator
-{
-public:
-
-				HeapAllocator();
-				~HeapAllocator();
-
-	/// @copydoc Allocator::allocate()
-	void*		allocate(size_t size, size_t align = memory::DEFAULT_ALIGN);
-
-	/// @copydoc Allocator::deallocate()
-	void		deallocate(void* data);
-
-	/// @copydoc Allocator::allocated_size()
-	size_t		allocated_size();
-
-	/// Returns the size in bytes of the block of memory pointed by @a data
-	size_t		get_size(void* data);
-
-private:
-
-	// Holds the number of bytes of an allocation
-	struct Header
-	{
-		uint32_t	size;
-	};
-
-	size_t		actual_allocation_size(size_t size, size_t align);
-	Header*		header(void* data);
-	void*		data(Header* header, size_t align);
-	void		pad(Header* header, void* data);
-
-	size_t		m_allocated_size;
-	uint32_t	m_allocation_count;
-};
-
-} // namespace crown
-

+ 123 - 1
engine/core/mem/Memory.cpp

@@ -25,7 +25,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "Memory.h"
-#include "HeapAllocator.h"
+#include "Allocator.h"
+#include "ScopedMutex.h"
 
 // //-----------------------------------------------------------------------------
 // void* operator new(size_t) throw (std::bad_alloc)
@@ -60,6 +61,127 @@ namespace crown
 namespace memory
 {
 
+/// Allocator based on C malloc().
+class HeapAllocator : public Allocator
+{
+public:
+
+	HeapAllocator()
+		: m_allocated_size(0)
+		, m_allocation_count(0)
+	{
+	}
+
+	~HeapAllocator()
+	{
+		CE_ASSERT(m_allocation_count == 0 && allocated_size() == 0,
+			"Missing %d deallocations causing a leak of %ld bytes", m_allocation_count, allocated_size());
+	}
+
+	/// @copydoc Allocator::allocate()
+	void* allocate(size_t size, size_t align = memory::DEFAULT_ALIGN)
+	{
+		ScopedMutex sm(m_mutex);
+
+		size_t actual_size = actual_allocation_size(size, align);
+
+		Header* h = (Header*)malloc(actual_size);
+		h->size = actual_size;
+
+		void* data = memory::align_top(h + 1, align);
+
+		pad(h, data);
+
+		m_allocated_size += actual_size;
+		m_allocation_count++;
+
+		return data;
+	}
+
+	/// @copydoc Allocator::deallocate()
+	void deallocate(void* data)
+	{
+		ScopedMutex sm(m_mutex);
+
+		if (!data) return;
+
+		Header* h = header(data);
+
+		m_allocated_size -= h->size;
+		m_allocation_count--;
+
+		free(h);
+	}
+
+	/// @copydoc Allocator::allocated_size()
+	size_t allocated_size()
+	{
+		ScopedMutex sm(m_mutex);
+		return m_allocated_size;
+	}
+
+	/// Returns the size in bytes of the block of memory pointed by @a data
+	size_t get_size(void* data)
+	{
+		ScopedMutex sm(m_mutex);
+		Header* h = header(data);
+		return h->size;
+	}
+
+private:
+
+	// Holds the number of bytes of an allocation
+	struct Header
+	{
+		uint32_t	size;
+	};
+
+	//-----------------------------------------------------------------------------
+	size_t actual_allocation_size(size_t size, size_t align)
+	{
+		return size + align + sizeof(Header);
+	}
+
+	//-----------------------------------------------------------------------------
+	Header* header(void* data)
+	{
+		uint32_t* ptr = (uint32_t*)data;
+		ptr--;
+
+		while (*ptr == memory::PADDING_VALUE)
+		{
+			ptr--;
+		}
+
+		return (Header*)ptr;
+	}
+
+	//-----------------------------------------------------------------------------
+	void* data(Header* header, size_t align)
+	{
+		return memory::align_top(header + 1, align);
+	}
+
+	//-----------------------------------------------------------------------------
+	void pad(Header* header, void* data)
+	{
+		uint32_t* p = (uint32_t*)(header + 1);
+
+		while (p != data)
+		{
+			*p = memory::PADDING_VALUE;
+			p++;
+		}
+	}
+
+private:
+
+	Mutex		m_mutex;
+	size_t		m_allocated_size;
+	uint32_t	m_allocation_count;
+};
+
+// Create default allocators
 static char buffer[1024];
 static HeapAllocator* g_default_allocator = NULL;
 

+ 13 - 7
engine/os/posix/Mutex.h

@@ -49,6 +49,7 @@ public:
 private:
 
 	pthread_mutex_t		m_mutex;
+	pthread_mutexattr_t m_attr;
 
 private:
 
@@ -63,33 +64,38 @@ private:
 inline Mutex::Mutex()
 {
 	memset(&m_mutex, 0, sizeof(pthread_mutex_t));
+	int result;
 
-	int32_t result = pthread_mutex_init(&m_mutex, NULL);
-
+	result = pthread_mutexattr_init(&m_attr);
+	CE_ASSERT(result == 0, "Failed to init mutex attr. errno: %d", result);
+	result = pthread_mutexattr_settype(&m_attr, PTHREAD_MUTEX_ERRORCHECK);
+	CE_ASSERT(result == 0, "Failed to set mutex type. errno: %d", result);
+	result = pthread_mutex_init(&m_mutex, &m_attr);
 	CE_ASSERT(result == 0, "Failed to init mutex. errno: %d", result);
 }
 
 //-----------------------------------------------------------------------------
 inline Mutex::~Mutex()
 {
-	int32_t result = pthread_mutex_destroy(&m_mutex);
+	int result;
 
+	result = pthread_mutex_destroy(&m_mutex);
 	CE_ASSERT(result == 0, "Failed to destroy mutex. errno: %d", result);
+	result = pthread_mutexattr_destroy(&m_attr);
+	CE_ASSERT(result == 0, "Failed to destroy mutex attr. errno: %d", result);
 }
 
 //-----------------------------------------------------------------------------
 inline void Mutex::lock()
 {
-	int32_t result = pthread_mutex_lock(&m_mutex);
-
+	int result = pthread_mutex_lock(&m_mutex);
 	CE_ASSERT(result == 0, "Failed to acquire lock. errno: %d", result);
 }
 
 //-----------------------------------------------------------------------------
 inline void Mutex::unlock()
 {
-	int32_t result = pthread_mutex_unlock(&m_mutex);
-
+	int result = pthread_mutex_unlock(&m_mutex);
 	CE_ASSERT(result == 0, "Failed to release lock. errno: %d", result);
 }
 

+ 40 - 12
engine/os/posix/OsSocket.h

@@ -52,6 +52,11 @@ struct WriteResult
 	size_t bytes_wrote;
 };
 
+struct AcceptResult
+{
+	enum { NO_ERROR, NO_CONNECTION, UNKNOWN } error;
+};
+
 class TCPSocket
 {
 public:
@@ -230,6 +235,13 @@ public:
 		fcntl(m_socket, F_SETFL, blocking ? (flags & ~O_NONBLOCK) : O_NONBLOCK);
 	}
 
+	//-----------------------------------------------------------------------------
+	void set_resuse_address(bool reuse)
+	{
+		int optval = (int) reuse;
+		setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));
+	}
+
 public:
 
 	int m_socket;
@@ -245,6 +257,8 @@ public:
 		m_server.m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
 		CE_ASSERT(m_server.m_socket > 0, "Failed to create socket");
 
+		m_server.set_resuse_address(true);
+
 		// Bind socket
 		sockaddr_in address;
 		address.sin_family = AF_INET;
@@ -271,40 +285,54 @@ public:
 	}
 
 	//-----------------------------------------------------------------------------
-	bool accept_nonblock(TCPSocket& c)
+	AcceptResult accept_nonblock(TCPSocket& c)
 	{
 		m_server.set_blocking(false);
 
 		sockaddr_in client;
 		size_t client_size = sizeof(client);
-		int asd = ::accept(m_server.m_socket, (sockaddr*) &client, (socklen_t*) &client_size);
+		int sock = ::accept(m_server.m_socket, (sockaddr*) &client, (socklen_t*) &client_size);
 
-		if (asd == -1 && errno == EWOULDBLOCK)
+		AcceptResult result;
+		if (sock == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
 		{
-			return false;
+			result.error = AcceptResult::NO_CONNECTION;
+		}
+		else if (sock == -1)
+		{
+			result.error = AcceptResult::UNKNOWN;
+		}
+		else
+		{
+			result.error = AcceptResult::NO_ERROR;
+			c.m_socket = sock;
 		}
 
-		c.m_socket = asd;
-		return true;
+		return result;
 	}
 
 	//-----------------------------------------------------------------------------
-	bool accept(TCPSocket& c)
+	AcceptResult accept(TCPSocket& c)
 	{
 		m_server.set_blocking(true);
 
 		sockaddr_in client;
 		size_t client_size = sizeof(client);
 
-		int asd = ::accept(m_server.m_socket, (sockaddr*) &client, (socklen_t*) &client_size);
+		int sock = ::accept(m_server.m_socket, (sockaddr*) &client, (socklen_t*) &client_size);
 
-		if (asd == -1 && errno == EWOULDBLOCK)
+		AcceptResult result;
+		if (sock == -1)
 		{
-			return false;
+			result.error = AcceptResult::UNKNOWN;
+		}
+		else
+		{
+			result.error = AcceptResult::NO_ERROR;
+			c.m_socket = sock;
 		}
 
-		c.m_socket = asd;
-		return true;
+		return result;
 	}
 
 	//-----------------------------------------------------------------------------

+ 2 - 1
engine/physics/PhysicsWorld.cpp

@@ -76,9 +76,10 @@ PhysicsWorld::PhysicsWorld()
 
 	if(!scene_desc.filterShader)
 		scene_desc.filterShader = g_default_filter_shader;
+
+	scene_desc.flags = PxSceneFlag::eENABLE_ACTIVETRANSFORMS;
 	
 	m_scene = device()->physx()->createScene(scene_desc);
-	m_scene->setFlag(PxSceneFlag::eENABLE_ACTIVETRANSFORMS, true);
 
 	// Create controller manager
 	m_controller_manager = PxCreateControllerManager(device()->physx()->getFoundation());

+ 8 - 0
engine/renderers/backend/RenderContext.h

@@ -26,6 +26,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
+#include <algorithm>
+
 #include "Color4.h"
 #include "Matrix4x4.h"
 #include "CommandBuffer.h"
@@ -162,6 +164,7 @@ struct Sampler
 	uint32_t	flags;
 };
 
+/// Maintains the states necessary for a single draw call.
 struct RenderState
 {
 	void clear()
@@ -344,6 +347,11 @@ struct RenderContext
 		m_constants.commit();
 	}
 
+	void sort()
+	{
+		std::sort(m_keys, m_keys + m_num_states);
+	}
+
 public:
 
 	uint64_t m_flags;

+ 1 - 1
engine/renderers/backend/gl/GLRenderer.cpp

@@ -260,7 +260,7 @@ public:
 		uint8_t layer = 0xFF;
 
 		// Sort render keys
-		std::sort(context.m_keys, context.m_keys + context.m_num_states);
+		context.sort();
 
 		for (uint32_t s = 0; s < context.m_num_states; s++)
 		{

+ 0 - 1
engine/renderers/backend/gl/GLRenderer.h

@@ -40,7 +40,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Renderer.h"
 #include "Resource.h"
 #include "GLContext.h"
-#include "HeapAllocator.h"
 #include "VertexFormat.h"
 #include "Allocator.h"
 

+ 4 - 4
engine/resource/PhysicsResource.cpp

@@ -41,10 +41,10 @@ static uint32_t shape_type_to_enum(const char* type)
 {
 	const StringId32 th = hash::murmur2_32(type, string::strlen(type));
 
-	if (th == hash::HASH32("sphere", 0x2eaa6850)) return PhysicsShapeType::SPHERE;
-	else if (th == hash::HASH32("capsule", 0xefe0dead)) return PhysicsShapeType::CAPSULE;
-	else if (th == hash::HASH32("box", 0x5af3a067)) return PhysicsShapeType::BOX;
-	else if (th == hash::HASH32("plane", 0xfb96769a)) return PhysicsShapeType::PLANE;
+	if (string::strcmp("sphere", type) == 0) return PhysicsShapeType::SPHERE;
+	else if (string::strcmp("capsule", type) == 0) return PhysicsShapeType::CAPSULE;
+	else if (string::strcmp("box", type) == 0) return PhysicsShapeType::BOX;
+	else if (string::strcmp("plane", type) == 0) return PhysicsShapeType::PLANE;
 
 	CE_FATAL("Bad shape type");
 }

+ 0 - 1
engine/world/World.h

@@ -27,7 +27,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Camera.h"
-#include "HeapAllocator.h"
 #include "IdArray.h"
 #include "LinearAllocator.h"
 #include "PhysicsTypes.h"

+ 4 - 5
tools/gui/console/MainWindow.cs

@@ -492,7 +492,6 @@ public partial class MainWindow: Gtk.Window
 	protected void SendScript(String script)
 	{
 		string json = "{\"type\":\"script\",\"script\":\"" + script + "\"}";
-
 		Send(json);
 	}
 
@@ -534,12 +533,12 @@ public partial class MainWindow: Gtk.Window
 			Connect();
 
 			// Sanitize entered text
-			string safe_text = text.Replace("\"", "\\\""); 
+			string safe_text = text.Replace("\"", "\\\"");
 
-			if (combobox1.Active == 0) {
-				SendScript (safe_text);
+			if (safe_text[0] == '\\') {
+				SendCommand (safe_text.Substring(1));
 			} else {
-				SendCommand (safe_text);
+				SendScript (safe_text);	
 			}
 
 			// Log entered text

+ 6 - 25
tools/gui/console/gtk-gui/MainWindow.cs

@@ -10,8 +10,6 @@ public partial class MainWindow
 	private global::Gtk.MenuBar menubar1;
 	private global::Gtk.ScrolledWindow scrolledwindow1;
 	private global::Gtk.TextView textview1;
-	private global::Gtk.HBox hbox2;
-	private global::Gtk.ComboBox combobox1;
 	private global::Gtk.Entry entry1;
 
 	protected virtual void Build ()
@@ -59,34 +57,17 @@ public partial class MainWindow
 		global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.scrolledwindow1]));
 		w4.Position = 1;
 		// Container child vbox1.Gtk.Box+BoxChild
-		this.hbox2 = new global::Gtk.HBox ();
-		this.hbox2.Name = "hbox2";
-		this.hbox2.Spacing = 6;
-		// Container child hbox2.Gtk.Box+BoxChild
-		this.combobox1 = global::Gtk.ComboBox.NewText ();
-		this.combobox1.AppendText (global::Mono.Unix.Catalog.GetString ("Script"));
-		this.combobox1.AppendText (global::Mono.Unix.Catalog.GetString ("Command"));
-		this.combobox1.Name = "combobox1";
-		this.combobox1.Active = 0;
-		this.hbox2.Add (this.combobox1);
-		global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.combobox1]));
-		w5.Position = 0;
-		w5.Expand = false;
-		w5.Fill = false;
-		// Container child hbox2.Gtk.Box+BoxChild
 		this.entry1 = new global::Gtk.Entry ();
 		this.entry1.CanFocus = true;
 		this.entry1.Name = "entry1";
 		this.entry1.IsEditable = true;
 		this.entry1.InvisibleChar = '●';
-		this.hbox2.Add (this.entry1);
-		global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.entry1]));
-		w6.Position = 1;
-		this.vbox1.Add (this.hbox2);
-		global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox2]));
-		w7.Position = 2;
-		w7.Expand = false;
-		w7.Fill = false;
+		this.vbox1.Add (this.entry1);
+		global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.entry1]));
+		w5.PackType = ((global::Gtk.PackType)(1));
+		w5.Position = 2;
+		w5.Expand = false;
+		w5.Fill = false;
 		this.Add (this.vbox1);
 		if ((this.Child != null)) {
 			this.Child.ShowAll ();

+ 7 - 31
tools/gui/console/gtk-gui/gui.stetic

@@ -65,40 +65,16 @@
           </packing>
         </child>
         <child>
-          <widget class="Gtk.HBox" id="hbox2">
+          <widget class="Gtk.Entry" id="entry1">
             <property name="MemberName" />
-            <property name="Spacing">6</property>
-            <child>
-              <widget class="Gtk.ComboBox" id="combobox1">
-                <property name="MemberName" />
-                <property name="IsTextCombo">True</property>
-                <property name="Items" translatable="yes">Script
-Command</property>
-                <property name="Active">0</property>
-              </widget>
-              <packing>
-                <property name="Position">0</property>
-                <property name="AutoSize">True</property>
-                <property name="Expand">False</property>
-                <property name="Fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="Gtk.Entry" id="entry1">
-                <property name="MemberName" />
-                <property name="CanFocus">True</property>
-                <property name="IsEditable">True</property>
-                <property name="InvisibleChar">●</property>
-                <signal name="Activated" handler="OnEntryActivated" />
-                <signal name="KeyPressEvent" handler="OnEntryKeyPressed" />
-              </widget>
-              <packing>
-                <property name="Position">1</property>
-                <property name="AutoSize">True</property>
-              </packing>
-            </child>
+            <property name="CanFocus">True</property>
+            <property name="IsEditable">True</property>
+            <property name="InvisibleChar">●</property>
+            <signal name="Activated" handler="OnEntryActivated" />
+            <signal name="KeyPressEvent" handler="OnEntryKeyPressed" />
           </widget>
           <packing>
+            <property name="PackType">End</property>
             <property name="Position">2</property>
             <property name="AutoSize">True</property>
             <property name="Expand">False</property>

+ 0 - 6
tools/gui/resource-browser/CMakeLists.txt

@@ -1,6 +0,0 @@
-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 tools)
-
-install (FILES ui/resource-browser.glade DESTINATION tools/ui)

+ 0 - 134
tools/gui/resource-browser/resource-browser.py

@@ -1,134 +0,0 @@
-#!/usr/bin/python
-
-# 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.
-
-import sys
-import os
-from gi.repository import Gtk
-
-from pycrown import Repository
-
-class ResourceBrowser:
-	def __init__(self, repository):
-		self.m_repository = repository
-
-		builder = Gtk.Builder()
-		builder.add_from_file("ui/resource-browser.glade")
-
-		self.m_filter_entry = builder.get_object("entry1")
-		self.m_list_store = builder.get_object("liststore1")
-
-		self.m_list_view = builder.get_object("treeview1")
-
-		self.m_window = builder.get_object("window1")
-		self.m_window.set_title(repository.root_path())
-
-		renderer = Gtk.CellRendererText()
-		column = Gtk.TreeViewColumn("Name", renderer, text=0)
-		self.m_list_view.append_column(column)
-
-		# Populate list model
-		self.update_list_model()
-
-		self.m_list_filter = self.m_list_store.filter_new()
-		self.m_list_filter.set_visible_func(self.visible_func)
-
-		self.m_list_view.set_model(self.m_list_filter)
-
-		builder.connect_signals(self)
-
-		self.m_window.show_all()
-
-		Gtk.main()
-
-	# Callback
-	def on_delete(self, *args):
-		Gtk.main_quit(*args)
-
-	def update_list_model(self):
-		self.m_repository.scan()
-
-		self.m_list_store.clear()
-
-		for res in self.m_repository.all_resources():
-			self.m_list_store.append([res])
-
-	# Refresh the repository contents
-	def on_update_button_clicked(self, button):
-		self.update_list_model()
-
-	# We call refilter whenever the user types into the filter entry
-	def on_filter_entry_text_changed(self, entry):
-		self.m_list_filter.refilter()
-
-	# The callback used to filter resources in the list view
-	def visible_func(self, model, iter, user_data):
-		name = str(model.get_value(iter, 0))
-
-		# Strip leading and trailing spaces
-		search_text = self.m_filter_entry.get_text().strip()
-
-		# Make the find case-insensitive
-		name = name.lower()
-		search_text = search_text.lower()
-
-		if (search_text == ""):
-			return True
-
-		if (name.find(search_text) == -1):
-			return False
-
-		return True
-
-#------------------------------------------------------------------------------
-def main():
-	root_path = ""
-
-	if (len(sys.argv) != 2):
-		print("Usage: resource-browser <root-path>")
-		sys.exit(-1)
-
-	root_path = sys.argv[1];
-
-	root_path = os.path.abspath(root_path)
-
-	if not os.path.exists(root_path):
-		print("The path does not exist.")
-		sys.exit(-1)
-
-	if (os.path.islink(root_path)):
-		print("The path is a symbolic link.")
-		sys.exit(-1)
-
-	if not os.path.isdir(root_path):
-		print("The path has to be a directory.")
-		sys.exit(-1)
-
-	repository = Repository.Repository(root_path)
-
-	browser = ResourceBrowser(repository)
-
-main()
-

+ 0 - 92
tools/gui/resource-browser/ui/resource-browser.glade

@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
-  <!-- interface-requires gtk+ 3.6 -->
-  <object class="GtkListStore" id="liststore1">
-    <columns>
-      <!-- column-name gchararray1 -->
-      <column type="gchararray"/>
-    </columns>
-  </object>
-  <object class="GtkWindow" id="window1">
-    <property name="can_focus">False</property>
-    <property name="default_width">500</property>
-    <property name="default_height">350</property>
-    <signal name="delete-event" handler="on_delete" swapped="no"/>
-    <child>
-      <object class="GtkBox" id="box1">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <child>
-          <object class="GtkBox" id="box3">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkEntry" id="entry1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">●</property>
-                <property name="invisible_char_set">True</property>
-                <property name="caps_lock_warning">False</property>
-                <property name="primary_icon_name">edit-find-symbolic</property>
-                <property name="secondary_icon_name">edit-clear-symbolic</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="primary_icon_sensitive">False</property>
-                <property name="placeholder_text">Find resource</property>
-                <signal name="changed" handler="on_filter_entry_text_changed" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button3">
-                <property name="label">gtk-refresh</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-                <signal name="clicked" handler="on_update_button_clicked" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow1">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTreeView" id="treeview1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="model">liststore1</property>
-                <property name="search_column">0</property>
-                <child internal-child="selection">
-                  <object class="GtkTreeSelection" id="treeview-selection"/>
-                </child>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
-</interface>