From: Holger Schemel Date: Mon, 20 Apr 2020 21:12:06 +0000 (+0200) Subject: moved flag for mouse click events from level to game structure X-Git-Tag: 4.2.0.0~48 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f681967164edaa7709d1082327fa7c309e05fd87;p=rocksndiamonds.git moved flag for mouse click events from level to game structure Without this change, click events for newly built levels that are started from the level editor, but that are not yet saved, are not recognized and not handled (because the corresponding flag was set only when loading a level). --- diff --git a/src/events.c b/src/events.c index 2b553720..2f5589fe 100644 --- a/src/events.c +++ b/src/events.c @@ -1375,7 +1375,7 @@ static void HandleButtonOrFinger(int mx, int my, int button) { if (strEqual(setup.touch.control_type, TOUCH_CONTROL_FOLLOW_FINGER)) HandleButtonOrFinger_FollowFinger(mx, my, button); - else if (level.has_mouse_events && valid_mouse_event) + else if (game.use_mouse_events && valid_mouse_event) SetPlayerMouseAction(mx, my, button); } } diff --git a/src/files.c b/src/files.c index fa807e8f..54835e28 100644 --- a/src/files.c +++ b/src/files.c @@ -1733,9 +1733,6 @@ static void setLevelInfoToDefaults_Level(struct LevelInfo *level) // set all bug compatibility flags to "false" => do not emulate this bug level->use_action_after_change_bug = FALSE; - // other flags that may be set due to certain level properties - level->has_mouse_events = FALSE; - if (leveldir_current) { // try to determine better author name than 'anonymous' @@ -6564,18 +6561,6 @@ static void LoadLevel_InitCustomElements(struct LevelInfo *level) element_info[element].ignition_delay = 8; } } - - // check for custom elements which have mouse click events defined - for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++) - { - int element = EL_CUSTOM_START + i; - - if (HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) || - HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) || - HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) || - HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X)) - level->has_mouse_events = TRUE; - } } static void LoadLevel_InitElements(struct LevelInfo *level) diff --git a/src/game.c b/src/game.c index d73efcfb..5d9e473b 100644 --- a/src/game.c +++ b/src/game.c @@ -3279,6 +3279,23 @@ static void InitGameEngine(void) // Supaplex levels with time limit currently unsupported -- should be added if (level.game_engine_type == GAME_ENGINE_TYPE_SP) level.time = 0; + + // ----------initialize flag for handling mouse events --------------------- + + // set flag to default value: do not handle mouse events + game.use_mouse_events = FALSE; + + // now check for custom elements which have mouse click events defined + for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++) + { + int element = EL_CUSTOM_START + i; + + if (HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) || + HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) || + HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) || + HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X)) + game.use_mouse_events = TRUE; + } } static int get_num_special_action(int element, int action_first, diff --git a/src/game.h b/src/game.h index 94b96855..74625440 100644 --- a/src/game.h +++ b/src/game.h @@ -178,6 +178,9 @@ struct GameInfo boolean max_num_changes_per_frame; boolean use_reverse_scan_direction; + // flag to indicate if mouse events are processed by game engine + boolean use_mouse_events; + // variable within running game int yamyam_content_nr; boolean robot_wheel_active; diff --git a/src/main.h b/src/main.h index 75ed2ee8..4fd367c7 100644 --- a/src/main.h +++ b/src/main.h @@ -3195,9 +3195,6 @@ struct LevelInfo // runtime flags to handle bugs in old levels (not stored in level file) boolean use_action_after_change_bug; - - // runtime flags to indicate level properties (not stored in level file) - boolean has_mouse_events; }; struct NetworkLevelInfo