This commit is contained in:
Christoph Oelckers 2013-06-23 20:06:48 +02:00
commit 0da957a605

View file

@ -824,9 +824,16 @@ void G_AddViewAngle (int yaw)
CVAR (Bool, bot_allowspy, false, 0) CVAR (Bool, bot_allowspy, false, 0)
enum {
SPY_CANCEL = 0,
SPY_NEXT,
SPY_PREV,
};
// [RH] Spy mode has been separated into two console commands. // [RH] Spy mode has been separated into two console commands.
// One goes forward; the other goes backward. // One goes forward; the other goes backward.
static void ChangeSpy (bool forward) static void ChangeSpy (int changespy)
{ {
// If you're not in a level, then you can't spy. // If you're not in a level, then you can't spy.
if (gamestate != GS_LEVEL) if (gamestate != GS_LEVEL)
@ -853,19 +860,23 @@ static void ChangeSpy (bool forward)
// Otherwise, cycle to the next player. // Otherwise, cycle to the next player.
bool checkTeam = !demoplayback && deathmatch; bool checkTeam = !demoplayback && deathmatch;
int pnum = int(players[consoleplayer].camera->player - players); int pnum = int(players[consoleplayer].camera->player - players);
int step = forward ? 1 : -1; if (changespy == SPY_CANCEL) {
pnum = consoleplayer;
} else {
int step = (changespy == SPY_NEXT) ? 1 : -1;
do do
{
pnum += step;
pnum &= MAXPLAYERS-1;
if (playeringame[pnum] &&
(!checkTeam || players[pnum].mo->IsTeammate (players[consoleplayer].mo) ||
(bot_allowspy && players[pnum].isbot)))
{ {
break; pnum += step;
} pnum &= MAXPLAYERS-1;
} while (pnum != consoleplayer); if (playeringame[pnum] &&
(!checkTeam || players[pnum].mo->IsTeammate (players[consoleplayer].mo) ||
(bot_allowspy && players[pnum].isbot)))
{
break;
}
} while (pnum != consoleplayer);
}
players[consoleplayer].camera = players[pnum].mo; players[consoleplayer].camera = players[pnum].mo;
S_UpdateSounds(players[consoleplayer].camera); S_UpdateSounds(players[consoleplayer].camera);
@ -879,15 +890,20 @@ static void ChangeSpy (bool forward)
CCMD (spynext) CCMD (spynext)
{ {
// allow spy mode changes even during the demo // allow spy mode changes even during the demo
ChangeSpy (true); ChangeSpy (SPY_NEXT);
} }
CCMD (spyprev) CCMD (spyprev)
{ {
// allow spy mode changes even during the demo // allow spy mode changes even during the demo
ChangeSpy (false); ChangeSpy (SPY_PREV);
} }
CCMD (spycancel)
{
// allow spy mode changes even during the demo
ChangeSpy (SPY_CANCEL);
}
// //
// G_Responder // G_Responder