rnd-20060225-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 25 Feb 2006 17:03:45 +0000 (18:03 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:50:52 +0000 (10:50 +0200)
src/conftime.h
src/engines.h
src/events.c
src/game.c
src/game_em/graphics.c
src/libgame/setup.c
src/libgame/system.c
src/libgame/system.h
src/main.h
src/tools.c

index f9dde6fb6fe2c8f76809c6e99668f1d81fee84dc..1baa07fce0adfd246246fcd3862765ddea66c33e 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-02-22 23:30]"
+#define COMPILE_DATE_STRING "[2006-02-25 18:03]"
index 2194a7c9a06ba9138eb6b4ada3896267876158f8..0b736da9dadc47ba53f3ba4ab32a86466dd16464 100644 (file)
 extern void SetBitmaps_EM(Bitmap **);
 extern void UpdateEngineValues(int, int);
 extern void DrawAllGameValues(int, int, int, int, int);
+
 extern int getGameFrameDelay_EM(int);
-extern int getCenteredPlayer_EM();
+extern int getCenteredPlayerNr_EM();
+
 extern void PlayLevelSound_EM(int, int, int, int);
 extern void InitGraphicInfo_EM(void);
 
index f9627a15be4f54d2a5f5524fe998d68c4874aa2a..f478a86bee482edd481952a5cee3325d92fcb776 100644 (file)
@@ -700,9 +700,12 @@ void HandleKey(Key key, int key_status)
 
   if (game_status == GAME_MODE_PLAYING)
   {
-    for (i = 0; i < MAX_PLAYERS; i++)
-      if (key == KSYM_1 + i)
-       game.centered_to_player_next = i;
+    if (key == KSYM_5)
+      game.centered_player_nr_next = -1;
+    else
+      for (i = 0; i < MAX_PLAYERS; i++)
+       if (key == KSYM_1 + i)
+         game.centered_player_nr_next = i;
   }
 
   HandleKeysSpecial(key);
index 19fcafdd74fa3acdef0094efc3d36877daa621ec..8fdc17e2f81893af4fb7da2d2f07f6e5141d40e8 100644 (file)
@@ -1933,7 +1933,7 @@ void InitGame()
 
   game.envelope_active = FALSE;
 
-  game.centered_to_player = game.centered_to_player_next = 0;  /* player_1 */
+  game.centered_player_nr = game.centered_player_nr_next = -1; /* focus all */
 
   for (i = 0; i < NUM_BELTS; i++)
   {
@@ -3266,8 +3266,14 @@ void RelocatePlayer(int jx, int jy, int el_player_raw)
     InitField(jx, jy, FALSE);
   }
 
+#if 1
+  /* only visually relocate centered player */
+  if (player->index_nr == game.centered_player_nr)
+    DrawRelocatePlayer(player, level.instant_relocation);
+#else
   if (player == local_player)  /* only visually relocate local player */
     DrawRelocatePlayer(player, level.instant_relocation);
+#endif
 
   TestIfPlayerTouchesBadThing(jx, jy);
   TestIfPlayerTouchesCustomElement(jx, jy);
@@ -8811,16 +8817,22 @@ void GameActions()
 
   if (ScreenMovPos == 0)       /* screen currently aligned at tile position */
   {
-    struct PlayerInfo *player = &stored_player[game.centered_to_player_next];
+    struct PlayerInfo *player;
+    int player_nr = game.centered_player_nr_next;
+
+    if (game.centered_player_nr_next == -1)
+      player_nr = local_player->index_nr;
+
+    player = &stored_player[player_nr];
 
     if (!player->active)
-      game.centered_to_player_next = game.centered_to_player;
+      game.centered_player_nr_next = game.centered_player_nr;
 
-    if (game.centered_to_player != game.centered_to_player_next)
+    if (game.centered_player_nr != game.centered_player_nr_next)
     {
       DrawRelocatePlayer(player, setup.quick_switch);
 
-      game.centered_to_player = game.centered_to_player_next;
+      game.centered_player_nr = game.centered_player_nr_next;
     }
   }
 
@@ -9652,7 +9664,11 @@ boolean MovePlayerOneStep(struct PlayerInfo *player,
 #endif
   }
 
-#if 0
+#if 1
+  if (!options.network && game.centered_player_nr == -1 &&
+      !AllPlayersInSight(player, new_jx, new_jy))
+    return MP_NO_ACTION;
+#else
   if (!options.network && !AllPlayersInSight(player, new_jx, new_jy))
     return MP_NO_ACTION;
 #endif
@@ -9800,7 +9816,8 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy)
 
 #if 1
   if (moved & MP_MOVING && !ScreenMovPos &&
-      player->index_nr == game.centered_to_player)
+      (player->index_nr == game.centered_player_nr ||
+       game.centered_player_nr == -1))
 #else
   if (moved & MP_MOVING && !ScreenMovPos &&
       (player == local_player || !options.network))
