rnd-20050630-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 29 Jun 2005 23:01:10 +0000 (01:01 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:49:12 +0000 (10:49 +0200)
* fixed bug with dynamite dropped on top of just dropped custom element
  (collect dynamite, collect CE, drop CE => dynamite was also dropped);
  dynamite can still be dropped, but drop key must be released before
* fixed bug with wrong start directory when started from file browser
  (due to this bug, R'n'D could not be started from KDE's Konqueror)

ChangeLog
src/conftime.h
src/game.c
src/libgame/misc.c
src/libgame/misc.h
src/libgame/system.c
src/main.h

index b37248b2e8da398b8d041632c1c7d63e6c6982bf..bbc96b9d4ee86cbc07d644dd543edc69b6c7b2bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-06-27
+       * fixed bug with dynamite dropped on top of just dropped custom element
+         (collect dynamite, collect CE, drop CE => dynamite was also dropped);
+         dynamite can still be dropped, but drop key must be released before
+
+2005-06-27
+       * fixed bug with wrong start directory when started from file browser
+         (due to this bug, R'n'D could not be started from KDE's Konqueror)
+
 2005-06-26
        * fixed bug causing "change when impact" on player not working
        * fixed wrong priority of "hitting something" over "hitting <element>"
index b8a6c3ad45dd9610497e46d2764a3e1e7653692f..cee54f4d3db06f4c5919542c3742508d487f845d 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2005-06-27 21:21]"
+#define COMPILE_DATE_STRING "[2005-06-30 00:18]"
index dd8af0d3679aa16450f8a65fac907bd7aadab7ee..34a57f74728c6790ddf24442678b4ece5feb90aa 100644 (file)
@@ -54,6 +54,8 @@
 #define USE_HITTING_SOMETHING_BUGFIX   (TRUE   * USE_NEW_STUFF         * 1)
 #define USE_HIT_BY_SOMETHING_BUGFIX    (TRUE   * USE_NEW_STUFF         * 1)
 
+#define USE_DROP_BUGFIX                        (TRUE   * USE_NEW_STUFF         * 1)
+
 
 /* for DigField() */
 #define DF_NO_PUSH             0
@@ -1775,6 +1777,11 @@ void InitGame()
     player->switch_x = -1;
     player->switch_y = -1;
 
+#if USE_DROP_BUGFIX
+    player->drop_x = -1;
+    player->drop_y = -1;
+#endif
+
     player->show_envelope = 0;
 
     player->move_delay       = game.initial_move_delay;
@@ -12361,6 +12368,15 @@ boolean DropElement(struct PlayerInfo *player)
                      EL_DYNABOMB_PLAYER_1_ACTIVE + player->index_nr :
                      EL_UNDEFINED);
 
+#if USE_DROP_BUGFIX
+  /* do not drop an element on top of another element; when holding drop key
+     pressed without moving, dropped element must move away before the next
+     element can be dropped (this is especially important if the next element
+     is dynamite, which can be placed on background for historical reasons) */
+  if (PLAYER_DROPPING(player, dropx, dropy) && Feld[dropx][dropy] != EL_EMPTY)
+    return MF_ACTION;
+#endif
+
   if (IS_THROWABLE(drop_element))
   {
     dropx += GET_DX_FROM_DIR(drop_direction);
@@ -12557,6 +12573,10 @@ boolean DropElement(struct PlayerInfo *player)
 
   player->is_dropping = TRUE;
 
+#if USE_DROP_BUGFIX
+  player->drop_x = dropx;
+  player->drop_y = dropy;
+#endif
 
   return TRUE;
 }
index f90b2c23b7b23f1bfb28420f4aac8784a9a31447..a3c3247978f80b38b24759f5d34bfbf6fc7871c1 100644 (file)
@@ -456,6 +456,51 @@ char *getHomeDir()
 }
 
 
