Exemple #1
0
 def __init__(self, replay):
     self._file = open(replay)
     game_type_name = self.replay_read()
     if game_type_name in ("multiplayer", "training"):
         self.default_triggers = _MultiplayerGame.default_triggers
     game_name = self.replay_read()
     voice.alert([game_name])
     version = self.replay_read()
     mods = self.replay_read()
     if mods != config.mods:
         config.mods = mods
         reload_all()
     _compatibility_version = self.replay_read()
     if _compatibility_version != compatibility_version():
         voice.alert([1029, 4012])  # hostile sound  "version error"
         warning(
             "Version mismatch. Version should be: %s. Mods should be: %s.",
             version, mods)
     self.map = Map()
     self.map.unpack(self.replay_read())
     players = self.replay_read().split()
     self.alliances = map(int, self.replay_read().split())
     self.factions = self.replay_read().split()
     self.seed = int(self.replay_read())
     self.me = ReplayClient(players[0], self)
     self.players = [self.me]
     for x in players[1:]:
         if x in ["aggressive", "easy"]:  # the "ai_" prefix wasn't recorded
             self.players += [DummyClient(x)]
         else:
             self.players += [HalfDummyClient(x)]
             self.me.nb_humans += 1
Exemple #2
0
 def __init__(self, replay):
     self._file = open(replay)
     game_type_name = self.replay_read()
     if game_type_name in ("multiplayer", "training"):
         self.default_triggers = _MultiplayerGame.default_triggers
     game_name = self.replay_read()
     voice.alert([game_name])
     version = self.replay_read()
     mods = self.replay_read()
     res.set_mods(mods)
     _compatibility_version = self.replay_read()
     if _compatibility_version != compatibility_version():
         voice.alert([1029, 4012]) # hostile sound  "version error"
         warning("Version mismatch. Version should be: %s. Mods should be: %s.",
                 version, mods)
     campaign_path_or_packed_map = self.replay_read()
     if game_type_name == "mission" and "***" not in campaign_path_or_packed_map:
         from campaign import Campaign
         self.map = Campaign(campaign_path_or_packed_map)._get(int(self.replay_read()))
     else:
         self.map = Map()
         self.map.unpack(campaign_path_or_packed_map)
     players = self.replay_read().split()
     self.alliances = map(int, self.replay_read().split())
     self.factions = self.replay_read().split()
     self.seed = int(self.replay_read())
     self.me = ReplayClient(players[0], self)
     self.players = [self.me]
     for x in players[1:]:
         if x in ["aggressive", "easy"]: # the "ai_" prefix wasn't recorded
             self.players += [DummyClient(x)]
         else:
             self.players += [HalfDummyClient(x)]
             self.me.nb_humans += 1
Exemple #3
0
class ReplayGame(_Game):

    game_type_name = "replay" # probably useless (or maybe for stats)
    record_replay = False

    def __init__(self, replay):
        self._file = open(replay)
        game_type_name = self.replay_read()
        if game_type_name in ("multiplayer", "training"):
            self.default_triggers = _MultiplayerGame.default_triggers
        game_name = self.replay_read()
        voice.alert([game_name])
        version = self.replay_read()
        mods = self.replay_read()
        res.set_mods(mods)
        _compatibility_version = self.replay_read()
        if _compatibility_version != compatibility_version():
            voice.alert([1029, 4012]) # hostile sound  "version error"
            warning("Version mismatch. Version should be: %s. Mods should be: %s.",
                    version, mods)
        campaign_path_or_packed_map = self.replay_read()
        if game_type_name == "mission" and "***" not in campaign_path_or_packed_map:
            from campaign import Campaign
            self.map = Campaign(campaign_path_or_packed_map)._get(int(self.replay_read()))
        else:
            self.map = Map()
            self.map.unpack(campaign_path_or_packed_map)
        players = self.replay_read().split()
        self.alliances = map(int, self.replay_read().split())
        self.factions = self.replay_read().split()
        self.seed = int(self.replay_read())
        self.me = ReplayClient(players[0], self)
        self.players = [self.me]
        for x in players[1:]:
            if x in ["aggressive", "easy"]: # the "ai_" prefix wasn't recorded
                self.players += [DummyClient(x)]
            else:
                self.players += [HalfDummyClient(x)]
                self.me.nb_humans += 1

    def replay_read(self):
        s = self._file.readline()
        if s and s.endswith("\n"):
            s = s[:-1]
        return s

    def pre_run(self):
        voice.info([4316])
        voice.flush()

    def run(self):
        if getattr(self.map, "campaign", None):
            self.map.campaign.load_resources()
        try:
            _Game.run(self)
        finally:
            if getattr(self.map, "campaign", None):
                self.map.campaign.unload_resources()
