diff options
author | 2010-01-06 17:30:05 +0000 | |
---|---|---|
committer | 2010-01-06 17:30:05 +0000 | |
commit | 8d88859471049f491531a52b01d60670dd864b99 (patch) | |
tree | db4ddb77774149f9aa850a400ac38324f2c076e8 | |
parent | 49b2d89ab2d259088260d40f64f3b4e0b1ce05f7 (diff) |
moved the fix for the crash when you toggle cheats inside cheat.c, to avoid duplicating the checks and looking up whether cheats are enabled.
-rw-r--r-- | src/emu/cheat.c | 47 | ||||
-rw-r--r-- | src/emu/ui.c | 4 | ||||
-rw-r--r-- | src/emu/uimenu.c | 4 |
3 files changed, 32 insertions, 23 deletions
diff --git a/src/emu/cheat.c b/src/emu/cheat.c index 6a9fc27df0c..d3698a0e504 100644 --- a/src/emu/cheat.c +++ b/src/emu/cheat.c @@ -455,7 +455,13 @@ static void cheat_exit(running_machine *machine) int cheat_get_global_enable(running_machine *machine) { cheat_private *cheatinfo = machine->cheat_data; - return !cheatinfo->disabled; + + if (cheatinfo != NULL) + { + return !cheatinfo->disabled; + } + + return 0; } @@ -469,26 +475,29 @@ void cheat_set_global_enable(running_machine *machine, int enable) cheat_private *cheatinfo = machine->cheat_data; cheat_entry *cheat; - /* if we're enabled currently and we don't want to be, turn things off */ - if (!cheatinfo->disabled && !enable) + if (cheatinfo != NULL) { - /* iterate over running cheats and execute any OFF Scripts */ - for (cheat = cheatinfo->cheatlist; cheat != NULL; cheat = cheat->next) - if (cheat->state == SCRIPT_STATE_RUN) - cheat_execute_script(cheatinfo, cheat, SCRIPT_STATE_OFF); - popmessage("Cheats Disabled"); - cheatinfo->disabled = TRUE; - } + /* if we're enabled currently and we don't want to be, turn things off */ + if (!cheatinfo->disabled && !enable) + { + /* iterate over running cheats and execute any OFF Scripts */ + for (cheat = cheatinfo->cheatlist; cheat != NULL; cheat = cheat->next) + if (cheat->state == SCRIPT_STATE_RUN) + cheat_execute_script(cheatinfo, cheat, SCRIPT_STATE_OFF); + popmessage("Cheats Disabled"); + cheatinfo->disabled = TRUE; + } - /* if we're disabled currently and we want to be enabled, turn things on */ - else if (cheatinfo->disabled && enable) - { - /* iterate over running cheats and execute any ON Scripts */ - cheatinfo->disabled = FALSE; - for (cheat = cheatinfo->cheatlist; cheat != NULL; cheat = cheat->next) - if (cheat->state == SCRIPT_STATE_RUN) - cheat_execute_script(cheatinfo, cheat, SCRIPT_STATE_ON); - popmessage("Cheats Enabled"); + /* if we're disabled currently and we want to be enabled, turn things on */ + else if (cheatinfo->disabled && enable) + { + /* iterate over running cheats and execute any ON Scripts */ + cheatinfo->disabled = FALSE; + for (cheat = cheatinfo->cheatlist; cheat != NULL; cheat = cheat->next) + if (cheat->state == SCRIPT_STATE_RUN) + cheat_execute_script(cheatinfo, cheat, SCRIPT_STATE_ON); + popmessage("Cheats Enabled"); + } } } diff --git a/src/emu/ui.c b/src/emu/ui.c index 5787f9ffeb6..04daa3c9c21 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -1238,8 +1238,8 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state) mame_pause(machine, !mame_is_paused(machine)); } - /* handle a toggle cheats request, but only if cheats are on */ - if (options_get_bool(mame_options(), OPTION_CHEAT) && ui_input_pressed(machine, IPT_UI_TOGGLE_CHEAT)) + /* handle a toggle cheats request */ + if (ui_input_pressed(machine, IPT_UI_TOGGLE_CHEAT)) cheat_set_global_enable(machine, !cheat_get_global_enable(machine)); /* toggle movie recording */ diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c index 8559761ff21..3818aee4da5 100644 --- a/src/emu/uimenu.c +++ b/src/emu/uimenu.c @@ -1221,8 +1221,8 @@ static void ui_menu_handle_keys(ui_menu *menu, UINT32 flags) if (!ignorepause && exclusive_input_pressed(menu, IPT_UI_PAUSE, 0)) mame_pause(menu->machine, !mame_is_paused(menu->machine)); - /* handle a toggle cheats request, but only if cheats are on */ - if (options_get_bool(mame_options(), OPTION_CHEAT) && ui_input_pressed_repeat(menu->machine, IPT_UI_TOGGLE_CHEAT, 0)) + /* handle a toggle cheats request */ + if (ui_input_pressed_repeat(menu->machine, IPT_UI_TOGGLE_CHEAT, 0)) cheat_set_global_enable(menu->machine, !cheat_get_global_enable(menu->machine)); /* see if any other UI keys are pressed */ |