rnd-19981105-1
authorHolger Schemel <info@artsoft.org>
Thu, 5 Nov 1998 20:23:07 +0000 (21:23 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:31:31 +0000 (10:31 +0200)
src/events.c
src/files.c
src/game.c
src/main.h
src/network.c
src/screens.c
src/screens.h

index 2eadeee60757b0a3e7d47ef6c30e82e30dfd9e50..2a858b8d60fa79a793429648b498b74afcfaf69a 100644 (file)
@@ -407,19 +407,9 @@ void HandleKey(KeySym key, int key_status)
          key_action |= key_info[i].action;
 
       if (key_status == KEY_PRESSED)
-      {
-       if (network_playing)
-         stored_player[pnr].potential_action |= key_action;
-       else
-         stored_player[pnr].action |= key_action;
-      }
+       stored_player[pnr].action |= key_action;
       else
-      {
-       if (network_playing)
-         stored_player[pnr].potential_action &= ~key_action;
-       else
-         stored_player[pnr].action &= ~key_action;
-      }
+       stored_player[pnr].action &= ~key_action;
     }
   }
   else
@@ -890,13 +880,9 @@ static int HandleJoystickForAllPlayers()
       continue;
 
     joy_action = Joystick(i);
-
     result |= joy_action;
 
-    if (network_playing)
-      stored_player[i].potential_action = joy_action;
-    else
-      stored_player[i].action = joy_action;
+    stored_player[i].action = joy_action;
   }
 
   return result;
index 31ef77420ab43b6313fa39ce2c5f80db45fb62dd..d96e3bf23000d25d6d112ed6b6c6c6c285d57833 100644 (file)
@@ -514,26 +514,27 @@ void SaveScore(int level_nr)
 #define SETUP_TOKEN_FADING             8
 #define SETUP_TOKEN_AUTORECORD         9
 #define SETUP_TOKEN_QUICK_DOORS                10
-#define SETUP_TOKEN_ALIAS_NAME         11
-
-#define SETUP_TOKEN_USE_JOYSTICK       12
-#define SETUP_TOKEN_JOY_DEVICE_NAME    13
-#define SETUP_TOKEN_JOY_XLEFT          14
-#define SETUP_TOKEN_JOY_XMIDDLE                15
-#define SETUP_TOKEN_JOY_XRIGHT         16
-#define SETUP_TOKEN_JOY_YUPPER         17
-#define SETUP_TOKEN_JOY_YMIDDLE                18
-#define SETUP_TOKEN_JOY_YLOWER         19
-#define SETUP_TOKEN_JOY_SNAP           20
-#define SETUP_TOKEN_JOY_BOMB           21
-#define SETUP_TOKEN_KEY_LEFT           22
-#define SETUP_TOKEN_KEY_RIGHT          23
-#define SETUP_TOKEN_KEY_UP             24
-#define SETUP_TOKEN_KEY_DOWN           25
-#define SETUP_TOKEN_KEY_SNAP           26
-#define SETUP_TOKEN_KEY_BOMB           27
-
-#define NUM_SETUP_TOKENS               28
+#define SETUP_TOKEN_TEAM_MODE          11
+#define SETUP_TOKEN_ALIAS_NAME         12
+
+#define SETUP_TOKEN_USE_JOYSTICK       13
+#define SETUP_TOKEN_JOY_DEVICE_NAME    14
+#define SETUP_TOKEN_JOY_XLEFT          15
+#define SETUP_TOKEN_JOY_XMIDDLE                16
+#define SETUP_TOKEN_JOY_XRIGHT         17
+#define SETUP_TOKEN_JOY_YUPPER         18
+#define SETUP_TOKEN_JOY_YMIDDLE                19
+#define SETUP_TOKEN_JOY_YLOWER         20
+#define SETUP_TOKEN_JOY_SNAP           21
+#define SETUP_TOKEN_JOY_BOMB           22
+#define SETUP_TOKEN_KEY_LEFT           23
+#define SETUP_TOKEN_KEY_RIGHT          24
+#define SETUP_TOKEN_KEY_UP             25
+#define SETUP_TOKEN_KEY_DOWN           26
+#define SETUP_TOKEN_KEY_SNAP           27
+#define SETUP_TOKEN_KEY_BOMB           28
+
+#define NUM_SETUP_TOKENS               29
 
 #define FIRST_GLOBAL_SETUP_TOKEN       SETUP_TOKEN_SOUND
 #define LAST_GLOBAL_SETUP_TOKEN                SETUP_TOKEN_ALIAS_NAME
@@ -567,6 +568,7 @@ static struct
   { TYPE_SWITCH,  &si.fading,          "screen_fading"                 },
   { TYPE_SWITCH,  &si.autorecord,      "automatic_tape_recording"      },
   { TYPE_SWITCH,  &si.quick_doors,     "quick_doors"                   },
+  { TYPE_SWITCH,  &si.team_mode,       "team_mode"                     },
   { TYPE_STRING,  &si.alias_name,      "alias_name"                    },
 
   /* for each player: */
index 08d980b2a3efae544677aaf7596e2cdb8eab1912..c19a74da3a3a696727ecf48a25697668f828edc1 100644 (file)
@@ -59,7 +59,7 @@ void InitGame()
     player->active = FALSE;
 
     player->action = 0;
-    player->potential_action = 0;
+    player->effective_action = 0;
 
     player->score = 0;
     player->gems_still_needed = level.edelsteine;
@@ -287,6 +287,12 @@ void InitGame()
     }
   }
 
