Raised Python requirement to 2.6+. Some spurious work on the mdsp support.
This commit is contained in:
parent
14ed95ebfe
commit
96e95ca525
3 changed files with 109 additions and 18 deletions
|
|
@ -17,3 +17,77 @@ def testoob(character, *args, **kwargs):
|
||||||
"Simple test function"
|
"Simple test function"
|
||||||
print "Called testoob: %s" % val
|
print "Called testoob: %s" % val
|
||||||
return "testoob did stuff to the input string '%s'!" % val
|
return "testoob did stuff to the input string '%s'!" % val
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# MSDP_MAP is a standard suggestions for making it easy to create generic guis.
|
||||||
|
# this maps MSDP command names to Evennia commands found in OOB_FUNC_MODULE. It
|
||||||
|
# is up to these commands to return data on proper form.
|
||||||
|
MSDP_REPORTABLE = {
|
||||||
|
# General
|
||||||
|
"CHARACTER_NAME": "get_character_name",
|
||||||
|
"SERVER_ID": "get_server_id",
|
||||||
|
"SERVER_TIME": "get_server_time",
|
||||||
|
|
||||||
|
# Character
|
||||||
|
"AFFECTS": "char_affects",
|
||||||
|
"ALIGNMENT": "char_alignment",
|
||||||
|
"EXPERIENCE": "char_experience",
|
||||||
|
"EXPERIENCE_MAX": "char_experience_max",
|
||||||
|
"EXPERIENCE_TNL": "char_experience_tnl",
|
||||||
|
"HEALTH": "char_health",
|
||||||
|
"HEALTH_MAX": "char_health_max",
|
||||||
|
"LEVEL": "char_level",
|
||||||
|
"RACE": "char_race",
|
||||||
|
"CLASS": "char_class",
|
||||||
|
"MANA": "char_mana",
|
||||||
|
"MANA_MAX": "char_mana_max",
|
||||||
|
"WIMPY": "char_wimpy",
|
||||||
|
"PRACTICE": "char_practice",
|
||||||
|
"MONEY": "char_money",
|
||||||
|
"MOVEMENT": "char_movement",
|
||||||
|
"MOVEMENT_MAX": "char_movement_max",
|
||||||
|
"HITROLL": "char_hitroll",
|
||||||
|
"DAMROLL": "char_damroll",
|
||||||
|
"AC": "char_ac",
|
||||||
|
"STR": "char_str",
|
||||||
|
"INT": "char_int",
|
||||||
|
"WIS": "char_wis",
|
||||||
|
"DEX": "char_dex",
|
||||||
|
"CON": "char_con",
|
||||||
|
|
||||||
|
# Combat
|
||||||
|
"OPPONENT_HEALTH": "opponent_health",
|
||||||
|
"OPPONENT_HEALTH_MAX":"opponent_health_max",
|
||||||
|
"OPPONENT_LEVEL": "opponent_level",
|
||||||
|
"OPPONENT_NAME": "opponent_name",
|
||||||
|
|
||||||
|
# World
|
||||||
|
"AREA_NAME": "area_name",
|
||||||
|
"ROOM_EXITS": "area_room_exits",
|
||||||
|
"ROOM_NAME": "room_name",
|
||||||
|
"ROOM_VNUM": "room_dbref",
|
||||||
|
"WORLD_TIME": "world_time",
|
||||||
|
|
||||||
|
# Configurable variables
|
||||||
|
"CLIENT_ID": "client_id",
|
||||||
|
"CLIENT_VERSION": "client_version",
|
||||||
|
"PLUGIN_ID": "plugin_id",
|
||||||
|
"ANSI_COLORS": "ansi_colours",
|
||||||
|
"XTERM_256_COLORS": "xterm_256_colors",
|
||||||
|
"UTF_8": "utf_8",
|
||||||
|
"SOUND": "sound",
|
||||||
|
"MXP": "mxp",
|
||||||
|
|
||||||
|
# GUI variables
|
||||||
|
"BUTTON_1": "button1",
|
||||||
|
"BUTTON_2": "button2",
|
||||||
|
"BUTTON_3": "button3",
|
||||||
|
"BUTTON_4": "button4",
|
||||||
|
"BUTTON_5": "button5",
|
||||||
|
"GAUGE_1": "gauge1",
|
||||||
|
"GAUGE_2": "gauge2",
|
||||||
|
"GAUGE_3": "gauge3",
|
||||||
|
"GAUGE_4": "gauge4",
|
||||||
|
"GAUGE_5": "gauge5"}
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,13 @@ etc.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
from src.utils.utils import make_iter
|
from django.conf import settings
|
||||||
|
from src.utils.utils import make_iter, mod_import
|
||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
|
|
||||||
# variables
|
OOC_MODULE = mod_import(settings.OOB_FUNC_MODULE)
|
||||||
|
|
||||||
|
# MSDP-relevant telnet cmd/opt-codes
|
||||||
MSDP = chr(69)
|
MSDP = chr(69)
|
||||||
MSDP_VAR = chr(1)
|
MSDP_VAR = chr(1)
|
||||||
MSDP_VAL = chr(2)
|
MSDP_VAL = chr(2)
|
||||||
|
|
@ -23,6 +26,7 @@ MSDP_TABLE_CLOSE = chr(4)
|
||||||
MSDP_ARRAY_OPEN = chr(5)
|
MSDP_ARRAY_OPEN = chr(5)
|
||||||
MSDP_ARRAY_CLOSE = chr(6)
|
MSDP_ARRAY_CLOSE = chr(6)
|
||||||
|
|
||||||
|
# pre-compiled regexes
|
||||||
regex_array = re.compile(r"%s(.*?)%s%s(.*?)%s" % (MSDP_VAR, MSDP_VAL, MSDP_ARRAY_OPEN, MSDP_ARRAY_CLOSE)) # return 2-tuple
|
regex_array = re.compile(r"%s(.*?)%s%s(.*?)%s" % (MSDP_VAR, MSDP_VAL, MSDP_ARRAY_OPEN, MSDP_ARRAY_CLOSE)) # return 2-tuple
|
||||||
regex_table = re.compile(r"%s(.*?)%s%s(.*?)%s" % (MSDP_VAR, MSDP_VAL, MSDP_TABLE_OPEN, MSDP_TABLE_CLOSE)) # return 2-tuple (may be nested)
|
regex_table = re.compile(r"%s(.*?)%s%s(.*?)%s" % (MSDP_VAR, MSDP_VAL, MSDP_TABLE_OPEN, MSDP_TABLE_CLOSE)) # return 2-tuple (may be nested)
|
||||||
regex_varval = re.compile(r"%s(.*?)%s(.*?)" % (MSDP_VAR, MSDP_VAL)) # return 2-tuple
|
regex_varval = re.compile(r"%s(.*?)%s(.*?)" % (MSDP_VAR, MSDP_VAL)) # return 2-tuple
|
||||||
|
|
@ -44,7 +48,7 @@ class Msdp(object):
|
||||||
self.protocol.will(MSDP).addCallbacks(self.do_msdp, self.no_msdp)
|
self.protocol.will(MSDP).addCallbacks(self.do_msdp, self.no_msdp)
|
||||||
|
|
||||||
def no_msdp(self, option):
|
def no_msdp(self, option):
|
||||||
"No msdp"
|
"No msdp supported or wanted"
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def do_msdp(self, option):
|
def do_msdp(self, option):
|
||||||
|
|
@ -53,7 +57,6 @@ class Msdp(object):
|
||||||
"""
|
"""
|
||||||
self.protocol.protocol_flags['MSDP'] = True
|
self.protocol.protocol_flags['MSDP'] = True
|
||||||
|
|
||||||
|
|
||||||
def func_to_msdp(self, cmdname, data):
|
def func_to_msdp(self, cmdname, data):
|
||||||
"""
|
"""
|
||||||
handle return data from cmdname by converting it to
|
handle return data from cmdname by converting it to
|
||||||
|
|
@ -96,13 +99,20 @@ class Msdp(object):
|
||||||
msdp_string = MSDP_VAR + cmdname + MSDP_VAL + data
|
msdp_string = MSDP_VAR + cmdname + MSDP_VAL + data
|
||||||
return msdp_string
|
return msdp_string
|
||||||
|
|
||||||
|
# MSDP commands supported by Evennia
|
||||||
|
MSDP_COMMANDS = {"LIST": "msdp_list",
|
||||||
|
"REPORT":"mspd_report",
|
||||||
|
"RESET":"mspd_reset",
|
||||||
|
"SEND":"mspd_send",
|
||||||
|
"UNREPORT":"mspd_unreport"}
|
||||||
|
|
||||||
def msdp_to_func(self, data):
|
def msdp_to_func(self, data):
|
||||||
"""
|
"""
|
||||||
Handle a client's requested negotiation, converting
|
Handle a client's requested negotiation, converting
|
||||||
it into a function mapping
|
it into a function mapping.
|
||||||
|
|
||||||
OBS-this does not support receiving nested tables
|
This does not support receiving nested tables from the client
|
||||||
from the client at this point!
|
(and there is no real reason why it should).
|
||||||
"""
|
"""
|
||||||
tables = {}
|
tables = {}
|
||||||
arrays = {}
|
arrays = {}
|
||||||
|
|
@ -113,7 +123,21 @@ class Msdp(object):
|
||||||
for array in regex_array.findall(data):
|
for array in regex_array.findall(data):
|
||||||
arrays[array[0]] = dict(regex_varval(array[1]))
|
arrays[array[0]] = dict(regex_varval(array[1]))
|
||||||
variables = dict(regex_varval(regex_array.sub("", regex_table.sub("", data))))
|
variables = dict(regex_varval(regex_array.sub("", regex_table.sub("", data))))
|
||||||
print variables
|
ret = ""
|
||||||
|
if "LIST" in variables:
|
||||||
|
ret = self.msdp_cmd_list(variables["LIST"])
|
||||||
|
if "REPORT" in variables:
|
||||||
|
ret = self.msdp_cmd_report(*(variables["REPORT"],))
|
||||||
|
if "REPORT" in arrays:
|
||||||
|
ret = self.msdp_cmd_report(*arrays["REPORT"])
|
||||||
|
if "RESET" in variables:
|
||||||
|
ret = self.msdp_cmd_reset(*(variables["RESET"],))
|
||||||
|
if "RESET" in arrays:
|
||||||
|
ret = self.msdp_cmd_reset(*arrays["RESET"])
|
||||||
|
if "SEND" in variables:
|
||||||
|
ret = self.msdp_cmd_send((*variables["SEND"],))
|
||||||
|
if "SEND" in arrays:
|
||||||
|
ret = self.msdp_cmd_send(*arrays["SEND"])
|
||||||
|
|
||||||
|
|
||||||
# MSDP Commands
|
# MSDP Commands
|
||||||
|
|
@ -142,7 +166,7 @@ class Msdp(object):
|
||||||
else:
|
else:
|
||||||
return self.func_to_msdp("LIST", arg)
|
return self.func_to_msdp("LIST", arg)
|
||||||
|
|
||||||
def msdp_cmd_report(self, arg):
|
def msdp_cmd_report(self, *arg):
|
||||||
"""
|
"""
|
||||||
The report command instructs the server to start reporting a
|
The report command instructs the server to start reporting a
|
||||||
reportable variable to the client.
|
reportable variable to the client.
|
||||||
|
|
@ -157,7 +181,7 @@ class Msdp(object):
|
||||||
Unreport a previously reported variable
|
Unreport a previously reported variable
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.MSDP_REPORTABLE[arg](eport=False)
|
self.MSDP_REPORTABLE[arg](report=False)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.logger.log_trace()
|
self.logger.log_trace()
|
||||||
|
|
||||||
|
|
@ -185,13 +209,6 @@ class Msdp(object):
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
MSDP_COMMANDS = {
|
|
||||||
"LIST": "msdp_list",
|
|
||||||
"REPORT":"mspd_report",
|
|
||||||
"RESET":"mspd_reset",
|
|
||||||
"SEND":"mspd_send",
|
|
||||||
"UNREPORT":"mspd_unreport"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# MSDP_MAP is a standard suggestions for making it easy to create generic guis.
|
# MSDP_MAP is a standard suggestions for making it easy to create generic guis.
|
||||||
|
|
|
||||||
|
|
@ -496,7 +496,7 @@ def check_evennia_dependencies():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# defining the requirements
|
# defining the requirements
|
||||||
python_min = '2.5'
|
python_min = '2.6'
|
||||||
twisted_min = '10.0'
|
twisted_min = '10.0'
|
||||||
django_min = '1.2'
|
django_min = '1.2'
|
||||||
south_min = '0.7'
|
south_min = '0.7'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue