replaced glib function calls to g_rand_*() and g_random_*()
[rocksndiamonds.git] / src / game_bd / bd_cave.c
index a1a5d40959bda960ea062d8221e932edcdc288a1..7d5aca5d2890d538f06381e277c2414dfc222675 100644 (file)
@@ -506,7 +506,7 @@ gpointer gd_cave_map_dup_size(const GdCave *cave, const gpointer map, const int
     return NULL;
 
   rows = checked_malloc((cave->h) * sizeof(gpointer));
-  rows[0] = getMemCopy (maplines[0], cell_size * cave->w * cave->h);
+  rows[0] = get_memcpy (maplines[0], cell_size * cave->w * cave->h);
 
   for (y = 1; y < cave->h; y++)
     rows[y] = (char *)rows[0] + cell_size * cave->w * y;
@@ -538,8 +538,8 @@ void gd_cave_free(GdCave *cave)
   if (cave->tags)
     hashtable_destroy(cave->tags);
 
-  if (cave->random)    /* random generator is a GRand * */
-    g_rand_free(cave->random);
+  if (cave->random)    /* random generator is a GdRand * */
+    gd_rand_free(cave->random);
 
   /* free strings */
   for (i = 0; gd_cave_properties[i].identifier != NULL; i++)
@@ -605,7 +605,7 @@ void gd_cave_copy(GdCave *dest, const GdCave *src)
 
     dest->objects = NULL;    /* new empty list */
     for (iter = src->objects; iter != NULL; iter = iter->next) /* do a deep copy */
-      dest->objects = list_append(dest->objects, getMemCopy (iter->data, sizeof (GdObject)));
+      dest->objects = list_append(dest->objects, get_memcpy (iter->data, sizeof (GdObject)));
   }
 
   /* copy replays */
@@ -620,7 +620,7 @@ void gd_cave_copy(GdCave *dest, const GdCave *src)
 
   /* copy random number generator */
   if (src->random)
-    dest->random = g_rand_copy(src->random);
+    dest->random = gd_rand_copy(src->random);
 }
 
 /* create new cave, which is a copy of the cave given. */
@@ -777,18 +777,6 @@ void gd_cave_c64_random_set_seed(GdCave *cave, int seed1, int seed2)
   gd_c64_random_set_seed(&cave->c64_rand, seed1, seed2);
 }
 
-/*
-  select random colors for a given cave.
-  this function will select colors so that they should look somewhat nice; for example
-  brick walls won't be the darkest color, for example.
-*/
-static inline void swap(int *i1, int *i2)
-{
-  int t = *i1;
-  *i1 = *i2;
-  *i2 = t;
-}
-
 /*
   shrink cave
   if last line or last row is just steel wall (or (invisible) outbox).
@@ -1158,10 +1146,10 @@ void gd_drawcave_game(const GdCave *cave, int **element_buffer, int **gfx_buffer
     {
       /* blinking and tapping is started at the beginning of animation sequences. */
       /* 1/4 chance of blinking, every sequence. */
-      player_blinking = g_random_int_range(0, 4) == 0;
+      player_blinking = gd_random_int_range(0, 4) == 0;
 
       /* 1/16 chance of starting or stopping tapping. */
-      if (g_random_int_range(0, 16) == 0)
+      if (gd_random_int_range(0, 16) == 0)
        player_tapping = !player_tapping;
     }
   }
@@ -1400,7 +1388,7 @@ GdReplay *gd_replay_new_from_replay(GdReplay *orig)
 {
   GdReplay *rep;
 
-  rep = getMemCopy(orig, sizeof(GdReplay));
+  rep = get_memcpy(orig, sizeof(GdReplay));
 
   /* replicate dynamic data */
   rep->comment = getStringCopy(orig->comment);