diff --git a/commands_general.py b/commands_general.py index 339b645d81..238dbcffdc 100644 --- a/commands_general.py +++ b/commands_general.py @@ -283,8 +283,12 @@ def cmd_say(cdat): """ Room-based speech command. """ - session_list = session_mgr.get_session_list() session = cdat['session'] + + if not functions_general.cmd_check_num_args(session, cdat['uinput']['splitted'], 1, errortext="Say What?"): + return + + session_list = session_mgr.get_session_list() pobject = session.get_pobject() speech = ' '.join(cdat['uinput']['splitted'][1:]) diff --git a/commands_unloggedin.py b/commands_unloggedin.py index a3fecbecb2..31ac506730 100644 --- a/commands_unloggedin.py +++ b/commands_unloggedin.py @@ -1,5 +1,6 @@ from django.contrib.auth.models import User import functions_db +import functions_general """ Commands that are available from the connect screen. @@ -13,8 +14,8 @@ def cmd_connect(cdat): session = cdat['session'] - if len(cdat['uinput']['splitted']) != 3: - session.msg("Missing arguments!") + # Argument check. + if not functions_general.cmd_check_num_args(session, cdat['uinput']['splitted'], 2): return uemail = cdat['uinput']['splitted'][1] @@ -44,10 +45,20 @@ def cmd_create(cdat): Handle the creation of new accounts. """ session = cdat['session'] + + # Argument check. + if not functions_general.cmd_check_num_args(session, cdat['uinput']['splitted'], 2): + return + server = session.server quote_split = ' '.join(cdat['uinput']['splitted']).split("\"") uname = quote_split[1] lastarg_split = quote_split[2].split() + + if len(lastarg_split) != 2: + session.msg("You must specify an email address, followed by a password!") + return + email = lastarg_split[0] password = lastarg_split[1] diff --git a/evennia.sql b/evennia.sql index e67d8c94a2..996055e5b4 100755 Binary files a/evennia.sql and b/evennia.sql differ diff --git a/functions_general.py b/functions_general.py index 25d7a2cdaa..d2a8541ab7 100644 --- a/functions_general.py +++ b/functions_general.py @@ -5,6 +5,17 @@ import commands_unloggedin """ General commonly used functions. """ + +def cmd_check_num_args(session, arg_list, min_args, errortext="Missing arguments!"): + """ + Check a player command's splitted argument list to make sure it contains + the minimum allowable number of arguments. + """ + if len(arg_list) < min_args+1: + session.msg(errortext) + return False + return True + def print_errmsg(errormsg): """ Prints/logs an error message. Pipe any errors to be logged through here. diff --git a/prepenv.sh b/startup.sh similarity index 100% rename from prepenv.sh rename to startup.sh