changeset 224:29cf1a17ca16 alpha

Traipse Alpha 'OpenRPG' {100503-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) Finalizing!!! 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 New to Mini Lin node, change title in design mode New to Game Tree, never lose a node, appends a number to the end of corrupted trees New to Server GUI, Traipse Suite's Debug Console New Namespace plugin, Allows Traipse users to use the Standard syntax !@ :: @! Updates: Update to White Board layer, uses a pencil image for color button Update to Grid Layer, uses a grid image for color button Update to Chat Window, size of drop down menus Update to default lobby message Update to template Text node Update to 4e PC Sheet node Update to how display names are acquired Update to Server, added some 'Pious' technology 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 Fix to Mini Lib node that was preventing use Fix to plugins that parce dice but did not call InterParse Fix to nodes for name changing by double click Fix to Game Tree, node ordering on drag and drop corrected Fix to Game Tree, corrupted error message was not showing Fix to Update Manager, checks for internet connection Fix to Update Manager, Auto Update corrections Fix to Server GUI's broadcast, room, player messaging
author sirebral
date Mon, 03 May 2010 01:44:38 -0500
parents d5ff505a2a16
children 2c6db2043764
files orpg/chat/chatwnd.py orpg/main.py orpg/networking/mplay_server.py orpg/networking/mplay_server_gui.py orpg/orpg_version.py
diffstat 5 files changed, 86 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/orpg/chat/chatwnd.py	Sun May 02 19:17:35 2010 -0500
+++ b/orpg/chat/chatwnd.py	Mon May 03 01:44:38 2010 -0500
@@ -1371,8 +1371,7 @@
         alias = msg.get_alias()
         # who sent us the message?
         if alias: display_name = self.chat_display_name([alias, player[1], player[2]])
-        elif player: display_name = self.chat_display_name(player)
-        else: display_name = "Server Administrator"
+        else: display_name = self.chat_display_name(player)
 
         ######### START plugin_incoming_msg() ###########
         for plugin_fname in self.activeplugins.keys():
@@ -1595,10 +1594,10 @@
     # This subroutine builds a chat display name.
     #
     def chat_display_name(self, player):
-        if self.settings.get_setting("ShowIDInChat") == "0":
-            display_name = player[0]
-        else:
-            display_name = "("+player[2]+") " + player[0]
+        if player == None:
+            player = ['<b><i><u>Server Administrator</u>-></i></b> ', '127.0.0.1', '0']
+        if self.settings.get_setting("ShowIDInChat") == "0": display_name = player[0]
+        else: display_name = "("+player[2]+") " + player[0]
         return display_name
 
     # This subroutine will get a hex color and return it, or return nothing
--- a/orpg/main.py	Sun May 02 19:17:35 2010 -0500
+++ b/orpg/main.py	Mon May 03 01:44:38 2010 -0500
@@ -929,10 +929,9 @@
         etreeEl = Element('msg')
         try: etreeEl.append(fromstring(data))
         except: etreeEl.text = data
-        if player: display_name = self.chat.chat_display_name(player)
-        else: display_name = "Server Administrator"
 
-        if etreeEl.text: self.chat.Post(etreeEl.text)
+        display_name = self.chat.chat_display_name(player)
+        if etreeEl.text:self.chat.Post(display_name+etreeEl.text)
 
         for child in etreeEl.getchildren():
             if child.tag == 'tree':
--- a/orpg/networking/mplay_server.py	Sun May 02 19:17:35 2010 -0500
+++ b/orpg/networking/mplay_server.py	Mon May 03 01:44:38 2010 -0500
@@ -890,8 +890,14 @@
         print "'help' or '?' or 'h' - for this help message"
         print
 
-    def broadcast(self,msg):
-        self.send_to_all("0","<msg to='all' from='0' group_id='1'><font color='#FF0000'>" + msg + "</font></msg>")
+    def broadcast(self, msg):
+        broadcast = '<chat type="1" version="1.0"><font color="#FF0000">' +msg+ '</font></chat>'
+        chat = Element('chat')
+        chat.set('type', '1')
+        chat.set('version', '1.0')
+        chat.text = broadcast
+        msg = self.buildMsg('all', '0', '1', tostring(chat))
+        self.send_to_all('0', msg)
 
     def console_log(self):
         if self.log_to_console == 1:
@@ -1118,8 +1124,8 @@
             bad_xml_string += "Please report this bug to the development team at:<br /> "
             bad_xml_string += "<a href='http://www.assembla.com/spaces/traipse_dev/tickets/'>Traipse-Dev "
             bad_xml_string += "(http://www.assembla.com/spaces/traipse_dev/tickets/)</a><br />"
