rnd-19981013-1
authorHolger Schemel <info@artsoft.org>
Tue, 13 Oct 1998 08:03:48 +0000 (10:03 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:31:07 +0000 (10:31 +0200)
src/editor.c
src/events.c
src/game.c
src/init.c
src/main.c
src/main.h
src/misc.c
src/network.c
src/screens.c
src/tape.c
src/tools.c

index 85ae127e3f95d4f66f0b6741af5558edebb1759e..6ec17e91ef08e8cfd5ebbc684f8c601686cf8b1c 100644 (file)
@@ -610,24 +610,25 @@ void FloodFill(int from_x, int from_y, int fill_element)
   static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
   static int safety = 0;
 
+  /* check if starting field still has the desired content */
+  if (Feld[from_x][from_y] == fill_element)
+    return;
+
   safety++;
 
-  if (safety>lev_fieldx*lev_fieldy)
-  {
-    fprintf(stderr,"Something went wrong in 'FloodFill()'. Please debug.\n");
-    exit(-1);
-  }
+  if (safety > lev_fieldx*lev_fieldy)
+    Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
 
   old_element = Feld[from_x][from_y];
   Feld[from_x][from_y] = fill_element;
 
   for(i=0;i<4;i++)
   {
-    x = from_x+check[i][0];
-    y = from_y+check[i][1];
+    x = from_x + check[i][0];
+    y = from_y + check[i][1];
 
-    if (IN_LEV_FIELD(x,y) && Feld[x][y]==old_element)
-      FloodFill(x,y,fill_element);
+    if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
+      FloodFill(x, y, fill_element);
   }
 
   safety--;
index 92bdeef6c4b2f5c04e576cc439a18e0f501d96f9..088650b17f2242a38244c4ccd944c74ebd6f46d3 100644 (file)
@@ -726,7 +726,8 @@ void HandleNoXEvent()
     return;
   }
 
