From 038fb64da88a05a91c974dc1e3b14cf4cdc69743 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 20 Feb 2020 18:36:53 +0100 Subject: [PATCH] renamed and removed some variables --- src/game_em/convert.c | 18 +++++++++--------- src/game_em/emerald.h | 23 +++++++++++------------ src/game_em/graphics.c | 12 ++++++------ src/game_em/logic.c | 13 ++++++------- 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/game_em/convert.c b/src/game_em/convert.c index e5bc5c68..0ae1f35b 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -381,13 +381,13 @@ void prepare_em_level(void) for (i = 0; i < MAX_PLAYERS; i++) { - ply[i].exists = 0; - ply[i].alive_initial = FALSE; + ply[i].exists = FALSE; + ply[i].alive = FALSE; if (cav.player_x[i] != -1 && cav.player_y[i] != -1) { - ply[i].exists = 1; + ply[i].exists = TRUE; lev.home_initial++; } @@ -407,7 +407,7 @@ void prepare_em_level(void) { if (players_left) { - ply[i].alive_initial = TRUE; + ply[i].alive = TRUE; players_left--; } else @@ -425,17 +425,17 @@ void prepare_em_level(void) for (i = 0; i < MAX_PLAYERS; i++) { ply[i].num = i; - ply[i].alive = ply[i].alive_initial; ply[i].dynamite = 0; ply[i].dynamite_cnt = 0; ply[i].keys = 0; ply[i].anim = 0; - ply[i].oldx = ply[i].x = cav.player_x[i] + lev.left; - ply[i].oldy = ply[i].y = cav.player_y[i] + lev.top; + ply[i].prev_x = ply[i].x = cav.player_x[i] + lev.left; + ply[i].prev_y = ply[i].y = cav.player_y[i] + lev.top; ply[i].last_move_dir = MV_NONE; ply[i].joy_n = ply[i].joy_e = ply[i].joy_s = ply[i].joy_w = 0; - ply[i].joy_snap = ply[i].joy_drop = 0; - ply[i].joy_stick = ply[i].joy_spin = 0; + ply[i].joy_snap = 0; + ply[i].joy_drop = 0; + ply[i].joy_stick = 0; } // the following engine variables are initialized to version-specific values diff --git a/src/game_em/emerald.h b/src/game_em/emerald.h index 50038d4d..a74769fd 100644 --- a/src/game_em/emerald.h +++ b/src/game_em/emerald.h @@ -620,20 +620,20 @@ enum struct PLAYER { - int num; - int exists; - int alive_initial; - int alive; - - int dynamite; - int dynamite_cnt; - int keys; int anim; - int x; int y; - int oldx; - int oldy; + int prev_x; + int prev_y; + + int num; /* player number */ + + boolean exists; /* flag if player exists in cave */ + boolean alive; /* flag if player is alive */ + + int dynamite; /* number of pieces of collected dynamite */ + int dynamite_cnt; /* how long the player has held down fire */ + int keys; /* keys the player has collected */ int last_move_dir; @@ -644,7 +644,6 @@ struct PLAYER int joy_snap:1; int joy_drop:1; int joy_stick:1; - int joy_spin:1; }; struct LOGIC diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 4ea90bd6..363cb9af 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -25,9 +25,9 @@ #define VALID_SCREEN_Y(y) ((y) < MIN_SCREEN_Y ? MIN_SCREEN_Y : \ (y) > MAX_SCREEN_Y ? MAX_SCREEN_Y : (y)) -#define PLAYER_POS_X(nr) (((7 - frame) * ply[nr].oldx + \ +#define PLAYER_POS_X(nr) (((7 - frame) * ply[nr].prev_x + \ (1 + frame) * ply[nr].x) * TILEX / 8) -#define PLAYER_POS_Y(nr) (((7 - frame) * ply[nr].oldy + \ +#define PLAYER_POS_Y(nr) (((7 - frame) * ply[nr].prev_y + \ (1 + frame) * ply[nr].y) * TILEY / 8) #define PLAYER_SCREEN_X(nr) (PLAYER_POS_X(nr) - \ @@ -385,10 +385,10 @@ static void blitplayer(int nr) (int)(y2 - screen_y) < ((MAX_BUF_YSIZE - 1) * TILEY - 1)) { /* some casts to "int" are needed because of negative calculation values */ - int dx = (int)ply[nr].x - (int)ply[nr].oldx; - int dy = (int)ply[nr].y - (int)ply[nr].oldy; - int old_x = (int)ply[nr].oldx + (int)frame * dx / 8; - int old_y = (int)ply[nr].oldy + (int)frame * dy / 8; + int dx = (int)ply[nr].x - (int)ply[nr].prev_x; + int dy = (int)ply[nr].y - (int)ply[nr].prev_y; + int old_x = (int)ply[nr].prev_x + (int)frame * dx / 8; + int old_y = (int)ply[nr].prev_y + (int)frame * dy / 8; int new_x = old_x + SIGN(dx); int new_y = old_y + SIGN(dy); int old_sx = old_x % MAX_BUF_XSIZE; diff --git a/src/game_em/logic.c b/src/game_em/logic.c index 001e47b0..f4968eed 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -340,7 +340,7 @@ static void kill_player(struct PLAYER *ply) int x = ply->x; int y = ply->y; - ply->alive = 0; + ply->alive = FALSE; switch (cave[x][y-1]) { @@ -1390,7 +1390,6 @@ static void check_player(struct PLAYER *ply) ply->joy_stick = 1; ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0; ply->dynamite_cnt = 0; /* reset dynamite timer if we move */ - ply->joy_spin = !ply->joy_spin; if (ply->joy_snap == 0) /* player wants to move */ { @@ -7304,8 +7303,8 @@ static void logic_players(void) game.set_centered_player_wrap = TRUE; } - ply[i].oldx = ply[i].x; - ply[i].oldy = ply[i].y; + ply[i].prev_x = ply[i].x; + ply[i].prev_y = ply[i].y; ply[i].anim = PLY_still; } @@ -7325,10 +7324,10 @@ static void logic_players(void) if (!ply[i].alive) continue; - if (cave[ply[i].oldx][ply[i].oldy] == Zplayer) + if (cave[ply[i].prev_x][ply[i].prev_y] == Zplayer) { - cave[ply[i].oldx][ply[i].oldy] = Xblank; - next[ply[i].oldx][ply[i].oldy] = Xblank; + cave[ply[i].prev_x][ply[i].prev_y] = Xblank; + next[ply[i].prev_x][ply[i].prev_y] = Xblank; } if (cave[ply[i].x][ply[i].y] == Xblank) -- 2.34.1