rnd-19980925
authorHolger Schemel <info@artsoft.org>
Fri, 25 Sep 1998 18:15:02 +0000 (20:15 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:30:41 +0000 (10:30 +0200)
src/events.c
src/files.c
src/gadget.c [new file with mode: 0644]
src/gadget.h [new file with mode: 0644]
src/game.c
src/init.c
src/main.c
src/main.h
src/random.c
src/screens.c

index 238aa066ed72188b931a4509121db9ec9d220af4..d2b364886627bc5412235e3f85cd260f1b63bd58 100644 (file)
@@ -552,7 +552,7 @@ void HandleKey(KeySym key, int key_status)
        case XK_Q:
 #endif
        case XK_q:
-         Dynamite = 1000;
+         local_player->dynamite = 1000;
          break;
 
        case XK_x:
index 9a50079c3598bf5d9cea9dcbba0dd66bd7ecf271..e3ad459fb57c59393cf3847fe073add1bcc8bdd6 100644 (file)
@@ -394,7 +394,7 @@ void LoadPlayerInfo(int mode)
 
   if (!file)
   {
-    player = default_player;
+    *local_player = default_player;
     level_nr = default_player.level_nr;
     return;
   }
@@ -453,19 +453,19 @@ void LoadPlayerInfo(int mode)
 
   if (mode==PLAYER_SETUP)
   {
-    player = new_player;
-    if (player.leveldir_nr < num_leveldirs)
-      leveldir_nr = player.leveldir_nr;
+    *local_player = new_player;
+    if (local_player->leveldir_nr < num_leveldirs)
+      leveldir_nr = local_player->leveldir_nr;
     else
       leveldir_nr = 0;
   }
   else
   {
-    player.handicap = new_player.handicap;
-    player.level_nr = new_player.level_nr;
+    local_player->handicap = new_player.handicap;
+    local_player->level_nr = new_player.level_nr;
   }
 
-  level_nr = player.level_nr;
+  level_nr = local_player->level_nr;
   fclose(file);
 }
 
@@ -668,26 +668,27 @@ void SavePlayerInfo(int mode)
     if (feof(file))            /* Spieler noch nicht in Liste enthalten */
       break;
     else                       /* prüfen, ob Spieler in Liste enthalten */
-      if (!strncmp(default_player.login_name,player.login_name,MAX_NAMELEN-1))
+      if (!strncmp(default_player.login_name,
+                  local_player->login_name, MAX_NAMELEN-1))
       {
        fseek(file,-(2*MAX_NAMELEN+1+2+1+(version_10_file ? 0 : 11)),SEEK_CUR);
        break;
       }
   }
 
-  player.level_nr = level_nr;
+  local_player->level_nr = level_nr;
 
   for(i=0;i<MAX_NAMELEN;i++)
-    fputc(player.login_name[i],file);
+    fputc(local_player->login_name[i],file);
   for(i=0;i<MAX_NAMELEN;i++)
-    fputc(player.alias_name[i],file);
-  fputc(player.handicap,file);
-  fputc(player.setup / 256,file);
-  fputc(player.setup % 256,file);
-  fputc(player.leveldir_nr,file);
+    fputc(local_player->alias_name[i],file);
+  fputc(local_player->handicap,file);
+  fputc(local_player->setup / 256,file);
+  fputc(local_player->setup % 256,file);
+  fputc(local_player->leveldir_nr,file);
   if (!version_10_file)
   {
-    fputc(player.level_nr,file);
+    fputc(local_player->level_nr,file);
     for(i=0;i<10;i++)          /* currently unused bytes */
       fputc(0,file);
   }
diff --git a/src/gadget.c b/src/gadget.c
new file mode 100644 (file)
index 0000000..dee0566
--- /dev/null
@@ -0,0 +1,7 @@
+/* gadget.c */
+
+#include "gadget.h"
+
+struct Gadget *gadget_list;
+
+void NextGadgetEvent()
diff --git a/src/gadget.h b/src/gadget.h
new file mode 100644 (file)
index 0000000..5ee9c98
--- /dev/null
@@ -0,0 +1,54 @@
+/* gadget.h */
+
+/* gadget types */
+#define GD_TYPE_NORMAL_BUTTON          (1<<0)
+#define GD_TYPE_TWO_STATE_BUTTON       (1<<1)
+#define GD_TYPE_DRAWING_AREA           (1<<2)
+#define GD_TYPE_TEXTINPUT              (1<<3)
+#define GD_TYPE_TEXTOUTPUT             (1<<4)
+#define GD_TYPE_NUMBERINPUT            (1<<5)
+#define GD_TYPE_NUMBEROUTPUT           (1<<6)
+
+/* gadget events */
+#define GD_EVENT_PRESSED               (1<<0)
+#define GD_EVENT_RELEASED              (1<<1)
+#define GD_EVENT_MOVING                        (1<<2)
+
+/* gadget structure constants */
+#define MAX_GADGET_TEXTSIZE            1024
+
+struct GadgetDesign
+{
+  Pixmap pixmap;                       /* Pixmap with gadget surface */
+  int x,y;                             /* position of rectangle in Pixmap */
+};
+
+struct Gadget
+{
+  int x,y;                             /* screen position */
+  int width,height;                    /* screen size */
+  unsigned long type;                  /* type (button, text input, ...) */
+  unsigned long state;                 /* state (pressed, released, ...) */
+  long number_value;
+  char text_value[MAX_GADGET_TEXTSIZE];
+  struct GadgetDesign *design[2];      /* 0: normal; 1: pressed */
+  struct GadgetDesign *alt_design[2];  /* alternative design */
+  unsigned long event;                 /* actual gadget event */
+  struct Gadget *next;                 /* next list entry */
+};
+
+struct NewGadget
+{
+  int x,y;                             /* screen position */
+  int width,height;                    /* screen size */
+  unsigned long type;                  /* type (button, text input, ...) */
+  struct GadgetDesign *design[2];      /* 0: normal; 1: pressed */
+  struct GadgetDesign *alt_design[2];  /* alternative design */
+  unsigned long value_mask;            /* actual gadget event */
+};
+
+struct GadgetEvent
+{
+  unsigned long state;                 /* state (pressed, released, ...) */
+  int x,y;                             /* position inside drawing area */
+};
index 0a7bbd4d7dbcd4a41430c65de4e6a6bbf9841aa5..c7b99a3da5a5ca4a8e1030eb718503933cbdfd86 100644 (file)
@@ -28,24 +28,24 @@ void GetPlayerConfig()
   int old_joystick_nr = joystick_nr;
 
   if (sound_status==SOUND_OFF)
