From 91b23f58a4a499d2e23014afc69b10e881656d32 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 20 Apr 2014 15:56:38 +0200 Subject: [PATCH] Removed CHARACTER_DEFAULT_HOME, replaced with DEFAULT_HOME and added START_LOCATION for determining where default commands dump new characters. --- contrib/email-login.py | 2 +- game/evennia.py | 6 +++++- src/commands/default/building.py | 7 ++++--- src/commands/default/player.py | 5 +++-- src/commands/default/unloggedin.py | 5 +++-- src/objects/models.py | 4 ++-- src/settings_default.py | 33 ++++++++++++++++++------------ src/utils/create.py | 6 +++--- 8 files changed, 41 insertions(+), 27 deletions(-) diff --git a/contrib/email-login.py b/contrib/email-login.py index 853dadf1b0..e55dd17f99 100644 --- a/contrib/email-login.py +++ b/contrib/email-login.py @@ -200,7 +200,7 @@ its and @/./+/-/_ only.") # this echoes the restrictions made by django's auth m # everything's ok. Create the new player account. try: - default_home = ObjectDB.objects.get_id(settings.CHARACTER_DEFAULT_HOME) + default_home = ObjectDB.objects.get_id(settings.DEFAULT_HOME) typeclass = settings.BASE_CHARACTER_TYPECLASS permissions = settings.PERMISSION_PLAYER_DEFAULT diff --git a/game/evennia.py b/game/evennia.py index bf14e901d3..d1ed65fd69 100755 --- a/game/evennia.py +++ b/game/evennia.py @@ -449,7 +449,8 @@ def error_check_python_modules(): imp(path, split=False) # cmdsets - deprstring = "settings.%s should be renamed to %s. If defaults are used, their path/classname must be updated (see src/settings_default.py)." + deprstring = "settings.%s should be renamed to %s. If defaults are used, " \ + "their path/classname must be updated (see src/settings_default.py)." if hasattr(settings, "CMDSET_DEFAULT"): raise DeprecationWarning(deprstring % ("CMDSET_DEFAULT", "CMDSET_CHARACTER")) if hasattr(settings, "CMDSET_OOC"): @@ -460,6 +461,9 @@ def error_check_python_modules(): raise DeprecationWarning(deprstring % ("BASE_COMM_TYPECLASS", "BASE_CHANNEL_TYPECLASS")) if hasattr(settings, "COMM_TYPECLASS_PATHS"): raise DeprecationWarning(deprstring % ("COMM_TYPECLASS_PATHS", "CHANNEL_TYPECLASS_PATHS")) + if hasattr(settings, "CHARACTER_DEFAULT_HOME"): + raise DeprecationWarning("settings.CHARACTER_DEFAULT_HOME should be renamed to DEFAULT_HOME. " \ + "See also settings.START_LOCATION (see src/settings_default.py).") from src.commands import cmdsethandler if not cmdsethandler.import_cmdset(settings.CMDSET_UNLOGGEDIN, None): print "Warning: CMDSET_UNLOGGED failed to load!" diff --git a/src/commands/default/building.py b/src/commands/default/building.py index e8adc17bca..fe7d11c161 100644 --- a/src/commands/default/building.py +++ b/src/commands/default/building.py @@ -525,14 +525,15 @@ class CmdDestroy(MuxCommand): if not obj: self.caller.msg(" (Objects to destroy must either be local or specified with a unique #dbref.)") return "" - if (not "override" in self.switches and - obj.dbid == int(settings.CHARACTER_DEFAULT_HOME.lstrip("#"))): - return "\nYou are trying to delete CHARACTER_DEFAULT_HOME. If you want to do this, use the /override switch." objname = obj.name if not obj.access(caller, 'delete'): return "\nYou don't have permission to delete %s." % objname if obj.player and not 'override' in self.switches: return "\nObject %s is controlled by an active player. Use /override to delete anyway." % objname + if obj.dbid == int(settings.DEFAULT_HOME.lstrip("#")): + return "\nYou are trying to delete {c%s{n, which is set as DEFAULT_HOME. " \ + "Re-point settings.DEFAULT_HOME to another " \ + "object before continuing." % objname had_exits = hasattr(obj, "exits") and obj.exits had_objs = hasattr(obj, "contents") and any(obj for obj in obj.contents diff --git a/src/commands/default/player.py b/src/commands/default/player.py index 021e639446..68716d0126 100644 --- a/src/commands/default/player.py +++ b/src/commands/default/player.py @@ -181,12 +181,13 @@ class CmdCharCreate(MuxPlayerCommand): # create the character from src.objects.models import ObjectDB - default_home = ObjectDB.objects.get_id(settings.CHARACTER_DEFAULT_HOME) + start_location = ObjectDB.objects.get_id(settings.START_LOCATION) + default_home = ObjectDB.objects.get_id(settings.DEFAULT_HOME) typeclass = settings.BASE_CHARACTER_TYPECLASS permissions = settings.PERMISSION_PLAYER_DEFAULT new_character = create.create_object(typeclass, key=key, - location=default_home, + location=start_location, home=default_home, permissions=permissions) # only allow creator (and immortals) to puppet this char diff --git a/src/commands/default/unloggedin.py b/src/commands/default/unloggedin.py index 69f60a19ad..b2bb73d645 100644 --- a/src/commands/default/unloggedin.py +++ b/src/commands/default/unloggedin.py @@ -160,7 +160,7 @@ class CmdUnconnectedCreate(MuxCommand): # everything's ok. Create the new player account. try: - default_home = ObjectDB.objects.get_id(settings.CHARACTER_DEFAULT_HOME) + default_home = ObjectDB.objects.get_id(settings.DEFAULT_HOME) typeclass = settings.BASE_CHARACTER_TYPECLASS permissions = settings.PERMISSION_PLAYER_DEFAULT @@ -190,8 +190,9 @@ class CmdUnconnectedCreate(MuxCommand): if MULTISESSION_MODE < 2: # if we only allow one character, create one with the same name as Player # (in mode 2, the character must be created manually once logging in) + start_location = settings.START_LOCATION new_character = create.create_object(typeclass, key=playername, - location=default_home, home=default_home, + location=start_location, home=default_home, permissions=permissions) # set playable character list new_player.db._playable_characters.append(new_character) diff --git a/src/objects/models.py b/src/objects/models.py index d31ebe498e..e97bb7f086 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -582,7 +582,7 @@ class ObjectDB(TypedObject): if _GA(self, "home"): source_location = _GA(self, "home") else: - default_home = ObjectDB.objects.get_id(settings.CHARACTER_DEFAULT_HOME) + default_home = ObjectDB.objects.get_id(settings.DEFAULT_HOME) source_location = default_home # Call hook on source location @@ -667,7 +667,7 @@ class ObjectDB(TypedObject): """ # Gather up everything that thinks this is its location. objs = ObjectDB.objects.filter(db_location=self) - default_home_id = int(settings.CHARACTER_DEFAULT_HOME.lstrip("#")) + default_home_id = int(settings.DEFAULT_HOME.lstrip("#")) try: default_home = ObjectDB.objects.get(id=default_home_id) if default_home.dbid == _GA(self, "dbid"): diff --git a/src/settings_default.py b/src/settings_default.py index e84d88fc5d..e9e9991171 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -270,11 +270,14 @@ BASE_CHANNEL_TYPECLASS = "src.comms.comms.Channel" # Typeclass for Scripts (fallback). You usually don't need to change this # but create custom variations of scripts on a per-case basis instead. BASE_SCRIPT_TYPECLASS = "src.scripts.scripts.DoNothing" -# The home location for new characters. This must be a unique -# dbref (default is Limbo #2). If you want more advanced control over -# start locations, copy the "create" command from -# src/commands/default/unloggedin.py and customize. -CHARACTER_DEFAULT_HOME = "#2" +# The default home location used for all objects. This is used as a +# fallback if an object's normal home location is deleted. Default +# is Limbo (#2). +DEFAULT_HOME = "#2" +# The start position for new characters. Default is Limbo (#2). +# MULTISESSION_MODE = 0, 1 - used by default unloggedin create command +# MULTISESSION_MODE = 2 - used by default character_create command +START_LOCATION = "#2" # 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 @@ -377,6 +380,15 @@ CHANNEL_CONNECTINFO = ("MUDconnections", '', 'Connection log', # versa. Obs - make sure the IRC network allows bots. # When enabled, command @irc2chan will be available in-game IRC_ENABLED = False +# RSS allows to connect RSS feeds (from forum updates, blogs etc) to +# an in-game channel. The channel will be updated when the rss feed +# updates. Use @rss2chan in game to connect if this setting is +# active. OBS: RSS support requires the python-feedparser package to +# be installed (through package manager or from the website +# http://code.google.com/p/feedparser/) +RSS_ENABLED=False +RSS_UPDATE_INTERVAL = 60*10 # 10 minutes + # IMC (Inter-MUD communication) allows to connect an Evennia channel # to an IMC2 server. This lets them talk to people on other MUDs also # using IMC. Evennia's IMC2 client was developed against MudByte's @@ -389,19 +401,14 @@ IRC_ENABLED = False # command @imc2chan becomes available in-game and allows you to # connect Evennia channels to IMC channels on the network. The Evennia # discussion channel 'ievennia' is on server01.mudbytes.net:5000. + +# NOTE - IMC2 is currently NOT FUNCTIONAL due to lack of testing means. IMC2_ENABLED = False IMC2_NETWORK = "server01.mudbytes.net" IMC2_PORT = 5000 # this is the imc2 port, not on localhost IMC2_CLIENT_PWD = "" IMC2_SERVER_PWD = "" -# RSS allows to connect RSS feeds (from forum updates, blogs etc) to -# an in-game channel. The channel will be updated when the rss feed -# updates. Use @rss2chan in game to connect if this setting is -# active. OBS: RSS support requires the python-feedparser package to -# be installed (through package manager or from the website -# http://code.google.com/p/feedparser/) -RSS_ENABLED=False -RSS_UPDATE_INTERVAL = 60*10 # 10 minutes + ###################################################################### # Django web features diff --git a/src/utils/create.py b/src/utils/create.py index aa9fdafb2a..de90d37c8d 100644 --- a/src/utils/create.py +++ b/src/utils/create.py @@ -176,10 +176,10 @@ def create_object(typeclass=None, key=None, location=None, # we shouldn't need to handle dbref here (home handler should fix it), but some have # reported issues here (issue 446). try: - new_object.home = handle_dbref(settings.CHARACTER_DEFAULT_HOME, _ObjectDB) if not nohome else None + new_object.home = handle_dbref(settings.DEFAULT_HOME, _ObjectDB) if not nohome else None except _ObjectDB.DoesNotExist: - raise _ObjectDB.DoesNotExist("CHARACTER_DEFAULT_HOME (= '%s') does not exist, or the setting is malformed." % - settings.CHARACTER_DEFAULT_HOME) + raise _ObjectDB.DoesNotExist("settings.DEFAULT_HOME (= '%s') does not exist, or the setting is malformed." % + settings.DEFAULT_HOME) # perform a move_to in order to display eventual messages. if location: