rnd-19981005-1
authorHolger Schemel <info@artsoft.org>
Mon, 5 Oct 1998 20:35:41 +0000 (22:35 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:31:00 +0000 (10:31 +0200)
16 files changed:
src/buttons.c
src/buttons.h
src/editor.c
src/events.c
src/files.c
src/game.c
src/init.c
src/main.c
src/main.h
src/misc.c
src/network.c
src/network.h
src/screens.c
src/tape.c
src/tools.c
src/tools.h

index 8077b03acac3894276596da2452a47812cf88e59..282481bd68f853b28a245cc6656bd6750c305937 100644 (file)
@@ -222,7 +222,7 @@ void DrawGameButton(unsigned long state)
   redraw_mask |= REDRAW_DOOR_1;
 }
 
-void DrawChooseButton(unsigned long state)
+void DrawYesNoButton(unsigned long state)
 {
   int pos, cx = DOOR_GFX_PAGEX4, cy = 0;
 
@@ -254,6 +254,60 @@ void DrawConfirmButton(unsigned long state)
   redraw_mask |= REDRAW_DOOR_1;
 }
 
+void DrawPlayerButton(unsigned long state, int mode)
+{
+  Drawable dest_drawto;
+  int dest_xoffset, dest_yoffset;
+  int graphic;
+  int graphic_offset = (PLAYER_BUTTON_XSIZE - TILEX/2)/2;
+  int xpos, ypos;
+  int cx = DOOR_GFX_PAGEX4, cy = 0;
+
+  if (mode == DB_INIT)
+  {
+    dest_drawto = pix[PIX_DB_DOOR];
+    dest_xoffset = DOOR_GFX_PAGEX1;
+    dest_yoffset = 0;
+  }
+  else
+  {
+    dest_drawto = drawto;
+    dest_xoffset = DX;
+    dest_yoffset = DY;
+  }
+
+  if (state & BUTTON_PLAYER_1)
+    graphic = GFX_SPIELER1;
+  else if (state & BUTTON_PLAYER_2)
+    graphic = GFX_SPIELER2;
+  else if (state & BUTTON_PLAYER_3)
+    graphic = GFX_SPIELER3;
+  else if (state & BUTTON_PLAYER_4)
+    graphic = GFX_SPIELER4;
+
+  xpos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_3 ?
+         PLAYER_BUTTON_1_XPOS : PLAYER_BUTTON_2_XPOS);
+  ypos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_2 ?
+         PLAYER_BUTTON_1_YPOS : PLAYER_BUTTON_3_YPOS);
+
+  if (state & BUTTON_PRESSED)
+  {
+    cx = DOOR_GFX_PAGEX3;
+    graphic_offset += 1;
+  }
+
+  XCopyArea(display,pix[PIX_DOOR],dest_drawto,gc,
+           cx + PLAYER_BUTTON_GFX_XPOS, cy + PLAYER_BUTTON_GFX_YPOS,
+           PLAYER_BUTTON_XSIZE, PLAYER_BUTTON_YSIZE,
+           dest_xoffset + xpos, dest_yoffset + ypos);
+  DrawMiniGraphicExt(dest_drawto,gc,
+                    dest_xoffset + xpos + graphic_offset,
+                    dest_yoffset + ypos + graphic_offset,
+                    graphic);
+
+  redraw_mask |= REDRAW_DOOR_1;
+}
+
 /* several buttons in the level editor */
 
 void DrawEditButton(unsigned long state)
@@ -621,12 +675,12 @@ int CheckGameButtons(int mx, int my, int button)
   return(return_code);
 }
 
-int CheckChooseButtons(int mx, int my, int button)
+int CheckYesNoButtons(int mx, int my, int button)
 {
   int return_code = 0;
   static int choice = -1;
   static BOOL pressed = FALSE;
-  static int choose_button[5] =
+  static int yesno_button[5] =
   {
     BUTTON_OK,
     BUTTON_NO
@@ -636,33 +690,33 @@ int CheckChooseButtons(int mx, int my, int button)
   {
     if (!motion_status)                /* Maustaste neu gedrückt */
     {
-      if (ON_CHOOSE_BUTTON(mx,my))
+      if (ON_YESNO_BUTTON(mx,my))
       {
-       choice = CHOOSE_BUTTON(mx);
+       choice = YESNO_BUTTON(mx);
        pressed = TRUE;
-       DrawChooseButton(choose_button[choice] | BUTTON_PRESSED);
+       DrawYesNoButton(yesno_button[choice] | BUTTON_PRESSED);
       }
     }
     else                       /* Mausbewegung bei gedrückter Maustaste */
     {
-      if ((!ON_CHOOSE_BUTTON(mx,my) || CHOOSE_BUTTON(mx)!=choice) &&
+      if ((!ON_YESNO_BUTTON(mx,my) || YESNO_BUTTON(mx)!=choice) &&
          choice>=0 && pressed)
       {
        pressed = FALSE;
-       DrawChooseButton(choose_button[choice] | BUTTON_RELEASED);
+       DrawYesNoButton(yesno_button[choice] | BUTTON_RELEASED);
       }
-      else if (ON_CHOOSE_BUTTON(mx,my) &&CHOOSE_BUTTON(mx)==choice && !pressed)
+      else if (ON_YESNO_BUTTON(mx,my) && YESNO_BUTTON(mx)==choice && !pressed)
       {
        pressed = TRUE;
-       DrawChooseButton(choose_button[choice] | BUTTON_PRESSED);
+       DrawYesNoButton(yesno_button[choice] | BUTTON_PRESSED);
       }
     }
   }
   else                         /* Maustaste wieder losgelassen */
   {
-    if (ON_CHOOSE_BUTTON(mx,my) && CHOOSE_BUTTON(mx)==choice && pressed)
+    if (ON_YESNO_BUTTON(mx,my) && YESNO_BUTTON(mx)==choice && pressed)
     {
-      DrawChooseButton(choose_button[choice] | BUTTON_RELEASED);
+      DrawYesNoButton(yesno_button[choice] | BUTTON_RELEASED);
       return_code = choice+1;
       choice = -1;
       pressed = FALSE;
@@ -729,6 +783,65 @@ int CheckConfirmButton(int mx, int my, int button)
   return(return_code);
 }
 
+int CheckPlayerButtons(int mx, int my, int button)
+{
+  int return_code = 0;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+  int player_state[4] =
+  {
+    BUTTON_PLAYER_1,
+    BUTTON_PLAYER_2,
+    BUTTON_PLAYER_3,
+    BUTTON_PLAYER_4
+  };
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_PLAYER_BUTTON(mx,my))
+      {
+       choice = PLAYER_BUTTON(mx,my);
+       pressed = TRUE;
+       DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if ((!ON_PLAYER_BUTTON(mx,my) || PLAYER_BUTTON(mx,my)!=choice) &&
+         choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
+      }
+      else if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && !pressed)
+      {
+       pressed = TRUE;
+       DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && pressed)
+    {
+      DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
+      return_code = player_state[choice];
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
+
 /* several buttons in the level editor */
 
 int CheckEditButtons(int mx, int my, int button)
index 397aa6f9be2283ae6737c90f95a06f79e1654fd7..9ed110c895c1558ee0668d754d71482d5991803e 100644 (file)
 #define SOUND_BUTTON_YSIZE     30
 #define SOUND_CONTROL_XPOS     5
 #define SOUND_CONTROL_YPOS     245
-#define SOUND_CONTROL_XSIZE    90
-#define SOUND_CONTROL_YSIZE     (SOUND_BUTTON_YSIZE)
+#define SOUND_CONTROL_XSIZE     (3*SOUND_BUTTON_XSIZE)
+#define SOUND_CONTROL_YSIZE     (1*SOUND_BUTTON_YSIZE)
 #define SOUND_BUTTON_MUSIC_XPOS         (SOUND_CONTROL_XPOS + 0 * SOUND_BUTTON_XSIZE)
 #define SOUND_BUTTON_LOOPS_XPOS         (SOUND_CONTROL_XPOS + 1 * SOUND_BUTTON_XSIZE)
 #define SOUND_BUTTON_SIMPLE_XPOS (SOUND_CONTROL_XPOS + 2 * SOUND_BUTTON_XSIZE)
 #define GAME_BUTTON_YSIZE      30
 #define GAME_CONTROL_XPOS      5
 #define GAME_CONTROL_YPOS      215
-#define GAME_CONTROL_XSIZE     90
-#define GAME_CONTROL_YSIZE     (GAME_BUTTON_YSIZE)
+#define GAME_CONTROL_XSIZE     (3*GAME_BUTTON_XSIZE)
+#define GAME_CONTROL_YSIZE     (1*GAME_BUTTON_YSIZE)
 #define GAME_BUTTON_STOP_XPOS  (GAME_CONTROL_XPOS + 0 * GAME_BUTTON_XSIZE)
 #define GAME_BUTTON_PAUSE_XPOS (GAME_CONTROL_XPOS + 1 * GAME_BUTTON_XSIZE)
 #define GAME_BUTTON_PLAY_XPOS  (GAME_CONTROL_XPOS + 2 * GAME_BUTTON_XSIZE)
 #define BUTTON_GAME_PAUSE      (1L<<1)
 #define BUTTON_GAME_PLAY       (1L<<2)
 
-
 /* some positions in the asking window */
 #define OK_BUTTON_XPOS         2
 #define OK_BUTTON_YPOS         250
 #define CONFIRM_BUTTON_XSIZE   96
 #define CONFIRM_BUTTON_YSIZE   OK_BUTTON_YSIZE
 
-#define ON_CHOOSE_BUTTON(x,y)  (((x)>=(DX+OK_BUTTON_XPOS) &&           \
+#define ON_YESNO_BUTTON(x,y)   (((x)>=(DX+OK_BUTTON_XPOS) &&           \
                                  (x)< (DX+OK_BUTTON_XPOS +             \
                                        OK_BUTTON_XSIZE) &&             \
                                  (y)>=(DY+OK_BUTTON_YPOS) &&           \
                                  (y)>=(DY+CONFIRM_BUTTON_YPOS) &&      \
                                  (y)< (DY+CONFIRM_BUTTON_YPOS +        \
                                        CONFIRM_BUTTON_YSIZE)))
-#define CHOOSE_BUTTON(x)       (((x)-(DX+OK_BUTTON_XPOS))/OK_BUTTON_XSIZE)
+#define YESNO_BUTTON(x)                (((x)-(DX+OK_BUTTON_XPOS))/OK_BUTTON_XSIZE)
 
 /* values for asking control */
 #define BUTTON_OK              (1L<<0)
 #define BUTTON_NO              (1L<<1)
 #define BUTTON_CONFIRM         (1L<<2)
 
+/* some positions in the choose player window */
+
+#define PLAYER_BUTTON_XSIZE    30
+#define PLAYER_BUTTON_YSIZE    30
+#define PLAYER_BUTTON_GFX_XPOS 5
+#define PLAYER_BUTTON_GFX_YPOS (215-30)
+#define PLAYER_CONTROL_XPOS    (5 + PLAYER_BUTTON_XSIZE/2)
+#define PLAYER_CONTROL_YPOS    (215 - PLAYER_BUTTON_YSIZE/2)
+#define PLAYER_CONTROL_XSIZE   (2*PLAYER_BUTTON_XSIZE)
+#define PLAYER_CONTROL_YSIZE   (2*PLAYER_BUTTON_YSIZE)
+#define PLAYER_BUTTON_1_XPOS   (PLAYER_CONTROL_XPOS + 0 * PLAYER_BUTTON_XSIZE)
+#define PLAYER_BUTTON_2_XPOS   (PLAYER_CONTROL_XPOS + 1 * PLAYER_BUTTON_XSIZE)
+#define PLAYER_BUTTON_3_XPOS   (PLAYER_CONTROL_XPOS + 0 * PLAYER_BUTTON_XSIZE)
+#define PLAYER_BUTTON_4_XPOS   (PLAYER_CONTROL_XPOS + 1 * PLAYER_BUTTON_XSIZE)
+#define PLAYER_BUTTON_1_YPOS   (PLAYER_CONTROL_YPOS + 0 * PLAYER_BUTTON_YSIZE)
+#define PLAYER_BUTTON_2_YPOS   (PLAYER_CONTROL_YPOS + 0 * PLAYER_BUTTON_YSIZE)
+#define PLAYER_BUTTON_3_YPOS   (PLAYER_CONTROL_YPOS + 1 * PLAYER_BUTTON_YSIZE)
+#define PLAYER_BUTTON_4_YPOS   (PLAYER_CONTROL_YPOS + 1 * PLAYER_BUTTON_YSIZE)
+
+#define ON_PLAYER_BUTTON(x,y)  ((x)>=(DX+PLAYER_CONTROL_XPOS) &&       \
+                                (x)< (DX+PLAYER_CONTROL_XPOS +         \
+                                      PLAYER_CONTROL_XSIZE) &&         \
+                                (y)>=(DY+PLAYER_CONTROL_YPOS) &&       \
+                                (y)< (DY+PLAYER_CONTROL_YPOS +         \
+                                      PLAYER_CONTROL_YSIZE))
+#define PLAYER_BUTTON(x,y)     ((((x)-(DX+PLAYER_CONTROL_XPOS)) /      \
+                                 PLAYER_BUTTON_XSIZE) + 2 *            \
+                                (((y)-(DY+PLAYER_CONTROL_YPOS)) /      \
+                                 PLAYER_BUTTON_YSIZE))
+
+/* values for choose player control */
+#define BUTTON_PLAYER_1                (1L<<10)
+#define BUTTON_PLAYER_2                (1L<<11)
+#define BUTTON_PLAYER_3                (1L<<12)
+#define BUTTON_PLAYER_4                (1L<<13)
+
 
 /* some positions in the editor control window */
 #define ED_BUTTON_EUP_XPOS     35
 #define ED_BUTTON_ELEM         2
 
 
+/* for DrawPlayerButton() */
+
+#define DB_INIT                        0
+#define DB_NORMAL              1
+
 void DrawVideoDisplay(unsigned long, unsigned long);
 void DrawCompleteVideoDisplay(void);
 void DrawSoundDisplay(unsigned long);
 void DrawGameButton(unsigned long);
-void DrawChooseButton(unsigned long);
+void DrawYesNoButton(unsigned long);
 void DrawConfirmButton(unsigned long);
+void DrawPlayerButton(unsigned long, int);
 void DrawEditButton(unsigned long state);
 void DrawCtrlButton(unsigned long state);
 void DrawElemButton(int, int);
@@ -510,8 +551,9 @@ void DrawCountButton(int, int);
 int CheckVideoButtons(int, int, int);
 int CheckSoundButtons(int, int, int);
 int CheckGameButtons(int, int, int);
-int CheckChooseButtons(int, int, int);
+int CheckYesNoButtons(int, int, int);
 int CheckConfirmButton(int, int, int);
+int CheckPlayerButtons(int, int, int);
 int CheckEditButtons(int, int, int);
 int CheckCtrlButtons(int, int, int);
 int CheckElemButtons(int, int, int);
index fc81ebe09a6bee9e175a28daa927ee138172ebc5..85ae127e3f95d4f66f0b6741af5558edebb1759e 100644 (file)
@@ -745,7 +745,7 @@ void LevelEd(int mx, int my, int button)
          edit_mode = FALSE;
          break;
        case ED_BUTTON_FILL:
-         AreYouSure("Caution ! Flood fill mode ! Choose area !",AYS_OPEN);
+         Request("Caution ! Flood fill mode ! Choose area !",REQ_OPEN);
          use_floodfill = TRUE;
          return;
          break;
@@ -1010,7 +1010,7 @@ void LevelEd(int mx, int my, int button)
          edit_mode = TRUE;
          break;
        case ED_BUTTON_CLEAR:
-         if (AreYouSure("Are you sure to clear this level ?",AYS_ASK))
+         if (Request("Are you sure to clear this level ?",REQ_ASK))
          {
            for(x=0;x<MAX_LEV_FIELDX;x++) 
              for(y=0;y<MAX_LEV_FIELDY;y++) 
@@ -1020,7 +1020,7 @@ void LevelEd(int mx, int my, int button)
          break;
        case ED_BUTTON_UNDO:
          if (leveldir[leveldir_nr].readonly ||
-             AreYouSure("Exit without saving ?",AYS_ASK | AYS_STAY_OPEN))
+             Request("Exit without saving ?",REQ_ASK | REQ_STAY_OPEN))
          {
            CloseDoor(DOOR_CLOSE_BOTH);
            game_status=MAINMENU;
@@ -1038,7 +1038,7 @@ void LevelEd(int mx, int my, int button)
 
            if (leveldir[leveldir_nr].readonly)
            {
-             AreYouSure("This level is read only !",AYS_CONFIRM);
+             Request("This level is read only !",REQ_CONFIRM);
              break;
            }
 
@@ -1048,12 +1048,12 @@ void LevelEd(int mx, int my, int button)
                  figur_vorhanden = TRUE;
 
            if (!figur_vorhanden)
-             AreYouSure("No Level without Gregor Mc Duffin please !",
-                        AYS_CONFIRM);
+             Request("No Level without Gregor Mc Duffin please !",
+                        REQ_CONFIRM);
            else
            {
-             if (AreYouSure("Save this level and kill the old ?",
-                            AYS_ASK | AYS_STAY_OPEN))
+             if (Request("Save this level and kill the old ?",
+                            REQ_ASK | REQ_STAY_OPEN))
              {
                for(x=0;x<lev_fieldx;x++)
                  for(y=0;y<lev_fieldy;y++) 
index e77b7510ea1c02ec2b30d74378ac34dc0cfc21ea..71d03604c22eb6081e1632232d3ffb852a5c9e41 100644 (file)
@@ -788,6 +788,11 @@ void HandleJoystick()
       if (tape.pausing || AllPlayersGone)
        joy = 0;
 
+      /*
+      if (!network_player_action_stored)
+       SendToServer_MovePlayer(joy, 0);
+      */
+
       HandleGameActions((byte)joy);
       break;
 
index 41fe210b7a46289d679e57324e9cd36ff1e2c186..d34fe40da717af4a1ab00e4a1b927d58f4a255c7 100644 (file)
@@ -267,10 +267,10 @@ void LoadLevelTape(int level_nr)
     {
       if (levelrec_10 && j>0)
       {
-       tape.pos[i].joystickdata[j] = MV_NO_MOVING;
+       tape.pos[i].action[j] = MV_NO_MOVING;
        continue;
       }
-      tape.pos[i].joystickdata[j] = fgetc(file);
+      tape.pos[i].action[j] = fgetc(file);
     }
 
     tape.pos[i].delay = fgetc(file);
@@ -533,7 +533,7 @@ void SaveLevelTape(int level_nr)
     new_tape = FALSE;
     fclose(file);
 
-    if (!AreYouSure("Replace old tape ?",AYS_ASK))
+    if (!Request("Replace old tape ?",REQ_ASK))
       return;
   }
 
@@ -566,7 +566,7 @@ void SaveLevelTape(int level_nr)
     int j;
 
     for(j=0; j<MAX_PLAYERS; j++)
-      fputc(tape.pos[i].joystickdata[j],file);
+      fputc(tape.pos[i].action[j],file);
 
     fputc(tape.pos[i].delay,file);
   }
@@ -578,7 +578,7 @@ void SaveLevelTape(int level_nr)
   tape.changed = FALSE;
 
   if (new_tape)
-    AreYouSure("tape saved !",AYS_CONFIRM);
+    Request("tape saved !",REQ_CONFIRM);
 }
 
 void SaveScore(int level_nr)