-    player.setup &= ~SETUP_SOUND;
+    local_player->setup &= ~SETUP_SOUND;
   if (!sound_loops_allowed)
   {
-    player.setup &= ~SETUP_SOUND_LOOPS;
-    player.setup &= ~SETUP_SOUND_MUSIC;
+    local_player->setup &= ~SETUP_SOUND_LOOPS;
+    local_player->setup &= ~SETUP_SOUND_MUSIC;
   }
 
-  sound_on = sound_simple_on = SETUP_SOUND_ON(player.setup);
-  sound_loops_on = SETUP_SOUND_LOOPS_ON(player.setup);
-  sound_music_on = SETUP_SOUND_MUSIC_ON(player.setup);
-  toons_on = SETUP_TOONS_ON(player.setup);
-  direct_draw_on = SETUP_DIRECT_DRAW_ON(player.setup);
-  fading_on = SETUP_FADING_ON(player.setup);
-  autorecord_on = SETUP_AUTO_RECORD_ON(player.setup);
-  joystick_nr = SETUP_2ND_JOYSTICK_ON(player.setup);
-  quick_doors = SETUP_QUICK_DOORS_ON(player.setup);
-  scroll_delay_on = SETUP_SCROLL_DELAY_ON(player.setup);
-  soft_scrolling_on = SETUP_SOFT_SCROLL_ON(player.setup);
+  sound_on = sound_simple_on = SETUP_SOUND_ON(local_player->setup);
+  sound_loops_on = SETUP_SOUND_LOOPS_ON(local_player->setup);
+  sound_music_on = SETUP_SOUND_MUSIC_ON(local_player->setup);
+  toons_on = SETUP_TOONS_ON(local_player->setup);
+  direct_draw_on = SETUP_DIRECT_DRAW_ON(local_player->setup);
+  fading_on = SETUP_FADING_ON(local_player->setup);
+  autorecord_on = SETUP_AUTO_RECORD_ON(local_player->setup);
+  joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup);
+  quick_doors = SETUP_QUICK_DOORS_ON(local_player->setup);
+  scroll_delay_on = SETUP_SCROLL_DELAY_ON(local_player->setup);
+  soft_scrolling_on = SETUP_SOFT_SCROLL_ON(local_player->setup);
 
 #ifndef MSDOS
   if (joystick_nr != old_joystick_nr)
@@ -63,12 +63,27 @@ void InitGame()
   BOOL emulate_bd = TRUE;      /* unless non-BOULDERDASH elements found */
   BOOL emulate_sb = TRUE;      /* unless non-SOKOBAN     elements found */
 
-  Dynamite = Score = 0;
-  Gems = level.edelsteine;
-  SokobanFields = Lights = Friends = 0;
-  DynaBombCount = DynaBombSize = DynaBombsLeft = 0;
-  DynaBombXL = FALSE;
-  Key[0] = Key[1] = Key[2] = Key[3] = FALSE;
+  local_player->active = TRUE;
+  local_player->local = TRUE;
+
+  actual_player = local_player;
+
+  actual_player->score = 0;
+
+  actual_player->gems_still_needed = level.edelsteine;
+  actual_player->sokobanfields_still_needed = 0;
+  actual_player->lights_still_needed = 0;
+  actual_player->friends_still_needed = 0;
+
+  for(i=0; i<4; i++)
+    actual_player->key[i] = FALSE;
+
+  actual_player->dynamite = 0;
+  actual_player->dynabomb_count = 0;
+  actual_player->dynabomb_size = 0;
+  actual_player->dynabombs_left = 0;
+  actual_player->dynabomb_xl = FALSE;
+
   MampferNr = 0;
   FrameCounter = 0;
   TimeFrames = 0;
@@ -110,6 +125,8 @@ void InitGame()
        JY = lastJY = y;
        break;
       case EL_SPIELER2:
+      case EL_SPIELER3:
+      case EL_SPIELER4:
        Feld[x][y] = EL_LEERRAUM;
        break;
       case EL_BADEWANNE:
@@ -169,14 +186,14 @@ void InitGame()
        MovDelay[x][y] = 96;
        break;
       case EL_BIRNE_AUS:
-       Lights++;
+       local_player->lights_still_needed++;
        break;
       case EL_SOKOBAN_FELD_LEER:
