}
/* having read all strings belonging to the cave, process it. */
-static void cave_process_tags(GdCave *cave, HashTable *tags, GList *maplines)
+static void cave_process_tags(GdCave *cave, HashTable *tags, List *maplines)
{
char *value;
/* some old bdcff files use smaller intermissions than the one specified. */
if (maplines)
{
- int x, y, length = g_list_length(maplines);
- GList *iter;
+ int x, y, length = list_length(maplines);
+ List *iter;
/* create map and fill with initial border, in case that map strings are shorter or somewhat */
cave->map = gd_cave_map_new(cave, GdElement);
char **lines;
int lineno;
GdCave *cave;
- GList *iter;
+ List *iter;
boolean reading_replay = FALSE;
boolean reading_map = FALSE;
boolean reading_mapcodes = FALSE;
boolean reading_bdcff_demo = FALSE;
/* assume version to be 0.32, also when the file does not specify it explicitly */
GdString version_read = "0.32";
- GList *mapstrings = NULL;
+ List *mapstrings = NULL;
int linenum;
HashTable *tags, *replay_tags;
GdObjectLevels levels = GD_OBJECT_LEVEL_ALL;
if (mapstrings)
{
Warn("incorrect file format: new [cave] section, but already read some map lines");
- g_list_free(mapstrings);
+ list_free(mapstrings);
mapstrings = NULL;
}
/* ... to be able to create a copy for a new cave. */
cave = gd_cave_new_from_cave(default_cave);
- gd_caveset = g_list_append (gd_caveset, cave);
+ gd_caveset = list_append (gd_caveset, cave);
}
else if (strcasecmp(line, "[/cave]") == 0)
{
cave_process_tags(cave, tags, mapstrings);
- g_list_free(mapstrings);
+ list_free(mapstrings);
mapstrings = NULL;
hashtable_foreach(tags, (hashtable_fn)cave_report_and_copy_unknown_tags_func, cave);
if (mapstrings != NULL)
{
Warn("incorrect file format: new [map] section, but already read some map lines");
- g_list_free(mapstrings);
+ list_free(mapstrings);
mapstrings = NULL;
}
}
replay = gd_replay_new();
replay->saved = TRUE;
replay->success = TRUE; /* we think that it is a successful demo */
- cave->replays = g_list_append(cave->replays, replay);
+ cave->replays = list_append(cave->replays, replay);
gd_strcpy(replay->player_name, "???"); /* name not saved */
}
else
if (replay->movements->len != 0)
{
- cave->replays = g_list_append(cave->replays, replay);
+ cave->replays = list_append(cave->replays, replay);
}
else
{
if (reading_map)
{
/* just append to the mapstrings list. we will process it later */
- mapstrings = g_list_append(mapstrings, line);
+ mapstrings = list_append(mapstrings, line);
continue;
}
if (reading_bdcff_demo)
{
GdReplay *replay;
- GList *iter;
+ List *iter;
/* demo must be in [cave] section. we already showed an error message for this. */
if (cave == default_cave)
continue;
- iter = g_list_last(cave->replays);
+ iter = list_last(cave->replays);
replay = (GdReplay *)iter->data;
replay_store_more_from_bdcff(replay, line);
if (new_object)
{
new_object->levels = levels; /* apply levels to new object */
- cave->objects = g_list_append(cave->objects, new_object);
+ cave->objects = list_append(cave->objects, new_object);
}
else
{
if (mapstrings)
{
Warn("incorrect file format: end of file, but still have some map lines read");
- g_list_free(mapstrings);
+ list_free(mapstrings);
mapstrings = NULL;
}
if (strEqual(version_read, "0.32"))
{
- GList *iter;
+ List *iter;
Warn("No BDCFF version, or 0.32. Using unspecified-intermission-size hack.");
object.element = cave->initial_border;
object.fill_element = cave->initial_border;
- cave->objects = g_list_prepend(cave->objects, getMemCopy(&object, sizeof(object)));
+ cave->objects = list_prepend(cave->objects, getMemCopy(&object, sizeof(object)));
object.x1 = 19;
object.y1 = 0; /* 19, as it is also the border */
- cave->objects = g_list_prepend(cave->objects, getMemCopy(&object, sizeof(object))); /* another */
+ cave->objects = list_prepend(cave->objects, getMemCopy(&object, sizeof(object))); /* another */
}
}
}
{
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));
}
}
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;
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;
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;
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;
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;
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;
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;
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;
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;
{
/* 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 */
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;
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;
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;
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;
{
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;
}
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;
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;
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;
gint32 prob[4] = { 37, 32, 2, 0 };
gint32 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)
gint32 prob[4] = { 0x18, 0x08, 0, 0 };
gint32 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));
+ 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)
GdElement rand[4] = { O_STONE, O_DIRT, O_DIRT, O_DIRT };
gint32 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 */
}
{
gint32 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));
}
}
/*
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 guint8 *buf, gsize length)
{
boolean numbering;
int cavenum, intermissionnum, num;
int cavelength, bufp;
- GList *caveset = NULL, *iter;
+ List *caveset = NULL, *iter;
guint32 encodedlength;
GdCavefileFormat format;
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();
}
else
{
- caveset = g_list_insert(caveset, newcave, insertpos);
+ caveset = list_insert(caveset, newcave, insertpos);
}
cavenum++;
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)
{
/* 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)
{