Mercurial > traipse_dev
comparison orpg/networking/mplay_server.py @ 235:f6aca9a7370b alpha
Traipse Alpha 'OpenRPG' {100616-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 (Closed)
New Features:
New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order
New to Server GUI, can now clear log
Updates:
Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence.
Update to Browser Server window. Display rooms with ' " & cleaner
Update to Server. Handles ' " & cleaner.
Fixes:
Fix to InterParse that was causing an Infernal Loop with Namespace Internal
Fix to XML data, removed old Minidom and switched to Element Tree
Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread
Fix to metaservers.xml file not being created
Fix to Single and Double quotes in Whiteboard text
Fix to Background images not showing when using the Image Server
Fix to Duplicate chat names appearing
Fix to Server GUI's logging output
Fix to FNB.COLORFUL_TABS bug.
author | sirebral |
---|---|
date | Wed, 16 Jun 2010 03:01:22 -0500 |
parents | f96e0e6d32d2 |
children |
comparison
equal
deleted
inserted
replaced
234:f96e0e6d32d2 | 235:f6aca9a7370b |
---|---|
49 | 49 |
50 from mplay_client import * | 50 from mplay_client import * |
51 from mplay_client import MPLAY_LENSIZE | 51 from mplay_client import MPLAY_LENSIZE |
52 from orpg.dirpath import dir_struct | 52 from orpg.dirpath import dir_struct |
53 import orpg.tools.validate | 53 import orpg.tools.validate |
54 import htmlentitydefs | |
54 | 55 |
55 from orpg.mapper.map_msg import * | 56 from orpg.mapper.map_msg import * |
56 from threading import Lock, RLock | 57 from threading import Lock, RLock |
57 from struct import pack, unpack, calcsize | 58 from struct import pack, unpack, calcsize |
58 from meta_server_lib import * | 59 from meta_server_lib import * |
314 try: | 315 try: |
315 self.banDom = parse(self.userPath + 'ban_list.xml') | 316 self.banDom = parse(self.userPath + 'ban_list.xml') |
316 self.banDoc = self.banDom.getroot() | 317 self.banDoc = self.banDom.getroot() |
317 | 318 |
318 for element in self.banDom.findall('banned'): | 319 for element in self.banDom.findall('banned'): |
319 playerName = element.get('name').replace("&", "&").replace("<", "<").replace('"', """).replace(">", ">") | 320 playerName = element.get('name').replace("&", "&").replace("<", "<").replace('"', "").replace(">", ">") |
320 playerIP = element.get('ip') | 321 playerIP = element.get('ip') |
321 self.ban_list[playerIP] = {} | 322 self.ban_list[playerIP] = {} |
322 self.ban_list[playerIP]['ip'] = playerIP | 323 self.ban_list[playerIP]['ip'] = playerIP |
323 self.ban_list[playerIP]['name'] = playerName | 324 self.ban_list[playerIP]['name'] = playerName |
324 self.log_msg(str(playerName) + " " + str(playerIP) + " is banned.") | 325 self.log_msg(str(playerName) + " " + str(playerIP) + " is banned.") |
334 # try to use it. | 335 # try to use it. |
335 try: | 336 try: |
336 etreeEl = Element('server') | 337 etreeEl = Element('server') |
337 for ip in self.ban_list: | 338 for ip in self.ban_list: |
338 el = Element('banned') | 339 el = Element('banned') |
339 el.set('name', str(self.ban_list[ip]['name'].replace("&", "&").replace("<", "<").replace(""", '"').replace(">", ">"))) | 340 el.set('name', str(self.ban_list[ip]['name'].replace("&", "&").replace("<", "<").replace("", '"').replace(">", ">"))) |
340 el.set('ip', str(self.ban_list[ip]['ip'])) | 341 el.set('ip', str(self.ban_list[ip]['ip'])) |
341 etreeEl.append(el) | 342 etreeEl.append(el) |
342 file = open(self.userPath + self.banFile ,"w") | 343 file = open(self.userPath + self.banFile ,"w") |
343 file.write(tostring(etreeEl)) | 344 file.write(tostring(etreeEl)) |
344 file.close() | 345 file.close() |
1689 def change_group_name(self, gid, name, pid): | 1690 def change_group_name(self, gid, name, pid): |
1690 "Change the name of a group" | 1691 "Change the name of a group" |
1691 # Check for & in name. We want to allow this because of its common | 1692 # Check for & in name. We want to allow this because of its common |
1692 # use in d&d games. | 1693 # use in d&d games. |
1693 try: | 1694 try: |
1694 loc = name.find("&") | 1695 name = name.replace('&', '&') |
1695 oldloc = 0 | 1696 name = name.replace('"', '"e;').replace("'", ''').replace("<", "<").replace(">", ">") |
1696 while loc > -1: | |
1697 loc = name.find("&",oldloc) | |
1698 if loc > -1: | |
1699 b = name[:loc] | |
1700 e = name[loc+1:] | |
1701 value = b + "&" + e | |
1702 oldloc = loc+1 | |
1703 loc = name.find("'") | |
1704 oldloc = 0 | |
1705 while loc > -1: | |
1706 loc = name.find("'",oldloc) | |
1707 if loc > -1: | |
1708 b = name[:loc] | |
1709 e = name[loc+1:] | |
1710 name = b + "'" + e | |
1711 oldloc = loc+1 | |
1712 loc = name.find('"') | |
1713 oldloc = 0 | |
1714 while loc > -1: | |
1715 loc = name.find('"',oldloc) | |
1716 if loc > -1: | |
1717 b = name[:loc] | |
1718 e = name[loc+1:] | |
1719 name = b + """ + e | |
1720 oldloc = loc+1 | |
1721 oldroomname = self.groups[gid].name | 1697 oldroomname = self.groups[gid].name |
1722 self.groups[gid].name = str(name) | 1698 self.groups[gid].name = str(name) |
1723 lmessage = "Room name changed to from \"" + oldroomname + "\" to \"" + name + "\"" | 1699 lmessage = "Room name changed to from \"" + oldroomname + "\" to \"" + name + "\"" |
1724 self.log_msg(lmessage + " by " + str(pid) ) | 1700 self.log_msg(lmessage + " by " + str(pid) ) |
1725 self.log_msg(("update_group", (str(name), group_id, False))) | 1701 self.log_msg(("update_group", (str(name), group_id, False))) |
1742 # see if passwords are allowed on this server and null password if not | 1718 # see if passwords are allowed on this server and null password if not |
1743 if self.allow_room_passwords != 1: pwd = "" | 1719 if self.allow_room_passwords != 1: pwd = "" |
1744 | 1720 |
1745 # Check for & in name. We want to allow this because of its common | 1721 # Check for & in name. We want to allow this because of its common |
1746 # use in d&d games. | 1722 # use in d&d games. |
1747 | 1723 name = name.replace('&', '&') |
1748 loc = name.find("&") | 1724 name = name.replace('"', '"e;').replace("'", ''').replace("<", "<").replace(">", ">") |
1749 oldloc = 0 | |
1750 while loc > -1: | |
1751 loc = name.find("&",oldloc) | |
1752 if loc > -1: | |
1753 b = name[:loc] | |
1754 e = name[loc+1:] | |
1755 name = b + "&" + e | |
1756 oldloc = loc+1 | |
1757 loc = name.find("'") | |
1758 oldloc = 0 | |
1759 while loc > -1: | |
1760 loc = name.find("'",oldloc) | |
1761 if loc > -1: | |
1762 b = name[:loc] | |
1763 e = name[loc+1:] | |
1764 name = b + "'" + e | |
1765 oldloc = loc+1 | |
1766 loc = name.find('"') | |
1767 oldloc = 0 | |
1768 while loc > -1: | |
1769 loc = name.find('"',oldloc) | |
1770 if loc > -1: | |
1771 b = name[:loc] | |
1772 e = name[loc+1:] | |
1773 name = b + """ + e | |
1774 oldloc = loc+1 | |
1775 group_id = str(self.next_group_id) | 1725 group_id = str(self.next_group_id) |
1776 self.next_group_id += 1 | 1726 self.next_group_id += 1 |
1777 | 1727 |
1778 self.groups[group_id] = game_group(group_id, name, pwd, "", boot_pwd, minVersion, None, messageFile) | 1728 self.groups[group_id] = game_group(group_id, name, pwd, "", boot_pwd, minVersion, None, messageFile) |
1779 self.groups[group_id].voice[from_id]=1 | 1729 self.groups[group_id].voice[from_id]=1 |
2025 ### if boot comes from lobby dump player from the server | 1975 ### if boot comes from lobby dump player from the server |
2026 ### any user in-room boot will dump to lobby instead | 1976 ### any user in-room boot will dump to lobby instead |
2027 """ | 1977 """ |
2028 if given_boot_pwd == server_admin_pwd: | 1978 if given_boot_pwd == server_admin_pwd: |
2029 # Send a message to everyone in the room, letting them know someone has been booted | 1979 # Send a message to everyone in the room, letting them know someone has been booted |
2030 boot_msg = "<msg to='all' from='%s' group_id='%s'/><font color='#FF0000'>Booting '(%s) %s' from server...</font>" % (from_id, group_id, to_id, self.players[to_id].name) | 1980 msg = '<font color="#FF0000">' |
1981 msg += 'Booting (' +str(to_id)+ ') ' +self.players[to_id].name+ ' from server...</font>' | |
1982 | |
1983 boot_msg = self.buildMsg('all', '0', group_id, msg) | |
2031 self.log_msg("boot_msg:" + boot_msg) | 1984 self.log_msg("boot_msg:" + boot_msg) |
2032 self.send_to_group( "0", group_id, boot_msg ) | 1985 self.send_to_group( "0", group_id, boot_msg ) |
2033 time.sleep( 1 ) | 1986 time.sleep( 1 ) |
2034 self.log_msg("Booting player " + str(to_id) + " from server.") | 1987 self.log_msg("Booting player " + str(to_id) + " from server.") |
2035 | |
2036 # Send delete player event to all | 1988 # Send delete player event to all |
2037 self.send_to_group("0",group_id,self.players[to_id].toxml("del")) | 1989 self.send_to_group("0",group_id,self.players[to_id].toxml("del")) |
2038 | |
2039 # Remove the player from local data structures | 1990 # Remove the player from local data structures |
2040 self.del_player(to_id,group_id) | 1991 self.del_player(to_id,group_id) |
2041 | |
2042 # Refresh the group data | 1992 # Refresh the group data |
2043 self.check_group(to_id, group_id) | 1993 self.check_group(to_id, group_id) |
2044 | 1994 |
2045 elif actual_boot_pwd == given_boot_pwd: | 1995 elif actual_boot_pwd == given_boot_pwd: |
2046 # Send a message to everyone in the room, letting them know someone has been booted | 1996 # Send a message to everyone in the room, letting them know someone has been booted |
2047 boot_msg = "<msg to='all' from='%s' group_id='%s'/><font color='#FF0000'>Booting '(%s) %s' from room...</font>" % (from_id, group_id, to_id, self.players[to_id].name) | 1997 msg = '<font color="#FF0000">' |
1998 msg += 'Booting (' +str(to_id)+ ') ' +self.players[to_id].name+ ' from server...</font>' | |
1999 boot_msg = self.buildMsg('all', from_id, group_id, msg) | |
2048 self.log_msg("boot_msg:" + boot_msg) | 2000 self.log_msg("boot_msg:" + boot_msg) |
2049 self.send_to_group( "0", group_id, boot_msg ) | 2001 self.send_to_group( "0", group_id, boot_msg ) |
2050 time.sleep( 1 ) | 2002 time.sleep( 1 ) |
2051 | |
2052 #dump player into the lobby | 2003 #dump player into the lobby |
2053 self.move_player(to_id,"0") | 2004 self.move_player(to_id,"0") |
2054 | |
2055 # Refresh the group data | 2005 # Refresh the group data |
2056 self.check_group(to_id, group_id) | 2006 self.check_group(to_id, group_id) |
2057 else: | 2007 else: |
2058 #tell the clients password manager the password failed -- SD 8/03 | 2008 #tell the clients password manager the password failed -- SD 8/03 |
2059 pm = "<password signal='fail' type='admin' id='" + group_id + "' data=''/>" | 2009 pm = "<password signal='fail' type='admin' id='" + group_id + "' data=''/>" |
2110 def admin_build_banlist(self): | 2060 def admin_build_banlist(self): |
2111 validate.config_file("ban_list.xml", "default_ban_list.xml" ) | 2061 validate.config_file("ban_list.xml", "default_ban_list.xml" ) |
2112 configDom = parse(dir_struct["user"] + 'ban_list.xml') | 2062 configDom = parse(dir_struct["user"] + 'ban_list.xml') |
2113 self.ban_list = {} | 2063 self.ban_list = {} |
2114 for element in configDom.findall('banned'): | 2064 for element in configDom.findall('banned'): |
2115 player = element.get('name').replace("&", "&").replace("<", "<").replace('"', """).replace(">", ">") | 2065 player = element.get('name').replace("&", "&").replace("<", "<").replace('"', "").replace(">", ">") |
2116 ip = element.get('ip') | 2066 ip = element.get('ip') |
2117 self.ban_list[ip] = {} | 2067 self.ban_list[ip] = {} |
2118 self.ban_list[ip]['ip'] = ip | 2068 self.ban_list[ip]['ip'] = ip |
2119 self.ban_list[ip]['name'] = element.get('name') | 2069 self.ban_list[ip]['name'] = element.get('name') |
2120 ################ | 2070 ################ |