Daniele Bartolini 11 年 前
コミット
b4c5bcef52
2 ファイル変更42 行追加44 行削除
  1. 38 37
      engine/main/main_windows.cpp
  2. 4 7
      makefile

+ 38 - 37
engine/main/main_windows.cpp

@@ -26,24 +26,6 @@
 namespace crown
 {
 
-static bool s_exit = false;
-
-struct MainThreadArgs
-{
-	Filesystem* fs;
-	ConfigSettings* cs;
-};
-
-int32_t func(void* data)
-{
-	MainThreadArgs* args = (MainThreadArgs*)data;
-	crown::init(*args->fs, *args->cs);
-	crown::update();
-	crown::shutdown();
-	s_exit = true;
-	return EXIT_SUCCESS;
-}
-
 static KeyboardButton::Enum win_translate_key(int32_t winkey)
 {
 	switch (winkey)
@@ -131,6 +113,24 @@ static KeyboardButton::Enum win_translate_key(int32_t winkey)
 	}
 }
 
+static bool s_exit = false;
+
+struct MainThreadArgs
+{
+	Filesystem* fs;
+	ConfigSettings* cs;
+};
+
+int32_t func(void* data)
+{
+	MainThreadArgs* args = (MainThreadArgs*)data;
+	crown::init(*args->fs, *args->cs);
+	crown::update();
+	crown::shutdown();
+	s_exit = true;
+	return EXIT_SUCCESS;
+}
+
 struct WindowsDevice
 {
 	WindowsDevice()
@@ -154,22 +154,21 @@ struct WindowsDevice
 		wnd.hIconSm = LoadIcon(instance, IDI_APPLICATION);
 		RegisterClassExA(&wnd);
 
-		_hwnd = CreateWindowA(
-					"crown",
-					"Crown",
-					WS_OVERLAPPEDWINDOW|WS_VISIBLE,
-					0,
-					0,
-					cs->window_width,
-					cs->window_height,
-					0,
-					NULL,
-					instance,
-					0);
+		_hwnd = CreateWindowA("crown"
+			, "Crown"
+			, WS_OVERLAPPEDWINDOW | WS_VISIBLE
+			, 0
+			, 0
+			, cs->window_width
+			, cs->window_height
+			, 0
+			, NULL
+			, instance
+			, 0);
+		CE_ASSERT(_hwnd != NULL, "CreateWindowA: GetLastError = %d", GetLastError());
 
 		bgfx::winSetHwnd(_hwnd);
 
-		// Start main thread
 		MainThreadArgs mta;
 		mta.fs = fs;
 		mta.cs = cs;
@@ -205,8 +204,9 @@ struct WindowsDevice
 			case WM_QUIT:
 			case WM_CLOSE:
 			{
+				s_exit = true;
 				_queue.push_exit_event(0);
-				break;
+				return 0;
 			}
 			case WM_SIZE:
 			{
@@ -298,6 +298,7 @@ struct WindowsDevice
 			default:
 				break;
 		}
+
 		return DefWindowProc(hwnd, id, wparam, lparam);
 	}
 
@@ -329,11 +330,11 @@ int main(int argc, char** argv)
 {
 	using namespace crown;
 
-	WSADATA WsaData;
-	int res = WSAStartup(MAKEWORD(2, 2), &WsaData);
-	CE_ASSERT(res == 0, "Unable to initialize socket");
-	CE_UNUSED(WsaData);
-	CE_UNUSED(res);
+	WSADATA dummy;
+	int err = WSAStartup(MAKEWORD(2, 2), &dummy);
+	CE_ASSERT(err == 0, "WSAStartup: error = %d", err);
+	CE_UNUSED(dummy);
+	CE_UNUSED(err);
 
 	ConfigSettings cs;
 	parse_command_line(argc, argv, cs);

+ 4 - 7
makefile

@@ -25,8 +25,6 @@ luajit-arm:
 	CROSS=$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi- \
 	TARGET_FLAGS="--sysroot $(ANDROID_NDK_ROOT)/platforms/android-14/arch-arm \
 		-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8"
-luajit-clean:
-	make -R -C third/luajit clean
 
 bgfx-linux-debug32:
 	make -R -C third/bgfx linux-debug32
@@ -52,8 +50,6 @@ bgfx-android-arm-debug:
 	make -R -C third/bgfx android-arm-debug
 bgfx-android-arm-release:
 	make -R -C third/bgfx android-arm-release
-bgfx-clean:
-	make -R -C third/bgfx clean
 
 deps-linux-debug32: luajit-linux32 bgfx-linux-debug32
 deps-linux-debug64: luajit-linux64 bgfx-linux-debug64
@@ -65,7 +61,6 @@ deps-windows-release32: luajit-windows32 bgfx-vs2013-release32
 deps-windows-release64: luajit-windows64 bgfx-vs2013-release64
 deps-android-arm-debug: luajit-arm bgfx-android-arm-debug
 deps-android-arm-release: luajit-arm bgfx-android-arm-release
-deps-clean: luajit-clean bgfx-clean
 
 linux-build:
 	$(GENIE) --file=genie/genie.lua --with-openal --compiler=linux-gcc gmake
@@ -113,6 +108,8 @@ docs:
 	doxygen docs/Doxyfile.doxygen
 	rst2html2 --stylesheet=html4css1.css,docs/style.css docs/lua_api.txt .build/docs/lua_api.html
 
-clean: deps-clean
+clean:
 	@echo Cleaning...
-	@rm -rf .build
+	-@rm -rf .build
+	-@rm -rf third/bgfx/.build
+	make -R -C third/luajit clean