rnd-20040612-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 12 Jun 2004 10:06:42 +0000 (12:06 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:47:27 +0000 (10:47 +0200)
* fixed waste of static memory usage of the binary, making it smaller
* fixed very little graphical bug in Supaplex explosion

16 files changed:
ChangeLog
src/conf_gfx.c
src/conf_mus.c
src/conf_snd.c
src/conftime.h
src/game.c
src/init.c
src/libgame/image.c
src/libgame/image.h
src/libgame/misc.c
src/libgame/misc.h
src/libgame/sound.c
src/libgame/sound.h
src/libgame/system.h
src/main.c
src/main.h

index 929c9f4a70f0f1b69e80828bd1c3e775caa8d927..829c0d5b972a466fc822a79bcfba92127aa4238c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2004-06-11
        * fixed bug with wrong door state after trying to quickload empty tape
+       * fixed waste of static memory usage of the binary, making it smaller
+       * fixed very little graphical bug in Supaplex explosion
 
 2004-06-07
        * version number set to 3.1.1
index ada412c6c52b19b6b7dc0028bf31427fb30fa4fa..5e5e998c845256443718becc8759e2b1dd569dc5 100644 (file)
@@ -19,7 +19,7 @@
    reliable default values. If that value is GFX_ARG_UNDEFINED, it will
    be dynamically determined, using some of the other list values. */
 
-struct ConfigInfo image_config_suffix[] =
+struct ConfigTypeInfo image_config_suffix[] =
 {
   { ".x",                              ARG_UNDEFINED,  TYPE_INTEGER    },
   { ".y",                              ARG_UNDEFINED,  TYPE_INTEGER    },
index 1c29c617d7d4ed6ebd65acec197d9b55b36cac61..27ec9056f35678f6d3ebe16f29914b254e1ac3ae 100644 (file)
@@ -19,7 +19,7 @@
    reliable default values. If that value is MUS_ARG_UNDEFINED, it will
    be dynamically determined, using some of the other list values. */
 
-struct ConfigInfo music_config_suffix[] =
+struct ConfigTypeInfo music_config_suffix[] =
 {
   { ".mode_loop",                      ARG_UNDEFINED,  TYPE_BOOLEAN    },
 
index cd9869b081fa9fc32e6dca45cdcdfea7d0897d94..45a8753f1fe892362493d547d73b75d01fb51072 100644 (file)
@@ -19,7 +19,7 @@
    reliable default values. If that value is SND_ARG_UNDEFINED, it will
    be dynamically determined, using some of the other list values. */
 
-struct ConfigInfo sound_config_suffix[] =
+struct ConfigTypeInfo sound_config_suffix[] =
 {
   { ".mode_loop",                      ARG_UNDEFINED,  TYPE_BOOLEAN    },
 
index 10db8e49aa88095d3905249d16c7d967d7068c13..dae3329ac318e9a5a04511cbe3021983549f62bb 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2004-06-11 03:48]"
+#define COMPILE_DATE_STRING "[2004-06-12 03:59]"
index 6de0372ce71aba949569874c821db12d8707d7a9..d43970cad7e203ffbb0f57dc74e884168fbf8c27 100644 (file)
@@ -29,6 +29,8 @@
 
 /* EXPERIMENTAL STUFF */
 #define USE_NEW_MOVEMENT       FALSE
+#define USE_NEW_MOVE_DELAY     TRUE   *1
+#define USE_NEW_PUSH_DELAY     TRUE   *1
 
 /* for DigField() */
 #define DF_NO_PUSH             0
 
 /* forward declaration for internal use */
 
+static void AdvanceFrameAndPlayerCounters(int);
+
 static boolean MovePlayerOneStep(struct PlayerInfo *, int, int, int, int);
 static boolean MovePlayer(struct PlayerInfo *, int, int);
 static void ScrollPlayer(struct PlayerInfo *, int);
@@ -1153,7 +1157,7 @@ static void resolve_group_element(int group_element, int recursion_depth)
 
 /*
   =============================================================================
 InitGameEngine()
+ InitGameEngine()
   -----------------------------------------------------------------------------
   initialize game engine due to level / tape version number
   =============================================================================
@@ -1189,6 +1193,15 @@ static void InitGameEngine()
 
   /* ---------- initialize player's initial move delay --------------------- */
 
+#if USE_NEW_MOVE_DELAY
+  /* dynamically adjust player properties according to level information */
+  game.initial_move_delay_value =
+    (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED);
+
+  /* dynamically adjust player properties according to game engine version */
+  game.initial_move_delay = (game.engine_version <= VERSION_IDENT(2,0,1,0) ?
+                            game.initial_move_delay_value : 0);
+#else
   /* dynamically adjust player properties according to game engine version */
   game.initial_move_delay =
     (game.engine_version <= VERSION_IDENT(2,0,1,0) ? INITIAL_MOVE_DELAY_ON :
@@ -1197,6 +1210,7 @@ static void InitGameEngine()
   /* dynamically adjust player properties according to level information */
   game.initial_move_delay_value =
     (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED);
+#endif
 
   /* ---------- initialize player's initial push delay --------------------- */
 
@@ -1573,8 +1587,13 @@ void InitGame()
 
     player->move_delay_reset_counter = 0;
 
-    player->push_delay = 0;
+#if USE_NEW_PUSH_DELAY
+    player->push_delay       = -1;     /* initialized when pushing starts */
     player->push_delay_value = game.initial_push_delay_value;
+#else
+    player->push_delay       = 0;
+    player->push_delay_value = game.initial_push_delay_value;
+#endif
 
     player->drop_delay = 0;
 
@@ -2890,7 +2909,12 @@ void RelocatePlayer(int jx, int jy, int el_player_raw)
     {
       ScrollPlayer(player, SCROLL_GO_ON);
       ScrollScreen(NULL, SCROLL_GO_ON);
+
+#if USE_NEW_MOVE_DELAY
+      AdvanceFrameAndPlayerCounters(player->index_nr);
+#else
       FrameCounter++;
+#endif
 
       DrawPlayer(player);
 
@@ -8323,6 +8347,45 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action)
 }
 #endif
 
+void AdvanceFrameAndPlayerCounters(int player_nr)
+{
+  int i;
+
+  /* advance frame counters (global frame counter and time frame counter) */
+  FrameCounter++;
+  TimeFrames++;
+
+  /* advance player counters (counters for move delay, move animation etc.) */
+  for (i = 0; i < MAX_PLAYERS; i++)
+  {
+    boolean advance_player_counters = (player_nr == -1 || player_nr == i);
+    int move_frames =
+      MOVE_DELAY_NORMAL_SPEED /  stored_player[i].move_delay_value;
+
+    if (!advance_player_counters)      /* not all players may be affected */
+      continue;
+
+    stored_player[i].Frame += move_frames;
+
+    if (stored_player[i].MovPos != 0)
+      stored_player[i].StepFrame += move_frames;
+
+#if USE_NEW_MOVE_DELAY
+    if (stored_player[i].move_delay > 0)
+      stored_player[i].move_delay--;
+#endif
+
+#if USE_NEW_PUSH_DELAY
+    /* due to bugs in previous versions, counter must count up, not down */
+    if (stored_player[i].push_delay != -1)
+      stored_player[i].push_delay++;
+#endif
+
+    if (stored_player[i].drop_delay > 0)
+      stored_player[i].drop_delay--;
+  }
+}
+
 void GameActions()
 {
   static unsigned long action_delay = 0;
@@ -9014,7 +9077,9 @@ void GameActions()
           stored_player[0].StepFrame);
 #endif
 
-#if 1
+#if USE_NEW_MOVE_DELAY
+  AdvanceFrameAndPlayerCounters(-1);   /* advance counters for all players */
+#else
   FrameCounter++;
   TimeFrames++;
 
@@ -9028,6 +9093,11 @@ void GameActions()
     if (stored_player[i].MovPos != 0)
       stored_player[i].StepFrame += move_frames;
 
+#if USE_NEW_MOVE_DELAY
+    if (stored_player[i].move_delay > 0)
+      stored_player[i].move_delay--;
+#endif
+
     if (stored_player[i].drop_delay > 0)
       stored_player[i].drop_delay--;
   }
@@ -9513,7 +9583,11 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy)
         player->move_delay + player->move_delay_value);
 #endif
 