+  /* when in single player mode, eliminate all but the first active player */
+  if (!options.network && !setup.team_mode)
+    for(i=0; i<MAX_PLAYERS; i++)
+      if (stored_player[i].active)
+       for(j=i+1; j<MAX_PLAYERS; j++)
+         stored_player[j].active = FALSE;
 
   for(i=0; i<MAX_PLAYERS; i++)
   {
@@ -2810,7 +2816,7 @@ void CheckForDragon(int x, int y)
   }
 }
 
-void PlayerActions(struct PlayerInfo *player, byte player_action)
+static void PlayerActions(struct PlayerInfo *player, byte player_action)
 {
   static byte stored_player_action[MAX_PLAYERS];
   static int num_stored_actions = 0;
@@ -2915,6 +2921,7 @@ void GameActions()
   int sieb_x = 0, sieb_y = 0;
   int i, x,y, element;
   byte *recorded_player_action;
+  byte summarized_player_action;
 
   if (game_status != PLAYING)
     return;
@@ -2968,19 +2975,23 @@ void GameActions()
 
   recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
 
-  if (network_playing)
+  for(i=0; i<MAX_PLAYERS; i++)
   {
-    byte local_potential_action = 0;
-
-    for(i=0; i<MAX_PLAYERS; i++)
-      local_potential_action |= stored_player[i].potential_action;
+    summarized_player_action |= stored_player[i].action;
 
-    SendToServer_MovePlayer(local_potential_action);
+    if (!network_playing)
+      stored_player[i].effective_action = stored_player[i].action;
   }
 
+  if (network_playing)
+    SendToServer_MovePlayer(summarized_player_action);
+
+  if (!options.network && !setup.team_mode)
+    local_player->effective_action = summarized_player_action;
+
   for(i=0; i<MAX_PLAYERS; i++)
   {
-    int actual_player_action = stored_player[i].action;
+    int actual_player_action = stored_player[i].effective_action;
 
     if (recorded_player_action)
       actual_player_action = recorded_player_action[i];
@@ -3295,7 +3306,7 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy)
     /* should only happen if pre-1.0 tape recordings are played */
     /* this is only for backward compatibility */
 
-#ifdef DEBUG
+#if DEBUG
     printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.0 LEVEL TAPES.\n");
 #endif
 
index d794d2372f7cfe5e89b93d1e52e42912194dc7a8..955cf84acdac28b1f2956ceccb7b433a03fa0718 100644 (file)
@@ -258,6 +258,7 @@ struct SetupInfo
   boolean fading;
   boolean autorecord;
   boolean quick_doors;
+  boolean team_mode;
 
   char login_name[MAX_NAMELEN];
   char alias_name[MAX_NAMELEN];
@@ -280,8 +281,10 @@ struct PlayerInfo
 
   int index_nr, client_nr, element_nr;
 
-  byte action;                 /* action from server or for local playing */
-  byte potential_action;       /* must go to network server first */
+  byte action;                 /* action from local input device */
+  byte effective_action;       /* action aknowledged from network server
+                                  or summarized over all configured input
+                                  devices when in single player mode */
 
   int joystick_fd;             /* file descriptor of player's joystick */
 
index 3989065e51c59d6b4ba7660bab17b6e14523a71f..65d186918016461cc33c6b8c894f093de93fda97 100644 (file)
@@ -580,7 +580,7 @@ static void Handle_OP_MOVE_FIGURE(unsigned int len)
 
   /* copy valid player actions */
   for (i=0; i<MAX_PLAYERS; i++)
-    stored_player[i].action =
+    stored_player[i].effective_action =
       (i < len - 6 && stored_player[i].active ? buf[6 + i] : 0);
 
   network_player_action_received = TRUE;
index 292f04afcaab32c8d40033b1c30270c0196073fd..5405e49bc747abf3a4c4fea810ca4027aaf63e5e 100644 (file)
@@ -905,9 +905,9 @@ void DrawSetupScreen()
     { &setup.fading,           "Fading:"       },
     { &setup.quick_doors,      "Quick Doors:"  },
     { &setup.autorecord,       "Auto-Record:"  },
+    { &setup.team_mode,                "Team-Mode:"    },
     { NULL,                    "Input Devices" },
     { NULL,                    ""              },
-    { NULL,                    ""              },
     { NULL,                    "Exit"          },
     { NULL,                    "Save and exit" }
   };
@@ -1099,6 +1099,14 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
        setup.autorecord = !setup.autorecord;
       }
       else if (y==13)
+      {
+       if (setup.team_mode)
+         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);
+       setup.team_mode = !setup.team_mode;
+      }
+      else if (y==14)
       {
        game_status = SETUPINPUT;
        DrawSetupInputScreen();
index 5971af20c743d3cfa89f272a1ac9d0df597a2479..2d89ac5c3029b94fead9725933cb39be6a1ea373 100644 (file)
@@ -19,7 +19,7 @@
 /* for DrawSetupScreen(), HandleSetupScreen() */
 #define SETUP_SCREEN_POS_START         2
 #define SETUP_SCREEN_POS_END           16
-#define SETUP_SCREEN_POS_EMPTY1                (SETUP_SCREEN_POS_END - 3)
+#define SETUP_SCREEN_POS_EMPTY1                (SETUP_SCREEN_POS_END - 2)
 #define SETUP_SCREEN_POS_EMPTY2                (SETUP_SCREEN_POS_END - 2)
 
 #define SETUPINPUT_SCREEN_POS_START    2