-       SokobanFields++;
+       local_player->sokobanfields_still_needed++;
        break;
       case EL_MAULWURF:
       case EL_PINGUIN:
-       Friends++;
+       local_player->friends_still_needed++;
        break;
       case EL_SCHWEIN:
       case EL_DRACHE:
@@ -212,13 +229,13 @@ void InitGame()
              int2str(level_nr,2),FS_SMALL,FC_YELLOW);
   DrawTextExt(pix[PIX_DB_DOOR],gc,
              DOOR_GFX_PAGEX1+XX_EMERALDS,DOOR_GFX_PAGEY1+YY_EMERALDS,
-             int2str(Gems,3),FS_SMALL,FC_YELLOW);
+             int2str(local_player->gems_still_needed,3),FS_SMALL,FC_YELLOW);
   DrawTextExt(pix[PIX_DB_DOOR],gc,
              DOOR_GFX_PAGEX1+XX_DYNAMITE,DOOR_GFX_PAGEY1+YY_DYNAMITE,
-             int2str(Dynamite,3),FS_SMALL,FC_YELLOW);
+             int2str(local_player->dynamite,3),FS_SMALL,FC_YELLOW);
   DrawTextExt(pix[PIX_DB_DOOR],gc,
              DOOR_GFX_PAGEX1+XX_SCORE,DOOR_GFX_PAGEY1+YY_SCORE,
-             int2str(Score,5),FS_SMALL,FC_YELLOW);
+             int2str(local_player->score,5),FS_SMALL,FC_YELLOW);
   DrawTextExt(pix[PIX_DB_DOOR],gc,
              DOOR_GFX_PAGEX1+XX_TIME,DOOR_GFX_PAGEY1+YY_TIME,
              int2str(TimeLeft,3),FS_SMALL,FC_YELLOW);
@@ -361,19 +378,19 @@ void GameWon()
   if (TimeLeft)
   {
     if (sound_loops_on)
-      PlaySoundExt(SND_SIRR,PSND_MAX_VOLUME,PSND_MAX_RIGHT,PSND_LOOP);
+      PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP);
 
-    while(TimeLeft>0)
+    while(TimeLeft > 0)
     {
       if (!sound_loops_on)
-       PlaySoundStereo(SND_SIRR,PSND_MAX_RIGHT);
+       PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT);
       if (TimeLeft && !(TimeLeft % 10))
        RaiseScore(level.score[SC_ZEITBONUS]);
       if (TimeLeft > 100 && !(TimeLeft % 10))
        TimeLeft -= 10;
       else
        TimeLeft--;
-      DrawText(DX_TIME,DY_TIME,int2str(TimeLeft,3),FS_SMALL,FC_YELLOW);
+      DrawText(DX_TIME, DY_TIME, int2str(TimeLeft,3), FS_SMALL, FC_YELLOW);
       BackToFront();
       Delay(10);
     }
@@ -385,7 +402,7 @@ void GameWon()
   FadeSounds();
 
   /* Hero disappears */
-  DrawLevelElement(ExitX,ExitY,Feld[ExitX][ExitY]);
+  DrawLevelField(ExitX, ExitY);
   BackToFront();
 
   if (tape.playing)
@@ -399,15 +416,15 @@ void GameWon()
     SaveLevelTape(tape.level_nr);      /* Ask to save tape */
   }
 
-  if (level_nr==player.handicap &&
-      level_nr<leveldir[leveldir_nr].levels-1)
+  if (level_nr == local_player->handicap &&
+      level_nr < leveldir[leveldir_nr].levels-1)
   { 
-    player.handicap++; 
+    local_player->handicap++; 
     bumplevel = TRUE;
     SavePlayerInfo(PLAYER_LEVEL);
   }
 
-  if ((hi_pos=NewHiScore())>=0) 
+  if ((hi_pos=NewHiScore()) >= 0) 
   {
     game_status = HALLOFFAME;
     DrawHallOfFame(hi_pos);
@@ -432,21 +449,23 @@ BOOL NewHiScore()
 
   LoadScore(level_nr);
 
-  if (!strcmp(player.alias_name,EMPTY_ALIAS) ||
-      Score<highscore[MAX_SCORE_ENTRIES-1].Score) 
+  if (!strcmp(local_player->alias_name,EMPTY_ALIAS) ||
+      local_player->score < highscore[MAX_SCORE_ENTRIES-1].Score) 
     return(-1);
 
   for(k=0;k<MAX_SCORE_ENTRIES;k++) 
   {
-    if (Score>highscore[k].Score)      /* Spieler kommt in Highscore-Liste */
+    if (local_player->score > highscore[k].Score)
     {
+      /* Spieler kommt in Highscore-Liste */
+
       if (k<MAX_SCORE_ENTRIES-1)
       {
        int m = MAX_SCORE_ENTRIES-1;
 
 #ifdef ONE_PER_NAME
        for(l=k;l<MAX_SCORE_ENTRIES;l++)
-         if (!strcmp(player.alias_name,highscore[l].Name))
+         if (!strcmp(local_player->alias_name,highscore[l].Name))
            m = l;
        if (m==k)       /* Spieler überschreibt seine alte Position */
          goto put_into_list;
@@ -462,14 +481,14 @@ BOOL NewHiScore()
 #ifdef ONE_PER_NAME
       put_into_list:
 #endif
-      sprintf(highscore[k].Name,player.alias_name);
-      highscore[k].Score = Score; 
+      sprintf(highscore[k].Name,local_player->alias_name);
+      highscore[k].Score = local_player->score; 
       position = k;
       break;
     }
 
 #ifdef ONE_PER_NAME
-    else if (!strcmp(player.alias_name,highscore[k].Name))
+    else if (!strcmp(local_player->alias_name,highscore[k].Name))
       break;   /* Spieler schon mit besserer Punktzahl in der Liste */
 #endif
 
@@ -792,12 +811,12 @@ void DynaExplode(int ex, int ey, int size)
       if (element != EL_LEERRAUM &&
          element != EL_ERDREICH &&
          element != EL_EXPLODING &&
-         !DynaBombXL)
+         !actual_player->dynabomb_xl)
        break;
     }
   }
 
-  DynaBombsLeft++;
+  actual_player->dynabombs_left++;
 }
 
 void Bang(int x, int y)
@@ -823,7 +842,7 @@ void Bang(int x, int y)
     case EL_DYNABOMB_NR:
     case EL_DYNABOMB_SZ:
     case EL_DYNABOMB_XL:
-      DynaExplode(x,y,DynaBombSize);
+      DynaExplode(x,y,actual_player->dynabomb_size);
       break;
     case EL_BIRNE_AUS:
     case EL_BIRNE_EIN:
@@ -1647,8 +1666,8 @@ void StartMoving(int x, int y)
        if (IN_SCR_FIELD(SCROLLX(newx),SCROLLY(newy)))
          DrawGraphicThruMask(SCROLLX(newx),SCROLLY(newy),el2gfx(element));
 
-       Friends--;
-       if (!Friends && PlayerGone && !GameOver)
+       local_player->friends_still_needed--;
+       if (!local_player->friends_still_needed && PlayerGone && !GameOver)
          LevelSolved = GameOver = TRUE;
 
        return;
@@ -2346,7 +2365,9 @@ void SiebAktivieren(int x, int y, int typ)
 
 void AusgangstuerPruefen(int x, int y)
 {
-  if (!Gems && !SokobanFields && !Lights)
+  if (!local_player->gems_still_needed &&
+      !local_player->sokobanfields_still_needed &&
+      !local_player->lights_still_needed)
   {
     Feld[x][y] = EL_AUSGANG_ACT;
 
@@ -3161,49 +3182,55 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
     case EL_EDELSTEIN_LILA:
       Feld[x][y] = EL_LEERRAUM;
       MovDelay[x][y] = 0;      /* wegen EDELSTEIN_BD-Funkeln! */
-      if (Gems>0)
-       Gems--;
+      if (local_player->gems_still_needed > 0)
+       local_player->gems_still_needed--;
       RaiseScoreElement(EL_EDELSTEIN);
-      DrawText(DX_EMERALDS,DY_EMERALDS,int2str(Gems,3),FS_SMALL,FC_YELLOW);
-      PlaySoundLevel(x,y,SND_PONG);
+      DrawText(DX_EMERALDS, DY_EMERALDS,
+              int2str(local_player->gems_still_needed, 3),
+              FS_SMALL, FC_YELLOW);
+      PlaySoundLevel(x, y, SND_PONG);
       break;
 
     case EL_DIAMANT:
       Feld[x][y] = EL_LEERRAUM;
-      Gems -= 3;
-      if (Gems<0)
-       Gems=0;
+      local_player->gems_still_needed -= 3;
+      if (local_player->gems_still_needed < 0)
+       local_player->gems_still_needed = 0;
       RaiseScoreElement(EL_DIAMANT);
-      DrawText(DX_EMERALDS,DY_EMERALDS,int2str(Gems,3),FS_SMALL,FC_YELLOW);
-      PlaySoundLevel(x,y,SND_PONG);
+      DrawText(DX_EMERALDS, DY_EMERALDS,
+              int2str(local_player->gems_still_needed, 3),
+              FS_SMALL, FC_YELLOW);
+      PlaySoundLevel(x, y, SND_PONG);
       break;
 
     case EL_DYNAMIT_AUS:
       Feld[x][y] = EL_LEERRAUM;
-      Dynamite++;
+      actual_player->dynamite++;
       RaiseScoreElement(EL_DYNAMIT);
-      DrawText(DX_DYNAMITE,DY_DYNAMITE,int2str(Dynamite,3),FS_SMALL,FC_YELLOW);
+      DrawText(DX_DYNAMITE, DY_DYNAMITE,
+              int2str(local_player->dynamite, 3),
+              FS_SMALL, FC_YELLOW);
       PlaySoundLevel(x,y,SND_PONG);
       break;
 
     case EL_DYNABOMB_NR:
       Feld[x][y] = EL_LEERRAUM;
-      DynaBombCount++;
-      DynaBombsLeft++;
+      actual_player->dynabomb_count++;
+      actual_player->dynabombs_left++;
       RaiseScoreElement(EL_DYNAMIT);
       PlaySoundLevel(x,y,SND_PONG);
       break;
     case EL_DYNABOMB_SZ:
 
       Feld[x][y] = EL_LEERRAUM;
-      DynaBombSize++;
+      actual_player->dynabomb_size++;
       RaiseScoreElement(EL_DYNAMIT);
       PlaySoundLevel(x,y,SND_PONG);
       break;
 
     case EL_DYNABOMB_XL:
       Feld[x][y] = EL_LEERRAUM;
-      DynaBombXL = TRUE;
+      actual_player->dynabomb_xl = TRUE;
       RaiseScoreElement(EL_DYNAMIT);
       PlaySoundLevel(x,y,SND_PONG);
       break;
@@ -3216,7 +3243,7 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
       int key_nr = element-EL_SCHLUESSEL1;
 
       Feld[x][y] = EL_LEERRAUM;
-      Key[key_nr] = TRUE;
+      actual_player->key[key_nr] = TRUE;
       RaiseScoreElement(EL_SCHLUESSEL);
       DrawMiniGraphicExt(drawto,gc,
                         DX_KEYS+key_nr*MINI_TILEX,DY_KEYS,
@@ -3277,7 +3304,7 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
     case EL_PFORTE2:
     case EL_PFORTE3:
     case EL_PFORTE4:
-      if (!Key[element-EL_PFORTE1])
+      if (!actual_player->key[element-EL_PFORTE1])
        return(MF_NO_ACTION);
       break;
 
@@ -3285,7 +3312,7 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
     case EL_PFORTE2X:
     case EL_PFORTE3X:
     case EL_PFORTE4X:
-      if (!Key[element-EL_PFORTE1X])
+      if (!actual_player->key[element-EL_PFORTE1X])
        return(MF_NO_ACTION);
       break;
 
@@ -3302,14 +3329,14 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
       PlayerGone = TRUE;
       PlaySoundLevel(x,y,SND_BUING);
 
-      if (!Friends)
+      if (!local_player->friends_still_needed)
        LevelSolved = GameOver = TRUE;
 
       break;
 
     case EL_BIRNE_AUS:
       Feld[x][y] = EL_BIRNE_EIN;
-      Lights--;
+      local_player->lights_still_needed--;
       DrawLevelField(x,y);
       PlaySoundLevel(x,y,SND_DENG);
       return(MF_ACTION);
@@ -3362,7 +3389,7 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
        if (element == EL_SOKOBAN_FELD_VOLL)
        {
          Feld[x][y] = EL_SOKOBAN_FELD_LEER;
-         SokobanFields++;
+         local_player->sokobanfields_still_needed++;
        }
        else
          Feld[x][y] = EL_LEERRAUM;
@@ -3370,7 +3397,7 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
        if (Feld[x+dx][y+dy] == EL_SOKOBAN_FELD_LEER)
        {
          Feld[x+dx][y+dy] = EL_SOKOBAN_FELD_VOLL;
-         SokobanFields--;
+         local_player->sokobanfields_still_needed--;
          if (element == EL_SOKOBAN_OBJEKT)
            PlaySoundLevel(x,y,SND_DENG);
        }
@@ -3390,7 +3417,8 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
       PlaySoundLevel(x+dx,y+dy,SND_PUSCH);
 
       if (IS_SB_ELEMENT(element) &&
-         SokobanFields == 0 && game_emulation == EMU_SOKOBAN)
+         local_player->sokobanfields_still_needed == 0 &&
+         game_emulation == EMU_SOKOBAN)
       {
        LevelSolved = GameOver = TRUE;
        PlaySoundLevel(x,y,SND_BUING);
@@ -3455,26 +3483,28 @@ BOOL PlaceBomb(void)
 
   element = Feld[JX][JY];
 
-  if ((Dynamite==0 && DynaBombsLeft==0) ||
+  if ((actual_player->dynamite==0 && actual_player->dynabombs_left==0) ||
       element==EL_DYNAMIT || element==EL_DYNABOMB || element==EL_EXPLODING)
     return(FALSE);
 
   if (element != EL_LEERRAUM)
     Store[JX][JY] = element;
 
-  if (Dynamite)
+  if (actual_player->dynamite)
   {
     Feld[JX][JY] = EL_DYNAMIT;
     MovDelay[JX][JY] = 96;
-    Dynamite--;
-    DrawText(DX_DYNAMITE,DY_DYNAMITE,int2str(Dynamite,3),FS_SMALL,FC_YELLOW);
+    actual_player->dynamite--;
+    DrawText(DX_DYNAMITE, DY_DYNAMITE,
+            int2str(local_player->dynamite, 3),
+            FS_SMALL, FC_YELLOW);
     DrawGraphicThruMask(SCROLLX(JX),SCROLLY(JY),GFX_DYNAMIT);
   }
   else
   {
     Feld[JX][JY] = EL_DYNABOMB;
     MovDelay[JX][JY] = 96;
-    DynaBombsLeft--;
+    actual_player->dynabombs_left--;
     DrawGraphicThruMask(SCROLLX(JX),SCROLLY(JY),GFX_DYNABOMB);
   }
 
@@ -3518,8 +3548,10 @@ void PlaySoundLevel(int x, int y, int sound_nr)
 
 void RaiseScore(int value)
 {
-  Score += value;
-  DrawText(DX_SCORE,DY_SCORE,int2str(Score,5),FS_SMALL,FC_YELLOW);
+  local_player->score += value;
+  DrawText(DX_SCORE, DY_SCORE,
+          int2str(local_player->score, 5),
+          FS_SMALL, FC_YELLOW);
 }
 
 void RaiseScoreElement(int element)
index 726f78560b8f25eae13d3a5cd26c8c0337879221..9092f382813787b83c942fd1d9403c5ea5ff6b77 100644 (file)
@@ -80,6 +80,8 @@ void OpenAll(int argc, char *argv[])
 
 void InitLevelAndPlayerInfo()
 {
+  local_player = &stored_player[0];
+
   if (!LoadLevelInfo())                        /* global level info */
     CloseAll();
 
index 443a433610c5ab31d86aba2283cf4368f61d22d4..b52761b3722d9f63801da2c622c14f98edcdfec6 100644 (file)
@@ -94,15 +94,13 @@ int         JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
 int            PlayerMovDir, PlayerMovPos, PlayerPushing;
 int            PlayerFrame, PlayerGfxPos;
 int            PlayerGone, LevelSolved, GameOver;
-int            FrameCounter, TimeFrames, TimeLeft, Score;
-int            Gems, SokobanFields, Lights, Friends;
-int            Dynamite, Key[4], MampferNr;
-int            DynaBombCount, DynaBombSize, DynaBombsLeft, DynaBombXL;
-int            SiebAktiv;
+int            FrameCounter, TimeFrames, TimeLeft;
+int            MampferNr, SiebAktiv;
 
 struct LevelDirInfo    leveldir[MAX_LEVDIR_ENTRIES];
 struct LevelInfo       level;
-struct PlayerInfo      player;
+struct PlayerInfo      stored_player[MAX_PLAYERS+1];
+struct PlayerInfo      *local_player, *actual_player;
 struct HiScore         highscore[MAX_SCORE_ENTRIES];
 struct SoundInfo       Sound[NUM_SOUNDS];
 struct RecordingInfo   tape;
index bf9fbfec0b7f5e480a0fce97199fcaaee4ae2fd9..928489ab42ec0077c0e82732acea54935952abbb 100644 (file)
@@ -68,6 +68,8 @@ typedef int BOOL;
 #define MAX_LEV_FIELDX 128
 #define MAX_LEV_FIELDY 128
 
+#define MAX_PLAYERS    4
+
 #ifndef MIN
 #define MIN(a,b)       ((a)<(b) ? (a) : (b))
 #endif
@@ -205,12 +207,28 @@ struct HiScore
 
 struct PlayerInfo
 {
+  BOOL active, local;
+
   char login_name[MAX_NAMELEN];
   char alias_name[MAX_NAMELEN];
   int handicap;
   unsigned int setup;
   int leveldir_nr;
   int level_nr;
+
+  int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
+  int PlayerMovDir, PlayerMovPos, PlayerPushing;
+  int PlayerFrame, PlayerGfxPos;
+  int PlayerGone, LevelSolved, GameOver;
+
+  int score;
+  int gems_still_needed;
+  int sokobanfields_still_needed;
+  int lights_still_needed;
+  int friends_still_needed;
+  int key[4];
+  int dynamite;
+  int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
 };
 
 struct LevelInfo
@@ -332,15 +350,13 @@ extern int                JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
 extern int             PlayerMovDir, PlayerMovPos, PlayerPushing;
 extern int             PlayerFrame, PlayerGfxPos;
 extern int             PlayerGone,LevelSolved,GameOver;
-extern int             FrameCounter,TimeFrames,TimeLeft,Score;
-extern int             Gems,SokobanFields,Lights,Friends;
-extern int             Dynamite,Key[4],MampferNr;
-extern int             DynaBombCount, DynaBombSize, DynaBombsLeft, DynaBombXL;
-extern int             SiebAktiv;
+extern int             FrameCounter,TimeFrames,TimeLeft;
+extern int             MampferNr, SiebAktiv;
 
 extern struct LevelDirInfo     leveldir[];
 extern struct LevelInfo                level;
-extern struct PlayerInfo       player;
+extern struct PlayerInfo       stored_player[];
+extern struct PlayerInfo       *local_player, *actual_player;
 extern struct HiScore          highscore[];
 extern struct RecordingInfo    tape;
 extern struct SoundInfo                Sound[];
index b2fa0d41e012bfe0c8581d2c0befe861e73d1bdb..864f3dcc902388e61c73239ac3662fb8893c2911 100644 (file)
@@ -21,9 +21,6 @@
  * It was reworked for the GNU C Library by Roland McGrath.
  */
 
-#ifndef MSDOS
-#include <ansidecl.h>
-#endif
 #include <errno.h>
 #include <limits.h>
 #include <stdlib.h>
index 9cc9235e6f780899c90c35ea63e232a1a25234dc..9f0ec9f9961e0b20bf30e76a834f05a6894b062f 100644 (file)
@@ -51,7 +51,7 @@ void DrawMainMenu()
   ClearWindow();
   DrawHeadline();
   DrawText(SX+32, SY+64, "Name:",FS_BIG,FC_GREEN);
-  DrawText(SX+192,SY+64, player.alias_name,FS_BIG,FC_RED);
+  DrawText(SX+192,SY+64, local_player->alias_name,FS_BIG,FC_RED);
   DrawText(SX+32, SY+96, "Level:",FS_BIG,FC_GREEN);
   DrawText(SX+352,SY+96, int2str(level_nr,3),FS_BIG,
           (level_nr<leveldir[leveldir_nr].levels ? FC_RED : FC_YELLOW));
@@ -151,8 +151,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
 
     level_nr = new_level_nr;
 
-    if (level_nr>player.handicap)
-      level_nr = player.handicap;
+    if (level_nr > local_player->handicap)
+      level_nr = local_player->handicap;
 
     DrawTextExt(drawto,gc,SX+352,SY+96, int2str(level_nr,3), FS_BIG,FC_RED);
     DrawTextExt(window,gc,SX+352,SY+96,        int2str(level_nr,3), FS_BIG,FC_RED);
@@ -185,7 +185,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       if (y==3)
       {
        game_status = TYPENAME;
-       HandleTypeName(strlen(player.alias_name),0);
+       HandleTypeName(strlen(local_player->alias_name),0);
       }
       else if (y==4)
       {
@@ -678,15 +678,15 @@ void HandleHelpScreen(int button)
 
 void CheckCheat()
 {
-  int old_handicap = player.handicap;
+  int old_handicap = local_player->handicap;
 
-  if (!strcmp(player.alias_name,"Artsoft"))
-    player.handicap = leveldir[leveldir_nr].levels-1;
+  if (!strcmp(local_player->alias_name,"Artsoft"))
+    local_player->handicap = leveldir[leveldir_nr].levels-1;
 
-  if (player.handicap != old_handicap)
+  if (local_player->handicap != old_handicap)
   {
     SavePlayerInfo(PLAYER_LEVEL);
-    level_nr = player.handicap;
+    level_nr = local_player->handicap;
   }
 }
 
@@ -698,7 +698,7 @@ void HandleTypeName(int newxpos, KeySym key)
   if (newxpos)
   {
     xpos = newxpos;
-    DrawText(SX+6*32,SY+ypos*32,player.alias_name,FS_BIG,FC_YELLOW);
+    DrawText(SX+6*32, SY+ypos*32, local_player->alias_name, FS_BIG, FC_YELLOW);
     DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
     return;
   }
@@ -715,25 +715,25 @@ void HandleTypeName(int newxpos, KeySym key)
   if((ascii = get_ascii(key)) && xpos<MAX_NAMELEN-1)
   {
 #endif
-    player.alias_name[xpos] = ascii;
-    player.alias_name[xpos+1] = 0;
+    local_player->alias_name[xpos] = ascii;
+    local_player->alias_name[xpos+1] = 0;
     xpos++;
     DrawTextExt(drawto,gc,SX+6*32,SY+ypos*32,
-               player.alias_name,FS_BIG,FC_YELLOW);
+               local_player->alias_name,FS_BIG,FC_YELLOW);
     DrawTextExt(window,gc,SX+6*32,SY+ypos*32,
-               player.alias_name,FS_BIG,FC_YELLOW);
+               local_player->alias_name,FS_BIG,FC_YELLOW);
     DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
   }
   else if ((key==XK_Delete || key==XK_BackSpace) && xpos>0)
   {
     xpos--;
-    player.alias_name[xpos] = 0;
+    local_player->alias_name[xpos] = 0;
     DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
     DrawGraphic(xpos+7,ypos,GFX_LEERRAUM);
   }
   else if (key==XK_Return && xpos>0)
   {
-    DrawText(SX+6*32,SY+ypos*32,player.alias_name,FS_BIG,FC_RED);
+    DrawText(SX+6*32,SY+ypos*32,local_player->alias_name,FS_BIG,FC_RED);
     DrawGraphic(xpos+6,ypos,GFX_LEERRAUM);
     SavePlayerInfo(PLAYER_SETUP);
     CheckCheat();
@@ -822,7 +822,7 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
     }
     else
     {
-      player.leveldir_nr = leveldir_nr = y-3;
+      local_player->leveldir_nr = leveldir_nr = y-3;
       LoadPlayerInfo(PLAYER_LEVEL);
       SavePlayerInfo(PLAYER_SETUP);
       CheckCheat();
@@ -929,7 +929,7 @@ void DrawSetupScreen()
     if (i < SETUP_SCREEN_POS_EMPTY)
     {
       int setting_bit = setup[base].bit;
-      int setting_pos = ((player.setup & setting_bit) != 0 ? 0 : 1);
+      int setting_pos = ((local_player->setup & setting_bit) != 0 ? 0 : 1);
       DrawText(SX+14*32, SY+i*32,setup[base].mode[setting_pos],
               FS_BIG,setup[base].color[setting_pos]);
     }
@@ -1003,105 +1003,105 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
 
       if (y==3 && sound_status==SOUND_AVAILABLE)
       {
-       if (SETUP_SOUND_ON(player.setup))
+       if (SETUP_SOUND_ON(local_player->setup))
        {
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
          DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
          DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
-         player.setup &= ~SETUP_SOUND_LOOPS;
-         player.setup &= ~SETUP_SOUND_MUSIC;
+         local_player->setup &= ~SETUP_SOUND_LOOPS;
+         local_player->setup &= ~SETUP_SOUND_MUSIC;
        }
        else
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
-       player.setup ^= SETUP_SOUND;
+       local_player->setup ^= SETUP_SOUND;
       }
       else if (y==4 && sound_loops_allowed)
       {
-       if (SETUP_SOUND_LOOPS_ON(player.setup))
+       if (SETUP_SOUND_LOOPS_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
        else
        {
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
          DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
-         player.setup |= SETUP_SOUND;
+         local_player->setup |= SETUP_SOUND;
        }
-       player.setup ^= SETUP_SOUND_LOOPS;
+       local_player->setup ^= SETUP_SOUND_LOOPS;
       }
       else if (y==5 && sound_loops_allowed)
       {
-       if (SETUP_SOUND_MUSIC_ON(player.setup))
+       if (SETUP_SOUND_MUSIC_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
        else
        {
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
          DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
-         player.setup |= SETUP_SOUND;
+         local_player->setup |= SETUP_SOUND;
        }
-       player.setup ^= SETUP_SOUND_MUSIC;
+       local_player->setup ^= SETUP_SOUND_MUSIC;
       }
       else if (y==6)
       {
-       if (SETUP_TOONS_ON(player.setup))
+       if (SETUP_TOONS_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
        else
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
-       player.setup ^= SETUP_TOONS;
+       local_player->setup ^= SETUP_TOONS;
       }
       else if (y==7)
       {
-       if (!SETUP_DIRECT_DRAW_ON(player.setup))
+       if (!SETUP_DIRECT_DRAW_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
        else
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
-       player.setup ^= SETUP_DIRECT_DRAW;
+       local_player->setup ^= SETUP_DIRECT_DRAW;
       }
       else if (y==8)
       {
-       if (SETUP_SCROLL_DELAY_ON(player.setup))
+       if (SETUP_SCROLL_DELAY_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
        else
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
-       player.setup ^= SETUP_SCROLL_DELAY;
+       local_player->setup ^= SETUP_SCROLL_DELAY;
       }
       else if (y==9)
       {
-       if (SETUP_SOFT_SCROLL_ON(player.setup))
+       if (SETUP_SOFT_SCROLL_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
        else
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
-       player.setup ^= SETUP_SOFT_SCROLL;
+       local_player->setup ^= SETUP_SOFT_SCROLL;
       }
       else if (y==10)
       {
-       if (SETUP_FADING_ON(player.setup))
+       if (SETUP_FADING_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
        else
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
-       player.setup ^= SETUP_FADING;
+       local_player->setup ^= SETUP_FADING;
       }
       else if (y==11)
       {
-       if (SETUP_QUICK_DOORS_ON(player.setup))
+       if (SETUP_QUICK_DOORS_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
        else
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
-       player.setup ^= SETUP_QUICK_DOORS;
+       local_player->setup ^= SETUP_QUICK_DOORS;
       }
       else if (y==12)
       {
-       if (SETUP_AUTO_RECORD_ON(player.setup))
+       if (SETUP_AUTO_RECORD_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
        else
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
-       player.setup ^= SETUP_AUTO_RECORD;
+       local_player->setup ^= SETUP_AUTO_RECORD;
       }
       else if (y==13)
       {
-       if (SETUP_2ND_JOYSTICK_ON(player.setup))
+       if (SETUP_2ND_JOYSTICK_ON(local_player->setup))
          DrawText(SX+14*32, SY+yy*32,"1st",FS_BIG,FC_YELLOW);
        else
          DrawText(SX+14*32, SY+yy*32,"2nd",FS_BIG,FC_YELLOW);
-       player.setup ^= SETUP_2ND_JOYSTICK;
+       local_player->setup ^= SETUP_2ND_JOYSTICK;
       }
       else if (y==14)
       {
@@ -1256,7 +1256,7 @@ void CalibrateJoystick()
 
 #ifdef MSDOS
   joy_nr[0] = '#';
-  joy_nr[1] = SETUP_2ND_JOYSTICK_ON(player.setup)+49;
+  joy_nr[1] = SETUP_2ND_JOYSTICK_ON(local_player->setup)+49;
   joy_nr[2] = '\0';
 
   remove_joystick();
@@ -1276,7 +1276,7 @@ void CalibrateJoystick()
   BackToFront();
 
   for(clear_keybuf();!keypressed(););
-  calibrate_joystick(SETUP_2ND_JOYSTICK_ON(player.setup));
+  calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
 
   ClearWindow();
   DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
@@ -1285,7 +1285,7 @@ void CalibrateJoystick()
   BackToFront();
 
   for(clear_keybuf();!keypressed(););
-  calibrate_joystick(SETUP_2ND_JOYSTICK_ON(player.setup));
+  calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
 
   DrawSetupScreen();
   return;
@@ -1416,14 +1416,14 @@ void HandleSoundButtons(int mx, int my, int button)
       if (sound_music_on)
       { 
        sound_music_on = FALSE;
-       player.setup &= ~SETUP_SOUND_MUSIC;
+       local_player->setup &= ~SETUP_SOUND_MUSIC;
        FadeSound(background_loop[level_nr % num_bg_loops]);
        DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
       }
       else if (sound_loops_allowed)
       { 
        sound_on = sound_music_on = TRUE;
-       player.setup |= (SETUP_SOUND | SETUP_SOUND_MUSIC);
+       local_player->setup |= (SETUP_SOUND | SETUP_SOUND_MUSIC);
        PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
        DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
       }
@@ -1434,13 +1434,13 @@ void HandleSoundButtons(int mx, int my, int button)
       if (sound_loops_on)
       { 
        sound_loops_on = FALSE;
-       player.setup &= ~SETUP_SOUND_LOOPS;
+       local_player->setup &= ~SETUP_SOUND_LOOPS;
        DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
       }
       else if (sound_loops_allowed)
       { 
        sound_on = sound_loops_on = TRUE;
-       player.setup |= (SETUP_SOUND | SETUP_SOUND_LOOPS);
+       local_player->setup |= (SETUP_SOUND | SETUP_SOUND_LOOPS);
        DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
       }
       else
@@ -1450,13 +1450,13 @@ void HandleSoundButtons(int mx, int my, int button)
       if (sound_simple_on)
       { 
        sound_simple_on = FALSE;
-       player.setup &= ~SETUP_SOUND;
+       local_player->setup &= ~SETUP_SOUND;
        DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
       }
       else if (sound_status==SOUND_AVAILABLE)
       { 
        sound_on = sound_simple_on = TRUE;
-       player.setup |= SETUP_SOUND;
+       local_player->setup |= SETUP_SOUND;
        DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON);
       }
       else