Many small but useful bug fixes in various modules.
/Griatch
This commit is contained in:
parent
615cb51b33
commit
c4114938cc
6 changed files with 67 additions and 32 deletions
|
|
@ -7,6 +7,7 @@ something.
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
from objects.models import Object
|
||||||
import defines_global
|
import defines_global
|
||||||
import cmdtable
|
import cmdtable
|
||||||
import statetable
|
import statetable
|
||||||
|
|
@ -207,6 +208,7 @@ def match_alias(command):
|
||||||
if command.command_alternatives:
|
if command.command_alternatives:
|
||||||
command_alternatives = []
|
command_alternatives = []
|
||||||
for command_alternative in command.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_alternatives.append( (alias_mgr.CMD_ALIAS_LIST.get(
|
||||||
command_alternative[0],
|
command_alternative[0],
|
||||||
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." %
|
logger.log_errmsg("cmdhandler.match_exits(): Object '%s' has no location." %
|
||||||
source_object)
|
source_object)
|
||||||
return
|
return
|
||||||
|
# get all exits at location
|
||||||
exits = location.get_contents(filter_type=defines_global.OTYPE_EXIT)
|
exits = location.get_contents(filter_type=defines_global.OTYPE_EXIT)
|
||||||
Object = ContentType.objects.get(app_label="objects",
|
|
||||||
model="object").model_class()
|
# /not sure why this was done this way when one can import Object.
|
||||||
exit_matches = Object.objects.list_search_object_namestr(exits,
|
# Object = ContentType.objects.get(app_label="objects",
|
||||||
command.command_string,
|
# model="object").model_class()
|
||||||
match_type="exact")
|
|
||||||
|
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 exit_matches:
|
||||||
if test:
|
if test:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Only interested in the first match.
|
# Only interested in the first match.
|
||||||
targ_exit = exit_matches[0]
|
targ_exit = exit_matches[0]
|
||||||
# An exit's home is its destination. If the exit has a None home value,
|
# 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.
|
# with this particular command table.
|
||||||
command.command_string = cmd_alternative[0]
|
command.command_string = cmd_alternative[0]
|
||||||
command.command_argument = cmd_alternative[1]
|
command.command_argument = cmd_alternative[1]
|
||||||
|
break
|
||||||
if not cmdtuple:
|
if not cmdtuple:
|
||||||
# None of the alternatives match, go with the default one-word name
|
# None of the alternatives match, go with the default one-word name
|
||||||
cmdtuple = command_table.get_command_tuple(command.command_string)
|
cmdtuple = command_table.get_command_tuple(command.command_string)
|
||||||
|
|
@ -360,7 +379,7 @@ def command_table_lookup(command, command_table, eval_perms=True,
|
||||||
if test:
|
if test:
|
||||||
# Check if this is just a test.
|
# Check if this is just a test.
|
||||||
return True
|
return True
|
||||||
# Check locks
|
# Check uselocks
|
||||||
if neighbor and not neighbor.scriptlink.use_lock(command.source_object):
|
if neighbor and not neighbor.scriptlink.use_lock(command.source_object):
|
||||||
# send an locked error message only if lock_desc is defined
|
# send an locked error message only if lock_desc is defined
|
||||||
lock_msg = neighbor.get_attribute_value("use_lock_msg")
|
lock_msg = neighbor.get_attribute_value("use_lock_msg")
|
||||||
|
|
@ -387,27 +406,21 @@ def match_neighbor_ctables(command,test=False):
|
||||||
any commands.
|
any commands.
|
||||||
"""
|
"""
|
||||||
source_object = command.source_object
|
source_object = command.source_object
|
||||||
if source_object.location != None:
|
location = source_object.get_location()
|
||||||
neighbors = source_object.location.get_contents()
|
if location:
|
||||||
|
# get all objects, including the current room
|
||||||
|
neighbors = location.get_contents() + [location]
|
||||||
for neighbor in neighbors:
|
for neighbor in neighbors:
|
||||||
if command_table_lookup(command,
|
if command_table_lookup(command,
|
||||||
neighbor.scriptlink.command_table,
|
neighbor.scriptlink.command_table,
|
||||||
test=test, neighbor=neighbor):
|
test=test, neighbor=neighbor):
|
||||||
# Test for a use-lock.
|
|
||||||
# If there was a command match, set the scripted_obj attribute
|
# If there was a command match, set the scripted_obj attribute
|
||||||
# for the script parent to pick up.
|
# for the script parent to pick up.
|
||||||
if test:
|
if test:
|
||||||
return True
|
return True
|
||||||
command.scripted_obj = neighbor
|
command.scripted_obj = neighbor
|
||||||
return True
|
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
|
|
||||||
|
|
||||||
# No matches
|
# No matches
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,11 @@ def cmd_clist(command):
|
||||||
@clist
|
@clist
|
||||||
|
|
||||||
Lists all available channels in the game.
|
Lists all available channels in the game.
|
||||||
|
|
||||||
|
[[clist]]
|
||||||
|
|
||||||
|
This is the same as @clist - it shows all
|
||||||
|
available channels in game.
|
||||||
"""
|
"""
|
||||||
session = command.session
|
session = command.session
|
||||||
source_object = command.source_object
|
source_object = command.source_object
|
||||||
|
|
@ -260,7 +265,7 @@ def cmd_clist(command):
|
||||||
#s += "** End of Channel List **"
|
#s += "** End of Channel List **"
|
||||||
source_object.emit_to(s)
|
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")
|
||||||
|
GLOBAL_CMD_TABLE.add_command("clist", cmd_clist, help_category="Comms")
|
||||||
|
|
||||||
def cmd_cdestroy(command):
|
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
|
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
|
they own or control it. It does not show the user's name unless they
|
||||||
provide the /sendername switch.
|
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
|
source_object = command.source_object
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -765,7 +765,7 @@ def cmd_help(command):
|
||||||
|
|
||||||
# add the 'See also:' footer
|
# add the 'See also:' footer
|
||||||
topics = HelpEntry.objects.find_topicsuggestions(source_object,
|
topics = HelpEntry.objects.find_topicsuggestions(source_object,
|
||||||
topicstr)
|
topic.get_topicname())
|
||||||
if topics:
|
if topics:
|
||||||
if len(topics) > 5:
|
if len(topics) > 5:
|
||||||
topics = topics[:5]
|
topics = topics[:5]
|
||||||
|
|
|
||||||
|
|
@ -1000,7 +1000,6 @@ def cmd_dig(command):
|
||||||
room_parent = None
|
room_parent = None
|
||||||
exit_names = [None,None]
|
exit_names = [None,None]
|
||||||
exit_parents = [None,None]
|
exit_parents = [None,None]
|
||||||
exit_aliases = [[], []]
|
|
||||||
|
|
||||||
#deal with arguments
|
#deal with arguments
|
||||||
arg_list = args.split("=",1)
|
arg_list = args.split("=",1)
|
||||||
|
|
@ -1019,13 +1018,10 @@ def cmd_dig(command):
|
||||||
rarg = arg_list[1]
|
rarg = arg_list[1]
|
||||||
exits = rarg.split(",",1)
|
exits = rarg.split(",",1)
|
||||||
for ie, exi in enumerate(exits):
|
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:
|
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:
|
except ValueError:
|
||||||
exit_names[ie] = name_and_parent.strip()
|
exit_names[ie] = exi.strip()
|
||||||
|
|
||||||
#start creating things.
|
#start creating things.
|
||||||
if not room_name:
|
if not room_name:
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ DATABASE_HOST = ''
|
||||||
DATABASE_PORT = ''
|
DATABASE_PORT = ''
|
||||||
|
|
||||||
# How many words a single command name may have (e.g. 'push button' instead of 'pushbutton')
|
# 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_MAXLEN = 3
|
||||||
|
|
||||||
## Command aliases
|
## Command aliases
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ class EvenniaBasicObject(object):
|
||||||
for player in con_players:
|
for player in con_players:
|
||||||
retval +='\n\r%s' % (player.get_name(show_dbref=show_dbrefs),)
|
retval +='\n\r%s' % (player.get_name(show_dbref=show_dbrefs),)
|
||||||
if not con_things == []:
|
if not con_things == []:
|
||||||
retval += "\n\r%sContents:%s" % (ANSITable.ansi["hilite"],
|
retval += "\n\r%sYou see:%s" % (ANSITable.ansi["hilite"],
|
||||||
ANSITable.ansi["normal"])
|
ANSITable.ansi["normal"])
|
||||||
for thing in con_things:
|
for thing in con_things:
|
||||||
retval += '\n\r%s' % (thing.get_name(show_dbref=show_dbrefs),)
|
retval += '\n\r%s' % (thing.get_name(show_dbref=show_dbrefs),)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue