medfall

A super great game engine
Log | Files | Refs

commit f30b1e150d61f6f5df1407f97bc30bfb2227e4d4
parent ad0d358a5a7d6d1e6b7357d28e987e5d97897e9f
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue, 31 Oct 2017 00:03:57 +0200

Ask for admin when it's time to update

Diffstat:
elevate_for_update.cc | 2+-
launcher/main.cc | 25++++++++++++++++++++-----
2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/elevate_for_update.cc b/elevate_for_update.cc @@ -3,6 +3,6 @@ #include "win32_exec.h" int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, char * szCmdLine, int iCmdShow ) { - exec_and_quit( "launch.exe", "-startupdate" ); + exec_and_quit( NULL, "launch.exe --start-update" ); return 1; } diff --git a/launcher/main.cc b/launcher/main.cc @@ -285,6 +285,7 @@ enum UpdaterState { UPDATER_NEED_UPDATE, + UPDATER_DOWNLOADING_PRE, UPDATER_DOWNLOADING, UPDATER_INSTALLING, @@ -310,6 +311,7 @@ struct Updater { #define DOWNLOAD_THREADS 16 static Locked< Updater > locked_updater; static WorkQueue download_queue; +static bool autostart_update = false; #define HOST "medfall.mikejsavage.co.uk" @@ -415,7 +417,12 @@ static WORK_QUEUE_CALLBACK( download_manifest ) { updater->game_size += kv.second.file_size; } - updater->state = UPDATER_NEED_UPDATE; + if( autostart_update ) { + updater->state = UPDATER_DOWNLOADING_PRE; + } + else { + updater->state = UPDATER_NEED_UPDATE; + } glfwPostEmptyEvent(); } @@ -621,11 +628,15 @@ static void asdf() { } } -int main() { +int main( int argc, char ** argv ) { logger_init(); logger_thread_name( "main" ); net_init(); + if( argc == 2 && strcmp( argv[ 1 ], "--start-update" ) == 0 ) { + autostart_update = true; + } + static u8 memory[ megabytes( 512 ) ]; MemoryArena arena; memarena_init( &arena, memory, sizeof( memory ) ); @@ -749,13 +760,17 @@ int main() { ImGui::PopStyleColor( 3 ); if( update ) { - updater->state = UPDATER_DOWNLOADING; + exec_and_quit( "elevate_for_update.exe" ); + } + } + else if( updater->state == UPDATER_DOWNLOADING_PRE || updater->state == UPDATER_DOWNLOADING ) { + if( updater->state == UPDATER_DOWNLOADING_PRE ) { for( size_t i = 0; i < updater->files_to_update.size(); i++ ) { workqueue_enqueue( &download_queue, download_file, &updater->files_to_update[ i ] ); } + updater->state = UPDATER_DOWNLOADING; } - } - else if( updater->state == UPDATER_DOWNLOADING ) { + static u64 last_total_downloaded = 0; u64 total_downloaded = 0; bool all_done = true;