From bd560c53129c84976b87827f1978ddf8de4ed57a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 25 Feb 2024 04:06:45 +0100 Subject: [PATCH] removed library dependency to glib-2.0 --- src/Makefile | 8 ---- src/game_bd/bd_bdcff.c | 15 +++----- src/game_bd/bd_bdcff.h | 3 -- src/game_bd/bd_c64import.c | 77 ++++++++++++++++++------------------- src/game_bd/bd_c64import.h | 6 +-- src/game_bd/bd_cave.c | 52 ++++++++++++------------- src/game_bd/bd_cave.h | 30 +++++++-------- src/game_bd/bd_cavedb.c | 3 -- src/game_bd/bd_cavedb.h | 2 - src/game_bd/bd_caveengine.c | 16 ++++---- src/game_bd/bd_caveengine.h | 2 - src/game_bd/bd_caveobject.c | 19 ++++----- src/game_bd/bd_caveobject.h | 14 +++---- src/game_bd/bd_caveset.c | 28 +++++++------- src/game_bd/bd_caveset.h | 4 +- src/game_bd/bd_gameplay.c | 3 -- src/game_bd/bd_gameplay.h | 2 - src/game_bd/bd_graphics.c | 4 +- src/game_bd/bd_graphics.h | 6 +-- src/game_bd/bd_random.c | 1 + src/game_bd/bd_sound.c | 4 +- src/game_bd/main_bd.h | 11 ++++++ 22 files changed, 134 insertions(+), 176 deletions(-) diff --git a/src/Makefile b/src/Makefile index 6e74c8e1..7a128e75 100644 --- a/src/Makefile +++ b/src/Makefile @@ -156,14 +156,6 @@ endif CFLAGS = $(OPTIONS) $(ANALYZE) $(SYS_CFLAGS) $(EXTRA_CFLAGS) $(CONFIG) LDFLAGS = $(ANALYZE) $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -# !!! DEPENDENCY TO GLIB SHOULD BE REMOVED AGAIN !!! -GLIB_CFLAGS := $(shell pkg-config --cflags glib-2.0) -GLIB_LDFLAGS := $(shell pkg-config --libs glib-2.0) - -CFLAGS := $(CFLAGS) $(GLIB_CFLAGS) -LDFLAGS := $(LDFLAGS) $(GLIB_LDFLAGS) -# !!! DEPENDENCY TO GLIB SHOULD BE REMOVED AGAIN !!! - SRCS = main.c \ conf_gfx.c \ diff --git a/src/game_bd/bd_bdcff.c b/src/game_bd/bd_bdcff.c index 4c57c14e..53fc4c91 100644 --- a/src/game_bd/bd_bdcff.c +++ b/src/game_bd/bd_bdcff.c @@ -14,9 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include #include "main_bd.h" @@ -140,7 +137,7 @@ static boolean attrib_is_valid_for_caveset(const char *attrib) return FALSE; } -static boolean struct_set_property(gpointer str, const GdStructDescriptor *prop_desc, +static boolean struct_set_property(void *str, const GdStructDescriptor *prop_desc, const char *attrib, const char *param, int ratio) { char **params; @@ -163,7 +160,7 @@ static boolean struct_set_property(gpointer str, const GdStructDescriptor *prop_ if (strcasecmp(prop_desc[i].identifier, attrib) == 0) { /* found the identifier */ - gpointer value = G_STRUCT_MEMBER_P(str, prop_desc[i].offset); + void *value = STRUCT_MEMBER_P(str, prop_desc[i].offset); /* these point to the same, but to avoid the awkward cast syntax */ int *ivalue = value; @@ -204,7 +201,7 @@ static boolean struct_set_property(gpointer str, const GdStructDescriptor *prop_ for (j = 0; j < prop_desc[i].count && params[paramindex] != NULL; j++) { boolean success = FALSE; - gdouble res; + double res; switch (prop_desc[i].type) { @@ -358,7 +355,7 @@ static boolean replay_store_more_from_bdcff(GdReplay *replay, const char *param) } /* report all remaining tags; called after the above function. */ -static void replay_report_unknown_tags_func(const char *attrib, const char *param, gpointer data) +static void replay_report_unknown_tags_func(const char *attrib, const char *param, void *data) { Warn("unknown replay tag '%s'", attrib); } @@ -489,7 +486,7 @@ static boolean cave_process_tags_func(const char *attrib, const char *param, GdC } /* report all remaining tags; called after the above function. */ -static void cave_report_and_copy_unknown_tags_func(char *attrib, char *param, gpointer data) +static void cave_report_and_copy_unknown_tags_func(char *attrib, char *param, void *data) { GdCave *cave = (GdCave *)data; @@ -1062,7 +1059,7 @@ boolean gd_caveset_load_from_bdcff(const char *contents) strcasecmp(params[0], gd_cave_properties[i].identifier) == 0) { /* found identifier */ - gpointer value = G_STRUCT_MEMBER_P (cave, gd_cave_properties[i].offset); + void *value = STRUCT_MEMBER_P (cave, gd_cave_properties[i].offset); *((GdElement *) value) = gd_get_element_from_string (params[1]); break; diff --git a/src/game_bd/bd_bdcff.h b/src/game_bd/bd_bdcff.h index 54fff642..d5b73c42 100644 --- a/src/game_bd/bd_bdcff.h +++ b/src/game_bd/bd_bdcff.h @@ -17,9 +17,6 @@ #ifndef BD_BDCFF_H #define BD_BDCFF_H -#include - boolean gd_caveset_load_from_bdcff(const char *contents); -void gd_caveset_save_to_bdcff(GPtrArray *out); #endif // BD_BDCFF_H diff --git a/src/game_bd/bd_c64import.c b/src/game_bd/bd_c64import.c index b838aa43..f878472e 100644 --- a/src/game_bd/bd_c64import.c +++ b/src/game_bd/bd_c64import.c @@ -14,9 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "main_bd.h" @@ -435,9 +432,9 @@ static int slime_shift_msb(int c64_data) return perm; } -static GdElement bd1_import(guint8 c, int i) +static GdElement bd1_import(byte c, int i) { - if (c < G_N_ELEMENTS(bd1_import_table)) + if (c < ARRAY_SIZE(bd1_import_table)) return bd1_import_table[c]; Warn("Invalid BD1 element in imported file at cave data %d: %d", i, c); @@ -446,7 +443,7 @@ static GdElement bd1_import(guint8 c, int i) } /* deluxe caves 1 contained a special element, non-sloped brick. */ -static GdElement deluxecaves_1_import(guint8 c, int i) +static GdElement deluxecaves_1_import(byte c, int i) { GdElement e = bd1_import(c, i); @@ -456,9 +453,9 @@ static GdElement deluxecaves_1_import(guint8 c, int i) return e; } -static GdElement firstboulder_import(guint8 c, int i) +static GdElement firstboulder_import(byte c, int i) { - if (c < G_N_ELEMENTS(firstboulder_import_table)) + if (c < ARRAY_SIZE(firstboulder_import_table)) return firstboulder_import_table[c]; Warn("Invalid 1stB element in imported file at cave data %d: %d", i, c); @@ -466,9 +463,9 @@ static GdElement firstboulder_import(guint8 c, int i) return O_UNKNOWN; } -static GdElement crazylight_import(guint8 c, int i) +static GdElement crazylight_import(byte c, int i) { - if (c < G_N_ELEMENTS(gd_crazylight_import_table)) + if (c < ARRAY_SIZE(gd_crazylight_import_table)) return gd_crazylight_import_table[c] & O_MASK; /* & O_MASK: do not import "scanned" flag */ Warn("Invalid CrLi element in imported file at cave data %d: %d", i, c); @@ -568,16 +565,16 @@ GdEngine gd_cave_get_engine_from_string(const char *param) */ /* import bd1 cave data into our format. */ -static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_bytes, +static int cave_copy_from_bd1(GdCave *cave, const byte *data, int remaining_bytes, GdCavefileFormat format) { int length, direction; int index; int level; int x1, y1, x2, y2; - guint8 code; + byte code; GdElement elem; - GdElement (* import_func) (guint8 c, int i); + GdElement (* import_func) (byte c, int i); int i; /* cant be shorted than this: header + no objects + delimiter */ @@ -718,7 +715,7 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by case 1: /* 01: LINE */ x1 = data[index + 1]; y1 = data[index + 2] - 2; - length = (gint8)data[index + 3] - 1; + length = (byte)data[index + 3] - 1; direction = data[index + 4]; if (length < 0) @@ -796,7 +793,7 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by /* import bd2 cave data into our format. return number of bytes if pointer passed. this is pretty much the same as above, only the encoding was different. */ -static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_bytes, +static int cave_copy_from_bd2(GdCave *cave, const byte *data, int remaining_bytes, GdCavefileFormat format) { int index; @@ -1107,7 +1104,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by /* import plck cave data into our format. length is always 512 bytes, and contains if it is an intermission cave. */ -static int cave_copy_from_plck(GdCave *cave, const guint8 *data, +static int cave_copy_from_plck(GdCave *cave, const byte *data, int remaining_bytes, GdCavefileFormat format) { /* i don't really think that all this table is needed, but included to be complete. */ @@ -1270,9 +1267,9 @@ static int cave_copy_from_plck(GdCave *cave, const guint8 *data, } /* no one's delight boulder dash essentially: rle compressed plck maps. */ -static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_bytes) +static int cave_copy_from_dlb(GdCave *cave, const byte *data, int remaining_bytes) { - guint8 decomp[512]; + byte decomp[512]; enum { START, /* initial state */ @@ -1281,7 +1278,7 @@ static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_by NORMAL /* normal, copy bytes till separator */ } state; int pos, cavepos, i, x, y; - guint8 byte, separator; + byte byte, separator; gd_cave_set_engine_defaults(cave, GD_ENGINE_PLCK); /* essentially the plck engine */ @@ -1420,7 +1417,7 @@ static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_by } /* import plck cave data into our format. */ -static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_bytes) +static int cave_copy_from_1stb(GdCave *cave, const byte *data, int remaining_bytes) { int i; int x, y; @@ -1559,10 +1556,10 @@ static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_b } /* crazy dream 7 */ -static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining_bytes) +static int cave_copy_from_crdr_7(GdCave *cave, const byte *data, int remaining_bytes) { int i, index; - guint8 checksum; + byte checksum; /* if we have name, convert */ gd_strcpy(cave->name, " "); @@ -1916,9 +1913,9 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining return 15 + 0x49 + index; } -static void crazy_dream_9_add_specials(GdCave *cave, const guint8 *buf, const int length) +static void crazy_dream_9_add_specials(GdCave *cave, const byte *buf, const int length) { - guint8 checksum; + byte checksum; int i; /* crazy dream 9 hack */ @@ -1930,8 +1927,8 @@ static void crazy_dream_9_add_specials(GdCave *cave, const guint8 *buf, const in if (strEqual(cave->name, "Rockfall") && checksum == 134) { GdElement rand[4] = { O_DIAMOND, O_STONE, O_ACID, O_DIRT }; - gint32 prob[4] = { 37, 32, 2, 0 }; - gint32 seeds[5] = { -1, -1, -1, -1, -1 }; + int prob[4] = { 37, 32, 2, 0 }; + int seeds[5] = { -1, -1, -1, -1, -1 }; cave->objects = list_append(cave->objects, gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 0, 0, 39, 21, seeds, O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE)); } @@ -1939,23 +1936,23 @@ static void crazy_dream_9_add_specials(GdCave *cave, const guint8 *buf, const in if (strEqual(cave->name, "Roll dice now!") && checksum == 235) { GdElement rand[4] = { O_STONE, O_BUTTER_3, O_DIRT, O_DIRT }; - gint32 prob[4] = { 0x18, 0x08, 0, 0 }; - gint32 seeds[5] = { -1, -1, -1, -1, -1 }; + int prob[4] = { 0x18, 0x08, 0, 0 }; + int seeds[5] = { -1, -1, -1, -1, -1 }; cave->objects = list_append(cave->objects, gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 0, 0, 39, 21, seeds, O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE)); } if (strEqual(cave->name, "Random maze") && checksum == 24) { - gint32 seeds[5] = { -1, -1, -1, -1, -1 }; + int seeds[5] = { -1, -1, -1, -1, -1 }; cave->objects = list_append(cave->objects, gd_object_new_maze(GD_OBJECT_LEVEL_ALL, 1, 4, 35, 20, 1, 1, O_NONE, O_DIRT, 50, seeds)); } if (strEqual(cave->name, "Metamorphosis") && checksum == 53) { - gint32 seeds[5] = { -1, -1, -1, -1, -1 }; + int seeds[5] = { -1, -1, -1, -1, -1 }; GdElement rand[4] = { O_STONE, O_DIRT, O_DIRT, O_DIRT }; - gint32 prob[4] = { 0x18, 0, 0, 0 }; + int prob[4] = { 0x18, 0, 0, 0 }; cave->objects = list_append(cave->objects, gd_object_new_maze(GD_OBJECT_LEVEL_ALL, 4, 1, 38, 19, 1, 3, O_NONE, O_BLADDER_SPENDER, 50, seeds)); cave->objects = list_append(cave->objects, gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 4, 1, 38, 19, seeds, O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE)); @@ -1964,7 +1961,7 @@ static void crazy_dream_9_add_specials(GdCave *cave, const guint8 *buf, const in if (strEqual(cave->name, "All the way") && checksum == 33) { - gint32 seeds[5] = { -1, -1, -1, -1, -1 }; + int seeds[5] = { -1, -1, -1, -1, -1 }; cave->objects = list_append(cave->objects, gd_object_new_maze_unicursal(GD_OBJECT_LEVEL_ALL, 1, 1, 35, 19, 1, 1, O_BRICK, O_PRE_DIA_1, 50, seeds)); @@ -1974,9 +1971,9 @@ static void crazy_dream_9_add_specials(GdCave *cave, const guint8 *buf, const in } /* crazy light contruction kit */ -static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_bytes) +static int cave_copy_from_crli(GdCave *cave, const byte *data, int remaining_bytes) { - guint8 uncompressed[1024]; + byte uncompressed[1024]; int datapos, cavepos, i, x, y; boolean cavefile; const char *versions[] = { "V2.2", "V2.6", "V3.0" }; @@ -1987,7 +1984,7 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b V2_6, V3_0 } version = none; - GdElement (*import) (guint8 c, int i) = NULL; /* import function */ + GdElement (*import) (byte c, int i) = NULL; /* import function */ gd_cave_set_engine_defaults(cave, GD_ENGINE_CRLI); @@ -2077,7 +2074,7 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b } /* check crli version */ - for (i = 0; i < G_N_ELEMENTS(versions); i++) + for (i = 0; i < ARRAY_SIZE(versions); i++) if (memcmp((char *)uncompressed + 0x3a0, versions[i], 4) == 0) version = i + 1; @@ -2249,7 +2246,7 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b return datapos; } -GdCavefileFormat gd_caveset_imported_get_format(const guint8 *buf) +GdCavefileFormat gd_caveset_imported_get_format(const byte *buf) { const char *s_bd1 = "GDashBD1"; const char *s_bd1_atari = "GDashB1A"; @@ -2297,13 +2294,13 @@ GdCavefileFormat gd_caveset_imported_get_format(const guint8 *buf) Loads the caveset from a memory buffer. returns: List * of caves. */ -List *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) +List *gd_caveset_import_from_buffer (const byte *buf, size_t length) { boolean numbering; int cavenum, intermissionnum, num; int cavelength, bufp; List *caveset = NULL, *iter; - guint32 encodedlength; + unsigned int encodedlength; GdCavefileFormat format; if (length != -1 && length < 12) @@ -2312,7 +2309,7 @@ List *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) return NULL; } - encodedlength = GUINT32_FROM_LE(*((guint32 *)(buf + 8))); + encodedlength = (unsigned int)(*((unsigned int *)(buf + 8))); if (length != -1 && encodedlength != length - 12) { Warn("file length and data size mismatch in GDash datafile"); diff --git a/src/game_bd/bd_c64import.h b/src/game_bd/bd_c64import.h index a130c4b7..0af4308c 100644 --- a/src/game_bd/bd_c64import.h +++ b/src/game_bd/bd_c64import.h @@ -17,8 +17,6 @@ #ifndef BD_CAVEIMPORT_H #define BD_CAVEIMPORT_H -#include - #include "bd_cave.h" @@ -58,8 +56,8 @@ typedef enum _gd_engine extern const char *gd_engines[]; -GdCavefileFormat gd_caveset_imported_get_format(const guint8 *buf); -List* gd_caveset_import_from_buffer (const guint8 *buf, gsize length); +GdCavefileFormat gd_caveset_imported_get_format(const unsigned char *buf); +List* gd_caveset_import_from_buffer (const unsigned char *buf, size_t length); void gd_cave_set_engine_defaults(GdCave *cave, GdEngine engine); GdEngine gd_cave_get_engine_from_string(const char *param); diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index 87d51af2..7a5766d7 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -14,9 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "main_bd.h" @@ -105,7 +102,7 @@ GdDirection gd_direction_from_string(const char *str) { int i; - for (i = 1; ih) * sizeof(gpointer)); + rows = checked_malloc((cave->h) * sizeof(void *)); rows[0] = checked_calloc(cell_size * cave->w * cave->h); for (y = 1; y < cave->h; y++) @@ -496,16 +493,16 @@ gpointer gd_cave_map_new_for_cave(const GdCave *cave, const int cell_size) if map is null, this also returns null. */ -gpointer gd_cave_map_dup_size(const GdCave *cave, const gpointer map, const int cell_size) +void *gd_cave_map_dup_size(const GdCave *cave, const void *map, const int cell_size) { - gpointer *rows; - gpointer *maplines = (gpointer *)map; + void **rows; + void **maplines = (void **)map; int y; if (!map) return NULL; - rows = checked_malloc((cave->h) * sizeof(gpointer)); + rows = checked_malloc((cave->h) * sizeof(void *)); rows[0] = get_memcpy (maplines[0], cell_size * cave->w * cave->h); for (y = 1; y < cave->h; y++) @@ -514,9 +511,9 @@ gpointer gd_cave_map_dup_size(const GdCave *cave, const gpointer map, const int return rows; } -void gd_cave_map_free(gpointer map) +void gd_cave_map_free(void *map) { - gpointer *maplines = (gpointer *) map; + void **maplines = (void **) map; if (!map) return; @@ -544,7 +541,7 @@ void gd_cave_free(GdCave *cave) /* free strings */ for (i = 0; gd_cave_properties[i].identifier != NULL; i++) if (gd_cave_properties[i].type == GD_TYPE_LONGSTRING) - checked_free(G_STRUCT_MEMBER(char *, cave, gd_cave_properties[i].offset)); + checked_free(STRUCT_MEMBER(char *, cave, gd_cave_properties[i].offset)); /* map */ gd_cave_map_free(cave->map); @@ -592,8 +589,8 @@ void gd_cave_copy(GdCave *dest, const GdCave *src) /* for longstrings */ for (i = 0; gd_cave_properties[i].identifier != NULL; i++) if (gd_cave_properties[i].type == GD_TYPE_LONGSTRING) - G_STRUCT_MEMBER(char *, dest, gd_cave_properties[i].offset) = - getStringCopy(G_STRUCT_MEMBER(char *, src, gd_cave_properties[i].offset)); + STRUCT_MEMBER(char *, dest, gd_cave_properties[i].offset) = + getStringCopy(STRUCT_MEMBER(char *, src, gd_cave_properties[i].offset)); /* no reason to copy this */ dest->objects_order = NULL; @@ -1407,7 +1404,7 @@ void gd_replay_free(GdReplay *replay) void gd_replay_store_movement(GdReplay *replay, GdDirection player_move, boolean player_fire, boolean suicide) { - guint8 data[1]; + byte data[1]; data[0] = ((player_move) | (player_fire ? GD_REPLAY_FIRE_MASK : 0) | @@ -1423,7 +1420,7 @@ void gd_replay_store_movement(GdReplay *replay, GdDirection player_move, } /* calculate adler checksum for a rendered cave; this can be used for more caves. */ -void gd_cave_adler_checksum_more(GdCave *cave, guint32 *a, guint32 *b) +void gd_cave_adler_checksum_more(GdCave *cave, unsigned int *a, unsigned int *b) { int x, y; @@ -1439,11 +1436,10 @@ void gd_cave_adler_checksum_more(GdCave *cave, guint32 *a, guint32 *b) } /* calculate adler checksum for a single rendered cave. */ -guint32 -gd_cave_adler_checksum(GdCave *cave) +unsigned int gd_cave_adler_checksum(GdCave *cave) { - guint32 a = 1; - guint32 b = 0; + unsigned int a = 1; + unsigned int b = 0; gd_cave_adler_checksum_more(cave, &a, &b); return (b << 16) + a; diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index 038c61fd..25eb1bd8 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -17,15 +17,13 @@ #ifndef BD_CAVE_H #define BD_CAVE_H -#include - #include "bd_elements.h" #include "bd_random.h" // colors -typedef guint32 GdColor; +typedef unsigned int GdColor; /* color internal: XXRRGGBB; @@ -142,7 +140,7 @@ typedef struct _gd_property_default } GdPropertyDefault; -void gd_struct_set_defaults_from_array(gpointer str, const GdStructDescriptor *properties, GdPropertyDefault *defaults); +void gd_struct_set_defaults_from_array(void *str, const GdStructDescriptor *properties, GdPropertyDefault *defaults); /* these define the number of the cells in the png file */ #define GD_NUM_OF_CELLS_X 8 @@ -328,7 +326,7 @@ typedef struct _replay_movements typedef struct _gd_cave_replay { int level; /* replay for level n */ - guint32 seed; /* seed the cave is to be rendered with */ + unsigned int seed; /* seed the cave is to be rendered with */ boolean saved; /* also store it in the saved bdcff */ GdString recorded_with; /* recorded with - application name and version */ @@ -339,7 +337,7 @@ typedef struct _gd_cave_replay int score; /* score collected */ int duration; /* number of seconds played */ boolean success; /* successful playing of cave? */ - guint32 checksum; /* checksum of the rendered cave. */ + unsigned int checksum; /* checksum of the rendered cave. */ boolean wrong_checksum; GdReplayMovements *movements; @@ -576,11 +574,11 @@ 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 */ + unsigned int render_seed; /* the seed value, which was used to render the cave, is saved here. will be used by record&playback */ 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. */ + void ***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. */ int **hammered_reappear; /* integer map of cave; if non-zero, a brick wall will appear there */ int speed; /* Time between game cycles in ms */ @@ -647,7 +645,7 @@ extern const int gd_dx[], gd_dy[]; extern GdElement gd_char_to_element[]; void gd_create_char_to_element_table(void); -GdElement gd_get_element_from_character(guint8 character); +GdElement gd_get_element_from_character(unsigned char character); GdElement gd_get_element_from_string(const char *string); /* init cave engine */ @@ -658,7 +656,7 @@ 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); +int gd_highscore_compare(const void *a, const void *b); boolean gd_is_highscore(GdHighScore *scores, int score); int gd_add_highscore(GdHighScore *highscores, const char *name, int score); void gd_clear_highscore(GdHighScore *hs); @@ -686,11 +684,11 @@ void gd_c64_random_set_seed(GdC64RandomGenerator *rand, int seed1, int seed2); void gd_cave_c64_random_set_seed(GdCave *cave, int seed1, int seed2); /* support */ -gpointer gd_cave_map_new_for_cave(const GdCave *cave, const int cell_size); -gpointer gd_cave_map_dup_size(const GdCave * cave, const gpointer map, const int cell_size); +void *gd_cave_map_new_for_cave(const GdCave *cave, const int cell_size); +void *gd_cave_map_dup_size(const GdCave * cave, const void *map, const int cell_size); #define gd_cave_map_new(CAVE, TYPE) ((TYPE **)gd_cave_map_new_for_cave((CAVE), sizeof(TYPE))) -#define gd_cave_map_dup(CAVE, MAP) ((gpointer)gd_cave_map_dup_size((CAVE), (gpointer *)(CAVE)->MAP, sizeof((CAVE)->MAP[0][0]))) -void gd_cave_map_free(gpointer map); +#define gd_cave_map_dup(CAVE, MAP) ((void *)gd_cave_map_dup_size((CAVE), (void **)(CAVE)->MAP, sizeof((CAVE)->MAP[0][0]))) +void gd_cave_map_free(void *map); void gd_cave_store_rc(GdCave * cave, int x, int y, const GdElement element, const void* order); GdElement gd_cave_get_rc (const GdCave *cave, int x, int y); @@ -724,8 +722,8 @@ GdReplay *gd_replay_new_from_replay(GdReplay *orig); void gd_replay_free(GdReplay *replay); void gd_replay_store_movement(GdReplay *replay, GdDirection player_move, boolean player_fire, boolean suicide); -guint32 gd_cave_adler_checksum(GdCave *cave); -void gd_cave_adler_checksum_more(GdCave *cave, guint32 *a, guint32 *b); +unsigned int gd_cave_adler_checksum(GdCave *cave); +void gd_cave_adler_checksum_more(GdCave *cave, unsigned int *a, unsigned int *b); GdColor gd_c64_color(int); diff --git a/src/game_bd/bd_cavedb.c b/src/game_bd/bd_cavedb.c index b29884cd..ac334aea 100644 --- a/src/game_bd/bd_cavedb.c +++ b/src/game_bd/bd_cavedb.c @@ -14,9 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "main_bd.h" diff --git a/src/game_bd/bd_cavedb.h b/src/game_bd/bd_cavedb.h index 31c54753..55ce6222 100644 --- a/src/game_bd/bd_cavedb.h +++ b/src/game_bd/bd_cavedb.h @@ -17,8 +17,6 @@ #ifndef BD_CAVEDB_H #define BD_CAVEDB_H -#include - #include "bd_cave.h" diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index 2609233e..bfe796f7 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -30,8 +30,6 @@ * The player_get function will also behave for lava as it does for space. */ -#include - #include "main_bd.h" @@ -2521,7 +2519,7 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, 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])) { @@ -2546,7 +2544,7 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, } } - 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) @@ -2711,7 +2709,7 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, }; GdDirection random_dir; - random_dir = dirs[gd_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); @@ -3201,7 +3199,7 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, O_WAITING_STONE, O_BITER_1 }; - store(cave, x, y, ghost_explode[gd_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; @@ -3404,14 +3402,14 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, } /* 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 */ diff --git a/src/game_bd/bd_caveengine.h b/src/game_bd/bd_caveengine.h index 12c456de..88b26757 100644 --- a/src/game_bd/bd_caveengine.h +++ b/src/game_bd/bd_caveengine.h @@ -17,8 +17,6 @@ #ifndef BD_CAVEENGINE_H #define BD_CAVEENGINE_H -#include - #include "bd_cave.h" diff --git a/src/game_bd/bd_caveobject.c b/src/game_bd/bd_caveobject.c index 01c3caf9..57bc963c 100644 --- a/src/game_bd/bd_caveobject.c +++ b/src/game_bd/bd_caveobject.c @@ -14,9 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "main_bd.h" @@ -163,7 +160,7 @@ GdObject *gd_object_new_floodfill_replace(GdObjectLevels levels, int x1, int y1, GdObject *gd_object_new_maze(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, - int horiz_percent, const gint32 seed[5]) + int horiz_percent, const int seed[5]) { int i; GdObject *newobj = checked_calloc(sizeof(GdObject)); @@ -188,7 +185,7 @@ GdObject *gd_object_new_maze(GdObjectLevels levels, int x1, int y1, int x2, int GdObject *gd_object_new_maze_unicursal(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, - int horiz_percent, const gint32 seed[5]) + int horiz_percent, const int seed[5]) { int i; GdObject *newobj = checked_calloc(sizeof(GdObject)); @@ -213,7 +210,7 @@ GdObject *gd_object_new_maze_unicursal(GdObjectLevels levels, int x1, int y1, in GdObject *gd_object_new_maze_braid(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, - int horiz_percent, const gint32 seed[5]) + int horiz_percent, const int seed[5]) { int i; GdObject *newobj = checked_calloc(sizeof(GdObject)); @@ -237,8 +234,8 @@ GdObject *gd_object_new_maze_braid(GdObjectLevels levels, int x1, int y1, int x2 } GdObject *gd_object_new_random_fill(GdObjectLevels levels, int x1, int y1, int x2, int y2, - const gint32 seed[5], GdElement initial, - const GdElement random[4], const gint32 prob[4], + const int seed[5], GdElement initial, + const GdElement random[4], const int prob[4], GdElement replace_only, boolean c64) { int i; @@ -1139,7 +1136,7 @@ static void draw_random_fill(GdCave *cave, const GdObject *object, int level) int y2 = object->y2; GdRand *rand; GdC64RandomGenerator c64_rand; - guint32 seed; + unsigned int seed; /* -1 means that it should be different every time played. */ if (object->seed[level] == -1) @@ -1316,7 +1313,7 @@ void gd_cave_draw_object(GdCave *cave, const GdObject *object, int level) } /* load cave to play... also can be called rendering the cave elements */ -GdCave *gd_cave_new_rendered(const GdCave *data, const int level, const guint32 seed) +GdCave *gd_cave_new_rendered(const GdCave *data, const int level, const unsigned int seed) { GdCave *cave; GdElement element; @@ -1331,7 +1328,7 @@ GdCave *gd_cave_new_rendered(const GdCave *data, const int level, const guint32 cave->random = gd_rand_new_with_seed(cave->render_seed); /* maps needed during drawing and gameplay */ - cave->objects_order = gd_cave_map_new(cave, gpointer); + cave->objects_order = gd_cave_map_new(cave, void *); cave->time = data->level_time[level]; cave->timevalue = data->level_timevalue[level]; diff --git a/src/game_bd/bd_caveobject.h b/src/game_bd/bd_caveobject.h index 5b2a3f7e..f52503ce 100644 --- a/src/game_bd/bd_caveobject.h +++ b/src/game_bd/bd_caveobject.h @@ -17,8 +17,6 @@ #ifndef BD_CAVEOBJECT_H #define BD_CAVEOBJECT_H -#include - #include "bd_cave.h" @@ -67,7 +65,7 @@ typedef struct _gd_object int dx, dy; /* distance of elements for raster or join */ GdElement element, fill_element; /* element type */ - gint32 seed[5]; /* for maze and random fill */ + int seed[5]; /* for maze and random fill */ int horiz; /* for maze */ boolean mirror, flip; /* for copy */ @@ -86,16 +84,16 @@ GdObject *gd_object_new_raster(GdObjectLevels levels, int x1, int y1, int x2, in GdObject *gd_object_new_join(GdObjectLevels levels, int dx, int dy, GdElement search, GdElement replace); GdObject *gd_object_new_floodfill_border(GdObjectLevels levels, int x1, int y1, GdElement fill, GdElement border); GdObject *gd_object_new_floodfill_replace(GdObjectLevels levels, int x1, int y1, GdElement fill, GdElement to_replace); -GdObject *gd_object_new_maze(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const gint32 seed[5]); -GdObject *gd_object_new_maze_unicursal(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const gint32 seed[5]); -GdObject *gd_object_new_maze_braid(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const gint32 seed[5]); -GdObject *gd_object_new_random_fill(GdObjectLevels levels, int x1, int y1, int x2, int y2, const gint32 seed[5], GdElement initial, const GdElement random[4], const gint32 prob[4], GdElement replace_only, boolean c64); +GdObject *gd_object_new_maze(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const int seed[5]); +GdObject *gd_object_new_maze_unicursal(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const int seed[5]); +GdObject *gd_object_new_maze_braid(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const int seed[5]); +GdObject *gd_object_new_random_fill(GdObjectLevels levels, int x1, int y1, int x2, int y2, const int seed[5], GdElement initial, const GdElement random[4], const int prob[4], GdElement replace_only, boolean c64); GdObject *gd_object_new_copy_paste(GdObjectLevels levels, int x1, int y1, int x2, int y2, int dx, int dy, boolean mirror, boolean flip); void gd_cave_draw_object(GdCave *cave, const GdObject *object, int level); GdObject *gd_object_new_from_string(char *str); -GdCave *gd_cave_new_rendered(const GdCave *data, const int level, guint32 seed); +GdCave *gd_cave_new_rendered(const GdCave *data, const int level, unsigned int seed); void gd_flatten_cave(GdCave *cave, const int level); #endif // BD_CAVEOBJECT_H diff --git a/src/game_bd/bd_caveset.c b/src/game_bd/bd_caveset.c index 50598fb7..0e04806b 100644 --- a/src/game_bd/bd_caveset.c +++ b/src/game_bd/bd_caveset.c @@ -14,9 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include +#include #include "main_bd.h" @@ -99,7 +97,7 @@ void gd_caveset_data_free(GdCavesetData *data) /* free strings */ for (i = 0; gd_caveset_properties[i].identifier != NULL; i++) if (gd_caveset_properties[i].type == GD_TYPE_LONGSTRING) - checked_free(G_STRUCT_MEMBER(char *, data, gd_caveset_properties[i].offset)); + checked_free(STRUCT_MEMBER(char *, data, gd_caveset_properties[i].offset)); free(data); } @@ -257,9 +255,9 @@ static GdColor brc_color_table_comp[] = 0x3526ff, }; -static GdElement brc_effect(guint8 byt) +static GdElement brc_effect(byte byt) { - if (byt >= G_N_ELEMENTS(brc_effect_table)) + if (byt >= ARRAY_SIZE(brc_effect_table)) { Warn("invalid element identifier for brc effect: %02x", byt); @@ -269,7 +267,7 @@ static GdElement brc_effect(guint8 byt) return brc_effect_table[byt]; } -static void brc_import(guint8 *data) +static void brc_import(byte *data) { int x, y; int level; @@ -337,12 +335,12 @@ static void brc_import(guint8 *data) { for (x = 0; x < cave->w; x++) { - guint8 import; + byte import; import = data[y + level * 24 + cavenum * 24 * 5 + x * 24 * 5 * 20]; // if (i == printcave) g_print("%2x", import); - if (import < G_N_ELEMENTS(brc_import_table)) + if (import < ARRAY_SIZE(brc_import_table)) cave->map[y][x] = brc_import_table[import]; else cave->map[y][x] = O_UNKNOWN; @@ -410,7 +408,7 @@ static void brc_import(guint8 *data) cave->intermission = (cavenum >= 16 || data[14 * c + datapos + 1] != 0); /* colors */ - colind = data[31 * c + datapos] % G_N_ELEMENTS(brc_color_table); + colind = data[31 * c + datapos] % ARRAY_SIZE(brc_color_table); cave->colorb = 0x000000; /* fixed rgb black */ cave->color0 = 0x000000; /* fixed rgb black */ cave->color1 = brc_color_table[colind]; @@ -504,7 +502,7 @@ static void caveset_name_set_from_filename(char *filename) */ boolean gd_caveset_load_from_file(char *filename) { - gsize length; + size_t length; char *buf; List *new_caveset; struct stat st; @@ -559,7 +557,7 @@ boolean gd_caveset_load_from_file(char *filename) if (strSuffix(filename, ".brc") || strSuffix(filename, "*.BRC")) { - brc_import((guint8 *) buf); + brc_import((byte *) buf); gd_caveset_edited = FALSE; /* newly loaded cave is not edited */ gd_caveset_last_selected = caveset_first_selectable_cave_index(); gd_caveset_last_selected_level = 0; @@ -570,7 +568,7 @@ boolean gd_caveset_load_from_file(char *filename) } /* BDCFF */ - if (gd_caveset_imported_get_format((guint8 *) buf) == GD_FORMAT_UNKNOWN) + if (gd_caveset_imported_get_format((byte *) buf) == GD_FORMAT_UNKNOWN) { /* try to load as bdcff */ boolean result; @@ -589,7 +587,7 @@ boolean gd_caveset_load_from_file(char *filename) } /* try to load as a binary file, as we know the format */ - new_caveset = gd_caveset_import_from_buffer ((guint8 *) buf, length); + new_caveset = gd_caveset_import_from_buffer ((byte *) buf, length); free(buf); /* if unable to load, exit here. error was reported by import_from_buffer() */ @@ -622,7 +620,7 @@ int gd_cave_check_replays(GdCave *cave, boolean report, boolean remove, boolean while (riter != NULL) { GdReplay *replay = (GdReplay *)riter->data; - guint32 checksum; + unsigned int checksum; GdCave *rendered; List *next = riter->next; diff --git a/src/game_bd/bd_caveset.h b/src/game_bd/bd_caveset.h index f191b17b..95bb7891 100644 --- a/src/game_bd/bd_caveset.h +++ b/src/game_bd/bd_caveset.h @@ -17,8 +17,6 @@ #ifndef BD_CAVESET_H #define BD_CAVESET_H -#include - #include "main_bd.h" @@ -61,7 +59,7 @@ extern char *gd_caveset_extensions[]; /* #included cavesets; configdir passed to look for .hsc file */ boolean gd_caveset_load_from_internal(int caveset, const char *configdir); -const gchar **gd_caveset_get_internal_game_names(void); +const char **gd_caveset_get_internal_game_names(void); /* caveset load from file */ boolean gd_caveset_load_from_file(char *filename); diff --git a/src/game_bd/bd_gameplay.c b/src/game_bd/bd_gameplay.c index a4b7e05b..464682ff 100644 --- a/src/game_bd/bd_gameplay.c +++ b/src/game_bd/bd_gameplay.c @@ -14,9 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "main_bd.h" diff --git a/src/game_bd/bd_gameplay.h b/src/game_bd/bd_gameplay.h index b87a3aea..2e795eba 100644 --- a/src/game_bd/bd_gameplay.h +++ b/src/game_bd/bd_gameplay.h @@ -17,8 +17,6 @@ #ifndef BD_GAMEPLAY_H #define BD_GAMEPLAY_H -#include - #include "bd_cave.h" diff --git a/src/game_bd/bd_graphics.c b/src/game_bd/bd_graphics.c index ffa09986..3471c9d2 100644 --- a/src/game_bd/bd_graphics.c +++ b/src/game_bd/bd_graphics.c @@ -14,8 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include - #include "main_bd.h" @@ -53,7 +51,7 @@ static int scroll_x, scroll_y; /* quit, global variable which is set to true if the application should quit */ boolean gd_quit = FALSE; -const guint8 *gd_keystate; +const byte *gd_keystate; static int cell_size = 0; diff --git a/src/game_bd/bd_graphics.h b/src/game_bd/bd_graphics.h index 15a24b99..fe6c8946 100644 --- a/src/game_bd/bd_graphics.h +++ b/src/game_bd/bd_graphics.h @@ -17,17 +17,15 @@ #ifndef BD_GRAPHICS_H #define BD_GRAPHICS_H -#include - #include "bd_cave.h" #include "bd_gameplay.h" extern Bitmap *gd_screen_bitmap; -extern const Uint8 *gd_keystate; +extern const unsigned char *gd_keystate; -typedef guint32 GdColor; +typedef unsigned int GdColor; void set_cell_size(int s); void set_play_area(int w, int h); diff --git a/src/game_bd/bd_random.c b/src/game_bd/bd_random.c index 08530863..c96b61c5 100644 --- a/src/game_bd/bd_random.c +++ b/src/game_bd/bd_random.c @@ -38,6 +38,7 @@ #include #include #include +#include #if defined(PLATFORM_WINDOWS) #include /* for getpid() */ diff --git a/src/game_bd/bd_sound.c b/src/game_bd/bd_sound.c index af024d95..387ea00d 100644 --- a/src/game_bd/bd_sound.c +++ b/src/game_bd/bd_sound.c @@ -14,8 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include - #include "main_bd.h" @@ -368,7 +366,7 @@ void gd_sound_off(void) int i; /* stop all sounds. */ - for (i = 0; i < G_N_ELEMENTS(snd_playing); i++) + for (i = 0; i < ARRAY_SIZE(snd_playing); i++) halt_channel(i); } diff --git a/src/game_bd/main_bd.h b/src/game_bd/main_bd.h index 5ae28e20..d5ffd8e5 100644 --- a/src/game_bd/main_bd.h +++ b/src/game_bd/main_bd.h @@ -65,6 +65,17 @@ extern int SX, SY; #define SXSIZE (SCR_FIELDX * TILEX) #define SYSIZE (SCR_FIELDY * TILEY) +/* compatibility macros */ + +#define gettext(String) (String) +#define N_(String) (String) +#define _(String) (String) + +#define STRUCT_MEMBER_P(struct_p, struct_offset) \ + ((void *) ((byte *) (struct_p) + (long) (struct_offset))) +#define STRUCT_MEMBER(member_type, struct_p, struct_offset) \ + (*(member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset))) + // ---------------------------------------------------------------------------- // data structure definitions -- 2.34.1