comparison orpg/networking/mplay_server.py @ 151:06f10429eedc alpha

Traipse Alpha 'OpenRPG' {091125-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 (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 Wed, 25 Nov 2009 06:15:49 -0600
parents 8e07c1a2c69b
children 5609ac142298
comparison
equal deleted inserted replaced
149:c2caca988a11 151:06f10429eedc
89 self.lock = Lock() 89 self.lock = Lock()
90 self.moderated = 0 90 self.moderated = 0
91 self.voice = {} 91 self.voice = {}
92 self.persistant = persist 92 self.persistant = persist
93 self.mapFile = None 93 self.mapFile = None
94 ### Needs to use Element Tree closer
95 if mapFile != None: tree = parse(mapFile) 94 if mapFile != None: tree = parse(mapFile)
96 else: tree = parse(dir_struct["template"] + "default_map.xml") 95 else: tree = parse(dir_struct["template"] + "default_map.xml")
97 tree = tree.getroot() 96 tree = tree.getroot()
98 self.game_map.init_from_xml(tostring(tree)) 97 self.game_map.init_from_xml(tostring(tree))
99 98
347 346
348 # This method reads in the server's configuration file and reconfigs the server 347 # This method reads in the server's configuration file and reconfigs the server
349 # as needed, over-riding any default values as requested. 348 # as needed, over-riding any default values as requested.
350 349
351 def initServerConfig(self): 350 def initServerConfig(self):
352 debug(log=False)
353 self.log_msg("Processing Server Configuration File... " + self.userPath) 351 self.log_msg("Processing Server Configuration File... " + self.userPath)
354 # make sure the server_ini.xml exists! 352 # make sure the server_ini.xml exists!
355 validate.config_file( "server_ini.xml", "default_server_ini.xml" ) 353 validate.config_file( "server_ini.xml", "default_server_ini.xml" )
356 # try to use it. 354 # try to use it.
357 try: 355 try:
847 self.listen_event.wait(10) 845 self.listen_event.wait(10)
848 self.incoming_event.wait(10) 846 self.incoming_event.wait(10)
849 self.log_msg("Server stopped!") 847 self.log_msg("Server stopped!")
850 848
851 def log_msg(self,msg): 849 def log_msg(self,msg):
852 debug(parents=True)
853 if self.log_to_console: 850 if self.log_to_console:
854 if self.log_console: self.log_console(msg) 851 if self.log_console: self.log_console(msg)
855 else: print str(msg) 852 else: print str(msg)
856 853
857 def print_help(self): 854 def print_help(self):
1193 1190
1194 # Re-initialize the role for this player incase they came from a different server 1191 # Re-initialize the role for this player incase they came from a different server
1195 self.handle_role("set", props['id'], "GM", self.groups[LOBBY_ID].boot_pwd, LOBBY_ID) 1192 self.handle_role("set", props['id'], "GM", self.groups[LOBBY_ID].boot_pwd, LOBBY_ID)
1196 cmsg = "Client Connect: (" + str(props['id']) + ") " + str(props['name']) + " [" + str(props['ip']) + "]" 1193 cmsg = "Client Connect: (" + str(props['id']) + ") " + str(props['name']) + " [" + str(props['ip']) + "]"
1197 self.log_msg(cmsg) 1194 self.log_msg(cmsg)
1195 self.log_msg(("update_group", (self.groups[LOBBY_ID].name, LOBBY_ID, len(self.groups[LOBBY_ID].players) ) ))
1198 cmsg = ("connect", props) ################################################# 1196 cmsg = ("connect", props) #################################################
1199 self.log_msg(cmsg) 1197 self.log_msg(cmsg)
1200 1198
1201 # If already registered then re-register, thereby updating the Meta 1199 # If already registered then re-register, thereby updating the Meta
1202 # on the number of players 1200 # on the number of players
1603 # this line sends a handle role message to change the players role 1601 # this line sends a handle role message to change the players role
1604 self.send_player_list(from_id,group_id) 1602 self.send_player_list(from_id,group_id)
1605 #notify user about others in the room 1603 #notify user about others in the room
1606 self.return_room_roles(from_id,group_id) 1604 self.return_room_roles(from_id,group_id)
1607 self.log_msg(("join_group", (self.groups[group_id].name, group_id, from_id))) 1605 self.log_msg(("join_group", (self.groups[group_id].name, group_id, from_id)))
1606 self.log_msg(("update_group", (self.groups[group_id].name, group_id, len(self.groups[group_id].players) )))
1608 self.handle_role("set", from_id, self.players[from_id].role, self.groups[group_id].boot_pwd, group_id) 1607 self.handle_role("set", from_id, self.players[from_id].role, self.groups[group_id].boot_pwd, group_id)
1609 except Exception, e: 1608 except Exception, e:
1610 self.log_msg(str(e)) 1609 self.log_msg(str(e))
1611 thread.start_new_thread(self.registerRooms,(0,)) 1610 thread.start_new_thread(self.registerRooms,(0,))
1612 1611
1907 self.check_group_members(group_id) 1906 self.check_group_members(group_id)
1908 return 1907 return
1909 1908
1910 def handle_role(self, act, player, role, given_boot_pwd, group_id): 1909 def handle_role(self, act, player, role, given_boot_pwd, group_id):
1911 if act == "display": 1910 if act == "display":
1912 msg = "<msg to=\"" + player + "\" from=\"0\" group_id=\"" + group_id + "\" />" 1911 msg = "<msg to='" + player + "' from='0' group_id='" + group_id + "' />"
1913 msg += "Displaying Roles<br /><br /><u>Role</u>&nbsp&nbsp&nbsp<u>Player</u><br />" 1912 msg += "Displaying Roles<br /><br /><u>Role</u>&nbsp&nbsp&nbsp<u>Player</u><br />"
1914 keys = self.players.keys() 1913 keys = self.players.keys()
1915 for m in keys: 1914 for m in keys:
1916 if self.players[m].group_id == group_id: msg += self.players[m].role + " " + self.players[m].name + "<br />" 1915 if self.players[m].group_id == group_id: msg += self.players[m].role + " " + self.players[m].name + "<br />"
1917 self.send(msg,player,group_id) 1916 self.send(msg,player,group_id)
1994 1993
1995 # Refresh the group data 1994 # Refresh the group data
1996 self.check_group(to_id, group_id) 1995 self.check_group(to_id, group_id)
1997 else: 1996 else:
1998 #tell the clients password manager the password failed -- SD 8/03 1997 #tell the clients password manager the password failed -- SD 8/03
1999 pm = "<password signal=\"fail\" type=\"admin\" id=\"" + group_id + "\" data=\"\"/>" 1998 pm = "<password signal='fail' type='admin' id='" + group_id + "' data=''/>"
2000 self.players[from_id].outbox.put(pm) 1999 self.players[from_id].outbox.put(pm)
2001 print "boot passwords did not match" 2000 print "boot passwords did not match"
2002 2001
2003 except Exception, e: 2002 except Exception, e:
2004 traceback.print_exc() 2003 traceback.print_exc()
2025 self.log_msg("boot_msg:" + boot_msg) 2024 self.log_msg("boot_msg:" + boot_msg)
2026 if (silent == 0): self.send_to_group( "0", group_id, boot_msg ) 2025 if (silent == 0): self.send_to_group( "0", group_id, boot_msg )
2027 time.sleep( 1 ) 2026 time.sleep( 1 )
2028 2027
2029 self.log_msg("kicking player " + str(id) + " from server.") 2028 self.log_msg("kicking player " + str(id) + " from server.")
2029
2030 # Send delete player event to all 2030 # Send delete player event to all
2031 self.send_to_group("0",group_id,self.players[id].toxml("del")) 2031 self.send_to_group("0", group_id, self.players[id].toxml("del"))
2032 2032
2033 # Remove the player from local data structures 2033 # Remove the player from local data structures
2034 self.del_player(id,group_id) 2034 self.del_player(id,group_id)
2035 2035
2036 # Refresh the group data 2036 # Refresh the group data
2078 self.saveBanList() 2078 self.saveBanList()
2079 2079
2080 # Send a message to everyone in the victim's room, letting them know someone has been booted 2080 # Send a message to everyone in the victim's room, letting them know someone has been booted
2081 ban_msg = "<msg to='all' from='0' group_id='%s'/><font color='#FF0000'>Banning '(%s) %s' from server... %s</font>" % ( group_id, id, self.players[id].name, str(message)) 2081 ban_msg = "<msg to='all' from='0' group_id='%s'/><font color='#FF0000'>Banning '(%s) %s' from server... %s</font>" % ( group_id, id, self.players[id].name, str(message))
2082 self.log_msg("ban_msg:" + ban_msg) 2082 self.log_msg("ban_msg:" + ban_msg)
2083 if (silent == 0): 2083 if (silent == 0): self.send_to_group("0", group_id, ban_msg)
2084 self.send_to_group("0", group_id, ban_msg)
2085 time.sleep( .1 ) 2084 time.sleep( .1 )
2086 2085
2087 self.log_msg("baning player " + str(id) + " from server.") 2086 self.log_msg("baning player " + str(id) + " from server.")
2088 # Send delete player event to all 2087 # Send delete player event to all
2089 self.send_to_group("0", group_id, self.players[id].toxml("del")) 2088 self.send_to_group("0", group_id, self.players[id].toxml("del"))
2518 pl += "<b>GROUP &amp; '' PLAYER LIST</b></font></td></tr>" 2517 pl += "<b>GROUP &amp; '' PLAYER LIST</b></font></td></tr>"
2519 try: 2518 try:
2520 keys = self.groups.keys() 2519 keys = self.groups.keys()
2521 keys.sort(id_compare) 2520 keys.sort(id_compare)
2522 for k in keys: 2521 for k in keys:
2523 debug((self.groups, self.groups[k], self.groups[k].name))
2524 groupstring = "<tr><td bgcolor='" + COLOR2 + "' colspan='2'>" 2522 groupstring = "<tr><td bgcolor='" + COLOR2 + "' colspan='2'>"
2525 groutstring += "<b>Group " + str(k) + ": " + self.groups[k].name + "</b>" 2523 groutstring += "<b>Group " + str(k) + ": " + self.groups[k].name + "</b>"
2526 groupstring += "</td><td bgcolor=" + COLOR2 + " > <i>Password: " + self.groups[k].pwd + "</td>" 2524 groupstring += "</td><td bgcolor=" + COLOR2 + " > <i>Password: " + self.groups[k].pwd + "</td>"
2527 groupstring += "<td bgcolor=" + COLOR2 + " > Boot: " + self.groups[k].boot_pwd + "</i></td></tr>" 2525 groupstring += "<td bgcolor=" + COLOR2 + " > Boot: " + self.groups[k].boot_pwd + "</i></td></tr>"
2528 pl += groupstring; debug(groupstring) 2526 pl += groupstring
2529 ids = self.groups[k].get_player_ids() 2527 ids = self.groups[k].get_player_ids()
2530 ids.sort(id_compare) 2528 ids.sort(id_compare)
2531 for id in ids: 2529 for id in ids:
2532 if self.players.has_key(id): 2530 if self.players.has_key(id):
2533 if k != "0": 2531 if k != "0":