comparison orpg/networking/mplay_server.py @ 119:9314d63c0941 alpha

Traipse Alpha 'OpenRPG' {091029-00} 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: Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images! Changes made to the map for increased portability. SnowDog has changes planned in Core, though. Added an initial push to the BCG. Not much to see, just shows off how it is re-writing Main code. Fix to remote admin commands Minor fix to texted based server, works in /System/ folder Some Core changes to gametree to correctly disply Pretty Print, thanks David! Fix to Splitter Nodes not being created. Added images to Plugin Control panel for Autostart feature Fix to massive amounts of images loading; from Core fix to gsclient so with_statement imports Added 'boot' command to remote admin Prep work in Pass tool for remote admin rankings and different passwords, ei, Server, Admin, Moderator, etc. Remote Admin Commands more organized, more prep work. Added Confirmation window for sent nodes. Minor changes to allow for portability to an OpenSUSE linux OS (hopefully without breaking) {091028} 00: Made changes to gametree to start working with Element Tree, mostly from Core Minor changes to Map to start working with Element Tree, from Core Preliminary changes to map efficiency, from FlexiRPG Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Changes to main.py to start working with Element Tree {091029} 00: Changes made to server to start working with Element Tree. Changes made to Meta Server Lib. Prepping test work for a multi meta network page. Minor bug fixed with mini to gametree Zoom Mouse plugin added. Known Issue: Disconnecting causes an server side error. XML data is not being passed correctly.
author sirebral
date Thu, 29 Oct 2009 20:35:28 -0500
parents bd6ca89e4cbb
children 36919b8a3ef9
comparison
equal deleted inserted replaced
118:217fb049bd00 119:9314d63c0941
75 "converts strings to intergers for list sort comparisons for group and player ids so they end up in numeric order" 75 "converts strings to intergers for list sort comparisons for group and player ids so they end up in numeric order"
76 return cmp(int(a),int(b)) 76 return cmp(int(a),int(b))
77 77
78 78
79 class game_group(object): 79 class game_group(object):
80 def __init__( self, id, name, pwd, desc="", boot_pwd="", minVersion="", mapFile=None, messageFile=None, persist =0 ): 80 def __init__(self, id, name, pwd, desc="", boot_pwd="",
81 minVersion="", mapFile=None, messageFile=None, persist=0):
81 self.id = id 82 self.id = id
82 self.name = name 83 self.name = name
83 self.desc = desc 84 self.desc = desc
84 self.minVersion = minVersion 85 self.minVersion = minVersion
85 self.messageFile = messageFile 86 self.messageFile = messageFile
92 self.voice = {} 93 self.voice = {}
93 self.persistant = persist 94 self.persistant = persist
94 self.mapFile = None 95 self.mapFile = None
95 96
96 if mapFile != None: 97 if mapFile != None:
98 """
99 try:
100 f = open(filename, "rb")
101 tree = parse(f)
102 self.xml_root = tree.getroot()
103 except:
104 f.close()
105 self.xml_root = None
106 """
97 self.mapFile = mapFile 107 self.mapFile = mapFile
98 f = open( mapFile ) 108 f = open( mapFile )
99 tree = f.read() 109 tree = f.read()
100 f.close() 110 f.close()
101
102 else: 111 else:
103 f = open(dir_struct["template"] + "default_map.xml") 112 f = open(dir_struct["template"] + "default_map.xml")
104 tree = f.read() 113 tree = f.read()
105 f.close() 114 f.close()
106
107 self.game_map.init_from_xml(tree) 115 self.game_map.init_from_xml(tree)
108 116
109 def save_map(self): 117 def save_map(self):
110 if self.mapFile is not None and self.persistant == 1 and self.mapFile.find("default_map.xml") == -1: 118 if self.mapFile is not None and self.persistant == 1 and self.mapFile.find("default_map.xml") == -1:
111 f = open(self.mapFile, "w") 119 f = open(self.mapFile, "w")
114 122
115 def add_player(self,id): 123 def add_player(self,id):
116 self.players.append(id) 124 self.players.append(id)
117 125
118 def remove_player(self,id): 126 def remove_player(self,id):
119 if self.voice.has_key(id): 127 if self.voice.has_key(id): del self.voice[id]
120 del self.voice[id]
121 self.players.remove(id) 128 self.players.remove(id)
122 129
123 def get_num_players(self): 130 def get_num_players(self):
124 num = len(self.players) 131 num = len(self.players)
125 return num 132 return num
147 if len(minVersion)>len(version): 154 if len(minVersion)>len(version):
148 return 0 155 return 0
149 return 1 156 return 1
150 157
151 #depreciated - see send_group_list() 158 #depreciated - see send_group_list()
152 def toxml(self,act="new"): 159 def toxml(self, act="new"):
153 # Please don't add the boot_pwd to the xml, as this will give it away to players watching their console 160 # Please don't add the boot_pwd to the xml, as this will give it away to players watching their console
154 xml_data = "<group id=\"" + self.id 161 el = Element('group')
155 xml_data += "\" name=\"" + self.name 162 el.set('id', self.id)
156 xml_data += "\" pwd=\"" + str(self.pwd!="") 163 el.set('name', self.name)
157 xml_data += "\" players=\"" + str(self.get_num_players()) 164 el.set('pwd', str(self.pwd!=""))
158 xml_data += "\" action=\"" + act + "\" />" 165 el.set('players', str(self.get_num_players()))
159 return xml_data 166 el.set('action', act)
167 return tostring(el)
168 #xml_data = "<group id=\"" + self.id
169 #xml_data += "\" name=\"" + self.name
170 #xml_data += "\" pwd=\"" + str(self.pwd!="")
171 #xml_data += "\" players=\"" + str(self.get_num_players())
172 #xml_data += "\" action=\"" + act + "\" />"
173 #return xml_data
160 174
161 175
162 class client_stub(client_base): 176 class client_stub(client_base):
163 def __init__(self,inbox,sock,props,log): 177 def __init__(self,inbox,sock,props,log):
164 client_base.__init__(self) 178 client_base.__init__(self)
188 curtime = time.time() 202 curtime = time.time()
189 diff = curtime - self.timeout_time 203 diff = curtime - self.timeout_time
190 if diff > 1800: return 1 204 if diff > 1800: return 1
191 else: return 0 205 else: return 0
192 206
193 def send(self,msg,player,group): 207 def send(self, msg, player, group):
194 if self.get_status() == MPLAY_CONNECTED: 208 if self.get_status() == MPLAY_CONNECTED:
209 #el = Element('msg')
210 #el.set('to', player)
211 #el.set('from', '0')
212 #el.set('group_id', group)
213 #el.text(msg)
195 self.outbox.put("<msg to='" + player + "' from='0' group_id='" + group + "' />" + msg) 214 self.outbox.put("<msg to='" + player + "' from='0' group_id='" + group + "' />" + msg)
196 215
197 def change_group(self,group_id,groups): 216 def change_group(self,group_id,groups):
198 old_group_id = str(self.group_id) 217 old_group_id = str(self.group_id)
199 groups[group_id].add_player(self.id) 218 groups[group_id].add_player(self.id)
236 self.next_player_id = 1 255 self.next_player_id = 1
237 self.plugin_player_id = -1 256 self.plugin_player_id = -1
238 self.next_group_id = 100 257 self.next_group_id = 100
239 self.metas = {} # This holds the registerThread objects for each meta 258 self.metas = {} # This holds the registerThread objects for each meta
240 self.be_registered = 0 # Status flag for whether we want to be registered. 259 self.be_registered = 0 # Status flag for whether we want to be registered.
241 self.serverName = name # Name of this server in the metas 260 self.serverName = name # Name of this server in the metas
242 self.boot_pwd = "" 261 self.boot_pwd = ""
243 self.server_address = None # IP or Name of server to post to the meta. None means the meta will auto-detect it. 262 self.server_address = None # IP or Name of server to post to the meta. None means the meta will auto-detect it.
244 self.defaultMessageFile = None 263 self.defaultMessageFile = None
245 self.userPath = dir_struct["user"] 264 self.userPath = dir_struct["user"]
246 self.lobbyMapFile = "Lobby_map.xml" 265 self.lobbyMapFile = "Lobby_map.xml"
247 self.lobbyMessageFile = "LobbyMessage.html" 266 self.lobbyMessageFile = "LobbyMessage.html"
248 self.banFile = "ban_list.xml" 267 self.banFile = "ban_list.xml"