-  HandleNetworking();
+  if (network)
+    HandleNetworking();
 
   switch(game_status)
   {
index f6e226bc7fcde6e693b7dc065d7596489b456564..354c823b22a05c935f3a2b4ac15436424d275286 100644 (file)
@@ -134,7 +134,8 @@ void InitGame()
 
 
   /* initial null action */
-  SendToServer_MovePlayer(MV_NO_MOVING);
+  if (network)
+    SendToServer_MovePlayer(MV_NO_MOVING);
 
 
 
@@ -2888,7 +2889,7 @@ void GameActions(byte player_action)
   /* main game synchronization point */
   WaitUntilDelayReached(&action_delay, action_delay_value);
 
-  if (!standalone && !network_player_action_received)
+  if (network && !network_player_action_received)
   {
     /*
 #ifdef DEBUG
@@ -2925,13 +2926,13 @@ void GameActions(byte player_action)
   else
     recorded_player_action = NULL;
 
-  if (!standalone)
+  if (network)
     SendToServer_MovePlayer(player_action);
 
   for(i=0; i<MAX_PLAYERS; i++)
   {
     int actual_player_action =
-      (standalone ? player_action : network_player_action[i]);
+      (network ? network_player_action[i] : player_action);
 
     /*
     int actual_player_action = network_player_action[i];
@@ -2948,7 +2949,7 @@ void GameActions(byte player_action)
       actual_player_action = 0;
     */
 
-    if (standalone && i != TestPlayer)
+    if (!network && i != TestPlayer)
       actual_player_action = 0;
 
     /* TEST TEST TEST */
@@ -3219,7 +3220,7 @@ BOOL MoveFigureOneStep(struct PlayerInfo *player,
   if (!IN_LEV_FIELD(new_jx,new_jy))
     return(MF_NO_ACTION);
 
-  if (standalone && !AllPlayersInSight(player, new_jx,new_jy))
+  if (!network && !AllPlayersInSight(player, new_jx,new_jy))
     return(MF_NO_ACTION);
 
   element = MovingOrBlocked2Element(new_jx,new_jy);
@@ -3292,7 +3293,7 @@ BOOL MoveFigure(struct PlayerInfo *player, int dx, int dy)
   */
 
   if (moved & MF_MOVING && !ScreenMovPos &&
-      (player == local_player || standalone))
+      (player == local_player || !network))
   {
     int old_scroll_x = scroll_x, old_scroll_y = scroll_y;
     int offset = (scroll_delay_on ? 3 : 0);
@@ -3362,7 +3363,7 @@ BOOL MoveFigure(struct PlayerInfo *player, int dx, int dy)
 
     if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
     {
-      if (standalone && !AllPlayersInVisibleScreen())
+      if (!network && !AllPlayersInVisibleScreen())
       {
        scroll_x = old_scroll_x;
        scroll_y = old_scroll_y;
index 5fecebf52592c8f0cccacc5e86f209965b2d2cda..6931936ee00a902d1aa55ba437dfa8dba5d5fa95 100644 (file)
@@ -105,7 +105,7 @@ void InitNetworkServer()
 {
   int nr_wanted;
 
-  if (standalone)
+  if (!network)
     return;
 
   nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
index cf042880bc0f621904d27137f2c3df53c14924a6..4db664635bc6d5c312c25f494f8138f657f2e003 100644 (file)
@@ -51,7 +51,7 @@ char         *display_name = NULL;
 char          *server_host = NULL;
 int            server_port = 0;
 int            serveronly = FALSE;
-int            standalone = TRUE;
+int            network = FALSE;
 int            verbose = FALSE;
 
 int            game_status = MAINMENU;
index 98d59381c2a914c37888675301cdc14cbb24e36d..794256e271d76cc517f6aaac0f48553596bf436f 100644 (file)
@@ -324,7 +324,7 @@ extern char        *display_name;
 extern char           *server_host;
 extern int             server_port;
 extern int             serveronly;
-extern int             standalone;
+extern int             network;
 extern int             verbose;
 
 extern int             game_status;
index 1ca457c90d8c68abafdced7011cc1cba291efd23..56b651cbc38f3d9cf6c9a2abe4e0f5098006d9bd 100644 (file)
@@ -265,7 +265,7 @@ void GetOptions(char *argv[])
     {
       printf("--network\n");
 
-      standalone = FALSE;
+      network = TRUE;
     }
     else if (strncmp(option, "-serveronly", option_len) == 0)
     {
index db7fc95f980d13811ac05718e16a5eff50959ffd..d92a09093dc30b904ab0707cc327723e2fd29fea 100644 (file)
@@ -98,7 +98,7 @@ static void flushbuf()
 
 static void sendbuf(int len)
 {
-  if (!standalone)
+  if (network)
   {
     realbuf[0] = realbuf[1] = realbuf[2] = 0;
     realbuf[3] = (unsigned char)len;
@@ -156,7 +156,7 @@ static void StartNetworkServer(int port)
     case -1:
       Error(ERR_RETURN,
            "cannot create network server process - no network games");
-      standalone = TRUE;
+      network = FALSE;
       return;
 
     default:
@@ -640,9 +640,6 @@ void HandleNetworking()
   fd_set rfds;
   int r = 0;
 
-  if (standalone)
-    return;
-
   flushbuf();
 
   FD_ZERO(&rfds);
index dbed745e212b8df13a59dbe62c74f6bfaef990c8..f689f1a00baa32f7bcdadc342a753751f2a72d05 100644 (file)
@@ -218,13 +218,13 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
        if (autorecord_on)
          TapeStartRecording();
 
-       if (standalone)
+       if (network)
+         SendToServer_StartPlaying();
+       else
        {
          game_status = PLAYING;
          InitGame();
        }
-       else
-         SendToServer_StartPlaying();
       }
       else if (y==9)
       {
@@ -1345,24 +1345,27 @@ void HandleVideoButtons(int mx, int my, int button)
       }
       DrawCompleteVideoDisplay();
       break;
+
     case BUTTON_VIDEO_STOP:
       TapeStop();
       break;
+
     case BUTTON_VIDEO_PAUSE:
       TapeTogglePause();
       break;
+
     case BUTTON_VIDEO_REC:
       if (TAPE_IS_STOPPED(tape))
       {
        TapeStartRecording();
 
-       if (standalone)
+       if (network)
+         SendToServer_StartPlaying();
+       else
        {
          game_status = PLAYING;
          InitGame();
        }
-       else
-         SendToServer_StartPlaying();
       }
       else if (tape.pausing)
       {
@@ -1379,6 +1382,7 @@ void HandleVideoButtons(int mx, int my, int button)
          TapeTogglePause();
       }
       break;
+
     case BUTTON_VIDEO_PLAY:
       if (TAPE_IS_EMPTY(tape))
        break;
@@ -1387,13 +1391,8 @@ void HandleVideoButtons(int mx, int my, int button)
       {
        TapeStartPlaying();
 
-       if (standalone)
-       {
-         game_status = PLAYING;
-         InitGame();
-       }
-       else
-         SendToServer_StartPlaying();
+       game_status = PLAYING;
+       InitGame();
       }
       else if (tape.playing)
       {
@@ -1417,6 +1416,7 @@ void HandleVideoButtons(int mx, int my, int button)
        }
       }
       break;
+
     default:
       break;
   }
@@ -1449,6 +1449,7 @@ void HandleSoundButtons(int mx, int my, int button)
       else
        DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
       break;
+
     case BUTTON_SOUND_LOOPS:
       if (sound_loops_on)
       { 
@@ -1465,6 +1466,7 @@ void HandleSoundButtons(int mx, int my, int button)
       else
        DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
       break;
+
     case BUTTON_SOUND_SIMPLE:
       if (sound_simple_on)
       { 
@@ -1481,6 +1483,7 @@ void HandleSoundButtons(int mx, int my, int button)
       else
        DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
       break;
+
     default:
       break;
   }
@@ -1507,51 +1510,67 @@ void HandleGameButtons(int mx, int my, int button)
       if (Request("Do you really want to quit the game ?",
                  REQ_ASK | REQ_STAY_CLOSED))
       { 
-       if (standalone)
+       if (network)
+         SendToServer_StopPlaying();
+       else
        {
          game_status = MAINMENU;
          DrawMainMenu();
        }
-       else
-         SendToServer_StopPlaying();
       }
       else
        OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
       break;
+
     case BUTTON_GAME_PAUSE:
+      if (network)
+      {
+       if (tape.pausing)
+         SendToServer_ContinuePlaying();
+       else
+         SendToServer_PausePlaying();
+      }
+      else
+       TapeTogglePause();
+
+      /*
       if (tape.pausing)
       {
-       if (standalone)
+       if (network)
+         SendToServer_ContinuePlaying();
+       else
        {
          tape.pausing = FALSE;
          DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
        }
-       else
-         SendToServer_ContinuePlaying();
       }
       else
       {
-       if (standalone)
+       if (network)
+         SendToServer_PausePlaying();
+       else
        {
          tape.pausing = TRUE;
          DrawVideoDisplay(VIDEO_STATE_PAUSE_ON,0);
        }
-       else
-         SendToServer_PausePlaying();
       }
+      */
+
       break;
+
     case BUTTON_GAME_PLAY:
       if (tape.pausing)
       {
-       if (standalone)
+       if (network)
+         SendToServer_ContinuePlaying();
+       else
        {
          tape.pausing = FALSE;
          DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
        }
-       else
-         SendToServer_ContinuePlaying();
       }
       break;
+
     default:
       break;
   }
index 267dd58dcee849948b96a9f58df68c2a960ba17e..61a5d7e8a950fb481cfb8db0e7cbe3d45bafb6b4 100644 (file)
@@ -242,5 +242,5 @@ unsigned int GetTapeLength()
   for(i=0;i<tape.length;i++)
     tape_length += tape.pos[i].delay;
 
-  return(tape_length * GAME_FRAME_DELAY / 100);
+  return(tape_length * GAME_FRAME_DELAY / 1000);
 }
index aefd540aceac4e01b33b34b0b05261a4c36ed93e..7efa122be50395c7bc392b5b28c426b8bd406400 100644 (file)
@@ -1309,7 +1309,7 @@ BOOL Request(char *text, unsigned int req_state)
   unsigned int old_door_state;
 
   /* pause network game while waiting for request to answer */
-  if (!standalone && game_status == PLAYING && req_state & REQUEST_WAIT_FOR)
+  if (network && game_status == PLAYING && req_state & REQUEST_WAIT_FOR)
     SendToServer_PausePlaying();
 
   old_door_state = GetDoorState();
@@ -1535,7 +1535,7 @@ BOOL Request(char *text, unsigned int req_state)
   }
 
   /* continue network game after request */
-  if (!standalone && game_status == PLAYING && req_state & REQUEST_WAIT_FOR)
+  if (network && game_status == PLAYING && req_state & REQUEST_WAIT_FOR)
     SendToServer_ContinuePlaying();
 
   return(result);