Huge overhaul in the way objects and sessions are used with commands. We now pass all commands through objects (aside from unlogged commands), which means session.msg() is now deprecated for any use other than unlogged out.

As a side-effect of all of this, logging in more than once acts as behaves now. Also, this will allow things/rooms/exits (IE: not players) or un-logged in players to run commands or be forced to run them via @fo. All of this will bring us more in-line with MUX behavior.
This commit is contained in:
Greg Taylor 2009-01-24 20:30:46 +00:00
parent 50f4d04096
commit 9407eb0ee4
20 changed files with 680 additions and 712 deletions

View file

@ -12,16 +12,13 @@ def cmd_reload(command):
"""
Reloads all modules.
"""
session = command.session
session.msg("To be implemented...")
#session.server.reload(session)
command.source_object.emit_to("To be implemented...")
def cmd_boot(command):
"""
Boot a player object from the server.
"""
session = command.session
pobject = session.get_pobject()
source_object = command.source_object
switch_quiet = False
switch_port = False
@ -34,7 +31,7 @@ def cmd_boot(command):
switch_port = True
if not command.command_argument:
session.msg("Who would you like to boot?")
source_object.emit_to("Who would you like to boot?")
return
else:
boot_list = []
@ -49,39 +46,41 @@ def cmd_boot(command):
break
else:
# Grab the objects that match
objs = Object.objects.local_and_global_search(pobject,
objs = Object.objects.local_and_global_search(source_object,
command.command_argument)
if not objs:
session.msg("No name or dbref match found for booting.")
source_object.emit_to("No name or dbref match found for booting.")
return
if not objs[0].is_player():
session.msg("You can only boot players.")
source_object.emit_to("You can only boot players.")
return
if not pobject.controls_other(objs[0]):
if not source_object.controls_other(objs[0]):
if objs[0].is_superuser():
session.msg("You cannot boot a Wizard.")
source_object.emit_to("You cannot boot a Wizard.")
return
else:
session.msg("You do not have permission to boot that player.")
source_object.emit_to("You do not have permission to boot that player.")
return
if objs[0].is_connected_plr():
boot_list.append(session_mgr.session_from_object(objs[0]))
matches = session_mgr.sessions_from_object(objs[0])
for match in matches:
boot_list.append(match)
else:
session.msg("That player is not connected.")
source_object.emit_to("That player is not connected.")
return
if not boot_list:
session.msg("No matches found.")
source_object.emit_to("No matches found.")
return
# Carry out the booting of the sessions in the boot list.
for boot in boot_list:
if not switch_quiet:
boot.msg("You have been disconnected by %s." % (pobject.name))
boot.msg("You have been disconnected by %s." % (source_object.name))
boot.disconnectClient()
session_mgr.remove_session(boot)
return
@ -90,28 +89,27 @@ def cmd_newpassword(command):
"""
Set a player's password.
"""
session = command.session
pobject = session.get_pobject()
source_object = command.source_object
eq_args = command.command_argument.split('=', 1)
searchstring = eq_args[0]
newpass = eq_args[1]
if not command.command_argument or len(searchstring) == 0:
session.msg("What player's password do you want to change")
source_object.emit_to("What player's password do you want to change")
return
if len(newpass) == 0:
session.msg("You must supply a new password.")
source_object.emit_to("You must supply a new password.")
return
target_obj = Object.objects.standard_plr_objsearch(session, searchstring)
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
target_obj = Object.objects.standard_objsearch(source_object, searchstring)
# Use standard_objsearch to handle duplicate/nonexistant results.
if not target_obj:
return
if not target_obj.is_player():
session.msg("You can only change passwords on players.")
elif not pobject.controls_other(target_obj):
session.msg("You do not control %s." % (target_obj.get_name(),))
source_object.emit_to("You can only change passwords on players.")
elif not source_object.controls_other(target_obj):
source_object.emit_to("You do not control %s." % (target_obj.get_name(),))
else:
uaccount = target_obj.get_user_account()
if len(newpass) == 0:
@ -119,18 +117,14 @@ def cmd_newpassword(command):
else:
uaccount.set_password(newpass)
uaccount.save()
session.msg("%s - PASSWORD set." % (target_obj.get_name(),))
source_object.emit_to("%s - PASSWORD set." % (target_obj.get_name(),))
target_obj.emit_to("%s has changed your password." %
(pobject.get_name(show_dbref=False),))
(source_object.get_name(show_dbref=False),))
def cmd_shutdown(command):
"""
Shut the server down gracefully.
"""
session = command.session
server = command.server
pobject = session.get_pobject()
session.msg('Shutting down...')
print 'Server shutdown by %s' % (pobject.get_name(show_dbref=False),)
server.shutdown()
"""
command.source_object.emit_to('Shutting down...')
print 'Server shutdown by %s' % (command.source_object.get_name(show_dbref=False),)
command.session.server.shutdown()