+/* ------------------------------------------------------------------------- */
+/* path manipulation functions                                               */
+/* ------------------------------------------------------------------------- */
+
+static char *getLastPathSeparatorPtr(char *filename)
+{
+  char *last_separator = strrchr(filename, '/');
+
+#if !defined(PLATFORM_UNIX)
+  if (last_separator == NULL)  /* also try DOS/Windows variant */
+    last_separator = strrchr(filename, '\\');
+#endif
+
+  return last_separator;
+}
+
+static char *getBaseNamePtr(char *filename)
+{
+  char *last_separator = getLastPathSeparatorPtr(filename);
+
+  if (last_separator != NULL)
+    return last_separator + 1; /* separator found: strip base path */
+  else
+    return filename;           /* no separator found: filename has no path */
+}
+
+char *getBaseName(char *filename)
+{
+  return getStringCopy(getBaseNamePtr(filename));
+}
+
+char *getBasePath(char *filename)
+{
+  char *basepath = getStringCopy(filename);
+  char *last_separator = getLastPathSeparatorPtr(basepath);
+
+  if (last_separator != NULL)
+    *last_separator = '\0';    /* separator found: strip basename */
+  else
+    basepath = ".";            /* no separator found: use current path */
+
+  return basepath;
+}
+
+
 /* ------------------------------------------------------------------------- */
 /* various string functions                                                  */
 /* ------------------------------------------------------------------------- */
