From 64eb09ed578961446d1271ab8a179efbd871a74f Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 24 Jun 2024 17:55:32 +0200 Subject: [PATCH] renamed variables This renames misleading variable names in the BD game engine for two buffers that do not contain actual playfield elements, but mapped elements only used for (re)drawing the playfield element graphics. --- src/game_bd/bd_cave.c | 8 +++---- src/game_bd/bd_cave.h | 2 +- src/game_bd/bd_gameplay.c | 44 +++++++++++++++++++-------------------- src/game_bd/bd_gameplay.h | 4 ++-- src/game_bd/bd_graphics.c | 6 +++--- src/game_bd/export_bd.h | 4 ++-- src/game_bd/main_bd.c | 12 +++++------ 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index 6a22a637..a406afb7 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -1317,7 +1317,7 @@ void gd_cave_count_diamonds(GdCave *cave) by the caller. */ void gd_drawcave_game(const GdCave *cave, - int **element_buffer, int **last_element_buffer, int **gfx_buffer, + int **drawing_buffer, int **last_drawing_buffer, int **gfx_buffer, boolean bonus_life_flash, int animcycle, boolean hate_invisible_outbox) { static int player_blinking = 0; @@ -1558,7 +1558,7 @@ void gd_drawcave_game(const GdCave *cave, // special check needed when smooth game element movements selected in setup menu: // last element must either be player (before pushing) or pushable element (while pushing) // (extra check needed to prevent pushing animation when moving towards pushable element) - if (!use_bd_smooth_movements() || last_element_buffer[y][x] != O_SPACE) + if (!use_bd_smooth_movements() || last_drawing_buffer[y][x] != O_SPACE) { if (cave->last_direction == GD_MV_LEFT) map = O_PLAYER_PUSH_LEFT; @@ -1581,8 +1581,8 @@ void gd_drawcave_game(const GdCave *cave, draw += GD_NUM_OF_CELLS; // set to buffer, with caching - if (element_buffer[y][x] != map) - element_buffer[y][x] = map; + if (drawing_buffer[y][x] != map) + drawing_buffer[y][x] = map; if (gfx_buffer[y][x] != draw) gfx_buffer[y][x] = draw | GD_REDRAW; diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index 3dede416..c551de65 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -704,7 +704,7 @@ GdScheduling gd_scheduling_from_string(const char *str); #define GD_REDRAW (1 << 10) void gd_drawcave_game(const GdCave *cave, - int **element_buffer, int **last_element_buffer, int **gfx_buffer, + int **drawing_buffer, int **last_drawing_buffer, int **gfx_buffer, boolean bonus_life_flash, int animcycle, boolean hate_invisible_outbox); // function to copy a GdString diff --git a/src/game_bd/bd_gameplay.c b/src/game_bd/bd_gameplay.c index 0b4f48cd..db10e62e 100644 --- a/src/game_bd/bd_gameplay.c +++ b/src/game_bd/bd_gameplay.c @@ -22,10 +22,10 @@ void gd_game_free(GdGame *game) // stop sounds gd_sound_off(); - if (game->element_buffer) - gd_cave_map_free(game->element_buffer); - if (game->last_element_buffer) - gd_cave_map_free(game->last_element_buffer); + if (game->drawing_buffer) + gd_cave_map_free(game->drawing_buffer); + if (game->last_drawing_buffer) + gd_cave_map_free(game->last_drawing_buffer); if (game->dir_buffer_from) gd_cave_map_free(game->dir_buffer_from); if (game->dir_buffer_to) @@ -81,15 +81,15 @@ static void load_cave(GdGame *game) { int x, y; - // delete element buffer - if (game->element_buffer) - gd_cave_map_free(game->element_buffer); - game->element_buffer = NULL; + // delete drawing buffer + if (game->drawing_buffer) + gd_cave_map_free(game->drawing_buffer); + game->drawing_buffer = NULL; - // delete last element buffer - if (game->last_element_buffer) - gd_cave_map_free(game->last_element_buffer); - game->last_element_buffer = NULL; + // delete last drawing buffer + if (game->last_drawing_buffer) + gd_cave_map_free(game->last_drawing_buffer); + game->last_drawing_buffer = NULL; // delete direction buffer (from) if (game->dir_buffer_from) @@ -131,19 +131,19 @@ static void load_cave(GdGame *game) game->cycle_counter = 0; - // create new element buffer - game->element_buffer = gd_cave_map_new(game->cave, int); + // create new drawing buffer + game->drawing_buffer = gd_cave_map_new(game->cave, int); for (y = 0; y < game->cave->h; y++) for (x = 0; x < game->cave->w; x++) - game->element_buffer[y][x] = O_NONE; + game->drawing_buffer[y][x] = O_NONE; - // create new last element buffer - game->last_element_buffer = gd_cave_map_new(game->cave, int); + // create new last drawing buffer + game->last_drawing_buffer = gd_cave_map_new(game->cave, int); for (y = 0; y < game->cave->h; y++) for (x = 0; x < game->cave->w; x++) - game->last_element_buffer[y][x] = O_NONE; + game->last_drawing_buffer[y][x] = O_NONE; // create new direction buffer (from) game->dir_buffer_from = gd_cave_map_new(game->cave, int); @@ -406,7 +406,7 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean { for (x = 0; x < game->cave->w; x++) { - game->last_element_buffer[y][x] = game->element_buffer[y][x]; + game->last_drawing_buffer[y][x] = game->drawing_buffer[y][x]; game->dir_buffer_from[y][x] = GD_MV_STILL; game->dir_buffer_to[y][x] = GD_MV_STILL; } @@ -595,8 +595,8 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean // always render the cave to the gfx buffer; // however it may do nothing if animcycle was not changed. - if (game->element_buffer && game->gfx_buffer) - gd_drawcave_game(game->cave, game->element_buffer, game->last_element_buffer, game->gfx_buffer, + if (game->drawing_buffer && game->gfx_buffer) + gd_drawcave_game(game->cave, game->drawing_buffer, game->last_drawing_buffer, game->gfx_buffer, game->bonus_life_flash != 0, game->animcycle, setup.bd_show_invisible_outbox); game->state_counter = counter_next; @@ -650,7 +650,7 @@ void play_game_func(GdGame *game, int action) // if drawcave was before scrolling, it would draw, scroll would invalidate, // and then it should be drawn again // only do the drawing if the cave already exists. - if (game->cave && game->element_buffer && game->gfx_buffer) + if (game->cave && game->drawing_buffer && game->gfx_buffer) { // if fine scrolling, scroll at 50hz. if not, only scroll at every second call, so 25hz. // do the scrolling. scroll exactly, if player is not yet alive diff --git a/src/game_bd/bd_gameplay.h b/src/game_bd/bd_gameplay.h index 2ea5d8c4..1378f0ef 100644 --- a/src/game_bd/bd_gameplay.h +++ b/src/game_bd/bd_gameplay.h @@ -75,8 +75,8 @@ typedef struct _gd_game int bonus_life_flash; // different kind of flashing, for bonus life int state_counter; // counter used to control the game flow, rendering of caves - int **element_buffer; - int **last_element_buffer; + int **drawing_buffer; + int **last_drawing_buffer; int **dir_buffer_from; int **dir_buffer_to; int **gfx_buffer; // contains the indexes to the cells; diff --git a/src/game_bd/bd_graphics.c b/src/game_bd/bd_graphics.c index fa139d0c..881a6788 100644 --- a/src/game_bd/bd_graphics.c +++ b/src/game_bd/bd_graphics.c @@ -602,8 +602,8 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d int sy = y * cell_size - scroll_y; int dir_from = game->dir_buffer_from[y][x]; int dir_to = game->dir_buffer_to[y][x]; - int tile = game->element_buffer[y][x]; - int tile_last = game->last_element_buffer[y][x]; + int tile = game->drawing_buffer[y][x]; + int tile_last = game->last_drawing_buffer[y][x]; int tile_from = O_NONE; // source element if element is moving (will be set later) int tile_to = tile; // target element if element is moving int frame = game->animcycle; @@ -620,7 +620,7 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d int new_x = cave->getx(cave, x + dx, y + dy); int new_y = cave->gety(cave, x + dx, y + dy); - tile_from = game->element_buffer[new_y][new_x]; + tile_from = game->drawing_buffer[new_y][new_x]; // handle special case of player running into enemy/explosion from top or left side if ((el_growing(tile_from) || el_explosion(tile_from)) && el_player(tile_last)) diff --git a/src/game_bd/export_bd.h b/src/game_bd/export_bd.h index 7778b066..ea288cd8 100644 --- a/src/game_bd/export_bd.h +++ b/src/game_bd/export_bd.h @@ -81,8 +81,8 @@ struct EngineSnapshotInfo_BD GdGame game; // data from pointers in game structure - int element_buffer[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; - int last_element_buffer[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; + int drawing_buffer[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; + int last_drawing_buffer[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; int dir_buffer_from[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; int dir_buffer_to[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; int gfx_buffer[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index 4404d0ab..4e0396fc 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -572,8 +572,8 @@ void SaveEngineSnapshotValues_BD(void) { for (x = 0; x < cave->w; x++) { - engine_snapshot_bd.element_buffer[x][y] = game->element_buffer[y][x]; - engine_snapshot_bd.last_element_buffer[x][y] = game->last_element_buffer[y][x]; + engine_snapshot_bd.drawing_buffer[x][y] = game->drawing_buffer[y][x]; + engine_snapshot_bd.last_drawing_buffer[x][y] = game->last_drawing_buffer[y][x]; engine_snapshot_bd.dir_buffer_from[x][y] = game->dir_buffer_from[y][x]; engine_snapshot_bd.dir_buffer_to[x][y] = game->dir_buffer_to[y][x]; engine_snapshot_bd.gfx_buffer[x][y] = game->gfx_buffer[y][x]; @@ -604,8 +604,8 @@ void LoadEngineSnapshotValues_BD(void) engine_snapshot_bd.game.cave = game->cave; engine_snapshot_bd.game.original_cave = game->original_cave; - engine_snapshot_bd.game.element_buffer = game->element_buffer; - engine_snapshot_bd.game.last_element_buffer = game->last_element_buffer; + engine_snapshot_bd.game.drawing_buffer = game->drawing_buffer; + engine_snapshot_bd.game.last_drawing_buffer = game->last_drawing_buffer; engine_snapshot_bd.game.dir_buffer_from = game->dir_buffer_from; engine_snapshot_bd.game.dir_buffer_to = game->dir_buffer_to; engine_snapshot_bd.game.gfx_buffer = game->gfx_buffer; @@ -616,8 +616,8 @@ void LoadEngineSnapshotValues_BD(void) { for (x = 0; x < cave->w; x++) { - game->element_buffer[y][x] = engine_snapshot_bd.element_buffer[x][y]; - game->last_element_buffer[y][x] = engine_snapshot_bd.last_element_buffer[x][y]; + game->drawing_buffer[y][x] = engine_snapshot_bd.drawing_buffer[x][y]; + game->last_drawing_buffer[y][x] = engine_snapshot_bd.last_drawing_buffer[x][y]; game->dir_buffer_from[y][x] = engine_snapshot_bd.dir_buffer_from[x][y]; game->dir_buffer_to[y][x] = engine_snapshot_bd.dir_buffer_to[x][y]; game->gfx_buffer[y][x] = engine_snapshot_bd.gfx_buffer[x][y]; -- 2.34.1