-            self.sendMsg( newsock, "<msg to='" +props['id']+ "' from='" +props['id']+ "' group_id='0' />" +bad_xml_string, 
-                            new_stub.useCompression, new_stub.compressionType)
+            msg = self.buildMsg(props['id'], props['id'], '0', bad_xml_string)
+            self.sendMsg( newsock, msg, new_stub.useCompression, new_stub.compressionType)
 
             time.sleep(2)
             newsock.close()
@@ -1224,7 +1230,6 @@
             newsock.close()
 
         #  Display the lobby message
-        print 'lobby message'
         self.SendLobbyMessage(newsock, props['id'])
 
     def checkClientVersion(self, clientversion):
@@ -1869,14 +1874,11 @@
         to_id = xml_dom.get("to")
         from_id = xml_dom.get("from")
         group_id = xml_dom.get("group_id")
-
         ## Backwards compatibility with older clients
         end = data.find(">")
-        head = data[:end+1]
         msg = data[end+1:]
         if msg[-6:] == '</msg>': msg = msg[:-6]
-        if head[end-1:] == '/>': head = head[:end-2]+'>'
-        data = head+msg+'</msg>'
+        data = msg
 
         if from_id == "0" or len(from_id) == 0:
             print "WARNING!! Message received with an invalid from_id.  Message dropped."
@@ -1900,21 +1902,27 @@
                 self.players[from_id].self_message('The lobby map may not be altered.')
             elif to_id.lower() == 'all':
                 #valid map for all players that is not the lobby.
-                self.send_to_group(from_id,group_id,data)
-                self.groups[group_id].game_map.init_from_xml(data)
+                msg = self.buildMsg('all', from_id, group_id, data)
+                self.send_to_group(from_id,group_id,msg)
+                self.groups[group_id].game_map.init_from_xml(msg)
             else:
                 #attempting to send map to specific individuals which is not supported.
                 self.players[from_id].self_message('Invalid map message. Message not sent to others.')
 
         elif msg[:6] == '<boot ':
+            msg = self.buildMsg('all', from_id, group_id, data)
             self.handle_boot(from_id,to_id,group_id,msg)
 
         else:
             if to_id == 'all':
                 if self.groups[group_id].moderated and not self.groups[group_id].voice.has_key(from_id):
                     self.players[from_id].self_message('This room is moderated - message not sent to others')
-                else: self.send_to_group(from_id,group_id,data)
-            else: self.players[to_id].outbox.put(data)
+                else: 
+                    msg = self.buildMsg('all', from_id, group_id, data)
+                    self.send_to_group(from_id,group_id,msg)
+            else: 
+                msg = self.buildMsg('all', from_id, group_id, data)
+                self.players[to_id].outbox.put(msg)
         self.check_group_members(group_id)
         return
 
@@ -2119,7 +2127,8 @@
             self.saveBanList()
 
             # Send a message to everyone in the victim's room, letting them know someone has been booted
-            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))
+            msg = 'Banning ('+id+') '+self.players[id].name+' from server... </font>'
+            msg = self.buildMsg('all', '0', group_id, msg)
             self.log_msg("ban_msg:" + ban_msg)
             if (silent == 0): self.send_to_group("0", group_id, ban_msg)
             time.sleep( .1 )
@@ -2282,6 +2291,10 @@
             self.log_msg("Exception: check_group_members(): " + str(e))
             self.log_msg( ('exception', str(e)) )
 
+    def buildMsg(self, toId, fromId, roomId, data):
+        msg = '<msg to="' +toId+ '" from="' +fromId+ '" group_id="' +roomId+ '">'
+        msg += data+ '</msg>'
+        return msg
 
     def remote_admin_handler(self,xml_dom,data):
         """
@@ -2330,102 +2343,107 @@
             #determine action to take based on command (cmd)
             if cmd == "list":
                 #return player list to this user.
-                msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + self.player_list_remote()
+                msg = self.buildMsg(pid, '0', gid, self.player_list_remote())
                 self.players[pid].outbox.put(msg)
             elif cmd == "banip":
                 ip = xml_dom.get("bip")
                 name = xml_dom.get("bname")
-                msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'> Banned: " + str(ip)
+                msg = self.buildMsg(pid, '0', gid, str(ip))
                 self.admin_banip(ip, name)
             elif cmd == "ban":
                 id = xml_dom.get("bid")
-                msg = "<msg to='" + id + "' from='0' group_id='" + gid + "'> Banned!"
+                msg = self.buildMsg(id, '0', gid, 'Banned!')
                 self.players[pid].outbox.put(msg)
                 self.admin_ban(id, "")
             ### Alpha ### and untested
             elif cmd == "boot":
                 id = xml_dom.get("bid")
-                msg = "<msg to='" + id + "' from='0' group_id='" + gid + "'> Booted!"
+                msg = self.buildMsg(id, '0', gid, 'Booted!!')
                 self.players[pid].outbox.put(msg)
                 self.admin_kick(id, "")
             #############
             elif cmd == "unban":
                 ip = xml_dom.get("ip")
                 self.admin_unban(ip)
-                msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'> Unbaned: " + str(ip)
+                msg = self.buildMsg(pid, '0', gid, str(ip))
                 self.players[pid].outbox.put(msg)
             elif cmd == "banlist":
-                msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + self.admin_banlist()
+                msg = self.buildMsg(pid, '0', gid, self.admin_banlist())
                 self.players[pid].outbox.put(msg)
             elif cmd == "killgroup":
                 ugid = xml_dom.get("gid")
                 if ugid == "0":
-                    m = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>"
-                    m += "Cannot Remove Lobby! Remote administrator request denied!"
-                    self.players[pid].outbox.put(m)
+                    m + "Cannot Remove Lobby! Remote administrator request denied!"
+                    msg = self.buildMsg(pid, '0', gid, m)
+                    self.players[pid].outbox.put(msg)
                 else:
                     result = self.prune_room(ugid)
-                    msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + str(result)
+                    msg = self.buildMsg(pid, '0', gid, str(result))
                     self.players[pid].outbox.put(msg)
 
             elif cmd == "message":
                 tuid = xml_dom.get("to_id")
                 msg = xml_dom.get("msg")
-                pmsg = "<msg to='" + tuid + "' from='0' group_id='" + self.players[tuid].group_id + "' >" + msg
+                pmsg = self.buildMsg(tuid, '0', self.players[tuid].group_id, msg)
                 try: self.players[tuid].outbox.put(pmsg)
                 except:
-                    msg = "<msg to='" + pid + "' from='0' group_id='" + gid + ">Unknown Player ID: No message sent."
+                    msg = "Unknown Player ID: No message sent."
+                    msg = self.buildMsg(pid, '0', gid, msg)
                     self.players[pid].outbox.put(msg)
             elif cmd == "broadcast":
                 bmsg = xml_dom.get("msg")
-                self.broadcast(bmsg)
+                self.send_to_all('0', bmsg)
             elif cmd == "killserver" and self.allowRemoteKill:
                 #dangerous command..once server stopped it must be restarted manually
                 self.kill_server()
             elif cmd == "uptime":
-                msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + self.uptime(1)
+                msg = self.uptime(1)
+                msg = self.buildMsg(pid, '0', gid, msg)
                 self.players[pid].outbox.put(msg)
             elif cmd == "help":
-                msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>"
-                msg += self.AdminHelpMessage()
+                msg = self.AdminHelpMessage()
+                msg = self.buildMsg(pid, '0', gid, msg)
                 self.players[pid].outbox.put( msg)
             elif cmd == "roompasswords":
                 # Toggle if room passwords are allowed on this server
-                msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>"
-                msg += self.RoomPasswords()
+                msg = self.RoomPasswords()
+                msg = self.buildMsg(pid, '0', gid, msg)
                 self.players[pid].outbox.put( msg)
             elif cmd == "createroom":
                 rm_name = xml_dom.get("name")
                 rm_pass = xml_dom.get("pass")
                 rm_boot = xml_dom.get("boot")
                 result = self.create_temporary_persistant_room(rm_name, rm_boot, rm_pass)
-                msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + result
+                msg = self.buildMsg(pid, '0', gid, result)
                 self.players[pid].outbox.put(msg)
             elif cmd == "nameroom":
                 rm_id   = xml_dom.get("rmid")
                 rm_name = xml_dom.get("name")
                 result = self.change_group_name(rm_id,rm_name,pid)
-                msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'/>" + result
+                msg = self.buildMsg(pid, '0', gid, result)
                 self.players[pid].outbox.put(msg)
             elif cmd == "passwd":
                 tgid = xml_dom.get("gid")
                 npwd = xml_dom.get("pass")
                 if tgid == "0":
-                    msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>"
-                    msg += "Server password may not be changed remotely!"
+                    msg = "Server password may not be changed remotely!"
+                    msg = self.buildMsg(pid, '0', gid, msg)
                     self.players[pid].outbox.put(msg)
                 else:
                     try:
                         self.groups[tgid].boot_pwd = npwd
-                        msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>Password changed for room " + tgid
+                        msg = "Password changed for room " + tgid
+                        msg = self.buildMsg(pid, '0', gid, msg)
                         self.players[pid].outbox.put(msg)
                     except: pass
             elif cmd == "savemaps":
                 for g in self.groups.itervalues(): g.save_map()
-                msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>Persistent room maps saved"
+                msg = "Persistent room maps saved"
+                msg = self.buildMsg(pid, '0', gid, msg)
                 self.players[pid].outbox.put(msg)
             else:
-                msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'><i>[Unknown Remote Administration Command]</i>"
+                msg = "<i>[Unknown Remote Administration Command]</i>"
+                msg = self.buildMsg(pid, '0', gid, msg)
                 self.players[pid].outbox.put(msg)
         except Exception, e:
             self.log_msg("Exception: Remote Admin Handler Error: " + str(e))
@@ -2602,4 +2620,4 @@
         self.p_lock.release()
         return pl
 
-server = mplay_server()
+server = mplay_server()     
--- a/orpg/networking/mplay_server_gui.py	Sun May 02 19:17:35 2010 -0500
+++ b/orpg/networking/mplay_server_gui.py	Mon May 03 01:44:38 2010 -0500
@@ -321,7 +321,7 @@
                 BanMsg = wx.TextEntryDialog( self, "Enter A Message To Send:",
                                                  "Ban Message", message, wx.OK|wx.CANCEL|wx.CENTRE )
                 if BanMsg.ShowModal() == wx.ID_OK: message = BanMsg.GetValue()
-                else: message = ''
+                else: return
                 Silent = wx.MessageDialog(None, 'Silent Ban?', 'Question', 
                     wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
                 if Silent.ShowModal() == wx.ID_YES: silent = 1
@@ -330,14 +330,30 @@
                 self.remove( playerID )
             elif menuItem == 4:
                 msg = self.GetMessageInput( "Send a message to player" )
-                if len(msg): self.main.server.server.send( msg, playerID, str(groupID) )
+
+                broadcast = '<chat type="1" version="1.0"><font color="#FF0000">' +msg+ '</font></chat>'
+                chat = Element('chat')
+                chat.set('type', '1')
+                chat.set('version', '1.0')
+                chat.text = broadcast
+                msg = self.main.server.server.buildMsg(str(playerID), '0', '1', msg)
+
+                if len(msg): self.main.server.server.players[playerID].outbox.put(msg)
             #Leave this in for now.
             elif menuItem == 5:
                 msg = self.GetMessageInput( "Send message to room of this player")
+
+                broadcast = '<chat type="1" version="1.0"><font color="#FF0000">' +msg+ '</font></chat>'
+                chat = Element('chat')
+                chat.set('type', '1')
+                chat.set('version', '1.0')
+                chat.text = broadcast
+                msg = self.main.server.server.buildMsg('all', '0', '1', tostring(chat))
+
                 if len(msg): self.main.server.server.send_to_group('0', str(groupID), msg )
             elif menuItem == 6:
                 msg = self.GetMessageInput( "Broadcast Server Message" )
-                if len(msg): self.main.server.server.broadcast( msg )
+                if len(msg): self.main.server.server.broadcast(msg )
             elif menuItem == 3:
                 version_string = self.main.server.server.obtain_by_id(playerID, 'client_string')
                 if version_string: wx.MessageBox("Running client version " + version_string,"Version")
@@ -479,7 +495,6 @@
         else: self.debugger.Show()
 
     def TraipseSuiteWarn(self, menuitem):
-        print 'traipse warn' #logger.debug('traipse warn')
         ### Allows for the reuse of the 'Attention' menu.
         ### component.get('frame').TraipseSuiteWarn('item') ### Portable
         self.mainMenu.Remove(3)
@@ -595,7 +610,7 @@
         self.conns.updateRoom(data)
 
     def OnUpdateGroup(self, data):
-        (room, room_id, players) = data; print 'update group', data
+        (room, room_id, players) = data
         self.groups.UpdateGroup(data)
 
     def OnSetRole( self, data ):
--- a/orpg/orpg_version.py	Sun May 02 19:17:35 2010 -0500
+++ b/orpg/orpg_version.py	Mon May 03 01:44:38 2010 -0500
@@ -4,7 +4,7 @@
 #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed)
 DISTRO = "Traipse Alpha"
 DIS_VER = "Ornery Orc"
-BUILD = "100502-01"
+BUILD = "100503-00"
 
 # This version is for network capability.
 PROTOCOL_VERSION = "1.2"