Mercurial > traipse_dev
comparison orpg/networking/mplay_server.py @ 212:13054be69834 beta
Traipse Beta 'OpenRPG' {100428-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 (Patch-2)
New Features:
New Namespace method with two new syntaxes
New Namespace Internal is context sensitive, always!
New Namespace External is 'as narrow as you make it'
New Namespace FutureCheck helps ensure you don't receive an incorrect node
New PluginDB access for URL2Link plugin
New to Forms, they now show their content in Design Mode
New to Update Manager, checks Repo for updates on software start
Fixes:
Fix to Server GUI startup errors
Fix to Server GUI Rooms tab updating
Fix to Chat and Settings if non existant die roller is picked
Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated
Fix to Alias Lib's Export to Tree, Open, Save features
Fix to alias node, now works properly
Fix to Splitter node, minor GUI cleanup
Fix to Backgrounds not loading through remote loader
Fix to Node name errors
Fix to rolling dice in chat Whispers
Fix to Splitters Sizing issues
Fix to URL2Link plugin, modified regex compilation should remove memory leak
Fix to mapy.py, a roll back due to zoomed grid issues
Fix to whiteboard_handler, Circles work by you clicking the center of the circle
Fix to Servers parse_incoming_dom which was outdated and did not respect XML
Fix to a broken link in the server welcome message
Fix to InterParse and logger requiring traceback
Fix to Update Manager Status Bar
Fix to failed image and erroneous pop up
author | sirebral |
---|---|
date | Wed, 28 Apr 2010 08:08:09 -0500 |
parents | dcae32e219f1 |
children | bb7b9648792c |
comparison
equal
deleted
inserted
replaced
194:44ef45e77880 | 212:13054be69834 |
---|---|
62 | 62 |
63 from orpg.tools.orpg_log import logger, crash, debug | 63 from orpg.tools.orpg_log import logger, crash, debug |
64 from orpg.tools.decorators import debugging | 64 from orpg.tools.decorators import debugging |
65 | 65 |
66 # Snag the version number | 66 # Snag the version number |
67 from orpg.orpg_version import VERSION, PROTOCOL_VERSION, CLIENT_STRING, SERVER_MIN_CLIENT_VERSION | 67 from orpg.orpg_version import VERSION, DISTRO, DIS_VER, BUILD, PROTOCOL_VERSION, CLIENT_STRING, SERVER_MIN_CLIENT_VERSION |
68 | 68 |
69 #Plugins | 69 #Plugins |
70 from server_plugins import ServerPlugins | 70 from server_plugins import ServerPlugins |
71 | 71 |
72 def id_compare(a,b): | 72 def id_compare(a,b): |
251 self.maxSendSize = 1024 | 251 self.maxSendSize = 1024 |
252 self.server_port = OPENRPG_PORT | 252 self.server_port = OPENRPG_PORT |
253 self.allowRemoteKill = False | 253 self.allowRemoteKill = False |
254 self.allowRemoteAdmin = True | 254 self.allowRemoteAdmin = True |
255 self.sendLobbySound = False | 255 self.sendLobbySound = False |
256 self.lobbySound = 'http://www.digitalxero.net/music/mus_tavern1.bmu' ##used? | 256 #self.lobbySound = 'http://www.digitalxero.net/music/mus_tavern1.bmu' ##used? |
257 | 257 |
258 def initServer(self, **kwargs): | 258 def initServer(self, **kwargs): |
259 for atter, value in kwargs.iteritems(): setattr(self, atter, value) | 259 for atter, value in kwargs.iteritems(): setattr(self, atter, value) |
260 validate.config_file( self.lobbyMapFile, "default_Lobby_map.xml" ) | 260 validate.config_file( self.lobbyMapFile, "default_Lobby_map.xml" ) |
261 validate.config_file( self.lobbyMessageFile, "default_LobbyMessage.html" ) | 261 validate.config_file( self.lobbyMessageFile, "default_LobbyMessage.html" ) |
1067 if need_new: self.new_request(newsock, xml_dom) | 1067 if need_new: self.new_request(newsock, xml_dom) |
1068 else: | 1068 else: |
1069 msg = self.groups[group_id].game_map.get_all_xml() | 1069 msg = self.groups[group_id].game_map.get_all_xml() |
1070 self.send(msg,id,group_id) | 1070 self.send(msg,id,group_id) |
1071 | 1071 |
1072 def new_request(self,newsock, xml_dom, LOBBY_ID='0'): | 1072 def new_request(self, newsock, xml_dom, LOBBY_ID='0'): |
1073 #build client stub | 1073 #build client stub |
1074 props = {} | 1074 props = {} |
1075 # Don't trust what the client tells us...trust what they connected as! | 1075 # Don't trust what the client tells us...trust what they connected as! |
1076 props['ip'] = socket.gethostbyname( newsock.getpeername()[0] ) | 1076 props['ip'] = socket.gethostbyname( newsock.getpeername()[0] ) |
1077 | 1077 |
1099 new_stub.EnableMessageLogging = self.log_network_messages | 1099 new_stub.EnableMessageLogging = self.log_network_messages |
1100 self.sendMsg(newsock, new_stub.toxml("new"), False, None) | 1100 self.sendMsg(newsock, new_stub.toxml("new"), False, None) |
1101 | 1101 |
1102 # send confirmation | 1102 # send confirmation |
1103 data = self.recvMsg(newsock, new_stub.useCompression, new_stub.compressionType) | 1103 data = self.recvMsg(newsock, new_stub.useCompression, new_stub.compressionType) |
1104 try: xml_dom = XML(data) | 1104 try: |
1105 xml_dom = XML(data) | |
1105 except Exception, e: | 1106 except Exception, e: |
1106 print e | 1107 print e |
1107 (remote_host,remote_port) = newsock.getpeername() | 1108 (remote_host,remote_port) = newsock.getpeername() |
1108 bad_xml_string = "Your client sent an illegal message to the server and will be disconnected. " | 1109 bad_xml_string = "Your client sent an illegal message to the server and will be disconnected. " |
1109 bad_xml_string += "Please report this bug to the development team at:<br /> " | 1110 bad_xml_string += "Please report this bug to the development team at:<br /> " |
1110 bad_xml_string += "<a href=\"http://sourceforge.net/tracker/?group_id=2237&atid=102237\">OpenRPG bugs " | 1111 bad_xml_string += "<a href='http://www.assembla.com/spaces/traipse_dev/tickets/'>Traipse-Dev " |
1111 bad_xml_string += "(http://sourceforge.net/tracker/?group_id=2237&atid=102237)</a><br />" | 1112 bad_xml_string += "(http://www.assembla.com/spaces/traipse_dev/tickets/)</a><br />" |
1112 self.sendMsg( newsock, "<msg to='" + props['id'] + "' from='" + props['id'] + "' group_id='0' />" + bad_xml_string, | 1113 self.sendMsg( newsock, "<msg to='" + props['id'] + "' from='" + props['id'] + "' group_id='0' />" + bad_xml_string, |
1113 new_stub.useCompression, new_stub.compressionType) | 1114 new_stub.useCompression, new_stub.compressionType) |
1114 | 1115 |
1115 time.sleep(2) | 1116 time.sleep(2) |
1116 newsock.close() | 1117 newsock.close() |
1212 self.sendMsg( newsock, "<msg to='" + props['id'] + "' from='" + props['id'] + "' group_id='0' />" + err_string, new_stub.useCompression, new_stub.compressionType ) | 1213 self.sendMsg( newsock, "<msg to='" + props['id'] + "' from='" + props['id'] + "' group_id='0' />" + err_string, new_stub.useCompression, new_stub.compressionType ) |
1213 time.sleep(2) | 1214 time.sleep(2) |
1214 newsock.close() | 1215 newsock.close() |
1215 | 1216 |
1216 # Display the lobby message | 1217 # Display the lobby message |
1217 self.SendLobbyMessage(newsock,props['id']) | 1218 print 'lobby message' |
1219 self.SendLobbyMessage(newsock, props['id']) | |
1218 | 1220 |
1219 def checkClientVersion(self, clientversion): | 1221 def checkClientVersion(self, clientversion): |
1220 minv = self.minClientVersion.split('.') | 1222 minv = self.minClientVersion.split('.') |
1221 cver = clientversion.split('.') | 1223 cver = clientversion.split('.') |
1222 for i in xrange(min(len(minv),len(cver))): | 1224 for i in xrange(min(len(minv),len(cver))): |
1232 """ | 1234 """ |
1233 # Display the lobby message | 1235 # Display the lobby message |
1234 # prepend this server's version string to the the lobby message | 1236 # prepend this server's version string to the the lobby message |
1235 """ | 1237 """ |
1236 try: | 1238 try: |
1237 lobbyMsg = "You have connected to an <a href=\"http://www.openrpg.com\">OpenRPG</a> " | 1239 lobbyMsg = "You have connected to a <a href='http://www.knowledgearcana.com/traipse-openrpg'>" |
1238 lobbyMsg += "server, version '" + VERSION + "'" | 1240 lobbyMsg += DISTRO +'</a> '+ DIS_VER +' {'+ BUILD+'}' |
1241 lobbyMsg += " server, built on OpenRPG version '" + VERSION + "'" | |
1239 | 1242 |
1240 # See if we have a server name to report! | 1243 # See if we have a server name to report! |
1241 if len(self.serverName): lobbyMsg += ", named '" + self.serverName + "'." | 1244 if len(self.serverName): lobbyMsg += ", named '" + self.serverName + "'." |
1242 else: lobbyMsg += "." | 1245 else: lobbyMsg += "." |
1243 | 1246 |
1248 except: pass | 1251 except: pass |
1249 else: | 1252 else: |
1250 open_msg = open( self.userPath + "LobbyMessage.html", "r" ) | 1253 open_msg = open( self.userPath + "LobbyMessage.html", "r" ) |
1251 lobbyMsg += open_msg.read() | 1254 lobbyMsg += open_msg.read() |
1252 open_msg.close() | 1255 open_msg.close() |
1253 | |
1254 # Send the server's lobby message to the client no matter what | 1256 # Send the server's lobby message to the client no matter what |
1255 self.sendMsg(socket, "<msg to='" + player_id + "' from='0' group_id='0' />" + lobbyMsg, | 1257 self.sendMsg(socket, "<msg to='" + player_id + "' from='0' group_id='0' />" + lobbyMsg, |
1256 self.players[player_id].useCompression, self.players[player_id].compressionType) | 1258 self.players[player_id].useCompression, self.players[player_id].compressionType) |
1257 if self.sendLobbySound: | 1259 if self.sendLobbySound: |
1258 self.sendMsg(socket, '<sound url="' + self.lobbySound + '" group_id="0" from="0" loop="True" />', | 1260 self.sendMsg(socket, '<sound url="' + self.lobbySound + '" group_id="0" from="0" loop="True" />', |
1392 self.log_msg(str(e)) | 1394 self.log_msg(str(e)) |
1393 self.log_msg("message handler thread exiting...") | 1395 self.log_msg("message handler thread exiting...") |
1394 self.incoming_event.set() | 1396 self.incoming_event.set() |
1395 | 1397 |
1396 def parse_incoming_dom(self, data): | 1398 def parse_incoming_dom(self, data): |
1397 end = data.find(">") #locate end of first element of message | 1399 end = data.find(">") |
1398 head = data[:end+1] | 1400 head = data[:end+1] |
1399 xml_dom = None | 1401 msg = data[end+1:] |
1400 try: | 1402 ### This if statement should help close invalid messages. ### |
1401 xml_dom = XML(head) | 1403 if head[end:] != '/': |
1404 if head[end:] != '>': head = head[:end] + '/>' | |
1405 try: | |
1406 try: xml_dom = fromstring(head) | |
1407 except: xml_dom = fromstring(head[:end] +'/>') | |
1402 self.message_action(xml_dom, data) | 1408 self.message_action(xml_dom, data) |
1403 | |
1404 except Exception, e: | 1409 except Exception, e: |
1405 print "Error in parse of inbound message. Ignoring message." | 1410 print "Error in parse of inbound message. Ignoring message." |
1406 print " Offending data(" + str(len(data)) + "bytes)=" + data | 1411 print " Offending data(" + str(len(data)) + "bytes)=" + data |
1407 print "Exception=" + str(e) | 1412 print "Exception=" + str(e) |
1408 | 1413 |
1601 # this line sends a handle role message to change the players role | 1606 # this line sends a handle role message to change the players role |
1602 self.send_player_list(from_id,group_id) | 1607 self.send_player_list(from_id,group_id) |
1603 #notify user about others in the room | 1608 #notify user about others in the room |
1604 self.return_room_roles(from_id,group_id) | 1609 self.return_room_roles(from_id,group_id) |
1605 self.log_msg(("join_group", (self.groups[group_id].name, group_id, from_id))) | 1610 self.log_msg(("join_group", (self.groups[group_id].name, group_id, from_id))) |
1611 self.log_msg(("update_group", (self.groups[old_group_id].name, old_group_id, len(self.groups[old_group_id].players) ))) | |
1606 self.log_msg(("update_group", (self.groups[group_id].name, group_id, len(self.groups[group_id].players) ))) | 1612 self.log_msg(("update_group", (self.groups[group_id].name, group_id, len(self.groups[group_id].players) ))) |
1607 self.handle_role("set", from_id, self.players[from_id].role, self.groups[group_id].boot_pwd, group_id) | 1613 self.handle_role("set", from_id, self.players[from_id].role, self.groups[group_id].boot_pwd, group_id) |
1608 except Exception, e: | 1614 except Exception, e: |
1609 self.log_msg(str(e)) | 1615 self.log_msg(str(e)) |
1610 thread.start_new_thread(self.registerRooms,(0,)) | 1616 thread.start_new_thread(self.registerRooms,(0,)) |
1630 self.groups[group_id].moderated = moderated | 1636 self.groups[group_id].moderated = moderated |
1631 ins = "" | 1637 ins = "" |
1632 if persist !=0: ins="Persistant " | 1638 if persist !=0: ins="Persistant " |
1633 lmsg = "Creating " + ins + "Group... (" + str(group_id) + ") " + str(name) | 1639 lmsg = "Creating " + ins + "Group... (" + str(group_id) + ") " + str(name) |
1634 self.log_msg( lmsg ) | 1640 self.log_msg( lmsg ) |
1635 self.log_msg(("create_group", (str(name), int(group_id), pwd, 0) )) | 1641 self.log_msg(("create_group", (str(name), int(group_id), 0, 'No' if pwd == '' else 'Yes') )) |
1636 | 1642 |
1637 def change_group_name(self, gid, name, pid): | 1643 def change_group_name(self, gid, name, pid): |
1638 "Change the name of a group" | 1644 "Change the name of a group" |
1639 # Check for & in name. We want to allow this because of its common | 1645 # Check for & in name. We want to allow this because of its common |
1640 # use in d&d games. | 1646 # use in d&d games. |
2182 traceback.print_exc() | 2188 traceback.print_exc() |
2183 self.log_msg("Exception: send_player_list(): " + str(e)) | 2189 self.log_msg("Exception: send_player_list(): " + str(e)) |
2184 | 2190 |
2185 def send_group_list(self, to_id, action="new"): | 2191 def send_group_list(self, to_id, action="new"): |
2186 try: | 2192 try: |
2187 print self.groups | |
2188 for key in self.groups: | 2193 for key in self.groups: |
2189 xml = self.groups[key].toxml(action) | 2194 xml = self.groups[key].toxml(action) |
2190 print xml, key | |
2191 self.players[to_id].outbox.put(xml) | 2195 self.players[to_id].outbox.put(xml) |
2192 except Exception, e: | 2196 except Exception, e: |
2193 self.log_msg("Exception: send_group_list(): (client #"+to_id+") : " + str(e)) | 2197 self.log_msg("Exception: send_group_list(): (client #"+to_id+") : " + str(e)) |
2194 traceback.print_exc() | 2198 traceback.print_exc() |
2195 | 2199 |