(player_find_other): Replace by getplayer. player_find_other()
searches for a player other than US for country CNUM, which is in state PS_PLAYING. Since there can be at most one player in state PS_PLAYING, and no caller pass that player as US, they can simply use getplayer() instead.
This commit is contained in:
parent
f6a8a14831
commit
ed5ba9fe3e
3 changed files with 4 additions and 19 deletions
|
@ -408,7 +408,6 @@ extern struct player *player_delete(struct player *);
|
||||||
extern struct player *player_next(struct player *);
|
extern struct player *player_next(struct player *);
|
||||||
extern struct player *player_prev(struct player *);
|
extern struct player *player_prev(struct player *);
|
||||||
extern struct player *getplayer(natid);
|
extern struct player *getplayer(natid);
|
||||||
extern struct player *player_find_other(struct player *, register natid);
|
|
||||||
extern void player_wakeup_all(natid);
|
extern void player_wakeup_all(natid);
|
||||||
extern void player_wakeup(struct player *);
|
extern void player_wakeup(struct player *);
|
||||||
extern void player_accept(void *);
|
extern void player_accept(void *);
|
||||||
|
|
|
@ -227,21 +227,6 @@ getplayer(natid cnum)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct player *
|
|
||||||
player_find_other(struct player *us, register natid cnum)
|
|
||||||
{
|
|
||||||
register struct emp_qelem *qp;
|
|
||||||
|
|
||||||
for (qp = Players.q_forw; qp != &Players; qp = qp->q_forw)
|
|
||||||
if (((struct player *)qp)->cnum == cnum &&
|
|
||||||
((struct player *)qp != us) &&
|
|
||||||
(((struct player *)qp)->state == PS_PLAYING))
|
|
||||||
return (struct player *)qp;
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
player_wakeup_all(natid cnum)
|
player_wakeup_all(natid cnum)
|
||||||
{
|
{
|
||||||
|
|
|
@ -291,7 +291,8 @@ play_cmd(void)
|
||||||
pr_id(player, C_CMDERR, "need country and password\n");
|
pr_id(player, C_CMDERR, "need country and password\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
if ((other = player_find_other(player, (natid)player->cnum)) != 0) {
|
other = getplayer((natid)player->cnum);
|
||||||
|
if (other) {
|
||||||
natp = getnatp(player->cnum);
|
natp = getnatp(player->cnum);
|
||||||
if (natp->nat_stat != VIS) {
|
if (natp->nat_stat != VIS) {
|
||||||
pr_id(player, C_EXIT, "country in use by %s\n", praddr(other));
|
pr_id(player, C_EXIT, "country in use by %s\n", praddr(other));
|
||||||
|
@ -321,8 +322,8 @@ kill_cmd(void)
|
||||||
pr_id(player, C_CMDERR, "need country and password\n");
|
pr_id(player, C_CMDERR, "need country and password\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
/* XXX find cnum other than us */
|
other = getplayer(player->cnum);
|
||||||
if ((other = player_find_other(player, player->cnum)) == 0) {
|
if (!other) {
|
||||||
pr_id(player, C_EXIT, "country not in use\n");
|
pr_id(player, C_EXIT, "country not in use\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue