X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_bd%2Fbd_cave.c;h=86b07a889bee26e1a36866053f22b8e78b1e8df3;hb=d2b7c541271aec188c9394af58cdb8d9f66d88b9;hp=9e281798013e74526ca05b0938fc0e620d906de4;hpb=646498771246351aaf243f5ab889179bd9684991;p=rocksndiamonds.git diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index 9e281798..86b07a88 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -1457,105 +1457,6 @@ boolean gd_replay_get_next_movement(GdReplay *replay, GdDirection *player_move, return TRUE; } -void gd_replay_rewind(GdReplay *replay) -{ - replay->current_playing_pos = 0; -} - -#define REPLAY_BDCFF_UP "u" -#define REPLAY_BDCFF_UP_RIGHT "ur" -#define REPLAY_BDCFF_RIGHT "r" -#define REPLAY_BDCFF_DOWN_RIGHT "dr" -#define REPLAY_BDCFF_DOWN "d" -#define REPLAY_BDCFF_DOWN_LEFT "dl" -#define REPLAY_BDCFF_LEFT "l" -#define REPLAY_BDCFF_UP_LEFT "ul" -/* when not moving */ -#define REPLAY_BDCFF_STILL "." -/* when the fire is pressed */ -#define REPLAY_BDCFF_FIRE "F" -#define REPLAY_BDCFF_SUICIDE "k" - -static char *direction_to_bdcff(GdDirection mov) -{ - switch (mov) - { - /* not moving */ - case GD_MV_STILL: return REPLAY_BDCFF_STILL; - - /* directions */ - case GD_MV_UP: return REPLAY_BDCFF_UP; - case GD_MV_UP_RIGHT: return REPLAY_BDCFF_UP_RIGHT; - case GD_MV_RIGHT: return REPLAY_BDCFF_RIGHT; - case GD_MV_DOWN_RIGHT: return REPLAY_BDCFF_DOWN_RIGHT; - case GD_MV_DOWN: return REPLAY_BDCFF_DOWN; - case GD_MV_DOWN_LEFT: return REPLAY_BDCFF_DOWN_LEFT; - case GD_MV_LEFT: return REPLAY_BDCFF_LEFT; - case GD_MV_UP_LEFT: return REPLAY_BDCFF_UP_LEFT; - - default: - return REPLAY_BDCFF_STILL; - } -} - -/* same as above; pressing fire will be a capital letter. */ -static char *direction_fire_to_bdcff(GdDirection dir, boolean fire) -{ - static char mov[10]; - - strcpy(mov, direction_to_bdcff(dir)); - - if (fire) - { - int i; - - for (i = 0; mov[i] != 0; i++) - mov[i] = g_ascii_toupper(mov[i]); - } - - return mov; -} - -char *gd_replay_movements_to_bdcff(GdReplay *replay) -{ - int pos; - GString *str; - - str = g_string_new(NULL); - - for (pos = 0; pos < replay->movements->len; pos++) - { - int num = 1; - guint8 data; - - /* if this is not the first movement, append a space. */ - if (str->len != 0) - g_string_append_c(str, ' '); - - /* if same byte appears, count number of occurrences - something like an rle compression. */ - /* be sure not to cross the array boundaries */ - while (pos < replay->movements->len - 1 && - replay->movements->data[pos] == replay->movements->data[pos + 1]) - { - pos++; - num++; - } - - data = replay->movements->data[pos]; - - if (data & GD_REPLAY_SUICIDE_MASK) - g_string_append(str, REPLAY_BDCFF_SUICIDE); - - g_string_append(str, direction_fire_to_bdcff(data & GD_REPLAY_MOVE_MASK, - data & GD_REPLAY_FIRE_MASK)); - - if (num != 1) - g_string_append_printf(str, "%d", num); - } - - return g_string_free(str, FALSE); -} - /* 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) {