diff --git a/apps/objects/models.py b/apps/objects/models.py index 9fc54d0a1b..2abe639f75 100755 --- a/apps/objects/models.py +++ b/apps/objects/models.py @@ -176,8 +176,8 @@ class Object(models.Model): # If it's a player, we need to update their user object as well. if self.is_player(): - pobject = User.objects.get(id=self.id) - pobject.name = new_name + pobject = self.get_user_account() + pobject.username = new_name pobject.save() def get_user_account(self): @@ -292,7 +292,7 @@ class Object(models.Model): uobj.is_active = False uobj.save() except: - functions_general.print_errmsg('Destroying object %s but no matching player.' % (self,)) + functions_general.log_errmsg('Destroying object %s but no matching player.' % (self,)) # Set the object type to GOING self.type = 5 @@ -439,7 +439,7 @@ class Object(models.Model): try: return self.location except: - functions_general.print_errmsg("Object '%s(#%d)' has invalid location: #%s" % (self.name,self.id,self.location_id)) + functions_general.log_errmsg("Object '%s(#%d)' has invalid location: #%s" % (self.name,self.id,self.location_id)) return False def get_attribute_value(self, attrib, default=False): diff --git a/cmdhandler.py b/cmdhandler.py index 43cd5f238c..46d194c701 100755 --- a/cmdhandler.py +++ b/cmdhandler.py @@ -3,6 +3,7 @@ import commands_privileged import commands_general import commands_unloggedin import functions_db +import functions_general """ This is the command processing module. It is instanced once in the main @@ -57,6 +58,9 @@ def handle(cdat): parsed_input['root_cmd'] = alias_list.get(parsed_input['root_cmd'],parsed_input['root_cmd']) if session.logged_in: + # Lets the users get around badly configured NAT timeouts. + if parsed_input['root_cmd'] == 'idle': + return # If it's prefixed by an '@', it's a staff command. if parsed_input['root_cmd'][0] != '@': cmd = getattr(commands_general, 'cmd_%s' % (parsed_input['root_cmd'],), None ) @@ -72,7 +76,7 @@ def handle(cdat): cmd(cdat) except: session.msg("Untrapped error, please file a bug report:\n%s" % (format_exc(),)) - functions_general.print_errmsg("Untrapped error, evoker %s: %s" % + functions_general.log_errmsg("Untrapped error, evoker %s: %s" % (session, format_exc())) return @@ -94,5 +98,5 @@ def handle(cdat): raise UnknownCommand except UnknownCommand: - session.msg("Unknown command.") + session.msg("Huh? (Type \"help\" for help.)") diff --git a/commands_general.py b/commands_general.py index be20587303..c7c20c3743 100644 --- a/commands_general.py +++ b/commands_general.py @@ -292,7 +292,7 @@ def cmd_who(cdat): session = cdat['session'] pobject = session.get_pobject() - retval = "Player Name On For Idle Room Cmds Host\n\r" + retval = "Player Name On For Idle Room Cmds Host\n\r" for player in session_list: if not player.logged_in: continue diff --git a/commands_privileged.py b/commands_privileged.py index 010c06f153..4a0cab743f 100644 --- a/commands_privileged.py +++ b/commands_privileged.py @@ -17,6 +17,13 @@ builder, staff or otherwise manipulative command that doesn't fall within the scope of normal gameplay. """ +def cmd_reload(cdat): + """ + Reloads all modules. + """ + session = cdat['session'] + server = session.server.reload(session) + def cmd_destroy(cdat): """ Destroy an object. diff --git a/functions_general.py b/functions_general.py index d2a8541ab7..8cb391d794 100644 --- a/functions_general.py +++ b/functions_general.py @@ -16,13 +16,22 @@ def cmd_check_num_args(session, arg_list, min_args, errortext="Missing arguments return False return True -def print_errmsg(errormsg): +def log_errmsg(errormsg): """ - Prints/logs an error message. Pipe any errors to be logged through here. - For now we're just printing to standard out. + Prints/logs an error message to the server log. + + errormsg: (string) The message to be logged. """ print 'ERROR: %s' % (errormsg,) +def log_infomsg(infomsg): + """ + Prints any generic debugging/informative info that should appear in the log. + + debugmsg: (string) The message to be logged. + """ + print '%s' % (infomsg,) + def command_list(): """ Return a list of all commands. diff --git a/server.py b/server.py index 95551b6e0a..fd52336c41 100755 --- a/server.py +++ b/server.py @@ -5,6 +5,7 @@ from django.db import models from django.db import connection from apps.config.models import CommandAlias +import sys import scheduler import functions_general import session_mgr @@ -88,7 +89,25 @@ class Server(dispatcher): def shutdown(self, message='The server has been shutdown. Please check back soon.'): functions_general.announce_all(message) self.game_running = False - + + + def reload(self, session): + """ + Reload modules that don't have any variables that can be reset. + For changes to the scheduler, server, or session_mgr modules, a cold + restart is needed. + """ + reload_list = ['ansi', 'cmdhandler', 'commands_general', + 'commands_privileged', 'commands_unloggedin', 'defines_global', + 'events', 'functions_db', 'functions_general', 'functions_help', + 'gameconf', 'session', 'apps.objects.models', + 'apps.helpsys.models', 'apps.config.models'] + + for mod in reload_list: + reload(sys.modules[mod]) + + session.msg("Modules reloaded.") + functions_general.log_infomsg("Modules reloaded by %s." % (session,)) """ END Server CLASS """