rnd-19981026-1
[rocksndiamonds.git] / src / game.c
index 2024abb41b49e957be9fabc3f2644f01e6dcb53f..5de902ee040948e2592db7bac1a772c07bf7274e 100644 (file)
 
 void GetPlayerConfig()
 {
-  int old_joystick_nr = setup.joystick_nr;
+#if 0
+  int old_joystick_nr = setup.input[0].joystick_nr;
+#endif
+
+
+  if (sound_status == SOUND_OFF)
+    setup.sound_on = FALSE;
 
-  if (sound_status==SOUND_OFF)
-    local_player->setup &= ~SETUP_SOUND;
   if (!sound_loops_allowed)
   {
-    local_player->setup &= ~SETUP_SOUND_LOOPS;
-    local_player->setup &= ~SETUP_SOUND_MUSIC;
+    setup.sound_loops_on = FALSE;
+    setup.sound_music_on = FALSE;
   }
 
+  setup.sound_simple_on = setup.sound_on;
+
+
+#if 0
   setup.sound_on = setup.sound_simple_on = SETUP_SOUND_ON(local_player->setup);
   setup.sound_loops_on = SETUP_SOUND_LOOPS_ON(local_player->setup);
   setup.sound_music_on = SETUP_SOUND_MUSIC_ON(local_player->setup);
@@ -42,19 +50,28 @@ void GetPlayerConfig()
   setup.direct_draw_on = SETUP_DIRECT_DRAW_ON(local_player->setup);
   setup.fading_on = SETUP_FADING_ON(local_player->setup);
   setup.autorecord_on = SETUP_AUTO_RECORD_ON(local_player->setup);
+
+#if 0
   setup.joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup);
+#endif
+
+  setup.input[0].joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup);
+
   setup.quick_doors = SETUP_QUICK_DOORS_ON(local_player->setup);
   setup.scroll_delay_on = SETUP_SCROLL_DELAY_ON(local_player->setup);
   setup.soft_scrolling_on = SETUP_SOFT_SCROLL_ON(local_player->setup);
 
 #ifndef MSDOS
-  if (setup.joystick_nr != old_joystick_nr)
+  if (setup.input[0].joystick_nr != old_joystick_nr)
   {
     if (joystick_device)
       close(joystick_device);
     InitJoystick();
   }
 #endif
+
+#endif
+
 }
 
 void InitGame()
@@ -76,6 +93,8 @@ void InitGame()
     player->present = FALSE;
     player->active = FALSE;
 
+    player->action = 0;
+
     /*
     player->local = FALSE;
     */
@@ -193,7 +212,7 @@ void InitGame()
        */
 
        player->present = TRUE;
-       if (player->connected)
+       if (!network_playing || player->connected)
        {
          player->active = TRUE;
 
@@ -564,13 +583,22 @@ void GameWon()
     SaveLevelTape(tape.level_nr);      /* Ask to save tape */
   }
 
+
+  /*
   if (level_nr == local_player->handicap &&
       level_nr < leveldir[leveldir_nr].levels-1)
   { 
     local_player->handicap++; 
     bumplevel = TRUE;
+
+
+#if 0
     SavePlayerInfo(PLAYER_LEVEL);
+#endif
+
   }
+  */
+
 
   if ((hi_pos=NewHiScore()) >= 0) 
   {
@@ -2875,7 +2903,7 @@ void PlayerActions(struct PlayerInfo *player, byte player_action)
   stored_player_action[player->index_nr] = 0;
   num_stored_actions++;
 
-  if (!player->active || player->gone)
+  if (!player->active || player->gone || tape.pausing)
     return;
 
   if (player_action)
@@ -2942,7 +2970,7 @@ void PlayerActions(struct PlayerInfo *player, byte player_action)
   }
 }
 
-void GameActions(byte player_action)
+void GameActions()
 {
   static long action_delay = 0;
   long action_delay_value;
@@ -2993,13 +3021,11 @@ void GameActions(byte player_action)
   recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
 
   if (network_playing)
-    SendToServer_MovePlayer(player_action);
+    SendToServer_MovePlayer(local_player->action);
 
   for(i=0; i<MAX_PLAYERS; i++)
   {
-    int actual_player_action =
-      (network_playing ? network_player_action[i] : player_action);
-
+    int actual_player_action = stored_player[i].action;
 
     /* TEST TEST TEST */
 
@@ -3008,8 +3034,10 @@ void GameActions(byte player_action)
       actual_player_action = 0;
     */
 
+    /*
     if (!options.network && i != TestPlayer)
       actual_player_action = 0;
+    */
 
     /* TEST TEST TEST */
 
@@ -3020,7 +3048,10 @@ void GameActions(byte player_action)
     PlayerActions(&stored_player[i], actual_player_action);
     ScrollFigure(&stored_player[i], SCROLL_GO_ON);
 
-    network_player_action[i] = 0;
+    /*
+    stored_player[i].action = 0;
+    */
+
   }
 
   network_player_action_received = FALSE;
@@ -3370,9 +3401,19 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy)
     {
       if (jx != old_jx)                /* player has moved horizontally */
       {
+       /*
        if ((scroll_x < jx-MIDPOSX-offset || scroll_x > jx-MIDPOSX+offset) &&
            jx >= MIDPOSX-1-offset && jx <= lev_fieldx-(MIDPOSX-offset))
-         scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : offset);
+         scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset);
+       */
+
+       if ((player->MovDir == MV_LEFT && scroll_x > jx-MIDPOSX+offset) ||
+           (player->MovDir == MV_RIGHT && scroll_x < jx-MIDPOSX-offset))
+         scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset);
+
+       /* don't scroll over playfield boundaries */
+       if (scroll_x < -1 || scroll_x > lev_fieldx - SCR_FIELDX + 2)
+         scroll_x = (scroll_x < -1 ? -1 : lev_fieldx - SCR_FIELDX + 2);
 
        /* don't scroll more than one field at a time */
        scroll_x = old_scroll_x + SIGN(scroll_x - old_scroll_x);
@@ -3384,9 +3425,19 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy)
       }
       else                     /* player has moved vertically */
       {
+       /*
        if ((scroll_y < jy-MIDPOSY-offset || scroll_y > jy-MIDPOSY+offset) &&
            jy >= MIDPOSY-1-offset && jy <= lev_fieldy-(MIDPOSY-offset))
-         scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : offset);
+         scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset);
+       */
+
+       if ((player->MovDir == MV_UP && scroll_y > jy-MIDPOSY+offset) ||
+           (player->MovDir == MV_DOWN && scroll_y < jy-MIDPOSY-offset))
+         scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset);
+
+       /* don't scroll over playfield boundaries */
+       if (scroll_y < -1 || scroll_y > lev_fieldy - SCR_FIELDY + 2)
+         scroll_y = (scroll_y < -1 ? -1 : lev_fieldy - SCR_FIELDY + 2);
 
        /* don't scroll more than one field at a time */
        scroll_y = old_scroll_y + SIGN(scroll_y - old_scroll_y);