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

Add support to run with network filesystem

Daniele Bartolini 12 лет назад
Родитель
Сommit
cbd4b8e688
5 измененных файлов с 62 добавлено и 16 удалено
  1. 21 6
      engine/Device.cpp
  2. 2 0
      engine/Device.h
  3. 9 0
      engine/os/android/AndroidDevice.cpp
  4. 15 5
      engine/os/linux/main.cpp
  5. 15 5
      engine/os/win/main.cpp

+ 21 - 6
engine/Device.cpp

@@ -56,6 +56,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "World.h"
 #include "LuaStack.h"
 #include "WorldManager.h"
+#include "NetworkFilesystem.h"
 
 #if defined(LINUX) || defined(WINDOWS)
 	#include "BundleCompiler.h"
@@ -76,6 +77,9 @@ Device::Device()
 	, m_argc(0)
 	, m_argv(NULL)
 
+	, m_fileserver(0)
+	, m_console_port(10001)
+
 	, m_is_init(false)
 	, m_is_running(false)
 	, m_is_paused(false)
@@ -122,15 +126,29 @@ void Device::init()
 
 	// RPC only in debug or development builds
 	#if defined(CROWN_DEBUG) || defined(CROWN_DEVELOPMENT)
-		m_console = CE_NEW(m_allocator, ConsoleServer);
+		m_console = CE_NEW(m_allocator, ConsoleServer)(m_console_port);
 		m_console->init(false);
 	#endif
 
 	// Default bundle filesystem
 	#if defined (LINUX) || defined(WINDOWS)
-		m_filesystem = CE_NEW(m_allocator, DiskFilesystem)(m_bundle_dir);
+		if (m_fileserver == 1)
+		{
+			m_filesystem = CE_NEW(m_allocator, NetworkFilesystem)(NetAddress(127, 0, 0, 1), 10001);
+		}
+		else
+		{
+			m_filesystem = CE_NEW(m_allocator, DiskFilesystem)(m_bundle_dir);
+		}
 	#elif defined(ANDROID)
-		m_filesystem = CE_NEW(m_allocator, ApkFilesystem)();
+		if (m_fileserver == 1)
+		{
+			m_filesystem = CE_NEW(m_allocator, NetworkFilesystem)(NetAddress(192, 168, 0, 7), 10001);
+		}
+		else
+		{
+			m_filesystem = CE_NEW(m_allocator, ApkFilesystem)();
+		}
 	#endif
 	Log::d("Filesystem created.");
 
@@ -254,7 +272,6 @@ void Device::shutdown()
 	}
 
 	#if defined(CROWN_DEBUG) || defined(CROWN_DEVELOPMENT)
-		m_console->process_requests();
 		m_console->shutdown();
 		CE_DELETE(m_allocator, m_console);
 		m_console = NULL;
@@ -414,8 +431,6 @@ void Device::frame()
 		m_sound_renderer->frame();
 	}
 
-	m_console->process_requests();
-
 	clear_lua_temporaries();
 
 	m_frame_count++;

+ 2 - 0
engine/Device.h

@@ -167,6 +167,8 @@ protected:
 	char					m_source_dir[MAX_PATH_LENGTH];
 	char 					m_bundle_dir[MAX_PATH_LENGTH];
 	char 					m_boot_file[MAX_PATH_LENGTH];
+	int32_t					m_fileserver;
+	uint16_t				m_console_port;
 
 	bool					m_is_init		: 1;
 	bool					m_is_running	: 1;

+ 9 - 0
engine/os/android/AndroidDevice.cpp

