replaced glib function calls to g_file_get_contents()
[rocksndiamonds.git] / src / game_bd / bd_cave.h
index 35b2b80b9d58ad41a71888db18f894aa53a40a37..038c61fda66ead21b746e72828aceae8ae003726 100644 (file)
@@ -20,6 +20,7 @@
 #include <glib.h>
 
 #include "bd_elements.h"
+#include "bd_random.h"
 
 
 // colors
@@ -151,6 +152,9 @@ void gd_struct_set_defaults_from_array(gpointer str, const GdStructDescriptor *p
    for example diamond + arrow = falling diamond */
 #define GD_NUM_OF_CELLS (GD_NUM_OF_CELLS_X*GD_NUM_OF_CELLS_Y+80)
 
+/* maximum replay size (maximum seconds x game cycles per second) */
+#define MAX_REPLAY_LEN (10000 * FRAMES_PER_SECOND / 8)
+
 extern const GdColor gd_flash_color;
 extern const GdColor gd_select_color;
 
@@ -167,6 +171,7 @@ enum _element_property
   E_P_BLOWS_UP_FLIES,   /* flies blow up, if they touch this */
   E_P_EXPLODES_BY_HIT,  /* explodes if hit by a stone */
 
+  E_P_EXPLOSION,                /* set for every stage of every explosion. */
   E_P_EXPLOSION_FIRST_STAGE,    /* set for first stage of every explosion.
                                   helps slower/faster explosions changing */
 
@@ -202,6 +207,7 @@ enum _element_property
 #define P_BLOWS_UP_FLIES               (1 << E_P_BLOWS_UP_FLIES)
 
 #define P_EXPLODES_BY_HIT              (1 << E_P_EXPLODES_BY_HIT)
+#define P_EXPLOSION                    (1 << E_P_EXPLOSION)
 #define P_EXPLOSION_FIRST_STAGE                (1 << E_P_EXPLOSION_FIRST_STAGE)
 
 #define P_NON_EXPLODABLE               (1 << E_P_NON_EXPLODABLE)
@@ -310,6 +316,12 @@ typedef struct _highscore
   int score;
 } GdHighScore;
 
+typedef struct _replay_movements
+{
+  unsigned char data[MAX_REPLAY_LEN];
+  unsigned int len;
+} GdReplayMovements;
+
 /* maximum seed value for the cave random generator. should be smaller than a signed int. */
 #define GD_CAVE_SEED_MAX       (1 << 30)
 
@@ -330,7 +342,7 @@ typedef struct _gd_cave_replay
   guint32 checksum;         /* checksum of the rendered cave. */
 
   boolean wrong_checksum;
-  GByteArray *movements;
+  GdReplayMovements *movements;
   int current_playing_pos;
 } GdReplay;
 
@@ -375,11 +387,11 @@ typedef struct _gd_cave
   /* and this one the highscores */
   GdHighScore highscore[GD_HIGHSCORE_NUM];
 
-  GHashTable *tags;            /* stores read-but-not-understood strings from bdcff, so we can save them later. */
+  HashTable *tags;      /* stores read-but-not-understood strings from bdcff, so we can save them later. */
 
   GdElement **map;            /* pointer to data for map, non-null if has a map */
-  GList *objects;
-  GList *replays;
+  List *objects;
+  List *replays;
 
   boolean intermission;        /* is this cave an intermission? */
   boolean intermission_instantlife;    /* one life extra, if the intermission is reached */
@@ -565,7 +577,7 @@ typedef struct _gd_cave
   boolean hatched;            /* hatching has happened. (timers may run, ...) */
   boolean gate_open;            /* self-explaining */
   guint32 render_seed;        /* the seed value, which was used to render the cave, is saved here. will be used by record&playback */
-  GRand *random;                /* random number generator of rendered cave */
+  GdRand *random;               /* random number generator of rendered cave */
   int rendered;                /* if not zero, rendered at level x */
   int timing_factor;            /* number of "milliseconds" in each second :) 1000 for ntsc, 1200 for pal. */
   gpointer **objects_order;    /* two-dimensional map of cave; each cell is a pointer to the drawing object, which created this element. NULL if map or random. */
@@ -626,7 +638,7 @@ typedef struct _gd_cave
 } GdCave;
 
 
-#define CAVE_OFFSET(property) (G_STRUCT_OFFSET(GdCave, property))
+#define CAVE_OFFSET(property) (STRUCT_OFFSET(GdCave, property))
 
 /* arrays for movements */
 /* also no1 and bd2 cave data import helpers; line direction coordinates */
@@ -642,8 +654,8 @@ GdElement gd_get_element_from_string(const char *string);
 void gd_cave_init(void);
 
 /* for cave tags hash table */
-boolean gd_str_case_equal(gconstpointer s1, gconstpointer s2);
-guint gd_str_case_hash(gconstpointer v);
+int gd_str_case_equal(void *s1, void *s2);
+unsigned int gd_str_case_hash(void *v);
 
 /* cave highscore functions */
 int gd_highscore_compare(gconstpointer a, gconstpointer b);
@@ -700,10 +712,9 @@ void gd_drawcave_game(const GdCave *cave, int **element_buffer, int **gfx_buffer
                      boolean bonus_life_flash, int animcycle, boolean hate_invisible_outbox);
 
 /* function to copy a GdString */
-static inline int
-gd_strcpy(GdString dest, const GdString src)
+static inline char *gd_strcpy(GdString dest, const GdString src)
 {
-    return g_strlcpy(dest, src, sizeof(GdString));
+    return strncpy(dest, src, sizeof(GdString));
 }
 
 int gd_cave_time_show(const GdCave *cave, int internal_time);