Many small but useful bug fixes in various modules.

/Griatch
This commit is contained in:
Griatch 2009-10-20 20:38:24 +00:00
parent 615cb51b33
commit c4114938cc
6 changed files with 67 additions and 32 deletions

View file

@ -7,6 +7,7 @@ something.
from traceback import format_exc
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from objects.models import Object
import defines_global
import cmdtable
import statetable
@ -207,6 +208,7 @@ def match_alias(command):
if command.command_alternatives:
command_alternatives = []
for command_alternative in command.command_alternatives:
# create correct command_alternative tuples for storage
command_alternatives.append( (alias_mgr.CMD_ALIAS_LIST.get(
command_alternative[0],
command_alternative[0]),
@ -292,17 +294,33 @@ def match_exits(command,test=False):
logger.log_errmsg("cmdhandler.match_exits(): Object '%s' has no location." %
source_object)
return
# get all exits at location
exits = location.get_contents(filter_type=defines_global.OTYPE_EXIT)
Object = ContentType.objects.get(app_label="objects",
model="object").model_class()
exit_matches = Object.objects.list_search_object_namestr(exits,
command.command_string,
match_type="exact")
# /not sure why this was done this way when one can import Object.
# Object = ContentType.objects.get(app_label="objects",
# model="object").model_class()
exit_matches = None
if command.command_alternatives:
# we have command alternatives (due to spaces in command definition).
# if so we replace the command_string appropriately.
for cmd_alternative in command.command_alternatives:
# the alternatives are ordered longest -> shortest.
exit_matches = Object.objects.list_search_object_namestr(exits,
cmd_alternative[0],
match_type="exact")
if exit_matches:
command.command_string = cmd_alternative[0]
command.command_argument = cmd_alternative[1]
break
if not exit_matches:
exit_matches = Object.objects.list_search_object_namestr(exits,
command.command_string,
match_type="exact")
if exit_matches:
if test:
return True
return True
# Only interested in the first match.
targ_exit = exit_matches[0]
# An exit's home is its destination. If the exit has a None home value,
@ -351,6 +369,7 @@ def command_table_lookup(command, command_table, eval_perms=True,
# with this particular command table.
command.command_string = cmd_alternative[0]
command.command_argument = cmd_alternative[1]
break
if not cmdtuple:
# None of the alternatives match, go with the default one-word name
cmdtuple = command_table.get_command_tuple(command.command_string)
@ -360,14 +379,14 @@ def command_table_lookup(command, command_table, eval_perms=True,
if test:
# Check if this is just a test.
return True
# Check locks
# Check uselocks
if neighbor and not neighbor.scriptlink.use_lock(command.source_object):
# send an locked error message only if lock_desc is defined
lock_msg = neighbor.get_attribute_value("use_lock_msg")
if lock_msg:
command.source_object.emit_to(lock_msg)
raise ExitCommandHandler
return False
return False
# If there is a permissions element to the entry, check perms.
if eval_perms and cmdtuple[1]:
if not command.source_object.has_perm_list(cmdtuple[1]):
@ -387,27 +406,21 @@ def match_neighbor_ctables(command,test=False):
any commands.
"""
source_object = command.source_object
if source_object.location != None:
neighbors = source_object.location.get_contents()
location = source_object.get_location()
if location:
# get all objects, including the current room
neighbors = location.get_contents() + [location]
for neighbor in neighbors:
if command_table_lookup(command,
neighbor.scriptlink.command_table,
test=test, neighbor=neighbor):
# Test for a use-lock.
# If there was a command match, set the scripted_obj attribute
# for the script parent to pick up.
if test:
return True
command.scripted_obj = neighbor
return True
# Check the object's location for command matches.
if command_table_lookup(command,
source_object.location.scriptlink.command_table,
test=test, neighbor=source_object.location):
command.scripted_obj = source_object.location
return True
return True
# No matches
return False

View file

@ -239,6 +239,11 @@ def cmd_clist(command):
@clist
Lists all available channels in the game.
[[clist]]
This is the same as @clist - it shows all
available channels in game.
"""
session = command.session
source_object = command.source_object
@ -260,7 +265,7 @@ def cmd_clist(command):
#s += "** End of Channel List **"
source_object.emit_to(s)
GLOBAL_CMD_TABLE.add_command("@clist", cmd_clist, help_category="Comms")
GLOBAL_CMD_TABLE.add_command("clist", cmd_clist, help_category="Comms")
def cmd_cdestroy(command):
"""
@ -385,6 +390,27 @@ def cmd_cemit(command):
Allows the user to send a message over a channel as long as
they own or control it. It does not show the user's name unless they
provide the /sendername switch.
[[channel_commands]]
Useful channel commands
(see their help pages for detailed help and options)
- Listing channels
clist - show all channels available to you
comlist - show channels you listen to
- Joining/parting channels
addcom - add your alias for a channel
delcom - remove alias for channel
(leave channel if no more aliases)
allcom - view, on/off or remove all your channels
clearcom - removes all channels
- Other
who - list who's online
<chanalias> off - silence channel temporarily
<chanalias> on - turn silenced channel back on
"""
source_object = command.source_object

View file

@ -765,7 +765,7 @@ def cmd_help(command):
# add the 'See also:' footer
topics = HelpEntry.objects.find_topicsuggestions(source_object,
topicstr)
topic.get_topicname())
if topics:
if len(topics) > 5:
topics = topics[:5]

View file

@ -1000,7 +1000,6 @@ def cmd_dig(command):
room_parent = None
exit_names = [None,None]
exit_parents = [None,None]
exit_aliases = [[], []]
#deal with arguments
arg_list = args.split("=",1)
@ -1019,13 +1018,10 @@ def cmd_dig(command):
rarg = arg_list[1]
exits = rarg.split(",",1)
for ie, exi in enumerate(exits):
aliaslist = exi.split(";")
name_and_parent = aliaslist.pop(0) #pops the first index
exit_aliases[ie] = aliaslist #what remains are the aliases
try:
exit_names[ie], exit_parents[ie] = [s.strip() for s in name_and_parent.split(":",1)]
exit_names[ie], exit_parents[ie] = [s.strip() for s in exi.split(":",1)]
except ValueError:
exit_names[ie] = name_and_parent.strip()
exit_names[ie] = exi.strip()
#start creating things.
if not room_name:

View file

@ -67,7 +67,7 @@ DATABASE_HOST = ''
DATABASE_PORT = ''
# How many words a single command name may have (e.g. 'push button' instead of 'pushbutton')
# (commands with switches always accept only one word in the name, e.g. @sethelp/add)
# (commands with switches can always only have one word in the name, e.g. @sethelp/add)
COMMAND_MAXLEN = 3
## Command aliases

View file

@ -179,7 +179,7 @@ class EvenniaBasicObject(object):
for player in con_players:
retval +='\n\r%s' % (player.get_name(show_dbref=show_dbrefs),)
if not con_things == []:
retval += "\n\r%sContents:%s" % (ANSITable.ansi["hilite"],
retval += "\n\r%sYou see:%s" % (ANSITable.ansi["hilite"],
ANSITable.ansi["normal"])
for thing in con_things:
retval += '\n\r%s' % (thing.get_name(show_dbref=show_dbrefs),)