index b96fa7addac29c8901251469c1216ddda9f8111e..c8519b390c7500c97d1d3b6507c04b63bd55e94d 100644 (file)
@@ -67,7 +67,8 @@ void InitGame()
   {
     struct PlayerInfo *player = &stored_player[i];
 
-    player->nr = i;
+    player->index_nr = i;
+    player->element_nr = EL_SPIELER1 + i;
     player->active = FALSE;
     player->local = FALSE;
 
@@ -128,6 +129,21 @@ void InitGame()
   local_player->active = TRUE;
   local_player->local = TRUE;
 
+  network_player_action_stored = FALSE;
+
+
+
+  /* initial null action */
+  SendToServer_MovePlayer(0,0);
+
+
+
+  /*
+  printf("BLURB\n");
+  */
+
+
+
   ZX = ZY = -1;
 
   MampferNr = 0;
@@ -2780,7 +2796,7 @@ void PlayerActions(struct PlayerInfo *player, byte player_action)
   int dx       = (left ? -1    : right ? 1     : 0);
   int dy       = (up   ? -1    : down  ? 1     : 0);
 
-  stored_player_action[player->nr] = 0;
+  stored_player_action[player->index_nr] = 0;
   num_stored_actions++;
 
   if (!player->active || player->gone)
@@ -2804,7 +2820,7 @@ void PlayerActions(struct PlayerInfo *player, byte player_action)
       if (bombed && !moved)
        player_action &= JOY_BUTTON;
 
-      stored_player_action[player->nr] = player_action;
+      stored_player_action[player->index_nr] = player_action;
 
       /* this allows cycled sequences of PlayerActions() */
       if (num_stored_actions >= MAX_PLAYERS)
@@ -2828,7 +2844,7 @@ void PlayerActions(struct PlayerInfo *player, byte player_action)
       tape.counter < tape.length)
   {
     int next_joy =
-      tape.pos[tape.counter].joystickdata[player->nr] & (JOY_LEFT|JOY_RIGHT);
+      tape.pos[tape.counter].action[player->index_nr] & (JOY_LEFT|JOY_RIGHT);
 
     if (next_joy == JOY_LEFT || next_joy == JOY_RIGHT)
     {
@@ -2858,9 +2874,11 @@ void GameActions(byte player_action)
   int i, x,y, element;
   int *recorded_player_action;
 
+
   if (game_status != PLAYING)
     return;
 
+
 #ifdef DEBUG
   action_delay_value =
     (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GameFrameDelay);
@@ -2869,23 +2887,60 @@ void GameActions(byte player_action)
     (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GAME_FRAME_DELAY);
 #endif
 
+  /*
+  HandleNetworking();
+
+  if (game_status != PLAYING)
+    return;
+  */
+
   /* main game synchronization point */
   WaitUntilDelayReached(&action_delay, action_delay_value);
 
+  if (!network_player_action_stored)
+  {
+#ifdef DEBUG
+    printf("DEBUG: try to get network player actions in time\n");
+#endif
+
+    /* last chance to get network player actions without main loop delay */
+    HandleNetworking();
+
+    if (game_status != PLAYING)
+      return;
+
+    if (!network_player_action_stored)
+    {
+#ifdef DEBUG
+      printf("DEBUG: failed to get network player actions in time\n");
+#endif
+      return;
+    }
+  }
+
   if (tape.playing)
     recorded_player_action = TapePlayAction();
   else
     recorded_player_action = NULL;
 
-  SendToServer_MovePlayer(player_action);
+
+  SendToServer_MovePlayer(player_action, FrameCounter);
+
 
   for(i=0; i<MAX_PLAYERS; i++)
   {
+    int actual_player_action = network_player_action[i];
+
+    /*
     int actual_player_action = player_action;
+    */
+
     /* TEST TEST TEST */
 
+    /*
     if (i != TestPlayer && !stored_player[i].MovPos)
       actual_player_action = 0;
+    */
 
     /* TEST TEST TEST */
 
@@ -2894,8 +2949,12 @@ void GameActions(byte player_action)
 
     PlayerActions(&stored_player[i], actual_player_action);
     ScrollFigure(&stored_player[i], SCROLL_GO_ON);
+
+    network_player_action[i] = 0;
   }
 
+  network_player_action_stored = FALSE;
+
   ScrollScreen(NULL, SCROLL_GO_ON);
 
   if (tape.pausing || (tape.playing && !TapePlayDelay()))
@@ -2906,6 +2965,11 @@ void GameActions(byte player_action)
   FrameCounter++;
   TimeFrames++;
 
+  /*
+  printf("advancing FrameCounter to %d\n",
+        FrameCounter);
+  */
+
   for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
   {
     Stop[x][y] = FALSE;
@@ -3143,7 +3207,7 @@ BOOL MoveFigureOneStep(struct PlayerInfo *player,
   if (!IN_LEV_FIELD(new_jx,new_jy))
     return(MF_NO_ACTION);
 
-  if (!networking && !AllPlayersInSight(player, new_jx,new_jy))
+  if (standalone && !AllPlayersInSight(player, new_jx,new_jy))
     return(MF_NO_ACTION);
 
   element = MovingOrBlocked2Element(new_jx,new_jy);
@@ -3174,7 +3238,7 @@ BOOL MoveFigureOneStep(struct PlayerInfo *player,
   player->last_jy = jy;
   jx = player->jx = new_jx;
   jy = player->jy = new_jy;
-  StorePlayer[jx][jy] = EL_SPIELER1 + player->nr;
+  StorePlayer[jx][jy] = player->element_nr;
 
   player->MovPos = (dx > 0 || dy > 0 ? -1 : 1) * 7*TILEX/8;
 
@@ -3215,11 +3279,19 @@ BOOL MoveFigure(struct PlayerInfo *player, int dx, int dy)
   if (moved & MF_MOVING && player == local_player)
   */
 
-  if (moved & MF_MOVING && !ScreenMovPos)
+  if (moved & MF_MOVING && !ScreenMovPos &&
+      (player == local_player || standalone))
   {
     int old_scroll_x = scroll_x, old_scroll_y = scroll_y;
     int offset = (scroll_delay_on ? 3 : 0);
 
+    /*
+    if (player == local_player)
+    {
+      printf("MOVING LOCAL PLAYER && SCROLLING\n");
+    }
+    */
+
     if (!IN_VIS_FIELD(SCREENX(jx),SCREENY(jy)))
     {
       /* actual player has left the screen -- scroll in that direction */
@@ -3278,22 +3350,15 @@ BOOL MoveFigure(struct PlayerInfo *player, int dx, int dy)
 
     if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
     {
-      if (networking || AllPlayersInVisibleScreen())
+      if (standalone && !AllPlayersInVisibleScreen())
       {
-       ScrollScreen(player, SCROLL_INIT);
-
-       /*
-       ScreenMovDir = player->MovDir;
-       ScreenMovPos = player->MovPos;
-       ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize);
-       */
-
-       ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y);
+       scroll_x = old_scroll_x;
+       scroll_y = old_scroll_y;
       }
       else
       {
-       scroll_x = old_scroll_x;
-       scroll_y = old_scroll_y;
+       ScrollScreen(player, SCROLL_INIT);
+       ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y);
       }
     }
   }
@@ -3338,10 +3403,6 @@ void ScrollFigure(struct PlayerInfo *player, int mode)
     player->actual_frame_counter = FrameCounter;
     player->GfxPos = ScrollStepSize * (player->MovPos / ScrollStepSize);
 
-    /*
-    ScreenGfxPos = local_player->GfxPos;
-    */
-
     if (Feld[last_jx][last_jy] == EL_LEERRAUM)
       Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING;
 
@@ -3354,22 +3415,6 @@ void ScrollFigure(struct PlayerInfo *player, int mode)
   player->MovPos += (player->MovPos > 0 ? -1 : 1) * TILEX/8;
   player->GfxPos = ScrollStepSize * (player->MovPos / ScrollStepSize);
 
-  /*
-  if (ScreenMovPos)
-  {
-    ScreenMovPos += (ScreenMovPos > 0 ? -1 : 1) * TILEX/8;
-    ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize);
-  }
-  */
-
-  /*
-  if (ScreenGfxPos && ScreenGfxPos != local_player->GfxPos)
-  {
-    ScreenGfxPos = local_player->GfxPos;
-    redraw_mask |= REDRAW_FIELD;
-  }
-  */
-
   if (Feld[last_jx][last_jy] == EL_PLAYER_IS_LEAVING)
     Feld[last_jx][last_jy] = EL_LEERRAUM;
 
@@ -3407,12 +3452,6 @@ void ScrollScreen(struct PlayerInfo *player, int mode)
 
   if (ScreenMovPos)
   {
-    /*
-    printf("ScreenMovDir = %d, ", ScreenMovDir);
-    printf("ScreenMovPos = %d, ", ScreenMovPos);
-    printf("ScreenGfxPos = %d\n", ScreenGfxPos);
-    */
-
     ScreenMovPos += (ScreenMovPos > 0 ? -1 : 1) * TILEX/8;
     ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize);
     redraw_mask |= REDRAW_FIELD;
@@ -3986,7 +4025,7 @@ BOOL PlaceBomb(struct PlayerInfo *player)
   else
   {
     Feld[jx][jy] = EL_DYNABOMB;
-    Store2[jx][jy] = EL_SPIELER1 + player->nr; /* for DynaExplode() */
+    Store2[jx][jy] = player->element_nr;       /* for DynaExplode() */
     MovDelay[jx][jy] = 96;
     player->dynabombs_left--;
     DrawGraphicThruMask(SCREENX(jx),SCREENY(jy),GFX_DYNABOMB);
index 88050961f227a372b6fcfdd17d5fc1d509e901a4..0a0c7580c460bd184622b944a91fb6e14d09b052 100644 (file)
@@ -44,11 +44,11 @@ struct IconFileInfo
 
 static int sound_process_id = 0;
 
-static void InitServer(void);
 static void InitLevelAndPlayerInfo(void);
+static void InitNetworkServer(void);
 static void InitDisplay(void);
 static void InitSound(void);
-static void InitSoundProcess(void);
+static void InitSoundServer(void);
 static void InitWindow(int, char **);
 static void InitGfx(void);
 static void LoadGfx(int, struct PictureFileInfo *);
@@ -57,11 +57,10 @@ static void InitElementProperties(void);
 void OpenAll(int argc, char *argv[])
 {
   InitLevelAndPlayerInfo();
-  InitServer();
 
   InitCounter();
   InitSound();
-  InitSoundProcess();
+  InitSoundServer();
   InitJoystick();
   InitRND(NEW_RANDOMIZE);
 
@@ -78,6 +77,8 @@ void OpenAll(int argc, char *argv[])
   InitElementProperties();
 
   DrawMainMenu();
+
+  InitNetworkServer();
 }
 
 void InitLevelAndPlayerInfo()
@@ -91,19 +92,25 @@ void InitLevelAndPlayerInfo()
   LoadPlayerInfo(PLAYER_LEVEL);                /* level specific info */
 }
 
-void InitServer()
+void InitNetworkServer()
 {
+  int nr_wanted;
+
   standalone = FALSE;
-  networking = !standalone;
 
   if (standalone)
     return;
 
+  nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
+
   if (!ConnectToServer(server_host, server_port))
     Error(ERR_EXIT, "cannot connect to multiplayer server");
 
   SendToServer_Nickname(local_player->alias_name);
   SendToServer_ProtocolVersion();
+
+  if (nr_wanted)
+    SendToServer_NrWanted(nr_wanted);
 }
 
 void InitSound()
@@ -154,7 +161,7 @@ void InitSound()
   }
 }
 
-void InitSoundProcess()
+void InitSoundServer()
 {
   if (sound_status==SOUND_OFF)
     return;
index 03d7e66e01c3d048b45b02d5463c6324f1486507..61039723459de7e82fd6f203e5a0a1c49c03957e 100644 (file)
@@ -50,7 +50,6 @@ char         *program_name = NULL;
 char          *display_name = NULL;
 char          *server_host = NULL;
 int            server_port = 0;
-int            networking = FALSE;
 int            standalone = TRUE;
 int            verbose = FALSE;
 
@@ -106,6 +105,8 @@ int         AllPlayersGone;
 int            FrameCounter, TimeFrames, TimeLeft;
 int            MampferNr, SiebAktiv;
 
+byte           network_player_action[MAX_PLAYERS];
+BOOL           network_player_action_stored = FALSE;
 int            TestPlayer = 0;
 
 struct LevelDirInfo    leveldir[MAX_LEVDIR_ENTRIES];
index dc5da4ffe71166dc8ca237d9129581dd3328ad87..354b23eca1c7bf2938e42c844bda537ad5a8a5bc 100644 (file)
@@ -144,12 +144,7 @@ typedef unsigned char byte;
 #define IS_PUSHABLE(e)         (Elementeigenschaften[e] & EP_BIT_PUSHABLE)
 #define ELEM_IS_PLAYER(e)      (Elementeigenschaften[e] & EP_BIT_PLAYER)
 
-/*
-#define IS_PLAYER(x,y)         (JX == (x) && JY == (y))
-*/
-
 #define IS_PLAYER(x,y)         (ELEM_IS_PLAYER(StorePlayer[x][y]))
-#define IS_LOCAL_PLAYER(x,y)   (StorePlayer[x][y] == EL_SPIELER1)
 
 #define IS_FREE(x,y)           (Feld[x][y] == EL_LEERRAUM && !IS_PLAYER(x,y))
 #define IS_FREE_OR_PLAYER(x,y) (Feld[x][y] == EL_LEERRAUM)
@@ -214,7 +209,8 @@ struct HiScore
 
 struct PlayerInfo
 {
-  int nr, active, local;
+  int active, local;
+  int index_nr, client_nr, element_nr;
 
   char login_name[MAX_NAMELEN];
   char alias_name[MAX_NAMELEN];
@@ -289,7 +285,7 @@ struct RecordingInfo
   BOOL changed;
   struct
   {
-    byte joystickdata[MAX_PLAYERS];
+    byte action[MAX_PLAYERS];
     byte delay;
   } pos[MAX_TAPELEN];
 };
@@ -327,7 +323,6 @@ extern char        *program_name;
 extern char           *display_name;
 extern char           *server_host;
 extern int             server_port;
-extern int             networking;
 extern int             standalone;
 extern int             verbose;
 
@@ -381,6 +376,8 @@ extern int          AllPlayersGone;
 extern int             FrameCounter, TimeFrames, TimeLeft;
 extern int             MampferNr, SiebAktiv;
 
+extern byte            network_player_action[];
+extern BOOL            network_player_action_stored;
 extern int             TestPlayer;
 
 extern struct LevelDirInfo     leveldir[];
index 8d36c27a186cc2e59c027580ffa742212cd8b73e..e412be85952f6febbb39cba65c5311b400dfc850 100644 (file)
@@ -233,6 +233,7 @@ void GetOptions(char *argv[])
             "Options:\n"
             "  -d, --display machine:0       X server display\n"
             "  -l, --levels directory        alternative level directory\n"
+            "  -n, --network                 network multiplayer game\n"
             "  -v, --verbose                 verbose mode\n",
             program_name);
       exit(0);
index 14ea8656fbc75a882e95ae6e21f771f9379b6ae9..17ca60d1c637b2540a276d69b35a09d602a83242 100644 (file)
@@ -29,6 +29,7 @@
 #include "game.h"
 #include "tape.h"
 #include "files.h"
+#include "tools.h"
 #include "misc.h"
 
 int norestart = 0;
@@ -43,7 +44,7 @@ int nospeedup = 0;
 #define OP_NICK 1
 #define OP_PLAY 2
 #define OP_MOVE 3
-#define OP_DRAW 4
+#define OP_NRWANTED 4
 #define OP_LOST 5
 #define OP_GONE 6
 #define OP_CLEAR 7
@@ -98,8 +99,11 @@ void copydown(char *s, char *t, int n)
 
 void sysmsg(char *s)
 {
-  printf("** %s\n", s);
-  fflush(stdout);
+  if (verbose)
+  {
+    printf("** %s\n", s);
+    fflush(stdout);
+  }
 }
 
 void fatal(char *s)
@@ -183,8 +187,8 @@ void startserver()
   int n = 0;
 
   options[0] = options[1] = NULL;
-  if (norestart)
-    options[n++] = "-norestart";
+  if (verbose)
+    options[n++] = "-v";
   if (nospeedup)
     options[n++] = "-nospeedup";
 
@@ -197,7 +201,7 @@ void startserver()
 #else
       "rnd_server",
 #endif
-      "rnd_server", "-once", "-v", options[0], options[1], NULL);
+      "rnd_server", "-once", options[0], options[1], NULL);
 
       fprintf(stderr, "Can't start server '%s'.\n",
 #ifdef XTRISPATH
@@ -295,22 +299,50 @@ void SendToServer_ProtocolVersion()
   sendbuf(5);
 }
 
