From dcb3da53b014761b233296a032cf96e87bd651f7 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 22 Oct 2023 19:49:33 +0700 Subject: [PATCH] engine/client: fallback to defaults in touch_reloadconfig if config not exist --- engine/client/in_touch.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/engine/client/in_touch.c b/engine/client/in_touch.c index 93fdfebb..a2ed8163 100644 --- a/engine/client/in_touch.c +++ b/engine/client/in_touch.c @@ -760,6 +760,8 @@ static void Touch_SetCommand_f( void ) Con_Printf( S_USAGE "touch_setcommand \n" ); } +static void Touch_LoadDefaults_f( void ); + static void Touch_ReloadConfig_f( void ) { touch.state = state_none; @@ -769,8 +771,15 @@ static void Touch_ReloadConfig_f( void ) touch.selection->finger = -1; touch.edit = touch.selection = NULL; touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1; - - Cbuf_AddTextf( "exec %s\n", touch_config_file.string ); + if( FS_FileExists( touch_config_file.string, true ) ) + { + Cbuf_AddTextf( "exec \"%s\"\n", touch_config_file.string ); + } + else + { + Touch_LoadDefaults_f(); + touch.configchanged = true; + } } static touch_button_t *Touch_AddButton( touchbuttonlist_t *list,