Skip to content

Commit

Permalink
fixed command arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
argoneuscze committed Dec 24, 2016
1 parent 588362d commit 9359ce3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
10 changes: 6 additions & 4 deletions server/aoprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,13 @@ def net_cmd_ct(self, args):
if self.client.name == '':
self.client.name = args[0]
if args[1].startswith('/'):
spl = args[1].split()
cmd = spl[0][1:]
args = spl[1:]
spl = args[1][1:].split(' ', 1)
cmd = spl[0]
arg = ''
if len(spl) == 2:
arg = spl[1][:256]
try:
getattr(commands, 'ooc_cmd_{}'.format(cmd))(self.client, args)
getattr(commands, 'ooc_cmd_{}'.format(cmd))(self.client, arg)
except AttributeError:
self.client.send_host_message('Invalid command.')
except (ClientError, AreaError, ArgumentError, ServerError) as ex:
Expand Down
18 changes: 9 additions & 9 deletions server/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
from server.exceptions import ClientError, ServerError, ArgumentError


def ooc_cmd_switch(client, args):
if len(args) == 0:
def ooc_cmd_switch(client, arg):
if len(arg) == 0:
raise ArgumentError('You must specify a character name.')
try:
cid = client.server.get_char_id_by_name(' '.join(args))
cid = client.server.get_char_id_by_name(arg)
except ServerError:
raise
try:
Expand All @@ -32,13 +32,13 @@ def ooc_cmd_switch(client, args):
client.send_host_message('Character changed.')


def ooc_cmd_g(client, args):
if len(args) == 0:
def ooc_cmd_g(client, arg):
if len(arg) == 0:
raise ArgumentError("Can't send an empty message.")
client.server.broadcast_global(client, ' '.join(args))
client.server.broadcast_global(client, arg)


def ooc_cmd_need(client, args):
if len(args) == 0:
def ooc_cmd_need(client, arg):
if len(arg) == 0:
raise ArgumentError("You must specify what you need.")
client.server.broadcast_need(client, ' '.join(args))
client.server.broadcast_need(client, arg)

0 comments on commit 9359ce3

Please sign in to comment.