@@ -529,19 +574,26 @@ void setString(char **old_value, char *new_value)
 
 void GetOptions(char *argv[], void (*print_usage_function)(void))
 {
+  char *ro_base_path = RO_BASE_PATH;
+  char *rw_base_path = RW_BASE_PATH;
   char **options_left = &argv[1];
 
+  if (strcmp(ro_base_path, ".") == 0)
+    ro_base_path = program.command_basepath;
+  if (strcmp(rw_base_path, ".") == 0)
+    rw_base_path = program.command_basepath;
+
   /* initialize global program options */
   options.display_name = NULL;
   options.server_host = NULL;
   options.server_port = 0;
-  options.ro_base_directory = RO_BASE_PATH;
-  options.rw_base_directory = RW_BASE_PATH;
-  options.level_directory = RO_BASE_PATH "/" LEVELS_DIRECTORY;
-  options.graphics_directory = RO_BASE_PATH "/" GRAPHICS_DIRECTORY;
-  options.sounds_directory = RO_BASE_PATH "/" SOUNDS_DIRECTORY;
-  options.music_directory = RO_BASE_PATH "/" MUSIC_DIRECTORY;
-  options.docs_directory = RO_BASE_PATH "/" DOCS_DIRECTORY;
+  options.ro_base_directory = ro_base_path;
+  options.rw_base_directory = rw_base_path;
+  options.level_directory    = getPath2(ro_base_path, LEVELS_DIRECTORY);
+  options.graphics_directory = getPath2(ro_base_path, GRAPHICS_DIRECTORY);
+  options.sounds_directory   = getPath2(ro_base_path, SOUNDS_DIRECTORY);
+  options.music_directory    = getPath2(ro_base_path, MUSIC_DIRECTORY);
+  options.docs_directory     = getPath2(ro_base_path, DOCS_DIRECTORY);
   options.execute_command = NULL;
   options.serveronly = FALSE;
   options.network = FALSE;
@@ -608,22 +660,17 @@ void GetOptions(char *argv[], void (*print_usage_function)(void))
        Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
 
       /* this should be extended to separate options for ro and rw data */
-      options.ro_base_directory = option_arg;
-      options.rw_base_directory = option_arg;
+      options.ro_base_directory = ro_base_path = option_arg;
+      options.rw_base_directory = rw_base_path = option_arg;
       if (option_arg == next_option)
        options_left++;
 
       /* adjust paths for sub-directories in base directory accordingly */
-      options.level_directory =
-       getPath2(options.ro_base_directory, LEVELS_DIRECTORY);
-      options.graphics_directory =
-       getPath2(options.ro_base_directory, GRAPHICS_DIRECTORY);
-      options.sounds_directory =
-       getPath2(options.ro_base_directory, SOUNDS_DIRECTORY);
-      options.music_directory =
-       getPath2(options.ro_base_directory, MUSIC_DIRECTORY);
-      options.docs_directory =
-       getPath2(options.ro_base_directory, DOCS_DIRECTORY);
+      options.level_directory    = getPath2(ro_base_path, LEVELS_DIRECTORY);
+      options.graphics_directory = getPath2(ro_base_path, GRAPHICS_DIRECTORY);
+      options.sounds_directory   = getPath2(ro_base_path, SOUNDS_DIRECTORY);
+      options.music_directory    = getPath2(ro_base_path, MUSIC_DIRECTORY);
+      options.docs_directory     = getPath2(ro_base_path, DOCS_DIRECTORY);
     }
     else if (strncmp(option, "-levels", option_len) == 0)
     {
@@ -1558,27 +1605,21 @@ boolean fileHasSuffix(char *basename, char *suffix)
 
 boolean FileIsGraphic(char *filename)
 {
-  char *basename = strrchr(filename, '/');
-
-  basename = (basename != NULL ? basename + 1 : filename);
+  char *basename = getBaseNamePtr(filename);
 
   return fileHasSuffix(basename, "pcx");
 }
 
 boolean FileIsSound(char *filename)
 {
-  char *basename = strrchr(filename, '/');
-
-  basename = (basename != NULL ? basename + 1 : filename);
+  char *basename = getBaseNamePtr(filename);
 
   return fileHasSuffix(basename, "wav");
 }
 
 boolean FileIsMusic(char *filename)
 {
-  char *basename = strrchr(filename, '/');
-
-  basename = (basename != NULL ? basename + 1 : filename);
+  char *basename = getBaseNamePtr(filename);
 
   if (FileIsSound(basename))
     return TRUE;
index db836823007b5d242b35a7886c1bd304589d90ee..b89be4e87d6382ef19d4305f876d28364a97692f 100644 (file)
@@ -94,6 +94,9 @@ char *getLoginName(void);
 char *getRealName(void);
 char *getHomeDir(void);
 
+char *getBasePath(char *);
+char *getBaseName(char *);
+
 char *getPath2(char *, char *);
 char *getPath3(char *, char *, char*);
 char *getStringCat2(char *, char *);
index e3fbe001184e63468954f372cf5e14d380d8c771..8e65d97056a32dd2baebed276d6016ab46dedc30 100644 (file)
@@ -75,23 +75,8 @@ void InitProgramInfo(char *argv0,
                     char *cookie_prefix, char *filename_prefix,
                     int program_version)
 {
-  char *argv0_copy = getStringCopy(argv0);
-  char *argv0_copy_last_slash = strrchr(argv0_copy, '/');
-
-  if (argv0_copy_last_slash != NULL)
-  {
-    program.command_basename = argv0_copy_last_slash + 1;
-    program.command_basepath = argv0_copy;
-    *argv0_copy_last_slash = '\0';
-  }
-  else
-  {
-    program.command_basename = argv0_copy;
-    program.command_basepath = ".";
-  }
-
-  printf("::: command_basepath == '%s'\n", program.command_basepath);
-  printf("::: command_basename == '%s'\n", program.command_basename);
+  program.command_basepath = getBasePath(argv0);
+  program.command_basename = getBaseName(argv0);
 
   program.userdata_directory = userdata_directory;
   program.program_title = program_title;
index 52d7fb81b57ffa5db7dbeee3179bd625b8b49984..55aba3704c92e06377875d6604db34dd7256816d 100644 (file)
 #define PLAYER_SWITCHING(p,x,y)        ((p)->is_switching &&                   \
                                 (p)->switch_x == (x) && (p)->switch_y == (y))
 
+#define PLAYER_DROPPING(p,x,y) ((p)->is_dropping &&                    \
+                                (p)->drop_x == (x) && (p)->drop_y == (y))
+
 #define PLAYER_NR_GFX(g,i)     ((g) + i * (IMG_PLAYER_2 - IMG_PLAYER_1))
 
 #define ANIM_FRAMES(g)         (graphic_info[g].anim_frames)
 
 /* program information and versioning definitions */
 
+#if 1
+#define PROGRAM_VERSION_MAJOR          3
+#define PROGRAM_VERSION_MINOR          1
+#define PROGRAM_VERSION_PATCH          1
+#define PROGRAM_VERSION_BUILD          0
+#else
 #define PROGRAM_VERSION_MAJOR          3
 #define PROGRAM_VERSION_MINOR          2
 #define PROGRAM_VERSION_PATCH          0
 #define PROGRAM_VERSION_BUILD          3
+#endif
 
 #define PROGRAM_TITLE_STRING           "Rocks'n'Diamonds"
 #define PROGRAM_AUTHOR_STRING          "Holger Schemel"
@@ -1551,6 +1561,7 @@ struct PlayerInfo
   int num_special_action_sleeping;
 
   int switch_x, switch_y;
+  int drop_x, drop_y;
 
   int show_envelope;