(may_play): New, factored out of play_cmd() and kill_cmd().
(play_cmd, kill_cmd): Use it. (player_main): Don't check authfil, caller takes care of that.
This commit is contained in:
parent
504305357d
commit
342d7b33ce
2 changed files with 26 additions and 30 deletions
|
@ -257,6 +257,30 @@ options_cmd(void)
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
may_play(void)
|
||||||
|
{
|
||||||
|
struct natstr *np;
|
||||||
|
|
||||||
|
if (player->cnum == 255 || !player->authenticated) {
|
||||||
|
pr_id(player, C_CMDERR, "need country and password\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (match_user(banfil, player)) {
|
||||||
|
logerror("Attempted login by BANNED host %s", praddr(player));
|
||||||
|
pr_id(player, C_EXIT, "Your login has been banned from this game\n");
|
||||||
|
io_shutdown(player->iop, IO_READ);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
np = getnatp(player->cnum);
|
||||||
|
if (np->nat_stat == STAT_GOD && !match_user(authfil, player)) {
|
||||||
|
logerror("NON-AUTHed Login attempted by %s", praddr(player));
|
||||||
|
pr_id(player, C_EXIT, "You're not a deity!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
play_cmd(void)
|
play_cmd(void)
|
||||||
{
|
{
|
||||||
|
@ -287,10 +311,8 @@ play_cmd(void)
|
||||||
player->cnum = cnum;
|
player->cnum = cnum;
|
||||||
player->authenticated = 1;
|
player->authenticated = 1;
|
||||||
}
|
}
|
||||||
if (player->cnum == 255 || !player->authenticated) {
|
if (!may_play())
|
||||||
pr_id(player, C_CMDERR, "need country and password\n");
|
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
|
||||||
other = getplayer((natid)player->cnum);
|
other = getplayer((natid)player->cnum);
|
||||||
if (other) {
|
if (other) {
|
||||||
natp = getnatp(player->cnum);
|
natp = getnatp(player->cnum);
|
||||||
|
@ -301,12 +323,6 @@ play_cmd(void)
|
||||||
}
|
}
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
if (match_user(banfil, player)) {
|
|
||||||
logerror("Attempted login by BANNED host %s", praddr(player));
|
|
||||||
pr("Your login has been banned from this game\n");
|
|
||||||
io_shutdown(player->iop, IO_READ);
|
|
||||||
return RET_FAIL;
|
|
||||||
}
|
|
||||||
logerror("%s logged in as country #%d", praddr(player), player->cnum);
|
logerror("%s logged in as country #%d", praddr(player), player->cnum);
|
||||||
pr_id(player, C_INIT, "%d\n", CLIENTPROTO);
|
pr_id(player, C_INIT, "%d\n", CLIENTPROTO);
|
||||||
player_main(player);
|
player_main(player);
|
||||||
|
@ -319,24 +335,9 @@ static int
|
||||||
kill_cmd(void)
|
kill_cmd(void)
|
||||||
{
|
{
|
||||||
struct player *other;
|
struct player *other;
|
||||||
struct natstr *np;
|
|
||||||
|
|
||||||
if (player->cnum == 255 || !player->authenticated) {
|
if (!may_play())
|
||||||
pr_id(player, C_CMDERR, "need country and password\n");
|
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
|
||||||
if (match_user(banfil, player)) {
|
|
||||||
logerror("Attempted login by BANNED host %s", praddr(player));
|
|
||||||
pr_id(player, C_EXIT, "Your login has been banned from this game\n");
|
|
||||||
io_shutdown(player->iop, IO_READ);
|
|
||||||
return RET_FAIL;
|
|
||||||
}
|
|
||||||
np = getnatp(player->cnum);
|
|
||||||
if (np->nat_stat == STAT_GOD && !match_user(authfil, player)) {
|
|
||||||
logerror("NON-AUTHed Login attempted by %s", praddr(player));
|
|
||||||
pr_id(player, C_EXIT, "You're not a deity!\n");
|
|
||||||
return RET_FAIL;
|
|
||||||
}
|
|
||||||
other = getplayer(player->cnum);
|
other = getplayer(player->cnum);
|
||||||
if (!other) {
|
if (!other) {
|
||||||
pr_id(player, C_EXIT, "country not in use\n");
|
pr_id(player, C_EXIT, "country not in use\n");
|
||||||
|
|
|
@ -79,11 +79,6 @@ player_main(struct player *p)
|
||||||
if (init_nats() < 0)
|
if (init_nats() < 0)
|
||||||
return;
|
return;
|
||||||
natp = getnatp(player->cnum);
|
natp = getnatp(player->cnum);
|
||||||
if (player->god && !match_user(authfil, player)) {
|
|
||||||
logerror("NON-AUTHed Login attempted by %s", praddr(player));
|
|
||||||
pr("You're not a deity!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!gamehours(player->curup)) {
|
if (!gamehours(player->curup)) {
|
||||||
pr("Empire hours restriction in force\n");
|
pr("Empire hours restriction in force\n");
|
||||||
if (natp->nat_stat != STAT_GOD)
|
if (natp->nat_stat != STAT_GOD)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue