More re-arranging to make things more closely resemble MUX/MUSH directory structure. Reason we're doing this is to begin the emergence of a separation of server code from game-specific stuff (called a driver by some codebases like LPMud).

Ideally game developers don't touch the server code, they just play within the game directory, which will contain all of their script parents and stuff.

NOTE: I may have broken the Linux/Unix start script. I am not able to boot back into Linux at the moment due to some testing going on, so if anyone could take a moment to tell me one way or another, I'd appreciate it.

NOTE: You'll need to move your evennia.db3 file into the game directory if you're using sqlite.
This commit is contained in:
Greg Taylor 2008-12-15 03:37:30 +00:00
parent 66a529ba84
commit 01db5700e8
11 changed files with 20 additions and 110 deletions

View file

@ -82,7 +82,7 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../
INPUT = ../../
FILE_PATTERNS = *.c \
*.cc \
*.cxx \

0
evennia.vhost.apache → docs/evennia.vhost.apache Executable file → Normal file
View file

0
game/__init__.py Normal file
View file

1
game/settings.py Normal file
View file

@ -0,0 +1 @@
from src.config_defaults import *

View file

@ -5,12 +5,12 @@ rem NOTE: This _MUST_ be launched with the Twisted environment variables
rem set. It is recommended that you launch Twisted Command Prompt to do so.
rem ------------------------------------------------------------------------
set DJANGO_SETTINGS_MODULE=settings
set PYTHONPATH=.
set DJANGO_SETTINGS_MODULE=game.settings
set PYTHONPATH=..
echo Starting Evennia...
rem ------------------------------------------------------------------------
rem We're only going to run in interactive mode until we've had more time to
rem make sure things work as expected on Windows.
rem ------------------------------------------------------------------------
twistd -oy --logfile=- --python=src/server.py
twistd -oy --logfile=- --python=../src/server.py

11
startup.sh → game/startup.sh Executable file → Normal file
View file

@ -14,22 +14,23 @@
init () {
## Sets environmental variables and preps the logs.
export DJANGO_SETTINGS_MODULE="settings"
BASE_PATH=`python -c "import settings; print settings.BASE_PATH"`
mv -f $BASE_PATH/logs/evennia.log $BASE_PATH/logs/evennia.logs.old
export PYTHON_PATH=".."
export DJANGO_SETTINGS_MODULE="game.settings"
GAME_DIR=`python -c "import settings; print settings.GAME_DIR"`
mv -f $GAME_DIR/logs/evennia.log $GAME_DIR/logs/evennia.logs.old
}
startup_interactive() {
## Starts the server in interactive mode.
init
echo "Starting in interactive mode..."
twistd -n --logfile=logs/evennia.log --python=src/server.py
twistd -n --logfile=logs/evennia.log --python=../src/server.py
}
startup_daemon() {
## Starts the server in daemon mode.
init
twistd --logfile=logs/evennia.log --python=src/server.py
twistd --logfile=logs/evennia.log --python=../src/server.py
}
stop_server() {

View file

@ -1,5 +0,0 @@
"""
Reloader module for handling @reload.
"""
from managers import ReloadManager as manager

View file

@ -1,27 +0,0 @@
"""
Configuration file for the reload system to add custom
modules to be reloaded at @reload.
"""
# All of these are reloaded after the built-in system modules and default
# model modules are reloaded.
# These are custom modules that have classes requiring state-saving.
# These modules are reloaded before those in no_cache.
cache = {
# This should be a dict of lists of tuples
# with the module name as a key, a list of tuples
# with the class name as the first element of the
# tuple, and True or False if this is a model
# for the database, like so:
#
# 'modulename' : [ ('ModelA', True), ('ClassA', False) ],
# 'anothermod' : [ ('ClassB', False), ('ClassC', False) ],
}
# This is a list of modules that need to be reloaded at @reload. There
# is no state-saving, and these are reloaded after those cached above.
no_cache = [
# 'modulename',
# 'anothermod',
]

View file

@ -1,51 +0,0 @@
import functions_general
class ReloadManager(object):
objects_cache = {}
failed = []
models = {}
def __init__(self, server):
self.server = server
def do_cache(self):
for module, info in self.models.iteritems():
module_obj = __import__(module)
for ituple in info:
mclass = getattr(module_obj, info[0])
for instance in mclass.__instances__():
instance.cache(self, do_save=ituple[1])
def do_reload(self):
self.do_cache()
self.server.reload()
self.reload_objects()
def cache_object(self, obj):
obj_dict = {}
for key, value in obj.__dict__.iteritems():
if not callable(obj[key]):
obj_dict[key] = value
self.objects_cache[obj] = obj_dict
def reload_objects(self):
for obj, cache in self.objects_cache.iteritems():
try:
obj.reload(cache)
except:
functions_general.log_errmsg("Failed to reload cache for object: %s." % (obj,))
self.failed.append(obj)
raise
self.objects_cache = {}
for obj in self.failed:
try:
obj.__dict__.update(cache)
except:
functions_general.log_errmsg("Failed to update object %s, giving up." %s (obj,))
raise
self.failed = []

25
settings.py → src/config_defaults.py Executable file → Normal file
View file

@ -2,10 +2,8 @@
Master configuration file for Evennia.
NOTE: NO MODIFICATIONS SHOULD BE MADE TO THIS FILE! All settings changes should
be done by copy-pasting the variable and its value to a new file (if it doesn't
already exist) called local_settings.py and changed there. Anything in the
local_settings.py file will override what is seen in settings.py by the
import at the end of this file.
be done by copy-pasting the variable and its value to your game directory's
settings.py file.
"""
import os
@ -30,7 +28,10 @@ ADMINS = (
MANAGERS = ADMINS
# The path that contains this settings.py file (no trailing slash).
BASE_PATH = os.path.abspath(os.path.split(__file__)[0])
BASE_PATH = os.path.join(os.path.abspath(os.path.split(__file__)[0]), '..')
# Path to the game directory (containing the database file if using sqlite).
GAME_DIR = os.path.join(BASE_PATH, 'game')
# Absolute path to the directory that holds media (no trailing slash).
# Example: "/home/media/media.lawrence.com"
@ -43,7 +44,7 @@ SCRIPT_ROOT = '%s/src/scripts' % (BASE_PATH)
# 'postgresql', 'mysql', 'mysql_old', 'sqlite3' or 'ado_mssql'.
DATABASE_ENGINE = 'sqlite3'
# Database name, or path to DB file if using sqlite3.
DATABASE_NAME = '%s/evennia.db3' % (BASE_PATH)
DATABASE_NAME = os.path.join(GAME_DIR, 'evennia.db3')
# Unused for sqlite3
DATABASE_USER = ''
# Unused for sqlite3
@ -181,14 +182,4 @@ try:
import django_extensions
INSTALLED_APPS = INSTALLED_APPS + ('django_extensions',)
except ImportError:
pass
"""
Importing everything from local_settings.py overrides the settings in this
file with the settings specified in local_settings.py. Any configuration
changes should happen in local_settings.py rather than this file.
"""
try:
from local_settings import *
except ImportError:
pass
pass

View file

@ -7,7 +7,7 @@ interaction with actual script methods should happen via calls to Objects.
import os
from traceback import format_exc
import settings
from django.conf import settings
from src import logger
# A dictionary with keys equivalent to the script's name and values that