X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=7fd229444b19f2cbf55bfa2b9b51347a5c63f1ce;hb=fa9c72bb286c8e5e5095e666dbf85981ad3a8ea2;hp=10e6e2fb5b5471726474958a28037e25ff5b7b2e;hpb=69eca5c908598155bf3f5d1fa74e73ff9e2bbbc9;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 10e6e2fb..7fd22944 100644 --- a/src/game.c +++ b/src/game.c @@ -119,10 +119,10 @@ static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; #define IS_LOOP_SOUND(s) (sound_info[s].loop) -/* ------------------------------------------------------------------------- - definition of elements that automatically change to other elements after - a specified time, eventually calling a function when changing - ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ +/* definition of elements that automatically change to other elements after */ +/* a specified time, eventually calling a function when changing */ +/* ------------------------------------------------------------------------- */ /* forward declaration for changer functions */ static void InitBuggyBase(int x, int y); @@ -2178,7 +2178,7 @@ void Impact(int x, int y) if ((element == EL_BOMB || element == EL_SP_DISK_ORANGE || element == EL_DX_SUPABOMB) && - (lastline || object_hit)) /* element is bomb */ + (lastline || object_hit)) /* element is bomb */ { Bang(x, y); return; @@ -2207,7 +2207,8 @@ void Impact(int x, int y) if (!lastline && object_hit) /* check which object was hit */ { if (CAN_CHANGE(element) && - (smashed == EL_MAGIC_WALL || smashed == EL_BD_MAGIC_WALL)) + (smashed == EL_MAGIC_WALL || + smashed == EL_BD_MAGIC_WALL)) { int xx, yy; int activated_magic_wall = @@ -2228,29 +2229,31 @@ void Impact(int x, int y) SND_BD_MAGIC_WALL_ACTIVATING)); } - if (IS_PLAYER(x, y+1)) + if (IS_PLAYER(x, y + 1)) { KillHeroUnlessProtected(x, y+1); return; } else if (smashed == EL_PENGUIN) { - Bang(x, y+1); + Bang(x, y + 1); return; } else if (element == EL_BD_DIAMOND) { if (IS_ENEMY(smashed) && IS_BD_ELEMENT(smashed)) { - Bang(x, y+1); + Bang(x, y + 1); return; } } - else if ((element == EL_SP_INFOTRON || element == EL_SP_ZONK) && - (smashed == EL_SP_SNIKSNAK || smashed == EL_SP_ELECTRON || + else if ((element == EL_SP_INFOTRON || + element == EL_SP_ZONK) && + (smashed == EL_SP_SNIKSNAK || + smashed == EL_SP_ELECTRON || smashed == EL_SP_DISK_ORANGE)) { - Bang(x, y+1); + Bang(x, y + 1); return; } else if (element == EL_ROCK || @@ -2258,19 +2261,23 @@ void Impact(int x, int y) element == EL_BD_ROCK) { if (IS_ENEMY(smashed) || - smashed == EL_BOMB || smashed == EL_SP_DISK_ORANGE || + smashed == EL_BOMB || + smashed == EL_SP_DISK_ORANGE || smashed == EL_DX_SUPABOMB || - smashed == EL_SATELLITE || smashed == EL_PIG || - smashed == EL_DRAGON || smashed == EL_MOLE) + smashed == EL_SATELLITE || + smashed == EL_PIG || + smashed == EL_DRAGON || + smashed == EL_MOLE) { - Bang(x, y+1); + Bang(x, y + 1); return; } - else if (!IS_MOVING(x, y+1)) + else if (!IS_MOVING(x, y + 1)) { - if (smashed == EL_LAMP || smashed == EL_LAMP_ACTIVE) + if (smashed == EL_LAMP || + smashed == EL_LAMP_ACTIVE) { - Bang(x, y+1); + Bang(x, y + 1); return; } else if (smashed == EL_NUT) @@ -5224,6 +5231,8 @@ void GameActions() ChangeElement(x, y); #if 1 + else if (element == EL_EXPLOSION) + ; /* drawing of correct explosion animation is handled separately */ else if (IS_ANIMATED(graphic)) DrawLevelGraphicAnimation(x, y, graphic); #endif @@ -6899,10 +6908,29 @@ boolean PlaceBomb(struct PlayerInfo *player) return TRUE; } +/* ------------------------------------------------------------------------- */ +/* game sound playing functions */ +/* ------------------------------------------------------------------------- */ + +static int *loop_sound_frame = NULL; +static int *loop_sound_volume = NULL; + +void InitPlaySoundLevel() +{ + int num_sounds = getSoundListSize(); + + if (loop_sound_frame != NULL) + free(loop_sound_frame); + + if (loop_sound_volume != NULL) + free(loop_sound_volume); + + loop_sound_frame = checked_calloc(num_sounds * sizeof(int)); + loop_sound_volume = checked_calloc(num_sounds * sizeof(int)); +} + 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]; int sx = SCREENX(x), sy = SCREENY(y); int volume, stereo_position; int max_distance = 8;