* The player_get function will also behave for lava as it does for space.
*/
-#include <glib.h>
-
#include "main_bd.h"
}
if (is_space_dir(cave, x, y, GD_MV_TWICE + player_move) &&
- g_rand_int_range(cave->random, 0, 1000000) < prob)
+ gd_rand_int_range(cave->random, 0, 1000000) < prob)
{
/* if decided that he will be able to push, */
store_dir(cave, x, y, GD_MV_TWICE + player_move, what);
{
const GdDirection *creature_move;
boolean ccw = rotates_ccw(cave, x, y); /* check if default is counterclockwise */
- GdElement base; /* base element number (which is like O_***_1) */
+ 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_ALT_BUTTER_4)
base = O_ALT_BUTTER_1;
- dir = get(cave, x, y)-base; /* facing where */
+ dir = get(cave, x, y) - base; /* facing where */
creature_move = cave->creatures_backwards ? creature_chdir : creature_dir;
/* now change direction if backwards */
{
int px = cave->px[0];
int py = cave->py[0];
- boolean horizontal = g_rand_boolean(cave->random);
+ boolean horizontal = gd_rand_boolean(cave->random);
boolean dont_move = FALSE;
int i = 3;
int i;
GdElement made_sound_of = O_NONE;
- for (i = 0; i < G_N_ELEMENTS (biter_try); i++)
+ for (i = 0; i < ARRAY_SIZE (biter_try); i++)
{
if (is_element_dir(cave, x, y, biter_move[dir], biter_try[i]))
{
}
}
- if (i == G_N_ELEMENTS(biter_try))
+ 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)
};
GdDirection random_dir;
- random_dir = dirs[g_rand_int_range(cave->random, 0, G_N_ELEMENTS(dirs))];
+ random_dir = dirs[gd_rand_int_range(cave->random, 0, ARRAY_SIZE(dirs))];
if (is_space_dir(cave, x, y, random_dir))
{
move(cave, x, y, random_dir, O_GHOST);
/* if alive, check in which dir to grow (or not) */
if (cave->amoeba_state == GD_AM_AWAKE)
{
- if (g_rand_int_range(cave->random, 0, 1000000) < cave->amoeba_growth_prob)
+ if (gd_rand_int_range(cave->random, 0, 1000000) < cave->amoeba_growth_prob)
{
- switch (g_rand_int_range(cave->random, 0, 4))
+ switch (gd_rand_int_range(cave->random, 0, 4))
{
/* decided to grow, choose a random direction. */
case 0: /* let this be up. numbers indifferent. */
/* if it is alive, decide if it attempts to grow */
if (cave->amoeba_2_state == GD_AM_AWAKE)
- if (g_rand_int_range(cave->random, 0, 1000000) < cave->amoeba_2_growth_prob)
+ if (gd_rand_int_range(cave->random, 0, 1000000) < cave->amoeba_2_growth_prob)
{
- switch (g_rand_int_range(cave->random, 0, 4))
+ switch (gd_rand_int_range(cave->random, 0, 4))
{
/* decided to grow, choose a random direction. */
case 0: /* let this be up. numbers indifferent. */
case O_ACID:
/* choose randomly, if it spreads */
- if (g_rand_int_range(cave->random, 0, 1000000) <= cave->acid_spread_ratio)
+ if (gd_rand_int_range(cave->random, 0, 1000000) <= cave->acid_spread_ratio)
{
/* the current one explodes */
store(cave, x, y, cave->acid_turns_to);
#if 1
; // to make compilers happy ...
#else
- g_print("Step[%03d]", cave->frame); /* XXX */
+ Info("Step[%03d]", cave->frame); /* XXX */
#endif
int rrr = gd_cave_c64_random(cave);
#if 1
#else
- 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);
#endif
/*
- * unpredictable: g_rand_int
+ * unpredictable: gd_rand_int
* 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)
{
GdDirection grav = cave->gravity;
GdDirection oppos = opposite[cave->gravity];
O_WAITING_STONE, O_BITER_1
};
- 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))]);
}
break;
}
/* record coordinates of player for chasing stone */
- for (i = 0; i < G_N_ELEMENTS(cave->px) - 1; i++)
+ for (i = 0; i < ARRAY_SIZE(cave->px) - 1; i++)
{
cave->px[i] = cave->px[i + 1];
cave->py[i] = cave->py[i + 1];
}
- 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;
/* SCHEDULING */