+void SendToServer_NrWanted(int nr_wanted)
+{
+  buf[1] = OP_NRWANTED;
+  buf[2] = nr_wanted;
+  sendbuf(3);
+}
+
 void SendToServer_StartPlaying()
 {
   buf[1] = OP_PLAY;
-  buf[2] = (unsigned char)(level_nr / 256);
-  buf[3] = (unsigned char)(level_nr % 256);
-  buf[4] = (unsigned char)(leveldir_nr / 256);
-  buf[5] = (unsigned char)(leveldir_nr % 256);
+  buf[2] = (byte)(level_nr >> 8);
+  buf[3] = (byte)(level_nr & 0xff);
+  buf[4] = (byte)(leveldir_nr >> 8);
+  buf[5] = (byte)(leveldir_nr & 0xff);
   strcpy(&buf[6], leveldir[leveldir_nr].name);
   sendbuf(strlen(leveldir[leveldir_nr].name)+1 + 6);
 }
 
-void SendToServer_MovePlayer(byte player_action)
+void SendToServer_MovePlayer(byte player_action, unsigned long frame_nr)
 {
   buf[1] = OP_MOVE;
   buf[2] = player_action;
+
   sendbuf(3);
+
+  /*
+  buf[3] = (byte)((frame_nr >> 24) & 0xff);
+  buf[4] = (byte)((frame_nr >> 16) & 0xff);
+  buf[5] = (byte)((frame_nr >>  8) & 0xff);
+  buf[6] = (byte)((frame_nr >>  0) & 0xff);
+
+  sendbuf(7);
+  */
+
+  /*
+  printf("%d: %x, %x, %x, %x\n", frame_nr, buf[3], buf[4], buf[5], buf[6]);
+  */
+
+
+
+  flushbuf();
+
+
+
 }
 
 void handlemessages()