+#if USE_NEW_MOVE_DELAY
+  if (player->move_delay > 0)
+#else
   if (!FrameReached(&player->move_delay, player->move_delay_value))
+#endif
   {
 #if 0
     printf("::: can NOT move\n");
@@ -9533,6 +9607,10 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy)
   printf("::: COULD move now\n");
 #endif
 
+#if USE_NEW_MOVE_DELAY
+  player->move_delay = -1;             /* set to "uninitialized" value */
+#endif
+
   /* store if player is automatically moved to next field */
   player->is_auto_moving = (player->programmed_action != MV_NO_MOVING);
 
@@ -9558,7 +9636,13 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy)
     {
       ScrollPlayer(player, SCROLL_GO_ON);
       ScrollScreen(NULL, SCROLL_GO_ON);
+
+#if USE_NEW_MOVE_DELAY
+      AdvanceFrameAndPlayerCounters(player->index_nr);
+#else
       FrameCounter++;
+#endif
+
       DrawAllPlayers();
       BackToFront();
     }
@@ -9756,6 +9840,11 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy)
 #endif
   }
 
+#if USE_NEW_MOVE_DELAY
+  if (player->move_delay == -1)                /* not yet initialized by DigField() */
+    player->move_delay = player->move_delay_value;
+#endif
+
   if (game.engine_version < VERSION_IDENT(3,0,7,0))
   {
     TestIfHeroTouchesBadThing(jx, jy);
@@ -10810,7 +10899,11 @@ int DigField(struct PlayerInfo *player,
     if (mode == DF_NO_PUSH)    /* player just stopped pushing */
     {
       player->is_switching = FALSE;
+#if USE_NEW_PUSH_DELAY
+      player->push_delay = -1;
+#else
       player->push_delay = 0;
+#endif
 
       return MF_NO_ACTION;
     }
@@ -11373,16 +11466,56 @@ int DigField(struct PlayerInfo *player,
        if (!checkDiagonalPushing(player, x, y, real_dx, real_dy))
          return MF_NO_ACTION;
 
+#if USE_NEW_PUSH_DELAY
+
+#if 0
+       if ( (player->push_delay == -1) != (player->push_delay2 == 0) )
+         printf("::: ALERT: %d, %d [%d / %d]\n",
+                player->push_delay, player->push_delay2,
+                FrameCounter, FrameCounter / 50);
+#endif
+
+       if (player->push_delay == -1)   /* new pushing; restart delay */
+         player->push_delay = 0;
+#else
        if (player->push_delay == 0)    /* new pushing; restart delay */
          player->push_delay = FrameCounter;
+#endif
+
+#if USE_NEW_PUSH_DELAY
+#if 0
+       if ( (player->push_delay > 0) != (!xxx_fr) )
+         printf("::: PUSH BUG! %d, (%d -> %d) %d [%d / %d]\n",
+                player->push_delay,
+                xxx_pdv2, player->push_delay2, player->push_delay_value,
+                FrameCounter, FrameCounter / 50);
+#endif
+
+#if 0
+       if (player->push_delay > 0 &&
+           !(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
+           element != EL_SPRING && element != EL_BALLOON)
+#else
+       /* !!! */
+       if (player->push_delay < player->push_delay_value &&
+           !(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
+           element != EL_SPRING && element != EL_BALLOON)
+#endif
 
+#else
        if (!FrameReached(&player->push_delay, player->push_delay_value) &&
            !(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
            element != EL_SPRING && element != EL_BALLOON)
+#endif
        {
          /* make sure that there is no move delay before next try to push */
+#if USE_NEW_MOVE_DELAY
+         if (game.engine_version >= VERSION_IDENT(3,0,7,1))
+           player->move_delay = 0;
+#else
          if (game.engine_version >= VERSION_IDENT(3,0,7,1))
            player->move_delay = INITIAL_MOVE_DELAY_OFF;
+#endif
 
          return MF_NO_ACTION;
        }
@@ -11608,7 +11741,11 @@ int DigField(struct PlayerInfo *player,
       return MF_NO_ACTION;
   }
 
+#if USE_NEW_PUSH_DELAY
+  player->push_delay = -1;
+#else
   player->push_delay = 0;
+#endif
 
   if (Feld[x][y] != element)           /* really digged/collected something */
     player->is_collecting = !player->is_digging;
index 02b29cdc66275026b1f57773c30654ef56a791c0..c62b8c4efef0bc60588cac72a48bd38897a0907c 100644 (file)
@@ -3655,6 +3655,15 @@ void InitElementPropertiesEngine(int engine_version)
 
 static void InitGlobal()
 {
+  int i;
+
+  for (i = 0; i < MAX_NUM_ELEMENTS + 1; i++)
+  {
+    element_info[i].token_name = element_name_info[i].token_name;
+    element_info[i].class_name = element_name_info[i].class_name;
+    element_info[i].editor_description=element_name_info[i].editor_description;
+  }
+
   global.autoplay_leveldir = NULL;
   global.convert_leveldir = NULL;
 
index 108fd39c3fc4d80033e2748b64170bc1ee5f88a1..977111f442092dfd43895a9d0677ad6b265b3adc 100644 (file)
@@ -845,7 +845,7 @@ struct PropertyMapping *getImageListPropertyMapping()
 }
 
 void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries,
-                  struct ConfigInfo *config_suffix_list,
+                  struct ConfigTypeInfo *config_suffix_list,
                   char **base_prefixes, char **ext1_suffixes,
                   char **ext2_suffixes, char **ext3_suffixes,
                   char **ignore_tokens)
index e48e04cc83d43e5a12895f467bf5460d6b9edc16..e9f1dbcd98b970498f8ff28ae99a6b861ffbb014 100644 (file)
@@ -82,7 +82,7 @@ int getImageIDFromToken(char *);
 char *getImageConfigFilename();
 int getImageListPropertyMappingSize();
 struct PropertyMapping *getImageListPropertyMapping();
-void InitImageList(struct ConfigInfo *, int, struct ConfigInfo *,
+void InitImageList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
                   char **, char **, char **, char **, char **);
 
 void ReloadCustomImages();
index ba3796259bf2e02bd579dee4fba25d6593434e09..225d385cf3323002b1c1257e87aa966efcb7e9c6 100644 (file)
@@ -1707,7 +1707,7 @@ static void FreeCustomArtworkList(struct ArtworkListInfo *,
                                  struct ListNodeInfo ***, int *);
 
 struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list,
-                                          struct ConfigInfo *suffix_list,
+                                          struct ConfigTypeInfo *suffix_list,
                                           char **ignore_tokens,
                                           int num_file_list_entries)
 {
@@ -1842,7 +1842,7 @@ static boolean token_suffix_match(char *token, char *suffix, int start_pos)
 #define KNOWN_TOKEN_VALUE      "[KNOWN_TOKEN_VALUE]"
 
 static void read_token_parameters(SetupFileHash *setup_file_hash,
-                                 struct ConfigInfo *suffix_list,
+                                 struct ConfigTypeInfo *suffix_list,
                                  struct FileInfo *file_list_entry)
 {
   /* check for config token that is the base token without any suffixes */
@@ -1895,7 +1895,7 @@ static void read_token_parameters(SetupFileHash *setup_file_hash,
 static void add_dynamic_file_list_entry(struct FileInfo **list,
                                        int *num_list_entries,
                                        SetupFileHash *extra_file_hash,
-                                       struct ConfigInfo *suffix_list,
+                                       struct ConfigTypeInfo *suffix_list,
                                        int num_suffix_list_entries,
                                        char *token)
 {
@@ -1944,7 +1944,7 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info,
                                          char *filename)
 {
   struct FileInfo *file_list = artwork_info->file_list;
-  struct ConfigInfo *suffix_list = artwork_info->suffix_list;
+  struct ConfigTypeInfo *suffix_list = artwork_info->suffix_list;
   char **base_prefixes = artwork_info->base_prefixes;
   char **ext1_suffixes = artwork_info->ext1_suffixes;
   char **ext2_suffixes = artwork_info->ext2_suffixes;
index 2f3a957ab5097fb06c0972a3869b591fc5a74d2f..62f3607e98713251b30b03d04bed83743e31788f 100644 (file)
@@ -166,7 +166,8 @@ int get_parameter_value(char *, char *, int);
 int get_auto_parameter_value(char *, char *);
 
 struct FileInfo *getFileListFromConfigList(struct ConfigInfo *,
-                                          struct ConfigInfo *, char **, int);
+                                          struct ConfigTypeInfo *,
+                                          char **, int);
 void LoadArtworkConfig(struct ArtworkListInfo *);
 void ReloadCustomArtworkList(struct ArtworkListInfo *);
 void FreeCustomArtworkLists(struct ArtworkListInfo *);
index b9fd88c66a460dd72e58300cba60644236440794..6eb1de14df23ca62529752743f0fd5ef64f406d5 100644 (file)
@@ -2035,7 +2035,7 @@ struct PropertyMapping *getMusicListPropertyMapping()
 }
 
 void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries,
-                  struct ConfigInfo *config_suffix_list,
+                  struct ConfigTypeInfo *config_suffix_list,
                   char **base_prefixes, char **ext1_suffixes,
                   char **ext2_suffixes, char **ext3_suffixes,
                   char **ignore_tokens)
@@ -2115,7 +2115,7 @@ void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries,
 }
 
 void InitMusicList(struct ConfigInfo *config_list, int num_file_list_entries,
-                  struct ConfigInfo *config_suffix_list,
+                  struct ConfigTypeInfo *config_suffix_list,
                   char **base_prefixes, char **ext1_suffixes,
                   char **ext2_suffixes, char **ext3_suffixes,
                   char **ignore_tokens)
index 17a1cee2e2e9e8cceb951f1911958659aaa41b53..ca1e26a6009dc1cc98750396cb2ac7ea2de89299 100644 (file)
@@ -153,9 +153,9 @@ int getSoundListPropertyMappingSize();
 int getMusicListPropertyMappingSize();
 struct PropertyMapping *getSoundListPropertyMapping();
 struct PropertyMapping *getMusicListPropertyMapping();
-void InitSoundList(struct ConfigInfo *, int, struct ConfigInfo *,
+void InitSoundList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
                   char **, char **, char **, char **, char **);
-void InitMusicList(struct ConfigInfo *, int, struct ConfigInfo *,
+void InitMusicList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
                   char **, char **, char **, char **, char **);
 void InitReloadCustomSounds(char *);
 void InitReloadCustomMusic(char *);
index 74a74a67e150ce4cd9baaaa8c709f675d730e4a6..ad9634a3b7bca5d9ba8d07e541b53b1e392366ea 100644 (file)
@@ -691,6 +691,12 @@ struct ValueTextInfo
 };
 
 struct ConfigInfo
+{
+  char *token;
+  char *value;
+};
+
+struct ConfigTypeInfo
 {
   char *token;
   char *value;
@@ -750,7 +756,7 @@ struct ArtworkListInfo
   struct FileInfo *dynamic_file_list;          /* dynamic artwrk file array */
 
   int num_suffix_list_entries;
-  struct ConfigInfo *suffix_list;              /* parameter suffixes array */
+  struct ConfigTypeInfo *suffix_list;          /* parameter suffixes array */
 
   int num_base_prefixes;
   int num_ext1_suffixes;
index 81319ed6b8899c868f75dea121e7f51b0d9b6b44..596f996ab70e174e27f4c08c93d5753c67289f1a 100644 (file)
@@ -122,7 +122,10 @@ SetupFileHash          *helptext_info = NULL;
 /* element definitions                                                       */
 /* ------------------------------------------------------------------------- */
 
-struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1] =
+struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1];
+
+/* this contains predefined structure elements to initialize "element_info" */
+struct ElementNameInfo element_name_info[MAX_NUM_ELEMENTS + 1] =
 {
   /* keyword to start parser: "ELEMENT_INFO_START" <-- do not change! */
 
index b4c3c4950347ef3a671f0315586db88d8a8778af..b7a70f9f001f6d5fca4bb613d3eb9f37f17bca7e 100644 (file)
@@ -1417,13 +1417,23 @@ struct PlayerInfo
 
   int show_envelope;
 
+#if 1  /* USE_NEW_MOVE_DELAY */
+  int move_delay;
+  int move_delay_value;
+#else
   unsigned long move_delay;
   int move_delay_value;
+#endif
 
   int move_delay_reset_counter;
 
+#if 1  /* USE_NEW_PUSH_DELAY */
+  int push_delay;
+  int push_delay_value;
+#else
   unsigned long push_delay;
   unsigned long push_delay_value;
+#endif
 
   unsigned long actual_frame_counter;
 
@@ -1662,6 +1672,15 @@ struct ElementGroupInfo
   int choice_pos;              /* current element choice position */
 };
 
+struct ElementNameInfo
+{
+  /* ---------- token and description strings ---------- */
+
+  char *token_name;            /* element token used in config files */
+  char *class_name;            /* element class used in config files */
+  char *editor_description;    /* pre-defined description for level editor */
+};
+
 struct ElementInfo
 {
   /* ---------- token and description strings ---------- */
@@ -1961,6 +1980,7 @@ extern struct GlobalInfo  global;
 extern struct MenuInfo         menu;
 extern struct DoorInfo         door_1, door_2;
 extern struct ElementInfo      element_info[];
+extern struct ElementNameInfo  element_name_info[];
 extern struct ElementActionInfo        element_action_info[];
 extern struct ElementDirectionInfo element_direction_info[];
 extern struct SpecialSuffixInfo special_suffix_info[];
@@ -1973,12 +1993,12 @@ extern struct MusicInfo        *music_info;
 extern struct MusicFileInfo    *music_file_info;
 extern struct HelpAnimInfo     *helpanim_info;
 extern SetupFileHash           *helptext_info;
+extern struct ConfigTypeInfo   image_config_suffix[];
+extern struct ConfigTypeInfo   sound_config_suffix[];
+extern struct ConfigTypeInfo   music_config_suffix[];
 extern struct ConfigInfo       image_config[];
 extern struct ConfigInfo       sound_config[];
 extern struct ConfigInfo       music_config[];
-extern struct ConfigInfo       image_config_suffix[];
-extern struct ConfigInfo       sound_config_suffix[];
-extern struct ConfigInfo       music_config_suffix[];
 extern struct ConfigInfo       helpanim_config[];
 extern struct ConfigInfo       helptext_config[];