Exemple #1
0
  def _define_methods(self):
    d = self._define_proxy_method
    r = self._control.server

    d(frostbite.commands.Version, r.version, filter=lambda r: r.split(" "))
    d(frostbite.commands.ServerInfo, r.info, filter=lambda i: ServerState.from_dict(i).to_packet_array())
    d(frostbite.commands.AdminListPlayers, r.list_all_players, filter=lambda p: PlayerCollection.from_dict(p).to_packet_array())
    d(frostbite.commands.FrostbiteVariable, r.get_variable, filter=lambda v: [v], extract_args=lambda m:[m.words[0]])
    d(frostbite.commands.MapListList, r.list_maps, filter=lambda m: MapList.from_dict(m).to_packet_array())
    d(frostbite.commands.MapListGetMapIndices, r.get_map_indices)
    d(frostbite.commands.MapListRestartRound, r.restart_round)
    d(frostbite.commands.MapListRunNextRound, r.next_round)
    d(frostbite.commands.MapListEndRound, r.end_round, extract_args=lambda m:[m.winning_team])
    d(frostbite.commands.AdminSay, r.say, extract_args=lambda m:[m.message])

    for var in frostbite.commands.variable_types:
      type = frostbite.commands.variable_types[var]
      self._command_to_method[type] = self._command_to_method[frostbite.commands.FrostbiteVariable]
Exemple #2
0
                    doc="Asks the server to list the reserved slots.")
define_message_type("mapList.load",
                    doc="Asks the server to load the map list from disk.")
define_message_type("mapList.save",
                    doc="Asks the server to save the map list to disk.")
define_message_type("mapList.add",
                    args=["map_name", "gamemode", "rounds", "index"],
                    doc="Asks the server to add a map to the map list.")
define_message_type("mapList.remove",
                    args=["index"],
                    doc="Asks the server to delete a map from the map list.")
define_message_type("mapList.clear",
                    doc="Asks the server to clear the map list.")
define_message_type(
    "mapList.list",
    response=lambda s, p, c: MapList.from_packet_array(p.words[1:]),
    doc="Asks the server to list the map list.")
define_message_type(
    "mapList.setNextMapIndex",
    args=["index"],
    doc=
    "Asks the server to set the next map to the specified index in the map list."
)
define_message_type("mapList.getMapIndices",
                    response=lambda s, p, c: [p.words[1], p.words[2]],
                    doc="Asks the server for the current and next map indices")
define_message_type("mapList.runNextRound",
                    doc="Asks the server to run the next round immediately.")
define_message_type("mapList.restartRound",
                    doc="Asks the server to restart the round immediately.")
define_message_type(
Exemple #3
0
define_message_type("banList.add", args=["id_type", "id", "timeout", "reason"], doc="Asks the server to add someone to the ban list.")
define_message_type("banList.remove", args=["id_type", "id"], doc="Asks the server to remove someone from the ban list.")
define_message_type("banList.clear", doc="Asks the server to clear the banlist.")
define_message_type("banList.list", args=["offset"], response=_parse_ban_list, doc="Asks the server for the ban list.")
define_message_type("reservedSlotsList.load", doc="Asks the server to load the reserved slots list from disk.")
define_message_type("reservedSlotsList.save", doc="Asks the server to save the reserved slots list to disk.")
define_message_type("reservedSlotsList.add", args=["name"], doc="Asks the server to add someone to the reserved slots list.")
define_message_type("reservedSlotsList.remove", args=["name"], doc="Asks the server to remove someone from the reserved slots list.")
define_message_type("reservedSlotsList.clear", doc="Clears the reserved slotslist.")
define_message_type("reservedSlotsList.list", doc="Asks the server to list the reserved slots.")
define_message_type("mapList.load", doc="Asks the server to load the map list from disk.")
define_message_type("mapList.save", doc="Asks the server to save the map list to disk.")
define_message_type("mapList.add", args=["map_name", "gamemode", "rounds", "index"], doc="Asks the server to add a map to the map list.")
define_message_type("mapList.remove", args=["index"], doc="Asks the server to delete a map from the map list.")
define_message_type("mapList.clear", doc="Asks the server to clear the map list.")
define_message_type("mapList.list", response=lambda s,p,c: MapList.from_packet_array(p.words[1:]), doc="Asks the server to list the map list.")
define_message_type("mapList.setNextMapIndex", args=["index"], doc="Asks the server to set the next map to the specified index in the map list.")
define_message_type("mapList.getMapIndices", response=lambda s,p,c: [p.words[1], p.words[2]], doc="Asks the server for the current and next map indices")
define_message_type("mapList.runNextRound", doc="Asks the server to run the next round immediately.")
define_message_type("mapList.restartRound", doc="Asks the server to restart the round immediately.")
define_message_type("mapList.endRound", args=["winning_team"], doc="Asks the server to end the current round immediately.")

define_variable_type("vars.ranked")
define_variable_type("vars.serverName")
define_variable_type("vars.gamePassword")
define_variable_type("vars.autoBalance")
define_variable_type("vars.friendlyFire")
define_variable_type("vars.maxPlayers")
define_variable_type("vars.killCam")
define_variable_type("vars.killRotation")
define_variable_type("vars.miniMap")
Exemple #4
0
  def _handle_command(self, server, seq, command):
    if isinstance(command, frostbite.commands.LoginHashed):
      if command.password is None:
        server.send(seq, frostbite.commands.ResponsePacket("OK", "1234"))
      else:
        server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.Version):
      server.send(seq, frostbite.commands.ResponsePacket("OK", "TestServer 1"))
    elif isinstance(command, frostbite.commands.ServerInfo):
      state = ServerState("testServer", 1, 16, "testmode0", "MP_Test", 1, 2, 2, [200, 200], 200, "", True, True, False, "1234", "200", "", "1.0", False, "US", "SF", "US")
      server.send(seq, frostbite.commands.ResponsePacket("OK", *state.to_packet_array()))
    elif isinstance(command, frostbite.commands.MapListRunNextRound):
      self.last_command = "next_round"
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.MapListRestartRound):
      self.last_command = "restart_round"
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.MapListEndRound):
      self.last_command = "end_round %s" % command.winning_team
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.MapListList):
      maps = MapList([Map("MP_Test1", "TestMode0", 2), Map("MP_Test2", "TestMode1", 5)])
      server.send(seq, frostbite.commands.ResponsePacket("OK", *maps.to_packet_array()))
    elif isinstance(command, frostbite.commands.MapListGetMapIndices):
      server.send(seq, frostbite.commands.ResponsePacket("OK", "0", "1"))
    elif isinstance(command, frostbite.commands.MapListAdd):
      self.last_command = "add_map %s %s %s" % (command.map_name, command.gamemode, command.rounds)
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.MapListSetNextMapIndex):
      self.last_command = "set_next_map %s" % command.index
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.MapListClear):
      self.last_command = "clear_map_list"
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.MapListSave):
      self.last_command = "save_map_list"
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.MapListRemove):
      self.last_command = "remove_map %s" % command.index
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.AdminListPlayers):
      list = PlayerCollection(["field1", "field2", "field3"], [["what", "the", "crap"]])
      server.send(seq, frostbite.commands.ResponsePacket("OK", *list.to_packet_array()))
    elif isinstance(command, frostbite.commands.AdminKickPlayer):
      self.last_command = "kick_player %s %s" % (command.player_name, command.reason)
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.AdminKillPlayer):
      self.last_command = "kill_player %s" % (command.player_name)
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.BanListAdd):
      self.last_command = "add_ban %s %s %s %s" % (command.id_type, command.id, command.timeout, command.reason)
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    elif isinstance(command, frostbite.commands.BanListList):
      list = [Ban("guid", "random-id", "forever", "100", "no reason")]
      flat = []
      for b in list:
        flat.extend(b.to_packet_array())

      server.send(seq, frostbite.commands.ResponsePacket("OK", len(list), *flat))
    elif isinstance(command, frostbite.commands.AdminSay):
      self.last_command = "say %s %s" % (command.scope, command.message)
      server.send(seq, frostbite.commands.ResponsePacket("OK"))
    else:
      server.send(seq, frostbite.commands.ResponsePacket("OK"))