removed runtime values from level structure for EM and SP engine
authorHolger Schemel <info@artsoft.org>
Thu, 13 Feb 2020 00:12:28 +0000 (01:12 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 19 May 2020 16:19:55 +0000 (18:19 +0200)
src/events.c
src/game.c
src/game_em/cave.c
src/game_em/export.h
src/game_sp/export.h
src/game_sp/file.c

index 21836c9dd6c67355bff8ec57d09084569c719640..6def0cb60992c285be6837ad94a877c4a6a0a303 100644 (file)
@@ -1275,7 +1275,7 @@ static void HandleButtonOrFinger_FollowFinger(int mx, int my, int button)
       int last_move_dir = (ABS(dx) > ABS(dy) ? MV_VERTICAL : MV_HORIZONTAL);
 
       if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
-       level.native_em_level->ply[0]->last_move_dir = last_move_dir;
+       game_em.ply[0]->last_move_dir = last_move_dir;
       else
        local_player->last_move_dir = last_move_dir;
 
index 1f019a4e1dfba2e62d425d82906a7bcbf9b71b8d..fbe34cc7a6eeef5328fc8bb5b85bef4a62c741fb 100644 (file)
@@ -2126,9 +2126,9 @@ static int compareGamePanelOrderInfo(const void *object1, const void *object2)
 int getPlayerInventorySize(int player_nr)
 {
   if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
-    return level.native_em_level->ply[player_nr]->dynamite;
+    return game_em.ply[player_nr]->dynamite;
   else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
-    return level.native_sp_level->game_sp->red_disk_count;
+    return game_sp.red_disk_count;
   else
     return stored_player[player_nr].inventory_size;
 }
@@ -2212,32 +2212,32 @@ static void UpdateGameControlValues(void)
   int time = (game.LevelSolved ?
              game.LevelSolved_CountingTime :
              level.game_engine_type == GAME_ENGINE_TYPE_EM ?
-             level.native_em_level->lev->time :
+             game_em.lev->time :
              level.game_engine_type == GAME_ENGINE_TYPE_SP ?
-             level.native_sp_level->game_sp->time_played :
+             game_sp.time_played :
              level.game_engine_type == GAME_ENGINE_TYPE_MM ?
              game_mm.energy_left :
              game.no_time_limit ? TimePlayed : TimeLeft);
   int score = (game.LevelSolved ?
               game.LevelSolved_CountingScore :
               level.game_engine_type == GAME_ENGINE_TYPE_EM ?
-              level.native_em_level->lev->score :
+              game_em.lev->score :
               level.game_engine_type == GAME_ENGINE_TYPE_SP ?
-              level.native_sp_level->game_sp->score :
+              game_sp.score :
               level.game_engine_type == GAME_ENGINE_TYPE_MM ?
               game_mm.score :
               game.score);
   int gems = (level.game_engine_type == GAME_ENGINE_TYPE_EM ?
-             level.native_em_level->lev->required :
+             game_em.lev->required :
              level.game_engine_type == GAME_ENGINE_TYPE_SP ?
-             level.native_sp_level->game_sp->infotrons_still_needed :
+             game_sp.infotrons_still_needed :
              level.game_engine_type == GAME_ENGINE_TYPE_MM ?
              game_mm.kettles_still_needed :
              game.gems_still_needed);
   int exit_closed = (level.game_engine_type == GAME_ENGINE_TYPE_EM ?
-                    level.native_em_level->lev->required > 0 :
+                    game_em.lev->required > 0 :
                     level.game_engine_type == GAME_ENGINE_TYPE_SP ?
-                    level.native_sp_level->game_sp->infotrons_still_needed > 0 :
+                    game_sp.infotrons_still_needed > 0 :
                     level.game_engine_type == GAME_ENGINE_TYPE_MM ?
                     game_mm.kettles_still_needed > 0 ||
                     game_mm.lights_still_needed > 0 :
@@ -2277,7 +2277,7 @@ static void UpdateGameControlValues(void)
       {
        if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
        {
-         if (level.native_em_level->ply[i]->keys & (1 << k))
+         if (game_em.ply[i]->keys & (1 << k))
            game_panel_controls[GAME_PANEL_KEY_1 + k].value =
              get_key_element_from_nr(k);
        }
@@ -2305,7 +2305,7 @@ static void UpdateGameControlValues(void)
     {
       if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
       {
-       if (level.native_em_level->ply[player_nr]->keys & (1 << k))
+       if (game_em.ply[player_nr]->keys & (1 << k))
          game_panel_controls[GAME_PANEL_KEY_1 + k].value =
            get_key_element_from_nr(k);
       }
@@ -4492,7 +4492,7 @@ static void LevelSolved(void)
   game.GameOver = TRUE;
 
   game.score_final = (level.game_engine_type == GAME_ENGINE_TYPE_EM ?
-                     level.native_em_level->lev->score :
+                     game_em.lev->score :
                      level.game_engine_type == GAME_ENGINE_TYPE_MM ?
                      game_mm.score :
                      game.score);
@@ -11240,7 +11240,7 @@ static void CheckLevelTime(void)
        if (!TimeLeft && setup.time_limit)
        {
          if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
-           level.native_em_level->lev->killed_out_of_time = TRUE;
+           game_em.lev->killed_out_of_time = TRUE;
          else
            for (i = 0; i < MAX_PLAYERS; i++)
              KillPlayer(&stored_player[i]);
@@ -11251,8 +11251,7 @@ static void CheckLevelTime(void)
        game_panel_controls[GAME_PANEL_TIME].value = TimePlayed;
       }
 
-      level.native_em_level->lev->time =
-       (game.no_time_limit ? TimePlayed : TimeLeft);
+      game_em.lev->time = (game.no_time_limit ? TimePlayed : TimeLeft);
     }
 
     if (tape.recording || tape.playing)
index cc863029ef0e8adf19a061c3ce6840e8af3dd12f..585bfd2f0de6c10435be6d33dce4453bb8997d1d 100644 (file)
@@ -18,6 +18,10 @@ void setLevelInfoToDefaults_EM(void)
   for (i = 0; i < MAX_PLAYERS; i++)
     native_em_level.ply[i] = &ply[i];
 
+  game_em.lev = &lev;
+  for (i = 0; i < MAX_PLAYERS; i++)
+    game_em.ply[i] = &ply[i];
+
   lev.width = 64;
   lev.height = 32;
 
index 1283829754c77f85527423c44595da22ba9bce5e..acd000b55d44408cbb3406306093e58294749726 100644 (file)
@@ -38,6 +38,9 @@ struct GameInfo_EM
 
   int last_moving_player;
   int last_player_direction[MAX_PLAYERS];
+
+  struct LEVEL *lev;
+  struct PLAYER *ply[MAX_PLAYERS];
 };
 
 struct LevelInfo_EM
@@ -48,9 +51,6 @@ struct LevelInfo_EM
 
   struct LEVEL *lev;
   struct PLAYER *ply[MAX_PLAYERS];
-
-  /* used for runtime values */
-  struct GameInfo_EM *game_em;
 };
 
 struct GraphicInfo_EM
index 11ef9edd44b9043ca73becf8c8ae483589b79ec8..d8b964fd102f5ebcc3211162921db581906dc56f 100644 (file)
@@ -123,9 +123,6 @@ struct LevelInfo_SP
   byte playfield[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT];
 
   struct DemoInfo_SP demo;
-
-  // used for runtime values
-  struct GameInfo_SP *game_sp;
 };
 
 struct GraphicInfo_SP
index 4e8c9a8feb4b4d7949b5f01f980288f48546a427..a702fd4d0ce32eaf846a85ef10ac573464aebb25 100644 (file)
@@ -19,8 +19,6 @@ void setLevelInfoToDefaults_SP(void)
   char *empty_title = "-------- EMPTY --------";
   int i, x, y;
 
-  native_sp_level.game_sp = &game_sp;
-
   native_sp_level.width  = SP_STD_PLAYFIELD_WIDTH;
   native_sp_level.height = SP_STD_PLAYFIELD_HEIGHT;