import sys
import logging
import pyramid.httpexceptions
+import pyramid.url
import re
from colorsys import rgb_to_hls, hls_to_rgb
from cgi import escape as html_escape
log = logging.getLogger(__name__)
+# Map of old weapons codes to new ones
+weapon_map = {
+ "grenadelauncher": "mortar",
+ "laser": "blaster",
+ "minstanex": "vaporizer",
+ "nex": "vortex",
+ "rocketlauncher": "devastator",
+ "uzi": "machinegun",
+}
+
+
# Map of special chars to ascii from Darkplace's console.c.
_qfont_ascii_table = [
'\0', '#', '#', '#', '#', '.', '#', '#',
u'\u005F', u'\u2747', u'\u2020', u'\u00B7',
u'\U0001F52B', u'\u0020', u'\u0020', u'\u25A0',
u'\u2022', u'\u2192', u'\u2748', u'\u2748',
- u'\u005B', u'\u005D', u'\U0001F47D', u'\U0001F60F',
+ u'\u005B', u'\u005D', u'\U0001F47D', u'\U0001F603',
u'\U0001F61E', u'\U0001F635', u'\U0001F615', u'\U0001F60A',
u'\u00AB', u'\u00BB', u'\u2022', u'\u203E',
u'\u2748', u'\u25AC', u'\u25AC', u'\u25AC',
u'\u00A1', u'\u004F', u'\u0055', u'\u0049',
u'\u0043', u'\u00A9', u'\u00AE', u'\u25A0',
u'\u00BF', u'\u25B6', u'\u2748', u'\u2748',
- u'\u2772', u'\u2773', u'\U0001F47D', u'\U0001F60F',
+ u'\u2772', u'\u2773', u'\U0001F47D', u'\U0001F603',
u'\U0001F61E', u'\U0001F635', u'\U0001F615', u'\U0001F60A',
u'\u00AB', u'\u00BB', u'\u2747', u'\u0078',
u'\u2748', u'\u2014', u'\u2014', u'\u2014',
_contrast_threshold = 0.5
-def qfont_decode(qstr='', for_html=False):
+def qfont_decode(qstr='', glyph_translation=False):
""" Convert the qfont characters in a string to ascii.
- for_html - determines whether to convert the unicode characters to
+ glyph_translation - determines whether to convert the unicode characters to
their ascii counterparts (if False, the default) or to
the mapped glyph in the Xolonium font (if True).
"""
chars = []
for c in qstr:
if u'\ue000' <= c <= u'\ue0ff':
- if for_html:
+ if glyph_translation:
c = _qfont_unicode_glyphs[ord(c) - 0xe000]
else:
c = _qfont_ascii_table[ord(c) - 0xe000]
def html_colors(qstr='', limit=None):
- qstr = html_escape(qfont_decode(qstr, for_html=True))
+ qstr = html_escape(qfont_decode(qstr, glyph_translation=True))
qstr = qstr.replace('^^', '^')
if limit is not None and limit > 0:
def page_url(page):
- return current_route_url(request, page=page, _query=request.GET)
+ return pyramid.url.current_route_url(request, page=page, _query=request.GET)
def pretty_date(time=False):