More fixes and cleanup in wake of ic/ooc changes.
This commit is contained in:
parent
86f76d0d08
commit
3e8b43d222
9 changed files with 66 additions and 40 deletions
|
|
@ -190,7 +190,7 @@ class OOCCmdSetCharGen(OOCCmdSet):
|
||||||
"""
|
"""
|
||||||
def at_cmdset_creation(self):
|
def at_cmdset_creation(self):
|
||||||
"Install everything from the default set, then overload"
|
"Install everything from the default set, then overload"
|
||||||
#super(OOCCmdSetExtended, self).at_cmdset_creation()
|
super(OOCCmdSetCharGen, self).at_cmdset_creation()
|
||||||
self.add(CmdOOCLook())
|
self.add(CmdOOCLook())
|
||||||
self.add(CmdOOCCharacterCreate())
|
self.add(CmdOOCCharacterCreate())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ from src.commands.cmdset import CmdSet
|
||||||
from src.commands.default import cmdset_default, cmdset_unloggedin, cmdset_ooc
|
from src.commands.default import cmdset_default, cmdset_unloggedin, cmdset_ooc
|
||||||
from game.gamesrc.commands.basecommand import Command
|
from game.gamesrc.commands.basecommand import Command
|
||||||
|
|
||||||
from contrib import menusystem, lineeditor
|
#from contrib import menusystem, lineeditor
|
||||||
#from contrib import misc_commands
|
#from contrib import misc_commands
|
||||||
from contrib import chargen
|
#from contrib import chargen, menu_login
|
||||||
|
|
||||||
class DefaultCmdSet(cmdset_default.DefaultCmdSet):
|
class DefaultCmdSet(cmdset_default.DefaultCmdSet):
|
||||||
"""
|
"""
|
||||||
|
|
@ -48,7 +48,7 @@ class DefaultCmdSet(cmdset_default.DefaultCmdSet):
|
||||||
#
|
#
|
||||||
# any commands you add below will overload the default ones.
|
# any commands you add below will overload the default ones.
|
||||||
#
|
#
|
||||||
self.add(menusystem.CmdMenuTest())
|
#self.add(menusystem.CmdMenuTest())
|
||||||
#self.add(lineeditor.CmdEditor())
|
#self.add(lineeditor.CmdEditor())
|
||||||
#self.add(misc_commands.CmdQuell())
|
#self.add(misc_commands.CmdQuell())
|
||||||
|
|
||||||
|
|
@ -92,8 +92,7 @@ class OOCCmdSet(cmdset_ooc.OOCCmdSet):
|
||||||
|
|
||||||
#
|
#
|
||||||
# any commands you add below will overload the default ones.
|
# any commands you add below will overload the default ones.
|
||||||
#
|
#
|
||||||
self.add(chargen.OOCCmdSetCharGen)
|
|
||||||
|
|
||||||
class BaseCmdSet(CmdSet):
|
class BaseCmdSet(CmdSet):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -99,37 +99,13 @@ class Object(BaseObject):
|
||||||
class Character(BaseCharacter):
|
class Character(BaseCharacter):
|
||||||
"""
|
"""
|
||||||
This is the default object created for a new user connecting - the
|
This is the default object created for a new user connecting - the
|
||||||
in-game player character representation. Note that it's important
|
in-game player character representation. The basetype_setup always
|
||||||
that at_object_creation sets up an script that adds the Default
|
assigns the default_cmdset as a fallback to objects of this type.
|
||||||
command set whenever the player logs in - otherwise they won't be
|
The default hooks also hide the character object away (by moving
|
||||||
able to use any commands!
|
it to a Null location whenever the player logs off (otherwise the
|
||||||
|
character would remain in the world, "headless" so to say).
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
def at_disconnect(self):
|
|
||||||
"""
|
|
||||||
We stove away the character when logging off, otherwise the character object will
|
|
||||||
remain in the room also after the player logged off ("headless", so to say).
|
|
||||||
"""
|
|
||||||
if self.location: # have to check, in case of multiple connections closing
|
|
||||||
self.location.msg_contents("%s has left the game." % self.name)
|
|
||||||
self.db.prelogout_location = self.location
|
|
||||||
self.location = None
|
|
||||||
|
|
||||||
def at_post_login(self):
|
|
||||||
"""
|
|
||||||
This recovers the character again after having been "stoved away" at disconnect.
|
|
||||||
"""
|
|
||||||
if self.db.prelogout_location:
|
|
||||||
# try to recover
|
|
||||||
self.location = self.db.prelogout_location
|
|
||||||
if self.location == None:
|
|
||||||
# make sure location is never None (home should always exist)
|
|
||||||
self.location = self.home
|
|
||||||
# save location again to be sure
|
|
||||||
self.db.prelogout_location = self.location
|
|
||||||
|
|
||||||
self.location.msg_contents("%s has entered the game." % self.name, exclude=[self])
|
|
||||||
self.location.at_object_receive(self, self.location)
|
|
||||||
|
|
||||||
class Room(BaseRoom):
|
class Room(BaseRoom):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -685,6 +685,15 @@ class CmdIC(MuxCommand):
|
||||||
if caller.swap_character(new_character):
|
if caller.swap_character(new_character):
|
||||||
new_character.msg("\n{gYou become {c%s{n.\n" % new_character.name)
|
new_character.msg("\n{gYou become {c%s{n.\n" % new_character.name)
|
||||||
caller.db.last_puppet = old_char
|
caller.db.last_puppet = old_char
|
||||||
|
if not new_character.location:
|
||||||
|
# this might be due to being hidden away at logout; check
|
||||||
|
loc = new_character.db.prelogout_location
|
||||||
|
if not loc: # still no location; use home
|
||||||
|
loc = new_character.home
|
||||||
|
new_character.location = loc
|
||||||
|
if new_character.location:
|
||||||
|
new_character.location.msg_contents("%s has entered the game." % new_character.key, exclude=[new_character])
|
||||||
|
new_character.location.at_object_receive(new_character, new_character.location)
|
||||||
new_character.execute_cmd("look")
|
new_character.execute_cmd("look")
|
||||||
else:
|
else:
|
||||||
caller.msg("{rYou cannot become {C%s{n." % new_character.name)
|
caller.msg("{rYou cannot become {C%s{n." % new_character.name)
|
||||||
|
|
@ -720,11 +729,15 @@ class CmdOOC(MuxCommand):
|
||||||
return
|
return
|
||||||
|
|
||||||
caller.db.last_puppet = caller.character
|
caller.db.last_puppet = caller.character
|
||||||
|
# save location as if we were disconnecting from the game entirely.
|
||||||
|
if caller.character.location:
|
||||||
|
caller.character.location.msg_contents("%s has left the game." % caller.character.key, exclude=[caller.character])
|
||||||
|
caller.character.db.prelogout_location = caller.character.location
|
||||||
|
caller.character.location = None
|
||||||
|
|
||||||
# disconnect
|
# disconnect
|
||||||
caller.character.player = None
|
caller.character.player = None
|
||||||
caller.character = None
|
caller.character = None
|
||||||
|
|
||||||
|
|
||||||
caller.msg("\n{GYou go OOC.{n\n")
|
caller.msg("\n{GYou go OOC.{n\n")
|
||||||
caller.execute_cmd("look")
|
caller.execute_cmd("look")
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ class ObjectDB(TypedObject):
|
||||||
string += "%s is not a valid home."
|
string += "%s is not a valid home."
|
||||||
self.msg(string % home)
|
self.msg(string % home)
|
||||||
logger.log_trace(string)
|
logger.log_trace(string)
|
||||||
raise
|
#raise
|
||||||
self.save()
|
self.save()
|
||||||
#@home.deleter
|
#@home.deleter
|
||||||
def home_del(self):
|
def home_del(self):
|
||||||
|
|
|
||||||
|
|
@ -409,6 +409,34 @@ class Character(Object):
|
||||||
def at_after_move(self, source_location):
|
def at_after_move(self, source_location):
|
||||||
"Default is to look around after a move."
|
"Default is to look around after a move."
|
||||||
self.execute_cmd('look')
|
self.execute_cmd('look')
|
||||||
|
|
||||||
|
def at_disconnect(self):
|
||||||
|
"""
|
||||||
|
We stove away the character when logging off, otherwise the character object will
|
||||||
|
remain in the room also after the player logged off ("headless", so to say).
|
||||||
|
"""
|
||||||
|
if self.location: # have to check, in case of multiple connections closing
|
||||||
|
self.location.msg_contents("%s has left the game." % self.name, exclude=[self])
|
||||||
|
self.db.prelogout_location = self.location
|
||||||
|
self.location = None
|
||||||
|
|
||||||
|
def at_post_login(self):
|
||||||
|
"""
|
||||||
|
This recovers the character again after having been "stoved away" at disconnect.
|
||||||
|
"""
|
||||||
|
if self.db.prelogout_location:
|
||||||
|
# try to recover
|
||||||
|
self.location = self.db.prelogout_location
|
||||||
|
if self.location == None:
|
||||||
|
# make sure location is never None (home should always exist)
|
||||||
|
self.location = self.home
|
||||||
|
# save location again to be sure
|
||||||
|
self.db.prelogout_location = self.location
|
||||||
|
|
||||||
|
self.location.msg_contents("%s has entered the game." % self.name, exclude=[self])
|
||||||
|
self.location.at_object_receive(self, self.location)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Base Room object
|
# Base Room object
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,7 @@ def create_objects():
|
||||||
character_typeclass=character_typeclass)
|
character_typeclass=character_typeclass)
|
||||||
|
|
||||||
if not god_character:
|
if not god_character:
|
||||||
print _("#1 could not be created. Check the Player/Character typeclass for bugs.")
|
raise Exception(_("#1 could not be created. Check the Player/Character typeclass for bugs."))
|
||||||
raise Exception
|
|
||||||
|
|
||||||
god_character.id = 1
|
god_character.id = 1
|
||||||
god_character.db.desc = _('This is User #1.')
|
god_character.db.desc = _('This is User #1.')
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,12 @@ AT_INITIAL_SETUP_HOOK_MODULE = "game.gamesrc.world.at_initial_setup"
|
||||||
###################################################
|
###################################################
|
||||||
# Default command sets
|
# Default command sets
|
||||||
###################################################
|
###################################################
|
||||||
|
# Note that with the exception of the unloggedin set (which is not
|
||||||
|
# stored anywhere), changing these paths will only affect NEW created
|
||||||
|
# characters, not those already in play. So if you plan to change
|
||||||
|
# this, it's recommended you do it on a pristine setup only. To
|
||||||
|
# dynamically add new commands to a running server, extend/overload
|
||||||
|
# these existing sets instead.
|
||||||
|
|
||||||
# Command set used before player has logged in
|
# Command set used before player has logged in
|
||||||
CMDSET_UNLOGGEDIN = "game.gamesrc.commands.basecmdset.UnloggedinCmdSet"
|
CMDSET_UNLOGGEDIN = "game.gamesrc.commands.basecmdset.UnloggedinCmdSet"
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ def create_object(typeclass, key=None, location=None,
|
||||||
# this will either load the typeclass or the default one
|
# this will either load the typeclass or the default one
|
||||||
new_object = new_db_object.typeclass
|
new_object = new_db_object.typeclass
|
||||||
|
|
||||||
|
|
||||||
if not object.__getattribute__(new_db_object, "is_typeclass")(typeclass, exact=True):
|
if not object.__getattribute__(new_db_object, "is_typeclass")(typeclass, exact=True):
|
||||||
# this will fail if we gave a typeclass as input and it still gave us a default
|
# this will fail if we gave a typeclass as input and it still gave us a default
|
||||||
SharedMemoryModel.delete(new_db_object)
|
SharedMemoryModel.delete(new_db_object)
|
||||||
|
|
@ -105,6 +106,10 @@ def create_object(typeclass, key=None, location=None,
|
||||||
# perform a move_to in order to display eventual messages.
|
# perform a move_to in order to display eventual messages.
|
||||||
if home:
|
if home:
|
||||||
new_object.home = home
|
new_object.home = home
|
||||||
|
else:
|
||||||
|
new_object.home = settings.CHARACTER_DEFAULT_HOME
|
||||||
|
|
||||||
|
|
||||||
if location:
|
if location:
|
||||||
new_object.move_to(location, quiet=True)
|
new_object.move_to(location, quiet=True)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue