Fixed settings_default.py compliance

Guests are enabled and disabled with GUEST_ENABLED.
This commit is contained in:
n0q 2014-07-07 23:34:07 -04:00
parent de6badd709
commit f6b3535021
2 changed files with 66 additions and 63 deletions

View file

@ -54,6 +54,7 @@ class CmdUnconnectedConnect(MuxCommand):
other types of logged-in commands (this is because
there is no object yet before the player has logged in)
"""
session = self.caller
args = self.args
# extract quoted parts
@ -62,7 +63,7 @@ class CmdUnconnectedConnect(MuxCommand):
# this was (hopefully) due to no quotes being found, or a guest login
parts = parts[0].split(None, 1)
# Guest login
if len(parts) == 1 and parts[0].lower() == "guest" and settings.GUEST_LIST:
if len(parts) == 1 and parts[0].lower() == "guest" and settings.GUEST_ENABLED:
try:
# Find an available guest name.
for playername in settings.GUEST_LIST:
@ -225,63 +226,6 @@ class CmdUnconnectedCreate(MuxCommand):
string = "%s\nThis is a bug. Please e-mail an admin if the problem persists."
session.msg(string % (traceback.format_exc()))
logger.log_errmsg(traceback.format_exc())
def CreatePlayer(session, playername, password,
default_home, permissions, typeclass=None):
"""
Creates a player of the specified typeclass.
"""
try:
new_player = create.create_player(playername, None, password,
permissions=permissions, typeclass=typeclass)
except Exception, e:
session.msg("There was an error creating the Player:\n%s\n If this problem persists, contact an admin." % e)
logger.log_trace()
return False
# This needs to be called so the engine knows this player is
# logging in for the first time. (so it knows to call the right
# hooks during login later)
utils.init_new_player(new_player)
# join the new player to the public channel
pchanneldef = settings.CHANNEL_PUBLIC
if pchanneldef:
pchannel = ChannelDB.objects.get_channel(pchanneldef[0])
if not pchannel.connect(new_player):
string = "New player '%s' could not connect to public channel!" % new_player.key
logger.log_errmsg(string)
return new_player
def CreateCharacter(session, new_player, typeclass, start_location, home, permissions):
"""
Creates a character based on a player's name. This is meant for Guest and
MULTISESSION_MODE <2 situations.
"""
try:
if not start_location:
start_location = home # fallback
new_character = create.create_object(typeclass, key=new_player.key,
location=start_location, home=home,
permissions=permissions)
# set playable character list
new_player.db._playable_characters.append(new_character)
# allow only the character itself and the player to puppet this character (and Immortals).
new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" %
(new_character.id, new_player.id))
# If no description is set, set a default description
if not new_character.db.desc:
new_character.db.desc = "This is a Player."
# We need to set this to have @ic auto-connect to this character
new_player.db._last_puppet = new_character
except Exception, e:
session.msg("There was an error creating the Character:\n%s\n If this problem persists, contact an admin." % e)
logger.log_trace()
return False
class CmdUnconnectedQuit(MuxCommand):
@ -376,3 +320,61 @@ To login to the system, you need to do one of the following:
You can use the {wlook{n command if you want to see the connect screen again.
"""
self.caller.msg(string)
def CreatePlayer(session, playername, password,
default_home, permissions, typeclass=None):
"""
Creates a player of the specified typeclass.
"""
try:
new_player = create.create_player(playername, None, password,
permissions=permissions, typeclass=typeclass)
except Exception, e:
session.msg("There was an error creating the Player:\n%s\n If this problem persists, contact an admin." % e)
logger.log_trace()
return False
# This needs to be called so the engine knows this player is
# logging in for the first time. (so it knows to call the right
# hooks during login later)
utils.init_new_player(new_player)
# join the new player to the public channel
pchanneldef = settings.CHANNEL_PUBLIC
if pchanneldef:
pchannel = ChannelDB.objects.get_channel(pchanneldef[0])
if not pchannel.connect(new_player):
string = "New player '%s' could not connect to public channel!" % new_player.key
logger.log_errmsg(string)
return new_player
def CreateCharacter(session, new_player, typeclass, start_location, home, permissions):
"""
Creates a character based on a player's name. This is meant for Guest and
MULTISESSION_MODE <2 situations.
"""
try:
if not start_location:
start_location = home # fallback
new_character = create.create_object(typeclass, key=new_player.key,
location=start_location, home=home,
permissions=permissions)
# set playable character list
new_player.db._playable_characters.append(new_character)
# allow only the character itself and the player to puppet this character (and Immortals).
new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" %
(new_character.id, new_player.id))
# If no description is set, set a default description
if not new_character.db.desc:
new_character.db.desc = "This is a Player."
# We need to set this to have @ic auto-connect to this character
new_player.db._last_puppet = new_character
except Exception, e:
session.msg("There was an error creating the Character:\n%s\n If this problem persists, contact an admin." % e)
logger.log_trace()
return False

View file

@ -306,6 +306,8 @@ BASE_SCRIPT_TYPECLASS = "src.scripts.scripts.DoNothing"
# fallback if an object's normal home location is deleted. Default
# is Limbo (#2).
DEFAULT_HOME = "#2"
# This enables guest logins.
GUEST_ENABLED = True
# The default home location used for guests.
GUEST_HOME = "#2"
# The start position for new characters. Default is Limbo (#2).
@ -314,6 +316,10 @@ GUEST_HOME = "#2"
START_LOCATION = "#2"
# The start position used for guest characters.
GUEST_START_LOCATION = "#2"
# The naming convention for guest players/characters. The size of this list
# also detemines how many guests may be on the game at once. The default is
# a maximum of five guests, named Guest1 through Guest5.
GUEST_LIST = ["Guest" + str(s+1) for s in range(9)]
# Lookups of Attributes, Tags, Nicks, Aliases can be aggressively
# cached to avoid repeated database hits. This often gives noticeable
# performance gains since they are called so often. Drawback is that
@ -384,11 +390,6 @@ PERMISSION_HIERARCHY = ("Players",
PERMISSION_PLAYER_DEFAULT = "Players"
# The permission given to guests
PERMISSION_GUEST_DEFAULT = "Guests"
# The naming convention for guest players/characters. The size of this list
# also detemines how many guests may be on the game at once. The default is
# a maximum of five guests, named Guest1 through Guest5.
# Set to None to disable guest logins entirely.
GUEST_LIST = ["Guest" + str(s+1) for s in range(5)]
######################################################################
# In-game Channels created from server start