Do not round player numbers in range

(fickle's suggestion.)
This commit is contained in:
james 2019-02-04 20:16:54 -08:00
parent e52641d15a
commit 8f47b55d29

View file

@ -1892,34 +1892,6 @@ static void Command_ResetCamera_f(void)
P_ResetCamera(&players[displayplayer], &camera); P_ResetCamera(&players[displayplayer], &camera);
} }
static INT32
RoundToValidPlayerNum (INT32 playernum)
{
INT32 playernuml, playernumr;
for (playernuml = playernum; --playernuml > 0; )
{
if (playeringame[playernuml])
break;
}
for (playernumr = playernum ;; )
{
if (++playernumr == MAXPLAYERS)
{
playernum = playernuml;
break;
}
if (playeringame[playernumr])
{
if (playernum - playernuml < playernumr - playernum)
playernum = playernuml;/* "round" down */
else
playernum = playernumr;
break;
}
}
return playernum;
}
static INT32/* Consider replacing nametonum with this */ static INT32/* Consider replacing nametonum with this */
LookupPlayer (const char *s) LookupPlayer (const char *s)
{ {
@ -1945,7 +1917,7 @@ LookupPlayer (const char *s)
return playernum; return playernum;
} }
} }
return -1;/* We can't "round" a name! */ return -1;
} }
#define PRINTVIEWPOINT( pre,suf ) \ #define PRINTVIEWPOINT( pre,suf ) \
@ -1957,7 +1929,7 @@ Command_View_f (void)
INT32 *displayplayerp; INT32 *displayplayerp;
INT32 olddisplayplayer; INT32 olddisplayplayer;
int viewnum; int viewnum;
INT32 playernum, oldplayernum; INT32 playernum;
char c; char c;
/* easy peasy */ /* easy peasy */
c = COM_Argv(0)[strlen(COM_Argv(0))-1];/* may be digit */ c = COM_Argv(0)[strlen(COM_Argv(0))-1];/* may be digit */
@ -1977,12 +1949,10 @@ Command_View_f (void)
CONS_Alert(CONS_WARNING, "There is no player by that name!\n"); CONS_Alert(CONS_WARNING, "There is no player by that name!\n");
return; return;
} }
oldplayernum = playernum;
if (!playeringame[playernum]) if (!playeringame[playernum])
{ {
playernum = RoundToValidPlayerNum(playernum); CONS_Alert(CONS_WARNING, "There is no player using that slot!\n");
return;
} }
olddisplayplayer = (*displayplayerp); olddisplayplayer = (*displayplayerp);
@ -1995,15 +1965,9 @@ Command_View_f (void)
if ((*displayplayerp) != oldplayernum)/* differ parameter */ if ((*displayplayerp) != oldplayernum)/* differ parameter */
{ {
if (playernum == oldplayernum)/* skipped some */ /* skipped some */
{ CONS_Alert(CONS_NOTICE,
CONS_Alert(CONS_NOTICE, "Another viewpoint is already set to that player.\n");
"Another viewpoint is already set to that player.\n");
}
else
{
CONS_Alert(CONS_NOTICE, "There is no player using that slot.\n");
}
PRINTVIEWPOINT ("Now "," instead") PRINTVIEWPOINT ("Now "," instead")
} }
else else