annotate orpg/networking/mplay_server.py @ 139:8e07c1a2c69b alpha

Traipse Alpha 'OpenRPG' {091123-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 Mon, 23 Nov 2009 03:22:50 -0600
parents fba298d65cf8
children 06f10429eedc
rev   line source
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1 #!/usr/bin/python2.1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2 # Copyright (C) 2000-2001 The OpenRPG Project
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
3 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
4 # openrpg-dev@lists.sourceforge.net
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
5 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
6 # This program is free software; you can redistribute it and/or modify
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
7 # it under the terms of the GNU General Public License as published by
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
8 # the Free Software Foundation; either version 2 of the License, or
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
9 # (at your option) any later version.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
10 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
14 # GNU General Public License for more details.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
15 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
16 # You should have received a copy of the GNU General Public License
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
17 # along with this program; if not, write to the Free Software
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
19 # --
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
20 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
21 # File: mplay_server.py
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
22 # Author: Chris Davis
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
23 # Maintainer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
24 # Version:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
25 # $Id: mplay_server.py,v 1.155 2008/01/24 03:52:03 digitalxero Exp $
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
26 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27 # Description: This file contains the code for the server of the multiplayer
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
28 # features in the orpg project.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
29 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
30
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
31
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
32 # 04-15-2005 [Snowdog]: Added patch from Brandan Yares (xeriar). Reference: patch tracker id #1182076
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
33
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
34 from __future__ import with_statement
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
35
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
36 __version__ = "$Id: mplay_server.py,v 1.155 2008/01/24 03:52:03 digitalxero Exp $"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
37
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
38 #!/usr/bin/env python
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
39 """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
40 <msg to='' from='' group_id='' />
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
41 <player id='' ip='' group_id='' name='' action='new,del,group,update' status="" version=""/>
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
42 <group id='' name='' pwd='' players='' action='new,del,update' />
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
43 <create_group from='' pwd='' name='' />
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
44 <join_group from='' pwd='' group_id='' />
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
45 <role action='set,get,display' player='' group_id='' boot_pwd='' role=''/>
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
46 """
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
47
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
48 import re, gc, cgi, sys, string, time, urllib, traceback
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
49
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
50 from mplay_client import *
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
51 from mplay_client import MPLAY_LENSIZE
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
52 from orpg.dirpath import dir_struct
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
53 import orpg.tools.validate
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
54
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
55 from orpg.mapper.map_msg import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
56 from threading import Lock, RLock
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 from struct import pack, unpack, calcsize
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
58 from meta_server_lib import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
59
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
60 from xml.etree.ElementTree import ElementTree, Element, iselement
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
61 from xml.etree.ElementTree import fromstring, tostring, parse, XML
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
62
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
63 from orpg.tools.orpg_log import logger, crash, debug
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
64 from orpg.tools.decorators import debugging
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
65
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
66 # Snag the version number
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
67 from orpg.orpg_version import VERSION, PROTOCOL_VERSION, CLIENT_STRING, SERVER_MIN_CLIENT_VERSION
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
68
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
69 #Plugins
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
70 from server_plugins import ServerPlugins
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
71
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
72 def id_compare(a,b):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
73 "converts strings to intergers for list sort comparisons for group and player ids so they end up in numeric order"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
74 return cmp(int(a),int(b))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
75
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
76
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
77 class game_group(object):
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
78 def __init__(self, id, name, pwd, desc="", boot_pwd="",
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
79 minVersion="", mapFile=None, messageFile=None, persist=0):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80 self.id = id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
81 self.name = name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
82 self.desc = desc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
83 self.minVersion = minVersion
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
84 self.messageFile = messageFile
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
85 self.players = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
86 self.pwd = pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
87 self.boot_pwd = boot_pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
88 self.game_map = map_msg()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
89 self.lock = Lock()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
90 self.moderated = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
91 self.voice = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
92 self.persistant = persist
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
93 self.mapFile = None
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
94 ### Needs to use Element Tree closer
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
95 if mapFile != None: tree = parse(mapFile)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
96 else: tree = parse(dir_struct["template"] + "default_map.xml")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
97 tree = tree.getroot()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
98 self.game_map.init_from_xml(tostring(tree))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
99
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
100 def save_map(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
101 if self.mapFile is not None and self.persistant == 1 and self.mapFile.find("default_map.xml") == -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
102 f = open(self.mapFile, "w")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103 f.write(self.game_map.get_all_xml())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104 f.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
105
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
106 def add_player(self,id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
107 self.players.append(id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
108
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
109 def remove_player(self,id):
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
110 if self.voice.has_key(id): del self.voice[id]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
111 self.players.remove(id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
112
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
113 def get_num_players(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
114 num = len(self.players)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
115 return num
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
116
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
117 def get_player_ids(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
118 tmp = self.players
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
119 return tmp
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
120
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
121 def check_pwd(self,pwd):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
122 return (pwd==self.pwd)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
123
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
124 def check_boot_pwd(self,pwd):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
125 return (pwd==self.boot_pwd)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
126
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
127 def check_version(self,ver):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
128 if (self.minVersion == ""): return 1
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
129 minVersion=self.minVersion.split('.')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
130 version=ver.split('.')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
131 for i in xrange(min(len(minVersion),len(version))):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
132 w=max(len(minVersion[i]),len(version[i]))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
133 v1=minVersion[i].rjust(w);
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
134 v2=version[i].rjust(w);
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
135 if v1<v2: return 1
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
136 if v1>v2: return 0
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
137 if len(minVersion)>len(version):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
138 return 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
139 return 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
140
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
141 #depreciated - see send_group_list()
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
142 def toxml(self, act="new"):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
143 # Please don't add the boot_pwd to the xml, as this will give it away to players watching their console
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
144 el = Element('group')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
145 el.set('id', self.id)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
146 el.set('name', self.name)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
147 el.set('pwd', str(self.pwd!=""))
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
148 el.set('players', str(self.get_num_players()))
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
149 el.set('action', act)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
150 return tostring(el)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
151
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
152 class client_stub(client_base):
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
153 def __init__(self, inbox, sock, props, log):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
154 client_base.__init__(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
155 self.ip = props['ip']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
156 self.role = props['role']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
157 self.id = props['id']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
158 self.group_id = props['group_id']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
159 self.name = props['name']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
160 self.version = props['version']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
161 self.protocol_version = props['protocol_version']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
162 self.client_string = props['client_string']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
163 self.inbox = inbox
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
164 self.sock = sock
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
165 self.timeout_time = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
166 self.log_console = log
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
167 self.ignorelist = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
168
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
169 # implement from our base class
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
170 def isServer( self ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
171 return 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
172
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
173 def clear_timeout(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
174 self.timeout_time = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
175
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
176 def check_time_out(self):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
177 if self.timeout_time==None: self.timeout_time = time.time()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
178 curtime = time.time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
179 diff = curtime - self.timeout_time
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
180 if diff > 1800: return 1
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
181 else: return 0
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
182
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
183 def send(self, msg, player, group):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
184 if self.get_status() == MPLAY_CONNECTED:
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
185 #el = Element('msg')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
186 #el.set('to', player)
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
187 #el.set('from', '0')
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
188 #el.set('group_id', group)
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
189 #el.append(msg)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
190 self.outbox.put("<msg to='" + player + "' from='0' group_id='" + group + "' />" + msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
191
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
192 def change_group(self, group_id, groups):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
193 old_group_id = str(self.group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
194 groups[group_id].add_player(self.id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
195 groups[old_group_id].remove_player(self.id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
196 self.group_id = group_id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
197 self.outbox.put(self.toxml('group'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
198 msg = groups[group_id].game_map.get_all_xml()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
199 self.send(msg,self.id,group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
200 return old_group_id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
201
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
202 def self_message(self,act):
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
203 self.send(act, self.id, self.group_id)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
204
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
205 def take_dom(self,xml_dom):
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
206 self.name = xml_dom.get("name")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
207 self.text_status = xml_dom.get("status")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
208
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
209 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
210 ######################################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
211 ######################################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
212 ##
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
213 ##
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
214 ## MPLAY SERVER
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
215 ##
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
216 ##
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
217 ######################################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
218 ######################################################################
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
219 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
220
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
221 class mplay_server:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
222 def __init__(self, log_console=None, name=None):
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
223 logger._set_log_level = 16
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
224 logger._set_log_to_console(True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
225 self.log_to_console = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
226 self.log_console = log_console
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
227 self.alive = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
228 self.players = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
229 self.listen_event = Event()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
230 self.incoming_event = Event()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
231 self.incoming = Queue.Queue(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
232 self.p_lock = RLock()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
233 self.next_player_id = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
234 self.plugin_player_id = -1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
235 self.next_group_id = 100
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
236 self.metas = {} # This holds the registerThread objects for each meta
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
237 self.be_registered = 0 # Status flag for whether we want to be registered.
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
238 self.serverName = name # Name of this server in the metas
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
239 self.boot_pwd = ""
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 114
diff changeset
240 self.server_address = None # IP or Name of server to post to the meta. None means the meta will auto-detect it.
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
241 self.defaultMessageFile = None
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 58
diff changeset
242 self.userPath = dir_struct["user"]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
243 self.lobbyMapFile = "Lobby_map.xml"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
244 self.lobbyMessageFile = "LobbyMessage.html"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
245 self.banFile = "ban_list.xml"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
246 self.show_meta_messages = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
247 self.log_network_messages = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
248 self.allow_room_passwords = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
249 self.silent_auto_kick = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
250 self.zombie_time = 480 #time in minutes before a client is considered a ZOMBIE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
251 self.minClientVersion = SERVER_MIN_CLIENT_VERSION
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
252 self.maxSendSize = 1024
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
253 self.server_port = OPENRPG_PORT
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
254 self.allowRemoteKill = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
255 self.allowRemoteAdmin = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
256 self.sendLobbySound = False
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
257 self.lobbySound = 'http://www.digitalxero.net/music/mus_tavern1.bmu' ##used?
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
258
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
259 def initServer(self, **kwargs):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
260 for atter, value in kwargs.iteritems(): setattr(self, atter, value)
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
261 validate.config_file( self.lobbyMapFile, "default_Lobby_map.xml" )
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
262 validate.config_file( self.lobbyMessageFile, "default_LobbyMessage.html" )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
263 self.server_start_time = time.time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
264
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
265 # Since the server is just starting here, we read in the XML configuration
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
266 # file. Notice the lobby is still created here by default.
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
267 self.groups = { '0': game_group('0','Lobby','',
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
268 'The game lobby', '', '', self.userPath + self.lobbyMapFile,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
269 self.userPath + self.lobbyMessageFile, 1)}
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
270 # Make sure the server's name gets set, in case we are being started from
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
271 # elsewhere. Basically, if it's passed in, we'll over ride what we were
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
272 # prompted for. This should never really happen at any rate.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
273
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
274 self.initServerConfig()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
275 self.listen_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
276 self.listen_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
277 self.listen_thread = thread.start_new_thread(self.listenAcceptThread, (0,))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
278 self.in_thread = thread.start_new_thread(self.message_handler,(0,))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
279
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
280 # Starts the player reaper thread. See self.player_reaper_thread_func() for more explanation
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
281 self.player_reaper_thread = thread.start_new_thread(self.player_reaper_thread_func,(0,))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
282 thread.start_new_thread(self.PluginThread,())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
283 self.svrcmds = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
284 self.initsvrcmds()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
285 self.ban_list = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
286 self.initBanList()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
287
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
288 def addsvrcmd(self, cmd, function):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
289 if not self.svrcmds.has_key(cmd):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
290 self.svrcmds[cmd] = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
291 self.svrcmds[cmd]['function'] = function
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
292
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
293 def initsvrcmds(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
294 self.addsvrcmd('msg', self.incoming_msg_handler)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
295 self.addsvrcmd('player', self.incoming_player_handler)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
296 self.addsvrcmd('admin', self.remote_admin_handler)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
297 self.addsvrcmd('alter', self.do_alter)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
298 self.addsvrcmd('role', self.do_role)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
299 self.addsvrcmd('ping', self.do_ping)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
300 self.addsvrcmd('system', self.do_system)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
301 self.addsvrcmd('join_group', self.join_group)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
302 self.addsvrcmd('create_group', self.create_group)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
303 self.addsvrcmd('moderate', self.moderate_group)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
304 self.addsvrcmd('plugin', self.plugin_msg_handler)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
305 self.addsvrcmd('sound', self.sound_msg_handler)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
306
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
307 # This method reads in the server's ban list added by Darren
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
308 def initBanList( self ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
309 self.log_msg("Processing Ban List File...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
310
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
311 # make sure the server_ini.xml exists!
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
312 validate.config_file(self.banFile, "default_ban_list.xml" )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
313
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
314 # try to use it.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
315 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
316 self.banDom = parse(self.userPath + 'ban_list.xml')
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
317 self.banDoc = self.banDom.getroot()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
318
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
319 for element in self.banDom.findall('banned'):
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
320 playerName = element.get('name').replace("&", "&amp;").replace("<", "&lt;").replace('"', "&quot;").replace(">", "&gt;")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
321 playerIP = element.get('ip')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
322 self.ban_list[playerIP] = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
323 self.ban_list[playerIP]['ip'] = playerIP
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
324 self.ban_list[playerIP]['name'] = playerName
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
325 self.log_msg(str(playerName) + " " + str(playerIP) + " is banned.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
326 self.saveBanList()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
327 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
328 self.log_msg("Exception in initBanList() " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
329
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
330 # This method writes out the server's ban list added by Darren
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
331 def saveBanList( self ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
332 self.log_msg("Saving Ban List File...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
333
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
334 # try to use it.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
335 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
336 etreeEl = Element('server')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
337 for ip in self.ban_list:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
338 el = Element('banned')
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
339 el.set('name', str(self.ban_list[ip]['name'].replace("&amp;", "&").replace("&lt;", "<").replace("&quot;", '"').replace("&gt;", ">")))
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
340 el.set('ip', str(self.ban_list[ip]['ip']))
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
341 etreeEl.append(el)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
342 file = open(self.userPath + self.banFile ,"w")
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
343 file.write(tostring(etreeEl))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
344 file.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
345 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
346 self.log_msg("Exception in saveBanList() " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
347
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
348 # This method reads in the server's configuration file and reconfigs the server
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
349 # as needed, over-riding any default values as requested.
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
350
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
351 def initServerConfig(self):
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
352 debug(log=False)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
353 self.log_msg("Processing Server Configuration File... " + self.userPath)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
354 # make sure the server_ini.xml exists!
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
355 validate.config_file( "server_ini.xml", "default_server_ini.xml" )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
356 # try to use it.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
357 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
358 self.configDom = parse(self.userPath + 'server_ini.xml')
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
359 self.configDoc = self.configDom.getroot()
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
360 if hasattr(self, 'bootPassword'): self.boot_pwd = self.bootPassword
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
361 else:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
362 if self.configDoc.get("admin"): self.boot_pwd = self.configDoc.get("admin")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
363 elif self.configDoc.get("boot"): self.boot_pwd = self.configDoc.get("boot")
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
364 if len(self.boot_pwd) < 1: self.boot_pwd = raw_input("Enter admin password: ")
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
365 if not hasattr(self, 'reg') and self.configDoc.get("register"):
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
366 self.reg = self.configDoc.get("register")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
367 if not len(self.reg) > 0 or self.reg[0].upper() not in ("Y", "N"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
368 opt = raw_input("Do you want to post your server to the OpenRPG Meta Server list? (y,n) ")
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
369 if len(opt) and (opt[0].upper() == 'Y'): self.reg = 'Y'
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
370 else: self.reg = 'N'
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
371 LobbyName = 'Lobby'
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
372
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
373 if self.configDoc.get("lobbyname"): LobbyName = self.configDoc.get("lobbyname")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
374 map_node = service_node = self.configDoc.findall("map")[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
375 msg_node = service_node = self.configDoc.findall("message")[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
376 mapFile = map_node.get('file')
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
377 msgFile = msg_node.get('file')
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
378 if mapFile == '': mapFile = 'Lobby_map.xml'
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
379 if msgFile == '': msgFile = 'LobbyMessage.html'
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
380 # Update the lobby with the passwords if they've been specified
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
381
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
382 if len(self.boot_pwd):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
383 self.groups = {'0': game_group( '0', LobbyName, "", 'The game lobby', self.boot_pwd, "",
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
384 self.userPath + mapFile.replace("myfiles/", ""),
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
385 self.userPath + msgFile.replace("myfiles/", ""), 1 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
386 }
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
387
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
388 # set ip or dns name to send to meta server
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
389 service_node = self.configDoc.findall("service")[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
390 address = service_node.get("address")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
391 address = address.lower()
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
392 if address == "" or address == "hostname/address" or address == "localhost": self.server_address = None
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
393 else: self.server_address = address
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
394 self.server_port = OPENRPG_PORT
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
395 if service_node.get("port"): self.server_port = int(service_node.get("port"))
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
396 if self.configDoc.get("name") and len(self.configDoc.get("name")) > 0 :
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
397 self.name = self.configDoc.get("name")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
398 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
399 if self.reg[0].upper() == "Y":
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
400 if self.name == None: self.name = raw_input("Server Name? ")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
401 self.register()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
402 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
403 # Get the minimum openrpg version from config if available
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
404 # if it isn't set min version to internal default.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
405 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
406 # server_ini.xml entry for version tag...
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
407 # <version min="x.x.x">
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
408 """
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
409
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
410 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
411 mver = self.configDoc.findall("version")[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
412 self.minClientVersion = mver.get("min")
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
413 except: self.minClientVersion = SERVER_MIN_CLIENT_VERSION #from orpg/orpg_version.py
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
414 self.defaultMessageFile = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
415 # This try/except bit is to allow older versions of python to continue without a list error.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
416
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
417
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
418 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
419 #------------------------[ START <AUTOKICK> TAG PROCESSING ]--------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
420 # Auto-kick option defaults for silent booting and
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
421 # setting the default zombie-client delay time --Snowdog 9/05
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
422 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
423 # server_ini.xml entry for autikick tag...
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
424 # <autokick silent=["no","yes"] delay="(# of seconds)">
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
425 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
426
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
427 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
428 ak = self.configDoc.findall("autokick")[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
429 if ak.get("silent"):
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
430 if ((ak.get("silent")).lower() == "yes"): self.silent_auto_kick = 1
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
431 else: self.silent_auto_kick = 0
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
432 if ak.get("delay"):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
433 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
434 delay = int(ak.get("delay"))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
435 self.zombie_time = delay
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
436 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
437 #delay value cannot be converted into an int use defaut
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
438 self.zombie_time = 480 #(default 8 mins)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
439 self.log_msg("**WARNING** Error with autokick delay string using default (480 sec)")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
440
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
441 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
442 self.silent_auto_kick = 0 #(default to off)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
443 self.zombie_time = 480 #(default 8 mins)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
444 self.log_msg("**WARNING** Error loading autokick settings... using defaults")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
445
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
446 alk = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
447 if (self.silent_auto_kick == 1): alk = "(Silent Mode)"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
448 self.log_msg("Auto Kick: Delay="+str(self.zombie_time) + " " + alk)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
449 """------------------------[ END <AUTOKICK> TAG PROCESSING ]--------------"""
90
d1aff41c031b Traipse Alpha 'OpenRPG' {090919-00}
sirebral
parents: 71
diff changeset
450
d1aff41c031b Traipse Alpha 'OpenRPG' {090919-00}
sirebral
parents: 71
diff changeset
451
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
452 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
453 #-------------------------------[ START <ROOM_DEFAULT> TAG PROCESSING ]--------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
454 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
455 # New room_defaults configuration option used to set various defaults
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
456 # for all user created rooms on the server. Incorporates akomans older
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
457 # default room message code (from above) --Snowdog 11/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
458 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
459 # option syntax
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
460 # <room_defaults passwords="yes" map="myfiles/LobbyMap.xml" message="myfiles/LobbyMessage.html" />
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
461 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
462
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
463 #default settings for tag options...
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
464 roomdefault_msg = str(self.defaultMessageFile) #no message is the default
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
465 roomdefault_map = "" #use lobby map as default
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
466 roomdefault_pass = 1 #allow passwords
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
467
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
468
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
469 #pull information from config file DOM
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
470 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
471 roomdefaults = self.configDom.findall("room_defaults")[0]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
472 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
473 setting = roomdefaults.findall('passwords')[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
474 rpw = setting.get('allow')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
475 if rpw == "no" or rpw == "0":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
476 roomdefault_pass = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
477 self.log_msg("Room Defaults: Disallowing Passworded Rooms")
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
478 else: self.log_msg("Room Defaults: Allowing Passworded Rooms")
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
479 except: self.log_msg("Room Defaults: [Warning] Allowing Passworded Rooms")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
480 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
481 setting = roomdefaults.findall('map')[0]
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
482 mapper = setting.get('file')
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
483 if mapper != "":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
484 roomdefault_map = self.userPath + mapper.replace("myfiles/", "")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
485 self.log_msg("Room Defaults: Using " + str(mapper) + " for room map")
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
486 except: self.log_msg("Room Defaults: [Warning] Using Default Map")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
487
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
488 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
489 setting = roomdefaults.findall('message')[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
490 msg = setting.get('file')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
491 if msg != "":
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
492 if msg[:4].lower() == 'http': roomdefault_msg = msg
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
493 else: roomdefault_msg = self.userPath + msg.replace("myfiles/", "")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
494 self.log_msg("Room Defaults: Using " + str(msg) + " for room messages")
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
495 except: print ("Room Defaults: [Warning] Using Default Message")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
496 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
497 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
498 self.log_msg("**WARNING** Error loading default room settings from configuration file. Using internal defaults.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
499
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
500 #set the defaults
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
501 if roomdefault_msg != "" or roomdefault_msg != None:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
502 self.defaultMessageFile = roomdefault_msg #<room_defaults> tag superceeds older <newrooms> tag
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
503 else: self.defaultMessageFile = None
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
504 if roomdefault_map != "" or roomdefault_map != None:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
505 self.defaultMapFile = roomdefault_map #<room_defaults> tag superceeds older <newrooms> tag
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
506 else: self.defaultMapFile = None
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
507
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
508 ##### room default map not handled yet. SETTING IGNORED
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
509 if roomdefault_pass == 0: self.allow_room_passwords = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
510 else: self.allow_room_passwords = 1
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
511 """-------------------------------[ END <ROOM_DEFAULT> TAG PROCESSING ]--------------------"""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
512
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
513 ###Server Cheat message
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
514 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
515 cheat_node = self.configDoc.findall("cheat")[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
516 self.cheat_msg = cheat_node.get("text")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
517 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
518 self.cheat_msg = "**FAKE ROLL**"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
519 self.log_msg("**WARNING** <cheat txt=\"\"> tag missing from server configuration file. Using empty string.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
520
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
521 # should validate protocal
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
522 validate_protocol_node = self.configDom.findall("validate_protocol")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
523 self.validate_protocol = 1
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
524 if(validate_protocol_node): self.validate_protocol = (validate_protocol_node[0].get("value") == "True")
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
525 if(self.validate_protocol != 1): self.log_msg("Protocol Validation: OFF")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
526 self.makePersistentRooms()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
527 self.log_msg("Server Configuration File: Processing Completed.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
528 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
529 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
530 self.log_msg("Exception in initServerConfig() " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
531
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
532 def makePersistentRooms(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
533 'Creates rooms on the server as defined in the server config file.'
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
534 for element in self.configDom.findall('room'):
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
535 roomName = element.get('name')
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
536 roomPassword = element.get('password')
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
537 bootPassword = element.get('boot')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
538
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
539 # Conditionally check for minVersion attribute
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
540 if element.get('minVersion'): minVersion = element.get('minVersion')
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
541 else: minVersion = ""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
542
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
543 # Extract the map filename attribute from the map node
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
544 # we only care about the first map element found -- others are ignored
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
545 mapElement = element.findall('map')[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
546 mapFile = self.userPath + mapElement.get('file').replace("myfiles/", "")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
547 messageElement = element.findall('message')[0]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
548 messageFile = messageElement.get('file')
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
549 if messageFile[:4] != 'http': messageFile = self.userPath + messageFile.replace("myfiles/", "")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
550
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
551 # Make sure we have a message to even mess with
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
552 if(len(messageFile) == 0): messageFile = self.defaultMessageFile
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
553 if(len(mapFile) == 0): mapFile = self.defaultMapFile
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
554 moderated = 0
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
555 if element.get('moderated') and element.get('moderated').lower() == "true": moderated = 1
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
556
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
557 #create the new persistant group
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
558 self.new_group(roomName, roomPassword,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
559 bootPassword, minVersion, mapFile,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
560 messageFile, persist = 1, moderated=moderated)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
561
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
562 def isPersistentRoom(self, id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
563 'Returns True if the id is a persistent room (other than the lobby), otherwise, False.'
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
564 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
565 # altered persistance tracking from simple room id based to per-group setting
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
566 # allows arbitrary rooms to be marked as persistant without needing the self.persistRoomThreshold
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
567 # -- Snowdog 4/04
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
568 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
569 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
570 id = str(id) #just in case someone sends an int instead of a str into the function
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
571 if id not in self.groups: return 0 #invalid room, can't be persistant
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
572 pr = (self.groups[id]).persistant
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
573 return pr
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
574 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
575 self.log_msg("Exception occured in isPersistentRoom(self,id)")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
576 return 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
577
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
578 #-----------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
579 # Toggle Meta Logging -- Added by Snowdog 4/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
580 #-----------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
581 def toggleMetaLogging(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
582 if self.show_meta_messages != 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
583 self.log_msg("Meta Server Logging: OFF")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
584 self.show_meta_messages = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
585 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
586 self.log_msg("Meta Server Logging: ON")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
587 self.show_meta_messages = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
588
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
589
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
590 #-----------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
591 # Start/Stop Network Logging to File -- Added by Snowdog 4/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
592 #-----------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
593 def NetworkLogging(self, mode = 0):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
594 if mode == 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
595 self.log_msg("Network Logging: OFF")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
596 self.log_network_messages = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
597 elif mode == 1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
598 self.log_msg("Network Logging: ON (composite logfile)")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
599 self.log_network_messages = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
600 elif mode == 2:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
601 self.log_msg("Network Logging: ON (split logfiles)")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
602 self.log_network_messages = 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
603 else: return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
604 #when log mode changes update all connection stubs
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
605 for n in self.players:
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
606 try: self.players[n].EnableMessageLogging = mode
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
607 except: self.log_msg("Error changing Message Logging Mode for client #" + str(self.players[n].id))
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
608
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
609 def NetworkLoggingStatus(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
610 if self.log_network_messages == 0: return "Network Traffic Log: Off"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
611 elif self.log_network_messages == 1: return "Network Traffic Log: Logging (composite file)"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
612 elif self.log_network_messages == 2: return "Network Traffic Log: Logging (inbound/outbound files)"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
613 else: self.log_msg("Network Traffic Log: [Unknown]")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
614
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
615 def register_callback(instance, xml_dom = None, source=None):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
616 if xml_dom: # if we get something
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
617 if source == getMetaServerBaseURL(): # if the source of this DOM is the authoritative meta
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
618 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
619 metacache_lock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
620 curlist = getRawMetaList() # read the raw meta cache lines into a list
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
621 updateMetaCache(xml_dom) # update the cache from the xml
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
622 newlist = getRawMetaList() # read it into a second list
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
623 finally:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
624 metacache_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
625
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
626 if newlist != curlist: # If the two lists aren't identical
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
627 # then something has changed.
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
628 instance.register() # Call self.register()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
629 # which will force a re-read of the meta cache and
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
630 # redo the registerThreads
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
631 else: instance.register()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
632
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
633 # Eventually, reset the MetaServerBaseURL here
90
d1aff41c031b Traipse Alpha 'OpenRPG' {090919-00}
sirebral
parents: 71
diff changeset
634
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
635 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
636 ## Added to help clean up parser errors in the XML on clients
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
637 ## due to characters that break welformedness of the XML from
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
638 ## the meta server.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
639 ## NOTE: this is a stopgap measure -SD
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
640 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
641 def clean_published_servername(self, name):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
642 #clean name of all apostrophes and quotes
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
643 badchars = "\"\\`><"
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
644 for c in badchars: name = name.replace(c,"")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
645 return name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
646
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
647 def registerRooms(self, args=None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
648 rooms = ''
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
649 id = '0'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
650 time.sleep(500)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
651 for rnum in self.groups.keys():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
652 rooms += urllib.urlencode( {"room_data[rooms][" + str(rnum) + "][name]":self.groups[rnum].name,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
653 "room_data[rooms][" + str(rnum) + "][pwd]":str(self.groups[rnum].pwd != "")})+'&'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
654 for pid in self.groups[rnum].players:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
655 rooms += urllib.urlencode( {"room_data[rooms][" + str(rnum) + "][players]["+str(pid)+"]":self.players[pid].name,})+'&'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
656 for meta in self.metas.keys():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
657 while id == '0':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
658 id, cookie = self.metas[meta].getIdAndCookie()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
659 data = urllib.urlencode( {"room_data[server_id]":id,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
660 "act":'registerrooms'})
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
661 get_server_dom(data+'&'+rooms, self.metas[meta].path, string=True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
662
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
663 def register(self,name_given=None):
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
664 if name_given == None: name = self.name
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
665 else: self.name = name = name_given
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
666 name = self.clean_published_servername(name)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
667
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
668 # Set up the value for num_users
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
669 if self.players: num_players = len(self.players)
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
670 else: num_players = 0
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
671
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
672 # request only Meta servers compatible with version 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
673 metalist = getMetaServers(versions=["2"])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
674 if self.show_meta_messages != 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
675 self.log_msg("Found these valid metas:")
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
676 for meta in metalist: self.log_msg("Meta:" + meta)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
677
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
678 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
679 # Go through the list and see if there is already a running register
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
680 # thread for the meta.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
681 # If so, call it's register() method
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
682 # If not, start one, implicitly calling the new thread's register() method
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
683
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
684 # iterate through the currently running metas and prune any
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
685 # not currently listed in the Meta Server list.
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
686 """
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
687
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
688 if self.show_meta_messages != 0: self.log_msg( "Checking running register threads for outdated metas.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
689 for meta in self.metas.keys():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
690 if self.show_meta_messages != 0: self.log_msg("meta:" + meta + ": ")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
691 if not meta in metalist: # if the meta entry running is not in the list
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
692 if self.show_meta_messages != 0: self.log_msg( "Outdated. Unregistering and removing")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
693 self.metas[meta].unregister()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
694 del self.metas[meta]
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
695 else:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
696 if self.show_meta_messages != 0: self.log_msg( "Found in current meta list. Leaving intact.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
697
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
698 # Now call register() for alive metas or start one if we need one
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
699 for meta in metalist:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
700 if self.metas.has_key(meta) and self.metas[meta] and self.metas[meta].isAlive():
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
701 self.metas[meta].register(name=name,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
702 realHostName=self.server_address,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
703 num_users=num_players)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
704 else:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
705 self.metas[meta] = registerThread(name=name, realHostName=self.server_address,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
706 num_users=num_players, MetaPath=meta, port=self.server_port,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
707 register_callback=self.register_callback)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
708 self.metas[meta].start()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
709
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
710 #The register Rooms thread
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
711 self.be_registered = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
712 thread.start_new_thread(self.registerRooms,(0,))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
713
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
714 def unregister(self):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
715 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
716 # loop through all existing meta entries
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
717 # Don't rely on getMetaServers(), as a server may have been
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
718 # removed since it was started. In that case, then the meta
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
719 # would never get unregistered.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
720 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
721 # Instead, loop through all existing meta threads and unregister them
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
722 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
723
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
724 for meta in self.metas.values():
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
725 if meta and meta.isAlive(): meta.unregister()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
726 self.be_registered = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
727
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
728 """
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
729 # This method runs as it's own thread and does the group_member_check every
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
730 # sixty seconds. This should eliminate zombies that linger when no one is
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
731 # around to spook them. GC: Frequency has been reduced as I question how valid
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
732 # the implementation is as it will only catch a very small segment of lingering
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
733 # connections.
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
734 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
735 def player_reaper_thread_func(self,arg):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
736 while self.alive:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
737 time.sleep(60)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
738 self.p_lock.acquire()
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
739 for group in self.groups.keys(): self.check_group_members(group)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
740 self.p_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
741
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
742 #This thread runs ever 250 miliseconds, and checks various plugin stuff
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
743 def PluginThread(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
744 while self.alive:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
745 self.p_lock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
746 players = ServerPlugins.getPlayer()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
747 for player in players:
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
748 if player is not None: pass #Do something here so they can show up in the chat room for non web users'
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
749 data = ServerPlugins.preParseOutgoing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
750 for msg in data:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
751 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
752 xml_dom = fromstring(msg).getroot()
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
753 if xml_dom.get('from') and int(xml_dom.get('from')) > -1:
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
754 xml_dom.set('from', '-1')
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
755 xml_dom.set('to', 'all')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
756 self.incoming_msg_handler(xml_dom, msg)
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
757 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
758 self.p_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
759 time.sleep(0.250)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
760
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
761 def sendMsg( self, sock, msg, useCompression=False, cmpType=None):
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
762 """Very simple function that will properly encode and send a message to the
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
763 remote on the specified socket."""
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
764 if not useCompression and cmpType != None:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
765 mpacket = cmpType.compress(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
766 lpacket = pack('!i', len(mpacket))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
767 sock.send(lpacket)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
768 offset = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
769 while offset < len(mpacket):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
770 slice = buffer(mpacket, offset, len(mpacket)-offset)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
771 sent = sock.send(slice)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
772 offset += sent
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
773 sentm = offset
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
774 else:
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
775 length = len( msg ) # Calculate our message length
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
776 lp = pack('!i', length) # Encode the message length into network byte order
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
777 try:
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
778 sentl = sock.send( lp ) # Send the encoded length
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
779 sentm = sock.send( msg ) # Now, send the message the the length was describing
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
780 except socket.error, e: self.log_msg( e )
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
781 except Exception, e: self.log_msg( e )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
782
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
783
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
784 def recvData( self, sock, readSize ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
785 """Simple socket receive method. This method will only return when the exact
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
786 byte count has been read from the connection, if remote terminates our
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
787 connection or we get some other socket exception."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
788 data = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
789 offset = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
790 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
791 while offset != readSize:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
792 frag = sock.recv( readSize - offset )
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
793 rs = len( frag ) # See if we've been disconnected
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
794 if rs <= 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
795 # Loudly raise an exception because we've been disconnected!
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
796 raise IOError, "Remote closed the connection!"
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
797 else: # Continue to build complete message
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
798 offset += rs
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
799 data += frag
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
800 except socket.error, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
801 self.log_msg("Socket Error: recvData(): " + e )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
802 data = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
803 return data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
804
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
805 def recvMsg(self, sock, useCompression=False, cmpType=None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
806 """This method now expects to receive a message having a 4-byte prefix length. It will ONLY read
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
807 completed messages. In the event that the remote's connection is terminated, it will throw an
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
808 exception which should allow for the caller to more gracefully handles this exception event.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
809
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
810 Because we use strictly reading ONLY based on the length that is told to use, we no longer have to
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
811 worry about partially adjusting for fragmented buffers starting somewhere within a buffer that we've
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
812 read. Rather, it will get ONLY a whole message and nothing more. Everything else will remain buffered
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
813 with the OS until we attempt to read the next complete message."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
814
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
815 msgData = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
816 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
817 lenData = self.recvData( sock, MPLAY_LENSIZE )
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
818 (length,) = unpack('!i', lenData) # Now, convert to a usable form
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
819 msgData = self.recvData( sock, length ) # Read exactly the remaining amount of data
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
820 try:
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
821 if useCompression and cmpType != None: msgData = cmpType.decompress(msgData)
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
822 except: traceback.print_exc()
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
823 except Exception, e: self.log_msg( "Exception: recvMsg(): " + str(e) )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
824 return msgData
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
825
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
826 def kill_server(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
827 self.alive = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
828 self.log_msg("Server stopping...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
829 self.unregister() # unregister from the Meta
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
830 for p in self.players.itervalues():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
831 p.disconnect()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
832 self.incoming.put("<system/>")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
833 for g in self.groups.itervalues():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
834 g.save_map()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
835 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
836 ip = socket.gethostbyname(socket.gethostname())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
837 kill = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
838 kill.connect((ip, self.server_port))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
839
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
840 # Now, send the "system" command using the correct protocol format
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
841 self.sendMsg( kill, "<system/>" )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
842 kill.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
843 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
844 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
845
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
846 self.listen_sock.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
847 self.listen_event.wait(10)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
848 self.incoming_event.wait(10)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
849 self.log_msg("Server stopped!")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
850
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
851 def log_msg(self,msg):
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
852 debug(parents=True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
853 if self.log_to_console:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
854 if self.log_console: self.log_console(msg)
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
855 else: print str(msg)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
856
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
857 def print_help(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
858 print
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
859 print "Commands: "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
860 print "'kill' or 'quit' - to stop the server"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
861 print "'broadcast' - broadcast a message to all players"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
862 print "'list' - list players and groups"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
863 print "'dump' - to dump player data"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
864 print "'dump groups' - to list the group names and ids only"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
865 print "'group n' - to list details about one group only"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
866 print "'register' - To register the server as name. Also used to change the server's name if registered."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
867 print "'unregister' - To remove this server from the list of servers"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
868 print "'get lobby boot password' - to show the Lobby's boot password"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
869 print "'set lobby boot password' - to set the Lobby's boot password"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
870 print "'log' - toggles logging to the console off or on"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
871 print "'log meta' - toggles logging of meta server messages on or off"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
872 print "'logfile [off|on|split]' - timestamped network traffic log"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
873 print "'remove room' - to remove a room from the server"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
874 print "'kick' - kick a player from the server"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
875 print "'ban' - ban a player from the server"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
876 print "'remotekill' - This will toggle the ability to kill the server via the /admin command"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
877 print "'monitor (#)' - monitors raw network I/O stream to specific client"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
878 print "'purge clients' - boots all connected clients off the server immediately"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
879 print "'zombie [set [min]]' - view/set the auto-kick time for zombie clients"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
880 #drop any clients that are idle for more than 8 hours
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
881 #as these are likely dead clientskick' - kick a player from the server"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
882 print "'uptime' - reports how long server has been running"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
883 print "'roompasswords' - allow/disallow room passwords (toggle)"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
884 print "'search' - will prompt for pattern and display results"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
885 print "'sendsize' - will ajust the send size limit"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
886 print "'remoteadmin' - will toggle remote admin commands"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
887 print "'togglelobbysound' - Will turn on or off the Auto sending of a sound to all players who join the loby"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
888 print "'lobbysound' - Lets you specify which sound file to send to players joining the lobby"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
889 print "'help' or '?' or 'h' - for this help message"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
890 print
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
891
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
892 def broadcast(self,msg):
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
893 self.send_to_all("0","<msg to='all' from='0' group_id='1'><font color='#FF0000'>" + msg + "</font></msg>")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
894
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
895 def console_log(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
896 if self.log_to_console == 1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
897 print "console logging now off"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
898 self.log_to_console = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
899 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
900 print "console logging now on"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
901 self.log_to_console = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
902
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
903 def groups_list(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
904 self.p_lock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
905 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
906 keys = self.groups.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
907 for k in keys:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
908 pw = "-"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
909 pr = " -"
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
910 if self.groups[k].pwd != "": pw = "P"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
911 if self.isPersistentRoom( k ): pr = " S" #using S for static (P for persistant conflicts with password)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
912 print "Group: " + k + pr + pw + ' Name: ' + self.groups[k].name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
913 print
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
914 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
915 self.log_msg(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
916 self.p_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
917
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
918 """
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
919 #----------------------------------------------------------------
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
920 # Monitor Function -- Added by snowdog 2/05
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
921 #----------------------------------------------------------------
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
922 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
923 def monitor(self, pid, mode=1 ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
924 "allows monitoring of a specific user(s) network i/o"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
925 #if mode is not set to 1 then monitor adds toggles the state
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
926 #of monitoring on the given user
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
927 if (mode == 1):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
928 for p in self.players:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
929 try: p.monitor("off")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
930 except: pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
931 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
932 r = (self.players[pid]).set_traffic_monitor("toggle")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
933 self.log_msg("Monitor: Mode=" + str(r) + " on Player #" + str(pid))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
934 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
935 self.log_msg("Monitor: Invalid Player ID")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
936 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
937
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
938 def search(self,patern):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
939 keys = self.groups.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
940 print "Search results:"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
941 for k in keys:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
942 ids = self.groups[k].get_player_ids()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
943 for id in ids:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
944 if self.players[id].id.find(patern)>-1: self.print_player_info(self.players[id])
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
945 elif self.players[id].name.find(patern)>-1: self.print_player_info(self.players[id])
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
946 elif self.players[id].ip.find(patern)>-1: self.print_player_info(self.players[id])
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
947 elif self.players[id].group_id.find(patern)>-1: self.print_player_info(self.players[id])
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
948 elif self.players[id].role.find(patern)>-1: self.print_player_info(self.players[id])
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
949 elif self.players[id].version.find(patern)>-1: self.print_player_info(self.players[id])
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
950 elif self.players[id].protocol_version.find(patern)>-1: self.print_player_info(self.players[id])
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
951 elif self.players[id].client_string.find(patern)>-1: self.print_player_info(self.players[id])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
952
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
953 def obtain_by_id(self, id, objects):
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
954 ### Alpha ### Basic way to obtain information for the Server GUI, currently reports the Client String only
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
955 return self.players[id].client_string
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
956
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
957 def print_player_info(self,player):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
958 print player.id, player.name, player.ip, player.group_id, player.role, player.version, player.protocol_version, player.client_string
90
d1aff41c031b Traipse Alpha 'OpenRPG' {090919-00}
sirebral
parents: 71
diff changeset
959
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
960 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
961 #----------------------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
962 # Uptime Function -- Added by snowdog 4/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
963 #----------------------------------------------------------------
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
964 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
965 def uptime(self , mode = 0):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
966 "returns string containing how long server has been in operation"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
967 ut = time.time() - self.server_start_time
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
968 d = int(ut/86400)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
969 h = int( (ut-(86400*d))/3600 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
970 m = int( (ut-(86400*d)-(3600*h))/60)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
971 s = int( (ut-(86400*d)-(3600*h)-(60*m)) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
972 uts = str( "This server has been running for:\n " + str(d) + " days " + str(h) + " hours " + str(m) + " min. " + str(s) + " sec. [" + str(int(ut)) + " seconds]")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
973 if mode == 0: print uts
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
974 else: return uts
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
975
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
976 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
977 #-----------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
978 # Toggle Room Password Allow -- Added by Snowdog 11/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
979 #-----------------------------------------------------
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
980 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
981 def RoomPasswords(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
982 if self.allow_room_passwords != 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
983 self.allow_room_passwords = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
984 return "Client Created Room Passwords: Disallowed"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
985 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
986 self.allow_room_passwords = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
987 return "Client Created Room Passwords: Allowed"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
988
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
989 def group_dump(self,k):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
990 self.p_lock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
991 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
992 print "Group: " + k
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
993 print " Name: %s" % self.groups[k].name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
994 print " Desc: %s" % self.groups[k].desc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
995 print " Pass: %s" % self.groups[k].pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
996 print " Boot: %s" % self.groups[k].boot_pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
997 print " Moderated: %s" % self.groups[k].moderated
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
998 print " Map: %s" % self.groups[k].game_map.get_all_xml()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
999 print
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1000 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1001 self.log_msg(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1002 self.p_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1003
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1004 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1005 #----------------------------------------------------------------
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1006 # Player List -- Added by snowdog 4/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1007 #----------------------------------------------------------------
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1008 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1009 def player_list(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1010 "display a condensed list of players on the server"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1011 self.p_lock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1012 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1013 print "------------[ PLAYER LIST ]------------"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1014 keys = self.groups.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1015 keys.sort(id_compare)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1016 for k in keys:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1017 groupstring = "Group " + str(k) + ": " + self.groups[k].name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1018 if self.groups[k].pwd != "":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1019 groupstring += " (Pass: \"" + self.groups[k].pwd + "\" )"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1020 print groupstring
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1021 ids = self.groups[k].get_player_ids()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1022 ids.sort(id_compare)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1023 for id in ids:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1024 if self.players.has_key(id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1025 print " (%s)%s [IP: %s] %s (%s)" % ((self.players[id]).id, (self.players[id]).name, (self.players[id]).ip, (self.players[id]).idle_status(), (self.players[id]).connected_time_string())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1026 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1027 self.groups[k].remove_player(id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1028 print "Bad Player Ref (#" + id + ") in group"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1029 if len(ids) > 0: print ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1030 print "--------------------------------------"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1031 print "\nStatistics: groups: " + str(len(self.groups)) + " players: " + str(len(self.players))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1032 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1033 self.log_msg(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1034 self.p_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1035
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1036
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1037 def player_dump(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1038 self.p_lock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1039 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1040 keys = self.groups.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1041 for k in keys:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1042 print "Group: %s %s (pass: \"%s\")" % (str(k),self.groups[k].name, self.groups[k].pwd)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1043 ids = self.groups[k].get_player_ids()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1044 for id in ids:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1045 if self.players.has_key(id): print str(self.players[id])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1046 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1047 self.groups[k].remove_player(id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1048 print "Bad Player Ref (#" + id + ") in group"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1049 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1050 self.log_msg(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1051 self.p_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1052
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1053 def update_request(self,newsock, xml_dom):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1054 # handle reconnects
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1055 self.log_msg( "update_request() has been called." )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1056
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1057 # get player id
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1058 id = xml_dom.get("id")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1059 group_id = xml_dom.get("group_id")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1060 self.p_lock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1061 if self.players.has_key(id):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1062 self.sendMsg(newsock, self.players[id].toxml("update"),
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1063 self.players[id].useCompression,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1064 self.players[id].compressionType )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1065 self.players[id].reset(newsock)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1066 self.players[id].clear_timeout()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1067 need_new = 0
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1068 else: need_new = 1
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1069 self.p_lock.release()
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1070 if need_new: self.new_request(newsock, xml_dom)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1071 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1072 msg = self.groups[group_id].game_map.get_all_xml()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1073 self.send(msg,id,group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1074
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1075 def new_request(self,newsock, xml_dom, LOBBY_ID='0'):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1076 #build client stub
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1077 props = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1078 # Don't trust what the client tells us...trust what they connected as!
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1079 props['ip'] = socket.gethostbyname( newsock.getpeername()[0] )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1080
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1081 props['role'] = xml_dom.get("role") or 'GM'
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1082 props['name'] = xml_dom.get("name")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1083 props['group_id'] = LOBBY_ID
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1084 props['id'] = str(self.next_player_id)
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1085 props['version'] = xml_dom.get("version")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1086 props['protocol_version'] = xml_dom.get("protocol_version")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1087 props['client_string'] = xml_dom.get("client_string")
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1088
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1089 self.next_player_id += 1
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1090 new_stub = client_stub(self.incoming, newsock, props, self.log_console)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1091 if xml_dom.get('useCompression'):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1092 new_stub.useCompression = True
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1093 if xml_dom.get('cmpType'):
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1094 cmpType = xml_dom.get('cmpType')
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1095 if cmpBZ2 and cmpType == 'bz2': new_stub.compressionType = bz2
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1096 elif cmpZLIB and cmpType == 'zlib': new_stub.compressionType = zlib
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1097 else: new_stub.compressionType = None
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1098 else: new_stub.compressionType = bz2
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1099 else: new_stub.useCompression = False
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1100
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1101 #update newly create client stub with network logging state
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1102 new_stub.EnableMessageLogging = self.log_network_messages
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1103 self.sendMsg(newsock, new_stub.toxml("new"), False, None)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1104
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1105 # send confirmation
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1106 data = self.recvMsg(newsock, new_stub.useCompression, new_stub.compressionType)
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
1107 try: xml_dom = XML(data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1108 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1109 print e
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1110 (remote_host,remote_port) = newsock.getpeername()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1111 bad_xml_string = "Your client sent an illegal message to the server and will be disconnected. "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1112 bad_xml_string += "Please report this bug to the development team at:<br /> "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1113 bad_xml_string += "<a href=\"http://sourceforge.net/tracker/?group_id=2237&atid=102237\">OpenRPG bugs "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1114 bad_xml_string += "(http://sourceforge.net/tracker/?group_id=2237&atid=102237)</a><br />"
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
1115 self.sendMsg( newsock, "<msg to='" + props['id'] + "' from='" + props['id'] + "' group_id='0' />" + bad_xml_string,
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
1116 new_stub.useCompression, new_stub.compressionType)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1117
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1118 time.sleep(2)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1119 newsock.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1120 print "Error in parse found from " + str(remote_host) + ". Disconnected."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1121 print " Offending data(" + str(len(data)) + "bytes)=" + data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1122 print "Exception=" + str(e)
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1123 #if xml_dom: xml_dom.unlink()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1124 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1125
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1126 #start threads and store player
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1127 allowed = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1128 version_string = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1129
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1130 if ((props['protocol_version'] != PROTOCOL_VERSION) and self.validate_protocol):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1131 version_string = "Sorry, this server can't handle your client version. (Protocol mismatch)<br />"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1132 allowed = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1133
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1134 if not self.checkClientVersion(props['version']):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1135 version_string = "Sorry, your client is out of date. <br />"
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1136 version_string += "This server requires your client be version "
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1137 version_string += "" + self.minClientVersion + " or higher to connect.<br />"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1138 allowed = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1139
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1140 if not allowed:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1141 version_string += " Please go to <a href='http://www.assembla.com/traipse'>"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1142 version_string += "http://www.assembla.com/traipse</a> to find a compatible client.<br />"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1143 version_string += "If you can't find a compatible client on the website, "
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1144 version_string += "chances are that the server is running an unreleased development "
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1145 version_string += "version for testing purposes.<br />"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1146
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1147 self.sendMsg( newsock, "<msg to='" + props['id'] + "' from='0' group_id='0' />" + version_string, new_stub.useCompression, new_stub.compressionType)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1148 # Give messages time to flow
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1149 time.sleep(1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1150 self.log_msg("Connection terminating due to version incompatibility with client (ver: " + props['version'] + " protocol: " + props['protocol_version'] + ")" )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1151 newsock.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1152 return None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1153
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1154 ip = props['ip']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1155 if self.ban_list.has_key(ip):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1156 banmsg = "You have been banned from this server.<br />"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1157 cmsg = "Banned Client: (" + str(props['id']) + ") " + str(props['name']) + " [" + str(props['ip']) + "]"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1158 self.log_msg(cmsg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1159 allowed = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1160 self.sendMsg( newsock, "<msg to='" + props['id'] + "' from='0' group_id='0' />" + banmsg, new_stub.useCompression, new_stub.compressionType)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1161 # Give messages time to flow
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1162 time.sleep(1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1163 newsock.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1164 return None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1165
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1166 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1167 #---- Connection order changed by Snowdog 1/05
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1168 #---- Attempt to register player and send group data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1169 #---- before displaying lobby message
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1170 #---- Does not solve the Blackhole bug but under some conditions may
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1171 #---- allow for a graceful server response. -SD
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1172
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1173 #---- changed method of sending group names to user 8/05
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1174 #---- black hole bug causes the group information to not be sent
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1175 #---- to clients. Not sure why the group messages were being sent to the
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1176 #---- incomming message queue, when they should be sent directly to user
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1177 #---- Does not solve the black hole bug totally -SD
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1178 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1179
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1180 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1181 if xml_dom.get("id") == props['id']:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1182 new_stub.initialize_threads()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1183 self.p_lock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1184 self.players[props['id']] = new_stub
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1185 self.groups[LOBBY_ID].add_player(props['id']) #always add to lobby on connection.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1186 self.send_group_list(props['id'])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1187 self.send_player_list(props['id'],LOBBY_ID)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1188 self.p_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1189 msg = self.groups[LOBBY_ID].game_map.get_all_xml()
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1190 self.send(msg, props['id'], LOBBY_ID)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1191 self.send_to_group(props['id'], LOBBY_ID, self.players[props['id']].toxml('new'))
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1192 self.return_room_roles(props['id'], LOBBY_ID)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1193
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1194 # Re-initialize the role for this player incase they came from a different server
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1195 self.handle_role("set", props['id'], "GM", self.groups[LOBBY_ID].boot_pwd, LOBBY_ID)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1196 cmsg = "Client Connect: (" + str(props['id']) + ") " + str(props['name']) + " [" + str(props['ip']) + "]"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1197 self.log_msg(cmsg)
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
1198 cmsg = ("connect", props) #################################################
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
1199 self.log_msg(cmsg)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1200
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1201 # If already registered then re-register, thereby updating the Meta
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1202 # on the number of players
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1203 if self.be_registered:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1204 self.register()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1205 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1206 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1207
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1208 #something didn't go right. Notify client and drop the connection
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1209 err_string = "<center>"
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1210 err_string += "<hr><b>The server has encountered an error while processing your connection request.</b><hr>"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1211 err_string += "<br /><i>You are being disconnected from the server.</i><br />"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1212 err_string += "This error may represent a problem with the server. If you continue to get this message "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1213 err_string += "please contact the servers administrator to correct the issue.</center> "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1214 self.sendMsg( newsock, "<msg to='" + props['id'] + "' from='" + props['id'] + "' group_id='0' />" + err_string, new_stub.useCompression, new_stub.compressionType )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1215 time.sleep(2)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1216 newsock.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1217
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1218 # Display the lobby message
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1219 self.SendLobbyMessage(newsock,props['id'])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1220
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1221 def checkClientVersion(self, clientversion):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1222 minv = self.minClientVersion.split('.')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1223 cver = clientversion.split('.')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1224 for i in xrange(min(len(minv),len(cver))):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1225 w=max(len(minv[i]),len(cver[i]))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1226 v1=minv[i].rjust(w);
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1227 v2=cver[i].rjust(w);
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1228 if v1<v2: return 1
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1229 if v1>v2: return 0
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1230 if len(minv)>len(cver): return 0
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1231 return 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1232
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1233 def SendLobbyMessage(self, socket, player_id):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1234 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1235 # Display the lobby message
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1236 # prepend this server's version string to the the lobby message
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1237 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1238 try:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1239 lobbyMsg = "You have connected to an <a href=\"http://www.openrpg.com\">OpenRPG</a> "
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1240 lobbyMsg += "server, version '" + VERSION + "'"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1241
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1242 # See if we have a server name to report!
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1243 if len(self.serverName): lobbyMsg += ", named '" + self.serverName + "'."
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1244 else: lobbyMsg += "."
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1245
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1246 # Add extra line spacing
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1247 lobbyMsg += "\n\n"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1248
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1249 try: validate.config_file("LobbyMessage.html","default_LobbyMessage.html")
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1250 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1251 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1252 open_msg = open( self.userPath + "LobbyMessage.html", "r" )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1253 lobbyMsg += open_msg.read()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1254 open_msg.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1255
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1256 # Send the server's lobby message to the client no matter what
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1257 self.sendMsg(socket, "<msg to='" + player_id + "' from='0' group_id='0' />" + lobbyMsg,
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1258 self.players[player_id].useCompression, self.players[player_id].compressionType)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1259 if self.sendLobbySound:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1260 self.sendMsg(socket, '<sound url="' + self.lobbySound + '" group_id="0" from="0" loop="True" />',
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1261 self.players[player_id].useCompression, self.players[player_id].compressionType)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1262 return
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1263 except: traceback.print_exc()
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1264 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1265 # End of lobby message code
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1266 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1267
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1268
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1269 def listenAcceptThread(self,arg):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1270 # Set up the socket to listen on.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1271 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1272 self.log_msg("\nlisten thread running...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1273 adder = ""
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1274 if self.server_address is not None: adder = self.server_address
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1275 self.listen_sock.bind(('', self.server_port))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1276 self.listen_sock.listen(5)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1277
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1278 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1279 self.log_msg(("Error binding request socket!", e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1280 self.alive = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1281
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1282 while self.alive:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1283 # Block on the socket waiting for a new connection
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1284 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1285 (newsock, addr) = self.listen_sock.accept()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1286 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1287 ## self.log_msg("New connection from " + str(addr)+ ". Interfacing with server...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1288
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1289 # Now that we've accepted a new connection, we must immediately spawn a new
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1290 # thread to handle it...otherwise we run the risk of having a DoS shoved into
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1291 # our face! :O After words, this thread is dead ready for another connection
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1292 # accept to come in.
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1293 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1294 thread.start_new_thread(self.acceptedNewConnectionThread, ( newsock, addr ))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1295
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1296 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1297 print "The following exception caught accepting new connection:"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1298 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1299
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1300 # At this point, we're done and cleaning up.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1301 self.log_msg("server socket listening thread exiting...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1302 self.listen_event.set()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1303
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1304 def acceptedNewConnectionThread( self, newsock, addr ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1305 """Once a new connection comes in and is accepted, this thread starts up to handle it."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1306 # Initialize xml_dom
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1307 xml_dom = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1308 data = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1309
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1310 # get client info and send othe client info
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1311 # If this receive fails, this thread should exit without even attempting to process it
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1312 self.log_msg("Connection from " + str(addr) + " has been accepted. Waiting for data...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1313 data = self.recvMsg( newsock )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1314 if data=="" or data == None:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1315 self.log_msg("Connection from " + str(addr) + " failed. Closing connection.")
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1316 try: newsock.close()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1317 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1318 self.log_msg( str(e) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1319 print str(e)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1320 return #returning causes connection thread instance to terminate
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1321 if data == "<system/>":
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1322 try: newsock.close()
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1323 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1324 return #returning causes connection thread instance to terminate
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1325 # Clear out the xml_dom in preparation for new stuff, if necessary
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1326 """try: if xml_dom: xml_dom.unlink()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1327
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1328 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1329 self.log_msg( "The following exception caught unlinking xml_dom:")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1330 self.log_msg("Continuing")
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1331 try: newsock.close()
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1332 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1333 return #returning causes connection thread instance to terminate
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1334 # Parse the XML received from the connecting client"""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1335 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1336 xml_dom = XML(data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1337
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1338 except:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1339 try: newsock.close()
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1340 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1341 self.log_msg( "Error in parse found from " + str(addr) + ". Disconnected.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1342 self.log_msg(" Offending data(" + str(len(data)) + "bytes)=" + data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1343 self.log_msg( "Exception:")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1344 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1345 return #returning causes connection thread instance to terminate
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1346
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1347 # Determine the correct action and execute it
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1348 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1349 # get action
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1350 action = xml_dom.get("action")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1351
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1352 # Figure out what type of connection we have going on now
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1353 if action == "new": self.new_request(newsock, xml_dom)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1354 elif action == "update": self.update_request(newsock, xml_dom)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1355 else: self.log_msg("Unknown Join Request!")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1356
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1357 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1358 print "The following message: " + str(data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1359 print "from " + str(addr) + " created the following exception: "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1360 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1361 return #returning causes connection thread instance to terminate
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1362
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1363 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1364 #========================================================
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1365 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1366 # Message_handler
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1367 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1368 #========================================================
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1369 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1370 # Changed thread organization from one continuous parsing/handling thread
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1371 # to multiple expiring parsing/handling threads to improve server performance
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1372 # and player load capacity -- Snowdog 3/04
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1373 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1374
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1375 def message_handler(self, arg):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1376 xml_dom = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1377 self.log_msg( "message handler thread running..." )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1378 while self.alive:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1379 data = None
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1380 try: data=self.incoming.get(0)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1381 except Queue.Empty:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1382 time.sleep(0.5) #sleep 1/2 second
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1383 continue
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1384
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1385 bytes = len(data)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1386 if bytes <= 0: continue
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1387 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1388 thread.start_new_thread(self.parse_incoming_dom,(str(data),))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1389 #data has been passed... unlink from the variable references
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1390 #so data in passed objects doesn't change (python passes by reference)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1391 del data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1392 data = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1393 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1394 self.log_msg(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1395 self.log_msg("message handler thread exiting...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1396 self.incoming_event.set()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1397
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1398 def parse_incoming_dom(self, data):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1399 end = data.find(">") #locate end of first element of message
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1400 head = data[:end+1]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1401 xml_dom = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1402 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1403 xml_dom = XML(head)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1404 self.message_action(xml_dom, data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1405
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1406 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1407 print "Error in parse of inbound message. Ignoring message."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1408 print " Offending data(" + str(len(data)) + "bytes)=" + data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1409 print "Exception=" + str(e)
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1410
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1411 def message_action(self, xml_dom, data):
124
8827271fbe1b Traipse Alpha 'OpenRPG' {091001-01}
sirebral
parents: 122
diff changeset
1412 tag_name = xml_dom.tag
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1413 if self.svrcmds.has_key(tag_name): self.svrcmds[tag_name]['function'](xml_dom, data)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1414 else: raise Exception, "Not a valid header!"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1415 #Message Action thread expires and closes here.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1416 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1417
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1418 def do_alter(self, xml_dom, data):
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1419 target = xml_dom.get("key") or 'None'
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1420 value = xml_dom.get("val") or 'None'
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1421 player = xml_dom.get("plr") or 'None'
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1422 group_id = xml_dom.get("gid") or 'None'
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1423 boot_pwd = xml_dom.get("bpw") or 'None'
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1424 actual_boot_pwd = self.groups[group_id].boot_pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1425
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1426 if self.allow_room_passwords == 0:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1427 msg ="<msg to='" + player + "' from='0' group_id='0' /> "
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1428 msg += "Room passwords have been disabled by the server administrator."
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1429 self.players[player].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1430 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1431 elif boot_pwd == actual_boot_pwd:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1432 if target == "pwd":
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1433 lmessage = "Room password changed to from " + self.groups[group_id].pwd + " to " + value + " by " + player
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1434 self.groups[group_id].pwd = value
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1435 msg ="<msg to='" + player + "' from='0' group_id='0' /> Room password changed to " + value + "."
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1436 self.players[player].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1437 self.log_msg(lmessage)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1438 self.send_to_all('0',self.groups[group_id].toxml('update'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1439 elif target == "name":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1440 # Check for & in name. We want to allow this because of its common
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1441 # use in d&d games
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1442 result = self.change_group_name(group_id, value, player)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1443 msg ="<msg to='" + player + "' from='0' group_id='0' />" + result
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1444 self.players[player].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1445 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1446 msg ="<msg to='" + player + "' from='0' group_id='0'>Invalid Administrator Password."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1447 self.players[player].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1448
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1449 def do_role(self, xml_dom, data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1450 role = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1451 boot_pwd = ""
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1452 act = xml_dom.get("action")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1453 player = xml_dom.get("player")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1454 group_id = xml_dom.get("group_id")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1455 if act == "set":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1456 role = xml_dom.get("role")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1457 boot_pwd = xml_dom.get("boot_pwd")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1458 if group_id != "0":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1459 self.handle_role(act, player, role, boot_pwd, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1460 self.log_msg(("role", (player, role)))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1461
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1462 def do_ping(self, xml_dom, data):
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1463 player = xml_dom.get("player")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1464 group_id = xml_dom.get("group_id")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1465 sent_time = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1466 msg = ""
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1467 try: sent_time = xml_dom.get("time")
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1468 except: pass
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1469 if sent_time != "": msg ="<ping time='" + str(sent_time) + "' />" #because a time was sent return a ping response
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1470 else:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1471 msg ="<msg to='" + player + "' from='" + player + "' group_id='" + group_id + "'>"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1472 msg += "<font color='#FF0000'>PONG!?!</font>"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1473 self.players[player].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1474
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1475 def do_system(self, xml_dom, data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1476 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1477
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1478 def moderate_group(self,xml_dom,data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1479 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1480 action = xml_dom.get("action")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1481 from_id = xml_dom.get("from")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1482 if xml_dom.get("pwd"): pwd=xml_dom.get("pwd")
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1483 else: pwd=""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1484 group_id=self.players[from_id].group_id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1485 if action == "list":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1486 if (self.groups[group_id].moderated):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1487 msg = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1488 for i in self.groups[group_id].voice.keys():
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1489 if msg != "": msg +=", "
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1490 if self.players.has_key(i): msg += '('+i+') '+self.players[i].name
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1491 else: del self.groups[group_id].voice[i]
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1492 if (msg != ""): msg = "The following users may speak in this room: " + msg
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1493 else: msg = "No people are currently in this room with the ability to chat"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1494 self.players[from_id].self_message(msg)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1495 else: self.players[from_id].self_message("This room is currently unmoderated")
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1496 elif action == 'enable' or 'disable' or 'addvoice' or 'delvoice':
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1497 #condenses password check --TaS 2009
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1498 if not self.groups[group_id].check_boot_pwd(pwd):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1499 self.players[from_id].self_message("Failed - incorrect admin password")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1500 return
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1501 if action == 'enable':
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1502 self.groups[group_id].moderated = 1
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1503 self.players[from_id].self_message("This channel is now moderated")
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1504 if action == 'disable':
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1505 self.groups[group_id].moderated = 0
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1506 self.players[from_id].self_message("This channel is now unmoderated")
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1507 if action == 'addvoice':
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1508 users = xml_dom.get("users").split(',')
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1509 for i in users: self.groups[group_id].voice[i.strip()]=1
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1510 if action == 'delvoice':
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1511 users = xml_dom.get("users").split(',')
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1512 for i in users:
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1513 if self.groups[group_id].voice.has_key(i.strip()): del self.groups[group_id].voice[i.strip()]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1514 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1515 print "Bad input: " + data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1516 except Exception,e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1517 self.log_msg(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1518
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1519 def join_group(self, xml_dom, data):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1520 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1521 from_id = xml_dom.get("from")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1522 pwd = xml_dom.get("pwd")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1523 group_id = xml_dom.get("group_id")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1524 ver = self.players[from_id].version
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1525 allowed = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1526
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1527 if not self.groups[group_id].check_version(ver):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1528 allowed = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1529 msg = 'failed - invalid client version ('+self.groups[group_id].minVersion+' or later required)'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1530
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1531 if not self.groups[group_id].check_pwd(pwd):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1532 allowed = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1533 #tell the clients password manager the password failed -- SD 8/03
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1534 pm = "<password signal='fail' type='room' id='" + group_id + "' data=''/>"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1535 self.players[from_id].outbox.put(pm)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1536 msg = 'failed - incorrect room password'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1537
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1538 if not allowed:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1539 self.players[from_id].self_message(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1540 #the following line makes sure that their role is reset to normal,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1541 #since it is briefly set to lurker when they even TRY to change
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1542 #rooms
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1543 msg = "<role action='update' id='" + from_id + "' role='" + self.players[from_id].role + "' />"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1544 self.players[from_id].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1545 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1546
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1547 #move the player into their new group.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1548 self.move_player(from_id, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1549 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1550 self.log_msg(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1551
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1552 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1553 # move_player function -- added by Snowdog 4/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1554 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1555 # Split join_group function in half. separating the player validation checks
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1556 # from the actual group changing code. Done primarily to impliment
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1557 # boot-from-room-to-lobby behavior in the server.
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1558 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1559
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1560 def move_player(self, from_id, group_id ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1561 "move a player from one group to another"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1562 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1563 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1564 if group_id == "0": self.players[from_id].role = "GM"
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1565 else: self.players[from_id].role = "Lurker"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1566 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1567 print "exception in move_player() "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1568 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1569
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1570 old_group_id = self.players[from_id].change_group(group_id, self.groups)
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1571 self.send_to_group(from_id, old_group_id, self.players[from_id].toxml('del'))
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1572 self.send_to_group(from_id, group_id, self.players[from_id].toxml('new'))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1573 self.check_group(from_id, old_group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1574
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1575 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1576 # Here, if we have a group specific lobby message to send, push it on
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1577 # out the door! Make it put the message then announce the player...just
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1578 # like in the lobby during a new connection.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1579 # -- only do this check if the room id is within range of known persistent id thresholds
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1580 #also goes ahead if there is a defaultRoomMessage --akoman
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1581 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1582
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1583 if self.isPersistentRoom(group_id) or self.defaultMessageFile != None:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1584 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1585 if self.groups[group_id].messageFile[:4] == 'http':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1586 data = urllib.urlretrieve(self.groups[group_id].messageFile)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1587 roomMsgFile = open(data[0])
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1588 else: roomMsgFile = open(self.groups[group_id].messageFile, "r")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1589 roomMsg = roomMsgFile.read()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1590 roomMsgFile.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1591 urllib.urlcleanup()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1592
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1593 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1594 roomMsg = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1595 self.log_msg(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1596
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1597 # Spit that darn message out now!
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1598 self.players[from_id].outbox.put("<msg to='" + from_id + "' from='0' group_id='" + group_id + "' />" + roomMsg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1599 if self.sendLobbySound and group_id == '0':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1600 self.players[from_id].outbox.put('<sound url="' + self.lobbySound + '" group_id="0" from="0" loop="True" />')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1601 # Now, tell everyone that we've arrived
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1602 self.send_to_all('0', self.groups[group_id].toxml('update'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1603 # this line sends a handle role message to change the players role
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1604 self.send_player_list(from_id,group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1605 #notify user about others in the room
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1606 self.return_room_roles(from_id,group_id)
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
1607 self.log_msg(("join_group", (self.groups[group_id].name, group_id, from_id)))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1608 self.handle_role("set", from_id, self.players[from_id].role, self.groups[group_id].boot_pwd, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1609 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1610 self.log_msg(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1611 thread.start_new_thread(self.registerRooms,(0,))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1612
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1613 def return_room_roles(self, from_id, group_id):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1614 for m in self.players.keys():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1615 if self.players[m].group_id == group_id:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1616 try: msg = "<role action='update' id='" + self.players[m].id + "' role='" + self.players[m].role + "' />"
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1617 except: exit()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1618 self.players[from_id].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1619
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1620 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1621 # This is pretty much the same thing as the create_group method, however,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1622 # it's much more generic whereas the create_group method is tied to a specific
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1623 # xml message. Ack! This version simply creates the groups, it does not
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1624 # send them to players. Also note, both these methods have race
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1625 # conditions written all over them. Ack! Ack!
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1626 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1627 def new_group( self, name, pwd, boot, minVersion, mapFile, messageFile, persist = 0, moderated=0 ):
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1628 group_id = str(self.next_group_id)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1629 self.next_group_id += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1630 self.groups[group_id] = game_group( group_id, name, pwd, "", boot, minVersion, mapFile, messageFile, persist )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1631 self.groups[group_id].moderated = moderated
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1632 ins = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1633 if persist !=0: ins="Persistant "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1634 lmsg = "Creating " + ins + "Group... (" + str(group_id) + ") " + str(name)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1635 self.log_msg( lmsg )
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1636 self.log_msg(("create_group", (str(name), int(group_id), pwd, 0) ))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1637
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1638 def change_group_name(self, gid, name, pid):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1639 "Change the name of a group"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1640 # Check for & in name. We want to allow this because of its common
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1641 # use in d&d games.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1642 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1643 loc = name.find("&")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1644 oldloc = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1645 while loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1646 loc = name.find("&",oldloc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1647 if loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1648 b = name[:loc]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1649 e = name[loc+1:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1650 value = b + "&amp;" + e
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1651 oldloc = loc+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1652 loc = name.find("'")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1653 oldloc = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1654 while loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1655 loc = name.find("'",oldloc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1656 if loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1657 b = name[:loc]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1658 e = name[loc+1:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1659 name = b + "&#39;" + e
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1660 oldloc = loc+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1661 loc = name.find('"')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1662 oldloc = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1663 while loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1664 loc = name.find('"',oldloc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1665 if loc > -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1666 b = name[:loc]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1667 e = name[loc+1:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1668 name = b + "&quot;" + e
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1669 oldloc = loc+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1670 oldroomname = self.groups[gid].name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1671 self.groups[gid].name = str(name)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1672 lmessage = "Room name changed to from \"" + oldroomname + "\" to \"" + name + "\""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1673 self.log_msg(lmessage + " by " + str(pid) )
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1674 self.log_msg(("update_group", (str(name), group_id, False)))
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1675
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1676 self.send_to_all('0',self.groups[gid].toxml('update'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1677 return lmessage
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1678 except: return "An error occured during rename of room!"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1679 thread.start_new_thread(self.registerRooms,(0,))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1680
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1681 def create_group(self, xml_dom, data):
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1682 #try:
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1683 from_id = xml_dom.get("from")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1684 pwd = xml_dom.get("pwd")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1685 name = xml_dom.get("name")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1686 boot_pwd = xml_dom.get("boot_pwd")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1687 minVersion = xml_dom.get("min_version")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1688 #added var reassign -- akoman
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1689 messageFile = self.defaultMessageFile
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1690
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1691 # see if passwords are allowed on this server and null password if not
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1692 if self.allow_room_passwords != 1: pwd = ""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1693
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1694 # Check for & in name. We want to allow this because of its common
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1695 # use in d&d games.
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1696
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1697 loc = name.find("&")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1698 oldloc = 0
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1699 while loc > -1:
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1700 loc = name.find("&",oldloc)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1701 if loc > -1:
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1702 b = name[:loc]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1703 e = name[loc+1:]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1704 name = b + "&amp;" + e
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1705 oldloc = loc+1
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1706 loc = name.find("'")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1707 oldloc = 0
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1708 while loc > -1:
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1709 loc = name.find("'",oldloc)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1710 if loc > -1:
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1711 b = name[:loc]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1712 e = name[loc+1:]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1713 name = b + "&#39;" + e
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1714 oldloc = loc+1
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1715 loc = name.find('"')
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1716 oldloc = 0
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1717 while loc > -1:
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1718 loc = name.find('"',oldloc)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1719 if loc > -1:
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1720 b = name[:loc]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1721 e = name[loc+1:]
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1722 name = b + "&quot;" + e
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1723 oldloc = loc+1
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1724 group_id = str(self.next_group_id)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1725 self.next_group_id += 1
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1726
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1727 self.groups[group_id] = game_group(group_id, name, pwd, "", boot_pwd, minVersion, None, messageFile)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1728 self.groups[group_id].voice[from_id]=1
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1729 self.players[from_id].outbox.put(self.groups[group_id].toxml('new'))
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1730 old_group_id = self.players[from_id].change_group(group_id, self.groups)
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1731 self.send_to_group(from_id, old_group_id, self.players[from_id].toxml('del'))
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1732 self.check_group(from_id, old_group_id)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1733 self.send_to_all(from_id,self.groups[group_id].toxml('new'))
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1734 self.send_to_all('0',self.groups[group_id].toxml('update'))
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1735 self.handle_role("set",from_id,"GM", boot_pwd, group_id)
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1736 lmsg = "Creating Group... (" + str(group_id) + ") " + str(name)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1737 self.log_msg( lmsg )
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1738 jmsg = "moving to room " + str(group_id) + "."
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1739 self.log_msg( jmsg )
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
1740 self.log_msg(("create_group", (str(name), group_id, from_id, 'No' if pwd == '' else 'Yes')))
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1741 #even creators of the room should see the HTML --akoman
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1742 #edit: jan10/03 - was placed in the except statement. Silly me.
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1743 if self.defaultMessageFile != None:
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1744 if self.defaultMessageFile[:4] == 'http':
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1745 data = urllib.urlretrieve(self.defaultMessageFile)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1746 open_msg = open(data[0])
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1747 urllib.urlcleanup()
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1748 else: open_msg = open( self.defaultMessageFile, "r" )
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1749 roomMsg = open_msg.read()
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1750 open_msg.close()
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1751 # Send the rooms message to the client no matter what
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1752 self.players[from_id].outbox.put( "<msg to='" + from_id + "' from='0' group_id='" + group_id + "' />" + roomMsg )
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1753 #except Exception, e: self.log_msg( "Exception: create_group(): " + str(e))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1754 thread.start_new_thread(self.registerRooms,(0,))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1755
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1756 def check_group(self, from_id, group_id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1757 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1758 if group_id not in self.groups: return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1759 if group_id == '0':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1760 self.send_to_all("0",self.groups[group_id].toxml('update'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1761 return #never remove lobby *sanity check*
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1762 if not self.isPersistentRoom(group_id) and self.groups[group_id].get_num_players() == 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1763 self.send_to_all("0",self.groups[group_id].toxml('del'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1764 del self.groups[group_id]
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
1765 self.log_msg(("delete_group", (group_id, from_id)))
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1766 else: self.send_to_all("0",self.groups[group_id].toxml('update'))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1767 #The register Rooms thread
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1768 thread.start_new_thread(self.registerRooms,(0,))
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1769 except Exception, e: self.log_msg(str(e))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1770
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1771 def del_player(self, id, group_id):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1772 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1773 dmsg = "Client Disconnect: (" + str(id) + ") " + str(self.players[id].name)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1774 self.players[id].disconnect()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1775 self.groups[group_id].remove_player(id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1776 del self.players[id]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1777 self.log_msg(dmsg)
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
1778 self.log_msg(("disconnect",id))
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1779 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1780 # If already registered then re-register, thereby updating the Meta
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1781 # on the number of players
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1782 # Note: Upon server shutdown, the server is first unregistered, so
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1783 # this code won't be repeated for each player being deleted.
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1784 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1785 if self.be_registered:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1786 self.register()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1787 except Exception, e: self.log_msg(str(e))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1788 self.log_msg("Explicit garbage collection shows %s undeletable items." % str(gc.collect()))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1789
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1790 def incoming_player_handler(self, xml_dom, data):
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1791 id = xml_dom.get("id")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1792 act = xml_dom.get("action")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1793 group_id = self.players[id].group_id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1794 ip = self.players[id].ip
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1795 self.log_msg("Player with IP: " + str(ip) + " joined.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1796 ServerPlugins.setPlayer(self.players[id])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1797 self.send_to_group(id,group_id,data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1798 if act=="new":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1799 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1800 self.send_player_list(id,group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1801 self.send_group_list(id)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1802 except Exception, e: traceback.print_exc()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1803 elif act=="del":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1804 self.del_player(id,group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1805 self.check_group(id, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1806 elif act=="update":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1807 self.players[id].take_dom(xml_dom)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1808 self.log_msg(("update", {"id": id,
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1809 "name": xml_dom.get("name"),
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1810 "status": xml_dom.get("status"),
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1811 "role": xml_dom.get("role"),
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1812 "ip": str(ip),
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1813 "group": xml_dom.get("group_id"),
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1814 "room": xml_dom.get("name"),
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1815 "boot": xml_dom.get("rm_boot"),
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1816 "version": xml_dom.get("version"),
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1817 "ping": xml_dom.get("time") \
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1818 }))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1819
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1820 def strip_cheat_roll(self, string):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1821 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1822 cheat_regex = re.compile('&amp;#91;(.*?)&amp;#93;')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1823 string = cheat_regex.sub( r'[ ' + self.cheat_msg + " \\1 " + self.cheat_msg + ' ]', string)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1824 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1825 return string
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1826
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1827 def strip_body_tags(self, string):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1828 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1829 bodytag_regex = re.compile('&lt;\/?body(.*?)&gt;')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1830 string = bodytag_regex.sub('', string)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1831 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1832 return string
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1833
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1834 def msgTooLong(self, length):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1835 if length > self.maxSendSize and not self.maxSendSize == 0: return True
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1836 return False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1837
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1838 def incoming_msg_handler(self,xml_dom,data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1839 xml_dom, data = ServerPlugins.preParseIncoming(xml_dom, data)
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1840 ###########################################################
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1841 to_id = xml_dom.get("to")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1842 from_id = xml_dom.get("from")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1843 group_id = xml_dom.get("group_id")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1844 end = data.find(">")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1845 msg = data[end+1:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1846
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1847 if from_id == "0" or len(from_id) == 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1848 print "WARNING!! Message received with an invalid from_id. Message dropped."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1849 return None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1850
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1851 """ check for < body to prevent someone from changing the background"""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1852 data = self.strip_body_tags(data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1853
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1854 """check for &#91 and &#93 codes which are often used to cheat with dice."""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1855 if self.players[from_id].role != "GM":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1856 data = self.strip_cheat_roll(data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1857
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1858 if group_id == '0' and self.msgTooLong(len(msg) and msg[:5] == '<chat'):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1859 self.send("Your message was too long, break it up into smaller parts please", from_id, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1860 self.log_msg('Message Blocked from Player: ' + self.players[from_id].name + ' attempting to send a message longer then ' + str(self.maxSendSize))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1861 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1862
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1863 if msg[:4] == '<map':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1864 if group_id == '0':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1865 #attempt to change lobby map. Illegal operation.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1866 self.players[from_id].self_message('The lobby map may not be altered.')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1867 elif to_id.lower() == 'all':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1868 #valid map for all players that is not the lobby.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1869 self.send_to_group(from_id,group_id,data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1870 self.groups[group_id].game_map.init_from_xml(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1871 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1872 #attempting to send map to specific individuals which is not supported.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1873 self.players[from_id].self_message('Invalid map message. Message not sent to others.')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1874
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1875 elif msg[:6] == '<boot ':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1876 self.handle_boot(from_id,to_id,group_id,msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1877
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1878 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1879 if to_id == 'all':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1880 if self.groups[group_id].moderated and not self.groups[group_id].voice.has_key(from_id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1881 self.players[from_id].self_message('This room is moderated - message not sent to others')
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1882 else: self.send_to_group(from_id,group_id,data)
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1883 else: self.players[to_id].outbox.put(data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1884 self.check_group_members(group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1885 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1886
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1887 def sound_msg_handler(self, xml_dom, data):
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1888 from_id = xml_dom.get("from")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1889 group_id = xml_dom.get("group_id")
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1890 if group_id != 0: self.send_to_group(from_id, group_id, data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1891
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1892 def plugin_msg_handler(self,xml_dom,data):
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1893 to_id = xml_dom.get("to")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1894 from_id = xml_dom.get("from")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1895 group_id = xml_dom.get("group_id")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1896 end = data.find(">")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1897 msg = data[end+1:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1898
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1899 if from_id == "0" or len(from_id) == 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1900 print "WARNING!! Message received with an invalid from_id. Message dropped."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1901 return None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1902 if to_id == 'all':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1903 if self.groups[group_id].moderated and not self.groups[group_id].voice.has_key(from_id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1904 self.players[from_id].self_message('This room is moderated - message not sent to others')
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1905 else: self.send_to_group(from_id, group_id, msg)
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1906 else: self.players[to_id].outbox.put(msg)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1907 self.check_group_members(group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1908 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1909
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1910 def handle_role(self, act, player, role, given_boot_pwd, group_id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1911 if act == "display":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1912 msg = "<msg to=\"" + player + "\" from=\"0\" group_id=\"" + group_id + "\" />"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1913 msg += "Displaying Roles<br /><br /><u>Role</u>&nbsp&nbsp&nbsp<u>Player</u><br />"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1914 keys = self.players.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1915 for m in keys:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1916 if self.players[m].group_id == group_id: msg += self.players[m].role + " " + self.players[m].name + "<br />"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1917 self.send(msg,player,group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1918 elif act == "set":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1919 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1920 actual_boot_pwd = self.groups[group_id].boot_pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1921 if self.players[player].group_id == group_id:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1922 if actual_boot_pwd == given_boot_pwd:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1923 self.log_msg( "Administrator passwords match -- changing role")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1924
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1925 # Send update role event to all
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1926 msg = "<role action=\"update\" id=\"" + player + "\" role=\"" + role + "\" />"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1927 self.send_to_group("0", group_id, msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1928 self.players[player].role = role
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1929 if (role.lower() == "gm" or role.lower() == "player"): self.groups[group_id].voice[player]=1
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1930 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1931 #tell the clients password manager the password failed -- SD 8/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1932 pm = "<password signal=\"fail\" type=\"admin\" id=\"" + group_id + "\" data=\"\"/>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1933 self.players[player].outbox.put(pm)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1934 self.log_msg( "Administrator passwords did not match")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1935 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1936 print e
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1937 print "Error executing the role change"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1938 print "due to the following exception:"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1939 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1940 print "Ignoring boot message"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1941
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1942 def handle_boot(self,from_id,to_id,group_id,msg):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1943 xml_dom = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1944 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1945 given_boot_pwd = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1946 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1947 xml_dom = XML(msg)
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
1948 given_boot_pwd = xml_dom.get("boot_pwd")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1949
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1950 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1951 print "Error in parse of boot message, Ignoring."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1952 print "Exception: "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1953 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1954
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1955 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1956 actual_boot_pwd = self.groups[group_id].boot_pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1957 server_admin_pwd = self.groups["0"].boot_pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1958 self.log_msg("Actual boot pwd = " + actual_boot_pwd)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1959 self.log_msg("Given boot pwd = " + given_boot_pwd)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1960
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1961 if self.players[to_id].group_id == group_id:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1962 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1963 ### ---CHANGES BY SNOWDOG 4/03 ---
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1964 ### added boot to lobby code.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1965 ### if boot comes from lobby dump player from the server
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1966 ### any user in-room boot will dump to lobby instead
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
1967 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1968 if given_boot_pwd == server_admin_pwd:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1969 # Send a message to everyone in the room, letting them know someone has been booted
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1970 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)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1971 self.log_msg("boot_msg:" + boot_msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1972 self.send_to_group( "0", group_id, boot_msg )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1973 time.sleep( 1 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1974 self.log_msg("Booting player " + str(to_id) + " from server.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1975
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1976 # Send delete player event to all
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1977 self.send_to_group("0",group_id,self.players[to_id].toxml("del"))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1978
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1979 # Remove the player from local data structures
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1980 self.del_player(to_id,group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1981
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1982 # Refresh the group data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1983 self.check_group(to_id, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1984
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1985 elif actual_boot_pwd == given_boot_pwd:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1986 # Send a message to everyone in the room, letting them know someone has been booted
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1987 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)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1988 self.log_msg("boot_msg:" + boot_msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1989 self.send_to_group( "0", group_id, boot_msg )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1990 time.sleep( 1 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1991
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1992 #dump player into the lobby
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1993 self.move_player(to_id,"0")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1994
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1995 # Refresh the group data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1996 self.check_group(to_id, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1997 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1998 #tell the clients password manager the password failed -- SD 8/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1999 pm = "<password signal=\"fail\" type=\"admin\" id=\"" + group_id + "\" data=\"\"/>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2000 self.players[from_id].outbox.put(pm)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2001 print "boot passwords did not match"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2002
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2003 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2004 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2005 self.log_msg('Exception in handle_boot() ' + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2006
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2007 finally:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2008 try:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2009 if xml_dom: xml_dom.unlink()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2010 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2011 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2012 self.log_msg('Exception in xml_dom.unlink() ' + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2013
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2014 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2015 # admin_kick function -- by Snowdog 4/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2016 # 9/17/05 updated to allow stealth boots (no client chat announce) -SD
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2017 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2018 def admin_kick(self, id, message="", silent = 0 ):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2019 "Kick a player from a server from the console"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2020
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2021 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2022 group_id = self.players[id].group_id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2023 # Send a message to everyone in the victim's room, letting them know someone has been booted
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2024 boot_msg = "<msg to='all' from='0' group_id='%s'/><font color='#FF0000'>Kicking '(%s) %s' from server... %s</font>" % ( group_id, id, self.players[id].name, str(message))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2025 self.log_msg("boot_msg:" + boot_msg)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2026 if (silent == 0): self.send_to_group( "0", group_id, boot_msg )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2027 time.sleep( 1 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2028
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2029 self.log_msg("kicking player " + str(id) + " from server.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2030 # Send delete player event to all
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2031 self.send_to_group("0",group_id,self.players[id].toxml("del"))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2032
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2033 # Remove the player from local data structures
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2034 self.del_player(id,group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2035
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2036 # Refresh the group data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2037 self.check_group(id, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2038
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2039 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2040 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2041 self.log_msg('Exception in admin_kick() ' + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2042
98
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2043 ### Alpha ### Addition added to assist in Un Banning users.
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2044 def admin_build_banlist(self):
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2045 validate.config_file("ban_list.xml", "default_ban_list.xml" )
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2046 configDom = parse(dir_struct["user"] + 'ban_list.xml')
98
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2047 self.ban_list = {}
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2048 for element in configDom.findall('banned'):
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2049 player = element.get('name').replace("&", "&amp;").replace("<", "&lt;").replace('"', "&quot;").replace(">", "&gt;")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2050 ip = element.get('ip')
98
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2051 self.ban_list[ip] = {}
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2052 self.ban_list[ip]['ip'] = ip
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2053 self.ban_list[ip]['name'] = element.get('name')
98
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2054 ################
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2055
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2056 def admin_banip(self, ip, name="", silent = 0):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2057 "Ban a player from a server from the console"
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
2058 self.admin_build_banlist() ### Alpha ###
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2059 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2060 self.ban_list[ip] = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2061 self.ban_list[ip]['ip'] = ip
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2062 self.ban_list[ip]['name'] = name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2063 self.saveBanList()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2064
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2065 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2066 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2067 self.log_msg('Exception in admin_banip() ' + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2068
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2069 def admin_ban(self, id, message="", silent = 0):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2070 "Ban a player from a server from the console"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2071 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2072 id = str(id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2073 group_id = self.players[id].group_id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2074 ip = self.players[id].ip
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2075 self.ban_list[ip] = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2076 self.ban_list[ip]['ip'] = ip
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2077 self.ban_list[ip]['name'] = self.players[id].name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2078 self.saveBanList()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2079
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2080 # Send a message to everyone in the victim's room, letting them know someone has been booted
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
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))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2082 self.log_msg("ban_msg:" + ban_msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2083 if (silent == 0):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2084 self.send_to_group("0", group_id, ban_msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2085 time.sleep( .1 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2086
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2087 self.log_msg("baning player " + str(id) + " from server.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2088 # Send delete player event to all
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2089 self.send_to_group("0", group_id, self.players[id].toxml("del"))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2090
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2091 # Remove the player from local data structures
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2092 self.del_player(id, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2093
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2094 # Refresh the group data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2095 self.check_group(id, group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2096
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2097 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2098 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2099 self.log_msg('Exception in admin_ban() ' + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2100
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2101 def admin_unban(self, ip):
98
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2102 self.admin_build_banlist()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2103 try:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2104 if self.ban_list.has_key(ip): del self.ban_list[ip]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2105 self.saveBanList()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2106
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2107 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2108 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2109 self.log_msg('Exception in admin_unban() ' + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2110
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2111 def admin_banlist(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2112 msg = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2113 msg.append('<table border="1"><tr><td><b>Name</b></td><td><b>IP</b></td></tr>')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2114 for ip in self.ban_list.keys():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2115 msg.append("<tr><td>")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2116 msg.append(self.ban_list[ip]['name'])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2117 msg.append("</td><td>")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2118 msg.append(self.ban_list[ip]['ip'])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2119 msg.append("</td></tr>")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2120 msg.append("</table>")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2121 return "".join(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2122
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2123 def admin_toggleSound(self):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2124 if self.sendLobbySound: self.sendLobbySound = False
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2125 else: self.sendLobbySound = True
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2126 return self.sendLobbySound
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2127
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2128 def admin_soundFile(self, file):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2129 self.lobbySound = file
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2130
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2131 def admin_setSendSize(self, sendlen):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2132 self.maxSendSize = sendlen
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2133 self.log_msg('Max Send Size was set to ' + str(sendlen))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2134
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2135 def remove_room(self, group):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2136 "removes a group and boots all occupants"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2137 #check that group id exists
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2138 if group not in self.groups:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2139 return "Invalid Room Id. Ignoring remove request."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2140
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2141 self.groups[group].persistant = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2142 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2143 keys = self.groups[group].get_player_ids()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2144 for k in keys: self.del_player(k, str(group))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2145 self.check_group("0", str(group))
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2146 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2147
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2148 def send(self,msg,player,group):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2149 self.players[player].send(msg,player,group)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2150
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2151 def send_to_all(self,from_id,data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2152 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2153 self.p_lock.acquire()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2154 keys = self.players.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2155 self.p_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2156 for k in keys:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2157 if k != from_id: self.players[k].outbox.put(data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2158 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2159 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2160 self.log_msg("Exception: send_to_all(): " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2161
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2162 def send_to_group(self, from_id, group_id, data):
58
27e58b0483e7 Fixed major bug that caused an error to spit out in Windows platforms.
sirebral
parents: 57
diff changeset
2163 #data = ("<msg to='all' from='0' group_id='"+str(group_id)+"'><font color='#FF0000'>" + data + "</font>")
27e58b0483e7 Fixed major bug that caused an error to spit out in Windows platforms.
sirebral
parents: 57
diff changeset
2164 data = ServerPlugins.postParseIncoming(data) #Function breaks here.
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2165 try:
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
2166 self.p_lock.acquire()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2167 keys = self.groups[group_id].get_player_ids()
56
c7f04d3c76f5 Major update to Server GUI. Basically makes it functional.
sirebral
parents: 0
diff changeset
2168 self.p_lock.release()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2169 for k in keys:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2170 if k != from_id: self.players[k].outbox.put(data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2171 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2172 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2173 self.log_msg("Exception: send_to_group(): " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2174
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2175 def send_player_list(self,to_id,group_id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2176 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2177 keys = self.groups[group_id].get_player_ids()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2178 for k in keys:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2179 if k != to_id:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2180 data = self.players[k].toxml('new')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2181 self.players[to_id].outbox.put(data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2182 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2183 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2184 self.log_msg("Exception: send_player_list(): " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2185
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2186 def send_group_list(self, to_id, action="new"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2187 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2188 print self.groups
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2189 for key in self.groups:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2190 xml = self.groups[key].toxml(action)
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2191 print xml, key
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2192 self.players[to_id].outbox.put(xml)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2193 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2194 self.log_msg("Exception: send_group_list(): (client #"+to_id+") : " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2195 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2196
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2197 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2198 # KICK_ALL_CLIENTS()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2199 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2200 # Convience method for booting all clients off the server at once.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2201 # used while troubleshooting mysterious "black hole" server bug
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2202 # Added by Snowdog 11-19-04
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2203 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2204 def kick_all_clients(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2205 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2206 keys = self.groups.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2207 for k in keys:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2208 pl = self.groups[k].get_player_ids()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2209 for p in pl: self.admin_kick(p,"Purged from server")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2210 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2211 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2212 self.log_msg("Exception: kick_all_clients(): " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2213
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2214 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2215 # This really has little value as it will only catch people that are hung
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2216 # on a disconnect which didn't complete. Other idle connections which are
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2217 # really dead go undeterred.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2218 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2219 # UPDATED 11-29-04: Changed remove XML send to forced admin_kick for 'dead clients'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2220 # Dead clients now removed more effeciently as soon as they are detected
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2221 # --Snowdog
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2222 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2223 def check_group_members(self, group_id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2224 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2225 keys = self.groups[group_id].get_player_ids()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2226 for k in keys:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2227 #drop any clients that are idle for more than 8 hours
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2228 #as these are likely dead clients
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2229 idlemins = self.players[k].idle_time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2230 idlemins = idlemins/60
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2231 if (idlemins > self.zombie_time): self.admin_kick(k,"Removing zombie client", self.silent_auto_kick)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2232 elif self.players[k].get_status() != MPLAY_CONNECTED:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2233 if self.players[k].check_time_out():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2234 self.log_msg("Player #" + k + " Lost connection!")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2235 self.admin_kick(k,"Removing dead client", self.silent_auto_kick)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2236 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2237 self.log_msg("Exception: check_group_members(): " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2238
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2239
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2240 def remote_admin_handler(self,xml_dom,data):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2241 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2242 # handle incoming remove server admin messages
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2243 # (allows basic administration of server from a remote client)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2244 # base message format: <admin id="" pwd="" cmd="" [data for command]>
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2245 """
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2246 if not self.allowRemoteAdmin: return
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2247 try:
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2248 pid = xml_dom.get("id")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2249 gid = ""
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2250 given_pwd = xml_dom.get("pwd")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2251 cmd = xml_dom.get("cmd")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2252 server_admin_pwd = self.groups["0"].boot_pwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2253 p_id = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2254 p_name= ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2255 p_ip = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2256
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2257 #verify that the message came from the proper ID/Socket and get IP address for logging
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2258 if self.players.has_key(pid):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2259 p_name=(self.players[pid]).name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2260 p_ip=(self.players[pid]).ip
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2261 gid=(self.players[pid]).group_id
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2262 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2263 #invalid ID.. report fraud and log
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2264 m = "Invalid Remote Server Control Message (invalid id) #" + str(pid) + " does not exist."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2265 self.log_msg( m )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2266 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2267
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2268 #log receipt of admin command added by Darren
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2269 m = "Remote Server Control Message ( "+ str(cmd) +" ) from #" + str(pid) + " (" + str(p_name) + ") " + str(p_ip)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2270 self.log_msg ( m )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2271
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2272 #check the admin password(boot password) against the supplied one in message
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2273 #dump and log any attempts to control server remotely with invalid password
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2274 if server_admin_pwd != given_pwd:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2275 #tell the clients password manager the password failed -- SD 8/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2276 pm = "<password signal=\"fail\" type=\"server\" id=\"" + str(self.players[pid].group_id) + "\" data=\"\"/>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2277 self.players[pid].outbox.put(pm)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2278 m = "Invalid Remote Server Control Message (bad password) from "
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2279 m += "#" + str(pid) + " (" + str(p_name) + ") " + str(p_ip)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2280 self.log_msg( m )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2281 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2282
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2283 #message now deemed 'authentic'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2284 #determine action to take based on command (cmd)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2285 if cmd == "list":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2286 #return player list to this user.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2287 msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + self.player_list_remote()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2288 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2289 elif cmd == "banip":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2290 ip = xml_dom.get("bip")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2291 name = xml_dom.get("bname")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2292 msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'> Banned: " + str(ip)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2293 self.admin_banip(ip, name)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2294 elif cmd == "ban":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2295 id = xml_dom.get("bid")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2296 msg = "<msg to='" + id + "' from='0' group_id='" + gid + "'> Banned!"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2297 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2298 self.admin_ban(id, "")
114
bd6ca89e4cbb Traipse Alpha 'OpenRPG' {091011-00}
sirebral
parents: 109
diff changeset
2299 ### Alpha ### and untested
bd6ca89e4cbb Traipse Alpha 'OpenRPG' {091011-00}
sirebral
parents: 109
diff changeset
2300 elif cmd == "boot":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2301 id = xml_dom.get("bid")
114
bd6ca89e4cbb Traipse Alpha 'OpenRPG' {091011-00}
sirebral
parents: 109
diff changeset
2302 msg = "<msg to='" + id + "' from='0' group_id='" + gid + "'> Booted!"
bd6ca89e4cbb Traipse Alpha 'OpenRPG' {091011-00}
sirebral
parents: 109
diff changeset
2303 self.players[pid].outbox.put(msg)
bd6ca89e4cbb Traipse Alpha 'OpenRPG' {091011-00}
sirebral
parents: 109
diff changeset
2304 self.admin_kick(id, "")
bd6ca89e4cbb Traipse Alpha 'OpenRPG' {091011-00}
sirebral
parents: 109
diff changeset
2305 #############
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2306 elif cmd == "unban":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2307 ip = xml_dom.get("ip")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2308 self.admin_unban(ip)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2309 msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'> Unbaned: " + str(ip)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2310 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2311 elif cmd == "banlist":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2312 msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + self.admin_banlist()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2313 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2314 elif cmd == "killgroup":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2315 ugid = xml_dom.get("gid")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2316 if ugid == "0":
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2317 m = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2318 m += "Cannot Remove Lobby! Remote administrator request denied!"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2319 self.players[pid].outbox.put(m)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2320 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2321 result = self.prune_room(ugid)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2322 msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + str(result)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2323 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2324
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2325 elif cmd == "message":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2326 tuid = xml_dom.get("to_id")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2327 msg = xml_dom.get("msg")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2328 pmsg = "<msg to='" + tuid + "' from='0' group_id='" + self.players[tuid].group_id + "' >" + msg
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2329 try: self.players[tuid].outbox.put(pmsg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2330 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2331 msg = "<msg to='" + pid + "' from='0' group_id='" + gid + ">Unknown Player ID: No message sent."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2332 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2333 elif cmd == "broadcast":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2334 bmsg = xml_dom.get("msg")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2335 self.broadcast(bmsg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2336 elif cmd == "killserver" and self.allowRemoteKill:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2337 #dangerous command..once server stopped it must be restarted manually
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2338 self.kill_server()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2339 elif cmd == "uptime":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2340 msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + self.uptime(1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2341 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2342 elif cmd == "help":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2343 msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2344 msg += self.AdminHelpMessage()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2345 self.players[pid].outbox.put( msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2346 elif cmd == "roompasswords":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2347 # Toggle if room passwords are allowed on this server
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2348 msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2349 msg += self.RoomPasswords()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2350 self.players[pid].outbox.put( msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2351 elif cmd == "createroom":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2352 rm_name = xml_dom.get("name")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2353 rm_pass = xml_dom.get("pass")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2354 rm_boot = xml_dom.get("boot")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2355 result = self.create_temporary_persistant_room(rm_name, rm_boot, rm_pass)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2356 msg = "<msg to='" + pid + "' from='0' group_id='" + gid + "'>" + result
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2357 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2358 elif cmd == "nameroom":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2359 rm_id = xml_dom.get("rmid")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2360 rm_name = xml_dom.get("name")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2361 result = self.change_group_name(rm_id,rm_name,pid)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2362 msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'/>" + result
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2363 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2364 elif cmd == "passwd":
122
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2365 tgid = xml_dom.get("gid")
36919b8a3ef9 Traipse Alpha 'OpenRPG' {091031-00}
sirebral
parents: 119
diff changeset
2366 npwd = xml_dom.get("pass")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2367 if tgid == "0":
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2368 msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2369 msg += "Server password may not be changed remotely!"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2370 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2371 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2372 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2373 self.groups[tgid].boot_pwd = npwd
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2374 msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>Password changed for room " + tgid
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2375 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2376 except: pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2377 elif cmd == "savemaps":
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 128
diff changeset
2378 for g in self.groups.itervalues(): g.save_map()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2379 msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'>Persistent room maps saved"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2380 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2381 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2382 msg ="<msg to='" + pid + "' from='0' group_id='" + gid + "'><i>[Unknown Remote Administration Command]</i>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2383 self.players[pid].outbox.put(msg)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2384 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2385 self.log_msg("Exception: Remote Admin Handler Error: " + str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2386 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2387
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2388 def toggleRemoteKill(self):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2389 if self.allowRemoteKill: self.allowRemoteKill = False
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2390 else: self.allowRemoteKill = True
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2391 return self.allowRemoteKill
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2392
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2393 def toggleRemoteAdmin(self):
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2394 if self.allowRemoteAdmin: self.allowRemoteAdmin = False
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2395 else: self.allowRemoteAdmin = True
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2396 return self.allowRemoteAdmin
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2397
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2398 """
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2399 # Remote Administrator Help (returns from server not client)
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2400 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2401 def AdminHelpMessage(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2402 "returns a string to be sent as a message to a remote admin"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2403 #define the help command list information
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2404 info = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2405 info.append( ['list', '/admin list', 'Displays information about rooms and players on the server'] )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2406 info.append( ['uptime', '/admin uptime', 'Information on how long server has been running'] )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2407 info.append( ['help', '/admin help', 'This help message'])
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2408 info.append( ['passwd', '/admin passwd &lt;group id&gt; &lt;new password&gt;',
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2409 'Changes a rooms bootpassword. Server(lobby) password may not be changed'])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2410 info.append( ['roompasswords', '/admin roompasswords', 'Allow/Disallow Room Passwords on the server (toggles)'])
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2411 info.append( ['message', '/admin message &lt;user id&gt; &lt;message&gt;',
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2412 'Send a message to a specific user on the server'])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2413 info.append( ['broadcast', '/admin broadcast &lt;message&gt;', 'Broadcast message to all players on server'])
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2414 info.append( ['createroom', '/admin createroom &lt;room name&gt; &lt;boot password&gt; [password]',
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2415 'Creates a temporary persistant room if possible.<i>Rooms created this way are lost on server restarts'])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2416 info.append( ['nameroom', '/admin nameroom &lt;group id&gt; &lt;new name&gt;', 'Rename a room'])
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2417 info.append( ['killgroup', '/admin killgroup &lt;room id&gt;',
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2418 'Remove a room from the server and kick everyone in it.'])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2419 if self.allowRemoteKill:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2420 info.append( ['killserver', '/admin killserver',
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2421 'Shuts down the server. <b>WARNING: Server cannot be restarted remotely via OpenRPG</b>'])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2422 info.append( ['ban', '/admin ban {playerId}', 'Ban a player from the server.'])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2423 info.append( ['unban', '/admin unban {bannedIP}', 'UnBan a player from the server.'])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2424 info.append( ['banlist', '/admin banlist', 'List Banned IPs and the Names associated with them'])
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2425 info.append( ['savemaps', '/admin savemaps',
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2426 'Save all persistent room maps that are not using the default map file.'])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2427
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2428 #define the HTML for the help display
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2429 FS = "<font size='-1'>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2430 FE = "<font>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2431 help = "<hr><B>REMOTE ADMINISTRATOR COMMANDS SUPPORTED</b><br /><br />"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2432 help += "<table border='1' cellpadding='2'>"
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2433 help += "<tr><td width='15%'><b>Command</b></td><td width='25%'><b>Format</b>"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2434 help += "</td><td width='60%'><b>Description</b></td></tr>"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2435 for n in info:
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2436 help += "<tr><td>" + FS + n[0] + FE + "</td><td><nobr>" + FS + n[1] + FE + "</nobr>"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2437 help += "</td><td>" + FS + n[2] + FE + "</td></tr>"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2438 help += "</table>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2439 return help
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2440
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2441 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2442 # Create Persistant Group -- Added by Snowdog 6/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2443 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2444 # Allows persistant groups to be created on the fly.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2445 # These persistant groups are not added to the server.ini file
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2446 # however and are lost on server restarts
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2447 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2448 # Updated function code to use per-group based persistance and
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2449 # removed references to outdated persistRoomIdThreshold
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2450 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2451
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2452 def create_temporary_persistant_room(self, roomname, bootpass, password=""):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2453 # if the room id just above the persistant room limit is available (not in use)
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2454 # then it will be assigned as a persistant room on the server
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2455 "create a temporary persistant room"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2456
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2457 group_id = str(self.next_group_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2458 self.next_group_id += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2459 self.groups[group_id] = game_group( group_id, roomname, password, "", bootpass, persist = 1 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2460 cgmsg = "Create Temporary Persistant Group: (" + str(group_id) + ") " + str(roomname)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2461 self.log_msg( cgmsg )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2462 self.send_to_all('0',self.groups[group_id].toxml('new'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2463 self.send_to_all('0',self.groups[group_id].toxml('update'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2464 return str("Persistant room created (group " + group_id + ").")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2465
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2466 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2467 # Prune Room -- Added by Snowdog 6/03
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2468 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2469 # similar to remove_room() except rooms are removed regardless
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2470 # of them being persistant or not
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2471 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2472 # Added some error checking and updated room removal for per-room
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2473 # based persistance -- Snowdog 4/04
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2474 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2475
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2476 def prune_room(self,group):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2477 #don't allow lobby to be removed
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2478 if group == '0': return "Lobby is required to exist and cannot be removed."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2479
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2480 #check that group id exists
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2481 if group not in self.groups: return "Invalid Room Id. Ignoring remove request."
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2482
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2483 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2484 keys = self.groups[group].get_player_ids()
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2485 for k in keys: self.move_player(k,'0')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2486 ins = "Room"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2487 if self.isPersistentRoom(group) : ins="Persistant room"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2488 self.send_to_all("0",self.groups[group].toxml('del'))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2489 del self.groups[group]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2490 self.log_msg(("delete_group", ('0',group)))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2491 return ins + " removed."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2492 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2493 traceback.print_exc()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2494 return "An Error occured on the server during room removal!"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2495
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2496 """
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2497 # Remote Player List -- Added by snowdog 6/03
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2498 #
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2499 # Similar to console listing except formated for web display
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2500 # in chat window on remote client
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2501 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2502 def player_list_remote(self):
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2503 """Does not work!!!""" # TaS.
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2504 COLOR1 = "'#004080'" #header/footer background color
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2505 COLOR2 = "'#DDDDDD'" #group line background color
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2506 COLOR3 = "'#FFFFFF'" #player line background color
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2507 COLOR4 = "'#FFFFFF'" #header/footer text color
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2508 PCOLOR = "'#000000'" #Player text color
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2509 LCOLOR = "'#404040'" #Lurker text color
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2510 GCOLOR = "'#FF0000'" #GM text color
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2511 SIZE = "size='-1'" #player info text size
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2512 FG = PCOLOR
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2513
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2514 "display a condensed list of players on the server"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2515 self.p_lock.acquire()
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2516 pl = "<br /><table border='0' cellpadding='1' cellspacing='2'>"
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2517 pl += "<tr><td colspan='4' bgcolor=" + COLOR1 + "><font color='" + COLOR4 + "'>"
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2518 pl += "<b>GROUP &amp; '' PLAYER LIST</b></font></td></tr>"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2519 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2520 keys = self.groups.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2521 keys.sort(id_compare)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2522 for k in keys:
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2523 debug((self.groups, self.groups[k], self.groups[k].name))
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2524 groupstring = "<tr><td bgcolor='" + COLOR2 + "' colspan='2'>"
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2525 groutstring += "<b>Group " + str(k) + ": " + self.groups[k].name + "</b>"
128
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2526 groupstring += "</td><td bgcolor=" + COLOR2 + " > <i>Password: " + self.groups[k].pwd + "</td>"
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2527 groupstring += "<td bgcolor=" + COLOR2 + " > Boot: " + self.groups[k].boot_pwd + "</i></td></tr>"
fba298d65cf8 Traipse Alpha 'OpenRPG' {091003-00}
sirebral
parents: 124
diff changeset
2528 pl += groupstring; debug(groupstring)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2529 ids = self.groups[k].get_player_ids()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2530 ids.sort(id_compare)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2531 for id in ids:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2532 if self.players.has_key(id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2533 if k != "0":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2534 if (self.players[id]).role == "GM": FG = GCOLOR
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2535 elif (self.players[id]).role == "Player": FG = PCOLOR
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2536 else: FG = LCOLOR
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2537 else: FG = PCOLOR
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2538 pl += "<tr><td bgcolor=" + COLOR3 + ">"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2539 pl += "<font color=" + FG + " " + SIZE + ">&nbsp;&nbsp;(" + (self.players[id]).id + ") "
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2540 pl += (self.players[id]).name
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2541 pl += "</font></td><td bgcolor=" + COLOR3 + " >"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2542 pl += "<font color=" + FG + " " + SIZE + ">[IP: " + (self.players[id]).ip + "]</font>"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2543 pl += "</td><td bgcolor=" + COLOR3 + " ><font color=" + FG + " " + SIZE + "> "
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2544 pl += (self.players[id]).idle_status()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2545 pl += "</font></td><td><font color=" + FG + " " + SIZE + ">"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2546 pl += (self.players[id]).connected_time_string()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2547 pl += "</font>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2548 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2549 self.groups[k].remove_player(id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2550 pl +="<tr><td colspan='4' bgcolor=" + COLOR3 + " >Bad Player Ref (#" + id + ") in group"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2551 pl+="</td></tr>"
96
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2552 pl += "<tr><td colspan='4' bgcolor=" + COLOR1 + ">"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2553 pl += "<font color=" + COLOR4 + "><b><i>Statistics: groups: " + str(len(self.groups)) + " "
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2554 pl += "players: " + str(len(self.players)) + "</i></b></font></td></tr></table>"
65c1604e7949 Traipse Alpha 'OpenRPG' {090924-00}
sirebral
parents: 90
diff changeset
2555 except Exception, e: self.log_msg(str(e))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2556 self.p_lock.release()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2557 return pl
98
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2558
95b5281e8d34 Traipse Alpha 'OpenRPG' {090925-00}
sirebral
parents: 96
diff changeset
2559 server = mplay_server()