]> git.pond.sub.org Git - empserver/commitdiff
(player_find_other): Replace by getplayer. player_find_other()
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 2 Oct 2005 16:30:43 +0000 (16:30 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 2 Oct 2005 16:30:43 +0000 (16:30 +0000)
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.

include/prototypes.h
src/lib/player/accept.c
src/lib/player/login.c

index 2aa340b0d326db676b3fb236aac5eeff189b1369..da47764acb41f233c53fb6064b706b91284ad1a0 100644 (file)
@@ -408,7 +408,6 @@ extern struct player *player_delete(struct player *);
 extern struct player *player_next(struct player *);
 extern struct player *player_prev(struct player *);
 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(struct player *);
 extern void player_accept(void *);
index 55a4050a1c212109a13acfc789e0d6b8e5a76202..2355bfa9592a403c79eda1a62dc6ceb55848b3ec 100644 (file)
@@ -227,21 +227,6 @@ getplayer(natid cnum)
     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
 player_wakeup_all(natid cnum)
 {
index 3a5bb4f9d4a94948dd96afc09326d8338f405b82..50b9a14f5888ca5fbad7208102cec82fd2e69302 100644 (file)
@@ -291,7 +291,8 @@ play_cmd(void)
        pr_id(player, C_CMDERR, "need country and password\n");
        return RET_FAIL;
     }
-    if ((other = player_find_other(player, (natid)player->cnum)) != 0) {
+    other = getplayer((natid)player->cnum);
+    if (other) {
        natp = getnatp(player->cnum);
        if (natp->nat_stat != VIS) {
            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");
        return RET_FAIL;
     }
-    /* XXX find cnum other than us */
-    if ((other = player_find_other(player, player->cnum)) == 0) {
+    other = getplayer(player->cnum);
+    if (!other) {
        pr_id(player, C_EXIT, "country not in use\n");
        return RET_FAIL;
     }