X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_bd%2Fbd_c64import.c;h=f878472e949f9852e0b5c16d7a91202340827ca5;hb=157fb76461d332a22233e6664cd294d7db5d3558;hp=36e2dc080d0cdaa3aa6b7f5f808776a15bfaa108;hpb=2be47982a3acd069ebfdb2a75b26f770257932a6;p=rocksndiamonds.git diff --git a/src/game_bd/bd_c64import.c b/src/game_bd/bd_c64import.c index 36e2dc08..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 */ @@ -690,7 +687,7 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by { int pos = x1 + y1 * 40 + y * dy * 40 + x * dx; - cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, pos % 40, pos / 40, elem)); + cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, pos % 40, pos / 40, elem)); } } @@ -710,7 +707,7 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by if (x1 >= cave->w || y1 >= cave->h) Warn("invalid point coordinates %d,%d at byte %d", x1, y1, index); - cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); + cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); index += 3; break; @@ -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) @@ -742,7 +739,7 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by y2 >= cave->h) Warn("invalid line coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); - cave->objects = g_list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); + cave->objects = list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); } index += 5; @@ -760,7 +757,7 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by y2 >= cave->h) Warn("invalid filled rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); - cave->objects = g_list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem, import_func(data[index + 5], index + 5))); + cave->objects = list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem, import_func(data[index + 5], index + 5))); index += 6; break; @@ -777,7 +774,7 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by y2 >= cave->h) Warn("invalid rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); - cave->objects = g_list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); + cave->objects = list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); index += 5; break; @@ -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; @@ -813,7 +810,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by gd_cave_set_engine_defaults(cave, GD_ENGINE_BD2); - if (format==GD_FORMAT_BD2_ATARI) + if (format == GD_FORMAT_BD2_ATARI) cave->scheduling = GD_SCHEDULING_BD2_PLCK_ATARI; /* set visible size for intermission */ @@ -829,11 +826,11 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by for (i = 0; i < 5; i++) { /* 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02. */ - cave->level_amoeba_time[i] = data[0]==0 ? 999 : data[0]; + cave->level_amoeba_time[i] = data[0] == 0 ? 999 : data[0]; cave->level_rand[i] = data[13 + i]; /* gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 needed */ - cave->level_diamonds[i] = data[8 + i]==0 ? 1000 : data[8 + i]; + cave->level_diamonds[i] = data[8 + i] == 0 ? 1000 : data[8 + i]; cave->level_time[i] = data[3 + i]; cave->level_magic_wall_time[i] = data[0]; } @@ -882,7 +879,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by y2 >= cave->h) Warn("invalid line coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); - cave->objects = g_list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); + cave->objects = list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); index += 6; break; @@ -900,7 +897,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by y2 >= cave->h) Warn("invalid rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); - cave->objects = g_list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); + cave->objects = list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); index += 6; break; @@ -918,7 +915,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by y2 >= cave->h) Warn("invalid filled rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); - cave->objects = g_list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem, bd1_import(data[index+6], index+6))); + cave->objects = list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem, bd1_import(data[index+6], index+6))); index += 7; break; @@ -932,7 +929,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by y1 >= cave->h) Warn("invalid point coordinates %d,%d at byte %d", x1, y1, index); - cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); + cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); index += 4; break; @@ -960,7 +957,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by y2 >= cave->h) Warn("invalid raster coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); - cave->objects = g_list_append(cave->objects, gd_object_new_raster(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, elem)); + cave->objects = list_append(cave->objects, gd_object_new_raster(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, elem)); index += 8; break; @@ -995,7 +992,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by { /* for (8 bits in a byte) */ if ((val & 1) != 0) /* convert to single points... */ - cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); + cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); val >>= 1; x1++; /* next cave pos */ @@ -1015,7 +1012,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by case 6: /* JOIN */ dy = data[index + 3] / 40; dx = data[index + 3] % 40; /* same byte!!! */ - cave->objects = g_list_append(cave->objects, gd_object_new_join(GD_OBJECT_LEVEL_ALL, dx, dy, bd1_import(data[index+1], index+1), bd1_import(data[index+2], index+2))); + cave->objects = list_append(cave->objects, gd_object_new_join(GD_OBJECT_LEVEL_ALL, dx, dy, bd1_import(data[index+1], index+1), bd1_import(data[index+2], index+2))); index += 4; break; @@ -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. */ @@ -1165,7 +1162,7 @@ static int cave_copy_from_plck(GdCave *cave, const guint8 *data, for (j = 0; j < 12; j++) cave->name[j] = data[0x1f2 + j]; - g_strchomp(cave->name); /* remove spaces */ + chompString(cave->name); /* remove spaces */ } else { @@ -1231,7 +1228,7 @@ static int cave_copy_from_plck(GdCave *cave, const guint8 *data, cave->map[cave->h - 1][x] = O_STEEL; /* - if (steels && data[0]==0x55) + if (steels && data[0] == 0x55) cave->map[cave->h - 1][0] = cave->map[cave->h - 1][1] = O_STEEL; */ @@ -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; @@ -1452,12 +1449,12 @@ static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_b c = ' '; /* don't know this, so change to space */ if (i > 0) - c = g_ascii_tolower(c); + c = tolower(c); cave->name[i] = c; } - g_strchomp(cave->name); + chompString(cave->name); cave->intermission = data[0x389] != 0; @@ -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, " "); @@ -1581,12 +1578,12 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining else c = ' '; if (i > 0) - c = g_ascii_tolower(c); + c = tolower(c); cave->name[i] = c; } - g_strchomp(cave->name); /* remove trailing and leading spaces */ + chompString(cave->name); /* remove trailing and leading spaces */ cave->selectable = data[14] != 0; @@ -1752,7 +1749,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining if (x1 >= cave->w || y1 >= cave->h) Warn("invalid point coordinates %d,%d at byte %d", x1, y1, index); - cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); + cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); index += 4; break; @@ -1770,7 +1767,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining y2 >= cave->h) Warn("invalid rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); - cave->objects = g_list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); + cave->objects = list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); index += 6; break; @@ -1788,7 +1785,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining Warn("invalid filled rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); /* border and inside of fill is the same element. */ - cave->objects = g_list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, crazydream_import_table[data[index + 1]], crazydream_import_table[data[index + 1]])); + cave->objects = list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, crazydream_import_table[data[index + 1]], crazydream_import_table[data[index + 1]])); index += 6; break; @@ -1812,7 +1809,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining { for (i = 0; i < length; i++) { - cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); + cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem)); x1 += nx; y1 += ny; } @@ -1826,7 +1823,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining y2 >= cave->h) Warn("invalid line coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index - 5); - cave->objects = g_list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); + cave->objects = list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem)); } index += 6; @@ -1863,7 +1860,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining dy + ch > cave->h) Warn("invalid paste coordinates %d,%d at byte %d", dx, dy, index); - cave->objects = g_list_append(cave->objects, gd_object_new_copy_paste(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, FALSE, FALSE)); + cave->objects = list_append(cave->objects, gd_object_new_copy_paste(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, FALSE, FALSE)); index += 3; break; @@ -1890,7 +1887,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining y2 >= cave->h) Warn("invalid raster coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index); - cave->objects = g_list_append(cave->objects, gd_object_new_raster(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, elem)); + cave->objects = list_append(cave->objects, gd_object_new_raster(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, elem)); index += 8; break; @@ -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,53 +1927,53 @@ 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 = g_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)); + 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, "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 = g_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)); + 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 }; - cave->objects = g_list_append(cave->objects, gd_object_new_maze(GD_OBJECT_LEVEL_ALL, 1, 4, 35, 20, 1, 1, O_NONE, O_DIRT, 50, seeds)); + 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 = g_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 = g_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)); + 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)); cave->creatures_backwards = TRUE; /* for some reason, this level worked like that */ } 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 = g_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)); + 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)); /* a point which "breaks" the unicursal maze, making it one very long path */ - cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, 35, 18, O_BRICK)); + cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, 35, 18, O_BRICK)); } } /* 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); @@ -2028,12 +2025,12 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b c = ' '; if (i > 0) - c = g_ascii_tolower(c); + c = tolower(c); cave->name[i] = c; } - g_strchomp(cave->name); /* remove trailing and leading spaces */ + chompString(cave->name); /* remove trailing and leading spaces */ } /* uncompress rle data */ @@ -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; @@ -2194,7 +2191,7 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b } cave->biter_delay_frame = uncompressed[0x394]; - cave->magic_wall_stops_amoeba = uncompressed[0x395]==0; /* negated!! */ + cave->magic_wall_stops_amoeba = uncompressed[0x395] == 0; /* negated!! */ cave->bomb_explosion_effect = import(uncompressed[0x396], 0x396); cave->explosion_effect = import(uncompressed[0x397], 0x397); cave->stone_bouncing_effect = import(uncompressed[0x398], 0x398); @@ -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"; @@ -2295,15 +2292,15 @@ GdCavefileFormat gd_caveset_imported_get_format(const guint8 *buf) /* Load caveset from memory buffer. Loads the caveset from a memory buffer. - returns: GList * of caves. + returns: List * of caves. */ -GList *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; - GList *caveset = NULL, *iter; - guint32 encodedlength; + List *caveset = NULL, *iter; + unsigned int encodedlength; GdCavefileFormat format; if (length != -1 && length < 12) @@ -2312,7 +2309,7 @@ GList *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"); @@ -2320,7 +2317,7 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) } format = gd_caveset_imported_get_format(buf); - if (format==GD_FORMAT_UNKNOWN) + if (format == GD_FORMAT_UNKNOWN) { Warn("buffer does not contain a GDash datafile"); return NULL; @@ -2335,7 +2332,7 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) while (bufp < length) { GdCave *newcave; - /* default is to append cave to caveset; g_list_insert appends when pos = -1 */ + /* default is to append cave to caveset; list_insert appends when pos = -1 */ int insertpos = -1; newcave = gd_cave_new(); @@ -2355,9 +2352,9 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) /* no name, so we make up one */ if (newcave->intermission) - g_snprintf(newcave->name, sizeof(newcave->name), _("Intermission %d"), cavenum - 15); + snprintf(newcave->name, sizeof(newcave->name), _("Intermission %d"), cavenum - 15); else - g_snprintf(newcave->name, sizeof(newcave->name), _("Cave %c"), 'A' + cavenum); + snprintf(newcave->name, sizeof(newcave->name), _("Cave %c"), 'A' + cavenum); switch(format) { @@ -2407,9 +2404,9 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) newcave->selectable = cavenum % 5 == 0; /* original selection scheme */ if (newcave->intermission) - g_snprintf(newcave->name, sizeof(newcave->name), _("Intermission %d"), cavenum / 5 + 1); + snprintf(newcave->name, sizeof(newcave->name), _("Intermission %d"), cavenum / 5 + 1); else - g_snprintf(newcave->name, sizeof(newcave->name), _("Cave %c"), 'A'+(cavenum % 5 + cavenum / 5 * 4)); + snprintf(newcave->name, sizeof(newcave->name), _("Cave %c"), 'A'+(cavenum % 5 + cavenum / 5 * 4)); cavelength = cave_copy_from_dlb (newcave, buf + bufp, length - bufp); break; @@ -2441,7 +2438,7 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) } else { - caveset = g_list_insert(caveset, newcave, insertpos); + caveset = list_insert(caveset, newcave, insertpos); } cavenum++; @@ -2463,11 +2460,11 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) if ((buf[2 + 0x1f0] != buf[2 + 0x1f1] - 1) || (buf[2 + 0x1f0] != 0x19 && buf[2 + 0x1f0] != 0x0e)) { - GList *iter; + List *iter; int n; boolean standard; - standard = (g_list_length(caveset)%5) == 0; /* cave count % 5 != 0 -> nonstandard */ + standard = (list_length(caveset)%5) == 0; /* cave count % 5 != 0 -> nonstandard */ for (n = 0, iter = caveset; iter != NULL; n++, iter = iter->next) { @@ -2496,7 +2493,7 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) /* use numbering instead of letters, if following formats or too many caves (as we would run out of letters) */ - numbering = format == GD_FORMAT_PLC || format==GD_FORMAT_CRLI || g_list_length(caveset) > 26; + numbering = format == GD_FORMAT_PLC || format == GD_FORMAT_CRLI || list_length(caveset) > 26; for (iter = caveset; iter != NULL; iter = iter->next) { @@ -2509,14 +2506,14 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length) { /* intermission */ if (numbering) - g_snprintf(cave->name, sizeof(cave->name), _("Intermission %02d"), num); + snprintf(cave->name, sizeof(cave->name), _("Intermission %02d"), num); else - g_snprintf(cave->name, sizeof(cave->name), _("Intermission %d"), intermissionnum); + snprintf(cave->name, sizeof(cave->name), _("Intermission %d"), intermissionnum); } else { if (numbering) - g_snprintf(cave->name, sizeof(cave->name), _("Cave %02d"), num); + snprintf(cave->name, sizeof(cave->name), _("Cave %02d"), num); else - g_snprintf(cave->name, sizeof(cave->name), _("Cave %c"), 'A' - 1 + cavenum); + snprintf(cave->name, sizeof(cave->name), _("Cave %c"), 'A' - 1 + cavenum); } num++;