@@ -40,6 +40,15 @@ class AndroidDevice : public Device
 {
 public:
 
+	//-----------------------------------------------------------------------------
+	AndroidDevice()
+	{
+		#if defined(CROWN_DEBUG) || defined(CROWN_DEVELOPMENT)
+			m_fileserver = 1;
+		#endif
+	}
+
+	//-----------------------------------------------------------------------------
 	int32_t run(int, char**)
 	{
 		process_events();

+ 15 - 5
engine/os/linux/main.cpp

@@ -478,8 +478,10 @@ public:
 			"\nAvailable only in debug and development builds:\n\n"
 
 			"  --source-dir <path>        Use <path> as the source directory for resource compilation.\n"
-			"  --compile                  Run the engine as resource compiler.\n"
-			"  --continue                 Do a full compile of the resources and continue the execution.\n";
+			"  --compile                  Do a full compile of the resources.\n"
+			"  --continue                 Continue the execution after the resource compilation step.\n"
+			"  --file-server              Read resources from a remote engine instance.\n"
+			"  --console-port             Set the network port of the console server.\n";
 
 		static ArgsOption options[] = 
 		{
@@ -492,6 +494,8 @@ public:
 			{ "height",           AOA_REQUIRED_ARGUMENT, NULL,        'h' },
 			{ "fullscreen",       AOA_NO_ARGUMENT,       &m_fullscreen, 1 },
 			{ "parent-window",    AOA_REQUIRED_ARGUMENT, NULL,        'p' },
+			{ "file-server",      AOA_NO_ARGUMENT,       &m_fileserver, 1 },
+			{ "console-port",     AOA_REQUIRED_ARGUMENT, NULL,        'c' },
 			{ NULL, 0, NULL, 0 }
 		};
 
@@ -536,6 +540,12 @@ public:
 					m_parent_window_handle = string::parse_uint(args.optarg());
 					break;
 				}
+				// Console port
+				case 'c':
+				{
+					m_console_port = string::parse_uint(args.optarg());
+					break;
+				}
 				case 'i':
 				case '?':
 				default:
@@ -600,10 +610,10 @@ public:
 		// Boot
 		if (root.has_key("boot"))
 		{
-			const char* boot = root.key("boot").string_value();
-			const size_t boot_length = string::strlen(boot);
+			DynamicString boot;
+			root.key("boot").string_value(boot);
 
-			string::strncpy(m_boot_file, boot, (boot_length > MAX_PATH_LENGTH) ? MAX_PATH_LENGTH : boot_length + 1);
+			string::strncpy(m_boot_file, boot.c_str(), (boot.length() > MAX_PATH_LENGTH) ? MAX_PATH_LENGTH : boot.length() + 1);
 		}
 
 		// Window width

+ 15 - 5
engine/os/win/main.cpp

@@ -706,8 +706,10 @@ public:
 			"\nAvailable only in debug and development builds:\n\n"
 
 			"  --source-dir <path>        Use <path> as the source directory for resource compilation.\n"
-			"  --compile                  Run the engine as resource compiler.\n"
-			"  --continue                 Do a full compile of the resources and continue the execution.\n";
+			"  --compile                  Do a full compile of the resources.\n"
+			"  --continue                 Continue the execution after the resource compilation step.\n"
+			"  --file-server              Read resources from a remote engine instance.\n"
+			"  --console-port             Set the network port of the console server.\n";
 
 		static ArgsOption options[] = 
 		{
@@ -720,6 +722,8 @@ public:
 			{ "height",           AOA_REQUIRED_ARGUMENT, NULL,        'h' },
 			{ "fullscreen",       AOA_NO_ARGUMENT,       &m_fullscreen, 1 },
 			{ "parent-window",    AOA_REQUIRED_ARGUMENT, NULL,        'p' },
+			{ "file-server",      AOA_NO_ARGUMENT,       &m_fileserver, 1 },
+			{ "console-port",     AOA_REQUIRED_ARGUMENT, NULL,        'c' },
 			{ NULL, 0, NULL, 0 }
 		};
 
@@ -764,6 +768,12 @@ public:
 					m_parent_window_handle = string::parse_uint(args.optarg());
 					break;
 				}
+				// Console port
+				case 'c':
+				{
+					m_console_port = string::parse_uint(args.optarg());
+					break;
+				}
 				case 'i':
 				case '?':
 				default:
@@ -828,10 +838,10 @@ public:
 		// Boot
 		if (root.has_key("boot"))
 		{
-			const char* boot = root.key("boot").string_value();
-			const size_t boot_length = string::strlen(boot);
+			DynamicString boot;
+			root.key("boot").string_value(boot);
 
-			string::strncpy(m_boot_file, boot, (boot_length > MAX_PATH_LENGTH) ? MAX_PATH_LENGTH : boot_length + 1);
+			string::strncpy(m_boot_file, boot, (boot.length() > MAX_PATH_LENGTH) ? MAX_PATH_LENGTH : boot.length() + 1);
 		}
 
 		// Window width