switch (element)
{
case O_NUT:
+ gd_sound_play(cave, GD_S_NUT_FALLING, element, x, y);
+ break;
+
case O_NUT_F:
- gd_sound_play(cave, GD_S_NUT, element, x, y);
+ gd_sound_play(cave, GD_S_NUT_IMPACT, element, x, y);
break;
case O_STONE:
+ gd_sound_play(cave, GD_S_STONE_FALLING, element, x, y);
+ break;
+
case O_STONE_F:
+ gd_sound_play(cave, GD_S_STONE_IMPACT, element, x, y);
+ break;
+
case O_FLYING_STONE:
+ gd_sound_play(cave, GD_S_FLYING_STONE_FALLING, element, x, y);
+ break;
+
case O_FLYING_STONE_F:
+ gd_sound_play(cave, GD_S_FLYING_STONE_IMPACT, element, x, y);
+ break;
+
case O_MEGA_STONE:
+ gd_sound_play(cave, GD_S_MEGA_STONE_FALLING, element, x, y);
+ break;
+
case O_MEGA_STONE_F:
- case O_WAITING_STONE:
- case O_CHASING_STONE:
- gd_sound_play(cave, GD_S_STONE, element, x, y);
+ gd_sound_play(cave, GD_S_MEGA_STONE_IMPACT, element, x, y);
break;
case O_NITRO_PACK:
+ gd_sound_play(cave, GD_S_NITRO_PACK_FALLING, element, x, y);
+ break;
+
case O_NITRO_PACK_F:
- gd_sound_play(cave, GD_S_NITRO_PACK, element, x, y);
+ gd_sound_play(cave, GD_S_NITRO_PACK_IMPACT, element, x, y);
break;
case O_FALLING_WALL:
+ gd_sound_play(cave, GD_S_FALLING_WALL_FALLING, element, x, y);
+ break;
+
case O_FALLING_WALL_F:
- gd_sound_play(cave, GD_S_FALLING_WALL, element, x, y);
+ gd_sound_play(cave, GD_S_FALLING_WALL_IMPACT, element, x, y);
break;
case O_H_EXPANDING_WALL:
break;
case O_DIAMOND:
+ gd_sound_play(cave, GD_S_DIAMOND_FALLING_RANDOM, element, x, y);
+ break;
+
case O_DIAMOND_F:
+ gd_sound_play(cave, GD_S_DIAMOND_IMPACT_RANDOM, element, x, y);
+ break;
+
case O_FLYING_DIAMOND:
+ gd_sound_play(cave, GD_S_FLYING_DIAMOND_FALLING_RANDOM, element, x, y);
+ break;
+
case O_FLYING_DIAMOND_F:
- gd_sound_play(cave, GD_S_DIAMOND_RANDOM, element, x, y);
+ gd_sound_play(cave, GD_S_FLYING_DIAMOND_IMPACT_RANDOM, element, x, y);
break;
case O_BLADDER_SPENDER:
break;
case O_DIRT_BALL:
+ gd_sound_play(cave, GD_S_DIRT_BALL_FALLING, element, x, y);
+ break;
+
case O_DIRT_BALL_F:
+ gd_sound_play(cave, GD_S_DIRT_BALL_IMPACT, element, x, y);
+ break;
+
case O_DIRT_LOOSE:
+ gd_sound_play(cave, GD_S_DIRT_LOOSE_FALLING, element, x, y);
+ break;
+
case O_DIRT_LOOSE_F:
- gd_sound_play(cave, GD_S_DIRT_BALL, element, x, y);
+ gd_sound_play(cave, GD_S_DIRT_LOOSE_IMPACT, element, x, y);
+ break;
+
+ default:
+ /* do nothing. */
+ break;
+ }
+}
+
+/* play sound of given element being pushed. */
+static void play_sound_of_element_pushing(GdCave *cave, GdElement element, int x, int y)
+{
+ switch (element)
+ {
+ case O_NUT:
+ gd_sound_play(cave, GD_S_NUT_PUSHING, element, x, y);
+ break;
+
+ case O_STONE:
+ gd_sound_play(cave, GD_S_STONE_PUSHING, element, x, y);
+ break;
+
+ case O_FLYING_STONE:
+ gd_sound_play(cave, GD_S_FLYING_STONE_PUSHING, element, x, y);
+ break;
+
+ case O_MEGA_STONE:
+ gd_sound_play(cave, GD_S_MEGA_STONE_PUSHING, element, x, y);
+ break;
+
+ case O_WAITING_STONE:
+ gd_sound_play(cave, GD_S_WAITING_STONE_PUSHING, element, x, y);
+ break;
+
+ case O_CHASING_STONE:
+ gd_sound_play(cave, GD_S_CHASING_STONE_PUSHING, element, x, y);
+ break;
+
+ case O_NITRO_PACK:
+ gd_sound_play(cave, GD_S_NITRO_PACK_PUSHING, element, x, y);
+ break;
+
+ case O_BLADDER:
+ gd_sound_play(cave, GD_S_BLADDER_PUSHING, element, x, y);
break;
default:
}
}
+static inline int getx(const GdCave *cave, const int x, const int y)
+{
+ return cave->getx(cave, x, y);
+}
+
+static inline int gety(const GdCave *cave, const int x, const int y)
+{
+ return cave->gety(cave, x, y);
+}
+
+/* perfect (non-lineshifting) GET x/y functions; returns range corrected x/y position */
+static inline int getx_perfect(const GdCave *cave, const int x, const int y)
+{
+ return (x + cave->w) % cave->w;
+}
+
+static inline int gety_perfect(const GdCave *cave, const int x, const int y)
+{
+ return (y + cave->h) % cave->h;
+}
+
+/* line shifting GET x/y function; returns range corrected x/y position */
+static inline int getx_shift(const GdCave *cave, int x, int y)
+{
+ return (x + cave->w) % cave->w;
+}
+
+static inline int gety_shift(const GdCave *cave, int x, int y)
+{
+ return ((x < 0 ? y - 1 : x >= cave->w ? y + 1 : y) + cave->h) % cave->h;
+}
+
static inline GdElement *getp(const GdCave *cave, const int x, const int y)
{
return cave->getp(cave, x, y);
static inline boolean is_space_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
- GdElement e = get_dir(cave, x, y, dir)&O_MASK;
+ GdElement e = get_dir(cave, x, y, dir) & O_MASK;
return (e == O_SPACE || e == O_LAVA);
}
+static inline void store_dir_buffer(GdCave *cave, const int x, const int y, const GdDirection dir)
+{
+ /* raw values without range correction */
+ int raw_x = x + gd_dx[dir];
+ int raw_y = y + gd_dy[dir];
+ /* final values with range correction */
+ int new_x = getx(cave, raw_x, raw_y);
+ int new_y = gety(cave, raw_x, raw_y);
+ int new_dir = (dir > GD_MV_TWICE ? dir - GD_MV_TWICE : dir);
+
+ game_bd.game->dir_buffer[new_y][new_x] = new_dir;
+}
+
/* store an element at the given position */
static inline void store(GdCave *cave, const int x, const int y, const GdElement element)
{
static inline void store_dir(GdCave *cave, const int x, const int y,
const GdDirection dir, const GdElement element)
{
- store(cave, x + gd_dx[dir], y + gd_dy[dir], element|SCANNED);
+ store_dir_buffer(cave, x, y, dir);
+ store(cave, x + gd_dx[dir], y + gd_dy[dir], element | SCANNED);
}
/* store an element to a neighbouring cell */
static inline void store_dir_no_scanned(GdCave *cave, const int x, const int y,
const GdDirection dir, const GdElement element)
{
+ store_dir_buffer(cave, x, y, dir);
store(cave, x + gd_dx[dir], y + gd_dy[dir], element);
}
case O_FLYING_DIAMOND:
// prevent diamond sounds for O_SKELETON (see below)
if (x != -1 && y != -1)
- gd_sound_play(cave, GD_S_DIAMOND_COLLECTING, object, x, y);
+ gd_sound_play(cave, (object == O_DIAMOND ? GD_S_DIAMOND_COLLECTING :
+ GD_S_FLYING_DIAMOND_COLLECTING), object, x, y);
cave->score += cave->diamond_value;
cave->diamonds_collected++;
{
/* if decided that he will be able to push, */
store_dir(cave, x, y, GD_MV_TWICE + player_move, what);
- play_sound_of_element(cave, what, x, y);
+ play_sound_of_element_pushing(cave, what, x, y);
result = TRUE;
}
}
}
if (result)
- play_sound_of_element(cave, O_BLADDER, x, y);
+ play_sound_of_element_pushing(cave, O_BLADDER, x, y);
}
break;
/* set cave get function; to implement perfect or lineshifting borders */
if (cave->lineshift)
+ {
cave->getp = getp_shift;
+ cave->getx = getx_shift;
+ cave->gety = gety_shift;
+ }
else
+ {
cave->getp = getp_perfect;
+ cave->getx = getx_perfect;
+ cave->gety = gety_perfect;
+ }
/* increment this. if the scan routine comes across player, clears it (sets to zero). */
if (cave->player_seen_ago < 100)
{
/* if we find a scanned element, change it to the normal one, and that's all. */
/* this is required, for example for chasing stones, which have moved, always passing slime! */
- if (get(cave, x, y)&SCANNED)
+ if (get(cave, x, y) & SCANNED)
{
store(cave, x, y, get(cave, x, y) & ~SCANNED);
/* try to push element; if successful, break */
push = do_push(cave, x, y, player_move, player_fire);
if (push)
+ {
remains = O_SPACE;
+ }
else
+ {
switch (what)
{
case O_BOMB:
default:
/* get element - process others.
if cannot get, player_get_element will return the same */
- remains = player_get_element (cave, what, x, y);
+ remains = player_get_element(cave, what, x, y);
break;
}
+ }
if (remains != what || remains == O_SPACE)
{
/* player fire is false... */
if (do_push(cave, x, y, player_move, FALSE))
+ {
remains = O_SPACE;
+ }
else
{
switch (what)