Exemple #4
0
 def __init__(self, replay):
     self._file = open(replay)
     game_type_name = self.replay_read()
     if game_type_name in ("multiplayer", "training"):
         self.default_triggers = _MultiplayerGame.default_triggers
     game_name = self.replay_read()
     version = self.replay_read()
     mods = self.replay_read()
     _compatibility_version = self.replay_read()
     if _compatibility_version != compatibility_version():
         voice.alert([1029, 4012]) # hostile sound  "version error"
         warning("Version mismatch. Version should be: %s. Mods should be: %s.",
                 version, mods)
     self.map = Map()
     self.map.unpack(self.replay_read())
     players = self.replay_read().split()
     self.alliances = map(int, self.replay_read().split())
     self.races = self.replay_read().split()
     self.seed = int(self.replay_read())
     self.me = ReplayClient(players[0], self)
     self.players = [self.me]
     for x in players[1:]:
         if x in ["aggressive", "easy"]: # the "ai_" prefix wasn't recorded
             self.players += [DummyClient(x)]
         else:
             self.players += [HalfDummyClient(x)]
             self.me.nb_humans += 1
Exemple #5
0
class ReplayGame(_Game):

    game_type_name = "replay"  # probably useless (or maybe for stats)
    record_replay = False

    def __init__(self, replay):
        self._file = open(replay)
        game_type_name = self.replay_read()
        if game_type_name in ("multiplayer", "training"):
            self.default_triggers = _MultiplayerGame.default_triggers
        game_name = self.replay_read()
        voice.alert([game_name])
        version = self.replay_read()
        mods = self.replay_read()
        if mods != config.mods:
            config.mods = mods
            reload_all()
        _compatibility_version = self.replay_read()
        if _compatibility_version != compatibility_version():
            voice.alert([1029, 4012])  # hostile sound  "version error"
            warning(
                "Version mismatch. Version should be: %s. Mods should be: %s.",
                version, mods)
        self.map = Map()
        self.map.unpack(self.replay_read())
        players = self.replay_read().split()
        self.alliances = map(int, self.replay_read().split())
        self.factions = self.replay_read().split()
        self.seed = int(self.replay_read())
        self.me = ReplayClient(players[0], self)
        self.players = [self.me]
        for x in players[1:]:
            if x in ["aggressive", "easy"]:  # the "ai_" prefix wasn't recorded
                self.players += [DummyClient(x)]
            else:
                self.players += [HalfDummyClient(x)]
                self.me.nb_humans += 1

    def replay_read(self):
        s = self._file.readline()
        if s and s.endswith("\n"):
            s = s[:-1]
        return s

    def pre_run(self):
        voice.info([4316])
        voice.flush()
Exemple #6
0
class ReplayGame(_Game):

    game_type_name = "replay" # probably useless (or maybe for stats)
    record_replay = False

    def __init__(self, replay):
        self._file = open(replay)
        game_type_name = self.replay_read()
        if game_type_name in ("multiplayer", "training"):
            self.default_triggers = _MultiplayerGame.default_triggers
        game_name = self.replay_read()
        voice.alert([game_name])
        version = self.replay_read()
        mods = self.replay_read()
        if mods != config.mods:
            config.mods = mods
            reload_all()
        _compatibility_version = self.replay_read()
        if _compatibility_version != compatibility_version():
            voice.alert([1029, 4012]) # hostile sound  "version error"
            warning("Version mismatch. Version should be: %s. Mods should be: %s.",
                    version, mods)
        self.map = Map()
        self.map.unpack(self.replay_read())
        players = self.replay_read().split()
        self.alliances = map(int, self.replay_read().split())
        self.factions = self.replay_read().split()
        self.seed = int(self.replay_read())
        self.me = ReplayClient(players[0], self)
        self.players = [self.me]
        for x in players[1:]:
            if x in ["aggressive", "easy"]: # the "ai_" prefix wasn't recorded
                self.players += [DummyClient(x)]
            else:
                self.players += [HalfDummyClient(x)]
                self.me.nb_humans += 1

    def replay_read(self):
        s = self._file.readline()
        if s and s.endswith("\n"):
            s = s[:-1]
        return s

    def pre_run(self):
        voice.info([4316])
        voice.flush()
Exemple #7
0
def _add_custom_multi(w):
    from mapfile import Map
    for mp in get_all_packages_paths():
        d = os.path.join(mp, "multi")
        if os.path.isdir(d):
            for n in os.listdir(d):
                p = os.path.join(d, n)
                if os.path.normpath(p) not in (os.path.normpath(x.path) for x in w):
                    w.append(Map(p, None))
Exemple #8
0
 def __init__(self, replay):
     self._file = open(replay)
     game_type_name = self.replay_read()
     if game_type_name in ("multiplayer", "training"):
         self.default_triggers = _MultiplayerGame.default_triggers
         self.must_apply_equivalent_type = True
     game_name = self.replay_read()
     voice.alert([game_name])
     version = self.replay_read()
     mods = self.replay_read()
     res.set_mods(mods)
     _compatibility_version = self.replay_read()
     if _compatibility_version != compatibility_version():
         voice.alert(mp.BEEP + mp.VERSION_ERROR)
         warning(
             "Version mismatch. Version should be: %s. Mods should be: %s.",
             version, mods)
     campaign_path_or_packed_map = self.replay_read()
     if game_type_name == "mission" and "***" not in campaign_path_or_packed_map:
         from campaign import Campaign
         self.map = Campaign(campaign_path_or_packed_map)._get(
             int(self.replay_read()))
     else:
         self.map = Map()
         self.map.unpack(campaign_path_or_packed_map)
     players = self.replay_read().split()
     alliances = self.replay_read().split()
     factions = self.replay_read().split()
     self.seed = int(self.replay_read())
     self.me = ReplayClient(players[0], self)
     self.players = [self.me]
     for x in players[1:]:
         if x.startswith("ai_"):
             x = x[3:]
         if x in ["aggressive", "easy", "ai2"]:
             self.players += [DummyClient(x)]
         else:
             self.players += [RemoteClient(x)]
             self.me.nb_humans += 1
     for p, a, f in zip(self.players, alliances, factions):
         p.alliance = a
         p.faction = f
Exemple #9
0
 def __init__(self, replay):
     self._file = open(replay)
     game_type_name = self.replay_read()
     if game_type_name in ("multiplayer", "training"):
         self.default_triggers = _MultiplayerGame.default_triggers
         self.must_apply_equivalent_type = True
     game_name = self.replay_read()
     voice.alert([game_name])
     version = self.replay_read()
     mods = self.replay_read()
     res.set_mods(mods)
     _compatibility_version = self.replay_read()
     if _compatibility_version != compatibility_version():
         voice.alert(mp.BEEP + mp.VERSION_ERROR)
         warning("Version mismatch. Version should be: %s. Mods should be: %s.",
                 version, mods)
     campaign_path_or_packed_map = self.replay_read()
     if game_type_name == "mission" and "***" not in campaign_path_or_packed_map:
         from campaign import Campaign
         self.map = Campaign(campaign_path_or_packed_map)._get(int(self.replay_read()))
     else:
         self.map = Map()
         self.map.unpack(campaign_path_or_packed_map)
     players = self.replay_read().split()
     alliances = self.replay_read().split()
     factions = self.replay_read().split()
     self.seed = int(self.replay_read())
     self.me = ReplayClient(players[0], self)
     self.players = [self.me]
     for x in players[1:]:
         if x.startswith("ai_"):
             x = x[3:]
         if x in ["aggressive", "easy", "ai2"]:
             self.players += [DummyClient(x)]
         else:
             self.players += [RemoteClient(x)]
             self.me.nb_humans += 1
     for p, a, f in zip(self.players, alliances, factions):
         p.alliance = a
         p.faction = f
Exemple #10
0
def _add_official_multi(w):
    from mapfile import Map
    maps = [line.strip().split() for line in open("cfg/official_maps.txt")]
    for n, digest in maps:
        p = os.path.join("multi", n)
        w.append(Map(p, digest, official=True))
Exemple #11
0
 def __init__(self, p, campaign, id):
     Map.__init__(self, p)
     self.campaign = campaign
     self.id = id
Exemple #12
0
 def __init__(self, p, campaign, id):
     Map.__init__(self, p)
     self.campaign = campaign
     self.id = id
