mirror of
https://github.com/evennia/evennia.git
synced 2026-04-06 16:44:08 +02:00
Getting ready for ANSI handling, some SQLite3 optimizations (hopefully).
This commit is contained in:
parent
ec2e39fa3e
commit
c66c93ad0b
6 changed files with 35 additions and 11 deletions
|
|
@ -36,11 +36,19 @@ ansi["back_magenta"] = "\033[45m"
|
|||
ansi["back_cyan"] = "\033[46m"
|
||||
ansi["back_white"] = "\033[47m"
|
||||
|
||||
def parse_ansi(string):
|
||||
# Formatting Characters
|
||||
ansi["return"] = "\n\r"
|
||||
ansi["tab"] = "\t"
|
||||
ansi["space"] = " "
|
||||
|
||||
def parse_ansi(string, strip_ansi=False):
|
||||
"""
|
||||
Parses a string, subbing color codes as needed.
|
||||
"""
|
||||
ansi_subs = [
|
||||
(r'%r', ansi["return"]),
|
||||
(r'%t', ansi["tab"]),
|
||||
(r'%b', ansi["space"]),
|
||||
(r'%cf', ansi["blink"]),
|
||||
(r'%ci', ansi["inverse"]),
|
||||
(r'%ch', ansi["hilite"]),
|
||||
|
|
@ -65,6 +73,9 @@ def parse_ansi(string):
|
|||
|
||||
for sub in ansi_subs:
|
||||
p = re.compile(sub[0], re.DOTALL)
|
||||
string = p.sub(sub[1], string)
|
||||
if strip_ansi:
|
||||
string = p.sub("", string)
|
||||
else:
|
||||
string = p.sub(sub[1], string)
|
||||
|
||||
print '%s%s' % (string, ansi["normal"])
|
||||
return '%s%s' % (string, ansi["normal"])
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ class Attribute(models.Model):
|
|||
example, a drink container needs to store its fill level, whereas an exit
|
||||
needs to store its open/closed/locked/unlocked state. These are done via
|
||||
attributes, rather than making different classes for each object type and
|
||||
storing them directly. The added benefit is that we can add/remove attributes
|
||||
on the fly as we like.
|
||||
storing them directly. The added benefit is that we can add/remove
|
||||
attributes on the fly as we like.
|
||||
"""
|
||||
name = models.CharField(maxlength=255)
|
||||
value = models.CharField(maxlength=255)
|
||||
|
|
@ -33,6 +33,7 @@ class Object(models.Model):
|
|||
modules or sub-classing.
|
||||
"""
|
||||
name = models.CharField(maxlength=255)
|
||||
ansi_name = models.CharField(maxlength=255)
|
||||
owner = models.ForeignKey('self', related_name="obj_owner", blank=True, null=True)
|
||||
zone = models.ForeignKey('self', related_name="obj_zone", blank=True, null=True)
|
||||
home = models.ForeignKey('self', related_name="obj_home", blank=True, null=True)
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ def cmd_examine(cdat):
|
|||
|
||||
for obj in target_obj.get_contents():
|
||||
if obj.is_player:
|
||||
con_players.append(obj)
|
||||
con_players.append(obj)
|
||||
elif obj.is_exit:
|
||||
con_exits.append(obj)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -47,12 +47,10 @@ def get_nextfree_dbnum():
|
|||
nextfree = Object.objects.filter(type__exact=6)
|
||||
if nextfree:
|
||||
# We've got at least one garbage object to recycle.
|
||||
print 'GARB'
|
||||
return nextfree[0]
|
||||
else:
|
||||
# No garbage to recycle, find the highest dbnum and increment it
|
||||
# for our next free.
|
||||
print 'NOTGARB'
|
||||
return int(Object.objects.order_by('-id')[0].id + 1)
|
||||
|
||||
def global_object_name_search(ostring):
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ def time_format(seconds, style=0):
|
|||
# We'll just use integer math, no need for decimal precision.
|
||||
seconds = int(seconds)
|
||||
|
||||
days = seconds / 86400
|
||||
days = seconds / 86400
|
||||
seconds -= days * 86400
|
||||
hours = seconds / 3600
|
||||
hours = seconds / 3600
|
||||
seconds -= hours * 3600
|
||||
minutes = seconds / 60
|
||||
minutes = seconds / 60
|
||||
seconds -= minutes * 60
|
||||
|
||||
if style is 0:
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import functions_general
|
|||
import global_defines
|
||||
import session_mgr
|
||||
import gameconf
|
||||
import settings
|
||||
|
||||
class Server(dispatcher):
|
||||
"""
|
||||
|
|
@ -21,6 +22,8 @@ class Server(dispatcher):
|
|||
self.game_running = True
|
||||
|
||||
# Wipe our temporary flags on all of the objects.
|
||||
if settings.DATABASE_ENGINE == "sqlite3":
|
||||
self.sqlite3_prep()
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("UPDATE objects_object SET nosave_flags=''")
|
||||
|
||||
|
|
@ -63,6 +66,17 @@ class Server(dispatcher):
|
|||
print 'Connection:', str(session)
|
||||
print 'Sessions active:', len(session_mgr.get_session_list())
|
||||
|
||||
def sqlite3_prep(self):
|
||||
"""
|
||||
Optimize some SQLite stuff at startup since we can't save it to the
|
||||
database.
|
||||
"""
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("PRAGMA cache_size=10000")
|
||||
cursor.execute("PRAGMA synchronous=OFF")
|
||||
cursor.execute("PRAGMA count_changes=OFF")
|
||||
cursor.execute("PRAGMA temp_store=2")
|
||||
|
||||
"""
|
||||
BEGIN GENERAL METHODS
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue