renamed some variables and changed some initializations
authorHolger Schemel <info@artsoft.org>
Fri, 21 Feb 2020 08:34:27 +0000 (09:34 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 19 May 2020 16:20:00 +0000 (18:20 +0200)
src/editor.c
src/files.c
src/game.c
src/game.h
src/game_em/cave.c
src/game_em/cave.h
src/game_em/convert.c
src/game_em/emerald.h
src/game_em/logic.c
src/game_em/reademc.c
src/main.h

index 3f56f42aa14336108a6ec44427a723478cb33aea..f648853f516b3aa5ce237d349047d8611c6ca543 100644 (file)
@@ -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);
index d4751ae52b8a4cfb6622a499e9f4f5d3e302be84..fd7cfcf4b78e4e143f7a79e60970e2954e6be8b9 100644 (file)
@@ -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;
 
index 862c5083d0c2d974b13eeadf6754b9fcfcf162c4..128c677f603ed1bac536fd04480b656e20160d9d 100644 (file)
@@ -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);
index ae58fc3965e9e81794b4a0475248adfa3dab1b73..94b96855ace5573a4d67a7ff68b5580baf69a2a7 100644 (file)
@@ -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)
index 3519723d54af1f3f601aa47b2807b6c7765a467a..664b88a7380c081bad10393319f9ef74001703c2 100644 (file)
@@ -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++)
index 5dd05255a56b11ffb7b586db524e67d5adfefceb..32d3a03d8ec8520128fbb2d7c3e67a1b74078ac7 100644 (file)
@@ -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 */
index 0d94aa00b6e65a1e74f164f6940db611fdad273c..03dacc4e4f5d132d903617559447d285fa3b9f7a 100644 (file)
@@ -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;
 
index a74769fd9f08855bd2b788d1bab7e56d38e8644f..8b5e05f2b4fb708041f4f31ef7ac35a1d82bc8a0 100644 (file)
@@ -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 */
 
index f4968eed725dda990023b36aef1f7c7820be4293..be2bed34a712bd36d7b2fa0fe9161d5fe979450e 100644 (file)
@@ -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)
index b4ddbc2411aa009c6886fa3a522e5bbbbb264bfd..afe3414cc4e5e46879200c7efe6a76f6247fedcf 100644 (file)
@@ -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;
     }
   }
index 49a627e73262e2a4fb6247a1939d9135f10dd0f3..f6c90269592f2b9fc5ab03182ed7301106db513f 100644 (file)
@@ -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;