Exemple #13
0
class ReplayGame(_Game):

    game_type_name = "replay" # probably useless (or maybe for stats)
    record_replay = False

    def __init__(self, replay):
        self._file = open(replay)
        game_type_name = self.replay_read()
        if game_type_name in ("multiplayer", "training"):
            self.default_triggers = _MultiplayerGame.default_triggers
            self.must_apply_equivalent_type = True
        game_name = self.replay_read()
        voice.alert([game_name])
        version = self.replay_read()
        mods = self.replay_read()
        res.set_mods(mods)
        _compatibility_version = self.replay_read()
        if _compatibility_version != compatibility_version():
            voice.alert(mp.BEEP + mp.VERSION_ERROR)
            warning("Version mismatch. Version should be: %s. Mods should be: %s.",
                    version, mods)
        campaign_path_or_packed_map = self.replay_read()
        if game_type_name == "mission" and "***" not in campaign_path_or_packed_map:
            from campaign import Campaign
            self.map = Campaign(campaign_path_or_packed_map)._get(int(self.replay_read()))
        else:
            self.map = Map()
            self.map.unpack(campaign_path_or_packed_map)
        players = self.replay_read().split()
        alliances = self.replay_read().split()
        factions = self.replay_read().split()
        self.seed = int(self.replay_read())
        self.me = ReplayClient(players[0], self)
        self.players = [self.me]
        for x in players[1:]:
            if x.startswith("ai_"):
                x = x[3:]
            if x in ["aggressive", "easy", "ai2"]:
                self.players += [DummyClient(x)]
            else:
                self.players += [RemoteClient(x)]
                self.me.nb_humans += 1
        for p, a, f in zip(self.players, alliances, factions):
            p.alliance = a
            p.faction = f

    def replay_read(self):
        s = self._file.readline()
        if s and s.endswith("\n"):
            s = s[:-1]
        return s

    def pre_run(self):
        voice.info(mp.OBSERVE_ANOTHER_PLAYER_EXPLANATION)
        voice.flush()

    def run(self):
        if getattr(self.map, "campaign", None):
            self.map.campaign.load_resources()
        try:
            _Game.run(self)
        finally:
            if getattr(self.map, "campaign", None):
                self.map.campaign.unload_resources()
Exemple #14
0
class ReplayGame(_Game):

    game_type_name = "replay"  # probably useless (or maybe for stats)
    record_replay = False

    def __init__(self, replay):
        self._file = open(replay)
        game_type_name = self.replay_read()
        if game_type_name in ("multiplayer", "training"):
            self.default_triggers = _MultiplayerGame.default_triggers
            self.must_apply_equivalent_type = True
        game_name = self.replay_read()
        voice.alert([game_name])
        version = self.replay_read()
        mods = self.replay_read()
        res.set_mods(mods)
        _compatibility_version = self.replay_read()
        if _compatibility_version != compatibility_version():
            voice.alert(mp.BEEP + mp.VERSION_ERROR)
            warning(
                "Version mismatch. Version should be: %s. Mods should be: %s.",
                version, mods)
        campaign_path_or_packed_map = self.replay_read()
        if game_type_name == "mission" and "***" not in campaign_path_or_packed_map:
            from campaign import Campaign
            self.map = Campaign(campaign_path_or_packed_map)._get(
                int(self.replay_read()))
        else:
            self.map = Map()
            self.map.unpack(campaign_path_or_packed_map)
        players = self.replay_read().split()
        alliances = self.replay_read().split()
        factions = self.replay_read().split()
        self.seed = int(self.replay_read())
        self.me = ReplayClient(players[0], self)
        self.players = [self.me]
        for x in players[1:]:
            if x.startswith("ai_"):
                x = x[3:]
            if x in ["aggressive", "easy", "ai2"]:
                self.players += [DummyClient(x)]
            else:
                self.players += [RemoteClient(x)]
                self.me.nb_humans += 1
        for p, a, f in zip(self.players, alliances, factions):
            p.alliance = a
            p.faction = f

    def replay_read(self):
        s = self._file.readline()
        if s and s.endswith("\n"):
            s = s[:-1]
        return s

    def pre_run(self):
        voice.info(mp.OBSERVE_ANOTHER_PLAYER_EXPLANATION)
        voice.flush()

    def run(self):
        if getattr(self.map, "campaign", None):
            self.map.campaign.load_resources()
        try:
            _Game.run(self)
        finally:
            if getattr(self.map, "campaign", None):
                self.map.campaign.unload_resources()