@@ -9859,7 +9876,15 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy)
 
     if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
     {
-#if 0
+#if 1
+      if (!options.network && game.centered_player_nr == -1 &&
+         !AllPlayersInVisibleScreen())
+      {
+       scroll_x = old_scroll_x;
+       scroll_y = old_scroll_y;
+      }
+      else
+#else
       if (!options.network && !AllPlayersInVisibleScreen())
       {
        scroll_x = old_scroll_x;
index 90f43f71da2b4379d17a2bd4bc14fc9ebfbb6361..d64863b4c46fba0bf68ddacdbc2da226c63de9d7 100644 (file)
@@ -45,7 +45,7 @@ static int crumbled_state[MAX_BUF_YSIZE][MAX_BUF_XSIZE];
 
 static boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
 
-static int centered_to_player;
+static int centered_player_nr;
 
 /* copy the entire screen to the window at the scroll position
  *
@@ -479,12 +479,18 @@ void game_initscreen(void)
   int dynamite_state = ply[0].dynamite;                /* !!! ONLY PLAYER 1 !!! */
   int all_keys_state = ply[0].keys | ply[1].keys | ply[2].keys | ply[3].keys;
 #if 1
-  int player_nr = getCenteredPlayer_EM();
+  int player_nr;
+#else
+#if 1
+  int player_nr = getCenteredPlayerNr_EM();
 #else
   int player_nr = 0;           /* !!! FIX THIS (CENTERED TO PLAYER 1) !!! */
 #endif
+#endif
+
+  centered_player_nr = getCenteredPlayerNr_EM();
 
-  centered_to_player = player_nr;
+  player_nr = (centered_player_nr != -1 ? centered_player_nr : 0);
 
   frame = 6;
 #if 1
@@ -612,7 +618,8 @@ void DrawRelocatePlayer(struct PlayerInfo *player, boolean quick_relocation)
 void RedrawPlayfield_EM(boolean force_redraw)
 {
 #if 1
-  int player_nr = getCenteredPlayer_EM();
+  int centered_player_nr_next = getCenteredPlayerNr_EM();
+  int player_nr = (centered_player_nr_next != -1 ? centered_player_nr_next :0);
   boolean draw_new_player_location = FALSE;
   boolean quick_relocation = setup.quick_switch;
 #else
@@ -627,9 +634,9 @@ void RedrawPlayfield_EM(boolean force_redraw)
 
   if (!scrolling)      /* screen currently aligned at tile position */
   {
-    if (player_nr != centered_to_player)
+    if (centered_player_nr != centered_player_nr_next)
     {
-      centered_to_player = player_nr;
+      centered_player_nr = centered_player_nr_next;
 
       draw_new_player_location = TRUE;
       force_redraw = TRUE;
index 4fc58a407b3933a9d6cdd23f69ad54fdf7f06a09..084bb3883182f0dde63b9505be2f3cb4b4689c26 100644 (file)
@@ -799,7 +799,7 @@ void InitLevelSetupDirectory(char *level_subdir)
 
 
 /* ------------------------------------------------------------------------- */
-/* some functions to handle lists of level directories                       */
+/* some functions to handle lists of level and artwork directories           */
 /* ------------------------------------------------------------------------- */
 
 TreeInfo *newTreeInfo()
@@ -927,6 +927,43 @@ TreeInfo *getTreeInfoFromIdentifier(TreeInfo *node, char *identifier)
   return NULL;
 }
 
+TreeInfo *cloneTreeNode(TreeInfo **node_top, TreeInfo *node_parent,
+                       TreeInfo *node, boolean skip_sets_without_levels)
+{
+  TreeInfo *node_new;
+
+  if (node == NULL)
+    return NULL;
+
+  if (!node->parent_link && !node->level_group &&
+      skip_sets_without_levels && node->levels == 0)
+    return cloneTreeNode(node_top, node_parent, node->next,
+                        skip_sets_without_levels);
+
+  node_new = newTreeInfo();
+
+  *node_new = *node;                           /* copy complete node */
+
+  node_new->node_top = node_top;               /* correct top node link */
+  node_new->node_parent = node_parent;         /* correct parent node link */
+
+  if (node->level_group)
+    node_new->node_group = cloneTreeNode(node_top, node_new, node->node_group,
+                                        skip_sets_without_levels);
+
+  node_new->next = cloneTreeNode(node_top, node_parent, node->next,
+                                skip_sets_without_levels);
+  
+  return node_new;
+}
+
+void cloneTree(TreeInfo **ti_new, TreeInfo *ti, boolean skip_empty_sets)
+{
+  TreeInfo *ti_cloned = cloneTreeNode(ti_new, NULL, ti, skip_empty_sets);
+
+  *ti_new = ti_cloned;
+}
+
 void dumpTreeInfo(TreeInfo *node, int depth)
 {
   int i;
@@ -1989,6 +2026,8 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first,
     (leveldir_new->user_defined || !leveldir_new->handicap ?
      leveldir_new->last_level : leveldir_new->first_level);
 
+#if 0
+  /* !!! don't skip sets without levels (else artwork base sets are missing) */
 #if 1
   if (leveldir_new->levels < 1 && !leveldir_new->level_group)
   {
@@ -2000,6 +2039,7 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first,
 
     return FALSE;
   }
+#endif
 #endif
 
   pushTreeInfo(node_first, leveldir_new);
@@ -2093,6 +2133,11 @@ void LoadLevelInfo()
   LoadLevelInfoFromLevelDir(&leveldir_first, NULL, options.level_directory);
   LoadLevelInfoFromLevelDir(&leveldir_first, NULL, getUserLevelDir(NULL));
 
+#if 1
+  leveldir_first_all = leveldir_first;
+  cloneTree(&leveldir_first, leveldir_first_all, TRUE);
+#endif
+
   /* before sorting, the first entries will be from the user directory */
   leveldir_current = getFirstValidTreeInfoEntry(leveldir_first);
 
@@ -2448,9 +2493,9 @@ void LoadLevelArtworkInfo()
 {
   DrawInitText("Looking for custom level artwork:", 120, FC_GREEN);
 
-  LoadArtworkInfoFromLevelInfo(&artwork.gfx_first, leveldir_first);
-  LoadArtworkInfoFromLevelInfo(&artwork.snd_first, leveldir_first);
-  LoadArtworkInfoFromLevelInfo(&artwork.mus_first, leveldir_first);
+  LoadArtworkInfoFromLevelInfo(&artwork.gfx_first, leveldir_first_all);
+  LoadArtworkInfoFromLevelInfo(&artwork.snd_first, leveldir_first_all);
+  LoadArtworkInfoFromLevelInfo(&artwork.mus_first, leveldir_first_all);
 
   /* needed for reloading level artwork not known at ealier stage */
 
index 2980d7b990a1504cb31a889f759c881c2c99bb5a..12e724040fcb56d54728626c75e30018e4e1a165 100644 (file)
@@ -41,6 +41,7 @@ struct ArtworkInfo    artwork;
 struct JoystickInfo    joystick;
 struct SetupInfo       setup;
 
+LevelDirTree          *leveldir_first_all = NULL;
 LevelDirTree          *leveldir_first = NULL;
 LevelDirTree          *leveldir_current = NULL;
 int                    level_nr;
index a0108a28e1f915633e36d37d6b2cdc4b60339cbf..4c05596d4231bc5b6e335ae26be4d1927a37a97e 100644 (file)
@@ -891,6 +891,7 @@ extern struct ArtworkInfo   artwork;
 extern struct JoystickInfo     joystick;
 extern struct SetupInfo                setup;
 
+extern LevelDirTree           *leveldir_first_all;
 extern LevelDirTree           *leveldir_first;
 extern LevelDirTree           *leveldir_current;
 extern int                     level_nr;
index 8ae104915bb26aefe87e8b4f064f0da00454b17c..ffde34c3fadf17fa1f714f3713f63d5248b64b26 100644 (file)
@@ -2081,8 +2081,8 @@ struct GameInfo
   boolean restart_level;
 
   /* values for special game control */
-  int centered_to_player;
-  int centered_to_player_next;
+  int centered_player_nr;
+  int centered_player_nr_next;
 };
 
 struct GlobalInfo
index 712be2395879d8483061304dec048c086b0945b3..4ce303450a2ec08fe552271eef51a8758dcd22f2 100644 (file)
@@ -5129,15 +5129,16 @@ int getGameFrameDelay_EM(int native_em_game_frame_delay)
   return game_frame_delay_value;
 }
 
-int getCenteredPlayer_EM()
+int getCenteredPlayerNr_EM()
 {
-  if (!native_em_level.ply[game.centered_to_player_next]->alive)
-    game.centered_to_player_next = game.centered_to_player;
+  if (game.centered_player_nr_next >= 0 &&
+      !native_em_level.ply[game.centered_player_nr_next]->alive)
+    game.centered_player_nr_next = game.centered_player_nr;
 
-  if (game.centered_to_player != game.centered_to_player_next)
-    game.centered_to_player = game.centered_to_player_next;
+  if (game.centered_player_nr != game.centered_player_nr_next)
+    game.centered_player_nr = game.centered_player_nr_next;
 
-  return game.centered_to_player;
+  return game.centered_player_nr;
 }
 
 unsigned int InitRND(long seed)