X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=533119c92b368df93d484018f33fd3d2b35a7b42;hb=7b47ce7ba0f673f0de5130daf5726104d0b38902;hp=ea346bfd599ddbd287013bf79259c1aa7517bfcd;hpb=4be46f1030df4cb7db0ce7c46d2518334861731a;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index ea346bfd..533119c9 100644 --- a/src/game.c +++ b/src/game.c @@ -105,61 +105,18 @@ static void CloseAllOpenTimegates(void); static void CheckGravityMovement(struct PlayerInfo *); static void KillHeroUnlessProtected(int, int); -void PlaySoundLevel(int, int, int); -void PlaySoundLevelAction(int, int, int); -void PlaySoundLevelElementAction(int, int, int, int); +static void PlaySoundLevel(int, int, int); +static void PlaySoundLevelNearest(int, int, int); +static void PlaySoundLevelAction(int, int, int); +static void PlaySoundLevelElementAction(int, int, int, int); static void MapGameButtons(); static void HandleGameButtons(struct GadgetInfo *); static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; - -/* ------------------------------------------------------------------------- */ -/* sound definitions */ -/* ------------------------------------------------------------------------- */ - -#define SND_ACTION_UNKNOWN 0 -#define SND_ACTION_WAITING 1 -#define SND_ACTION_MOVING 2 -#define SND_ACTION_DIGGING 3 -#define SND_ACTION_COLLECTING 4 -#define SND_ACTION_PASSING 5 -#define SND_ACTION_IMPACT 6 -#define SND_ACTION_PUSHING 7 -#define SND_ACTION_ACTIVATING 8 -#define SND_ACTION_ACTIVE 9 - -#define NUM_SND_ACTIONS 10 - -static struct -{ - char *text; - int value; - boolean is_loop; -} sound_action_properties[] = -{ - /* insert _all_ loop sound actions here */ - { ".waiting", SND_ACTION_WAITING, TRUE }, - { ".moving", SND_ACTION_MOVING, TRUE }, /* continuos moving */ - { ".active", SND_ACTION_ACTIVE, TRUE }, - { ".growing", SND_ACTION_UNKNOWN, TRUE }, - { ".attacking", SND_ACTION_UNKNOWN, TRUE }, - - /* other (non-loop) sound actions are optional */ - { ".stepping", SND_ACTION_MOVING, FALSE }, /* discrete moving */ - { ".digging", SND_ACTION_DIGGING, FALSE }, - { ".collecting", SND_ACTION_COLLECTING, FALSE }, - { ".passing", SND_ACTION_PASSING, FALSE }, - { ".impact", SND_ACTION_IMPACT, FALSE }, - { ".pushing", SND_ACTION_PUSHING, FALSE }, - { ".activating", SND_ACTION_ACTIVATING, FALSE }, - { NULL, 0, 0 }, -}; -static int element_action_sound[MAX_NUM_ELEMENTS][NUM_SND_ACTIONS]; -static boolean is_loop_sound[NUM_SOUND_FILES]; - -#define IS_LOOP_SOUND(x) (is_loop_sound[x]) +#define IS_ANIMATED(g) (graphic_info[g].anim_frames > 1) +#define IS_LOOP_SOUND(s) (sound_info[s].loop) /* ------------------------------------------------------------------------- @@ -167,6 +124,21 @@ static boolean is_loop_sound[NUM_SOUND_FILES]; a specified time, eventually calling a function when changing ------------------------------------------------------------------------- */ +/* forward declaration for changer functions */ +static void InitBuggyBase(int x, int y); +static void WarnBuggyBase(int x, int y); + +static void InitTrap(int x, int y); +static void ActivateTrap(int x, int y); +static void ChangeActiveTrap(int x, int y); + +static void InitRobotWheel(int x, int y); +static void RunRobotWheel(int x, int y); +static void StopRobotWheel(int x, int y); + +static void InitTimegateWheel(int x, int y); +static void RunTimegateWheel(int x, int y); + struct ChangingElementInfo { int base_element; @@ -182,11 +154,31 @@ static struct ChangingElementInfo changing_element_list[] = { EL_NUT_CRACKING, EL_EMERALD, 6, NULL, NULL, NULL }, { EL_PEARL_BREAKING, EL_EMPTY, 8, NULL, NULL, NULL }, { EL_EXIT_OPENING, EL_EXIT_OPEN, 29, NULL, NULL, NULL }, + { EL_SWITCHGATE_OPENING, EL_SWITCHGATE_OPEN, 29, NULL, NULL, NULL }, { EL_SWITCHGATE_CLOSING, EL_SWITCHGATE_CLOSED, 29, NULL, NULL, NULL }, + { EL_TIMEGATE_OPENING, EL_TIMEGATE_OPEN, 29, NULL, NULL, NULL }, { EL_TIMEGATE_CLOSING, EL_TIMEGATE_CLOSED, 29, NULL, NULL, NULL }, + { EL_SP_BUGGY_BASE, EL_SP_BUGGY_BASE_ACTIVATING, 0, + InitBuggyBase, NULL, NULL }, + { EL_SP_BUGGY_BASE_ACTIVATING,EL_SP_BUGGY_BASE_ACTIVE, 0, + InitBuggyBase, NULL, NULL }, + { EL_SP_BUGGY_BASE_ACTIVE, EL_SP_BUGGY_BASE, 0, + InitBuggyBase, WarnBuggyBase, NULL }, + + { EL_TRAP, EL_TRAP_ACTIVE, 0, + InitTrap, NULL, ActivateTrap }, + { EL_TRAP_ACTIVE, EL_TRAP, 31, + NULL, ChangeActiveTrap, NULL }, + + { EL_ROBOT_WHEEL_ACTIVE, EL_ROBOT_WHEEL, 0, + InitRobotWheel, RunRobotWheel, StopRobotWheel }, + + { EL_TIMEGATE_SWITCH_ACTIVE, EL_TIMEGATE_SWITCH, 0, + InitTimegateWheel, RunTimegateWheel, NULL }, + { EL_UNDEFINED, EL_UNDEFINED, -1, NULL } }; @@ -540,97 +532,6 @@ void DrawGameDoorValues() } -/* - ============================================================================= - InitGameSound() - ----------------------------------------------------------------------------- - initialize sound effect lookup table for element actions - ============================================================================= -*/ - -void InitGameSound() -{ - int sound_effect_properties[NUM_SOUND_FILES]; - int i, j; - -#if 0 - debug_print_timestamp(0, NULL); -#endif - - /* initialize sound effect for all elements to "no sound" */ - for (i=0; i %d: %d [%d]\n", graphic, frame, MovDelay[x][y]); - */ + frame = getGraphicAnimationFrame(graphic, GfxFrame[x][y]); if (game.emulation == EMU_SUPAPLEX) - DrawGraphic(sx, sy, IMG_SP_DISK_RED, 0); + DrawGraphic(sx, sy, IMG_SP_DISK_RED, frame); else if (Store[x][y]) DrawGraphicThruMask(sx, sy, graphic, frame); else @@ -1563,21 +1460,18 @@ void DrawDynamite(int x, int y) void CheckDynamite(int x, int y) { - if (MovDelay[x][y]) /* dynamite is still waiting to explode */ + int element = Feld[x][y]; + + if (MovDelay[x][y] != 0) /* dynamite is still waiting to explode */ { MovDelay[x][y]--; - if (MovDelay[x][y]) - { - if (!(MovDelay[x][y] % 6)) - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); - if (IS_ACTIVE_BOMB(Feld[x][y])) - { - int delay = (Feld[x][y] == EL_DYNAMITE_ACTIVE ? 12 : 6); + if (MovDelay[x][y] != 0) + { + if (checkDrawLevelGraphicAnimation(x, y, el2img(element))) + DrawDynamite(x, y); - if (!(MovDelay[x][y] % delay)) - DrawDynamite(x, y); - } + PlaySoundLevelAction(x, y, ACTION_ACTIVE); return; } @@ -1987,9 +1881,9 @@ static void InitBeltMovement() int graphic = el2img(element); if (game.belt_dir[i] == MV_LEFT) - new_graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; + graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; else - new_graphic_info[graphic].anim_mode |= ANIM_REVERSE; + graphic_info[graphic].anim_mode |= ANIM_REVERSE; } } @@ -2071,9 +1965,9 @@ static void ToggleBeltSwitch(int x, int y) int graphic = el2img(element); if (belt_dir == MV_LEFT) - new_graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; + graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; else - new_graphic_info[graphic].anim_mode |= ANIM_REVERSE; + graphic_info[graphic].anim_mode |= ANIM_REVERSE; } for (yy=0; yy=0 && ZY>=0) + if (element == EL_ROBOT && ZX >= 0 && ZY >= 0) { attr_x = ZX; attr_y = ZY; @@ -2886,7 +2787,7 @@ void StartMoving(int x, int y) if (Stop[x][y]) return; - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxAction[x][y] = ACTION_DEFAULT; if (CAN_FALL(element) && y < lev_fieldy - 1) { @@ -3081,7 +2982,7 @@ void StartMoving(int x, int y) InitMovingField(x, y, belt_dir); started_moving = TRUE; - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxAction[x][y] = ACTION_DEFAULT; } } } @@ -3209,7 +3110,7 @@ void StartMoving(int x, int y) if (MovDelay[x][y]) /* element still has to wait some time */ { - PlaySoundLevelAction(x, y, SND_ACTION_WAITING); + PlaySoundLevelAction(x, y, ACTION_WAITING); return; } @@ -3429,14 +3330,14 @@ void StartMoving(int x, int y) if (DONT_TOUCH(element)) TestIfBadThingTouchesHero(x, y); - PlaySoundLevelAction(x, y, SND_ACTION_WAITING); + PlaySoundLevelAction(x, y, ACTION_WAITING); return; } InitMovingField(x, y, MovDir[x][y]); - PlaySoundLevelAction(x, y, SND_ACTION_MOVING); + PlaySoundLevelAction(x, y, ACTION_MOVING); } if (MovDir[x][y]) @@ -3560,7 +3461,7 @@ void ContinueMoving(int x, int y) MovDelay[newx][newy] = 0; GfxAction[newx][newy] = GfxAction[x][y]; /* keep action one frame */ - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxAction[x][y] = ACTION_DEFAULT; #if 0 if (!CAN_MOVE(element)) @@ -3598,11 +3499,11 @@ void ContinueMoving(int x, int y) else /* still moving on */ { #if 0 - if (GfxAction[x][y] == GFX_ACTION_DEFAULT) + if (GfxAction[x][y] == ACTION_DEFAULT) { printf("reset GfxAction...\n"); - GfxAction[x][y] = GFX_ACTION_MOVING; + GfxAction[x][y] = ACTION_MOVING; } #endif @@ -4082,6 +3983,23 @@ void Life(int ax, int ay) SND_BIOMAZE_CREATING); } +static void InitRobotWheel(int x, int y) +{ + MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; +} + +static void RunRobotWheel(int x, int y) +{ + PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVE); +} + +static void StopRobotWheel(int x, int y) +{ + if (ZX == x && ZY == y) + ZX = ZY = -1; +} + +#if 1 void RobotWheel(int x, int y) { if (!MovDelay[x][y]) /* next animation frame */ @@ -4111,7 +4029,19 @@ void RobotWheel(int x, int y) if (ZX == x && ZY == y) ZX = ZY = -1; } +#endif +static void InitTimegateWheel(int x, int y) +{ + MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; +} + +static void RunTimegateWheel(int x, int y) +{ + PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); +} + +#if 1 void TimegateWheel(int x, int y) { if (!MovDelay[x][y]) /* next animation frame */ @@ -4138,11 +4068,17 @@ void TimegateWheel(int x, int y) Feld[x][y] = EL_TIMEGATE_SWITCH; DrawLevelField(x, y); + /* THIS HAS NO EFFECT AT ALL! */ +#if 1 /* !!! THIS LOOKS WRONG !!! */ if (ZX == x && ZY == y) ZX = ZY = -1; +#endif + } +#endif +#if 1 void NussKnacken(int x, int y) { if (!MovDelay[x][y]) /* next animation frame */ @@ -4168,7 +4104,9 @@ void NussKnacken(int x, int y) Feld[x][y] = EL_EMERALD; DrawLevelField(x, y); } +#endif +#if 1 void BreakingPearl(int x, int y) { if (!MovDelay[x][y]) /* next animation frame */ @@ -4194,6 +4132,7 @@ void BreakingPearl(int x, int y) Feld[x][y] = EL_EMPTY; DrawLevelField(x, y); } +#endif void SiebAktivieren(int x, int y, int type) { @@ -4202,7 +4141,7 @@ void SiebAktivieren(int x, int y, int type) DrawLevelGraphicAnimation(x, y, graphic); } -void AusgangstuerPruefen(int x, int y) +void CheckExit(int x, int y) { if (local_player->gems_still_needed > 0 || local_player->sokobanfields_still_needed > 0 || @@ -4211,27 +4150,20 @@ void AusgangstuerPruefen(int x, int y) Feld[x][y] = EL_EXIT_OPENING; - PlaySoundLevel(x < LEVELX(BX1) ? LEVELX(BX1) : - (x > LEVELX(BX2) ? LEVELX(BX2) : x), - y < LEVELY(BY1) ? LEVELY(BY1) : - (y > LEVELY(BY2) ? LEVELY(BY2) : y), - SND_EXIT_OPENING); + PlaySoundLevelNearest(x, y, SND_EXIT_OPENING); } -void AusgangstuerPruefen_SP(int x, int y) +void CheckExitSP(int x, int y) { if (local_player->gems_still_needed > 0) return; Feld[x][y] = EL_SP_EXIT_OPEN; - PlaySoundLevel(x < LEVELX(BX1) ? LEVELX(BX1) : - (x > LEVELX(BX2) ? LEVELX(BX2) : x), - y < LEVELY(BY1) ? LEVELY(BY1) : - (y > LEVELY(BY2) ? LEVELY(BY2) : y), - SND_SP_EXIT_OPENING); + PlaySoundLevelNearest(x, y, SND_SP_EXIT_OPENING); } +#if 1 void AusgangstuerOeffnen(int x, int y) { int delay = 6; @@ -4264,7 +4196,9 @@ void AusgangstuerOeffnen(int x, int y) Feld[x][y] = EL_EXIT_OPEN; DrawLevelField(x, y); } +#endif +#if 1 void OpenSwitchgate(int x, int y) { int delay = 6; @@ -4294,7 +4228,9 @@ void OpenSwitchgate(int x, int y) Feld[x][y] = EL_SWITCHGATE_OPEN; DrawLevelField(x, y); } +#endif +#if 1 void CloseSwitchgate(int x, int y) { int delay = 6; @@ -4324,7 +4260,9 @@ void CloseSwitchgate(int x, int y) Feld[x][y] = EL_SWITCHGATE_CLOSED; DrawLevelField(x, y); } +#endif +#if 1 void OpenTimegate(int x, int y) { int delay = 6; @@ -4354,7 +4292,9 @@ void OpenTimegate(int x, int y) Feld[x][y] = EL_TIMEGATE_OPEN; DrawLevelField(x, y); } +#endif +#if 1 void CloseTimegate(int x, int y) { int delay = 6; @@ -4384,6 +4324,7 @@ void CloseTimegate(int x, int y) Feld[x][y] = EL_TIMEGATE_CLOSED; DrawLevelField(x, y); } +#endif static void CloseAllOpenTimegates() { @@ -4410,13 +4351,17 @@ void EdelsteinFunkeln(int x, int y) return; if (Feld[x][y] == EL_BD_DIAMOND) +#if 0 DrawLevelElementAnimation(x, y, el2img(Feld[x][y])); +#else + return; +#endif else { - if (!MovDelay[x][y]) /* next animation frame */ + if (MovDelay[x][y] == 0) /* next animation frame */ MovDelay[x][y] = 11 * !SimpleRND(500); - if (MovDelay[x][y]) /* wait some time before next frame */ + if (MovDelay[x][y] != 0) /* wait some time before next frame */ { MovDelay[x][y]--; @@ -4429,7 +4374,7 @@ void EdelsteinFunkeln(int x, int y) DrawLevelElementAnimation(x, y, Feld[x][y]); #endif - if (MovDelay[x][y]) + if (MovDelay[x][y] != 0) { int frame = getGraphicAnimationFrame(IMG_TWINKLE_WHITE, 10 - MovDelay[x][y]); @@ -4689,7 +4634,8 @@ static void WarnBuggyBase(int x, int y) } } -static void CheckBuggyBase(int x, int y) +#if 1 +void CheckBuggyBase(int x, int y) { int element = Feld[x][y]; @@ -4759,8 +4705,30 @@ static void CheckBuggyBase(int x, int y) } } } +#endif + +static void InitTrap(int x, int y) +{ + MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND); +} + +static void ActivateTrap(int x, int y) +{ + PlaySoundLevel(x, y, SND_TRAP_ACTIVATING); +} -static void CheckTrap(int x, int y) +static void ChangeActiveTrap(int x, int y) +{ + int graphic = IMG_TRAP_ACTIVE; + + /* if animation frame already drawn, correct crumbled sand border */ + if (IS_ANIMATED(graphic)) + if (checkDrawLevelGraphicAnimation(x, y, graphic)) + DrawCrumbledSand(SCREENX(x), SCREENY(y)); +} + +#if 1 +void CheckTrap(int x, int y) { int element = Feld[x][y]; @@ -4806,8 +4774,9 @@ static void CheckTrap(int x, int y) } } } +#endif -#if 0 +#if 1 static void DrawBeltAnimation(int x, int y, int element) { int belt_nr = getBeltNrFromBeltActiveElement(element); @@ -4818,7 +4787,7 @@ static void DrawBeltAnimation(int x, int y, int element) DrawLevelElementAnimation(x, y, element); if (!(FrameCounter % 2)) - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); + PlaySoundLevelAction(x, y, ACTION_ACTIVE); } } #endif @@ -4840,7 +4809,8 @@ static void ChangeElement(int x, int y) if (MovDelay[x][y] != 0) /* continue element change */ { - DrawLevelElementAnimation(x, y, element); + if (IS_ANIMATED(el2img(element))) + DrawLevelElementAnimation(x, y, element); if (changing_element[element].change_function) changing_element[element].change_function(x, y); @@ -4848,6 +4818,8 @@ static void ChangeElement(int x, int y) else /* finish element change */ { Feld[x][y] = changing_element[element].next_element; + GfxFrame[x][y] = 0; + DrawLevelField(x, y); if (changing_element[element].post_change_function) @@ -5142,7 +5114,7 @@ void GameActions() { #if 1 - if (new_graphic_info[graphic].anim_frames > 1) + if (IS_ANIMATED(graphic)) DrawLevelGraphicAnimation(x, y, graphic); #endif @@ -5154,10 +5126,16 @@ void GameActions() StartMoving(x, y); #if 1 +#if 0 if (Feld[x][y] == EL_EMERALD && - new_graphic_info[graphic].anim_frames > 1 && + IS_ANIMATED(graphic) && + !IS_MOVING(x, y)) + DrawLevelGraphicAnimation(x, y, graphic); +#else + if (IS_ANIMATED(graphic) && !IS_MOVING(x, y)) DrawLevelGraphicAnimation(x, y, graphic); +#endif #endif if (IS_GEM(element) || element == EL_SP_INFOTRON) @@ -5173,7 +5151,7 @@ void GameActions() element == EL_EXTRA_TIME || element == EL_SHIELD_NORMAL || element == EL_SHIELD_DEADLY) && - new_graphic_info[graphic].anim_frames > 1) + IS_ANIMATED(graphic)) DrawLevelGraphicAnimation(x, y, graphic); #endif @@ -5197,10 +5175,12 @@ void GameActions() else if (element == EL_GAMEOFLIFE || element == EL_BIOMAZE) Life(x, y); +#if 0 else if (element == EL_ROBOT_WHEEL_ACTIVE) RobotWheel(x, y); else if (element == EL_TIMEGATE_SWITCH_ACTIVE) TimegateWheel(x, y); +#endif else if (element == EL_ACID_SPLASH_LEFT || element == EL_ACID_SPLASH_RIGHT) Blurb(x, y); @@ -5211,9 +5191,9 @@ void GameActions() BreakingPearl(x, y); #endif else if (element == EL_EXIT_CLOSED) - AusgangstuerPruefen(x, y); + CheckExit(x, y); else if (element == EL_SP_EXIT_CLOSED) - AusgangstuerPruefen_SP(x, y); + CheckExitSP(x, y); #if 0 else if (element == EL_EXIT_OPENING) AusgangstuerOeffnen(x, y); @@ -5227,13 +5207,14 @@ void GameActions() MauerAbleger(x, y); else if (element == EL_FLAMES) CheckForDragon(x, y); +#if 0 else if (element == EL_SP_BUGGY_BASE || element == EL_SP_BUGGY_BASE_ACTIVATING || element == EL_SP_BUGGY_BASE_ACTIVE) CheckBuggyBase(x, y); - else if (element == EL_TRAP || element == EL_TRAP_ACTIVE) + else if (element == EL_TRAP || + element == EL_TRAP_ACTIVE) CheckTrap(x, y); -#if 0 else if (IS_BELT_ACTIVE(element)) DrawBeltAnimation(x, y, element); else if (element == EL_SWITCHGATE_OPENING) @@ -5250,12 +5231,14 @@ void GameActions() ChangeElement(x, y); #if 1 - else if (new_graphic_info[graphic].anim_frames > 1) + else if (element == EL_EXPLOSION) + ; /* drawing of correct explosion animation is handled separately */ + else if (IS_ANIMATED(graphic)) DrawLevelGraphicAnimation(x, y, graphic); #endif if (IS_BELT_ACTIVE(element)) - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); + PlaySoundLevelAction(x, y, ACTION_ACTIVE); if (game.magic_wall_active) { @@ -6256,7 +6239,7 @@ int DigField(struct PlayerInfo *player, case EL_SP_BUGGY_BASE: case EL_SP_BUGGY_BASE_ACTIVATING: RemoveField(x, y); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_DIGGING); + PlaySoundLevelElementAction(x, y, element, ACTION_DIGGING); break; case EL_EMERALD: @@ -6278,7 +6261,7 @@ int DigField(struct PlayerInfo *player, DrawText(DX_EMERALDS, DY_EMERALDS, int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING); + PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING); break; case EL_SPEED_PILL: @@ -6323,7 +6306,7 @@ int DigField(struct PlayerInfo *player, DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING); + PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING); break; case EL_DYNABOMB_NR: @@ -6545,7 +6528,7 @@ int DigField(struct PlayerInfo *player, player->push_delay_value = (element == EL_SPRING ? 0 : 2 + RND(8)); DrawLevelField(x + dx, y + dy); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING); + PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING); break; case EL_GATE1: @@ -6605,7 +6588,7 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_PASSING); + PlaySoundLevelElementAction(x, y, element, ACTION_PASSING); break; case EL_SP_PORT1_LEFT: @@ -6803,7 +6786,7 @@ int DigField(struct PlayerInfo *player, { RemoveField(x, y); Feld[x+dx][y+dy] = element; - PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING); + PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING); } player->push_delay_value = (element == EL_BALLOON ? 0 : 2); @@ -6890,11 +6873,14 @@ boolean PlaceBomb(struct PlayerInfo *player) if (element != EL_EMPTY) Store[jx][jy] = element; + MovDelay[jx][jy] = 96; + GfxFrame[jx][jy] = 0; + if (player->dynamite) { Feld[jx][jy] = EL_DYNAMITE_ACTIVE; - MovDelay[jx][jy] = 96; player->dynamite--; + DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) @@ -6911,8 +6897,8 @@ boolean PlaceBomb(struct PlayerInfo *player) { Feld[jx][jy] = EL_DYNABOMB_PLAYER1_ACTIVE + (player->element_nr - EL_PLAYER1); - MovDelay[jx][jy] = 96; player->dynabombs_left--; + if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), el2img(Feld[jx][jy]), 0); @@ -6922,7 +6908,7 @@ boolean PlaceBomb(struct PlayerInfo *player) return TRUE; } -void PlaySoundLevel(int x, int y, int nr) +static void PlaySoundLevel(int x, int y, int nr) { static int loop_sound_frame[NUM_SOUND_FILES]; static int loop_sound_volume[NUM_SOUND_FILES]; @@ -6969,16 +6955,26 @@ void PlaySoundLevel(int x, int y, int nr) PlaySoundExt(nr, volume, stereo_position, type); } -void PlaySoundLevelAction(int x, int y, int sound_action) +static void PlaySoundLevelNearest(int x, int y, int sound_action) +{ + PlaySoundLevel(x < LEVELX(BX1) ? LEVELX(BX1) : + x > LEVELX(BX2) ? LEVELX(BX2) : x, + y < LEVELY(BY1) ? LEVELY(BY1) : + y > LEVELY(BY2) ? LEVELY(BY2) : y, + sound_action); +} + +static void PlaySoundLevelAction(int x, int y, int sound_action) { PlaySoundLevelElementAction(x, y, Feld[x][y], sound_action); } -void PlaySoundLevelElementAction(int x, int y, int element, int sound_action) +static void PlaySoundLevelElementAction(int x, int y, int element, + int sound_action) { - int sound_effect = element_action_sound[element][sound_action]; + int sound_effect = element_info[element].sound[sound_action]; - if (sound_effect != -1) + if (sound_effect != SND_UNDEFINED) PlaySoundLevel(x, y, sound_effect); } @@ -7125,7 +7121,7 @@ void CreateGameButtons() for (i=0; i