annotate orpg/networking/mplay_client.py @ 145:067922263f07 alpha

Traipse Alpha 'OpenRPG' {091123-03} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana Pretty important update that can help remove thousands of dead children from your gametree. Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops return error instead of freezing the software! New Syntax added for custom PC sheets Tip of the Day added, from Core and community Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix.
author sirebral
date Mon, 23 Nov 2009 20:01:47 -0600
parents b4e02e8cd314
children 06f10429eedc
rev   line source
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
3 # openrpg-dev@lists.sourceforge.net
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
4 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
6 # it under the terms of the GNU General Public License as published by
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
8 # (at your option) any later version.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
9 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
13 # GNU General Public License for more details.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
14 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
16 # along with this program; if not, write to the Free Software
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
18 # --
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
19 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
20 # File: mplay_client.py
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
21 # Author: Chris Davis
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
22 # Maintainer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
23 # Version:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
24 # $Id: mplay_client.py,v 1.71 2007/05/12 20:41:54 digitalxero Exp $
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
25 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
26 # Description: This file contains the code for the client stubs of the multiplayer
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27 # features in the orpg project.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
28 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
29
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
30 __version__ = "$Id: mplay_client.py,v 1.71 2007/05/12 20:41:54 digitalxero Exp $"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
31
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
32 ### Alpha ###
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
33 ##import orpg.minidom ## Deprecated. xml.parseXml calls minidom.parseString so it was superfluous and wasteful.
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
34 import socket, Queue, thread, traceback, errno, os, time
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
35
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
36 from threading import Event, Lock
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
37 from xml.sax.saxutils import escape
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
38 from struct import pack, unpack, calcsize
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
39 from string import *
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
40 from orpg.orpg_version import CLIENT_STRING, PROTOCOL_VERSION, VERSION
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
41
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
42 from orpg.orpgCore import component
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
43 from orpg.orpg_xml import xml
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
44 from orpg.tools.orpg_log import debug
145
067922263f07 Traipse Alpha 'OpenRPG' {091123-03}
sirebral
parents: 136
diff changeset
45 from orpg.tools.settings import settings
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
46
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
47 from xml.etree.ElementTree import ElementTree, Element, iselement
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
48 from xml.etree.ElementTree import fromstring, tostring
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
49 from xml.parsers.expat import ExpatError
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
50
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
51 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
52 import bz2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
53 cmpBZ2 = True
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
54 except: cmpBZ2 = False
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
55
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
56 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 import zlib
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
58 cmpZLIB = True
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
59 except: cmpZLIB = False
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
60
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
61 # Default, is configurable
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
62 OPENRPG_PORT = 9557
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
63
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
64 # We should be sending a length for each packet
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
65 MPLAY_LENSIZE = calcsize( 'i' )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
66 MPLAY_DISCONNECTED = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
67 MPLAY_CONNECTED = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
68 MPLAY_DISCONNECTING = 3
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
69 MPLAY_GROUP_CHANGE = 4
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
70 MPLAY_GROUP_CHANGE_F = 5
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
71 PLAYER_NEW = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
72 PLAYER_DEL = 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
73 PLAYER_GROUP = 3
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
74
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
75 # The next two messages are used to inform others that a player is typing
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
76 PLAYER_TYPING = 4
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
77 PLAYER_NOT_TYPING = 5
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
78 PLAYER_UPDATE = 6
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
79 GROUP_JOIN = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80 GROUP_NEW = 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
81 GROUP_DEL = 3
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
82 GROUP_UPDATE = 4
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
83 STATUS_SET_URL = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
84
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
85 def parseXml(data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
86 "parse and return doc"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
87 #print data
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
88 doc = xml.parseXml(data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
89 doc.normalize()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
90 return doc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
91
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
92 def myescape(data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
93 return escape(data,{"\"":""})
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
94
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
95 class mplay_event:
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
96 def __init__(self, id, data=None):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
97 self.id = id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
98 self.data = data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
99
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
100 def get_id(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
101 return self.id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
102
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103 def get_data(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104 return self.data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
105
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
106 BOOT_MSG = "YoU ArE ThE WeAkEsT LiNk. GoOdByE."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
107
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
108 class client_base:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
109 # Player role definitions
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
110 def __init__(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
111 self.outbox = Queue.Queue(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
112 self.inbox = Queue.Queue(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
113 self.startedEvent = Event()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
114 self.exitEvent = Event()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
115 self.sendThreadExitEvent = Event()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
116 self.recvThreadExitEvent = Event()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
117 self.id = "0"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
118 self.group_id = "0"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
119 self.name = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
120 self.role = "GM"
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
121 ## Soon to be removed
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
122 self.ROLE_GM = "GM"
2
d5e81dac98ff Made some changes to the way the player list colors. Also fixed an annoyence with images
sirebral
parents: 0
diff changeset
123 self.ROLE_PLAYER = "Player"
d5e81dac98ff Made some changes to the way the player list colors. Also fixed an annoyence with images
sirebral
parents: 0
diff changeset
124 self.ROLE_LURKER = "Lurker"
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
125 ## --TaS
136
b4e02e8cd314 Traipse Alpha 'OpenRPG' {091016-00}
sirebral
parents: 128
diff changeset
126 try: self.ip = socket.gethostbyname(socket.gethostname())
b4e02e8cd314 Traipse Alpha 'OpenRPG' {091016-00}
sirebral
parents: 128
diff changeset
127 except: self.ip = socket.gethostbyname('localhost')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
128 self.remote_ip = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
129 self.version = VERSION
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
130 self.protocol_version = PROTOCOL_VERSION
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
131 self.client_string = CLIENT_STRING
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
132 self.status = MPLAY_DISCONNECTED
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
133 self.useCompression = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
134 self.compressionType = 'Undefined'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
135 self.log_console = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
136 self.sock = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
137 self.text_status = "Idle"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
138 self.statLock = Lock()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
139 self.useroles = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
140 self.lastmessagetime = time.time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
141 self.connecttime = time.time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
142
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
143 def sendThread( self, arg ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
144 "Sending thread. This thread reads from the data queue and writes to the socket."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
145
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
146 # Wait to be told it's okay to start running
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
147 self.startedEvent.wait()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
148
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
149 # Loop as long as we have a connection
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
150 while( self.get_status() == MPLAY_CONNECTED ):
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
151 try: readMsg = self.outbox.get(block=1)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
152 except Exception, text:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
153 self.log_msg( ("outbox.get() got an exception: ", text) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
154
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
155 # If we are here, it's because we have data to send, no doubt!
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
156 if self.status == MPLAY_CONNECTED:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
157 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
158 # Send the entire message, properly formated/encoded
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
159 sent = self.sendMsg( self.sock, readMsg )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
160 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
161 self.log_msg( e )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
162 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
163 # If we are not connected, purge the data queue
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
164 self.log_msg( "Data queued without a connection, purging data from queue..." )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
165 self.sendThreadExitEvent.set()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
166 self.log_msg( "sendThread has terminated..." )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
167
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
168 def recvThread( self, arg ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
169 "Receiving thread. This thread reads from the socket and writes to the data queue."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
170 # Wait to be told it's okay to start running
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
171 self.startedEvent.wait()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
172
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
173 while( self.get_status() == MPLAY_CONNECTED ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
174 readMsg = self.recvMsg( self.sock )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
175 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
176 if self.useCompression and self.compressionType != None:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
177 readMsg = self.compressionType.decompress(readMsg)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
178 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
179
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
180 # Check the length of the message
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
181 bytes = len( readMsg )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
182
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
183 # Make sure we are still connected
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
184 if bytes == 0: break
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
185 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
186 # Pass along the message so it can be processed
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
187 self.inbox.put( readMsg )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
188 self.update_idle_time() #update the last message time
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
189 if bytes == 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
190 self.log_msg( "Remote has disconnected!" )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
191 self.set_status( MPLAY_DISCONNECTING )
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
192 self.outbox.put("") # Make sure the other thread is woken up!
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
193 self.sendThreadExitEvent.set()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
194 self.log_msg( "recvThread has terminated..." )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
195
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
196 def sendMsg( self, sock, msg ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
197 """Very simple function that will properly encode and send a message to te
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
198 remote on the specified socket."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
199 if self.useCompression and self.compressionType != None:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
200 mpacket = self.compressionType.compress(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
201 lpacket = pack('!i', len(mpacket))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
202 sock.send(lpacket)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
203 offset = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
204 while offset < len(mpacket):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
205 slice = buffer(mpacket, offset, len(mpacket)-offset)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
206 sent = sock.send(slice)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
207 offset += sent
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
208 sentm = offset
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
209 else:
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
210 length = len(msg) # Calculate our message length
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
211 lp = pack('!i', length) # Encode the message length into network byte order
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
212 try:
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
213 sentl = sock.send( lp ) # Send the encoded length
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
214 # Now, send the message the the length was describing
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
215 sentm = sock.send( msg )
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
216 if self.isServer(): self.log_msg(("data_sent", sentl+sentm))
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
217 except socket.error, e: self.log_msg( e )
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
218 except Exception, e: self.log_msg( e )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
219 return sentm
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
220
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
221 def recvData( self, sock, readSize ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
222 """Simple socket receive method. This method will only return when the exact
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
223 byte count has been read from the connection, if remote terminates our
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
224 connection or we get some other socket exception."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
225 data = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
226 offset = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
227 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
228 while offset != readSize:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
229 frag = sock.recv( readSize - offset )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
230 # See if we've been disconnected
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
231 rs = len( frag )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
232 if rs <= 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
233 # Loudly raise an exception because we've been disconnected!
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
234 raise IOError, "Remote closed the connection!"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
235 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
236 # Continue to build complete message
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
237 offset += rs
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
238 data += frag
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
239 except socket.error, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
240 self.log_msg( e )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
241 data = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
242 return data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
243
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
244 def recvMsg(self, sock):
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
245 """This method now expects to receive a message having a 4-byte prefix length. It will ONLY read completed messages. In the event that the remote's connection is terminated, it will throw an exception which should allow for the caller to more gracefully handle this exception event.
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
246
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
247 Because we use strictly reading ONLY based on the length that is told to use, we no longer have to worry about partially adjusting for fragmented buffers starting somewhere within a buffer that we've read. Rather, it will get ONLY a whole message and nothing more. Everything else will remain buffered with the OS until we attempt to read the next complete message."""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
248 msgData = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
249 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
250 lenData = self.recvData( sock, MPLAY_LENSIZE )
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
251 (length,) = unpack('!i', lenData) # Now, convert to a usable form
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
252 msgData = self.recvData( sock, length ) # Read exactly the remaining amount of data
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
253 if self.isServer():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
254 self.log_msg(("data_recv", length+4))
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
255 if self.remote_ip is None: # Make the peer IP address available for reference later
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
256 self.remote_ip = self.sock.getpeername()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
257 except IOError, e: self.log_msg( e )
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
258 except Exception, e: self.log_msg( e )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
259 return msgData
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
260
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
261 def initialize_threads(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
262 "Starts up our threads (2) and waits for them to make sure they are running!"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
263 self.status = MPLAY_CONNECTED
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
264 self.sock.setblocking(1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
265 # Confirm that our threads have started
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
266 thread.start_new_thread( self.sendThread,(0,))
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
267 thread.start_new_thread( self.recvThread,(0,))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
268 self.startedEvent.set()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
269
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
270 def disconnect(self):
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
271 debug()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
272 self.set_status(MPLAY_DISCONNECTING)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
273 self.log_msg("client stub " + self.ip +" disconnecting...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
274 self.log_msg("closing sockets...")
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
275 try: self.sock.shutdown(2)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
276 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
277 print "Caught exception: " + str(e)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
278 print
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
279 print "Continuing"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
280 self.set_status(MPLAY_DISCONNECTED)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
281
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
282 def reset(self,sock):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
283 self.disconnect()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
284 self.sock = sock
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
285 self.initialize_threads()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
286
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
287 def update_role(self,role):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
288 self.useroles = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
289 self.role = role
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
290
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
291 def use_roles(self):
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
292 if self.useroles: return 1
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
293 else: return 0
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
294 def update_self_from_player(self, player):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
295 try: (self.name, self.ip, self.id,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
296 self.text_status, self.version,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
297 self.protocol_version, self.client_string, role) = player
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
298 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
299 print e
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
300 """
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
301 The IP field should really be deprecated as too many systems are NAT'd and/or behind firewalls for a
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
302 client provided IP address to have much value. As such, we now label it as deprecated.
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
303 """
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
304 def toxml(self, action):
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
305 el = Element('player')
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
306 el.set('name', self.name)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
307 el.set('action', action)
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
308 el.set('role', self.role)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
309 el.set('id', self.id)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
310 el.set('group_id', self.group_id)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
311 el.set('ip', self.ip)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
312 el.set('status', self.text_status)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
313 el.set('version', self.version)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
314 el.set('protocol_version', self.protocol_version)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
315 el.set('client_string', self.client_string)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
316 el.set('useCompression', str(self.useCompression))
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
317 cmpType = 'None'
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
318 if cmpBZ2 and (self.compressionType == 'Undefined' or self.compressionType == bz2):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
319 cmpType = 'bz2'
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
320 elif cmpZLIB and (self.compressionType == 'Undefined' or self.compressionType == zlib):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
321 cmpType = 'zlib'
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 96
diff changeset
322 el.set('cmpType', cmpType)
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
323 return tostring(el)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
324
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
325 def log_msg(self,msg):
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
326 debug(msg, log=False)
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
327 if self.log_console: self.log_console(msg)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
328
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
329 def get_status(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
330 self.statLock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
331 status = self.status
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
332 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
333 return status
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
334
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
335 def my_role(self):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
336 return self.role
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
337
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
338 def set_status(self,status):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
339 self.statLock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
340 self.status = status
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
341 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
342
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
343 def isServer( self ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
344 # Return 1 if we are running as a server, else, return 0.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
345 # This method must be overloaded by whomever derives from us
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
346 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
347
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
348 def __str__(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
349 return "%s(%s)\nIP:%s\ngroup_id:%s\n" % (self.name, self.id, self.ip, self.group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
350
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
351 # idle time functions added by snowdog 3/31/04
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
352 def update_idle_time(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
353 self.lastmessagetime = time.time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
354
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
355 def idle_time(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
356 curtime = time.time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
357 idletime = curtime - self.lastmessagetime
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
358 return idletime
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
359
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
360 def idle_status(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
361 idletime = self.idle_time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
362 idlemins = idletime / 60
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
363 status = "Unknown"
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
364 if idlemins < 3: status = "Active"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
365 elif idlemins < 10: status = "Idle ("+str(int(idlemins))+" mins)"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
366 else: status = "Inactive ("+str(int(idlemins))+" mins)"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
367 return status
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
368
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
369 def connected_time(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
370 curtime = time.time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
371 timeoffset = curtime - self.connecttime
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
372 return timeoffset
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
373
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
374 def connected_time_string(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
375 "returns the time client has been connected as a formated time string"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
376 ct = self.connected_time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
377 d = int(ct/86400)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
378 h = int( (ct-(86400*d))/3600 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
379 m = int( (ct-(86400*d)-(3600*h))/60)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
380 s = int( (ct-(86400*d)-(3600*h)-(60*m)) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
381 cts = zfill(d,2)+":"+zfill(h,2)+":"+zfill(m,2)+":"+zfill(s,2)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
382 return cts
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
383
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
384 #========================================================================
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
385 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
386 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
387 # MPLAY CLIENT
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
388 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
389 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
390 #========================================================================
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
391 class mplay_client(client_base):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
392 "mplay client"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
393 def __init__(self,name,callbacks):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
394 client_base.__init__(self)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
395 component.add('mp_client', self)
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
396 self.xml = component.get('xml')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
397 self.set_name(name)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
398 self.on_receive = callbacks['on_receive']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
399 self.on_mplay_event = callbacks['on_mplay_event']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
400 self.on_group_event = callbacks['on_group_event']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
401 self.on_player_event = callbacks['on_player_event']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
402 self.on_status_event = callbacks['on_status_event']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
403 self.on_password_signal = callbacks['on_password_signal']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
404 # I know this is a bad thing to do but it has to be
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
405 # be done to use the unified password manager.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
406 # Should really find a better solution. -- SD 8/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
407 self.orpgFrame_callback = callbacks['orpgFrame']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
408 self.ignore_id = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
409 self.ignore_name = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
410 self.players = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
411 self.groups = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
412 self.unique_cookie = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
413 self.msg_handlers = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
414 self.core_msg_handlers = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
415 self.load_core_msg_handlers()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
416
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
417 # implement from our base class
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
418 def isServer(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
419 return 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
420
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
421 def get_chat(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
422 return self.orpgFrame_callback.chat
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
423
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
424 def set_name(self,name):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
425 self.name = name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
426 self.update()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
427
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
428 def set_text_status(self, status):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
429 if self.text_status != status:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
430 self.text_status = status
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
431 self.update()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
432
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
433 def set_status_url(self, url="None"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
434 self.on_status_event(mplay_event(STATUS_SET_URL,url))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
435
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
436 def update(self, evt=None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
437 if self.status == MPLAY_CONNECTED:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
438 self.outbox.put(self.toxml('update'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
439 self.inbox.put(self.toxml('update'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
440
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
441 def get_group_info(self, id=0):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
442 self.statLock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
443 id = self.groups[id]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
444 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
445 return id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
446
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
447 def get_my_group(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
448 self.statLock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
449 id = self.groups[self.group_id]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
450 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
451 return id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
452
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
453 def get_groups(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
454 self.statLock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
455 groups = self.groups.values()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
456 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
457 return groups
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
458
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
459 def get_players(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
460 self.statLock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
461 players = self.players.values()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
462 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
463 return players
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
464
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
465 def get_player_info(self,id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
466 self.statLock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
467 player = self.players[id]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
468 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
469 return player
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
470
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
471 def get_player_by_player_id(self,player):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
472 players = self.get_players()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
473 if self.players.has_key(player):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
474 for m in players:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
475 if player == m[2]: return m
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
476 return -1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
477
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
478 def get_id(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
479 return self.id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
480
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
481 def get_my_info(self):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
482 return (self.name, self.ip, self.id,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
483 self.text_status, self.version,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
484 self.protocol_version, self.client_string,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
485 self.role)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
486
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
487 def is_valid_id(self,id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
488 self.statLock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
489 value = self.players.has_key( id )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
490 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
491 return value
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
492
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
493 def clear_players(self,save_self=0):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
494 self.statLock.acquire()
90
d1aff41c031b Traipse Alpha 'OpenRPG' {090919-00}
sirebral
parents: 88
diff changeset
495 keys = self.players.keys()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
496 for k in keys: del self.players[k]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
497 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
498
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
499 def clear_groups(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
500 self.statLock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
501 keys = self.groups.keys()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
502 for k in keys: del self.groups[k]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
503 self.statLock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
504
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
505 def find_role(self,id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
506 return self.players[id].role
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
507
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
508 def get_ignore_list(self):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
509 try: return (self.ignore_id, self.ignore_name)
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
510 except: return (None, None)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
511
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
512 def toggle_ignore(self, id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
513 for m in self.ignore_id:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
514 if `self.ignore_id[self.ignore_id.index(m)]` == `id`:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
515 name = self.ignore_name[self.ignore_id.index(m)]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
516 self.ignore_id.remove(m)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
517 self.ignore_name.remove(name)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
518 return (0,id,name)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
519 self.ignore_name.append(self.players[id][0])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
520 self.ignore_id.append(self.players[id][2])
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
521 return (1, self.players[id][2], self.players[id][0])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
522
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
523 def boot_player(self,id,boot_pwd = ""):
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
524 el = Element('boot')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
525 el.set('boot_pwd', boot_pwd)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
526 self.send(tostring(el), id)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
527
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
528 #---------------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
529 # [START] Snowdog Password/Room Name altering code 12/02
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
530 #---------------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
531
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
532 def set_room_pass(self, npwd, pwd=""):
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
533 el = Element('alter')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
534 el.set('key', 'pwd')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
535 el.set('val', npwd)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
536 el.set('bpw', pwd)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
537 el.set('plr', self.id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
538 el.set('gid', self.group_id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
539 self.outbox.put(tostring(el))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
540 self.update()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
541
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
542 def set_room_name(self, name, pwd=""):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
543 loc = name.find("&")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
544 oldloc=0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
545 while loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
546 loc = name.find("&",oldloc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
547 if loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
548 b = name[:loc]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
549 e = name[loc+1:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
550 name = b + "&amp;" + e
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
551 oldloc = loc+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
552 loc = name.find('"')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
553 oldloc=0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
554 while loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
555 loc = name.find('"',oldloc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
556 if loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
557 b = name[:loc]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
558 e = name[loc+1:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
559 name = b + "&quot;" + e
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
560 oldloc = loc+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
561 loc = name.find("'")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
562 oldloc=0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
563 while loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
564 loc = name.find("'",oldloc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
565 if loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
566 b = name[:loc]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
567 e = name[loc+1:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
568 name = b + "&#39;" + e
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
569 oldloc = loc+1
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
570 el = Element('alter')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
571 el.set('key', 'pwd')
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
572 #el.set('val', npwd)
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
573 el.set('bpw', str(pwd))
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
574 el.set('plr', self.id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
575 el.set('gid', self.group_id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
576 self.outbox.put(tostring(el))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
577 self.update()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
578
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
579 #---------------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
580 # [END] Snowdog Password/Room Name altering code 12/02
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
581 #---------------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
582
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
583 def display_roles(self):
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
584 el = Element('role')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
585 el.set('action', 'display')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
586 el.set('player', self.id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
587 el.set('group_id', self.group_id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
588 self.outbox.put(tostring(el))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
589
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
590 def get_role(self):
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
591 el = Element('role')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
592 el.set('action', 'get')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
593 el.set('player', self.id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
594 el.set('group_id', self.group_id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
595 self.outbox.put(tostring(el))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
596
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
597 def set_role(self, player, role, pwd=""):
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
598 el = Element('role')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
599 el.set('action', 'set')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
600 el.set('player', player)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
601 el.set('role', role)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
602 el.set('boot_pwd', pwd)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
603 el.set('group_id', self.group_id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
604 self.outbox.put(tostring(el))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
605 self.update()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
606
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
607 def send(self, msg, player="all"):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
608 if self.status == MPLAY_CONNECTED and player != self.id:
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
609 ### Pre Alpha ###
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
610 #el = Element('msg')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
611 #el.set('to', player)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
612 #el.set('from', self.id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
613 #el.set('group_id', self.group_id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
614 #el.append(fromstring(msg))
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
615 #self.outbox.put(tostring(el))
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
616 ### Current chat is not ready for Element Tree ###
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
617 self.outbox.put("<msg to='"+player+"' from='"+self.id+"' group_id='"+self.group_id+"' />"+msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
618 self.check_my_status()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
619
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
620 def send_sound(self, snd_xml):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
621 if self.status == MPLAY_CONNECTED:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
622 self.outbox.put(snd_xml)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
623 self.check_my_status()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
624
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
625 def send_create_group(self, name, pwd, boot_pwd, min_version):
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
626 el = Element('create_group')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
627 el.set('from', self.id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
628 el.set('pwd', pwd)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
629 el.set('name', name)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
630 el.set('boot_pwd', boot_pwd)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
631 el.set('min_version', min_version)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
632 self.outbox.put(tostring(el))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
633
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
634 def send_join_group(self, group_id, pwd):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
635 if (group_id != 0): self.update_role("Lurker")
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
636 el = Element('join_group')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
637 el.set('from', self.id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
638 el.set('pwd', pwd)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
639 el.set('group_id', str(group_id))
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
640
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
641 self.outbox.put(tostring(el))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
642
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
643 def poll(self, evt=None):
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
644 try: msg = self.inbox.get_nowait()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
645 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
646 if self.get_status() != MPLAY_CONNECTED:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
647 self.check_my_status()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
648 else:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
649 try: self.pretranslate(msg)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
650 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
651 print "The following message: " + str(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
652 print "created the following exception: "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
653 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
654
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
655 def add_msg_handler(self, tag, function, core=False):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
656 if not self.msg_handlers.has_key(tag):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
657 self.msg_handlers[tag] = function
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
658 if core: self.core_msg_handlers.append(tag)
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
659 else: print 'XML Messages ' + tag + ' already has a handler'
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
660
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
661 def remove_msg_handler(self, tag):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
662 if self.msg_handlers.has_key(tag) and not tag in self.core_msg_handlers:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
663 del self.msg_handlers[tag]
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
664 else: print 'XML Messages ' + tag + ' already deleted'
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
665
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
666 def load_core_msg_handlers(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
667 self.add_msg_handler('msg', self.on_msg, True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
668 self.add_msg_handler('ping', self.on_ping, True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
669 self.add_msg_handler('group', self.on_group, True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
670 self.add_msg_handler('role', self.on_role, True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
671 self.add_msg_handler('player', self.on_player, True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
672 self.add_msg_handler('password', self.on_password, True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
673 self.add_msg_handler('sound', self.on_sound, True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
674
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
675 def pretranslate(self, data):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
676 # Pre-qualify our data. If we don't have atleast 5-bytes, then there is
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
677 # no way we even have a valid message!
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
678 if len(data) < 5: return
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
679 try: el = fromstring(data)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
680 except ExpatError:
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
681 end = data.find(">")
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
682 head = data[:end+1]
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
683 msg = data[end+1:]
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
684 ### Alpha ###
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
685 if head[end:] != '/':
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
686 if head[end:] != '>': head = head[:end] + '/>'
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
687 ### This if statement should help close invalid messages. Since it needs fixing, use the try except message for now.
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
688 try: el = fromstring(head)
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
689 except: el = fromstring(head[:end] +'/>')
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
690
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
691 try:
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
692 el1 = fromstring(msg)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
693 el.append(el1)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
694 except ExpatError:
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
695 el.text = msg
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
696 #logger.general("Bad Message: \n" + data)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
697 id = el.get('from') or el.get('id')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
698 if el.tag in self.msg_handlers: self.msg_handlers[el.tag](id, data, el)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
699
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
700 def on_sound(self, id, data, etreeEl):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
701 (ignore_id,ignore_name) = self.get_ignore_list()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
702 for m in ignore_id:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
703 if m == id:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
704 # yes we are
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
705 print "ignoring sound from player:"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
706 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
707 chat = self.get_chat()
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
708 chat.sound_player.play(etreeEl.get('url'), 'remote', etreeEl.get('loop'))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
709
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
710 def on_msg(self, id, data, etreeEl):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
711 end = data.find(">")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
712 head = data[:end+1]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
713 msg = data[end+1:]
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
714 if msg[-6:] == '</msg>': msg = msg[:-6]
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
715 if id == "0": self.on_receive(msg, None)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
716 # None get's interpreted in on_receive as the sys admin.
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
717 # Doing it this way makes it harder to impersonate the admin
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
718 elif self.is_valid_id(id): self.on_receive(msg, self.players[id])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
719
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
720 def on_ping(self, id, msg, etreeEl):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
721 #a REAL ping time implementation by Snowdog 8/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
722 # recieves special server <ping time="###" /> command
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
723 # where ### is a returning time from the clients ping command
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
724 #get current time, pull old time from object and compare them
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
725 # the difference is the latency between server and client * 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
726 ct = time.clock()
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
727 ot = etreeEl.get("time")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
728 latency = float(float(ct) - float(ot))
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
729 latency = int(latency * 10000.0)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
730 latency = float(latency) / 10.0
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
731 ping_msg = "Ping Results: " + str(latency) + " ms (parsed message, round trip)"
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
732 self.on_receive(ping_msg, None)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
733
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
734 def on_group(self, id, msg, etreeEl):
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
735 act = etreeEl.get("action")
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
736 group_data = (id, etreeEl.get("name"), etreeEl.get("pwd"), etreeEl.get("players"))
136
b4e02e8cd314 Traipse Alpha 'OpenRPG' {091016-00}
sirebral
parents: 128
diff changeset
737 if act == 'new' or act == 'update':
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
738 self.groups[id] = group_data
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
739 if act == 'update': self.on_group_event(mplay_event(GROUP_UPDATE, group_data))
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
740 elif act == 'new': self.on_group_event(mplay_event(GROUP_NEW, group_data))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
741 elif act == 'del':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
742 del self.groups[id]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
743 self.on_group_event(mplay_event(GROUP_DEL, group_data))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
744
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
745 def on_role(self, id, msg, etreeEl):
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
746 act = etreeEl.get("action")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
747 if (act == "set") or (act == "update"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
748 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
749 (a,b,c,d,e,f,g,h) = self.players[id]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
750 if id == self.id:
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
751 self.players[id] = (a,b,c,d,e,f,g,etreeEl.get("role"))
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
752 self.update_role(etreeEl.get("role"))
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
753 else: self.players[id] = (a,b,c,d,e,f,g,etreeEl.get("role"))
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
754 self.on_player_event(mplay_event(PLAYER_UPDATE, self.players[id]))
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
755 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
756
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
757 def on_player(self, id, msg, etreeEl):
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
758 act = etreeEl.get("action")
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
759 try: player = (etreeEl.get("name"), etreeEl.get("ip"), id, etreeEl.get("status"),
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
760 etreeEl.get("version"), etreeEl.get("protocol_version"),
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
761 etreeEl.get("client_string"), self.players[id][7])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
762 except Exception, e:
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
763 player = (etreeEl.get("name"), etreeEl.get("ip"), id, etreeEl.get("status"),
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
764 etreeEl.get("version"), etreeEl.get("protocol_version"),
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
765 etreeEl.get("client_string"), "Player")
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
766 print e
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
767 if act == "new":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
768 self.players[id] = player
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
769 self.on_player_event(mplay_event(PLAYER_NEW, self.players[id]))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
770 elif act == "group":
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
771 self.group_id = etreeEl.get('group_id')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
772 self.clear_players()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
773 self.on_mplay_event(mplay_event(MPLAY_GROUP_CHANGE, self.groups[self.group_id]))
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
774 self.players[self.id] = self.get_my_info()
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
775 #(self.name,self.ip,self.id,self.text_status)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
776 self.on_player_event(mplay_event(PLAYER_NEW, self.players[self.id]))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
777 elif act == "failed":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
778 self.on_mplay_event(mplay_event(MPLAY_GROUP_CHANGE_F))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
779 elif act == "del":
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
780 self.on_player_event(mplay_event(PLAYER_DEL, self.players[id]))
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
781 if self.players.has_key(id): del self.players[id]
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
782 if id == self.id: self.do_disconnect()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
783 # the next two cases handle the events that are used to let you know when others are typing
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
784 elif act == "update":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
785 if id == self.id:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
786 self.players[id] = player
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
787 self.update_self_from_player(player)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
788 else: self.players[id] = player
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
789 dont_send = 0
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
790 for m in self.ignore_id:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
791 if m == id: dont_send=1
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
792 if dont_send != 1: self.on_player_event(mplay_event(PLAYER_UPDATE, self.players[id]))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
793
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
794 def on_password(self, id, msg, etreeEl):
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
795 self.on_password_signal(etreeEl.get("signal"), etreeEl.get("type"),
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
796 etreeEl.get("id"), etreeEl.get("data"))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
797
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
798 def check_my_status(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
799 status = self.get_status()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
800 if status == MPLAY_DISCONNECTING: self.do_disconnect()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
801
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
802 def connect(self, addressport):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
803 """Establish a connection to a server while still using sendThread & recvThread for its
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
804 communication."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
805 if self.is_connected():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
806 self.log_msg( "Client is already connected to a server?!? Need to disconnect first." )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
807 return 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
808 self.inbox = Queue.Queue(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
809 self.outbox = Queue.Queue(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
810 addressport_ar = addressport.split(":")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
811 if len(addressport_ar) == 1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
812 address = addressport_ar[0]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
813 port = OPENRPG_PORT
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
814 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
815 address = addressport_ar[0]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
816 port = int(addressport_ar[1])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
817 self.host_server = addressport
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
818 self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
819 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
820 self.sock.connect((address,port))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
821 # send client into with id=0
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
822 outgoing = self.toxml('new')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
823 if iselement(outgoing): outgoing = tostring(outgoing)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
824 self.sendMsg(self.sock, outgoing)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
825 data = self.recvMsg(self.sock)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
826 # get new id and group_id
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
827 el = fromstring(data)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
828 self.id = el.get('id')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
829 self.group_id = el.get('group_id')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
830 if el.get('useCompression') == 'True':
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
831 self.useCompression = True
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
832 if cmpBZ2 and el.get('cmpType') == 'bz2':
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
833 self.compressionType = bz2
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
834 elif cmpZLIB and el.get('cmpType') == 'zlib':
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
835 self.compressionType = zlib
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
836 else: self.compressionType = None
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
837 #send confirmation
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
838 outgoing = self.toxml('new')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
839 if iselement(outgoing): outgoing = tostring(outgoing)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
840 self.sendMsg(self.sock, outgoing)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
841 except Exception, e:
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
842 print e
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
843 self.log_msg(e)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
844 return 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
845 # Start things rollings along
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
846 self.initialize_threads()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
847 self.on_mplay_event(mplay_event(MPLAY_CONNECTED))
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
848 self.players[self.id] = (self.name, self.ip, self.id,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
849 self.text_status, self.version,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
850 self.protocol_version, self.client_string, self.role)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
851 self.on_player_event(mplay_event(PLAYER_NEW,self.players[self.id]))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
852 return 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
853
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
854 def start_disconnect(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
855 self.on_mplay_event(mplay_event(MPLAY_DISCONNECTING))
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
856 outgoing = self.toxml('del')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
857 if iselement(outgoing): outgoing = tostring(outgoing)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
858 self.outbox.put(outgoing)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
859 ## Client Side Disconect Forced -- Snowdog 10-09-2003
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
860 #pause to allow GUI events time to sync.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
861 time.sleep(1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
862 self.do_disconnect()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
863
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
864 def do_disconnect(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
865 client_base.disconnect(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
866 self.clear_players()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
867 self.clear_groups()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
868 self.useroles = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
869 self.on_mplay_event(mplay_event(MPLAY_DISCONNECTED))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
870 self.useCompression = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
871
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
872 def is_connected(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
873 return (self.status == MPLAY_CONNECTED)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
874
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
875 def get_next_id(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
876 self.unique_cookie += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
877 return_str = self.id + "-" + str(self.unique_cookie)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
878 return return_str