rnd-19990822-1-src
authorHolger Schemel <info@artsoft.org>
Sun, 22 Aug 1999 21:07:31 +0000 (23:07 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:34:09 +0000 (10:34 +0200)
src/editor.c
src/files.c
src/game.c
src/main.h

index c5af969143ec21a9a05e40af956e5f4548ff08eb..fdef6f27911007a9797e417fffcfb4d6de5fcb4b 100644 (file)
@@ -1071,6 +1071,11 @@ int editor_element[] =
   EL_LIGHT_SWITCH_OFF,
   EL_LIGHT_SWITCH_ON,
 
+  EL_FORCE_FIELD,
+  EL_EXTRA_TIME,
+  EL_LEERRAUM,
+  EL_LEERRAUM,
+
   /*
   EL_CHAR('D'),
   EL_CHAR('Y'),
index 80c766cd94bb8b97f8a6e385266d9f4f9738e4fb..ce0a95befddb0ff20ff3f7c0be7ae3fa44d81d7d 100644 (file)
@@ -524,6 +524,16 @@ void LoadLevel(int level_nr)
       fgetc(file);
       fgetc(file);
 
+      if (level.num_yam_contents < 1 ||
+         level.num_yam_contents > MAX_ELEMENT_CONTENTS)
+      {
+#if DEBUG
+       printf("WARNING: num_yam_contents == %d (corrected)\n",
+              level.num_yam_contents);
+#endif
+       level.num_yam_contents = STD_ELEMENT_CONTENTS;
+      }
+
       for(i=0; i<MAX_ELEMENT_CONTENTS; i++)
        for(y=0; y<3; y++)
          for(x=0; x<3; x++)
index a9c903cceb5bab85072c08f8cb43cf9fcb632eea..fc0d64767d09631bef0d1fb55345d7ab2c7b26f2 100644 (file)
@@ -1523,6 +1523,134 @@ void Blurb(int x, int y)
   }
 }
 
+static void ToggleBeltSwitch(int x, int y)
+{
+  static int belt_base_element[4] =
+  {
+    EL_BELT1_SWITCH_L,
+    EL_BELT2_SWITCH_L,
+    EL_BELT3_SWITCH_L,
+    EL_BELT4_SWITCH_L
+  };
+  static int belt_move_dir[4] =
+  {
+    MV_LEFT,
+    MV_NO_MOVING,
+    MV_RIGHT,
+    MV_NO_MOVING,
+  };
+
+  int element = Feld[x][y];
+  int belt_nr = getBeltNrFromSwitchElement(element);
+  int belt_dir_nr = (game.belt_dir_nr[belt_nr] + 1) % 4;
+  int belt_dir = belt_move_dir[belt_dir_nr];
+  int xx, yy;
+
+  if (!IS_BELT_SWITCH(element))
+    return;
+
+  game.belt_dir_nr[belt_nr] = belt_dir_nr;
+  game.belt_dir[belt_nr] = belt_dir;
+
+  if (belt_dir_nr == 3)
+    belt_dir_nr = 1;
+
+  for (yy=0; yy<lev_fieldy; yy++)
+  {
+    for (xx=0; xx<lev_fieldx; xx++)
+    {
+      int element = Feld[xx][yy];
+
+      if (IS_BELT_SWITCH(element))
+      {
+       int e_belt_nr = getBeltNrFromSwitchElement(element);
+
+       if (e_belt_nr == belt_nr)
+       {
+         Feld[xx][yy] = belt_base_element[belt_nr] + belt_dir_nr;
+         DrawLevelField(xx, yy);
+       }
+      }
+      else if (belt_dir == MV_NO_MOVING && IS_BELT(element))
+      {
+       int e_belt_nr = getBeltNrFromElement(element);
+
+       if (e_belt_nr == belt_nr)
+         DrawLevelField(xx, yy);    /* set belt to parking position */
+      }
+    }
+  }
+}
+
+static void ToggleSwitchgateSwitch(int x, int y)
+{
+  int xx, yy;
+
+  game.switchgate_pos = !game.switchgate_pos;
+
+  for (yy=0; yy<lev_fieldy; yy++)
+  {
+    for (xx=0; xx<lev_fieldx; xx++)
+    {
+      int element = Feld[xx][yy];
+
+      if (element == EL_SWITCHGATE_SWITCH_1 ||
+         element == EL_SWITCHGATE_SWITCH_2)
+      {
+       Feld[xx][yy] = EL_SWITCHGATE_SWITCH_1 + game.switchgate_pos;
+       DrawLevelField(xx, yy);
+      }
+      else if (element == EL_SWITCHGATE_OPEN ||
+              element == EL_SWITCHGATE_OPENING)
+      {
+       Feld[xx][yy] = EL_SWITCHGATE_CLOSING;
+       PlaySoundLevel(xx, yy, SND_OEFFNEN);
+      }
+      else if (element == EL_SWITCHGATE_CLOSED ||
+              element == EL_SWITCHGATE_CLOSING)
+      {
+       Feld[xx][yy] = EL_SWITCHGATE_OPENING;
+       PlaySoundLevel(xx, yy, SND_OEFFNEN);
+      }
+    }
+  }
+}
+
+static void ToggleLightSwitch(int x, int y)
+{
+  int element = Feld[x][y];
+  int xx, yy;
+
+  game.light_time_left =
+    (element == EL_LIGHT_SWITCH_OFF ? 10 * FRAMES_PER_SECOND : 0);
+
+  for (yy=0; yy<lev_fieldy; yy++)
+  {
+    for (xx=0; xx<lev_fieldx; xx++)
+    {
+      int element = Feld[xx][yy];
+
+      if (element == EL_LIGHT_SWITCH_OFF &&
+         game.light_time_left > 0)
+      {
+       Feld[xx][yy] = EL_LIGHT_SWITCH_ON;
+       DrawLevelField(xx, yy);
+      }
+      else if (element == EL_LIGHT_SWITCH_ON &&
+              game.light_time_left == 0)
+      {
+       Feld[xx][yy] = EL_LIGHT_SWITCH_OFF;
+       DrawLevelField(xx, yy);
+      }
+
+      if (element == EL_INVISIBLE_STEEL ||
+         element == EL_UNSICHTBAR ||
+         element == EL_SAND_INVISIBLE)
+       DrawLevelField(xx, yy);
+    }
+  }
+}
+
 void Impact(int x, int y)
 {
   boolean lastline = (y == lev_fieldy-1);
@@ -1636,6 +1764,20 @@ void Impact(int x, int y)
          PlaySoundLevel(x, y, SND_QUIRK);
          return;
        }
