(getplayer): There may be multiple players for the same country in the
list of players, but at most one in state PS_PLAYING. getplayer() used to get the one first in the list. However, its callers need the one in state PS_PLAYING. In particular, typed_wu() notifies the player obtained from getplayer(). If the player in state PS_PLAYING isn't first, say because another one is trying to log in, the notification gets lost. Fix by making getplayer() return the player in state PS_PLAYING.
This commit is contained in:
parent
687cacd887
commit
f6a8a14831
1 changed files with 11 additions and 5 deletions
|
@ -209,16 +209,22 @@ player_prev(struct player *lp)
|
|||
return lp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return player in state PS_PLAYING for CNUM.
|
||||
*/
|
||||
struct player *
|
||||
getplayer(natid cnum)
|
||||
{
|
||||
register struct emp_qelem *qp;
|
||||
struct emp_qelem *qp;
|
||||
struct player *pl;
|
||||
|
||||
for (qp = Players.q_forw; qp != &Players; qp = qp->q_forw)
|
||||
if (((struct player *)qp)->cnum == cnum)
|
||||
return (struct player *)qp;
|
||||
for (qp = Players.q_forw; qp != &Players; qp = qp->q_forw) {
|
||||
pl = (struct player *)qp;
|
||||
if (pl->cnum == cnum && pl->state == PS_PLAYING)
|
||||
return pl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct player *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue