diff 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
line wrap: on
line diff
--- a/orpg/networking/mplay_server.py	Wed Oct 28 14:24:54 2009 -0500
+++ b/orpg/networking/mplay_server.py	Thu Oct 29 20:35:28 2009 -0500
@@ -77,7 +77,8 @@
 
 
 class game_group(object):
-    def __init__( self, id, name, pwd, desc="", boot_pwd="", minVersion="", mapFile=None, messageFile=None, persist =0 ):
+    def __init__(self, id, name, pwd, desc="", boot_pwd="", 
+                    minVersion="", mapFile=None, messageFile=None, persist=0):
         self.id = id
         self.name = name
         self.desc = desc
@@ -94,16 +95,23 @@
         self.mapFile = None
 
         if mapFile != None:
+        """
+        try:
+            f = open(filename, "rb")
+            tree = parse(f)
+            self.xml_root = tree.getroot()
+        except:
+            f.close()
+            self.xml_root = None
+        """
             self.mapFile = mapFile
             f = open( mapFile )
             tree = f.read()
             f.close()
-
         else:
             f = open(dir_struct["template"] + "default_map.xml")
             tree = f.read()
             f.close()
-
         self.game_map.init_from_xml(tree)
 
     def save_map(self):
@@ -116,8 +124,7 @@
         self.players.append(id)
 
     def remove_player(self,id):
-        if self.voice.has_key(id):
-            del self.voice[id]
+        if self.voice.has_key(id): del self.voice[id]
         self.players.remove(id)
 
     def get_num_players(self):
@@ -149,14 +156,21 @@
         return 1
 
     #depreciated - see send_group_list()
-    def toxml(self,act="new"):
+    def toxml(self, act="new"):
         #  Please don't add the boot_pwd to the xml, as this will give it away to players watching their console
-        xml_data = "<group id=\"" + self.id
-        xml_data += "\" name=\"" + self.name
-        xml_data += "\" pwd=\"" + str(self.pwd!="")
-        xml_data += "\" players=\"" + str(self.get_num_players())
-        xml_data += "\" action=\"" + act + "\" />"
-        return xml_data
+        el = Element('group')
+        el.set('id', self.id)
+        el.set('name', self.name)
+        el.set('pwd', str(self.pwd!=""))
+        el.set('players', str(self.get_num_players()))
+        el.set('action', act)
+        return tostring(el)
+        #xml_data = "<group id=\"" + self.id
+        #xml_data += "\" name=\"" + self.name
+        #xml_data += "\" pwd=\"" + str(self.pwd!="")
+        #xml_data += "\" players=\"" + str(self.get_num_players())
+        #xml_data += "\" action=\"" + act + "\" />"
+        #return xml_data
 
 
 class client_stub(client_base):
@@ -190,8 +204,13 @@
         if diff > 1800: return 1
         else: return 0
 
-    def send(self,msg,player,group):
+    def send(self, msg, player, group):
         if self.get_status() == MPLAY_CONNECTED:
+            #el = Element('msg')
+            #el.set('to', player)
+            #el.set('from', '0')
+            #el.set('group_id', group)
+            #el.text(msg)
             self.outbox.put("<msg to='" + player + "' from='0' group_id='" + group + "' />" + msg)
 
     def change_group(self,group_id,groups):
@@ -238,9 +257,9 @@
         self.next_group_id = 100
         self.metas = {}              #  This holds the registerThread objects for each meta
         self.be_registered = 0       #  Status flag for whether we want to be registered.
-        self.serverName = name            #  Name of this server in the metas
+        self.serverName = name       #  Name of this server in the metas
         self.boot_pwd = ""
-        self.server_address = None # IP or Name of server to post to the meta. None means the meta will auto-detect it.
+        self.server_address = None   # IP or Name of server to post to the meta. None means the meta will auto-detect it.
         self.defaultMessageFile = None
         self.userPath = dir_struct["user"]
         self.lobbyMapFile = "Lobby_map.xml"