From e266a3bf7deb0f198281ecb082584d84fe02e0a1 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 13 Jan 2008 10:38:45 +0000 Subject: [PATCH] Change allow_new_nicks to accept either "yes" or "no", not a number. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@412 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- config.l | 2 ++ config.y | 16 ++++++++++++---- examples/dgamelaunch.conf | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/config.l b/config.l index d826480..82ed757 100644 --- a/config.l +++ b/config.l @@ -79,6 +79,8 @@ WHITE [\t ]* "game_args" { return TYPE_GAME_ARGS; } "rc_fmt" { return TYPE_RC_FMT; } commands { return TYPE_CMDQUEUE; } +yes { yylval.i = 1; return TYPE_BOOL; } +no { yylval.i = 0; return TYPE_BOOL; } dglstart { yylval.i = DGLTIME_DGLSTART; return TYPE_CMDQUEUENAME; } login { yylval.i = DGLTIME_LOGIN; return TYPE_CMDQUEUENAME; } register { yylval.i = DGLTIME_REGISTER; return TYPE_CMDQUEUENAME; } diff --git a/config.y b/config.y index e75e734..1a35661 100644 --- a/config.y +++ b/config.y @@ -45,6 +45,7 @@ static const char* lookup_token (int t); %type KeyType %token TYPE_DGLCMD1 TYPE_DGLCMD2 %token TYPE_DEFINE_GAME +%token TYPE_BOOL %% @@ -180,6 +181,17 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']' free($3); } | KeyType '=' TYPE_MALSTRING {} + | KeyType '=' TYPE_BOOL { + switch ($1) { + case TYPE_ALLOW_REGISTRATION: + globalconfig.allow_registration = $3; + break; + default: + fprintf(stderr, "%s:%d: token %s does not take a boolean, bailing out\n", + config, line, lookup_token($1)); + exit(1); + } + } | KeyType '=' TYPE_NUMBER { globalconfig.shed_uid = (uid_t)-1; @@ -210,10 +222,6 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']' globalconfig.shed_gid = $3; break; - case TYPE_ALLOW_REGISTRATION: - globalconfig.allow_registration = $3; - break; - case TYPE_MAX: globalconfig.max = $3; break; diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index cea5787..dd2c092 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -11,8 +11,8 @@ # compiled with SQLite maxusers = 64000 -# Allow registration of new nicks? (0 or 1) -allow_new_nicks = 1 +# Allow registration of new nicks? (yes or no) +allow_new_nicks = yes # Max length for newly registered nicks. Must be less than 20. # By default, NetHack only stores the first 10 chars of a name into