@@ -332,12 +364,65 @@ void handlemessages()
     switch(buf[1])
     {
       case OP_YOUARE:
+      {
+       int new_client_nr = buf[2];
+       int new_index_nr = new_client_nr - 1;
+
        printf("OP_YOUARE: %d\n", buf[0]);
-       me.nr = buf[0];
+       me.nr = new_client_nr;
+
+       stored_player[new_index_nr] = *local_player;
+       local_player = &stored_player[new_index_nr];
+
+       TestPlayer = new_index_nr;
+
+       if (me.nr > MAX_PLAYERS)
+         Error(ERR_EXIT, "sorry - no more than %d players", MAX_PLAYERS);
+
+       sprintf(msgbuf, "you get client # %d", new_client_nr);
+       sysmsg(msgbuf);
+
+       break;
+      }
+
+      case OP_NRWANTED:
+      {
+       int client_nr_wanted = buf[2];
+       int new_client_nr = buf[3];
+       int new_index_nr = new_client_nr - 1;
 
-       TestPlayer = buf[0] - 1;
+       printf("OP_NRWANTED: %d\n", buf[0]);
+
+       if (new_client_nr != client_nr_wanted)
+       {
+         char *color[] = { "yellow", "red", "green", "blue" };
+
+         sprintf(msgbuf, "Sorry ! You are %s player !",
+                 color[new_index_nr]);
+         Request(msgbuf, REQ_CONFIRM);
+
+         sprintf(msgbuf, "cannot switch -- you keep client # %d",
+                 new_client_nr);
+         sysmsg(msgbuf);
+       }
+       else
+       {
+         if (me.nr != client_nr_wanted)
+           sprintf(msgbuf, "switching to client # %d", new_client_nr);
+         else
+           sprintf(msgbuf, "keeping client # %d", new_client_nr);
+         sysmsg(msgbuf);
+
+         me.nr = new_client_nr;
+
+         stored_player[new_index_nr] = *local_player;
+         local_player = &stored_player[new_index_nr];
+
+         TestPlayer = new_index_nr;
+       }
 
        break;
+      }
 
       case OP_NEW:
        printf("OP_NEW: %d\n", buf[0]);
@@ -428,13 +513,41 @@ void handlemessages()
        break;
 
       case OP_MOVE:
-       if (buf[2])
+      {
+       int frame_nr;
+       int i;
+
+       frame_nr =
+         (buf[2] << 24) | (buf[3] << 16) | (buf[4] << 8) | (buf[5]);
+
+       for (i=0; i<MAX_PLAYERS; i++)
        {
-         printf("OP_MOVE: %d\n", buf[0]);
-         sprintf(msgbuf, "client %d moves player [0x%02x]", buf[0], buf[2]);
-         sysmsg(msgbuf);
+         if (stored_player[i].active)
+           network_player_action[i] = buf[6 + i];
        }
+
+       network_player_action_stored = TRUE;
+
+       /*
+       printf("FrameCounter == %d, frame_nr = %d\n",
+              FrameCounter, frame_nr);
+       */
+
+       /*
+       if (buf[2])
+       */
+
+
+       /*
+       printf("OP_MOVE: %d\n", buf[0]);
+       */
+
+       sprintf(msgbuf, "frame %d: client %d moves player [0x%02x]",
+               FrameCounter, buf[0], buf[2]);
+       sysmsg(msgbuf);
+
        break;
+      }
 
       case OP_PAUSE:
        printf("OP_PAUSE: %d\n", buf[0]);
index 5465cae174965c18a3a1fdba576a3dd2cc949ff2..893f4c5a769ed9178ee79dd8fd1048feeae067f6 100644 (file)
@@ -19,8 +19,9 @@
 BOOL ConnectToServer(char *, int);
 void SendToServer_Nickname(char *);
 void SendToServer_ProtocolVersion(void);
+void SendToServer_NrWanted(int);
 void SendToServer_StartPlaying(void);
-void SendToServer_MovePlayer(byte);
+void SendToServer_MovePlayer(byte, unsigned long);
 void HandleNetworking(void);
 
 #endif
index baa76948c4270dab4bc47824ec5bf1953f8e4fce..cc78f0d8c52714197f368159db3fd0d58bc52775 100644 (file)
@@ -205,7 +205,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       {
        game_status = LEVELED;
        if (leveldir[leveldir_nr].readonly)
-         AreYouSure("This level is read only !",AYS_CONFIRM);
+         Request("This level is read only !",REQ_CONFIRM);
        DrawLevelEd();
       }
       else if (y==7)
@@ -234,7 +234,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       else if (y==10)
       {
        SavePlayerInfo(PLAYER_LEVEL);
-        if (AreYouSure("Do you really want to quit ?",AYS_ASK|AYS_STAY_CLOSED))
+        if (Request("Do you really want to quit ?",REQ_ASK|REQ_STAY_CLOSED))
          game_status = EXITGAME;
       }
 
@@ -1333,7 +1333,7 @@ void HandleVideoButtons(int mx, int my, int button)
       {
        LoadLevelTape(level_nr);
        if (TAPE_IS_EMPTY(tape))
-         AreYouSure("No tape for this level !",AYS_CONFIRM);
+         Request("No tape for this level !",REQ_CONFIRM);
       }
       else
       {
@@ -1490,8 +1490,8 @@ void HandleGameButtons(int mx, int my, int button)
        break;
       }
 
-      if (AreYouSure("Do you really want to quit the game ?",
-                     AYS_ASK | AYS_STAY_CLOSED))
+      if (Request("Do you really want to quit the game ?",
+                 REQ_ASK | REQ_STAY_CLOSED))
       { 
        game_status = MAINMENU;
        DrawMainMenu();
index 6d6a8d5ce7cd998f5be47c9c9c92ec233da356c3..267dd58dcee849948b96a9f58df68c2a960ba17e 100644 (file)
@@ -48,7 +48,7 @@ void TapeStopRecording()
     return;
 
   for(i=0; i<MAX_PLAYERS; i++)
-    tape.pos[tape.counter].joystickdata[i] = 0;
+    tape.pos[tape.counter].action[i] = 0;
 
   tape.counter++;
   tape.length = tape.counter;
@@ -72,7 +72,7 @@ void TapeRecordAction(byte joy[MAX_PLAYERS])
   }
 
   for(i=0; i<MAX_PLAYERS; i++)
-    tape.pos[tape.counter].joystickdata[i] = joy[i];
+    tape.pos[tape.counter].action[i] = joy[i];
 
   tape.counter++;
   tape.pos[tape.counter].delay = 0;
@@ -96,7 +96,7 @@ void TapeRecordDelay()
   if (tape.pos[tape.counter].delay >= 255)
   {
     for(i=0; i<MAX_PLAYERS; i++)
-      tape.pos[tape.counter].joystickdata[i] = 0;
+      tape.pos[tape.counter].action[i] = 0;
 
     tape.counter++;
     tape.pos[tape.counter].delay = 0;
@@ -168,7 +168,7 @@ int *TapePlayAction()
     tape.counter++;
 
     for(i=0; i<MAX_PLAYERS; i++)
-      joy[i] = tape.pos[tape.counter-1].joystickdata[i];
+      joy[i] = tape.pos[tape.counter-1].action[i];
 
     return(joy);
   }
index a705df5603bf498f82f15aa2c42246bd067a1eef..f987d323a2f550c0b778f3eda9e4fd1ec268daa9 100644 (file)
@@ -356,11 +356,17 @@ void DrawPlayer(struct PlayerInfo *player)
   int element = Feld[jx][jy];
   int graphic, phase;
 
+  /*
   if (!player->active || player->gone || !IN_SCR_FIELD(sx,sy))
     return;
+  */
+
+  if (!player->active || player->gone ||
+      !IN_SCR_FIELD(SCREENX(last_jx),SCREENY(last_jy)))
+    return;
 
 #if DEBUG
-  if (!IN_LEV_FIELD(jx,jy) || !IN_SCR_FIELD(sx,sy))
+  if (!IN_LEV_FIELD(jx,jy))
   {
     printf("DrawPlayerField(): x = %d, y = %d\n",jx,jy);
     printf("DrawPlayerField(): sx = %d, sy = %d\n",sx,sy);
@@ -372,9 +378,6 @@ void DrawPlayer(struct PlayerInfo *player)
   if (element == EL_EXPLODING)
     return;
 
-  if (direct_draw_on)
-    SetDrawtoField(DRAW_BUFFERED);
-
   /* draw things in the field the player is leaving, if needed */
 
   if (last_jx != jx || last_jy != jy)
@@ -389,7 +392,7 @@ void DrawPlayer(struct PlayerInfo *player)
     else
       DrawLevelField(last_jx,last_jy);
 
-    if (player->Pushing)
+    if (player->Pushing && IN_SCR_FIELD(SCREENX(next_jx),SCREENY(next_jy)))
     {
       if (player->GfxPos)
       {
@@ -403,6 +406,12 @@ void DrawPlayer(struct PlayerInfo *player)
     }
   }
 
+  if (!IN_SCR_FIELD(sx,sy))
+    return;
+
+  if (direct_draw_on)
+    SetDrawtoField(DRAW_BUFFERED);
+
   /* draw things behind the player, if needed */
 
   if (Store[jx][jy])
@@ -421,7 +430,7 @@ void DrawPlayer(struct PlayerInfo *player)
   else /* MV_DOWN || MV_NO_MOVING */
     graphic = GFX_SPIELER1_DOWN;
 
-  graphic += player->nr * 3*HEROES_PER_LINE;
+  graphic += player->index_nr * 3*HEROES_PER_LINE;
   graphic += player->Frame;
 
   if (player->GfxPos)
@@ -555,7 +564,6 @@ void DrawGraphicAnimationThruMask(int x, int y, int graphic,
 
 void DrawGraphic(int x, int y, int graphic)
 {
-
 #if DEBUG
   if (!IN_SCR_FIELD(x,y))
   {
@@ -602,11 +610,6 @@ void DrawGraphicExt(Drawable d, GC gc, int x, int y, int graphic)
 
 void DrawGraphicThruMask(int x, int y, int graphic)
 {
-  int src_x,src_y, dest_x,dest_y;
-  int tile = graphic;
-  Pixmap src_pixmap;
-  GC drawing_gc;
-
 #if DEBUG
   if (!IN_SCR_FIELD(x,y))
   {
@@ -616,6 +619,17 @@ void DrawGraphicThruMask(int x, int y, int graphic)
   }
 #endif
 
+  DrawGraphicThruMaskExt(drawto_field, FX+x*TILEX, FY+y*TILEY, graphic);
+  MarkTileDirty(x,y);
+}
+
+void DrawGraphicThruMaskExt(Drawable d, int dest_x, int dest_y, int graphic)
+{
+  int src_x, src_y;
+  int tile = graphic;
+  Pixmap src_pixmap;
+  GC drawing_gc;
+
   if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
   {
     src_pixmap = pix[PIX_BACK];
@@ -634,13 +648,10 @@ void DrawGraphicThruMask(int x, int y, int graphic)
   }
   else
   {
-    DrawGraphic(x,y,graphic);
+    DrawGraphicExt(d, gc, dest_x,dest_y, graphic);
     return;
   }
 
-  dest_x = FX + x*TILEX;
-  dest_y = FY + y*TILEY;
-
   if (tile_clipmask[tile] != None)
   {
     XSetClipMask(display, tile_clip_gc, tile_clipmask[tile]);
@@ -658,8 +669,6 @@ void DrawGraphicThruMask(int x, int y, int graphic)
     XCopyArea(display, src_pixmap, drawto_field, drawing_gc,
              src_x,src_y, TILEX,TILEY, dest_x,dest_y);
   }
-
-  MarkTileDirty(x,y);
 }
 
 void DrawMiniGraphic(int x, int y, int graphic)
@@ -1281,7 +1290,7 @@ void DrawMicroLevel(int xpos, int ypos)
   redraw_mask |= REDRAW_MICROLEV;
 }
 
-int AYS_in_range(int x, int y)
+int REQ_in_range(int x, int y)
 {
   if (y>DY+249 && y<DY+278)
   {
@@ -1293,7 +1302,7 @@ int AYS_in_range(int x, int y)
   return(0);
 }
 
-BOOL AreYouSure(char *text, unsigned int ays_state)
+BOOL Request(char *text, unsigned int req_state)
 {
   int mx,my, ty, result = -1;
   unsigned int old_door_state;
@@ -1337,21 +1346,53 @@ BOOL AreYouSure(char *text, unsigned int ays_state)
     text+=(tl+(tc==32));
   }
 
-  if (ays_state & AYS_ASK)
+  if (req_state & REQ_ASK)
     XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
              DOOR_GFX_PAGEX4,OK_BUTTON_GFX_YPOS,
              DXSIZE,OK_BUTTON_YSIZE,
              DOOR_GFX_PAGEX1,OK_BUTTON_YPOS);
-  else if (ays_state & AYS_CONFIRM)
+  else if (req_state & REQ_CONFIRM)
     XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
              DOOR_GFX_PAGEX4,CONFIRM_BUTTON_GFX_YPOS,
              DXSIZE,CONFIRM_BUTTON_YSIZE,
              DOOR_GFX_PAGEX1,CONFIRM_BUTTON_YPOS);
+  else if (req_state & REQ_PLAYER)
+  {
+    DrawPlayerButton(BUTTON_PLAYER_1, DB_INIT);
+    DrawPlayerButton(BUTTON_PLAYER_2, DB_INIT);
+    DrawPlayerButton(BUTTON_PLAYER_3, DB_INIT);
+    DrawPlayerButton(BUTTON_PLAYER_4, DB_INIT);
+
+    /*
+    XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
+             DOOR_GFX_PAGEX4 + PLAYER_BUTTON_GFX_XPOS, PLAYER_BUTTON_GFX_YPOS,
+             PLAYER_BUTTON_XSIZE,PLAYER_BUTTON_YSIZE,
+             DOOR_GFX_PAGEX1 + PLAYER_BUTTON_1_XPOS, PLAYER_BUTTON_1_YPOS);
+    XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
+             DOOR_GFX_PAGEX4 + PLAYER_BUTTON_GFX_XPOS, PLAYER_BUTTON_GFX_YPOS,
+             PLAYER_BUTTON_XSIZE,PLAYER_BUTTON_YSIZE,
+             DOOR_GFX_PAGEX1 + PLAYER_BUTTON_1_XPOS, PLAYER_BUTTON_1_YPOS);
+    XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
+             DOOR_GFX_PAGEX4 + PLAYER_BUTTON_GFX_XPOS, PLAYER_BUTTON_GFX_YPOS,
+             PLAYER_BUTTON_XSIZE,PLAYER_BUTTON_YSIZE,
+             DOOR_GFX_PAGEX1 + PLAYER_BUTTON_2_XPOS, PLAYER_BUTTON_2_YPOS);
+    XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
+             DOOR_GFX_PAGEX4 + PLAYER_BUTTON_GFX_XPOS, PLAYER_BUTTON_GFX_YPOS,
+             PLAYER_BUTTON_XSIZE,PLAYER_BUTTON_YSIZE,
+             DOOR_GFX_PAGEX1 + PLAYER_BUTTON_3_XPOS, PLAYER_BUTTON_3_YPOS);
+    XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
+             DOOR_GFX_PAGEX4 + PLAYER_BUTTON_GFX_XPOS, PLAYER_BUTTON_GFX_YPOS,
+             PLAYER_BUTTON_XSIZE,PLAYER_BUTTON_YSIZE,
+             DOOR_GFX_PAGEX1 + PLAYER_BUTTON_4_XPOS, PLAYER_BUTTON_4_YPOS);
+    */
+  }
 
   OpenDoor(DOOR_OPEN_1);
   ClearEventQueue();
 
-  if (!(ays_state & AYS_ASK) && !(ays_state & AYS_CONFIRM))
+  if (!(req_state & REQ_ASK) &&
+      !(req_state & REQ_CONFIRM) &&
+      !(req_state & REQ_PLAYER))
     return(FALSE);
 
   if (game_status != MAINMENU)
@@ -1400,10 +1441,12 @@ BOOL AreYouSure(char *text, unsigned int ays_state)
              button_status = MB_RELEASED;
          }
 
-         if (ays_state & AYS_ASK)
-           choice = CheckChooseButtons(mx,my,button_status);
-         else
+         if (req_state & REQ_ASK)
+           choice = CheckYesNoButtons(mx,my,button_status);
+         else if (req_state & REQ_CONFIRM)
            choice = CheckConfirmButton(mx,my,button_status);
+         else
+           choice = CheckPlayerButtons(mx,my,button_status);
 
          switch(choice)
          {
@@ -1414,7 +1457,19 @@ BOOL AreYouSure(char *text, unsigned int ays_state)
              result = FALSE;
              break;
            case BUTTON_CONFIRM:
-             result = TRUE|FALSE;
+             result = TRUE | FALSE;
+             break;
+           case BUTTON_PLAYER_1:
+             result = 1;
+             break;
+           case BUTTON_PLAYER_2:
+             result = 2;
+             break;
+           case BUTTON_PLAYER_3:
+             result = 3;
+             break;
+           case BUTTON_PLAYER_4:
+             result = 4;
              break;
            default:
              break;
@@ -1432,6 +1487,8 @@ BOOL AreYouSure(char *text, unsigned int ays_state)
              result = 0;
              break;
          }
+         if (req_state & REQ_PLAYER)
+           result = 0;
          break;
        case KeyRelease:
          key_joystick_mapping = 0;
@@ -1461,11 +1518,11 @@ BOOL AreYouSure(char *text, unsigned int ays_state)
   if (game_status != MAINMENU)
     StopAnimation();
 
-  if (!(ays_state & AYS_STAY_OPEN))
+  if (!(req_state & REQ_STAY_OPEN))
   {
     CloseDoor(DOOR_CLOSE_1);
 
-    if (!(ays_state & AYS_STAY_CLOSED) && (old_door_state & DOOR_OPEN_1))
+    if (!(req_state & REQ_STAY_CLOSED) && (old_door_state & DOOR_OPEN_1))
     {
       XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc,
                DOOR_GFX_PAGEX2,DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
index d4679614534bff0bb6964bb39d87036d894e6a8b..4c7544df2fb191c619d31a8b2b30a7d8caee1901 100644 (file)
 #define USE_MASKING    1
  
 /* for MoveDoor */
-#define DOOR_OPEN_1    1
-#define DOOR_OPEN_2    2
-#define DOOR_CLOSE_1   4
-#define DOOR_CLOSE_2   8
+#define DOOR_OPEN_1    (1 << 0)
+#define DOOR_OPEN_2    (1 << 1)
+#define DOOR_CLOSE_1   (1 << 2)
+#define DOOR_CLOSE_2   (1 << 3)
 #define DOOR_OPEN_BOTH (DOOR_OPEN_1 | DOOR_OPEN_2)
 #define DOOR_CLOSE_BOTH        (DOOR_CLOSE_1 | DOOR_CLOSE_2)
 #define DOOR_ACTION_1  (DOOR_OPEN_1 | DOOR_CLOSE_1)
 #define DOOR_ACTION_2  (DOOR_OPEN_2 | DOOR_CLOSE_2)
 #define DOOR_ACTION    (DOOR_ACTION_1 | DOOR_ACTION_2)
-#define DOOR_COPY_BACK 16
-#define DOOR_NO_DELAY  32
-#define DOOR_GET_STATE 64
+#define DOOR_COPY_BACK (1 << 4)
+#define DOOR_NO_DELAY  (1 << 5)
+#define DOOR_GET_STATE (1 << 6)
 
-/* for AreYouSure */
-#define AYS_ASK                1
-#define AYS_OPEN       2
-#define AYS_CLOSE      4
-#define AYS_CONFIRM    8
-#define AYS_STAY_CLOSED        16
-#define AYS_STAY_OPEN  32
+/* for Request */
+#define REQ_ASK                (1 << 0)
+#define REQ_OPEN       (1 << 1)
+#define REQ_CLOSE      (1 << 2)
+#define REQ_CONFIRM    (1 << 3)
+#define REQ_STAY_CLOSED        (1 << 4)
+#define REQ_STAY_OPEN  (1 << 5)
+#define REQ_PLAYER     (1 << 6)
 
 void SetDrawtoField(int);
 void BackToFront();
@@ -70,6 +71,7 @@ void DrawGraphicAnimationThruMask(int, int, int, int, int, int);
 void DrawGraphic(int, int, int);
 void DrawGraphicExt(Drawable, GC, int, int, int);
 void DrawGraphicThruMask(int, int, int);
+void DrawGraphicThruMaskExt(Drawable, int, int, int);
 void DrawMiniGraphic(int, int, int);
 void DrawMiniGraphicExt(Drawable, GC, int, int, int);
 void DrawGraphicShifted(int, int, int, int, int, int, int);
@@ -92,7 +94,7 @@ void DrawMicroElement(int, int, int);
 void DrawLevel(void);
 void DrawMiniLevel(int, int);
 void DrawMicroLevel(int, int);
-BOOL AreYouSure(char *, unsigned int);
+BOOL Request(char *, unsigned int);
 unsigned int OpenDoor(unsigned int);
 unsigned int CloseDoor(unsigned int);
 unsigned int GetDoorState(void);