medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 1ba5fcb223da1007a32325663332692aa24c321a
parent bb713e6d84846fb272c3752394df59c4d792c9b8
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Jan 21 23:01:32 +0200

Fix Windows launcher build

Diffstat:
build.bat | 2+-
launcher/main.cc | 4++--
platform_exec.h | 11+++++++++++
unix_exec.h | 10++++++++++
win32_exec.h | 18++++++++++++++++++
5 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/build.bat b/build.bat @@ -38,4 +38,4 @@ @cl main.cc gl.obj glad.obj hm.obj terrain_manager.obj heightmap.obj btt.obj gpubtt.obj lz4.obj skybox.obj http.obj -DSTATIC_GAME %COMMONOBJS% %EXEFLAGS% -Femedfall.exe @cl pp.cc heightmap.obj log.obj stb_image.obj lz4.obj lz4hc.obj memory_arena.obj strlcpy.obj %EXEFLAGS% -@cl launcher\main.cc log.obj http.obj sha2.obj strlcpy.obj Ws2_32.lib -Felauncher.exe %FLAGS% +@cl launcher\main.cc log.obj http.obj sha2.obj gl.obj glad.obj work_queue.obj memory_arena.obj strlcpy.obj glfw3dll.lib imgui.lib Ws2_32.lib -Felauncher.exe %FLAGS% diff --git a/launcher/main.cc b/launcher/main.cc @@ -15,6 +15,7 @@ #include "str.h" #include "sha2.h" #include "strlcpy.h" +#include "platform_exec.h" #include "platform_io.h" #include "platform_network.h" #include "platform_thread.h" @@ -557,8 +558,7 @@ int main() { ImGui::PopStyleColor( 3 ); if( launch ) { - execl( GAME_BINARY, GAME_BINARY, ( char * ) 0 ); - break; + replace_process_with( GAME_BINARY ); } } else if( updater->state == UPDATER_NEED_UPDATE ) { diff --git a/platform_exec.h b/platform_exec.h @@ -0,0 +1,11 @@ +#pragma once + +#include "platform.h" + +#if PLATFORM_WINDOWS +#include "win32_exec.h" +#elif PLATFORM_UNIX +#include "unix_exec.h" +#else +#error new platform +#endif diff --git a/unix_exec.h b/unix_exec.h @@ -0,0 +1,10 @@ +#pragma once + +#include <unistd.h> + +#include "log.h" + +void replace_process_with( const char * path ) { + execl( path, path, ( char * ) 0 ); + FATAL( "execl" ); +} diff --git a/win32_exec.h b/win32_exec.h @@ -0,0 +1,18 @@ +#pragma once + +#include <windows.h> + +#include "log.h" + +void replace_process_with( const char * path ) { + STARTUPINFO startup_info = { }; + startup_info.cb = sizeof( startup_info ); + + PROCESS_INFORMATION process_info = { }; + + if( CreateProcess( path, NULL, 0, 0, FALSE, 0, NULL, NULL, &startup_info, &process_info ) == 0 ) { + FATAL( "CreateProcess" ); + } + + exit( 0 ); +}