X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=96b3ca1ad6ea9388480a65c67d5152605c233725;hb=130737058201069bf104d946d48ffd6a05693873;hp=b8383b115ea588318b9140be09c719d4b59bd3b6;hpb=4a1cf573aae3a92b4ca910482d425e8b789b32eb;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index b8383b11..96b3ca1a 100644 --- a/src/game.c +++ b/src/game.c @@ -3330,6 +3330,14 @@ void InitGame() player->effective_action = 0; player->programmed_action = 0; + player->mouse_action.lx = 0; + player->mouse_action.ly = 0; + player->mouse_action.button = 0; + + player->effective_mouse_action.lx = 0; + player->effective_mouse_action.ly = 0; + player->effective_mouse_action.button = 0; + player->score = 0; player->score_final = 0; @@ -4120,9 +4128,6 @@ void InitGame() FadeIn(fade_mask); - if (level.game_engine_type == GAME_ENGINE_TYPE_MM) - InitGameEngine_MM_AfterFadingIn(); - #if 1 // full screen redraw is required at this point in the following cases: // - special editor door undrawn when game was started from level editor @@ -4211,6 +4216,9 @@ void InitGame() game.restart_level = FALSE; + if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + InitGameActions_MM(); + SaveEngineSnapshotToListInitial(); } @@ -10970,6 +10978,28 @@ static byte PlayerActions(struct PlayerInfo *player, byte player_action) } } +static void SetMouseActionFromTapeAction(struct MouseActionInfo *mouse_action, + byte *tape_action) +{ + if (!tape.use_mouse) + return; + + mouse_action->lx = tape_action[TAPE_ACTION_LX]; + mouse_action->ly = tape_action[TAPE_ACTION_LY]; + mouse_action->button = tape_action[TAPE_ACTION_BUTTON]; +} + +static void SetTapeActionFromMouseAction(byte *tape_action, + struct MouseActionInfo *mouse_action) +{ + if (!tape.use_mouse) + return; + + tape_action[TAPE_ACTION_LX] = mouse_action->lx; + tape_action[TAPE_ACTION_LY] = mouse_action->ly; + tape_action[TAPE_ACTION_BUTTON] = mouse_action->button; +} + static void CheckLevelTime() { int i; @@ -11297,6 +11327,12 @@ void GameActionsExt() /* when playing tape, read previously recorded player input from tape data */ recorded_player_action = (tape.playing ? TapePlayAction() : NULL); + local_player->effective_mouse_action = local_player->mouse_action; + + if (recorded_player_action != NULL) + SetMouseActionFromTapeAction(&local_player->effective_mouse_action, + recorded_player_action); + /* TapePlayAction() may return NULL when toggling to "pause before death" */ if (tape.pausing) return; @@ -11353,6 +11389,9 @@ void GameActionsExt() tape.player_participates[i] = TRUE; } + SetTapeActionFromMouseAction(tape_action, + &local_player->effective_mouse_action); + /* only record actions from input devices, but not programmed actions */ if (tape.recording) TapeRecordAction(tape_action); @@ -11509,14 +11548,9 @@ void GameActions_SP_Main() void GameActions_MM_Main() { - byte effective_action[MAX_PLAYERS]; boolean warp_mode = (tape.playing && tape.warp_forward && !tape.pausing); - int i; - - for (i = 0; i < MAX_PLAYERS; i++) - effective_action[i] = stored_player[i].effective_action; - GameActions_MM(effective_action, warp_mode); + GameActions_MM(local_player->effective_mouse_action, warp_mode); } void GameActions_RND_Main() @@ -14674,6 +14708,50 @@ void PlayLevelSound_SP(int xx, int yy, int element_sp, int action_sp) PlayLevelSoundElementAction(x, y, element, action); } +void PlayLevelSound_MM(int xx, int yy, int element_mm, int action_mm) +{ + int element = map_element_MM_to_RND(element_mm); + int action = map_action_MM_to_RND(action_mm); + int offset = 0; + int x = xx - offset; + int y = yy - offset; + + if (!IS_MM_ELEMENT(element)) + element = EL_MM_DEFAULT; + + PlayLevelSoundElementAction(x, y, element, action); +} + +void PlaySound_MM(int sound_mm) +{ + int sound = map_sound_MM_to_RND(sound_mm); + + if (sound == SND_UNDEFINED) + return; + + PlaySound(sound); +} + +void PlaySoundLoop_MM(int sound_mm) +{ + int sound = map_sound_MM_to_RND(sound_mm); + + if (sound == SND_UNDEFINED) + return; + + PlaySoundLoop(sound); +} + +void StopSound_MM(int sound_mm) +{ + int sound = map_sound_MM_to_RND(sound_mm); + + if (sound == SND_UNDEFINED) + return; + + StopSound(sound); +} + void RaiseScore(int value) { local_player->score += value;