+       else if (IS_BELT_SWITCH(smashed))
+       {
+         ToggleBeltSwitch(x, y+1);
+       }
+       else if (smashed == EL_SWITCHGATE_SWITCH_1 ||
+                smashed == EL_SWITCHGATE_SWITCH_2)
+       {
+         ToggleSwitchgateSwitch(x, y+1);
+       }
+       else if (smashed == EL_LIGHT_SWITCH_OFF ||
+                smashed == EL_LIGHT_SWITCH_ON)
+       {
+         ToggleLightSwitch(x, y+1);
+       }
       }
     }
   }
@@ -1693,7 +1835,7 @@ void Impact(int x, int y)
         break;
     }
 
-    if (sound>=0)
+    if (sound >= 0)
       PlaySoundLevel(x, y, sound);
   }
 }
@@ -3833,6 +3975,10 @@ void GameActions()
       OpenSwitchgate(x, y);
     else if (element == EL_SWITCHGATE_CLOSING)
       CloseSwitchgate(x, y);
+    else if (element == EL_EXTRA_TIME)
+      DrawGraphicAnimation(x, y, GFX_EXTRA_TIME, 6, 4, ANIM_NORMAL);
+    else if (element == EL_FORCE_FIELD)
+      DrawGraphicAnimation(x, y, GFX_FORCE_FIELD, 6, 4, ANIM_NORMAL);
 
     if (game.magic_wall_active)
     {
@@ -4631,6 +4777,21 @@ int DigField(struct PlayerInfo *player,
       PlaySoundLevel(x, y, SND_PONG);
       break;
 
+    case EL_EXTRA_TIME:
+      RemoveField(x, y);
+      if (level.time > 0)
+      {
+       TimeLeft += 10;
+       DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW);
+      }
+      PlaySoundStereo(SND_GONG, PSND_MAX_RIGHT);
+      break;
+
+    case EL_FORCE_FIELD:
+      RemoveField(x, y);
+      PlaySoundLevel(x, y, SND_PONG);
+      break;
+
     case EL_DYNAMITE_INACTIVE:
     case EL_SP_DISK_RED:
       RemoveField(x, y);
@@ -4746,152 +4907,32 @@ int DigField(struct PlayerInfo *player,
     case EL_BELT4_SWITCH_L:
     case EL_BELT4_SWITCH_M:
     case EL_BELT4_SWITCH_R:
+      if (!player->Switching)
       {
-       static int belt_base_element[4] =
-       {
-         EL_BELT1_SWITCH_L,
-         EL_BELT2_SWITCH_L,
-         EL_BELT3_SWITCH_L,
-         EL_BELT4_SWITCH_L
-       };
-       static int belt_move_dir[4] =
-       {
-         MV_LEFT,
-         MV_NO_MOVING,
-         MV_RIGHT,
-         MV_NO_MOVING,
-       };
-
-       int belt_nr = getBeltNrFromSwitchElement(element);
-       int belt_dir_nr = (game.belt_dir_nr[belt_nr] + 1) % 4;
-       int belt_dir = belt_move_dir[belt_dir_nr];
-       int xx, yy;
-
-       if (player->Switching)
-         return MF_ACTION;
-
        player->Switching = TRUE;
-
-       game.belt_dir_nr[belt_nr] = belt_dir_nr;
-       game.belt_dir[belt_nr] = belt_dir;
-
-       if (belt_dir_nr == 3)
-         belt_dir_nr = 1;
-
-       for (yy=0; yy<lev_fieldy; yy++)
-       {
-         for (xx=0; xx<lev_fieldx; xx++)
-         {
-           int element = Feld[xx][yy];
-
-           if (IS_BELT_SWITCH(element))
-           {
-             int e_belt_nr = getBeltNrFromSwitchElement(element);
-
-             if (e_belt_nr == belt_nr)
-             {
-               Feld[xx][yy] = belt_base_element[belt_nr] + belt_dir_nr;
-               DrawLevelField(xx, yy);
-             }
-           }
-           else if (belt_dir == MV_NO_MOVING && IS_BELT(element))
-           {
-             int e_belt_nr = getBeltNrFromElement(element);
-
-             if (e_belt_nr == belt_nr)
-               DrawLevelField(xx, yy);    /* set belt to parking position */
-           }
-         }
-       }
-
-       return MF_ACTION;
+       ToggleBeltSwitch(x, y);
       }
+      return MF_ACTION;
       break;
 
     case EL_SWITCHGATE_SWITCH_1:
     case EL_SWITCHGATE_SWITCH_2:
+      if (!player->Switching)
       {
-       int xx, yy;
-
-       if (player->Switching)
-         return MF_ACTION;
-
        player->Switching = TRUE;
-
-       game.switchgate_pos = !game.switchgate_pos;
-
-       for (yy=0; yy<lev_fieldy; yy++)
-       {
-         for (xx=0; xx<lev_fieldx; xx++)
-         {
-           int element = Feld[xx][yy];
-
-           if (element == EL_SWITCHGATE_SWITCH_1 ||
-               element == EL_SWITCHGATE_SWITCH_2)
-           {
-             Feld[xx][yy] = EL_SWITCHGATE_SWITCH_1 + game.switchgate_pos;
-             DrawLevelField(xx, yy);
-           }
-           else if (element == EL_SWITCHGATE_OPEN ||
-                    element == EL_SWITCHGATE_OPENING)
-           {
-             Feld[xx][yy] = EL_SWITCHGATE_CLOSING;
-             PlaySoundLevel(xx, yy, SND_OEFFNEN);
-           }
-           else if (element == EL_SWITCHGATE_CLOSED ||
-                    element == EL_SWITCHGATE_CLOSING)
-           {
-             Feld[xx][yy] = EL_SWITCHGATE_OPENING;
-             PlaySoundLevel(xx, yy, SND_OEFFNEN);
-           }
-         }
-       }
-
-       return MF_ACTION;
+       ToggleSwitchgateSwitch(x, y);
       }
+      return MF_ACTION;
       break;
 
     case EL_LIGHT_SWITCH_OFF:
     case EL_LIGHT_SWITCH_ON:
+      if (!player->Switching)
       {
-       int xx, yy;
-
-       if (player->Switching)
-         return MF_ACTION;
-
        player->Switching = TRUE;
-
-       game.light_time_left =
-         (element == EL_LIGHT_SWITCH_OFF ? 10 * FRAMES_PER_SECOND : 0);
-
-       for (yy=0; yy<lev_fieldy; yy++)
-       {
-         for (xx=0; xx<lev_fieldx; xx++)
-         {
-           int element = Feld[xx][yy];
-
-           if (element == EL_LIGHT_SWITCH_OFF &&
-               game.light_time_left > 0)
-           {
-             Feld[xx][yy] = EL_LIGHT_SWITCH_ON;
-             DrawLevelField(xx, yy);
-           }
-           else if (element == EL_LIGHT_SWITCH_ON &&
-                    game.light_time_left == 0)
-           {
-             Feld[xx][yy] = EL_LIGHT_SWITCH_OFF;
-             DrawLevelField(xx, yy);
-           }
-
-           if (element == EL_INVISIBLE_STEEL ||
-               element == EL_UNSICHTBAR ||
-               element == EL_SAND_INVISIBLE)
-             DrawLevelField(xx, yy);
-         }
-       }
-
-       return MF_ACTION;
+       ToggleLightSwitch(x, y);
       }
+      return MF_ACTION;
       break;
 
     case EL_SP_EXIT:
index ab26aad533650a1b19010a500a4d249185d6b184..5cfda96e0ec68531089cbfc9c44b0ada4fd3fad1 100644 (file)
@@ -589,12 +589,12 @@ extern char               *element_info[];
 #define MICRO_SP_PER_LINE      64
 
 #define MINI_DC_STARTX         256
-#define MINI_DC_STARTY         0
-#define MICRO_DC_STARTX                256
+#define MINI_DC_STARTY         256
+#define MICRO_DC_STARTX                384
 #define MICRO_DC_STARTY                384
-#define DC_PER_LINE            8
-#define MINI_DC_PER_LINE       8
-#define MICRO_DC_PER_LINE      8
+#define DC_PER_LINE            16
+#define MINI_DC_PER_LINE       16
+#define MICRO_DC_PER_LINE      16
 
 #define FONT_CHARS_PER_LINE    16
 #define FONT_LINES_PER_FONT    4
@@ -1320,6 +1320,9 @@ extern char               *element_info[];
 #define GFX_LANDMINE           (GFX_START_ROCKSDC + 14 * DC_PER_LINE +  7)
 #define GFX_STEEL_SLANTED      (GFX_START_ROCKSDC + 15 * DC_PER_LINE +  5)
 
+#define GFX_EXTRA_TIME         (GFX_START_ROCKSDC +  0 * DC_PER_LINE +  8)
+#define GFX_FORCE_FIELD                (GFX_START_ROCKSDC +  1 * DC_PER_LINE +  8)
+
 /* graphics from "RocksFont" */
 #define GFX_CHAR_START         (GFX_START_ROCKSFONT)
 #define GFX_CHAR_ASCII0                (GFX_CHAR_START - 32)
@@ -1360,8 +1363,6 @@ extern char               *element_info[];
 #define GFX_DOOR_WHITE         GFX_CHAR_FRAGE
 #define GFX_DOOR_WHITE_GRAY    GFX_CHAR_FRAGE
 #define GFX_KEY_WHITE          GFX_CHAR_FRAGE
-#define GFX_FORCE_FIELD                GFX_CHAR_FRAGE
-#define GFX_EXTRA_TIME         GFX_CHAR_FRAGE
 #define GFX_TIME_GATE          GFX_CHAR_FRAGE
 #define GFX_TIME_GATE_WHEEL    GFX_CHAR_FRAGE
 #define GFX_SIGN_RADIOACTIVITY GFX_CHAR_FRAGE