Mercurial > traipse_dev
comparison orpg/networking/mplay_client.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 | 067922263f07 |
children | b633f4c64aae 81d0bfd5e800 |
comparison
equal
deleted
inserted
replaced
149:c2caca988a11 | 151:06f10429eedc |
---|---|
82 GROUP_UPDATE = 4 | 82 GROUP_UPDATE = 4 |
83 STATUS_SET_URL = 1 | 83 STATUS_SET_URL = 1 |
84 | 84 |
85 def parseXml(data): | 85 def parseXml(data): |
86 "parse and return doc" | 86 "parse and return doc" |
87 #print data | |
88 doc = xml.parseXml(data) | 87 doc = xml.parseXml(data) |
89 doc.normalize() | 88 doc.normalize() |
90 return doc | 89 return doc |
91 | 90 |
92 def myescape(data): | 91 def myescape(data): |
266 thread.start_new_thread( self.sendThread,(0,)) | 265 thread.start_new_thread( self.sendThread,(0,)) |
267 thread.start_new_thread( self.recvThread,(0,)) | 266 thread.start_new_thread( self.recvThread,(0,)) |
268 self.startedEvent.set() | 267 self.startedEvent.set() |
269 | 268 |
270 def disconnect(self): | 269 def disconnect(self): |
271 debug() | |
272 self.set_status(MPLAY_DISCONNECTING) | 270 self.set_status(MPLAY_DISCONNECTING) |
273 self.log_msg("client stub " + self.ip +" disconnecting...") | 271 self.log_msg("client stub " + self.ip +" disconnecting...") |
274 self.log_msg("closing sockets...") | 272 self.log_msg("closing sockets...") |
275 try: self.sock.shutdown(2) | 273 try: self.sock.shutdown(2) |
276 except Exception, e: | 274 except Exception, e: |
289 self.role = role | 287 self.role = role |
290 | 288 |
291 def use_roles(self): | 289 def use_roles(self): |
292 if self.useroles: return 1 | 290 if self.useroles: return 1 |
293 else: return 0 | 291 else: return 0 |
292 | |
294 def update_self_from_player(self, player): | 293 def update_self_from_player(self, player): |
295 try: (self.name, self.ip, self.id, | 294 try: (self.name, self.ip, self.id, |
296 self.text_status, self.version, | 295 self.text_status, self.version, |
297 self.protocol_version, self.client_string, role) = player | 296 self.protocol_version, self.client_string, role) = player |
298 except Exception, e: | 297 except Exception, e: |
313 el.set('version', self.version) | 312 el.set('version', self.version) |
314 el.set('protocol_version', self.protocol_version) | 313 el.set('protocol_version', self.protocol_version) |
315 el.set('client_string', self.client_string) | 314 el.set('client_string', self.client_string) |
316 el.set('useCompression', str(self.useCompression)) | 315 el.set('useCompression', str(self.useCompression)) |
317 cmpType = 'None' | 316 cmpType = 'None' |
318 if cmpBZ2 and (self.compressionType == 'Undefined' or self.compressionType == bz2): | 317 if cmpBZ2 and (self.compressionType == 'Undefined' or self.compressionType == bz2): cmpType = 'bz2' |
319 cmpType = 'bz2' | 318 elif cmpZLIB and (self.compressionType == 'Undefined' or self.compressionType == zlib): cmpType = 'zlib' |
320 elif cmpZLIB and (self.compressionType == 'Undefined' or self.compressionType == zlib): | |
321 cmpType = 'zlib' | |
322 el.set('cmpType', cmpType) | 319 el.set('cmpType', cmpType) |
323 return tostring(el) | 320 return tostring(el) |
324 | 321 |
325 def log_msg(self,msg): | 322 def log_msg(self,msg): |
326 debug(msg, log=False) | |
327 if self.log_console: self.log_console(msg) | 323 if self.log_console: self.log_console(msg) |
328 | 324 |
329 def get_status(self): | 325 def get_status(self): |
330 self.statLock.acquire() | 326 self.statLock.acquire() |
331 status = self.status | 327 status = self.status |
522 | 518 |
523 def boot_player(self,id,boot_pwd = ""): | 519 def boot_player(self,id,boot_pwd = ""): |
524 el = Element('boot') | 520 el = Element('boot') |
525 el.set('boot_pwd', boot_pwd) | 521 el.set('boot_pwd', boot_pwd) |
526 self.send(tostring(el), id) | 522 self.send(tostring(el), id) |
527 | |
528 #--------------------------------------------------------- | |
529 # [START] Snowdog Password/Room Name altering code 12/02 | |
530 #--------------------------------------------------------- | |
531 | 523 |
532 def set_room_pass(self, npwd, pwd=""): | 524 def set_room_pass(self, npwd, pwd=""): |
533 el = Element('alter') | 525 el = Element('alter') |
534 el.set('key', 'pwd') | 526 el.set('key', 'pwd') |
535 el.set('val', npwd) | 527 el.set('val', npwd) |
574 el.set('plr', self.id) | 566 el.set('plr', self.id) |
575 el.set('gid', self.group_id) | 567 el.set('gid', self.group_id) |
576 self.outbox.put(tostring(el)) | 568 self.outbox.put(tostring(el)) |
577 self.update() | 569 self.update() |
578 | 570 |
579 #--------------------------------------------------------- | |
580 # [END] Snowdog Password/Room Name altering code 12/02 | |
581 #--------------------------------------------------------- | |
582 | |
583 def display_roles(self): | 571 def display_roles(self): |
584 el = Element('role') | 572 el = Element('role') |
585 el.set('action', 'display') | 573 el.set('action', 'display') |
586 el.set('player', self.id) | 574 el.set('player', self.id) |
587 el.set('group_id', self.group_id) | 575 el.set('group_id', self.group_id) |
679 try: el = fromstring(data) | 667 try: el = fromstring(data) |
680 except ExpatError: | 668 except ExpatError: |
681 end = data.find(">") | 669 end = data.find(">") |
682 head = data[:end+1] | 670 head = data[:end+1] |
683 msg = data[end+1:] | 671 msg = data[end+1:] |
684 ### Alpha ### | 672 ### This if statement should help close invalid messages. ### |
685 if head[end:] != '/': | 673 if head[end:] != '/': |
686 if head[end:] != '>': head = head[:end] + '/>' | 674 if head[end:] != '>': head = head[:end] + '/>' |
687 ### This if statement should help close invalid messages. Since it needs fixing, use the try except message for now. | |
688 try: el = fromstring(head) | 675 try: el = fromstring(head) |
689 except: el = fromstring(head[:end] +'/>') | 676 except: el = fromstring(head[:end] +'/>') |
677 ########### | |
690 | 678 |
691 try: | 679 try: |
692 el1 = fromstring(msg) | 680 el1 = fromstring(msg) |
693 el.append(el1) | 681 el.append(el1) |
694 except ExpatError: | 682 except ExpatError: |
695 el.text = msg | 683 el.text = msg |
696 #logger.general("Bad Message: \n" + data) | |
697 id = el.get('from') or el.get('id') | 684 id = el.get('from') or el.get('id') |
698 if el.tag in self.msg_handlers: self.msg_handlers[el.tag](id, data, el) | 685 if el.tag in self.msg_handlers: self.msg_handlers[el.tag](id, data, el) |
699 | 686 |
700 def on_sound(self, id, data, etreeEl): | 687 def on_sound(self, id, data, etreeEl): |
701 (ignore_id,ignore_name) = self.get_ignore_list() | 688 (ignore_id,ignore_name) = self.get_ignore_list() |
716 # None get's interpreted in on_receive as the sys admin. | 703 # None get's interpreted in on_receive as the sys admin. |
717 # Doing it this way makes it harder to impersonate the admin | 704 # Doing it this way makes it harder to impersonate the admin |
718 elif self.is_valid_id(id): self.on_receive(msg, self.players[id]) | 705 elif self.is_valid_id(id): self.on_receive(msg, self.players[id]) |
719 | 706 |
720 def on_ping(self, id, msg, etreeEl): | 707 def on_ping(self, id, msg, etreeEl): |
721 #a REAL ping time implementation by Snowdog 8/03 | 708 # A REAL ping time implementation by Snowdog 8/03 |
722 # recieves special server <ping time="###" /> command | 709 # recieves special server <ping time="###" /> command |
723 # where ### is a returning time from the clients ping command | 710 # where ### is a returning time from the clients ping command |
724 #get current time, pull old time from object and compare them | 711 # get current time, pull old time from object and compare them |
725 # the difference is the latency between server and client * 2 | 712 # the difference is the latency between server and client * 2 |
726 ct = time.clock() | 713 ct = time.clock() |
727 ot = etreeEl.get("time") | 714 ot = etreeEl.get("time") |
728 latency = float(float(ct) - float(ot)) | 715 latency = float(float(ct) - float(ot)) |
729 latency = int(latency * 10000.0) | 716 latency = int(latency * 10000.0) |
770 elif act == "group": | 757 elif act == "group": |
771 self.group_id = etreeEl.get('group_id') | 758 self.group_id = etreeEl.get('group_id') |
772 self.clear_players() | 759 self.clear_players() |
773 self.on_mplay_event(mplay_event(MPLAY_GROUP_CHANGE, self.groups[self.group_id])) | 760 self.on_mplay_event(mplay_event(MPLAY_GROUP_CHANGE, self.groups[self.group_id])) |
774 self.players[self.id] = self.get_my_info() | 761 self.players[self.id] = self.get_my_info() |
775 #(self.name,self.ip,self.id,self.text_status) | |
776 self.on_player_event(mplay_event(PLAYER_NEW, self.players[self.id])) | 762 self.on_player_event(mplay_event(PLAYER_NEW, self.players[self.id])) |
777 elif act == "failed": | 763 elif act == "failed": |
778 self.on_mplay_event(mplay_event(MPLAY_GROUP_CHANGE_F)) | 764 self.on_mplay_event(mplay_event(MPLAY_GROUP_CHANGE_F)) |
779 elif act == "del": | 765 elif act == "del": |
780 self.on_player_event(mplay_event(PLAYER_DEL, self.players[id])) | 766 self.on_player_event(mplay_event(PLAYER_DEL, self.players[id])) |