Fixed so reloading the server reconnects the proper sessions to the characters again.
This commit is contained in:
parent
eb1044d7a1
commit
707a21c7d7
5 changed files with 28 additions and 36 deletions
|
|
@ -27,16 +27,6 @@ from twisted.internet import protocol
|
|||
from twisted.internet.defer import Deferred
|
||||
from src.utils.utils import to_str, variable_from_module
|
||||
|
||||
# these are only needed on the server side, so we delay loading of them
|
||||
# so as to not have to load them on the portal too. Note: It's doubtful
|
||||
# if this really matters, considering many of the
|
||||
# protocols require import of django components (at least settings).
|
||||
#_ServerConfig = None
|
||||
#_ScriptDB = None
|
||||
#_PlayerDB = None
|
||||
#_ServerSession = None
|
||||
#_ = None #i18n hook
|
||||
|
||||
# communication bits
|
||||
|
||||
PCONN = chr(1) # portal session connect
|
||||
|
|
@ -61,8 +51,8 @@ def get_restart_mode(restart_file):
|
|||
|
||||
class AmpServerFactory(protocol.ServerFactory):
|
||||
"""
|
||||
This factory creates new AMPProtocol protocol instances to use for accepting
|
||||
connections from TCPServer.
|
||||
This factory creates the Server as a new AMPProtocol instance for accepting
|
||||
connections from the Portal.
|
||||
"""
|
||||
def __init__(self, server):
|
||||
"""
|
||||
|
|
@ -83,10 +73,7 @@ class AmpServerFactory(protocol.ServerFactory):
|
|||
|
||||
class AmpClientFactory(protocol.ReconnectingClientFactory):
|
||||
"""
|
||||
This factory creates new AMPProtocol protocol instances to use to connect
|
||||
to the MUD server. It also maintains the portal attribute
|
||||
on the ProxyService instance, which is used for piping input
|
||||
from Telnet to the MUD server.
|
||||
This factory creates an instance of the Portal, an AMPProtocol instances to use to connect
|
||||
"""
|
||||
# Initial reconnect delay in seconds.
|
||||
initialDelay = 1
|
||||
|
|
|
|||
|
|
@ -190,9 +190,6 @@ class Evennia(object):
|
|||
from src.objects.models import ObjectDB
|
||||
#from src.players.models import PlayerDB
|
||||
|
||||
# clear eventual lingering session storages
|
||||
ObjectDB.objects.clear_all_sessids()
|
||||
|
||||
#update eventual changed defaults
|
||||
self.update_defaults()
|
||||
|
||||
|
|
@ -209,6 +206,8 @@ class Evennia(object):
|
|||
SERVER_STARTSTOP_MODULE.at_server_reload_start()
|
||||
elif mode in ('reset', 'shutdown'):
|
||||
SERVER_STARTSTOP_MODULE.at_server_cold_start()
|
||||
# clear eventual lingering session storages
|
||||
ObjectDB.objects.clear_all_sessids()
|
||||
# always call this regardless of start type
|
||||
SERVER_STARTSTOP_MODULE.at_server_start()
|
||||
|
||||
|
|
@ -231,20 +230,6 @@ class Evennia(object):
|
|||
f.write(str(mode))
|
||||
return mode
|
||||
|
||||
#if mode == None:
|
||||
# f = open(SERVER_RESTART, 'r')
|
||||
# if os.path.exists(SERVER_RESTART) and 'True' == f.read():
|
||||
# mode = 'reload'
|
||||
# else:
|
||||
# mode = 'shutdown'
|
||||
# f.close()
|
||||
#else:
|
||||
# restart = mode in ('reload', 'reset')
|
||||
# f = open(SERVER_RESTART, 'w')
|
||||
# f.write(str(restart))
|
||||
# f.close()
|
||||
#return mode
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def shutdown(self, mode=None, _reactor_stopping=False):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ class ServerSession(Session):
|
|||
self.cmdset_storage = [settings.CMDSET_UNLOGGEDIN]
|
||||
self.cmdset.update(init_mode=True)
|
||||
return
|
||||
else:
|
||||
self.player.reconnect_session_to_character(self.sessid)
|
||||
|
||||
def session_login(self, player):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ class ServerSessionHandler(SessionHandler):
|
|||
_ScriptDB.objects.validate(init_mode=init_mode)
|
||||
_ServerConfig.objects.conf("server_restart_mode", delete=True)
|
||||
# announce the reconnection
|
||||
self.announce_all(_(" ... server restarted."))
|
||||
self.announce_all(_(" ... Server restarted."))
|
||||
|
||||
def portal_shutdown(self):
|
||||
"""
|
||||
|
|
@ -431,8 +431,8 @@ class PortalSessionHandler(SessionHandler):
|
|||
serversessions - dictionary {sessid:{property:value},...} describing the properties
|
||||
to sync on all sessions
|
||||
"""
|
||||
to_save = [sessid for sessid, syncdata in serversessions if sessid in self.sessions]
|
||||
to_delete = [sessid for sessid, syncdata in serversessions if sessid not in to_save]
|
||||
to_save = [sessid for sessid in serversessions if sessid in self.sessions]
|
||||
to_delete = [sessid for sessid in serversessions if sessid not in to_save]
|
||||
# save protocols
|
||||
for sessid in to_save:
|
||||
self.sessions[sessid].load_sync_data(serversessions[sessid])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue