Ejemplo n.º 1
0
    def DownloadMap(self, mapName, current=None):
        self.refresh_action()

        self.report("%s wants to download the map, %s." % (self.name, mapName))
        map = Map_Manager.get_manager().get_map_by_filename(mapName)
        if not map:
            raise BadInformationException("That map does not exist.")

        vtank_map = VTankObject.Map()
        tiles = []
        for tile in map.tiles:
            tiles.append(
                VTankObject.Tile(tile.tile_id, tile.object_id, tile.event_id,
                                 tile.collision, tile.height, tile.type,
                                 tile.effect))

        vtank_map.version = map.version
        vtank_map.title = map.get_title()
        vtank_map.filename = mapName
        vtank_map.width = map.map_width
        vtank_map.height = map.map_height
        vtank_map.tileData = tiles
        vtank_map.supportedGameModes = map.game_modes

        return vtank_map
Ejemplo n.º 2
0
 def update_game_server_maps(self):
     """
     Get the list of game play servers and notify them of the new map list.
     """
     clients = self.client_tracker.get_everyone();
     for client in clients.values():
         if client.get_type() == THEATRE_CLIENT_TYPE:
             c = client.get();
             c.get_callback().UpdateMapList(Map_Manager.get_manager().get_map_list());
Ejemplo n.º 3
0
 def update_game_server_maps(self):
     """
     Get the list of game play servers and notify them of the new map list.
     """
     clients = self.client_tracker.get_everyone()
     for client in clients.values():
         if client.get_type() == THEATRE_CLIENT_TYPE:
             c = client.get()
             c.get_callback().UpdateMapList(
                 Map_Manager.get_manager().get_map_list())
Ejemplo n.º 4
0
    def Join(self, servername, secret, port, usingGlacier2, 
             glacier2Host, glacier2Port, client, current=None):
        if client == None:
            # Client callback class cannot be null.
            raise BadInformationException("No callback is set.");
        
        host = Utils.extract_remote_addr(current);
        allowed = self.config.allow_unapproved_game_servers;
        
        self.report("Attempted connection from a game server from %s: %s" % (str(host), servername));
        
        approved = True;
        if host not in self.config.approved:
            # Unapproved game server.
            approved = False;
            
        if not allowed:
            # Unapproved game servers are not allowed.
            Log.quick_log("Server %s tried to log in as a game server but is not allowed." % servername);
            raise PermissionDeniedException("Unauthorized login attempt.");
        
        # Compare the secrets.
        if secret != self.config.server_secret:
            # Secret does not match.
            Log.quick_log("Server %s tried to log in as a game server but had a bad secret." % servername);
            raise PermissionDeniedException("Bad secret.");
        
        session = MTGSession(servername, port, approved, usingGlacier2, glacier2Host, glacier2Port, 
                             client, current.con.toString(), self.reporter);
                             
        ice_object = current.adapter.addWithUUID(session);
        id = ice_object.ice_getIdentity();
        
        session.set_id(id);
        
        self.add(id, Client(THEATRE_CLIENT_TYPE, session, servername));
        
        self.report("%s (%s) logged in." % (session, THEATRE_CLIENT_TYPE));
        Log.quick_log("%s joined as a game server." % servername);
        
        client.UpdateMapList(Map_Manager.get_manager().get_map_list());
        client.UpdateUtilities(Equipment_Manager.get_manager().get_utilities_list());
        
        return MainToGameSession.MTGSessionPrx.uncheckedCast(ice_object);
    
	def HealthMonitorLogin(username, password, current=None):
		if not password:
            raise BadInformationException("Bad username or password.");
			
		self.helper_validate_name(username);
		
		ice_object = current.adapter.addWithUUID(session);
Ejemplo n.º 5
0
 def UploadMap(self, map, current=None):
     self.report("%s wants to upload the map, %s." % (self.name, map.filename));
     # Validate.
     if not map.title:
         raise BadInformationException("Map is corrupted: Title cannot be blank.");
     
     if map.width <= 0 or map.height <= 0:
         raise BadInformationException("Map is corrupted: width/height <= 0.");
     
     if not len(map.tileData):
         raise BadInformationException("Map is corrupted: has no tiles!");
     
     map_obj = _Map.Map(self.reporter);
     map_obj.create_from_ice_object(map);
     
     if not Map_Manager.get_manager().save(map.filename, map_obj):
         raise BadInformationException("Database upload failed: error unknown.");
Ejemplo n.º 6
0
 def DownloadMap(self, mapName, current=None):
     self.report("%s wants to download the map, %s." % (self.name, mapName));
     map = Map_Manager.get_manager().get_map_by_filename(mapName);
     if not map:
         raise BadInformationException("That map does not exist.");
     
     vtank_map = Map();
     tiles = [];
     for tile in map.tiles:
         tiles.append(Tile(tile.tile_id, tile.object_id, tile.event_id, tile.collision,
                           tile.height, tile.type, tile.effect));
     
     vtank_map.title = map.get_title();
     vtank_map.filename = mapName;
     vtank_map.width = map.map_width;
     vtank_map.height = map.map_height;
     vtank_map.tileData = tiles;
     vtank_map.supportedGameModes = map.game_modes;
     
     return vtank_map;
Ejemplo n.º 7
0
    def UploadMap(self, map, current=None):
        self.report("%s wants to upload the map, %s." %
                    (self.name, map.filename))
        # Validate.
        if not map.title:
            raise BadInformationException(
                "Map is corrupted: Title cannot be blank.")

        if map.width <= 0 or map.height <= 0:
            raise BadInformationException(
                "Map is corrupted: width/height <= 0.")

        if not len(map.tileData):
            raise BadInformationException("Map is corrupted: has no tiles!")

        map_obj = _Map.Map(self.reporter)
        map_obj.create_from_ice_object(map)

        if not Map_Manager.get_manager().save(map.filename, map_obj):
            raise BadInformationException(
                "Database upload failed: error unknown.")
Ejemplo n.º 8
0
    def HashIsValid(self, mapFileName, hash, current=None):
        self.refresh_action()

        return Map_Manager.get_manager().check_hash(mapFileName, hash)
Ejemplo n.º 9
0
    def GetMapList(self, current=None):
        self.refresh_action()

        return Map_Manager.get_manager().get_map_list()
Ejemplo n.º 10
0
 def HashIsValid(self, mapFileName, hash, current=None):
     self.refresh_action();
     
     return Map_Manager.get_manager().check_hash(mapFileName, hash);
Ejemplo n.º 11
0
 def RemoveMap(self, mapName, current=None):
     if not Map_Manager.get_manager().delete(mapName):
         raise BadInformationException("Map does not exist.");
Ejemplo n.º 12
0
 def GetMapList(self, current=None):
     return Map_Manager.get_manager().get_map_list();
Ejemplo n.º 13
0
 def GetMapList(self, current=None):
     return Map_Manager.get_manager().get_map_list()
Ejemplo n.º 14
0
 def RemoveMap(self, mapName, current=None):
     if not Map_Manager.get_manager().delete(mapName):
         raise BadInformationException("Map does not exist.")
Ejemplo n.º 15
0
 def GetMapList(self, current=None):
     self.refresh_action();
     
     return Map_Manager.get_manager().get_map_list();