From: Holger Schemel Date: Fri, 21 Feb 2020 08:34:27 +0000 (+0100) Subject: renamed some variables and changed some initializations X-Git-Tag: 4.2.0.0~76 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=76966ac62fb1c36c12b64d60915afcbe149635ff;p=rocksndiamonds.git renamed some variables and changed some initializations --- diff --git a/src/editor.c b/src/editor.c index 3f56f42a..f648853f 100644 --- a/src/editor.c +++ b/src/editor.c @@ -642,7 +642,7 @@ enum GADGET_ID_USE_TIME_ORB_BUG, GADGET_ID_USE_LIFE_BUGS, GADGET_ID_RANDOM_BALL_CONTENT, - GADGET_ID_INITIAL_BALL_STATE, + GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_GROW_INTO_DIGGABLE, GADGET_ID_SB_FIELDS_NEEDED, GADGET_ID_SB_OBJECTS_NEEDED, @@ -947,7 +947,7 @@ enum ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG, ED_CHECKBUTTON_ID_USE_LIFE_BUGS, ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT, - ED_CHECKBUTTON_ID_INITIAL_BALL_STATE, + ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE, ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE, ED_CHECKBUTTON_ID_SB_FIELDS_NEEDED, ED_CHECKBUTTON_ID_SB_OBJECTS_NEEDED, @@ -3060,8 +3060,8 @@ static struct }, { ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1), - GADGET_ID_INITIAL_BALL_STATE, GADGET_ID_NONE, - &level.ball_state_initial, + GADGET_ID_INITIAL_BALL_ACTIVE, GADGET_ID_NONE, + &level.ball_active_initial, NULL, NULL, "magic ball initially activated", "activate magic ball after level start" }, @@ -9896,7 +9896,7 @@ static void DrawPropertiesConfig(void) DrawMagicBallContentAreas(); MapCheckbuttonGadget(ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT); - MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_STATE); + MapCheckbuttonGadget(ED_CHECKBUTTON_ID_INITIAL_BALL_ACTIVE); } else if (properties_element == EL_EMC_ANDROID) DrawAndroidElementArea(properties_element); diff --git a/src/files.c b/src/files.c index d4751ae5..fd7cfcf4 100644 --- a/src/files.c +++ b/src/files.c @@ -815,7 +815,7 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] = { EL_EMC_MAGIC_BALL, -1, TYPE_BOOLEAN, CONF_VALUE_8_BIT(2), - &li.ball_state_initial, FALSE + &li.ball_active_initial, FALSE }, { EL_EMC_MAGIC_BALL, -1, @@ -3554,7 +3554,7 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) cav->android_move_time = level->android_move_time; cav->android_clone_time = level->android_clone_time; cav->ball_random = level->ball_random; - cav->ball_state = level->ball_state_initial; + cav->ball_active = level->ball_active_initial; cav->ball_time = level->ball_time; cav->num_ball_arrays = level->num_ball_contents; @@ -3567,8 +3567,6 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) cav->wind_direction = map_direction_RND_to_EM(level->wind_direction_initial); - cav->wind_cnt = (level->wind_direction_initial != MV_NONE ? - cav->wind_time : 0); for (i = 0; i < MAX_ELEMENT_CONTENTS; i++) for (j = 0; j < 8; j++) @@ -3666,7 +3664,7 @@ static void CopyNativeLevel_EM_to_RND(struct LevelInfo *level) level->android_move_time = cav->android_move_time; level->android_clone_time = cav->android_clone_time; level->ball_random = cav->ball_random; - level->ball_state_initial = cav->ball_state; + level->ball_active_initial = cav->ball_active; level->ball_time = cav->ball_time; level->num_ball_contents = cav->num_ball_arrays; diff --git a/src/game.c b/src/game.c index 862c5083..128c677f 100644 --- a/src/game.c +++ b/src/game.c @@ -1963,12 +1963,12 @@ static void InitField(int x, int y, boolean init_game) break; case EL_EMC_MAGIC_BALL: - if (game.ball_state) + if (game.ball_active) Feld[x][y] = EL_EMC_MAGIC_BALL_ACTIVE; break; case EL_EMC_MAGIC_BALL_SWITCH: - if (game.ball_state) + if (game.ball_active) Feld[x][y] = EL_EMC_MAGIC_BALL_SWITCH_ACTIVE; break; @@ -2366,9 +2366,9 @@ static void UpdateGameControlValues(void) (exit_closed ? EL_EXIT_CLOSED : EL_EXIT_OPEN); game_panel_controls[GAME_PANEL_EMC_MAGIC_BALL].value = - (game.ball_state ? EL_EMC_MAGIC_BALL_ACTIVE : EL_EMC_MAGIC_BALL); + (game.ball_active ? EL_EMC_MAGIC_BALL_ACTIVE : EL_EMC_MAGIC_BALL); game_panel_controls[GAME_PANEL_EMC_MAGIC_BALL_SWITCH].value = - (game.ball_state ? EL_EMC_MAGIC_BALL_SWITCH_ACTIVE : + (game.ball_active ? EL_EMC_MAGIC_BALL_SWITCH_ACTIVE : EL_EMC_MAGIC_BALL_SWITCH); game_panel_controls[GAME_PANEL_LIGHT_SWITCH].value = @@ -3619,7 +3619,7 @@ void InitGame(void) game.lenses_time_left = 0; game.magnify_time_left = 0; - game.ball_state = level.ball_state_initial; + game.ball_active = level.ball_active_initial; game.ball_content_nr = 0; game.explosions_delayed = TRUE; @@ -14225,13 +14225,13 @@ static int DigField(struct PlayerInfo *player, { int xx, yy; - game.ball_state = !game.ball_state; + game.ball_active = !game.ball_active; SCAN_PLAYFIELD(xx, yy) { int e = Feld[xx][yy]; - if (game.ball_state) + if (game.ball_active) { if (e == EL_EMC_MAGIC_BALL) CreateField(xx, yy, EL_EMC_MAGIC_BALL_ACTIVE); diff --git a/src/game.h b/src/game.h index ae58fc39..94b96855 100644 --- a/src/game.h +++ b/src/game.h @@ -215,7 +215,7 @@ struct GameInfo // values for the new EMC elements int lenses_time_left; int magnify_time_left; - boolean ball_state; + boolean ball_active; int ball_content_nr; // values for player idle animation (no effect on engine) diff --git a/src/game_em/cave.c b/src/game_em/cave.c index 3519723d..664b88a7 100644 --- a/src/game_em/cave.c +++ b/src/game_em/cave.c @@ -51,26 +51,24 @@ void setLevelInfoToDefaults_EM(void) cav.amoeba_time = 0; cav.wonderwall_time = 0; cav.wheel_time = 0; - cav.wheel_x = 1; - cav.wheel_y = 1; + cav.wheel_x = 0; + cav.wheel_y = 0; cav.lenses_time = 0; cav.magnify_time = 0; - cav.wind_time = 9999; + cav.wind_time = 0; cav.wind_direction = 0; - cav.ball_random = 0; - cav.ball_state = 0; - cav.wonderwall_state = 0; - cav.wheel_cnt = 0; - cav.lenses_cnt = 0; - cav.magnify_cnt = 0; - cav.wind_cnt = 0; - - cav.num_ball_arrays = 8; - - cav.testmode = FALSE; - cav.teamwork = FALSE; - cav.infinite = FALSE; + cav.num_ball_arrays = 8; + + cav.testmode = FALSE; + cav.teamwork = FALSE; + cav.infinite = FALSE; + cav.ball_random = FALSE; + cav.ball_active = FALSE; + cav.wonderwall_active = FALSE; + cav.wheel_active = FALSE; + cav.lenses_active = FALSE; + cav.magnify_active = FALSE; for (i = 0; i < 8; i++) for (j = 0; j < 9; j++) diff --git a/src/game_em/cave.h b/src/game_em/cave.h index 5dd05255..32d3a03d 100644 --- a/src/game_em/cave.h +++ b/src/game_em/cave.h @@ -217,8 +217,8 @@ struct CAVE int width; /* cave width */ int height; /* cave height */ - int player_x[MAX_PLAYERS]; /* player x pos */ - int player_y[MAX_PLAYERS]; /* player y pos */ + int player_x[MAX_PLAYERS]; /* player x position */ + int player_y[MAX_PLAYERS]; /* player y position */ int time_seconds; /* available time (seconds) */ int gems_needed; /* emeralds needed */ @@ -237,32 +237,30 @@ struct CAVE int magnify_score; /* score for collecting magnifier */ int exit_score; /* score for entering exit */ - int android_move_time; /* android move reset time */ - int android_clone_time; /* android clone reset time */ - int ball_time; /* ball reset time */ - int amoeba_time; /* amoeba speed */ - int wonderwall_time; /* wonderwall time */ - int wheel_time; /* wheel reset time */ - int wheel_x; /* wheel x pos */ - int wheel_y; /* wheel y pos */ - int lenses_time; /* lenses reset time */ - int magnify_time; /* magnify reset time */ - int wind_time; /* wind reset time */ + int android_move_time; /* reset time for android movement */ + int android_clone_time; /* reset time for android cloning */ + int ball_time; /* reset time for ball activity */ + int amoeba_time; /* amoeba growth speed */ + int wonderwall_time; /* reset time for wonderwall activity */ + int wheel_time; /* reset time for wheel activity */ + int wheel_x; /* wheel x position */ + int wheel_y; /* wheel y position */ + int lenses_time; /* reset time for lenses activity */ + int magnify_time; /* reset time for magnifier activity */ + int wind_time; /* reset time for wind activity */ int wind_direction; /* wind direction */ - int ball_random; /* ball is random flag */ - int ball_state; /* ball active flag */ - int wonderwall_state; /* wonderwall active flag */ - int wheel_cnt; /* wheel counter */ - int lenses_cnt; /* lenses counter */ - int magnify_cnt; /* magnify counter */ - int wind_cnt; /* wind time counter */ - int num_ball_arrays; /* number of ball data arrays used */ - boolean testmode; /* test mode */ - boolean teamwork; /* two player mode */ - boolean infinite; /* cave is infinitely wide */ + boolean testmode; /* flag for test mode */ + boolean teamwork; /* flag for two player mode */ + boolean infinite; /* flag for infinitely wide cave */ + boolean ball_random; /* flag if ball is random */ + boolean ball_active; /* flag if ball is already active */ + boolean wonderwall_active; /* flag if wonderwall is already active */ + boolean wheel_active; /* flag if wheel is already active */ + boolean lenses_active; /* flag if lenses are already active */ + boolean magnify_active; /* flag if magnifier is already active */ short eater_array[8][9]; /* eater data */ short ball_array[8][8]; /* ball data */ diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 0d94aa00..03dacc4e 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -336,7 +336,7 @@ void prepare_em_level(void) lev.ball_time = cav.ball_time; lev.ball_cnt = cav.ball_time; - lev.ball_state = cav.ball_state; + lev.ball_active = cav.ball_active; lev.ball_random = cav.ball_random; lev.ball_pos = 0; @@ -344,22 +344,22 @@ void prepare_em_level(void) lev.shine_cnt = 0; lev.lenses_time = cav.lenses_time; - lev.lenses_cnt = cav.lenses_cnt; + lev.lenses_cnt = cav.lenses_active ? cav.lenses_time : 0; lev.magnify_time = cav.magnify_time; - lev.magnify_cnt = cav.magnify_cnt; + lev.magnify_cnt = cav.magnify_active ? cav.magnify_time : 0; lev.wheel_time = cav.wheel_time; - lev.wheel_cnt = cav.wheel_cnt; + lev.wheel_cnt = cav.wheel_active ? cav.wheel_time : 0; lev.wheel_x = cav.wheel_x; lev.wheel_y = cav.wheel_y; lev.wind_time = cav.wind_time; - lev.wind_cnt = cav.wind_cnt; + lev.wind_cnt = cav.wind_time; lev.wind_direction = cav.wind_direction; - lev.wonderwall_time = cav.wonderwall_time; - lev.wonderwall_state = cav.wonderwall_state; + lev.wonderwall_time = cav.wonderwall_time; + lev.wonderwall_active = cav.wonderwall_active; lev.killed_out_of_time = FALSE; diff --git a/src/game_em/emerald.h b/src/game_em/emerald.h index a74769fd..8b5e05f2 100644 --- a/src/game_em/emerald.h +++ b/src/game_em/emerald.h @@ -674,33 +674,33 @@ struct LOGIC int magnify_score; /* score for collecting magnifier */ int exit_score; /* score for entering exit */ - int android_move_time; /* android move reset time */ - int android_clone_time; /* android clone reset time */ - int ball_time; /* ball reset time */ - int amoeba_time; /* amoeba speed */ - int wonderwall_time; /* wonderwall time */ - int wheel_time; /* wheel reset time */ - int wheel_x; /* wheel x pos */ - int wheel_y; /* wheel y pos */ - int lenses_time; /* lenses reset time */ - int magnify_time; /* magnify reset time */ - int wind_time; /* wind reset time */ + int android_move_time; /* reset time for android movement */ + int android_clone_time; /* reset time for android cloning */ + int ball_time; /* reset time for ball activity */ + int amoeba_time; /* amoeba growth speed */ + int wonderwall_time; /* reset time for wonderwall activity */ + int wheel_time; /* reset time for wheel activity */ + int wheel_x; /* wheel x position */ + int wheel_y; /* wheel y position */ + int lenses_time; /* reset time for lenses activity */ + int magnify_time; /* reset time for magnifier activity */ + int wind_time; /* reset time for wind activity */ int wind_direction; /* wind direction */ - int ball_random; /* ball is random flag */ - int ball_state; /* ball active flag */ - int wonderwall_state; /* wonderwall active flag */ - int wheel_cnt; /* wheel counter */ - int lenses_cnt; /* lenses counter */ - int magnify_cnt; /* magnify counter */ - int wind_cnt; /* wind time counter */ - - int android_move_cnt; /* android move counter */ - int android_clone_cnt; /* android clone counter */ - int ball_cnt; /* ball counter */ - int ball_pos; /* ball array pos counter */ - int eater_pos; /* eater array pos */ - int shine_cnt; /* shine counter for emerald/diamond */ + boolean ball_random; /* flag if ball is random */ + boolean ball_active; /* flag if ball is already active */ + boolean wonderwall_active; /* flag if wonderwall is already active */ + + int wheel_cnt; /* counter for wheel activity */ + int lenses_cnt; /* counter for lenses activity */ + int magnify_cnt; /* counter for magnifier activity */ + int wind_cnt; /* counter for wind activity */ + int android_move_cnt; /* counter for android movement */ + int android_clone_cnt; /* counter for android cloning */ + int ball_cnt; /* counter for ball activity */ + int ball_pos; /* counter for ball array position */ + int eater_pos; /* counter for eater array position */ + int shine_cnt; /* counter for emerald/diamond shining */ int num_ball_arrays; /* number of ball data arrays used */ diff --git a/src/game_em/logic.c b/src/game_em/logic.c index f4968eed..be2bed34 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -1136,7 +1136,7 @@ static boolean player_digfield(struct PLAYER *ply, int dx, int dy) case Xswitch: play_element_sound(x, y, SOUND_press, element); lev.ball_cnt = lev.ball_time; - lev.ball_state = !lev.ball_state; + lev.ball_active = !lev.ball_active; break; case Xplant: @@ -3961,9 +3961,9 @@ static void Lemerald_fall(int x, int y) return; case Xwonderwall: - if (lev.wonderwall_time) + if (lev.wonderwall_time > 0) { - lev.wonderwall_state = 1; + lev.wonderwall_active = TRUE; cave[x][y] = Yemerald_sB; next[x][y] = Xblank; if (is_blank[cave[x][y+2]]) @@ -4220,9 +4220,9 @@ static void Ldiamond_fall(int x, int y) return; case Xwonderwall: - if (lev.wonderwall_time) + if (lev.wonderwall_time > 0) { - lev.wonderwall_state = 1; + lev.wonderwall_active = TRUE; cave[x][y] = Ydiamond_sB; next[x][y] = Xblank; if (is_blank[cave[x][y+2]]) @@ -4668,9 +4668,9 @@ static void Lstone_fall(int x, int y) return; case Xwonderwall: - if (lev.wonderwall_time) + if (lev.wonderwall_time > 0) { - lev.wonderwall_state = 1; + lev.wonderwall_active = TRUE; cave[x][y] = Ystone_sB; next[x][y] = Xblank; if (is_blank[cave[x][y+2]]) @@ -6558,7 +6558,7 @@ static void Lball_common(int x, int y) static void Lball_1(int x, int y) { - if (lev.ball_state == 0) + if (!lev.ball_active) return; cave[x][y] = Yball_1; @@ -6571,7 +6571,7 @@ static void Lball_1(int x, int y) static void Lball_2(int x, int y) { - if (lev.ball_state == 0) + if (!lev.ball_active) return; cave[x][y] = Yball_2; @@ -6664,7 +6664,7 @@ static void Ldrip_stretchB(int x, int y) static void Lwonderwall(int x, int y) { - if (lev.wonderwall_time && lev.wonderwall_state) + if (lev.wonderwall_time > 0 && lev.wonderwall_active) { cave[x][y] = Ywonderwall; play_element_sound(x, y, SOUND_wonder, Xwonderwall); @@ -6679,7 +6679,7 @@ static void Lwheel(int x, int y) static void Lswitch(int x, int y) { - if (lev.ball_state) + if (lev.ball_active) cave[x][y] = Yswitch; } @@ -7387,7 +7387,7 @@ static void logic_globals(void) lev.android_move_cnt = lev.android_move_time; if (lev.android_clone_cnt-- == 0) lev.android_clone_cnt = lev.android_clone_time; - if (lev.ball_state) + if (lev.ball_active) if (lev.ball_cnt-- == 0) lev.ball_cnt = lev.ball_time; if (lev.lenses_cnt) @@ -7398,7 +7398,7 @@ static void logic_globals(void) lev.wheel_cnt--; if (lev.wind_cnt) lev.wind_cnt--; - if (lev.wonderwall_time && lev.wonderwall_state) + if (lev.wonderwall_time > 0 && lev.wonderwall_active) lev.wonderwall_time--; if (lev.wheel_cnt) diff --git a/src/game_em/reademc.c b/src/game_em/reademc.c index b4ddbc24..afe3414c 100644 --- a/src/game_em/reademc.c +++ b/src/game_em/reademc.c @@ -270,12 +270,15 @@ void convert_em_level(unsigned char *src, int file_version) /* common to all emc caves */ + cav.width = 64; + cav.height = 32; + cav.time_seconds = MIN(GET_BE16(src[2110]), 9999); cav.gems_needed = src[2095]; cav.infinite = TRUE; cav.testmode = FALSE; - cav.teamwork = (src[2150] & 128) ? TRUE : FALSE; + cav.teamwork = (src[2150] & 128) != 0; /* scores */ @@ -307,39 +310,44 @@ void convert_em_level(unsigned char *src, int file_version) cav.amoeba_time = MIN(GET_BE16(src[2100]) * 28, 9999); cav.wonderwall_time = MIN(GET_BE16(src[2102]), 9999); - cav.wind_cnt = src[2149] & 15 ? cav.wind_time : 0; + cav.wind_time = 9999; temp = src[2149]; cav.wind_direction = (temp & 8 ? 0 : temp & 1 ? 1 : temp & 2 ? 2 : - temp & 4 ? 3 : 0); + temp & 4 ? 3 : 4); /* global flags */ - cav.ball_random = src[2162] & 1 ? 1 : 0; - cav.ball_state = src[2162] & 128 ? 1 : 0; + cav.ball_random = (src[2162] & 1) != 0; + cav.ball_active = (src[2162] & 128) != 0; + + cav.wonderwall_active = FALSE; + cav.wheel_active = FALSE; + cav.lenses_active = FALSE; + cav.magnify_active = FALSE; for (temp = 1; temp < 2047; temp++) { switch (src[temp]) { case 36: /* wonderwall */ - cav.wonderwall_state = 1; + cav.wonderwall_active = TRUE; cav.wonderwall_time = 9999; break; case 40: /* wheel */ - cav.wheel_x = temp & 63; - cav.wheel_y = temp >> 6; - cav.wheel_cnt = cav.wheel_time; + cav.wheel_active = TRUE; + cav.wheel_x = temp % 64; + cav.wheel_y = temp / 64; break; case 163: /* fake blank */ - cav.lenses_cnt = 9999; + cav.lenses_active = TRUE; break; case 164: /* fake grass */ - cav.magnify_cnt = 9999; + cav.magnify_active = TRUE; break; } } diff --git a/src/main.h b/src/main.h index 49a627e7..f6c90269 100644 --- a/src/main.h +++ b/src/main.h @@ -3116,7 +3116,7 @@ struct LevelInfo int android_move_time; int android_clone_time; boolean ball_random; - boolean ball_state_initial; + boolean ball_active_initial; int ball_time; int lenses_score; int magnify_score;