예제 #1
0
def _parse_formation(reader: ReplayReader) -> TYPE_FORMATION:
    formation = reader.read_int()
    if formation != -1:
        w = reader.read_float()
        position = _read_vector(reader)
        scale = reader.read_float()
        return {"w": w, "position": position, "scale": scale}
    return None
예제 #2
0
def command_set_command_cells(reader: ReplayReader) -> Dict[str, Union[str, int, TYPE_LUA]]:
    command_id = reader.read_int()
    cells = reader.read_lua()
    if cells:
        reader.read(1)
    vector = (reader.read_float(), reader.read_float(), reader.read_float())
    return {"type": "set_command_cells",
            "command_id": command_id,
            "cells": cells,
            "vector": vector}
예제 #3
0
    def __init__(self, reader: ReplayReader) -> None:
        self.version = reader.read_string()
        reader.read(3)
        self.replay_version, self.map_name = reader.read_string().split(
            "\r\n", 1)
        reader.read(4)

        mods_size = reader.read_int()
        self.mods = reader.read_lua()
        scenario_size = reader.read_int()
        self.scenario = reader.read_lua()
        sources_number = reader.read_byte()

        self.players = {}
        for i in range(sources_number):
            name = reader.read_string()
            player_id = reader.read_int()
            self.players[name] = str(player_id)

        self.cheats_enabled = reader.read_bool()
        self.numbers_of_armies = reader.read_byte()

        self.armies = {}
        for i in range(self.numbers_of_armies):
            player_data_size = reader.read_int()
            player_data = reader.read_lua()
            player_source = reader.read_byte()
            self.armies[player_source] = player_data

            if player_source != 255:
                reader.read(1)

        self.random_seed = reader.read_float()
예제 #4
0
def _read_vector(reader: ReplayReader) -> TYPE_VECTOR:
    return reader.read_float(), reader.read_float(), reader.read_float()