Skip to content

Commit

Permalink
Prevent top DOS shell from being exitted with exit by default
Browse files Browse the repository at this point in the history
Exitting can still be enabled with the core option that allows the core to auto shut down
  • Loading branch information
schellingb committed Dec 28, 2024
1 parent a6acc12 commit 5392d93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dosbox_pure_libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,11 @@ bool DBP_IsLowLatency()
return dbp_latency == DBP_LATENCY_LOW;
}

bool DBP_WantAutoShutDown()
{
return (dbp_menu_time >= 0 && dbp_menu_time < 99);
}

void DBP_EnableNetwork()
{
if (dbp_use_network) return;
Expand Down Expand Up @@ -3750,11 +3755,11 @@ void retro_get_system_av_info(struct retro_system_av_info *info) // #5
DBP_ThreadControl(TCM_FINISH_FRAME);
if (dbp_biosreboot || dbp_state == DBPSTATE_EXITED)
{
// A reboot can happen during the first frame if puremenu wants to change DOSBox machine config
DBP_ASSERT(dbp_state == DBPSTATE_EXITED && (dbp_biosreboot || dbp_crash_message.size()));
// A reboot can happen during the first frame if puremenu wants to change DOSBox machine config or if autoexec via dosbox.conf ran 'exit'
DBP_ASSERT(dbp_state == DBPSTATE_EXITED && (dbp_biosreboot || dbp_crash_message.size() || (control && !dbp_game_running)));
DBP_ForceReset();
DBP_ThreadControl(TCM_FINISH_FRAME);
DBP_ASSERT((!dbp_biosreboot && dbp_state == DBPSTATE_FIRST_FRAME) || dbp_crash_message.size());
DBP_ASSERT((!dbp_biosreboot && dbp_state == DBPSTATE_FIRST_FRAME) || dbp_crash_message.size() || (control && !dbp_game_running));
}
DBP_ASSERT(render.src.fps > 10.0); // validate initialized video mode after first frame
const DBP_Buffer& buf = dbp_buffers[buffer_active];
Expand Down
8 changes: 8 additions & 0 deletions src/shell/shell_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,15 @@ void DOS_Shell::CMD_ECHO(char * args){

void DOS_Shell::CMD_EXIT(char * args) {
HELP("EXIT");
#ifndef C_DBP_LIBRETRO // prevent exiting the first shell
exit = true;
#else
extern bool DBP_WantAutoShutDown();
if (this != first_shell || DBP_WantAutoShutDown())
exit = true;
else
WriteOut("\nUnable to exit top DOS shell\n\nChange the core option 'Emulation' -> 'Start Menu' to\n'shut down core .. after .. exit' to enable shutting\ndown of the core with the exit command.\n\n");
#endif
}

void DOS_Shell::CMD_CHDIR(char * args) {
Expand Down

0 comments on commit 5392d93

Please sign in to comment.