void gd_cave_set_seconds_sound(GdCave *cave)
{
// when not counting bonus time, timeout sounds will be played by main game engine;
void gd_cave_set_seconds_sound(GdCave *cave)
{
// when not counting bonus time, timeout sounds will be played by main game engine;
- /* this is an integer division, so 0 seconds can be 0.5 seconds... */
- /* also, when this reaches 8, the player still has 8.9999 seconds.
- so the sound is played at almost t = 9s. */
+ // this is an integer division, so 0 seconds can be 0.5 seconds...
+ // also, when this reaches 8, the player still has 8.9999 seconds.
+ // so the sound is played at almost t = 9s.
switch (cave->time / cave->timing_factor)
{
case 9: gd_sound_play(cave, GD_S_TIMEOUT_10, O_NONE, -1, -1); break;
switch (cave->time / cave->timing_factor)
{
case 9: gd_sound_play(cave, GD_S_TIMEOUT_10, O_NONE, -1, -1); break;
static void play_sound_of_element(GdCave *cave, GdElement element, int x, int y)
{
static void play_sound_of_element(GdCave *cave, GdElement element, int x, int y)
{
static void play_sound_of_element_pushing(GdCave *cave, GdElement element, int x, int y)
{
switch (element)
static void play_sound_of_element_pushing(GdCave *cave, GdElement element, int x, int y)
{
switch (element)
static inline int getx_perfect(const GdCave *cave, const int x, const int y)
{
return (x + cave->w) % cave->w;
static inline int getx_perfect(const GdCave *cave, const int x, const int y)
{
return (x + cave->w) % cave->w;
static inline int getx_shift(const GdCave *cave, int x, int y)
{
return (x + cave->w) % cave->w;
static inline int getx_shift(const GdCave *cave, int x, int y)
{
return (x + cave->w) % cave->w;
static inline GdElement get_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
static inline GdElement get_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_EXPLODES_BY_HIT) != 0;
}
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_EXPLODES_BY_HIT) != 0;
}
static inline boolean non_explodable(const GdCave *cave, const int x, const int y)
{
return (gd_elements[get(cave, x,y) & O_MASK].properties & P_NON_EXPLODABLE) != 0;
}
static inline boolean non_explodable(const GdCave *cave, const int x, const int y)
{
return (gd_elements[get(cave, x,y) & O_MASK].properties & P_NON_EXPLODABLE) != 0;
}
static inline boolean amoeba_eats_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_AMOEBA_CONSUMES) != 0;
}
static inline boolean amoeba_eats_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_AMOEBA_CONSUMES) != 0;
}
-/* returns true if the element is sloped, so stones and diamonds roll down on it.
- for example a stone or brick wall */
+// returns true if the element is sloped, so stones and diamonds roll down on it.
+// for example a stone or brick wall
static inline boolean sloped_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir, const GdDirection slop)
{
static inline boolean sloped_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir, const GdDirection slop)
{
-/* returns true if the element is sloped for bladder movement
- (brick = yes, diamond = no, for example) */
+// returns true if the element is sloped for bladder movement
+// (brick = yes, diamond = no, for example)
static inline boolean sloped_for_bladder_dir (const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
static inline boolean sloped_for_bladder_dir (const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_BLOWS_UP_FLIES) != 0;
}
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_BLOWS_UP_FLIES) != 0;
}
static inline boolean rotates_ccw (const GdCave *cave, const int x, const int y)
{
return (gd_elements[get(cave, x, y) & O_MASK].properties & P_CCW) != 0;
}
static inline boolean rotates_ccw (const GdCave *cave, const int x, const int y)
{
return (gd_elements[get(cave, x, y) & O_MASK].properties & P_CCW) != 0;
}
static inline boolean is_player(const GdCave *cave, const int x, const int y)
{
return (gd_elements[get(cave, x, y) & O_MASK].properties & P_PLAYER) != 0;
}
static inline boolean is_player(const GdCave *cave, const int x, const int y)
{
return (gd_elements[get(cave, x, y) & O_MASK].properties & P_PLAYER) != 0;
}
static inline boolean is_player_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
static inline boolean is_player_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_CAN_BE_HAMMERED) != 0;
}
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_CAN_BE_HAMMERED) != 0;
}
static inline boolean is_first_stage_of_explosion(const GdCave *cave, const int x, const int y)
{
return (gd_elements[get(cave, x, y) & O_MASK].properties & P_EXPLOSION_FIRST_STAGE) != 0;
}
static inline boolean is_first_stage_of_explosion(const GdCave *cave, const int x, const int y)
{
return (gd_elements[get(cave, x, y) & O_MASK].properties & P_EXPLOSION_FIRST_STAGE) != 0;
}
static inline boolean moved_by_conveyor_top_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_MOVED_BY_CONVEYOR_TOP) != 0;
}
static inline boolean moved_by_conveyor_top_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
return (gd_elements[get_dir(cave, x, y, dir) & O_MASK].properties & P_MOVED_BY_CONVEYOR_TOP) != 0;
}
static inline boolean moved_by_conveyor_bottom_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
static inline boolean moved_by_conveyor_bottom_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
return (get_dir(cave, x, y, dir) & SCANNED) != 0;
}
return (get_dir(cave, x, y, dir) & SCANNED) != 0;
}
-/* returns true if neighbouring element is "e" */
-/* treats dirt specially */
-/* treats lava specially */
+// returns true if neighbouring element is "e"
+// treats dirt specially
+// treats lava specially
static inline boolean is_element_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir, GdElement e)
{
GdElement examined = get_dir(cave, x, y, dir);
static inline boolean is_element_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir, GdElement e)
{
GdElement examined = get_dir(cave, x, y, dir);
if (gd_elements[examined & O_MASK].properties & P_DIRT)
examined = O_DIRT;
if (gd_elements[e & O_MASK].properties & P_DIRT)
e = O_DIRT;
if (gd_elements[examined & O_MASK].properties & P_DIRT)
examined = O_DIRT;
if (gd_elements[e & O_MASK].properties & P_DIRT)
e = O_DIRT;
static inline boolean is_space_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
static inline boolean is_space_dir(const GdCave *cave, const int x, const int y,
const GdDirection dir)
{
static inline void store_dir_buffer(GdCave *cave, const int x, const int y, const GdDirection dir)
{
static inline void store_dir_buffer(GdCave *cave, const int x, const int y, const GdDirection dir)
{
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);
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);
static inline void store(GdCave *cave, const int x, const int y, const GdElement element)
{
GdElement *e = getp(cave, x, y);
static inline void store(GdCave *cave, const int x, const int y, const GdElement element)
{
GdElement *e = getp(cave, x, y);
static inline void store_sc(GdCave *cave, const int x, const int y, const GdElement element)
{
store(cave, x, y, element | SCANNED);
}
static inline void store_sc(GdCave *cave, const int x, const int y, const GdElement element)
{
store(cave, x, y, element | SCANNED);
}
static inline void store_dir(GdCave *cave, const int x, const int y,
const GdDirection dir, 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(cave, x + gd_dx[dir], y + gd_dy[dir], element | SCANNED);
}
static inline void store_dir_no_scanned(GdCave *cave, const int x, const int y,
const GdDirection dir, const GdElement element)
{
static inline void store_dir_no_scanned(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);
}
store(cave, x + gd_dx[dir], y + gd_dy[dir], element);
}
static inline void move(GdCave *cave, const int x, const int y,
const GdDirection dir, const GdElement e)
{
static inline void move(GdCave *cave, const int x, const int y,
const GdDirection dir, const GdElement e)
{
store(cave, x, y, O_SPACE);
}
store(cave, x, y, O_SPACE);
}
-/* increment a cave element; can be used for elements which are one after
- the other, for example bladder1, bladder2, bladder3... */
+// increment a cave element; can be used for elements which are one after
+// the other, for example bladder1, bladder2, bladder3...
cave->voodoo_touched = TRUE;
if (get(cave, x, y) == O_VOODOO && !cave->voodoo_disappear_in_explosion)
cave->voodoo_touched = TRUE;
if (get(cave, x, y) == O_VOODOO && !cave->voodoo_disappear_in_explosion)
store_sc(cave, x, y, O_TIME_PENALTY);
else if (get(cave, x, y) == O_NITRO_PACK ||
get(cave, x, y) == O_NITRO_PACK_F)
store_sc(cave, x, y, O_TIME_PENALTY);
else if (get(cave, x, y) == O_NITRO_PACK ||
get(cave, x, y) == O_NITRO_PACK_F)
store_sc(cave, x, y, O_NITRO_PACK_EXPLODE);
else
store_sc(cave, x, y, O_NITRO_PACK_EXPLODE);
else
store_sc(cave, x, y, explode_to);
}
store_sc(cave, x, y, explode_to);
}
static void creature_explode(GdCave *cave, int x, int y, GdElement explode_to)
{
int xx, yy;
static void creature_explode(GdCave *cave, int x, int y, GdElement explode_to)
{
int xx, yy;
cave->ckdelay += 1200;
gd_sound_play(cave, GD_S_EXPLODING, get(cave, x, y), x, y);
cave->ckdelay += 1200;
gd_sound_play(cave, GD_S_EXPLODING, get(cave, x, y), x, y);
cave->ckdelay += 1200;
gd_sound_play(cave, GD_S_NITRO_PACK_EXPLODING, get(cave, x, y), x, y);
cave->ckdelay += 1200;
gd_sound_play(cave, GD_S_NITRO_PACK_EXPLODING, get(cave, x, y), x, y);
for (xx = x - 1; xx <= x + 1; xx++)
cell_explode(cave, xx, yy, O_NITRO_EXPL_1);
for (xx = x - 1; xx <= x + 1; xx++)
cell_explode(cave, xx, yy, O_NITRO_EXPL_1);
- /* the current cell is explicitly changed into a nitro expl,
- as cell_explode changes it to a triggered nitro pack */
+ // the current cell is explicitly changed into a nitro expl,
+ // as cell_explode changes it to a triggered nitro pack
store_sc(cave, x, y, O_NITRO_EXPL_1);
}
store_sc(cave, x, y, O_NITRO_EXPL_1);
}
cave->ckdelay += 1000;
gd_sound_play(cave, GD_S_VOODOO_EXPLODING, get(cave, x, y), x, y);
if (cave->voodoo_any_hurt_kills_player)
cave->voodoo_touched = TRUE;
cave->ckdelay += 1000;
gd_sound_play(cave, GD_S_VOODOO_EXPLODING, get(cave, x, y), x, y);
if (cave->voodoo_any_hurt_kills_player)
cave->voodoo_touched = TRUE;
for (yy = y - 1; yy <= y + 1; yy++)
for (xx = x - 1; xx <= x + 1; xx++)
store_sc(cave, xx, yy, O_PRE_STEEL_1);
for (yy = y - 1; yy <= y + 1; yy++)
for (xx = x - 1; xx <= x + 1; xx++)
store_sc(cave, xx, yy, O_PRE_STEEL_1);
store_sc(cave, x, y, O_TIME_PENALTY);
}
store_sc(cave, x, y, O_TIME_PENALTY);
}
-/* a bomb does not explode the voodoo, neither does the ghost.
- this function check this, and stores the new element or not.
- destroying the voodoo is also controlled by the
- voodoo_disappear_in_explosion flag. */
+/*
+ a bomb does not explode the voodoo, neither does the ghost.
+ this function check this, and stores the new element or not.
+ destroying the voodoo is also controlled by the
+ voodoo_disappear_in_explosion flag.
+*/
static void explode_try_skip_voodoo(GdCave *cave, const int x, const int y, const GdElement expl)
{
if (non_explodable (cave, x, y))
return;
static void explode_try_skip_voodoo(GdCave *cave, const int x, const int y, const GdElement expl)
{
if (non_explodable (cave, x, y))
return;
store_sc (cave, x, y, expl);
}
store_sc (cave, x, y, expl);
}
static void ghost_explode(GdCave *cave, const int x, const int y)
{
gd_sound_play(cave, GD_S_GHOST_EXPLODING, get(cave, x, y), x, y);
static void ghost_explode(GdCave *cave, const int x, const int y)
{
gd_sound_play(cave, GD_S_GHOST_EXPLODING, get(cave, x, y), x, y);
cave->ckdelay += 650;
explode_try_skip_voodoo(cave, x, y, O_GHOST_EXPL_1);
cave->ckdelay += 650;
explode_try_skip_voodoo(cave, x, y, O_GHOST_EXPL_1);
explode_try_skip_voodoo(cave, x + 1, y - 1, O_GHOST_EXPL_1);
}
explode_try_skip_voodoo(cave, x + 1, y - 1, O_GHOST_EXPL_1);
}
static void bomb_explode(GdCave *cave, const int x, const int y)
{
gd_sound_play(cave, GD_S_BOMB_EXPLODING, get(cave, x, y), x, y);
static void bomb_explode(GdCave *cave, const int x, const int y)
{
gd_sound_play(cave, GD_S_BOMB_EXPLODING, get(cave, x, y), x, y);
cave->ckdelay += 650;
explode_try_skip_voodoo(cave, x, y, O_BOMB_EXPL_1);
cave->ckdelay += 650;
explode_try_skip_voodoo(cave, x, y, O_BOMB_EXPL_1);
gd_sound_play(cave, GD_S_DIAMOND_KEY_COLLECTING, object, x, y);
return O_SPACE;
gd_sound_play(cave, GD_S_DIAMOND_KEY_COLLECTING, object, x, y);
return O_SPACE;
case O_KEY_1:
gd_sound_play(cave, GD_S_KEY_COLLECTING, object, x, y);
cave->key1++;
case O_KEY_1:
gd_sound_play(cave, GD_S_KEY_COLLECTING, object, x, y);
cave->key1++;
gd_sound_play(cave, GD_S_SWITCH_CREATURES, object, x, y);
cave->creatures_backwards = !cave->creatures_backwards;
return object;
gd_sound_play(cave, GD_S_SWITCH_CREATURES, object, x, y);
cave->creatures_backwards = !cave->creatures_backwards;
return object;
gd_sound_play(cave, GD_S_SWITCH_EXPANDING, object, x, y);
cave->expanding_wall_changed = !cave->expanding_wall_changed;
return object;
gd_sound_play(cave, GD_S_SWITCH_EXPANDING, object, x, y);
cave->expanding_wall_changed = !cave->expanding_wall_changed;
return object;
gd_sound_play(cave, GD_S_SWITCH_BITER, object, x, y);
cave->biter_delay_frame++;
if (cave->biter_delay_frame == 4)
cave->biter_delay_frame = 0;
return object;
gd_sound_play(cave, GD_S_SWITCH_BITER, object, x, y);
cave->biter_delay_frame++;
if (cave->biter_delay_frame == 4)
cave->biter_delay_frame = 0;
return object;
gd_sound_play(cave, GD_S_SWITCH_REPLICATOR, object, x, y);
cave->replicators_active = !cave->replicators_active;
return object;
gd_sound_play(cave, GD_S_SWITCH_REPLICATOR, object, x, y);
cave->replicators_active = !cave->replicators_active;
return object;
gd_sound_play(cave, GD_S_SWITCH_CONVEYOR, object, x, y);
cave->conveyor_belts_active = !cave->conveyor_belts_active;
return object;
gd_sound_play(cave, GD_S_SWITCH_CONVEYOR, object, x, y);
cave->conveyor_belts_active = !cave->conveyor_belts_active;
return object;
gd_sound_play(cave, GD_S_SWITCH_CONVEYOR, object, x, y);
cave->conveyor_belts_direction_changed = !cave->conveyor_belts_direction_changed;
return object;
gd_sound_play(cave, GD_S_SWITCH_CONVEYOR, object, x, y);
cave->conveyor_belts_direction_changed = !cave->conveyor_belts_direction_changed;
return object;
gd_sound_play(cave, GD_S_CLOCK_COLLECTING, object, x, y);
cave->time += cave->time_bonus * cave->timing_factor;
if (cave->time > cave->max_time * cave->timing_factor)
cave->time -= cave->max_time * cave->timing_factor;
gd_sound_play(cave, GD_S_CLOCK_COLLECTING, object, x, y);
cave->time += cave->time_bonus * cave->timing_factor;
if (cave->time > cave->max_time * cave->timing_factor)
cave->time -= cave->max_time * cave->timing_factor;
for (i = 0; i < cave->skeletons_worth_diamonds; i++)
player_get_element(cave, O_DIAMOND, -1, -1);
for (i = 0; i < cave->skeletons_worth_diamonds; i++)
player_get_element(cave, O_DIAMOND, -1, -1);
gd_sound_play(cave, GD_S_SKELETON_COLLECTING, object, x, y);
return O_SPACE;
case O_OUTBOX:
case O_INVIS_OUTBOX:
gd_sound_play(cave, GD_S_SKELETON_COLLECTING, object, x, y);
return O_SPACE;
case O_OUTBOX:
case O_INVIS_OUTBOX:
gd_sound_play(cave, GD_S_EMPTY_WALKING, object, x, y);
return O_SPACE;
default:
gd_sound_play(cave, GD_S_EMPTY_WALKING, object, x, y);
return O_SPACE;
default:
if (get(cave, tx, ty) == O_TELEPORTER &&
is_space_dir(cave, tx, ty, player_move))
{
if (get(cave, tx, ty) == O_TELEPORTER &&
is_space_dir(cave, tx, ty, player_move))
{
store_dir(cave, tx, ty, player_move, get(cave, px, py));
store_dir(cave, tx, ty, player_move, get(cave, px, py));
store(cave, px, py, O_SPACE);
gd_sound_play(cave, GD_S_TELEPORTER, O_TELEPORTER, tx, ty);
store(cave, px, py, O_SPACE);
gd_sound_play(cave, GD_S_TELEPORTER, O_TELEPORTER, tx, ty);
boolean result;
GdElement what = get_dir(cave, x, y, player_move);
boolean result;
GdElement what = get_dir(cave, x, y, player_move);
- /* pushing some kind of stone or nut */
- /* directions possible: 90degrees cw or ccw to current gravity. */
- /* only push if player dir is orthogonal to gravity,
- ie. gravity down, pushing left & right possible */
+ // pushing some kind of stone or nut
+ // directions possible: 90degrees cw or ccw to current gravity.
+ // only push if player dir is orthogonal to gravity,
+ // ie. gravity down, pushing left & right possible
}
if (is_space_dir(cave, x, y, GD_MV_TWICE + player_move) &&
}
if (is_space_dir(cave, x, y, GD_MV_TWICE + player_move) &&
store_dir(cave, x, y, GD_MV_TWICE + player_move, what);
play_sound_of_element_pushing(cave, what, x, y);
result = TRUE;
store_dir(cave, x, y, GD_MV_TWICE + player_move, what);
play_sound_of_element_pushing(cave, what, x, y);
result = TRUE;
- /* pushing a bladder. keep in mind that after pushing, we always get an O_BLADDER,
- * not an O_BLADDER_x. */
- /* there is no "delayed" state of a bladder, so we use store_dir_no_scanned! */
+ // pushing a bladder. keep in mind that after pushing, we always get an O_BLADDER,
+ // not an O_BLADDER_x.
+ // there is no "delayed" state of a bladder, so we use store_dir_no_scanned!
- /* pushing a bladder "down". p = player, o = bladder, 1, 2, 3 = directions to check. */
- /* player moving in the direction of gravity. */
- /* p p g */
- /* 2o3 | | */
- /* 1 v v */
+ // pushing a bladder "down". p = player, o = bladder, 1, 2, 3 = directions to check.
+ // player moving in the direction of gravity.
+ // p p g
+ // 2o3 | |
+ // 1 v v
if (is_space_dir(cave, x, y, GD_MV_TWICE + player_move))
store_dir_no_scanned(cave, x, y, GD_MV_TWICE + player_move, O_BLADDER), result = TRUE;
if (is_space_dir(cave, x, y, GD_MV_TWICE + player_move))
store_dir_no_scanned(cave, x, y, GD_MV_TWICE + player_move, O_BLADDER), result = TRUE;
else if (is_space_dir(cave, x, y, cw_eighth[grav_compat]))
else if (is_space_dir(cave, x, y, cw_eighth[grav_compat]))
store_dir_no_scanned(cave, x, y, cw_eighth[grav_compat], O_BLADDER), result = TRUE;
store_dir_no_scanned(cave, x, y, cw_eighth[grav_compat], O_BLADDER), result = TRUE;
else if (is_space_dir(cave, x, y, ccw_eighth[grav_compat]))
store_dir_no_scanned(cave, x, y, ccw_eighth[grav_compat], O_BLADDER), result = TRUE;
}
else if (is_space_dir(cave, x, y, ccw_eighth[grav_compat]))
store_dir_no_scanned(cave, x, y, ccw_eighth[grav_compat], O_BLADDER), result = TRUE;
}
- /* pushing a bladder "left". p = player, o = bladder, 1, 2, 3 = directions to check. */
- /* 3 g */
- /* 1op <-p | */
- /* 2 v */
+ // pushing a bladder "left". p = player, o = bladder, 1, 2, 3 = directions to check.
+ // 3 g
+ // 1op <-p |
+ // 2 v
- if (is_space_dir(cave, x, y, GD_MV_TWICE + cw_fourth[grav_compat])) /* pushing it left */
+ if (is_space_dir(cave, x, y, GD_MV_TWICE + cw_fourth[grav_compat])) // pushing it left
store_dir_no_scanned(cave, x, y, GD_MV_TWICE + cw_fourth[grav_compat], O_BLADDER), result = TRUE;
store_dir_no_scanned(cave, x, y, GD_MV_TWICE + cw_fourth[grav_compat], O_BLADDER), result = TRUE;
- else if (is_space_dir(cave, x, y, cw_eighth[grav_compat])) /* maybe down, and player will move left */
+ else if (is_space_dir(cave, x, y, cw_eighth[grav_compat])) // maybe down, and player will move left
store_dir_no_scanned(cave, x, y, cw_eighth[grav_compat], O_BLADDER), result = TRUE;
store_dir_no_scanned(cave, x, y, cw_eighth[grav_compat], O_BLADDER), result = TRUE;
- else if (is_space_dir(cave, x, y, cw_eighth[player_move])) /* maybe up, and player will move left */
+ else if (is_space_dir(cave, x, y, cw_eighth[player_move])) // maybe up, and player will move left
store_dir_no_scanned(cave, x, y, cw_eighth[player_move], O_BLADDER), result = TRUE;
}
store_dir_no_scanned(cave, x, y, cw_eighth[player_move], O_BLADDER), result = TRUE;
}
- /* pushing a bladder "right". p = player, o = bladder, 1, 2, 3 = directions to check. */
- /* 3 g */
- /* po1 p-< | */
- /* 2 v */
+ // pushing a bladder "right". p = player, o = bladder, 1, 2, 3 = directions to check.
+ // 3 g
+ // po1 p-< |
+ // 2 v
- if (is_space_dir(cave, x, y, GD_MV_TWICE + player_move)) /* pushing it right */
+ if (is_space_dir(cave, x, y, GD_MV_TWICE + player_move)) // pushing it right
store_dir_no_scanned(cave, x, y, GD_MV_TWICE + player_move, O_BLADDER), result = TRUE;
store_dir_no_scanned(cave, x, y, GD_MV_TWICE + player_move, O_BLADDER), result = TRUE;
- else if (is_space_dir(cave, x, y, ccw_eighth[grav_compat])) /* maybe down, and player will move right */
+ else if (is_space_dir(cave, x, y, ccw_eighth[grav_compat])) // maybe down, and player will move right
store_dir_no_scanned(cave, x, y, ccw_eighth[grav_compat], O_BLADDER), result = TRUE;
store_dir_no_scanned(cave, x, y, ccw_eighth[grav_compat], O_BLADDER), result = TRUE;
- else if (is_space_dir(cave, x, y, ccw_eighth[player_move])) /* maybe up, and player will move right */
+ else if (is_space_dir(cave, x, y, ccw_eighth[player_move])) // maybe up, and player will move right
store_dir_no_scanned(cave, x, y, ccw_eighth[player_move], O_BLADDER), result = TRUE;
}
store_dir_no_scanned(cave, x, y, ccw_eighth[player_move], O_BLADDER), result = TRUE;
}
if (is_space_dir(cave, x, y, player_move + GD_MV_TWICE))
{
if (is_space_dir(cave, x, y, player_move + GD_MV_TWICE))
{
store_dir(cave, x, y, player_move + GD_MV_TWICE, O_BOX);
result = TRUE;
gd_sound_play(cave, GD_S_BOX_PUSHING, what, x, y);
store_dir(cave, x, y, player_move + GD_MV_TWICE, O_BOX);
result = TRUE;
gd_sound_play(cave, GD_S_BOX_PUSHING, what, x, y);
GdDirection gd_direction_from_keypress(boolean up, boolean down, boolean left, boolean right)
{
GdDirection player_move;
GdDirection gd_direction_from_keypress(boolean up, boolean down, boolean left, boolean right)
{
GdDirection player_move;
if (is_space_dir(cave, x, y, falling_direction))
{
if (is_space_dir(cave, x, y, falling_direction))
{
play_sound_of_element(cave, get(cave, x, y), x, y);
move(cave, x, y, falling_direction, falling_element);
}
play_sound_of_element(cave, get(cave, x, y), x, y);
move(cave, x, y, falling_direction, falling_element);
}
- /* check if it is on a sloped element, and it can roll. */
- /* for example, sloped wall looks like: */
- /* /| */
- /* /_| */
- /* this is tagged as sloped up&left. */
- /* first check if the stone or diamond is coming from "up" (ie. opposite of gravity) */
- /* then check the direction to roll (left or right) */
- /* this way, gravity can also be pointing right, and the above slope will work as one would expect */
+ // check if it is on a sloped element, and it can roll.
+ // for example, sloped wall looks like:
+ // /|
+ // /_|
+ // this is tagged as sloped up&left.
+ // first check if the stone or diamond is coming from "up" (ie. opposite of gravity)
+ // then check the direction to roll (left or right)
+ // this way, gravity can also be pointing right, and the above slope will work as one would expect
else if (sloped_dir(cave, x, y, falling_direction, opposite[falling_direction]))
{
else if (sloped_dir(cave, x, y, falling_direction, opposite[falling_direction]))
{
if (sloped_dir(cave, x, y, falling_direction, cw_fourth[falling_direction]) &&
is_space_dir(cave, x, y, cw_fourth[falling_direction]) &&
is_space_dir(cave, x, y, cw_eighth[falling_direction]))
{
if (sloped_dir(cave, x, y, falling_direction, cw_fourth[falling_direction]) &&
is_space_dir(cave, x, y, cw_fourth[falling_direction]) &&
is_space_dir(cave, x, y, cw_eighth[falling_direction]))
{
- /* rolling left? - keep in mind that ccw_fourth rotates gravity ccw,
- so here we use cw_fourth */
+ // rolling left? - keep in mind that ccw_fourth rotates gravity ccw,
+ // so here we use cw_fourth
play_sound_of_element(cave, get(cave, x, y), x, y);
move(cave, x, y, cw_fourth[falling_direction], falling_element);
}
play_sound_of_element(cave, get(cave, x, y), x, y);
move(cave, x, y, cw_fourth[falling_direction], falling_element);
}
is_space_dir(cave, x, y, ccw_fourth[falling_direction]) &&
is_space_dir(cave, x, y, ccw_eighth[falling_direction]))
{
is_space_dir(cave, x, y, ccw_fourth[falling_direction]) &&
is_space_dir(cave, x, y, ccw_eighth[falling_direction]))
{
play_sound_of_element(cave, get(cave, x, y), x, y);
move(cave, x, y, ccw_fourth[falling_direction], falling_element);
}
play_sound_of_element(cave, get(cave, x, y), x, y);
move(cave, x, y, ccw_fourth[falling_direction], falling_element);
}
if (get_dir(cave, x, y, fall_dir) == O_VOODOO &&
cave->voodoo_dies_by_stone)
{
if (get_dir(cave, x, y, fall_dir) == O_VOODOO &&
cave->voodoo_dies_by_stone)
{
explode_dir(cave, x, y, fall_dir);
return TRUE;
}
explode_dir(cave, x, y, fall_dir);
return TRUE;
}
if (get_dir(cave, x, y, fall_dir) == O_VOODOO &&
cave->voodoo_collects_diamonds)
{
if (get_dir(cave, x, y, fall_dir) == O_VOODOO &&
cave->voodoo_collects_diamonds)
{
- /* this is a 1stB-style voodoo. explodes by stone, collects diamonds */
- player_get_element(cave, O_DIAMOND, x, y); /* as if player got diamond */
- store(cave, x, y, O_SPACE); /* diamond disappears */
+ // this is a 1stB-style voodoo. explodes by stone, collects diamonds
+ player_get_element(cave, O_DIAMOND, x, y); // as if player got diamond
+ store(cave, x, y, O_SPACE); // diamond disappears
if (get_dir(cave, x, y, fall_dir) == O_NUT ||
get_dir(cave, x, y, fall_dir) == O_NUT_F)
{
if (get_dir(cave, x, y, fall_dir) == O_NUT ||
get_dir(cave, x, y, fall_dir) == O_NUT_F)
{
store(cave, x, y, bouncing);
store_dir(cave, x, y, fall_dir, cave->nut_turns_to_when_crushed);
store(cave, x, y, bouncing);
store_dir(cave, x, y, fall_dir, cave->nut_turns_to_when_crushed);
{
if (get_dir(cave, x, y, fall_dir) == O_MAGIC_WALL)
{
{
if (get_dir(cave, x, y, fall_dir) == O_MAGIC_WALL)
{
- play_sound_of_element(cave, O_DIAMOND, x, y); /* always play diamond sound */
+ play_sound_of_element(cave, O_DIAMOND, x, y); // always play diamond sound
is_space_dir(cave, x, y, GD_MV_TWICE+fall_dir))
{
is_space_dir(cave, x, y, GD_MV_TWICE+fall_dir))
{
- /* if magic wall active and place underneath, it turns element
- into anything the effect says to do. */
+ // if magic wall active and place underneath, it turns element
+ // into anything the effect says to do.
store_dir(cave, x, y, GD_MV_TWICE+fall_dir, magic);
}
store_dir(cave, x, y, GD_MV_TWICE+fall_dir, magic);
}
store(cave, x, y, O_SPACE);
return TRUE;
store(cave, x, y, O_SPACE);
return TRUE;
{
if (is_space_dir(cave, x, y, fall_dir))
{
{
if (is_space_dir(cave, x, y, fall_dir))
{
move(cave, x, y, fall_dir, get(cave, x, y));
return TRUE;
}
move(cave, x, y, fall_dir, get(cave, x, y));
return TRUE;
}
- /* check if it is on a sloped element, and it can roll. */
- /* for example, sloped wall looks like: */
- /* /| */
- /* /_| */
- /* this is tagged as sloped up&left. */
- /* first check if the stone or diamond is coming from "up" (ie. opposite of gravity) */
- /* then check the direction to roll (left or right) */
- /* this way, gravity can also be pointing right, and the above slope will work as one would expect */
+ // check if it is on a sloped element, and it can roll.
+ // for example, sloped wall looks like:
+ // /|
+ // /_|
+ // this is tagged as sloped up&left.
+ // first check if the stone or diamond is coming from "up" (ie. opposite of gravity)
+ // then check the direction to roll (left or right)
+ // this way, gravity can also be pointing right, and the above slope will work as one would expect
if (sloped_dir(cave, x, y, fall_dir, opposite[fall_dir]))
{
if (sloped_dir(cave, x, y, fall_dir, opposite[fall_dir]))
{
if (sloped_dir(cave, x, y, fall_dir, cw_fourth[fall_dir]) &&
is_space_dir(cave, x, y, cw_eighth[fall_dir]) &&
is_space_dir(cave, x, y, cw_fourth[fall_dir]))
{
play_sound_of_element(cave, get(cave, x, y), x, y);
if (sloped_dir(cave, x, y, fall_dir, cw_fourth[fall_dir]) &&
is_space_dir(cave, x, y, cw_eighth[fall_dir]) &&
is_space_dir(cave, x, y, cw_fourth[fall_dir]))
{
play_sound_of_element(cave, get(cave, x, y), x, y);
move(cave, x, y, cw_fourth[fall_dir], get(cave, x, y));
}
else if (sloped_dir(cave, x, y, fall_dir, ccw_fourth[fall_dir]) &&
move(cave, x, y, cw_fourth[fall_dir], get(cave, x, y));
}
else if (sloped_dir(cave, x, y, fall_dir, ccw_fourth[fall_dir]) &&
{
play_sound_of_element(cave, get(cave, x, y), x, y);
{
play_sound_of_element(cave, get(cave, x, y), x, y);
move(cave, x, y, ccw_fourth[fall_dir], get(cave, x, y));
}
else
{
move(cave, x, y, ccw_fourth[fall_dir], get(cave, x, y));
}
else
{
play_sound_of_element(cave, get(cave, x, y), x, y);
store(cave, x, y, bouncing);
}
play_sound_of_element(cave, get(cave, x, y), x, y);
store(cave, x, y, bouncing);
}
play_sound_of_element(cave, get(cave, x, y), x, y);
store(cave, x, y, bouncing);
return TRUE;
play_sound_of_element(cave, get(cave, x, y), x, y);
store(cave, x, y, bouncing);
return TRUE;
cave->speed = (60 + 3.66 * cave->c64_timing + (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
break;
case GD_SCHEDULING_BD1_ATARI:
cave->speed = (60 + 3.66 * cave->c64_timing + (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
break;
case GD_SCHEDULING_BD1_ATARI:
cave->speed = MAX(65 + cave->ckdelay / 1000, cave->c64_timing * 20);
break;
case GD_SCHEDULING_BD2_PLCK_ATARI:
cave->speed = MAX(65 + cave->ckdelay / 1000, cave->c64_timing * 20);
break;
case GD_SCHEDULING_BD2_PLCK_ATARI:
- /* a really fast engine; timing works like c64 plck. */
- /* 40 ms was measured in the construction kit, with delay = 0 */
+ // a really fast engine; timing works like c64 plck.
+ // 40 ms was measured in the construction kit, with delay = 0
void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, boolean suicide)
{
int x, y, i;
void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, boolean suicide)
{
int x, y, i;
- /* if diagonal movements not allowed, */
- /* horizontal movements have precedence. [BROADRIBB] */
+ // if diagonal movements not allowed,
+ // horizontal movements have precedence. [BROADRIBB]
if (cave->player_seen_ago < 100)
cave->player_seen_ago++;
if (cave->pneumatic_hammer_active_delay > 0)
cave->pneumatic_hammer_active_delay--;
if (cave->player_seen_ago < 100)
cave->player_seen_ago++;
if (cave->pneumatic_hammer_active_delay > 0)
cave->pneumatic_hammer_active_delay--;
- /* inboxes and outboxes flash with the rhythm of the game, not the display.
- * also, a player can be born only from an open, not from a steel-wall-like inbox. */
+ // inboxes and outboxes flash with the rhythm of the game, not the display.
+ // also, a player can be born only from an open, not from a steel-wall-like inbox.
cave->inbox_flash_toggle = !cave->inbox_flash_toggle;
inbox_toggle = cave->inbox_flash_toggle;
if (cave->gate_open_flash > 0)
cave->gate_open_flash--;
cave->inbox_flash_toggle = !cave->inbox_flash_toggle;
inbox_toggle = cave->inbox_flash_toggle;
if (cave->gate_open_flash > 0)
cave->gate_open_flash--;
- /* suicide only kills the active player */
- /* player_x, player_y was set by the previous iterate routine, or the cave setup. */
- /* we must check if there is a player or not - he may have exploded or something like that */
+ // suicide only kills the active player
+ // player_x, player_y was set by the previous iterate routine, or the cave setup.
+ // we must check if there is a player or not - he may have exploded or something like that
if (suicide && cave->player_state == GD_PL_LIVING &&
is_player(cave, cave->player_x, cave->player_y))
store(cave, cave->player_x, cave->player_y, O_EXPLODE_1);
if (suicide && cave->player_state == GD_PL_LIVING &&
is_player(cave, cave->player_x, cave->player_y))
store(cave, cave->player_x, cave->player_y, O_EXPLODE_1);
if (cave->hammered_reappear)
{
for (y = 0; y < cave->h; y++)
{
for (x = 0; x < cave->w; x++)
{
if (cave->hammered_reappear)
{
for (y = 0; y < cave->h; y++)
{
for (x = 0; x < cave->w; x++)
{
if (cave->hammered_reappear[y][x] == 0)
{
store(cave, x, y, O_BRICK);
if (cave->hammered_reappear[y][x] == 0)
{
store(cave, x, y, O_BRICK);
- /* 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 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)
{
store(cave, x, y, get(cave, x, y) & ~SCANNED);
if (get(cave, x, y) & SCANNED)
{
store(cave, x, y, get(cave, x, y) & ~SCANNED);
- /* bd4 intermission caves have many players. so if one of them has exited,
- * do not change the flag anymore. so this if () is needed */
- if (cave->player_state!=GD_PL_EXITED)
+ // bd4 intermission caves have many players. so if one of them has exited,
+ // do not change the flag anymore. so this if () is needed
+ if (cave->player_state != GD_PL_EXITED)
- /* check for pneumatic hammer things */
- /* 1) press fire, 2) have pneumatic hammer 4) space on left or right
- for hammer 5) stand on something */
+ // check for pneumatic hammer things
+ // 1) press fire, 2) have pneumatic hammer 4) space on left or right
+ // for hammer 5) stand on something
if (player_fire && cave->got_pneumatic_hammer &&
is_space_dir(cave, x, y, player_move) &&
!is_space_dir(cave, x, y, GD_MV_DOWN))
if (player_fire && cave->got_pneumatic_hammer &&
is_space_dir(cave, x, y, player_move) &&
!is_space_dir(cave, x, y, GD_MV_DOWN))
cave->pneumatic_hammer_active_delay = cave->pneumatic_hammer_frame;
store_dir(cave, x, y, GD_MV_LEFT, O_PNEUMATIC_ACTIVE_LEFT);
store(cave, x, y, O_PLAYER_PNEUMATIC_LEFT);
cave->pneumatic_hammer_active_delay = cave->pneumatic_hammer_frame;
store_dir(cave, x, y, GD_MV_LEFT, O_PNEUMATIC_ACTIVE_LEFT);
store(cave, x, y, O_PLAYER_PNEUMATIC_LEFT);
cave->pneumatic_hammer_active_delay = cave->pneumatic_hammer_frame;
store_dir(cave, x, y, GD_MV_RIGHT, O_PNEUMATIC_ACTIVE_RIGHT);
store(cave, x, y, O_PLAYER_PNEUMATIC_RIGHT);
cave->pneumatic_hammer_active_delay = cave->pneumatic_hammer_frame;
store_dir(cave, x, y, GD_MV_RIGHT, O_PNEUMATIC_ACTIVE_RIGHT);
store(cave, x, y, O_PLAYER_PNEUMATIC_RIGHT);
GdElement what = get_dir(cave, x, y, player_move);
GdElement remains = what;
boolean push;
GdElement what = get_dir(cave, x, y, player_move);
GdElement remains = what;
boolean push;
- /* if we are 'eating' a teleporter, and the function returns true
- (teleporting worked), break here */
+ // if we are 'eating' a teleporter, and the function returns true
+ // (teleporting worked), break here
if (what == O_TELEPORTER && do_teleporter(cave, x, y, player_move))
break;
if (what == O_TELEPORTER && do_teleporter(cave, x, y, player_move))
break;
push = do_push(cave, x, y, player_move, player_fire);
if (push)
{
push = do_push(cave, x, y, player_move, player_fire);
if (push)
{
- /* if its a bomb, remember he now has one. */
- /* we do not change the "remains" and "what" variables,
- so that part of the code will be ineffective */
+ // if its a bomb, remember he now has one.
+ // we do not change the "remains" and "what" variables,
+ // so that part of the code will be ineffective
gd_sound_play(cave, GD_S_BOMB_COLLECTING, what, x, y);
store_dir(cave, x, y, player_move, O_SPACE);
gd_sound_play(cave, GD_S_BOMB_COLLECTING, what, x, y);
store_dir(cave, x, y, player_move, O_SPACE);
- /* we do not change the "remains" and "what" variables,
- so that part of the code will be ineffective */
+ // we do not change the "remains" and "what" variables,
+ // so that part of the code will be ineffective
if (!player_fire && !cave->gravity_switch_active &&
cave->skeletons_collected >= cave->skeletons_needed_for_pot)
{
if (!player_fire && !cave->gravity_switch_active &&
cave->skeletons_collected >= cave->skeletons_needed_for_pot)
{
- /* (we cannot use player_get for this as it does not have player_move parameter) */
- /* only allow changing direction if the new dir is not diagonal */
+ // (we cannot use player_get for this as it does not have player_move parameter)
+ // only allow changing direction if the new dir is not diagonal
if (cave->gravity_switch_active &&
(player_move == GD_MV_LEFT ||
player_move == GD_MV_RIGHT ||
if (cave->gravity_switch_active &&
(player_move == GD_MV_LEFT ||
player_move == GD_MV_RIGHT ||
- /* get element - process others.
- if cannot get, player_get_element will return the same */
+ // get element - process others.
+ // if cannot get, player_get_element will return the same
remains = player_get_element(cave, what, x, y);
break;
}
remains = player_get_element(cave, what, x, y);
break;
}
- /* if snapping anything and we have snapping explosions set.
- but these is not true for pushing. */
+ // if snapping anything and we have snapping explosions set.
+ // but these is not true for pushing.
if (remains == O_SPACE && player_fire && !push)
remains = cave->snap_element;
if (remains != O_SPACE || player_fire)
if (remains == O_SPACE && player_fire && !push)
remains = cave->snap_element;
if (remains != O_SPACE || player_fire)
- /* if any other element than space, player cannot move.
- also if pressing fire, will not move. */
+ // if any other element than space, player cannot move.
+ // also if pressing fire, will not move.
store_dir(cave, x, y, player_move, remains);
else
store_dir(cave, x, y, player_move, remains);
else
move(cave, x, y, player_move, O_PLAYER);
}
}
break;
case O_PLAYER_BOMB:
move(cave, x, y, player_move, O_PLAYER);
}
}
break;
case O_PLAYER_BOMB:
- /* bd4 intermission caves have many players. so if one of them has exited,
- * do not change the flag anymore. so this if () is needed */
+ // bd4 intermission caves have many players. so if one of them has exited,
+ // do not change the flag anymore. so this if () is needed
if (cave->player_state != GD_PL_EXITED)
cave->player_state = GD_PL_LIVING;
if (player_move != GD_MV_STILL)
{
if (cave->player_state != GD_PL_EXITED)
cave->player_state = GD_PL_LIVING;
if (player_move != GD_MV_STILL)
{
GdElement what = get_dir(cave, x, y, player_move);
GdElement remains = what;
if (player_fire)
{
GdElement what = get_dir(cave, x, y, player_move);
GdElement remains = what;
if (player_fire)
{
if (is_space_dir(cave, x, y, player_move) ||
is_element_dir(cave, x, y, player_move, O_DIRT))
{
store_dir(cave, x, y, player_move, O_BOMB_TICK_1);
if (is_space_dir(cave, x, y, player_move) ||
is_element_dir(cave, x, y, player_move, O_DIRT))
{
store_dir(cave, x, y, player_move, O_BOMB_TICK_1);
store(cave, x, y, O_PLAYER);
gd_sound_play(cave, GD_S_BOMB_PLACING, O_BOMB, x, y);
}
break;
}
store(cave, x, y, O_PLAYER);
gd_sound_play(cave, GD_S_BOMB_PLACING, O_BOMB, x, y);
}
break;
}
- /* pushing and collecting */
- /* if we are 'eating' a teleporter, and the function returns true
- (teleporting worked), break here */
+ // pushing and collecting
+ // if we are 'eating' a teleporter, and the function returns true
+ // (teleporting worked), break here
if (what == O_TELEPORTER && do_teleporter(cave, x, y, player_move))
break;
if (what == O_TELEPORTER && do_teleporter(cave, x, y, player_move))
break;
if (do_push(cave, x, y, player_move, FALSE))
{
remains = O_SPACE;
if (do_push(cave, x, y, player_move, FALSE))
{
remains = O_SPACE;
- /* (we cannot use player_get for this as it does not have
- player_move parameter) */
- /* only allow changing direction if the new dir is not diagonal */
+ // (we cannot use player_get for this as it does not have
+ // player_move parameter)
+ // only allow changing direction if the new dir is not diagonal
- (player_move==GD_MV_LEFT ||
- player_move==GD_MV_RIGHT ||
- player_move==GD_MV_UP ||
- player_move==GD_MV_DOWN))
+ (player_move == GD_MV_LEFT ||
+ player_move == GD_MV_RIGHT ||
+ player_move == GD_MV_UP ||
+ player_move == GD_MV_DOWN))
{
gd_sound_play(cave, GD_S_SWITCH_GRAVITY, what, x, y);
cave->gravity_will_change =
{
gd_sound_play(cave, GD_S_SWITCH_GRAVITY, what, x, y);
cave->gravity_will_change =
remains = player_get_element (cave, what, x, y);
break;
}
}
remains = player_get_element (cave, what, x, y);
break;
}
}
move(cave, x, y, player_move, O_PLAYER_BOMB);
}
}
move(cave, x, y, player_move, O_PLAYER_BOMB);
}
}
gd_sound_play(cave, GD_S_STIRRING, O_PLAYER_STIRRING, x, y);
cave->player_seen_ago = 0;
gd_sound_play(cave, GD_S_STIRRING, O_PLAYER_STIRRING, x, y);
cave->player_seen_ago = 0;
- /* bd4 intermission caves have many players. so if one of them has exited,
- * do not change the flag anymore. so this if () is needed */
- if (cave->player_state!=GD_PL_EXITED)
+ // bd4 intermission caves have many players. so if one of them has exited,
+ // do not change the flag anymore. so this if () is needed
+ if (cave->player_state != GD_PL_EXITED)
cave->gravity_disabled = FALSE;
store(cave, x, y, O_PLAYER);
cave->gravity_switch_active = TRUE;
}
break;
cave->gravity_disabled = FALSE;
store(cave, x, y, O_PLAYER);
cave->gravity_switch_active = TRUE;
}
break;
if (cave->pneumatic_hammer_active_delay == 0)
store(cave, x, y, O_PLAYER);
break;
if (cave->pneumatic_hammer_active_delay == 0)
store(cave, x, y, O_PLAYER);
break;
case O_PNEUMATIC_ACTIVE_RIGHT:
case O_PNEUMATIC_ACTIVE_LEFT:
if (cave->pneumatic_hammer_active_delay == 0)
{
GdElement new_elem;
case O_PNEUMATIC_ACTIVE_RIGHT:
case O_PNEUMATIC_ACTIVE_LEFT:
if (cave->pneumatic_hammer_active_delay == 0)
{
GdElement new_elem;
store(cave, x, y, O_SPACE);
store(cave, x, y, O_SPACE);
new_elem = gd_element_get_hammered(get_dir(cave, x, y, GD_MV_DOWN));
new_elem = gd_element_get_hammered(get_dir(cave, x, y, GD_MV_DOWN));
- /* if there is a new element, display it */
- /* O_NONE might be returned, for example if the element being
- hammered explodes during hammering (by a nearby explosion) */
+ // if there is a new element, display it
+ // O_NONE might be returned, for example if the element being
+ // hammered explodes during hammering (by a nearby explosion)
if (new_elem != O_NONE)
{
store_dir(cave, x, y, GD_MV_DOWN, new_elem);
if (new_elem != O_NONE)
{
store_dir(cave, x, y, GD_MV_DOWN, new_elem);
- /*
- * S T O N E S, D I A M O N D S
- */
- case O_STONE: /* standing stone */
+ // ============================================================================
+ // S T O N E S, D I A M O N D S
+ // ============================================================================
+
+ case O_STONE: // standing stone
do_start_fall(cave, x, y, cave->gravity, cave->stone_falling_effect);
break;
do_start_fall(cave, x, y, cave->gravity, cave->stone_falling_effect);
break;
do_start_fall(cave, x, y, cave->gravity, O_MEGA_STONE_F);
break;
do_start_fall(cave, x, y, cave->gravity, O_MEGA_STONE_F);
break;
do_start_fall(cave, x, y, cave->gravity, cave->diamond_falling_effect);
break;
do_start_fall(cave, x, y, cave->gravity, cave->diamond_falling_effect);
break;
do_start_fall(cave, x, y, cave->gravity, O_NUT_F);
break;
do_start_fall(cave, x, y, cave->gravity, O_NUT_F);
break;
do_start_fall(cave, x, y, cave->gravity, O_DIRT_BALL_F);
break;
do_start_fall(cave, x, y, cave->gravity, O_DIRT_BALL_F);
break;
do_start_fall(cave, x, y, cave->gravity, O_DIRT_LOOSE_F);
break;
do_start_fall(cave, x, y, cave->gravity, O_DIRT_LOOSE_F);
break;
do_start_fall(cave, x, y, opposite[cave->gravity], O_FLYING_STONE_F);
break;
do_start_fall(cave, x, y, opposite[cave->gravity], O_FLYING_STONE_F);
break;
do_start_fall(cave, x, y, opposite[cave->gravity], O_FLYING_DIAMOND_F);
break;
do_start_fall(cave, x, y, opposite[cave->gravity], O_FLYING_DIAMOND_F);
break;
- /*
- * F A L L I N G E L E M E N T S, F L Y I N G S T O N E S, D I A M O N D S
- */
- case O_DIRT_BALL_F: /* falling dirt ball */
+ // ============================================================================
+ // F A L L I N G E L E M E N T S, F L Y I N G S T O N E S, D I A M O N D S
+ // ============================================================================
+
+ case O_DIRT_BALL_F: // falling dirt ball
if (!cave->gravity_disabled)
do_fall_roll_or_stop(cave, x, y, cave->gravity, O_DIRT_BALL);
break;
if (!cave->gravity_disabled)
do_fall_roll_or_stop(cave, x, y, cave->gravity, O_DIRT_BALL);
break;
if (!cave->gravity_disabled)
do_fall_roll_or_stop(cave, x, y, cave->gravity, O_DIRT_LOOSE);
break;
if (!cave->gravity_disabled)
do_fall_roll_or_stop(cave, x, y, cave->gravity, O_DIRT_LOOSE);
break;
if (!cave->gravity_disabled)
{
if (do_fall_try_crush_voodoo(cave, x, y, cave->gravity))
if (!cave->gravity_disabled)
{
if (do_fall_try_crush_voodoo(cave, x, y, cave->gravity))
if (!cave->gravity_disabled)
{
if (do_fall_try_crush_voodoo(cave, x, y, cave->gravity))
if (!cave->gravity_disabled)
{
if (do_fall_try_crush_voodoo(cave, x, y, cave->gravity))
if (!cave->gravity_disabled)
{
if (do_fall_try_eat_voodoo(cave, x, y, cave->gravity))
if (!cave->gravity_disabled)
{
if (do_fall_try_eat_voodoo(cave, x, y, cave->gravity))
if (!cave->gravity_disabled)
{
if (do_fall_try_magic(cave, x, y, cave->gravity, cave->magic_nut_to))
if (!cave->gravity_disabled)
{
if (do_fall_try_magic(cave, x, y, cave->gravity, cave->magic_nut_to))
- /*
- * N I T R O P A C K
- */
- case O_NITRO_PACK: /* standing nitro pack */
+ // ============================================================================
+ // N I T R O P A C K
+ // ============================================================================
+
+ case O_NITRO_PACK: // standing nitro pack
do_start_fall(cave, x, y, cave->gravity, O_NITRO_PACK_F);
break;
do_start_fall(cave, x, y, cave->gravity, O_NITRO_PACK_F);
break;
- if (is_space_dir(cave, x, y, cave->gravity)) /* if space, falling further */
+ if (is_space_dir(cave, x, y, cave->gravity)) // if space, falling further
move(cave, x, y, cave->gravity, get(cave, x, y));
else if (do_fall_try_magic(cave, x, y, cave->gravity, cave->magic_nitro_pack_to))
{
move(cave, x, y, cave->gravity, get(cave, x, y));
else if (do_fall_try_magic(cave, x, y, cave->gravity, cave->magic_nitro_pack_to))
{
}
else if (is_element_dir(cave, x, y, cave->gravity, O_DIRT))
{
}
else if (is_element_dir(cave, x, y, cave->gravity, O_DIRT))
{
play_sound_of_element(cave, O_NITRO_PACK, x, y);
store(cave, x, y, O_NITRO_PACK);
}
else
play_sound_of_element(cave, O_NITRO_PACK, x, y);
store(cave, x, y, O_NITRO_PACK);
}
else
if (!is_space_dir(cave, x, y, GD_MV_UP) && !is_space_dir(cave, x, y, GD_MV_DOWN) &&
!is_space_dir(cave, x, y, GD_MV_LEFT) && !is_space_dir(cave, x, y, GD_MV_RIGHT))
store(cave, x, y, O_COW_ENCLOSED_1);
else
{
if (!is_space_dir(cave, x, y, GD_MV_UP) && !is_space_dir(cave, x, y, GD_MV_DOWN) &&
!is_space_dir(cave, x, y, GD_MV_LEFT) && !is_space_dir(cave, x, y, GD_MV_RIGHT))
store(cave, x, y, O_COW_ENCLOSED_1);
else
{
- boolean ccw = rotates_ccw(cave, x, y); /* check if default is counterclockwise */
- GdElement base; /* base element number (which is like O_***_1) */
- int dir, dirn, dirp; /* direction */
+ boolean ccw = rotates_ccw(cave, x, y); // check if default is counterclockwise
+ GdElement base; // base element number (which is like O_***_1)
+ int dir, dirn, dirp; // direction
}
if (is_space_dir(cave, x, y, creature_move[dirn]))
}
if (is_space_dir(cave, x, y, creature_move[dirn]))
- move(cave, x, y, creature_move[dirn], base + dirn); /* turn and move to preferred dir */
+ move(cave, x, y, creature_move[dirn], base + dirn); // turn and move to preferred dir
else if (is_space_dir(cave, x, y, creature_move[dir]))
else if (is_space_dir(cave, x, y, creature_move[dir]))
- move(cave, x, y, creature_move[dir], base + dir); /* go on */
+ move(cave, x, y, creature_move[dir], base + dir); // go on
- store(cave, x, y, base + dirp); /* turn in place if nothing else possible */
+ store(cave, x, y, base + dirp); // turn in place if nothing else possible
if (get_dir(cave, x, y, GD_MV_LEFT) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_RIGHT) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_UP) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_DOWN) == O_VOODOO)
cave->voodoo_touched = TRUE;
if (get_dir(cave, x, y, GD_MV_LEFT) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_RIGHT) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_UP) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_DOWN) == O_VOODOO)
cave->voodoo_touched = TRUE;
if (blows_up_flies_dir(cave, x, y, GD_MV_DOWN) ||
blows_up_flies_dir(cave, x, y, GD_MV_UP) ||
blows_up_flies_dir(cave, x, y, GD_MV_LEFT) ||
blows_up_flies_dir(cave, x, y, GD_MV_RIGHT))
explode (cave, x, y);
if (blows_up_flies_dir(cave, x, y, GD_MV_DOWN) ||
blows_up_flies_dir(cave, x, y, GD_MV_UP) ||
blows_up_flies_dir(cave, x, y, GD_MV_LEFT) ||
blows_up_flies_dir(cave, x, y, GD_MV_RIGHT))
explode (cave, x, y);
- boolean ccw = rotates_ccw(cave, x, y); /* check if default is counterclockwise */
- GdElement base; /* base element number (which is like O_***_1) */
- int dir, dirn, dirp; /* direction */
+ boolean ccw = rotates_ccw(cave, x, y); // check if default is counterclockwise
+ GdElement base = -1; // base element number (which is like O_***_1)
+ int dir, dirn, dirp; // direction
if (get(cave, x, y) >= O_FIREFLY_1 &&
get(cave, x, y) <= O_FIREFLY_4)
if (get(cave, x, y) >= O_FIREFLY_1 &&
get(cave, x, y) <= O_FIREFLY_4)
}
if (is_space_dir(cave, x, y, creature_move[dirn]))
}
if (is_space_dir(cave, x, y, creature_move[dirn]))
- move(cave, x, y, creature_move[dirn], base + dirn); /* turn and move to preferred dir */
+ move(cave, x, y, creature_move[dirn], base + dirn); // turn and move to preferred dir
else if (is_space_dir(cave, x, y, creature_move[dir]))
else if (is_space_dir(cave, x, y, creature_move[dir]))
- move(cave, x, y, creature_move[dir], base + dir); /* go on */
+ move(cave, x, y, creature_move[dir], base + dir); // go on
- store(cave, x, y, base + dirp); /* turn in place if nothing else possible */
+ store(cave, x, y, base + dirp); // turn in place if nothing else possible
}
break;
case O_WAITING_STONE:
if (is_space_dir(cave, x, y, grav_compat))
{
}
break;
case O_WAITING_STONE:
if (is_space_dir(cave, x, y, grav_compat))
{
move(cave, x, y, grav_compat, O_CHASING_STONE);
}
else if (sloped_dir(cave, x, y, grav_compat, opposite[grav_compat]))
{
move(cave, x, y, grav_compat, O_CHASING_STONE);
}
else if (sloped_dir(cave, x, y, grav_compat, opposite[grav_compat]))
{
if (sloped_dir(cave, x, y, grav_compat, cw_fourth[grav_compat]) &&
is_space_dir(cave, x, y, cw_fourth[grav_compat]) &&
is_space_dir(cave, x, y, cw_eighth[grav_compat]))
{
if (sloped_dir(cave, x, y, grav_compat, cw_fourth[grav_compat]) &&
is_space_dir(cave, x, y, cw_fourth[grav_compat]) &&
is_space_dir(cave, x, y, cw_eighth[grav_compat]))
{
move(cave, x, y, cw_fourth[grav_compat], O_WAITING_STONE);
}
else if (sloped_dir(cave, x, y, grav_compat, ccw_fourth[grav_compat]) &&
is_space_dir(cave, x, y, ccw_fourth[grav_compat]) &&
is_space_dir(cave, x, y, ccw_eighth[grav_compat]))
{
move(cave, x, y, cw_fourth[grav_compat], O_WAITING_STONE);
}
else if (sloped_dir(cave, x, y, grav_compat, ccw_fourth[grav_compat]) &&
is_space_dir(cave, x, y, ccw_fourth[grav_compat]) &&
is_space_dir(cave, x, y, ccw_eighth[grav_compat]))
{
move(cave, x, y, ccw_fourth[grav_compat], O_WAITING_STONE);
}
}
move(cave, x, y, ccw_fourth[grav_compat], O_WAITING_STONE);
}
}
- /*********************************/
- /* check for a horizontal movement */
+ // ------------------------------------------------------------
+ // check for a horizontal movement
+ // ------------------------------------------------------------
- /********************************/
- /* check for a vertical movement */
+ // ------------------------------------------------------------
+ // check for a vertical movement
+ // ------------------------------------------------------------
if (x >= px)
{
if (is_space_dir(cave, x, y, GD_MV_UP) &&
if (x >= px)
{
if (is_space_dir(cave, x, y, GD_MV_UP) &&
if (y >= py)
{
if (is_space_dir(cave, x, y, GD_MV_LEFT) &&
if (y >= py)
{
if (is_space_dir(cave, x, y, GD_MV_LEFT) &&
- /* only replicate, if space is under it. */
- /* do not replicate players! */
- /* also obeys gravity settings. */
- /* only replicate element if it is not a scanned one */
- /* do not replicate space... that condition looks like it
- makes no sense, but otherwise it generates SCANNED spaces,
- which cannot be "collected" by the player, so he cannot run
- under a replicator */
+ // only replicate, if space is under it.
+ // do not replicate players!
+ // also obeys gravity settings.
+ // only replicate element if it is not a scanned one
+ // do not replicate space... that condition looks like it
+ // makes no sense, but otherwise it generates SCANNED spaces,
+ // which cannot be "collected" by the player, so he cannot run
+ // under a replicator
if (is_space_dir(cave, x, y, cave->gravity) &&
!is_player_dir(cave, x, y, opposite[cave->gravity]) &&
!is_space_dir(cave, x, y, opposite[cave->gravity]))
if (is_space_dir(cave, x, y, cave->gravity) &&
!is_player_dir(cave, x, y, opposite[cave->gravity]) &&
!is_space_dir(cave, x, y, opposite[cave->gravity]))
int dir = get(cave, x, y) - O_BITER_1;
int dirn = (dir + 3) & 3;
int dirp = (dir + 1) & 3;
int i;
GdElement made_sound_of = O_NONE;
int dir = get(cave, x, y) - O_BITER_1;
int dirn = (dir + 3) & 3;
int dirp = (dir + 1) & 3;
int i;
GdElement made_sound_of = O_NONE;
{
if (is_element_dir(cave, x, y, biter_move[dir], biter_try[i]))
{
move(cave, x, y, biter_move[dir], O_BITER_1 + dir);
if (biter_try[i] != O_SPACE)
{
if (is_element_dir(cave, x, y, biter_move[dir], biter_try[i]))
{
move(cave, x, y, biter_move[dir], O_BITER_1 + dir);
if (biter_try[i] != O_SPACE)
break;
}
else if (is_element_dir(cave, x, y, biter_move[dirn], biter_try[i]))
{
move(cave, x, y, biter_move[dirn], O_BITER_1 + dirn);
if (biter_try[i] != O_SPACE)
break;
}
else if (is_element_dir(cave, x, y, biter_move[dirn], biter_try[i]))
{
move(cave, x, y, biter_move[dirn], O_BITER_1 + dirn);
if (biter_try[i] != O_SPACE)
break;
}
else if (is_element_dir(cave, x, y, biter_move[dirp], biter_try[i]))
{
move(cave, x, y, biter_move[dirp], O_BITER_1 + dirp);
if (biter_try[i] != O_SPACE)
break;
}
else if (is_element_dir(cave, x, y, biter_move[dirp], biter_try[i]))
{
move(cave, x, y, biter_move[dirp], O_BITER_1 + dirp);
if (biter_try[i] != O_SPACE)
- if (i == G_N_ELEMENTS(biter_try))
- /* i = number of elements in array: could not move, so just turn */
+ if (i == ARRAY_SIZE(biter_try))
+ // i = number of elements in array: could not move, so just turn
store(cave, x, y, O_BITER_1 + dirp);
else if (biter_try[i] == O_STONE)
{
store(cave, x, y, O_BITER_1 + dirp);
else if (biter_try[i] == O_STONE)
{
- /* if there was a stone there, where we moved...
- do not eat stones, just throw them back */
+ // if there was a stone there, where we moved...
+ // do not eat stones, just throw them back
store(cave, x, y, O_STONE);
made_sound_of = O_STONE;
}
store(cave, x, y, O_STONE);
made_sound_of = O_STONE;
}
if (made_sound_of != O_NONE)
play_sound_of_element(cave, made_sound_of, x, y);
}
if (made_sound_of != O_NONE)
play_sound_of_element(cave, made_sound_of, x, y);
}
if (get_dir(cave, x, y, GD_MV_LEFT) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_RIGHT) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_UP) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_DOWN) == O_VOODOO)
cave->voodoo_touched = TRUE;
if (get_dir(cave, x, y, GD_MV_LEFT) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_RIGHT) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_UP) == O_VOODOO ||
get_dir(cave, x, y, GD_MV_DOWN) == O_VOODOO)
cave->voodoo_touched = TRUE;
if (blows_up_flies_dir(cave, x, y, GD_MV_DOWN) ||
blows_up_flies_dir(cave, x, y, GD_MV_UP) ||
blows_up_flies_dir(cave, x, y, GD_MV_LEFT) ||
blows_up_flies_dir(cave, x, y, GD_MV_RIGHT))
explode (cave, x, y);
if (blows_up_flies_dir(cave, x, y, GD_MV_DOWN) ||
blows_up_flies_dir(cave, x, y, GD_MV_UP) ||
blows_up_flies_dir(cave, x, y, GD_MV_LEFT) ||
blows_up_flies_dir(cave, x, y, GD_MV_RIGHT))
explode (cave, x, y);
- boolean ccw = rotates_ccw(cave, x, y); /* check if default is counterclockwise */
- GdElement base = O_DRAGONFLY_1; /* base element number (which is like O_***_1) */
- int dir, dirn; /* direction */
+ boolean ccw = rotates_ccw(cave, x, y); // check if default is counterclockwise
+ GdElement base = O_DRAGONFLY_1; // base element number (which is like O_***_1)
+ int dir, dirn; // direction
if (is_space_dir(cave, x, y, creature_move[dir]))
move(cave, x, y, creature_move[dir], base + dir);
else
if (is_space_dir(cave, x, y, creature_move[dir]))
move(cave, x, y, creature_move[dir], base + dir);
else
store(cave, x, y, base + dirn);
}
break;
store(cave, x, y, base + dirn);
}
break;
if (is_element_dir(cave, x, y, opposite[grav_compat], cave->bladder_converts_by) ||
is_element_dir(cave, x, y, cw_fourth[grav_compat], cave->bladder_converts_by) || is_element_dir(cave, x, y, ccw_fourth[grav_compat], cave->bladder_converts_by))
{
if (is_element_dir(cave, x, y, opposite[grav_compat], cave->bladder_converts_by) ||
is_element_dir(cave, x, y, cw_fourth[grav_compat], cave->bladder_converts_by) || is_element_dir(cave, x, y, ccw_fourth[grav_compat], cave->bladder_converts_by))
{
store(cave, x, y, O_PRE_CLOCK_1);
store(cave, x, y, O_PRE_CLOCK_1);
play_sound_of_element(cave, O_PRE_CLOCK_1, x, y);
}
else
{
play_sound_of_element(cave, O_PRE_CLOCK_1, x, y);
}
else
{
if (is_space_dir(cave, x, y, opposite[grav_compat]))
{
if (is_space_dir(cave, x, y, opposite[grav_compat]))
{
move(cave, x, y, opposite[grav_compat], O_BLADDER_1);
play_sound_of_element(cave, O_BLADDER, x, y);
}
else
move(cave, x, y, opposite[grav_compat], O_BLADDER_1);
play_sound_of_element(cave, O_BLADDER, x, y);
}
else
if (sloped_for_bladder_dir(cave, x, y, opposite[grav_compat]) &&
sloped_dir(cave, x, y, opposite[grav_compat], opposite[grav_compat]))
{
if (sloped_for_bladder_dir(cave, x, y, opposite[grav_compat]) &&
sloped_dir(cave, x, y, opposite[grav_compat], opposite[grav_compat]))
{
is_space_dir(cave, x, y, ccw_fourth[opposite[grav_compat]]) &&
is_space_dir(cave, x, y, ccw_eighth[opposite[grav_compat]]))
{
is_space_dir(cave, x, y, ccw_fourth[opposite[grav_compat]]) &&
is_space_dir(cave, x, y, ccw_eighth[opposite[grav_compat]]))
{
move(cave, x, y, ccw_fourth[opposite[grav_compat]], O_BLADDER_8);
play_sound_of_element(cave, O_BLADDER, x, y);
}
else
move(cave, x, y, ccw_fourth[opposite[grav_compat]], O_BLADDER_8);
play_sound_of_element(cave, O_BLADDER, x, y);
}
else
next(cave, x, y);
}
else if (sloped_dir(cave, x, y, opposite[grav_compat], cw_fourth[opposite[grav_compat]]) &&
is_space_dir(cave, x, y, cw_fourth[opposite[grav_compat]]) &&
is_space_dir(cave, x, y, cw_eighth[opposite[grav_compat]]))
{
next(cave, x, y);
}
else if (sloped_dir(cave, x, y, opposite[grav_compat], cw_fourth[opposite[grav_compat]]) &&
is_space_dir(cave, x, y, cw_fourth[opposite[grav_compat]]) &&
is_space_dir(cave, x, y, cw_eighth[opposite[grav_compat]]))
{
move(cave, x, y, cw_fourth[opposite[grav_compat]], O_BLADDER_8);
play_sound_of_element(cave, O_BLADDER, x, y);
}
else
move(cave, x, y, cw_fourth[opposite[grav_compat]], O_BLADDER_8);
play_sound_of_element(cave, O_BLADDER, x, y);
}
else
else
store(cave, x, y, O_BLADDER_1);
}
else
store(cave, x, y, O_BLADDER_1);
}
if (is_space_dir(cave, x, y, random_dir))
{
move(cave, x, y, random_dir, O_GHOST);
if (is_space_dir(cave, x, y, random_dir))
{
move(cave, x, y, random_dir, O_GHOST);
- /*
- * A C T I V E E L E M E N T S
- */
+ // ============================================================================
+ // A C T I V E E L E M E N T S
+ // ============================================================================
- /* if still found enclosed, check all four directions,
- if this one is able to grow. */
+ // if still found enclosed, check all four directions, if this one is able to grow.
if (amoeba_eats_dir(cave, x, y, GD_MV_UP) ||
amoeba_eats_dir(cave, x, y, GD_MV_DOWN) ||
amoeba_eats_dir(cave, x, y, GD_MV_LEFT) ||
amoeba_eats_dir(cave, x, y, GD_MV_RIGHT))
{
if (amoeba_eats_dir(cave, x, y, GD_MV_UP) ||
amoeba_eats_dir(cave, x, y, GD_MV_DOWN) ||
amoeba_eats_dir(cave, x, y, GD_MV_LEFT) ||
amoeba_eats_dir(cave, x, y, GD_MV_RIGHT))
{
- /* if alive, check in which dir to grow (or not) */
- if (cave->amoeba_state==GD_AM_AWAKE)
+ // if alive, check in which dir to grow (or not)
+ if (cave->amoeba_state == GD_AM_AWAKE)
- /* decided to grow, choose a random direction. */
- case 0: /* let this be up. numbers indifferent. */
+ // decided to grow, choose a random direction.
+ case 0: // let this be up. numbers indifferent.
if (amoeba_eats_dir(cave, x, y, GD_MV_UP))
store_dir(cave, x, y, GD_MV_UP, O_AMOEBA);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_UP))
store_dir(cave, x, y, GD_MV_UP, O_AMOEBA);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_DOWN))
store_dir(cave, x, y, GD_MV_DOWN, O_AMOEBA);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_DOWN))
store_dir(cave, x, y, GD_MV_DOWN, O_AMOEBA);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_LEFT))
store_dir(cave, x, y, GD_MV_LEFT, O_AMOEBA);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_LEFT))
store_dir(cave, x, y, GD_MV_LEFT, O_AMOEBA);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_RIGHT))
store_dir(cave, x, y, GD_MV_RIGHT, O_AMOEBA);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_RIGHT))
store_dir(cave, x, y, GD_MV_RIGHT, O_AMOEBA);
break;
if (cave->amoeba_2_explodes_by_amoeba &&
(is_element_dir(cave, x, y, GD_MV_DOWN, O_AMOEBA) ||
is_element_dir(cave, x, y, GD_MV_UP, O_AMOEBA) ||
if (cave->amoeba_2_explodes_by_amoeba &&
(is_element_dir(cave, x, y, GD_MV_DOWN, O_AMOEBA) ||
is_element_dir(cave, x, y, GD_MV_UP, O_AMOEBA) ||
if (amoeba_2_found_enclosed)
if (amoeba_eats_dir(cave, x, y, GD_MV_UP) ||
amoeba_eats_dir(cave, x, y, GD_MV_DOWN) ||
amoeba_eats_dir(cave, x, y, GD_MV_LEFT) ||
amoeba_eats_dir(cave, x, y, GD_MV_RIGHT))
{
if (amoeba_2_found_enclosed)
if (amoeba_eats_dir(cave, x, y, GD_MV_UP) ||
amoeba_eats_dir(cave, x, y, GD_MV_DOWN) ||
amoeba_eats_dir(cave, x, y, GD_MV_LEFT) ||
amoeba_eats_dir(cave, x, y, GD_MV_RIGHT))
{
- /* decided to grow, choose a random direction. */
- case 0: /* let this be up. numbers indifferent. */
+ // decided to grow, choose a random direction.
+ case 0: // let this be up. numbers indifferent.
if (amoeba_eats_dir(cave, x, y, GD_MV_UP))
store_dir(cave, x, y, GD_MV_UP, O_AMOEBA_2);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_UP))
store_dir(cave, x, y, GD_MV_UP, O_AMOEBA_2);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_DOWN))
store_dir(cave, x, y, GD_MV_DOWN, O_AMOEBA_2);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_DOWN))
store_dir(cave, x, y, GD_MV_DOWN, O_AMOEBA_2);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_LEFT))
store_dir(cave, x, y, GD_MV_LEFT, O_AMOEBA_2);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_LEFT))
store_dir(cave, x, y, GD_MV_LEFT, O_AMOEBA_2);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_RIGHT))
store_dir(cave, x, y, GD_MV_RIGHT, O_AMOEBA_2);
break;
if (amoeba_eats_dir(cave, x, y, GD_MV_RIGHT))
store_dir(cave, x, y, GD_MV_RIGHT, O_AMOEBA_2);
break;
- /* choose randomly, if it spreads */
- if (g_rand_int_range(cave->random, 0, 1000000) <= cave->acid_spread_ratio)
+ // choose randomly, if it spreads
+ if (gd_rand_int_range(cave->random, 0, 1000000) <= cave->acid_spread_ratio)
store(cave, x, y, cave->acid_turns_to);
store(cave, x, y, cave->acid_turns_to);
if (is_element_dir(cave, x, y, GD_MV_UP, cave->acid_eats_this))
{
play_sound_of_element(cave, O_ACID, x, y);
if (is_element_dir(cave, x, y, GD_MV_UP, cave->acid_eats_this))
{
play_sound_of_element(cave, O_ACID, x, y);
found_water = TRUE;
if (!cave->water_does_not_flow_down &&
is_space_dir(cave, x, y, GD_MV_DOWN))
found_water = TRUE;
if (!cave->water_does_not_flow_down &&
is_space_dir(cave, x, y, GD_MV_DOWN))
store_dir(cave, x, y, GD_MV_DOWN, O_WATER_1);
if (is_space_dir(cave, x, y, GD_MV_UP))
store_dir(cave, x, y, GD_MV_DOWN, O_WATER_1);
if (is_space_dir(cave, x, y, GD_MV_UP))
if (((get(cave, x, y) == O_H_EXPANDING_WALL ||
get(cave, x, y) == O_H_EXPANDING_STEEL_WALL) &&
!cave->expanding_wall_changed) ||
if (((get(cave, x, y) == O_H_EXPANDING_WALL ||
get(cave, x, y) == O_H_EXPANDING_STEEL_WALL) &&
!cave->expanding_wall_changed) ||
- ((get(cave, x, y)==O_V_EXPANDING_WALL ||
- get(cave, x, y)==O_V_EXPANDING_STEEL_WALL) &&
+ ((get(cave, x, y) == O_V_EXPANDING_WALL ||
+ get(cave, x, y) == O_V_EXPANDING_STEEL_WALL) &&
cave->expanding_wall_changed))
{
if (is_space_dir(cave, x, y, GD_MV_LEFT))
cave->expanding_wall_changed))
{
if (is_space_dir(cave, x, y, GD_MV_LEFT))
if (is_space_dir(cave, x, y, GD_MV_LEFT))
{
store_dir(cave, x, y, GD_MV_LEFT, get(cave, x, y));
if (is_space_dir(cave, x, y, GD_MV_LEFT))
{
store_dir(cave, x, y, GD_MV_LEFT, get(cave, x, y));
- g_print(".Rand[%03d].Perm[%03d].Result[%d]\n", rrr, cave->slime_permeability_c64,
- (rrr & cave->slime_permeability_c64) == 0);
+ Info(".Rand[%03d].Perm[%03d].Result[%d]\n", rrr, cave->slime_permeability_c64,
+ (rrr & cave->slime_permeability_c64) == 0);
* predictable: c64 predictable random generator.
* for predictable, a random number is generated,
* whether or not it is even possible that the stone will be able to pass.
*/
* predictable: c64 predictable random generator.
* for predictable, a random number is generated,
* whether or not it is even possible that the stone will be able to pass.
*/
- if (cave->slime_predictable ? ((rrr /* XXX */ & cave->slime_permeability_c64) == 0) : g_rand_int_range(cave->random, 0, 1000000) < cave->slime_permeability)
+ if (cave->slime_predictable ? ((rrr /* XXX */ & cave->slime_permeability_c64) == 0) : gd_rand_int_range(cave->random, 0, 1000000) < cave->slime_permeability)
if (is_space_dir(cave, x, y, grav))
{
if (get_dir(cave, x, y, oppos) == cave->slime_eats_1)
{
if (is_space_dir(cave, x, y, grav))
{
if (get_dir(cave, x, y, oppos) == cave->slime_eats_1)
{
store_dir(cave, x, y, grav, cave->slime_converts_1);
store_dir(cave, x, y, oppos, O_SPACE);
store_dir(cave, x, y, grav, cave->slime_converts_1);
store_dir(cave, x, y, oppos, O_SPACE);
}
else if (get_dir(cave, x, y, oppos) == O_WAITING_STONE)
{
}
else if (get_dir(cave, x, y, oppos) == O_WAITING_STONE)
{
store_dir(cave, x, y, grav, O_WAITING_STONE);
store_dir(cave, x, y, oppos, O_SPACE);
play_sound_of_element(cave, O_SLIME, x, y);
}
else if (get_dir(cave, x, y, oppos) == O_CHASING_STONE)
{
store_dir(cave, x, y, grav, O_WAITING_STONE);
store_dir(cave, x, y, oppos, O_SPACE);
play_sound_of_element(cave, O_SLIME, x, y);
}
else if (get_dir(cave, x, y, oppos) == O_CHASING_STONE)
{
store_dir(cave, x, y, grav, O_CHASING_STONE);
store_dir(cave, x, y, oppos, O_SPACE);
play_sound_of_element(cave, O_SLIME, x, y);
}
}
else
store_dir(cave, x, y, grav, O_CHASING_STONE);
store_dir(cave, x, y, oppos, O_SPACE);
play_sound_of_element(cave, O_SLIME, x, y);
}
}
else
if (is_space_dir(cave, x, y, oppos))
{
if (get_dir(cave, x, y, grav) == O_BLADDER)
{
if (is_space_dir(cave, x, y, oppos))
{
if (get_dir(cave, x, y, grav) == O_BLADDER)
{
store_dir(cave, x, y, grav, O_SPACE);
store_dir(cave, x, y, oppos, O_BLADDER_1);
play_sound_of_element(cave, O_SLIME, x, y);
}
store_dir(cave, x, y, grav, O_SPACE);
store_dir(cave, x, y, oppos, O_BLADDER_1);
play_sound_of_element(cave, O_SLIME, x, y);
}
- else if (get_dir(cave, x, y, grav)==O_FLYING_STONE)
+ else if (get_dir(cave, x, y, grav) == O_FLYING_STONE)
{
store_dir(cave, x, y, grav, O_SPACE);
store_dir(cave, x, y, oppos, O_FLYING_STONE_F);
play_sound_of_element(cave, O_SLIME, x, y);
}
{
store_dir(cave, x, y, grav, O_SPACE);
store_dir(cave, x, y, oppos, O_FLYING_STONE_F);
play_sound_of_element(cave, O_SLIME, x, y);
}
- else if (get_dir(cave, x, y, grav)==O_FLYING_DIAMOND)
+ else if (get_dir(cave, x, y, grav) == O_FLYING_DIAMOND)
{
store_dir(cave, x, y, grav, O_SPACE);
store_dir(cave, x, y, oppos, O_FLYING_DIAMOND_F);
play_sound_of_element(cave, O_SLIME, x, y);
}
}
{
store_dir(cave, x, y, grav, O_SPACE);
store_dir(cave, x, y, oppos, O_FLYING_DIAMOND_F);
play_sound_of_element(cave, O_SLIME, x, y);
}
}
}
break;
case O_FALLING_WALL:
if (is_space_dir(cave, x, y, grav_compat))
{
}
break;
case O_FALLING_WALL:
if (is_space_dir(cave, x, y, grav_compat))
{
if (get(cave, x, yy) == O_PLAYER ||
get(cave, x, yy) == O_PLAYER_GLUED ||
get(cave, x, yy) == O_PLAYER_BOMB)
{
move(cave, x, y, grav_compat, O_FALLING_WALL_F);
if (get(cave, x, yy) == O_PLAYER ||
get(cave, x, yy) == O_PLAYER_GLUED ||
get(cave, x, yy) == O_PLAYER_BOMB)
{
move(cave, x, y, grav_compat, O_FALLING_WALL_F);
move(cave, x, y, grav_compat, O_FALLING_WALL_F);
break;
default:
move(cave, x, y, grav_compat, O_FALLING_WALL_F);
break;
default:
play_sound_of_element(cave, get(cave, x, y), x, y);
store(cave, x, y, O_FALLING_WALL);
break;
}
break;
play_sound_of_element(cave, get(cave, x, y), x, y);
store(cave, x, y, O_FALLING_WALL);
break;
}
break;
- /*
- * C O N V E Y O R B E L T S
- */
+ // ============================================================================
+ // C O N V E Y O R B E L T S
+ // ============================================================================
- /* only works if gravity is up or down!!! */
- /* first, check for gravity and running belts. */
+ // only works if gravity is up or down!!!
+ // first, check for gravity and running belts.
left = get(cave, x, y) != O_CONVEYOR_RIGHT;
if (cave->conveyor_belts_direction_changed)
left = !left;
dir = left ? ccw_eighth : cw_eighth;
left = get(cave, x, y) != O_CONVEYOR_RIGHT;
if (cave->conveyor_belts_direction_changed)
left = !left;
dir = left ? ccw_eighth : cw_eighth;
- /* CHECK IF IT CONVEYS THE ELEMENT ABOVE IT */
- /* if gravity is normal, and the conveyor belt has something
- ABOVE which can be moved
- OR
- the gravity is up, so anything that should float now goes
- DOWN and touches the conveyor */
+ // CHECK IF IT CONVEYS THE ELEMENT ABOVE IT
+ // if gravity is normal, and the conveyor belt has something
+ // ABOVE which can be moved
+ // OR
+ // the gravity is up, so anything that should float now goes
+ // DOWN and touches the conveyor
if ((cave->gravity == GD_MV_DOWN &&
moved_by_conveyor_top_dir(cave, x, y, GD_MV_UP)) ||
(cave->gravity == GD_MV_UP &&
if ((cave->gravity == GD_MV_DOWN &&
moved_by_conveyor_top_dir(cave, x, y, GD_MV_UP)) ||
(cave->gravity == GD_MV_UP &&
if (!is_scanned_dir(cave, x, y, GD_MV_UP) &&
is_space_dir(cave, x, y, dir[GD_MV_UP]))
{
if (!is_scanned_dir(cave, x, y, GD_MV_UP) &&
is_space_dir(cave, x, y, dir[GD_MV_UP]))
{
- store_dir(cave, x, y, dir[GD_MV_UP], get_dir(cave, x, y, GD_MV_UP)); /* move */
- store_dir(cave, x, y, GD_MV_UP, O_SPACE); /* and place a space. */
+ store_dir(cave, x, y, dir[GD_MV_UP], get_dir(cave, x, y, GD_MV_UP)); // move
+ store_dir(cave, x, y, GD_MV_UP, O_SPACE); // and place a space.
if ((cave->gravity == GD_MV_UP &&
moved_by_conveyor_top_dir(cave, x, y, GD_MV_DOWN)) ||
(cave->gravity == GD_MV_DOWN &&
if ((cave->gravity == GD_MV_UP &&
moved_by_conveyor_top_dir(cave, x, y, GD_MV_DOWN)) ||
(cave->gravity == GD_MV_DOWN &&
if (!is_scanned_dir(cave, x, y, GD_MV_DOWN) &&
is_space_dir(cave, x, y, dir[GD_MV_DOWN]))
{
if (!is_scanned_dir(cave, x, y, GD_MV_DOWN) &&
is_space_dir(cave, x, y, dir[GD_MV_DOWN]))
{
- store_dir(cave, x, y, dir[GD_MV_DOWN], get_dir(cave, x, y, GD_MV_DOWN)); /* move */
- store_dir(cave, x, y, GD_MV_DOWN, O_SPACE); /* and clear. */
+ store_dir(cave, x, y, dir[GD_MV_DOWN], get_dir(cave, x, y, GD_MV_DOWN)); // move
+ store_dir(cave, x, y, GD_MV_DOWN, O_SPACE); // and clear.
- /*
- * S I M P L E C H A N G I N G; E X P L O S I O N S
- */
+ // ============================================================================
+ // S I M P L E C H A N G I N G; E X P L O S I O N S
+ // ============================================================================
case O_EXPLODE_5:
store(cave, x, y, cave->explosion_effect);
case O_EXPLODE_5:
store(cave, x, y, cave->explosion_effect);
- store(cave, x, y, ghost_explode[g_rand_int_range(cave->random, 0, G_N_ELEMENTS(ghost_explode))]);
+ store(cave, x, y, ghost_explode[gd_rand_int_range(cave->random, 0, ARRAY_SIZE(ghost_explode))]);
- if (cave->gate_open) /* if no more diamonds needed */
- store(cave, x, y, O_OUTBOX); /* open outbox */
+ if (cave->gate_open) // if no more diamonds needed
+ store(cave, x, y, O_OUTBOX); // open outbox
- if (cave->gate_open) /* if no more diamonds needed */
- store(cave, x, y, O_INVIS_OUTBOX); /* open outbox. invisible one :P */
+ if (cave->gate_open) // if no more diamonds needed
+ store(cave, x, y, O_INVIS_OUTBOX); // open outbox. invisible one :P
store(cave, x, y, O_PRE_PL_1);
inbox_toggle = !inbox_toggle;
break;
store(cave, x, y, O_PRE_PL_1);
inbox_toggle = !inbox_toggle;
break;
- /* another scan-like routine: */
- /* short explosions (for example, in bd1) started with explode_2. */
- /* internally we use explode_1; and change it to explode_2 if needed. */
+ // ============================================================================
+ // POSTPROCESSING
+ // ============================================================================
+
+ // another scan-like routine:
+ // short explosions (for example, in bd1) started with explode_2.
+ // internally we use explode_1; and change it to explode_2 if needed.
store(cave, x, y, get(cave, x, y) & ~SCANNED);
}
}
}
}
store(cave, x, y, get(cave, x, y) & ~SCANNED);
}
}
}
}
- /* finally: forget "scanned" flags for objects. */
- /* also, check for time penalties. */
- /* these is something like an effect table, but we do not really use one. */
+ // finally: forget "scanned" flags for objects.
+ // also, check for time penalties.
+ // these is something like an effect table, but we do not really use one.
{
store(cave, x, y, O_GRAVESTONE);
{
store(cave, x, y, O_GRAVESTONE);
- /* this loop finds the coordinates of the player. needed for scrolling and chasing stone.*/
- /* but we only do this, if a living player was found. if not yet, the setup
- routine coordinates are used */
- if (cave->player_state==GD_PL_LIVING)
+ // this loop finds the coordinates of the player. needed for scrolling and chasing stone.
+ // but we only do this, if a living player was found. if not yet, the setup
+ // routine coordinates are used
+ if (cave->player_state == GD_PL_LIVING)
for (y = cave->h - 1; y >= 0; y--)
{
for (x = cave->w - 1; x >= 0; x--)
{
if (is_player(cave, x, y))
{
for (y = cave->h - 1; y >= 0; y--)
{
for (x = cave->w - 1; x >= 0; x--)
{
if (is_player(cave, x, y))
{
for (y = 0; y < cave->h; y++)
{
for (x = 0; x < cave->w; x++)
{
if (is_player(cave, x, y))
{
for (y = 0; y < cave->h; y++)
{
for (x = 0; x < cave->w; x++)
{
if (is_player(cave, x, y))
{
- /* record coordinates of player for chasing stone */
- for (i = 0; i < G_N_ELEMENTS(cave->px) - 1; i++)
+ // record coordinates of player for chasing stone
+ for (i = 0; i < ARRAY_SIZE(cave->px) - 1; i++)
- cave->px[G_N_ELEMENTS(cave->px) - 1] = cave->player_x;
- cave->py[G_N_ELEMENTS(cave->py) - 1] = cave->player_y;
+ cave->px[ARRAY_SIZE(cave->px) - 1] = cave->player_x;
+ cave->py[ARRAY_SIZE(cave->py) - 1] = cave->player_y;
- /* cave 3 sounds. precedence is controlled by the sound_play function. */
- /* but we have to check amoeba&magic together as they had a different gritty sound when mixed */
+ // cave 3 sounds. precedence is controlled by the sound_play function.
+ // but we have to check amoeba&magic together as they had a different gritty sound when mixed
if (found_water)
gd_sound_play(cave, GD_S_WATER, O_WATER, -1, -1);
if (found_water)
gd_sound_play(cave, GD_S_WATER, O_WATER, -1, -1);
play_sound_of_element(cave, O_AMOEBA, x, y);
}
play_sound_of_element(cave, O_AMOEBA, x, y);
}
if (cave->pneumatic_hammer_active_delay > 0)
gd_sound_play(cave, GD_S_PNEUMATIC_HAMMER, O_PNEUMATIC_HAMMER, -1, -1);
if (cave->pneumatic_hammer_active_delay > 0)
gd_sound_play(cave, GD_S_PNEUMATIC_HAMMER, O_PNEUMATIC_HAMMER, -1, -1);
- /* check if player is alive. */
- if ((cave->player_state == GD_PL_LIVING && cave->player_seen_ago > 15) || cave->kill_player)
+ // check if player is alive.
+ if ((cave->player_state == GD_PL_LIVING && cave->player_seen_ago > 1) || cave->kill_player)
if (cave->magic_wall_stops_amoeba && cave->magic_wall_state == GD_MW_ACTIVE)
cave->amoeba_state = GD_AM_ENCLOSED;
if (cave->magic_wall_stops_amoeba && cave->magic_wall_state == GD_MW_ACTIVE)
cave->amoeba_state = GD_AM_ENCLOSED;
if (cave->magic_wall_stops_amoeba && cave->magic_wall_state == GD_MW_ACTIVE)
cave->amoeba_2_state = GD_AM_ENCLOSED;
if (cave->magic_wall_stops_amoeba && cave->magic_wall_state == GD_MW_ACTIVE)
cave->amoeba_2_state = GD_AM_ENCLOSED;
gd_sound_play(cave, GD_S_NONE, O_NONE, -1, -1);
if (secondsbefore != secondsafter)
gd_cave_set_seconds_sound(cave);
}
gd_sound_play(cave, GD_S_NONE, O_NONE, -1, -1);
if (secondsbefore != secondsafter)
gd_cave_set_seconds_sound(cave);
}
- gd_sound_play(cave, GD_S_GRAVITY_CHANGING, O_GRAVITY_SWITCH, -1, -1); /* takes precedence over amoeba and magic wall sound */
+ gd_sound_play(cave, GD_S_GRAVITY_CHANGING, O_GRAVITY_SWITCH, -1, -1); // takes precedence over amoeba and magic wall sound
if (cave->magic_wall_state == GD_MW_ACTIVE &&
(cave->hatched || !cave->magic_timer_wait_for_hatching))
{
if (cave->magic_wall_state == GD_MW_ACTIVE &&
(cave->hatched || !cave->magic_timer_wait_for_hatching))
{
if (cave->amoeba_timer_started_immediately ||
(cave->amoeba_state == GD_AM_AWAKE &&
(cave->hatched || !cave->amoeba_timer_wait_for_hatching)))
if (cave->amoeba_timer_started_immediately ||
(cave->amoeba_state == GD_AM_AWAKE &&
(cave->hatched || !cave->amoeba_timer_wait_for_hatching)))
if (cave->amoeba_timer_started_immediately ||
(cave->amoeba_2_state == GD_AM_AWAKE &&
(cave->hatched || !cave->amoeba_timer_wait_for_hatching)))
if (cave->amoeba_timer_started_immediately ||
(cave->amoeba_2_state == GD_AM_AWAKE &&
(cave->hatched || !cave->amoeba_timer_wait_for_hatching)))
- /* if not the c64 scheduling, but the correct frametime is used,
- hatching delay should always be decremented. */
- /* otherwise, the if (millisecs...) condition below will set this. */
+ // if not the c64 scheduling, but the correct frametime is used,
+ // hatching delay should always be decremented.
+ // otherwise, the if (millisecs...) condition below will set this.
gd_sound_play(cave, GD_S_CRACKING, O_INBOX, -1, -1);
}
gd_sound_play(cave, GD_S_CRACKING, O_INBOX, -1, -1);
}
if (cave->biters_wait_frame == 0)
cave->biters_wait_frame = cave->biter_delay_frame;
else
cave->biters_wait_frame--;
if (cave->biters_wait_frame == 0)
cave->biters_wait_frame = cave->biter_delay_frame;
else
cave->biters_wait_frame--;
if (cave->replicators_wait_frame == 0)
cave->replicators_wait_frame = cave->replicator_delay_frame;
else
cave->replicators_wait_frame--;
if (cave->replicators_wait_frame == 0)
cave->replicators_wait_frame = cave->replicator_delay_frame;
else
cave->replicators_wait_frame--;
- /* here we remember last movements for animation. this is needed here,
- as animation is in sync with the game, not the keyboard directly.
- (for example, after exiting the cave, the player was "running" in the
- original, till bonus points were counted for remaining time and so on. */
+
+ // here we remember last movements for animation. this is needed here,
+ // as animation is in sync with the game, not the keyboard directly.
+ // (for example, after exiting the cave, the player was "running" in the
+ // original, till bonus points were counted for remaining time and so on.
if (player_move == GD_MV_LEFT ||
player_move == GD_MV_UP_LEFT ||
player_move == GD_MV_DOWN_LEFT)
if (player_move == GD_MV_LEFT ||
player_move == GD_MV_UP_LEFT ||
player_move == GD_MV_DOWN_LEFT)