mirror of
https://github.com/evennia/evennia.git
synced 2026-03-22 15:56:30 +01:00
Removed stale remnant of PlayerChannelConnection from comm manager.
This commit is contained in:
parent
c73e013459
commit
2cc4315941
3 changed files with 7 additions and 121 deletions
|
|
@ -302,49 +302,6 @@ class ChannelDBManager(TypedObjectManager):
|
|||
"""
|
||||
return player.dbobj.subscription_set.all()
|
||||
|
||||
|
||||
# def del_channel(self, channelkey):
|
||||
# """
|
||||
# Delete channel matching channelkey.
|
||||
# Also cleans up channelhandler.
|
||||
# """
|
||||
# channels = self.filter(db_key__iexact=channelkey)
|
||||
# if not channels:
|
||||
# # no aliases allowed for deletion.
|
||||
# return False
|
||||
# for channel in channels:
|
||||
# channel.delete()
|
||||
# from src.comms.channelhandler import CHANNELHANDLER
|
||||
# CHANNELHANDLER.update()
|
||||
# return None
|
||||
|
||||
# def get_all_connections(self, channel, online=False):
|
||||
# """
|
||||
# Return the connections of all players listening
|
||||
# to this channel. If Online is true, it only returns
|
||||
# connected players.
|
||||
# """
|
||||
# global _SESSIONS
|
||||
# if not _SESSIONS:
|
||||
# from src.server.sessionhandler import SESSIONS as _SESSIONS
|
||||
#
|
||||
# PlayerChannelConnection = ContentType.objects.get(app_label="comms",
|
||||
# model="playerchannelconnection").model_class()
|
||||
# players = []
|
||||
# if online:
|
||||
# session_list = _SESSIONS.get_sessions()
|
||||
# unique_online_users = set(sess.uid for sess in session_list if sess.logged_in)
|
||||
# online_players = (sess.get_player() for sess in session_list if sess.uid in unique_online_users)
|
||||
# for player in online_players:
|
||||
# players.extend(PlayerChannelConnection.objects.filter(
|
||||
# db_player=player.dbobj, db_channel=channel.dbobj))
|
||||
# else:
|
||||
# players.extend(PlayerChannelConnection.objects.get_all_connections(channel))
|
||||
#
|
||||
# external_connections = ExternalChannelConnection.objects.get_all_connections(channel)
|
||||
#
|
||||
# return itertools.chain(players, external_connections)
|
||||
|
||||
@returns_typeclass_list
|
||||
def channel_search(self, ostring, exact=True):
|
||||
"""
|
||||
|
|
@ -378,70 +335,3 @@ class ChannelManager(ChannelDBManager, TypeclassManager):
|
|||
pass
|
||||
|
||||
|
||||
#
|
||||
# PlayerChannelConnection manager
|
||||
#
|
||||
class PlayerChannelConnectionManager(models.Manager):
|
||||
"""
|
||||
This PlayerChannelConnectionManager implements methods for searching
|
||||
and manipulating PlayerChannelConnections directly from the database.
|
||||
|
||||
These methods will all return database objects
|
||||
(or QuerySets) directly.
|
||||
|
||||
A PlayerChannelConnection defines a user's subscription to an in-game
|
||||
channel - deleting the connection object will disconnect the player
|
||||
from the channel.
|
||||
|
||||
Evennia-specific:
|
||||
get_all_player_connections
|
||||
has_connection
|
||||
get_all_connections
|
||||
create_connection
|
||||
break_connection
|
||||
|
||||
"""
|
||||
@returns_typeclass_list
|
||||
def get_all_player_connections(self, player):
|
||||
"Get all connections that the given player has."
|
||||
player = to_object(player)
|
||||
return self.filter(db_player=player)
|
||||
|
||||
def has_player_connection(self, player, channel):
|
||||
"Checks so a connection exists player<->channel"
|
||||
if player and channel:
|
||||
return self.filter(db_player=player.dbobj).filter(
|
||||
db_channel=channel.dbobj).count() > 0
|
||||
return False
|
||||
|
||||
def get_all_connections(self, channel):
|
||||
"""
|
||||
Get all connections for a channel
|
||||
"""
|
||||
channel = to_object(channel, objtype='channel')
|
||||
return self.filter(db_channel=channel)
|
||||
|
||||
def create_connection(self, player, channel):
|
||||
"""
|
||||
Connect a player to a channel. player and channel
|
||||
can be actual objects or keystrings.
|
||||
"""
|
||||
player = to_object(player)
|
||||
channel = to_object(channel, objtype='channel')
|
||||
if not player or not channel:
|
||||
raise CommError("NOTFOUND")
|
||||
new_connection = self.model(db_player=player, db_channel=channel)
|
||||
new_connection.save()
|
||||
return new_connection
|
||||
|
||||
def break_connection(self, player, channel):
|
||||
"Remove link between player and channel"
|
||||
player = to_object(player)
|
||||
channel = to_object(channel, objtype='channel')
|
||||
if not player or not channel:
|
||||
raise CommError("NOTFOUND")
|
||||
conns = self.filter(db_player=player).filter(db_channel=channel)
|
||||
for conn in conns:
|
||||
conn.delete()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -174,8 +174,7 @@ class Msg(SharedMemoryModel):
|
|||
Getter. Allows for value = self.receivers.
|
||||
Returns three lists of receivers: players, objects and channels.
|
||||
"""
|
||||
return [hasattr(o, "typeclass") and o.typeclass or o for o in
|
||||
list(self.db_receivers_players.all()) + list(self.db_receivers_objects.all())]
|
||||
return list(self.db_receivers_players.all()) + list(self.db_receivers_objects.all())
|
||||
|
||||
#@receivers.setter
|
||||
def __receivers_set(self, value):
|
||||
|
|
@ -371,7 +370,7 @@ class ChannelDB(TypedObject):
|
|||
#
|
||||
|
||||
def __str__(self):
|
||||
return "Channel '%s' (%s)" % (self.key, self.typeclass.db.desc)
|
||||
return "Channel '%s' (%s)" % (self.key, self.db.desc)
|
||||
|
||||
def has_connection(self, player):
|
||||
"""
|
||||
|
|
@ -387,33 +386,31 @@ class ChannelDB(TypedObject):
|
|||
"Connect the user to this channel. This checks access."
|
||||
if hasattr(player, "player"):
|
||||
player = player.player
|
||||
player = player.typeclass
|
||||
# check access
|
||||
if not self.access(player, 'listen'):
|
||||
return False
|
||||
# pre-join hook
|
||||
connect = self.typeclass.pre_join_channel(player)
|
||||
connect = self.pre_join_channel(player)
|
||||
if not connect:
|
||||
return False
|
||||
# subscribe
|
||||
self.db_subscriptions.add(player.dbobj)
|
||||
# post-join hook
|
||||
self.typeclass.post_join_channel(player)
|
||||
self.post_join_channel(player)
|
||||
return True
|
||||
|
||||
def disconnect(self, player):
|
||||
"Disconnect user from this channel."
|
||||
if hasattr(player, "player"):
|
||||
player = player.player
|
||||
player = player.typeclass
|
||||
# pre-disconnect hook
|
||||
disconnect = self.typeclass.pre_leave_channel(player)
|
||||
disconnect = self.pre_leave_channel(player)
|
||||
if not disconnect:
|
||||
return False
|
||||
# disconnect
|
||||
self.db_subscriptions.remove(player.dbobj)
|
||||
# post-disconnect hook
|
||||
self.typeclass.post_leave_channel(player.dbobj)
|
||||
self.post_leave_channel(player.dbobj)
|
||||
return True
|
||||
|
||||
def access(self, accessing_obj, access_type='listen', default=False):
|
||||
|
|
|
|||
|
|
@ -258,9 +258,8 @@ def handle_setup(last_step):
|
|||
for profile in PlayerDB.objects.all():
|
||||
profile.delete()
|
||||
elif last_step + num == 3:
|
||||
from src.comms.models import ChannelDB, PlayerChannelConnection
|
||||
from src.comms.models import ChannelDB
|
||||
ChannelDB.objects.all().delete()
|
||||
PlayerChannelConnection.objects.all().delete()
|
||||
raise
|
||||
ServerConfig.objects.conf("last_initial_setup_step", last_step + num + 1)
|
||||
# We got through the entire list. Set last_step to -1 so we don't
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue