Mixed batch of minor bug fixes and cleanups.
This commit is contained in:
parent
9520e261d8
commit
4bcd5239b5
8 changed files with 40 additions and 39 deletions
|
|
@ -104,7 +104,7 @@ class Command(BaseCommand):
|
||||||
used by Evennia to create the automatic help entry for
|
used by Evennia to create the automatic help entry for
|
||||||
the command, so make sure to document consistently here.
|
the command, so make sure to document consistently here.
|
||||||
"""
|
"""
|
||||||
def access(self, srcobj):
|
def access(self, srcobj, access_type="cmd", default=False):
|
||||||
"""
|
"""
|
||||||
This is called by the cmdhandler to determine
|
This is called by the cmdhandler to determine
|
||||||
if srcobj is allowed to execute this command. This
|
if srcobj is allowed to execute this command. This
|
||||||
|
|
@ -113,7 +113,7 @@ class Command(BaseCommand):
|
||||||
By default, We use checks of the 'cmd' type of lock to determine
|
By default, We use checks of the 'cmd' type of lock to determine
|
||||||
if the command should be run.
|
if the command should be run.
|
||||||
"""
|
"""
|
||||||
return super(Command, self).access(srcobj)
|
return super(Command, self).access(srcobj, access_type=access_type, default=default)
|
||||||
|
|
||||||
def at_pre_cmd(self):
|
def at_pre_cmd(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -120,13 +120,12 @@ def get_and_merge_cmdsets(caller):
|
||||||
local_objects_cmdsets = [obj.cmdset.current
|
local_objects_cmdsets = [obj.cmdset.current
|
||||||
for obj in local_objlist
|
for obj in local_objlist
|
||||||
if obj.locks.check(caller, 'call', no_superuser_bypass=True)]
|
if obj.locks.check(caller, 'call', no_superuser_bypass=True)]
|
||||||
|
|
||||||
# Merge all command sets into one
|
# Merge all command sets into one
|
||||||
# (the order matters, the higher-prio cmdsets are merged last)
|
# (the order matters, the higher-prio cmdsets are merged last)
|
||||||
cmdset = caller_cmdset
|
cmdset = caller_cmdset
|
||||||
for obj_cmdset in [obj_cmdset for obj_cmdset in local_objects_cmdsets if obj_cmdset]:
|
for obj_cmdset in [obj_cmdset for obj_cmdset in local_objects_cmdsets if obj_cmdset]:
|
||||||
# Here only, object cmdsets are merged with duplicates=True
|
# Here only, object cmdsets are merged with duplicates=True
|
||||||
# (or we would never be able to differentiate between objects)
|
# (or we would never be able to differentiate between same-prio objects)
|
||||||
try:
|
try:
|
||||||
old_duplicate_flag = obj_cmdset.duplicates
|
old_duplicate_flag = obj_cmdset.duplicates
|
||||||
obj_cmdset.duplicates = True
|
obj_cmdset.duplicates = True
|
||||||
|
|
@ -306,7 +305,7 @@ def cmdhandler(caller, raw_string, unloggedin=False, testing=False):
|
||||||
raise ExecSystemCommand(syscmd, sysarg)
|
raise ExecSystemCommand(syscmd, sysarg)
|
||||||
|
|
||||||
# Parse the input string into command candidates
|
# Parse the input string into command candidates
|
||||||
cmd_candidates = COMMAND_PARSER(raw_string)
|
cmd_candidates = COMMAND_PARSER(raw_string)
|
||||||
|
|
||||||
#string ="Command candidates"
|
#string ="Command candidates"
|
||||||
#for cand in cmd_candidates:
|
#for cand in cmd_candidates:
|
||||||
|
|
|
||||||
|
|
@ -131,10 +131,9 @@ class CmdSet(object):
|
||||||
|
|
||||||
priority- All cmdsets are always merged in pairs of two so that
|
priority- All cmdsets are always merged in pairs of two so that
|
||||||
the higher set's mergetype is applied to the
|
the higher set's mergetype is applied to the
|
||||||
lower-priority cmdset. Evennia uses priorities from 0-10
|
lower-priority cmdset. Default commands have priority 0,
|
||||||
where 10 are used for high-priority things like comsys
|
high-priority ones like Exits and Channels have 10 and 9. Priorities
|
||||||
channel names and 9 for exit names in order to give
|
can be negative as well to give default commands preference.
|
||||||
these priority when the given command matches.
|
|
||||||
|
|
||||||
duplicates - determines what happens when two sets of equal
|
duplicates - determines what happens when two sets of equal
|
||||||
priority merge. Default has the first of them in the
|
priority merge. Default has the first of them in the
|
||||||
|
|
|
||||||
|
|
@ -1018,6 +1018,8 @@ class CmdOpen(ObjManipCommand):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# exit does not exist before. Create a new one.
|
# exit does not exist before. Create a new one.
|
||||||
|
if not typeclass:
|
||||||
|
typeclass = settings.BASE_EXIT_TYPECLASS
|
||||||
exit_obj = create.create_object(typeclass, key=exit_name,
|
exit_obj = create.create_object(typeclass, key=exit_name,
|
||||||
location=location,
|
location=location,
|
||||||
aliases=exit_aliases)
|
aliases=exit_aliases)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ class DefaultCmdSet(CmdSet):
|
||||||
Implements the default command set.
|
Implements the default command set.
|
||||||
"""
|
"""
|
||||||
key = "DefaultMUX"
|
key = "DefaultMUX"
|
||||||
|
priority = 0
|
||||||
|
|
||||||
def at_cmdset_creation(self):
|
def at_cmdset_creation(self):
|
||||||
"Populates the cmdset"
|
"Populates the cmdset"
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ class ExitHandler(object):
|
||||||
exit_cmdset.priority = 9
|
exit_cmdset.priority = 9
|
||||||
exit_cmdset.duplicates = True
|
exit_cmdset.duplicates = True
|
||||||
try:
|
try:
|
||||||
location = srcobj.location
|
location = srcobj.location
|
||||||
except Exception:
|
except Exception:
|
||||||
location = None
|
location = None
|
||||||
if not location:
|
if not location:
|
||||||
|
|
@ -84,8 +84,7 @@ class ExitHandler(object):
|
||||||
return exit_cmdset
|
return exit_cmdset
|
||||||
|
|
||||||
# use exits to create searchable "commands" for the cmdhandler
|
# use exits to create searchable "commands" for the cmdhandler
|
||||||
for exi in (exi for exi in location.contents
|
for exi in location.exits:
|
||||||
if exi.destination):
|
|
||||||
if exi.id in self.cached_exit_cmds:
|
if exi.id in self.cached_exit_cmds:
|
||||||
# retrieve from cache
|
# retrieve from cache
|
||||||
exit_cmdset.add(self.cached_exit_cmds[exi.id])
|
exit_cmdset.add(self.cached_exit_cmds[exi.id])
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ they control by simply linking to a new object's user property.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from src.typeclasses.typeclass import TypeClass
|
from src.typeclasses.typeclass import TypeClass
|
||||||
|
from src.commands import cmdset, command
|
||||||
from src.objects.exithandler import EXITHANDLER
|
from src.objects.exithandler import EXITHANDLER
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -347,7 +348,7 @@ class Character(Object):
|
||||||
"""
|
"""
|
||||||
super(Character, self).basetype_setup()
|
super(Character, self).basetype_setup()
|
||||||
self.locks.add("get:false()") # noone can pick up the character
|
self.locks.add("get:false()") # noone can pick up the character
|
||||||
self.locks.add("call:false()") # no commands can be called on character
|
self.locks.add("call:false()") # no commands can be called on character from outside
|
||||||
|
|
||||||
# add the default cmdset
|
# add the default cmdset
|
||||||
from settings import CMDSET_DEFAULT
|
from settings import CMDSET_DEFAULT
|
||||||
|
|
@ -393,6 +394,11 @@ class Room(Object):
|
||||||
super(Room, self).basetype_setup()
|
super(Room, self).basetype_setup()
|
||||||
self.location = None
|
self.location = None
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Exits
|
||||||
|
#
|
||||||
|
|
||||||
class Exit(Object):
|
class Exit(Object):
|
||||||
"""
|
"""
|
||||||
This is the base exit object - it connects a location
|
This is the base exit object - it connects a location
|
||||||
|
|
@ -414,23 +420,14 @@ class Exit(Object):
|
||||||
"""
|
"""
|
||||||
# the lock is open to all by default
|
# the lock is open to all by default
|
||||||
super(Exit, self).basetype_setup()
|
super(Exit, self).basetype_setup()
|
||||||
|
|
||||||
self.locks.add("puppet:false()") # would be weird to puppet an exit ...
|
self.locks.add("puppet:false()") # would be weird to puppet an exit ...
|
||||||
self.locks.add("traverse:all()") # who can pass through exit
|
self.locks.add("traverse:all()") # who can pass through exit by default
|
||||||
self.locks.add("get:false()") # noone can pick up the exit
|
self.locks.add("get:false()") # noone can pick up the exit
|
||||||
|
|
||||||
def at_object_creation(self):
|
# an exit should have a destination (this is replaced at creation time)
|
||||||
"""
|
if self.dbobj.location:
|
||||||
An example just for show; the destination property
|
self.destination = self.dbobj.location
|
||||||
is usually set at creation time, not as part of the class
|
|
||||||
definition (unless you want an entire class of exits
|
|
||||||
all leadning to the same hard-coded place ...)
|
|
||||||
"""
|
|
||||||
# having destination != None is what makes it an exit
|
|
||||||
# (what's set here won't last)
|
|
||||||
if self.location:
|
|
||||||
self.destination = self.location
|
|
||||||
else:
|
|
||||||
self.destination = 2 # use limbo as a failsafe
|
|
||||||
|
|
||||||
def at_object_delete(self):
|
def at_object_delete(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ from django.conf import settings
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from src.utils.idmapper.models import SharedMemoryModel
|
from src.utils.idmapper.models import SharedMemoryModel
|
||||||
|
from src.server.models import ServerConfig
|
||||||
from src.typeclasses import managers
|
from src.typeclasses import managers
|
||||||
from src.locks.lockhandler import LockHandler
|
from src.locks.lockhandler import LockHandler
|
||||||
from src.utils import logger, utils
|
from src.utils import logger, utils
|
||||||
|
|
@ -617,21 +618,24 @@ class TypedObject(SharedMemoryModel):
|
||||||
Helper function to display error.
|
Helper function to display error.
|
||||||
"""
|
"""
|
||||||
infochan = None
|
infochan = None
|
||||||
|
cmessage = message
|
||||||
try:
|
try:
|
||||||
from src.comms.models import Channel
|
from src.comms.models import Channel
|
||||||
infochan = settings.CHANNEL_MUDINFO
|
infochan = settings.CHANNEL_MUDINFO
|
||||||
infochan = Channel.objects.get_channel(infochan[0])
|
infochan = Channel.objects.get_channel(infochan[0])
|
||||||
except Exception, e:
|
if infochan:
|
||||||
print e
|
cname = infochan.key
|
||||||
pass
|
cmessage = "\n".join(["[%s]: %s" % (cname, line) for line in message.split('\n')])
|
||||||
if infochan:
|
infochan.msg(message)
|
||||||
cname = infochan.key
|
else:
|
||||||
cmessage = "\n".join(["[%s]: %s" % (cname, line) for line in message.split('\n')])
|
# no mudinfo channel is found. Log instead.
|
||||||
infochan.msg(message)
|
cmessage = "\n".join(["[NO MUDINFO CHANNEL]: %s" % line for line in message.split('\n')])
|
||||||
else:
|
logger.log_errmsg(cmessage)
|
||||||
# no mudinfo channel is found. Log instead.
|
except Exception, e:
|
||||||
cmessage = "\n".join(["[NO MUDINFO CHANNEL]: %s" % line for line in message.split('\n')])
|
if ServerConfig.objects.conf("server_starting_mode"):
|
||||||
logger.log_errmsg(cmessage)
|
print cmessage
|
||||||
|
else:
|
||||||
|
logger.log_trace(cmessage)
|
||||||
|
|
||||||
#path = self.db_typeclass_path
|
#path = self.db_typeclass_path
|
||||||
path = object.__getattribute__(self, 'db_typeclass_path')
|
path = object.__getattribute__(self, 'db_typeclass_path')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue