Skip to content

map

Data structures generated from the eo-protocol XML specification.

Warning
  • This subpackage should not be directly imported.
  • Instead, import eolib.protocol.map (or the top-level eolib).

MapWarpRowTile

A single tile in a row of warp entities

Source code in src/eolib/protocol/_generated/map/map_warp_row_tile.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class MapWarpRowTile:
    """
    A single tile in a row of warp entities
    """
    _byte_size: int = 0
    _x: int = None # type: ignore [assignment]
    _warp: MapWarp = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def x(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._x

    @x.setter
    def x(self, x: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._x = x

    @property
    def warp(self) -> MapWarp:
        return self._warp

    @warp.setter
    def warp(self, warp: MapWarp) -> None:
        self._warp = warp

    @staticmethod
    def serialize(writer: EoWriter, data: "MapWarpRowTile") -> None:
        """
        Serializes an instance of `MapWarpRowTile` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapWarpRowTile): The data to serialize.
        """
        if data._x is None:
            raise SerializationError("x must be provided.")
        writer.add_char(data._x)
        if data._warp is None:
            raise SerializationError("warp must be provided.")
        MapWarp.serialize(writer, data._warp)

    @staticmethod
    def deserialize(reader: EoReader) -> "MapWarpRowTile":
        """
        Deserializes an instance of `MapWarpRowTile` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapWarpRowTile: The data to serialize.
        """
        data: MapWarpRowTile = MapWarpRowTile()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._x = reader.get_char()
            data._warp = MapWarp.deserialize(reader)
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapWarpRowTile(byte_size={repr(self._byte_size)}, x={repr(self._x)}, warp={repr(self._warp)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

x: int property writable

Note
  • Value range is 0-252.

warp: MapWarp property writable

serialize(writer, data) staticmethod

Serializes an instance of MapWarpRowTile to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapWarpRowTile

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_warp_row_tile.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@staticmethod
def serialize(writer: EoWriter, data: "MapWarpRowTile") -> None:
    """
    Serializes an instance of `MapWarpRowTile` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapWarpRowTile): The data to serialize.
    """
    if data._x is None:
        raise SerializationError("x must be provided.")
    writer.add_char(data._x)
    if data._warp is None:
        raise SerializationError("warp must be provided.")
    MapWarp.serialize(writer, data._warp)

deserialize(reader) staticmethod

Deserializes an instance of MapWarpRowTile from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapWarpRowTile MapWarpRowTile

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_warp_row_tile.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@staticmethod
def deserialize(reader: EoReader) -> "MapWarpRowTile":
    """
    Deserializes an instance of `MapWarpRowTile` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapWarpRowTile: The data to serialize.
    """
    data: MapWarpRowTile = MapWarpRowTile()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._x = reader.get_char()
        data._warp = MapWarp.deserialize(reader)
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapWarp

Warp EMF entity

Source code in src/eolib/protocol/_generated/map/map_warp.py
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
class MapWarp:
    """
    Warp EMF entity
    """
    _byte_size: int = 0
    _destination_map: int = None # type: ignore [assignment]
    _destination_coords: Coords = None # type: ignore [assignment]
    _level_required: int = None # type: ignore [assignment]
    _door: int = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def destination_map(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._destination_map

    @destination_map.setter
    def destination_map(self, destination_map: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._destination_map = destination_map

    @property
    def destination_coords(self) -> Coords:
        return self._destination_coords

    @destination_coords.setter
    def destination_coords(self, destination_coords: Coords) -> None:
        self._destination_coords = destination_coords

    @property
    def level_required(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._level_required

    @level_required.setter
    def level_required(self, level_required: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._level_required = level_required

    @property
    def door(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._door

    @door.setter
    def door(self, door: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._door = door

    @staticmethod
    def serialize(writer: EoWriter, data: "MapWarp") -> None:
        """
        Serializes an instance of `MapWarp` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapWarp): The data to serialize.
        """
        if data._destination_map is None:
            raise SerializationError("destination_map must be provided.")
        writer.add_short(data._destination_map)
        if data._destination_coords is None:
            raise SerializationError("destination_coords must be provided.")
        Coords.serialize(writer, data._destination_coords)
        if data._level_required is None:
            raise SerializationError("level_required must be provided.")
        writer.add_char(data._level_required)
        if data._door is None:
            raise SerializationError("door must be provided.")
        writer.add_short(data._door)

    @staticmethod
    def deserialize(reader: EoReader) -> "MapWarp":
        """
        Deserializes an instance of `MapWarp` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapWarp: The data to serialize.
        """
        data: MapWarp = MapWarp()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._destination_map = reader.get_short()
            data._destination_coords = Coords.deserialize(reader)
            data._level_required = reader.get_char()
            data._door = reader.get_short()
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapWarp(byte_size={repr(self._byte_size)}, destination_map={repr(self._destination_map)}, destination_coords={repr(self._destination_coords)}, level_required={repr(self._level_required)}, door={repr(self._door)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

destination_map: int property writable

Note
  • Value range is 0-64008.

destination_coords: Coords property writable

level_required: int property writable

Note
  • Value range is 0-252.

door: int property writable

Note
  • Value range is 0-64008.

serialize(writer, data) staticmethod

Serializes an instance of MapWarp to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapWarp

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_warp.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
@staticmethod
def serialize(writer: EoWriter, data: "MapWarp") -> None:
    """
    Serializes an instance of `MapWarp` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapWarp): The data to serialize.
    """
    if data._destination_map is None:
        raise SerializationError("destination_map must be provided.")
    writer.add_short(data._destination_map)
    if data._destination_coords is None:
        raise SerializationError("destination_coords must be provided.")
    Coords.serialize(writer, data._destination_coords)
    if data._level_required is None:
        raise SerializationError("level_required must be provided.")
    writer.add_char(data._level_required)
    if data._door is None:
        raise SerializationError("door must be provided.")
    writer.add_short(data._door)

deserialize(reader) staticmethod

Deserializes an instance of MapWarp from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapWarp MapWarp

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_warp.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
@staticmethod
def deserialize(reader: EoReader) -> "MapWarp":
    """
    Deserializes an instance of `MapWarp` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapWarp: The data to serialize.
    """
    data: MapWarp = MapWarp()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._destination_map = reader.get_short()
        data._destination_coords = Coords.deserialize(reader)
        data._level_required = reader.get_char()
        data._door = reader.get_short()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapTileSpecRowTile

A single tile in a row of tilespecs

Source code in src/eolib/protocol/_generated/map/map_tile_spec_row_tile.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class MapTileSpecRowTile:
    """
    A single tile in a row of tilespecs
    """
    _byte_size: int = 0
    _x: int = None # type: ignore [assignment]
    _tile_spec: MapTileSpec = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def x(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._x

    @x.setter
    def x(self, x: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._x = x

    @property
    def tile_spec(self) -> MapTileSpec:
        return self._tile_spec

    @tile_spec.setter
    def tile_spec(self, tile_spec: MapTileSpec) -> None:
        self._tile_spec = tile_spec

    @staticmethod
    def serialize(writer: EoWriter, data: "MapTileSpecRowTile") -> None:
        """
        Serializes an instance of `MapTileSpecRowTile` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapTileSpecRowTile): The data to serialize.
        """
        if data._x is None:
            raise SerializationError("x must be provided.")
        writer.add_char(data._x)
        if data._tile_spec is None:
            raise SerializationError("tile_spec must be provided.")
        writer.add_char(int(data._tile_spec))

    @staticmethod
    def deserialize(reader: EoReader) -> "MapTileSpecRowTile":
        """
        Deserializes an instance of `MapTileSpecRowTile` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapTileSpecRowTile: The data to serialize.
        """
        data: MapTileSpecRowTile = MapTileSpecRowTile()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._x = reader.get_char()
            data._tile_spec = MapTileSpec(reader.get_char())
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapTileSpecRowTile(byte_size={repr(self._byte_size)}, x={repr(self._x)}, tile_spec={repr(self._tile_spec)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

x: int property writable

Note
  • Value range is 0-252.

tile_spec: MapTileSpec property writable

serialize(writer, data) staticmethod

Serializes an instance of MapTileSpecRowTile to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapTileSpecRowTile

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_tile_spec_row_tile.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@staticmethod
def serialize(writer: EoWriter, data: "MapTileSpecRowTile") -> None:
    """
    Serializes an instance of `MapTileSpecRowTile` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapTileSpecRowTile): The data to serialize.
    """
    if data._x is None:
        raise SerializationError("x must be provided.")
    writer.add_char(data._x)
    if data._tile_spec is None:
        raise SerializationError("tile_spec must be provided.")
    writer.add_char(int(data._tile_spec))

deserialize(reader) staticmethod

Deserializes an instance of MapTileSpecRowTile from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapTileSpecRowTile MapTileSpecRowTile

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_tile_spec_row_tile.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@staticmethod
def deserialize(reader: EoReader) -> "MapTileSpecRowTile":
    """
    Deserializes an instance of `MapTileSpecRowTile` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapTileSpecRowTile: The data to serialize.
    """
    data: MapTileSpecRowTile = MapTileSpecRowTile()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._x = reader.get_char()
        data._tile_spec = MapTileSpec(reader.get_char())
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapTileSpec

Bases: IntEnum

The type of a tile on a map

Source code in src/eolib/protocol/_generated/map/map_tile_spec.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class MapTileSpec(IntEnum, metaclass=ProtocolEnumMeta):
    """
    The type of a tile on a map
    """
    Wall = 0
    ChairDown = 1
    ChairLeft = 2
    ChairRight = 3
    ChairUp = 4
    ChairDownRight = 5
    ChairUpLeft = 6
    ChairAll = 7
    Reserved8 = 8
    Chest = 9
    Reserved10 = 10
    Reserved11 = 11
    Reserved12 = 12
    Reserved13 = 13
    Reserved14 = 14
    Reserved15 = 15
    BankVault = 16
    NpcBoundary = 17
    Edge = 18
    FakeWall = 19
    Board1 = 20
    Board2 = 21
    Board3 = 22
    Board4 = 23
    Board5 = 24
    Board6 = 25
    Board7 = 26
    Board8 = 27
    Jukebox = 28
    Jump = 29
    Water = 30
    Reserved31 = 31
    Arena = 32
    AmbientSource = 33
    TimedSpikes = 34
    Spikes = 35
    HiddenSpikes = 36

Wall = 0 class-attribute instance-attribute

ChairDown = 1 class-attribute instance-attribute

ChairLeft = 2 class-attribute instance-attribute

ChairRight = 3 class-attribute instance-attribute

ChairUp = 4 class-attribute instance-attribute

ChairDownRight = 5 class-attribute instance-attribute

ChairUpLeft = 6 class-attribute instance-attribute

ChairAll = 7 class-attribute instance-attribute

Reserved8 = 8 class-attribute instance-attribute

Chest = 9 class-attribute instance-attribute

Reserved10 = 10 class-attribute instance-attribute

Reserved11 = 11 class-attribute instance-attribute

Reserved12 = 12 class-attribute instance-attribute

Reserved13 = 13 class-attribute instance-attribute

Reserved14 = 14 class-attribute instance-attribute

Reserved15 = 15 class-attribute instance-attribute

BankVault = 16 class-attribute instance-attribute

NpcBoundary = 17 class-attribute instance-attribute

Edge = 18 class-attribute instance-attribute

FakeWall = 19 class-attribute instance-attribute

Board1 = 20 class-attribute instance-attribute

Board2 = 21 class-attribute instance-attribute

Board3 = 22 class-attribute instance-attribute

Board4 = 23 class-attribute instance-attribute

Board5 = 24 class-attribute instance-attribute

Board6 = 25 class-attribute instance-attribute

Board7 = 26 class-attribute instance-attribute

Board8 = 27 class-attribute instance-attribute

Jukebox = 28 class-attribute instance-attribute

Jump = 29 class-attribute instance-attribute

Water = 30 class-attribute instance-attribute

Reserved31 = 31 class-attribute instance-attribute

Arena = 32 class-attribute instance-attribute

AmbientSource = 33 class-attribute instance-attribute

TimedSpikes = 34 class-attribute instance-attribute

Spikes = 35 class-attribute instance-attribute

HiddenSpikes = 36 class-attribute instance-attribute

ProtocolEnumMeta

Bases: EnumMeta

Source code in src/eolib/protocol/protocol_enum_meta.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class ProtocolEnumMeta(EnumMeta):
    def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
        if names is not None:
            return super().__call__(
                value, names=names, module=module, qualname=qualname, type=type, start=start
            )
        try:
            return super().__call__(
                value, names=names, module=module, qualname=qualname, type=type, start=start
            )
        except ValueError:
            unrecognized = int.__new__(cls, value)
            unrecognized._name_ = f"Unrecognized({int(value)})"
            unrecognized._value_ = value
            return unrecognized

__call__(value, names=None, *, module=None, qualname=None, type=None, start=1)

Source code in src/eolib/protocol/protocol_enum_meta.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
    if names is not None:
        return super().__call__(
            value, names=names, module=module, qualname=qualname, type=type, start=start
        )
    try:
        return super().__call__(
            value, names=names, module=module, qualname=qualname, type=type, start=start
        )
    except ValueError:
        unrecognized = int.__new__(cls, value)
        unrecognized._name_ = f"Unrecognized({int(value)})"
        unrecognized._value_ = value
        return unrecognized

Coords

Map coordinates

Source code in src/eolib/protocol/_generated/coords.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
class Coords:
    """
    Map coordinates
    """
    _byte_size: int = 0
    _x: int = None # type: ignore [assignment]
    _y: int = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def x(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._x

    @x.setter
    def x(self, x: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._x = x

    @property
    def y(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._y

    @y.setter
    def y(self, y: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._y = y

    @staticmethod
    def serialize(writer: EoWriter, data: "Coords") -> None:
        """
        Serializes an instance of `Coords` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (Coords): The data to serialize.
        """
        if data._x is None:
            raise SerializationError("x must be provided.")
        writer.add_char(data._x)
        if data._y is None:
            raise SerializationError("y must be provided.")
        writer.add_char(data._y)

    @staticmethod
    def deserialize(reader: EoReader) -> "Coords":
        """
        Deserializes an instance of `Coords` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            Coords: The data to serialize.
        """
        data: Coords = Coords()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._x = reader.get_char()
            data._y = reader.get_char()
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"Coords(byte_size={repr(self._byte_size)}, x={repr(self._x)}, y={repr(self._y)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

x: int property writable

Note
  • Value range is 0-252.

y: int property writable

Note
  • Value range is 0-252.

serialize(writer, data) staticmethod

Serializes an instance of Coords to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data Coords

The data to serialize.

required
Source code in src/eolib/protocol/_generated/coords.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@staticmethod
def serialize(writer: EoWriter, data: "Coords") -> None:
    """
    Serializes an instance of `Coords` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (Coords): The data to serialize.
    """
    if data._x is None:
        raise SerializationError("x must be provided.")
    writer.add_char(data._x)
    if data._y is None:
        raise SerializationError("y must be provided.")
    writer.add_char(data._y)

deserialize(reader) staticmethod

Deserializes an instance of Coords from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
Coords Coords

The data to serialize.

Source code in src/eolib/protocol/_generated/coords.py
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@staticmethod
def deserialize(reader: EoReader) -> "Coords":
    """
    Deserializes an instance of `Coords` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        Coords: The data to serialize.
    """
    data: Coords = Coords()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._x = reader.get_char()
        data._y = reader.get_char()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapGraphicRowTile

A single tile in a row of map graphics

Source code in src/eolib/protocol/_generated/map/map_graphic_row_tile.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
class MapGraphicRowTile:
    """
    A single tile in a row of map graphics
    """
    _byte_size: int = 0
    _x: int = None # type: ignore [assignment]
    _graphic: int = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def x(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._x

    @x.setter
    def x(self, x: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._x = x

    @property
    def graphic(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._graphic

    @graphic.setter
    def graphic(self, graphic: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._graphic = graphic

    @staticmethod
    def serialize(writer: EoWriter, data: "MapGraphicRowTile") -> None:
        """
        Serializes an instance of `MapGraphicRowTile` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapGraphicRowTile): The data to serialize.
        """
        if data._x is None:
            raise SerializationError("x must be provided.")
        writer.add_char(data._x)
        if data._graphic is None:
            raise SerializationError("graphic must be provided.")
        writer.add_short(data._graphic)

    @staticmethod
    def deserialize(reader: EoReader) -> "MapGraphicRowTile":
        """
        Deserializes an instance of `MapGraphicRowTile` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapGraphicRowTile: The data to serialize.
        """
        data: MapGraphicRowTile = MapGraphicRowTile()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._x = reader.get_char()
            data._graphic = reader.get_short()
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapGraphicRowTile(byte_size={repr(self._byte_size)}, x={repr(self._x)}, graphic={repr(self._graphic)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

x: int property writable

Note
  • Value range is 0-252.

graphic: int property writable

Note
  • Value range is 0-64008.

serialize(writer, data) staticmethod

Serializes an instance of MapGraphicRowTile to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapGraphicRowTile

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_graphic_row_tile.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@staticmethod
def serialize(writer: EoWriter, data: "MapGraphicRowTile") -> None:
    """
    Serializes an instance of `MapGraphicRowTile` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapGraphicRowTile): The data to serialize.
    """
    if data._x is None:
        raise SerializationError("x must be provided.")
    writer.add_char(data._x)
    if data._graphic is None:
        raise SerializationError("graphic must be provided.")
    writer.add_short(data._graphic)

deserialize(reader) staticmethod

Deserializes an instance of MapGraphicRowTile from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapGraphicRowTile MapGraphicRowTile

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_graphic_row_tile.py
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@staticmethod
def deserialize(reader: EoReader) -> "MapGraphicRowTile":
    """
    Deserializes an instance of `MapGraphicRowTile` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapGraphicRowTile: The data to serialize.
    """
    data: MapGraphicRowTile = MapGraphicRowTile()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._x = reader.get_char()
        data._graphic = reader.get_short()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapGraphicRow

A row in a layer of map graphics

Source code in src/eolib/protocol/_generated/map/map_graphic_row.py
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
class MapGraphicRow:
    """
    A row in a layer of map graphics
    """
    _byte_size: int = 0
    _y: int = None # type: ignore [assignment]
    _tiles_count: int = None # type: ignore [assignment]
    _tiles: list[MapGraphicRowTile] = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def y(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._y

    @y.setter
    def y(self, y: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._y = y

    @property
    def tiles(self) -> list[MapGraphicRowTile]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._tiles

    @tiles.setter
    def tiles(self, tiles: list[MapGraphicRowTile]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._tiles = tiles
        self._tiles_count = len(self._tiles)

    @staticmethod
    def serialize(writer: EoWriter, data: "MapGraphicRow") -> None:
        """
        Serializes an instance of `MapGraphicRow` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapGraphicRow): The data to serialize.
        """
        if data._y is None:
            raise SerializationError("y must be provided.")
        writer.add_char(data._y)
        if data._tiles_count is None:
            raise SerializationError("tiles_count must be provided.")
        writer.add_char(data._tiles_count)
        if data._tiles is None:
            raise SerializationError("tiles must be provided.")
        if len(data._tiles) > 252:
            raise SerializationError(f"Expected length of tiles to be 252 or less, got {len(data._tiles)}.")
        for i in range(data._tiles_count):
            MapGraphicRowTile.serialize(writer, data._tiles[i])

    @staticmethod
    def deserialize(reader: EoReader) -> "MapGraphicRow":
        """
        Deserializes an instance of `MapGraphicRow` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapGraphicRow: The data to serialize.
        """
        data: MapGraphicRow = MapGraphicRow()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._y = reader.get_char()
            data._tiles_count = reader.get_char()
            data._tiles = []
            for i in range(data._tiles_count):
                data._tiles.append(MapGraphicRowTile.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapGraphicRow(byte_size={repr(self._byte_size)}, y={repr(self._y)}, tiles={repr(self._tiles)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

y: int property writable

Note
  • Value range is 0-252.

tiles: list[MapGraphicRowTile] property writable

Note
  • Length must be 252 or less.

serialize(writer, data) staticmethod

Serializes an instance of MapGraphicRow to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapGraphicRow

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_graphic_row.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@staticmethod
def serialize(writer: EoWriter, data: "MapGraphicRow") -> None:
    """
    Serializes an instance of `MapGraphicRow` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapGraphicRow): The data to serialize.
    """
    if data._y is None:
        raise SerializationError("y must be provided.")
    writer.add_char(data._y)
    if data._tiles_count is None:
        raise SerializationError("tiles_count must be provided.")
    writer.add_char(data._tiles_count)
    if data._tiles is None:
        raise SerializationError("tiles must be provided.")
    if len(data._tiles) > 252:
        raise SerializationError(f"Expected length of tiles to be 252 or less, got {len(data._tiles)}.")
    for i in range(data._tiles_count):
        MapGraphicRowTile.serialize(writer, data._tiles[i])

deserialize(reader) staticmethod

Deserializes an instance of MapGraphicRow from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapGraphicRow 'MapGraphicRow'

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_graphic_row.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
@staticmethod
def deserialize(reader: EoReader) -> "MapGraphicRow":
    """
    Deserializes an instance of `MapGraphicRow` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapGraphicRow: The data to serialize.
    """
    data: MapGraphicRow = MapGraphicRow()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._y = reader.get_char()
        data._tiles_count = reader.get_char()
        data._tiles = []
        for i in range(data._tiles_count):
            data._tiles.append(MapGraphicRowTile.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

SerializationError

Bases: Exception

Represents an error in serializing a protocol data structure.

Source code in src/eolib/protocol/serialization_error.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class SerializationError(Exception):
    """
    Represents an error in serializing a protocol data structure.
    """

    def __init__(self, message: str):
        """
        Constructs a SerializationError with the specified error message.

        Args:
            message (str): The error message.
        """
        super().__init__(message)

__init__(message)

Constructs a SerializationError with the specified error message.

Parameters:

Name Type Description Default
message str

The error message.

required
Source code in src/eolib/protocol/serialization_error.py
 6
 7
 8
 9
10
11
12
13
def __init__(self, message: str):
    """
    Constructs a SerializationError with the specified error message.

    Args:
        message (str): The error message.
    """
    super().__init__(message)

EoWriter

Source code in src/eolib/data/eo_writer.py
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
class EoWriter:
    def __init__(self):
        self.data = bytearray()
        self._string_sanitization_mode = False

    def add_byte(self, value: int) -> None:
        """
        Adds a raw byte to the writer data.

        Args:
            value (int): The byte to add.

        Raises:
            ValueError: If the value is above `0xFF`.
        """
        self._check_number_size(value, 0xFF)
        self.data.append(value)

    def add_bytes(self, bytes: bytes) -> None:
        """
        Adds raw bytes to the writer data.

        Args:
            bytes (bytes): The bytes to add.
        """
        self.data.extend(bytes)

    def add_char(self, number: int) -> None:
        """
        Adds an encoded 1-byte integer to the writer data.

        Args:
            number (int): The number to encode and add.

        Raises:
            ValueError: If the value is not below `CHAR_MAX`.
        """
        self._check_number_size(number, CHAR_MAX - 1)
        number_bytes = encode_number(number)
        self._add_bytes_with_length(number_bytes, 1)

    def add_short(self, number: int) -> None:
        """
        Adds an encoded 2-byte integer to the writer data.

        Args:
            number (int): The number to encode and add.

        Raises:
            ValueError: If the value is not below `SHORT_MAX`.
        """
        self._check_number_size(number, SHORT_MAX - 1)
        number_bytes = encode_number(number)
        self._add_bytes_with_length(number_bytes, 2)

    def add_three(self, number: int) -> None:
        """
        Adds an encoded 3-byte integer to the writer data.

        Args:
            number (int): The number to encode and add.

        Raises:
            ValueError: If the value is not below `THREE_MAX`.
        """
        self._check_number_size(number, THREE_MAX - 1)
        number_bytes = encode_number(number)
        self._add_bytes_with_length(number_bytes, 3)

    def add_int(self, number: int) -> None:
        """
        Adds an encoded 4-byte integer to the writer data.

        Args:
            number (int): The number to encode and add.

        Raises:
            ValueError: If the value is not below `INT_MAX`.
        """
        self._check_number_size(number, INT_MAX - 1)
        number_bytes = encode_number(number)
        self._add_bytes_with_length(number_bytes, 4)

    def add_string(self, string: str) -> None:
        """
        Adds a string to the writer data.

        Args:
            string (str): The string to be added.
        """
        string_bytes = self._encode_ansi(string)
        self._sanitize_string(string_bytes)
        self.add_bytes(string_bytes)

    def add_fixed_string(self, string: str, length: int, padded: bool = False) -> None:
        """
        Adds a fixed-length string to the writer data.

        Args:
            string (str): The string to be added.
            length (int): The expected length of the string.
            padded (bool, optional): True if the string should be padded to the length with
                trailing `0xFF` bytes. Defaults to False.
        """
        self._check_string_length(string, length, padded)
        string_bytes = self._encode_ansi(string)
        self._sanitize_string(string_bytes)
        if padded:
            string_bytes = self._add_padding(string_bytes, length)
        self.add_bytes(string_bytes)

    def add_encoded_string(self, string: str) -> None:
        """
        Adds an encoded string to the writer data.

        Args:
            string (str): The string to be encoded and added.
        """
        string_bytes = self._encode_ansi(string)
        self._sanitize_string(string_bytes)
        encode_string(string_bytes)
        self.add_bytes(string_bytes)

    def add_fixed_encoded_string(self, string: str, length: int, padded: bool = False) -> None:
        """
        Adds a fixed-length encoded string to the writer data.

        Args:
            string (str): The string to be encoded and added.
            length (int): The expected length of the string.
            padded (bool, optional): True if the string should be padded to the length with
                trailing `0xFF` bytes. Defaults to False.
        """
        self._check_string_length(string, length, padded)
        string_bytes = self._encode_ansi(string)
        self._sanitize_string(string_bytes)
        if padded:
            string_bytes = self._add_padding(string_bytes, length)
        encode_string(string_bytes)
        self.add_bytes(string_bytes)

    @property
    def string_sanitization_mode(self) -> bool:
        """
        Gets the string sanitization mode for the writer.

        Returns:
            bool: True if string sanitization is enabled.
        """
        return self._string_sanitization_mode

    @string_sanitization_mode.setter
    def string_sanitization_mode(self, string_sanitization_mode: bool) -> None:
        self._string_sanitization_mode = string_sanitization_mode

    def to_bytearray(self) -> bytearray:
        """
        Gets the writer data as a byte array.

        Returns:
            bytearray: A copy of the writer data as a byte array.
        """
        return self.data.copy()

    def __len__(self) -> int:
        """
        Gets the length of the writer data.

        Returns:
            int: The length of the writer data.
        """
        return len(self.data)

    def _add_bytes_with_length(self, bytes: bytes, bytes_length: int) -> None:
        """
        Adds raw bytes with a specified length to the writer data.

        Args:
            bytes (bytes): The bytes to add.
            bytes_length (int): The number of bytes to add.
        """
        self.data.extend(bytes[:bytes_length])

    def _sanitize_string(self, bytes: bytearray) -> None:
        if self.string_sanitization_mode:
            for i in range(len(bytes)):
                if bytes[i] == 0xFF:  # 'ÿ'
                    bytes[i] = 0x79  # 'y'

    @staticmethod
    def _check_number_size(number: int, max_value: int) -> None:
        if number > max_value:
            raise ValueError(f"Value {number} exceeds maximum of {max_value}.")

    @staticmethod
    def _add_padding(bytes: bytearray, length: int) -> bytearray:
        if len(bytes) == length:
            return bytes

        result = bytearray(length)
        result[: len(bytes)] = bytes
        result[len(bytes) :] = bytearray([0xFF] * (length - len(bytes)))

        return result

    @staticmethod
    def _check_string_length(string: str, length: int, padded: bool) -> None:
        if padded:
            if length >= len(string):
                return
            raise ValueError(f'Padded string "{string}" is too large for a length of {length}.')

        if len(string) != length:
            raise ValueError(f'String "{string}" does not have expected length of {length}.')

    @staticmethod
    def _encode_ansi(string: str) -> bytearray:
        """
        Encodes string to windows-1252 bytes.

        Args:
            string (str): The string to encode.

        Returns:
            bytearray: The encoded string.
        """
        return bytearray(string, 'windows-1252', 'replace')

data = bytearray() instance-attribute

string_sanitization_mode: bool property writable

Gets the string sanitization mode for the writer.

Returns:

Name Type Description
bool bool

True if string sanitization is enabled.

__init__()

Source code in src/eolib/data/eo_writer.py
7
8
9
def __init__(self):
    self.data = bytearray()
    self._string_sanitization_mode = False

add_byte(value)

Adds a raw byte to the writer data.

Parameters:

Name Type Description Default
value int

The byte to add.

required

Raises:

Type Description
ValueError

If the value is above 0xFF.

Source code in src/eolib/data/eo_writer.py
11
12
13
14
15
16
17
18
19
20
21
22
def add_byte(self, value: int) -> None:
    """
    Adds a raw byte to the writer data.

    Args:
        value (int): The byte to add.

    Raises:
        ValueError: If the value is above `0xFF`.
    """
    self._check_number_size(value, 0xFF)
    self.data.append(value)

add_bytes(bytes)

Adds raw bytes to the writer data.

Parameters:

Name Type Description Default
bytes bytes

The bytes to add.

required
Source code in src/eolib/data/eo_writer.py
24
25
26
27
28
29
30
31
def add_bytes(self, bytes: bytes) -> None:
    """
    Adds raw bytes to the writer data.

    Args:
        bytes (bytes): The bytes to add.
    """
    self.data.extend(bytes)

add_char(number)

Adds an encoded 1-byte integer to the writer data.

Parameters:

Name Type Description Default
number int

The number to encode and add.

required

Raises:

Type Description
ValueError

If the value is not below CHAR_MAX.

Source code in src/eolib/data/eo_writer.py
33
34
35
36
37
38
39
40
41
42
43
44
45
def add_char(self, number: int) -> None:
    """
    Adds an encoded 1-byte integer to the writer data.

    Args:
        number (int): The number to encode and add.

    Raises:
        ValueError: If the value is not below `CHAR_MAX`.
    """
    self._check_number_size(number, CHAR_MAX - 1)
    number_bytes = encode_number(number)
    self._add_bytes_with_length(number_bytes, 1)

add_short(number)

Adds an encoded 2-byte integer to the writer data.

Parameters:

Name Type Description Default
number int

The number to encode and add.

required

Raises:

Type Description
ValueError

If the value is not below SHORT_MAX.

Source code in src/eolib/data/eo_writer.py
47
48
49
50
51
52
53
54
55
56
57
58
59
def add_short(self, number: int) -> None:
    """
    Adds an encoded 2-byte integer to the writer data.

    Args:
        number (int): The number to encode and add.

    Raises:
        ValueError: If the value is not below `SHORT_MAX`.
    """
    self._check_number_size(number, SHORT_MAX - 1)
    number_bytes = encode_number(number)
    self._add_bytes_with_length(number_bytes, 2)

add_three(number)

Adds an encoded 3-byte integer to the writer data.

Parameters:

Name Type Description Default
number int

The number to encode and add.

required

Raises:

Type Description
ValueError

If the value is not below THREE_MAX.

Source code in src/eolib/data/eo_writer.py
61
62
63
64
65
66
67
68
69
70
71
72
73
def add_three(self, number: int) -> None:
    """
    Adds an encoded 3-byte integer to the writer data.

    Args:
        number (int): The number to encode and add.

    Raises:
        ValueError: If the value is not below `THREE_MAX`.
    """
    self._check_number_size(number, THREE_MAX - 1)
    number_bytes = encode_number(number)
    self._add_bytes_with_length(number_bytes, 3)

add_int(number)

Adds an encoded 4-byte integer to the writer data.

Parameters:

Name Type Description Default
number int

The number to encode and add.

required

Raises:

Type Description
ValueError

If the value is not below INT_MAX.

Source code in src/eolib/data/eo_writer.py
75
76
77
78
79
80
81
82
83
84
85
86
87
def add_int(self, number: int) -> None:
    """
    Adds an encoded 4-byte integer to the writer data.

    Args:
        number (int): The number to encode and add.

    Raises:
        ValueError: If the value is not below `INT_MAX`.
    """
    self._check_number_size(number, INT_MAX - 1)
    number_bytes = encode_number(number)
    self._add_bytes_with_length(number_bytes, 4)

add_string(string)

Adds a string to the writer data.

Parameters:

Name Type Description Default
string str

The string to be added.

required
Source code in src/eolib/data/eo_writer.py
89
90
91
92
93
94
95
96
97
98
def add_string(self, string: str) -> None:
    """
    Adds a string to the writer data.

    Args:
        string (str): The string to be added.
    """
    string_bytes = self._encode_ansi(string)
    self._sanitize_string(string_bytes)
    self.add_bytes(string_bytes)

add_fixed_string(string, length, padded=False)

Adds a fixed-length string to the writer data.

Parameters:

Name Type Description Default
string str

The string to be added.

required
length int

The expected length of the string.

required
padded bool

True if the string should be padded to the length with trailing 0xFF bytes. Defaults to False.

False
Source code in src/eolib/data/eo_writer.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
def add_fixed_string(self, string: str, length: int, padded: bool = False) -> None:
    """
    Adds a fixed-length string to the writer data.

    Args:
        string (str): The string to be added.
        length (int): The expected length of the string.
        padded (bool, optional): True if the string should be padded to the length with
            trailing `0xFF` bytes. Defaults to False.
    """
    self._check_string_length(string, length, padded)
    string_bytes = self._encode_ansi(string)
    self._sanitize_string(string_bytes)
    if padded:
        string_bytes = self._add_padding(string_bytes, length)
    self.add_bytes(string_bytes)

add_encoded_string(string)

Adds an encoded string to the writer data.

Parameters:

Name Type Description Default
string str

The string to be encoded and added.

required
Source code in src/eolib/data/eo_writer.py
117
118
119
120
121
122
123
124
125
126
127
def add_encoded_string(self, string: str) -> None:
    """
    Adds an encoded string to the writer data.

    Args:
        string (str): The string to be encoded and added.
    """
    string_bytes = self._encode_ansi(string)
    self._sanitize_string(string_bytes)
    encode_string(string_bytes)
    self.add_bytes(string_bytes)

add_fixed_encoded_string(string, length, padded=False)

Adds a fixed-length encoded string to the writer data.

Parameters:

Name Type Description Default
string str

The string to be encoded and added.

required
length int

The expected length of the string.

required
padded bool

True if the string should be padded to the length with trailing 0xFF bytes. Defaults to False.

False
Source code in src/eolib/data/eo_writer.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
def add_fixed_encoded_string(self, string: str, length: int, padded: bool = False) -> None:
    """
    Adds a fixed-length encoded string to the writer data.

    Args:
        string (str): The string to be encoded and added.
        length (int): The expected length of the string.
        padded (bool, optional): True if the string should be padded to the length with
            trailing `0xFF` bytes. Defaults to False.
    """
    self._check_string_length(string, length, padded)
    string_bytes = self._encode_ansi(string)
    self._sanitize_string(string_bytes)
    if padded:
        string_bytes = self._add_padding(string_bytes, length)
    encode_string(string_bytes)
    self.add_bytes(string_bytes)

to_bytearray()

Gets the writer data as a byte array.

Returns:

Name Type Description
bytearray bytearray

A copy of the writer data as a byte array.

Source code in src/eolib/data/eo_writer.py
161
162
163
164
165
166
167
168
def to_bytearray(self) -> bytearray:
    """
    Gets the writer data as a byte array.

    Returns:
        bytearray: A copy of the writer data as a byte array.
    """
    return self.data.copy()

__len__()

Gets the length of the writer data.

Returns:

Name Type Description
int int

The length of the writer data.

Source code in src/eolib/data/eo_writer.py
170
171
172
173
174
175
176
177
def __len__(self) -> int:
    """
    Gets the length of the writer data.

    Returns:
        int: The length of the writer data.
    """
    return len(self.data)

EoReader

Bases: object

A class for reading EO data from a sequence of bytes.

EoReader features a chunked reading mode, which is important for accurate emulation of the official game client.

See documentation for chunked reading: https://github.com/Cirras/eo-protocol/blob/master/docs/chunks.md

Source code in src/eolib/data/eo_reader.py
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
class EoReader(object):
    """
    A class for reading EO data from a sequence of bytes.

    `EoReader` features a chunked reading mode, which is important for accurate emulation of
    the official game client.

    See documentation for chunked reading:
    https://github.com/Cirras/eo-protocol/blob/master/docs/chunks.md
    """

    _data: memoryview
    _position: int
    _chunked_reading_mode: bool
    _chunk_start: int
    _next_break: int

    def __init__(self, data: bytes):
        """
        Creates a new `EoReader` instance for the specified data.

        Args:
            data (bytes): The byte array containing the input data.
        """
        self._data = memoryview(data)
        self._position = 0
        self._chunked_reading_mode = False
        self._chunk_start = 0
        self._next_break = -1

    def slice(self, index: Optional[int] = None, length: Optional[int] = None) -> "EoReader":
        """
        Creates a new `EoReader` whose input data is a shared subsequence of this reader's
        data.

        The input data of the new reader will start at position `index` in this reader and contain
        up to `length` bytes. The two reader's position and chunked reading mode will be
        independent.

        The new reader's position will be zero, and its chunked reading mode will be false.

        Args:
            index (int, optional): The position in this reader at which the data of the new reader
                will start; must be non-negative. Defaults to the current reader position.
            length (int, optional): The length of the shared subsequence of data to supply to the
                new reader; must be non-negative. Defaults to the length of the remaining data
                starting from `index`.

        Returns:
            EoReader: The new reader.

        Raises:
            ValueError: If `index` or `length` is negative.
        """
        if index is None:
            index = self.position
        if length is None:
            length = max(0, len(self._data) - index)

        if index < 0:
            raise ValueError(f"negative index: {index}")

        if length < 0:
            raise ValueError(f"negative length: {length}")

        begin = max(0, min(len(self._data), index))
        end = begin + min(len(self._data) - begin, length)

        return EoReader(self._data[begin:end])

    def get_byte(self) -> int:
        """
        Reads a raw byte from the input data.

        Returns:
            int: A raw byte.
        """
        return self._read_byte()

    def get_bytes(self, length: int) -> bytearray:
        """
        Reads an array of raw bytes from the input data.

        Args:
            length (int): The number of bytes to read.

        Returns:
            bytearray: An array of raw bytes.
        """
        return self._read_bytes(length)

    def get_char(self) -> int:
        """
        Reads an encoded 1-byte integer from the input data.

        Returns:
            int: A decoded 1-byte integer.
        """
        return decode_number(self._read_bytes(1))

    def get_short(self) -> int:
        """
        Reads an encoded 2-byte integer from the input data.

        Returns:
            int: A decoded 2-byte integer.
        """
        return decode_number(self._read_bytes(2))

    def get_three(self) -> int:
        """
        Reads an encoded 3-byte integer from the input data.

        Returns:
            int: A decoded 3-byte integer.
        """
        return decode_number(self._read_bytes(3))

    def get_int(self) -> int:
        """
        Reads an encoded 4-byte integer from the input data.

        Returns:
            int: A decoded 4-byte integer.
        """
        return decode_number(self._read_bytes(4))

    def get_string(self) -> str:
        """
        Reads a string from the input data.

        Returns:
            str: A string.
        """
        string_bytes = self._read_bytes(self.remaining)
        return self._decode_ansi(string_bytes)

    def get_fixed_string(self, length: int, padded: bool = False) -> str:
        """
        Reads a string with a fixed length from the input data.

        Args:
            length (int): The length of the string.
            padded (bool, optional): True if the string is padded with trailing `0xFF` bytes.

        Returns:
            str: A decoded string.

        Raises:
            ValueError: If the length is negative.
        """
        if length < 0:
            raise ValueError("Negative length")
        bytes_ = self._read_bytes(length)
        if padded:
            bytes_ = self._remove_padding(bytes_)
        return self._decode_ansi(bytes_)

    def get_encoded_string(self) -> str:
        """
        Reads an encoded string from the input data.

        Returns:
            str: A decoded string.
        """
        bytes_ = self._read_bytes(self.remaining)
        decode_string(bytes_)
        return self._decode_ansi(bytes_)

    def get_fixed_encoded_string(self, length: int, padded: bool = False) -> str:
        """
        Reads an encoded string with a fixed length from the input data.

        Args:
            length (int): The length of the string.
            padded (bool, optional): True if the string is padded with trailing `0xFF` bytes.

        Returns:
            str: A decoded string.

        Raises:
            ValueError: If the length is negative.
        """
        if length < 0:
            raise ValueError("Negative length")
        bytes_ = self._read_bytes(length)
        decode_string(bytes_)
        if padded:
            bytes_ = self._remove_padding(bytes_)
        return self._decode_ansi(bytes_)

    @property
    def chunked_reading_mode(self) -> bool:
        """
        bool: Gets or sets the chunked reading mode for the reader.

        In chunked reading mode:
        - The reader will treat `0xFF` bytes as the end of the current chunk.
        - `next_chunk()` can be called to move to the next chunk.
        """
        return self._chunked_reading_mode

    @chunked_reading_mode.setter
    def chunked_reading_mode(self, chunked_reading_mode: bool) -> None:
        self._chunked_reading_mode = chunked_reading_mode
        if self._next_break == -1:
            self._next_break = self._find_next_break_index()

    @property
    def remaining(self) -> int:
        """
        int: If chunked reading mode is enabled, gets the number of bytes remaining in the current
            chunk. Otherwise, gets the total number of bytes remaining in the input data.
        """
        if self.chunked_reading_mode:
            return self._next_break - min(self.position, self._next_break)
        else:
            return len(self._data) - self.position

    def next_chunk(self) -> None:
        """
        Moves the reader position to the start of the next chunk in the input data.

        Raises:
            RuntimeError: If not in chunked reading mode.
        """
        if not self.chunked_reading_mode:
            raise RuntimeError("Not in chunked reading mode.")

        self._position = self._next_break
        if self._position < len(self._data):
            # Skip the break byte
            self._position += 1

        self._chunk_start = self._position
        self._next_break = self._find_next_break_index()

    @property
    def position(self) -> int:
        """
        int: Gets the current position in the input data.
        """
        return self._position

    def _read_byte(self) -> int:
        """
        Reads a raw byte from the input data.

        Returns:
            int: A raw byte.
        """
        if self.remaining > 0:
            byte = self._data[self._position]
            self._position += 1
            return byte
        return 0

    def _read_bytes(self, length) -> bytearray:
        """
        Reads an array of raw bytes from the input data.

        Args:
            length (int): The number of bytes to read.

        Returns:
            bytearray: An array of raw bytes.
        """
        length = min(length, self.remaining)

        result = bytearray(self._data[self._position : self._position + length])
        self._position += length

        return result

    def _find_next_break_index(self) -> int:
        """
        Finds the index of the next break byte (0xFF) in the input data.

        Returns:
            int: The index of the next break byte, or the length of the data if not found.
        """
        for i in range(self._chunk_start, len(self._data)):
            if self._data[i] == 0xFF:
                return i
        return len(self._data)

    @staticmethod
    def _remove_padding(array: bytearray) -> bytearray:
        """
        Removes padding (trailing 0xFF bytes) from a sequence of bytes.

        Args:
            array (bytearray): The sequence of bytes.

        Returns:
            bytearray: The bytes without padding.
        """
        padding_start = array.find(bytes([0xFF]))
        if padding_start != -1:
            return array[:padding_start]
        return array

    @staticmethod
    def _decode_ansi(bytes: bytearray) -> str:
        """
        Decodes windows-1252 bytes to a string.

        Args:
            bytes (bytearray): The sequence of bytes to decode.

        Returns:
            str: The decoded string.
        """
        return bytes.decode('windows-1252', 'replace')

chunked_reading_mode: bool property writable

bool: Gets or sets the chunked reading mode for the reader.

In chunked reading mode: - The reader will treat 0xFF bytes as the end of the current chunk. - next_chunk() can be called to move to the next chunk.

remaining: int property

If chunked reading mode is enabled, gets the number of bytes remaining in the current

chunk. Otherwise, gets the total number of bytes remaining in the input data.

position: int property

int: Gets the current position in the input data.

__init__(data)

Creates a new EoReader instance for the specified data.

Parameters:

Name Type Description Default
data bytes

The byte array containing the input data.

required
Source code in src/eolib/data/eo_reader.py
23
24
25
26
27
28
29
30
31
32
33
34
def __init__(self, data: bytes):
    """
    Creates a new `EoReader` instance for the specified data.

    Args:
        data (bytes): The byte array containing the input data.
    """
    self._data = memoryview(data)
    self._position = 0
    self._chunked_reading_mode = False
    self._chunk_start = 0
    self._next_break = -1

slice(index=None, length=None)

Creates a new EoReader whose input data is a shared subsequence of this reader's data.

The input data of the new reader will start at position index in this reader and contain up to length bytes. The two reader's position and chunked reading mode will be independent.

The new reader's position will be zero, and its chunked reading mode will be false.

Parameters:

Name Type Description Default
index int

The position in this reader at which the data of the new reader will start; must be non-negative. Defaults to the current reader position.

None
length int

The length of the shared subsequence of data to supply to the new reader; must be non-negative. Defaults to the length of the remaining data starting from index.

None

Returns:

Name Type Description
EoReader EoReader

The new reader.

Raises:

Type Description
ValueError

If index or length is negative.

Source code in src/eolib/data/eo_reader.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def slice(self, index: Optional[int] = None, length: Optional[int] = None) -> "EoReader":
    """
    Creates a new `EoReader` whose input data is a shared subsequence of this reader's
    data.

    The input data of the new reader will start at position `index` in this reader and contain
    up to `length` bytes. The two reader's position and chunked reading mode will be
    independent.

    The new reader's position will be zero, and its chunked reading mode will be false.

    Args:
        index (int, optional): The position in this reader at which the data of the new reader
            will start; must be non-negative. Defaults to the current reader position.
        length (int, optional): The length of the shared subsequence of data to supply to the
            new reader; must be non-negative. Defaults to the length of the remaining data
            starting from `index`.

    Returns:
        EoReader: The new reader.

    Raises:
        ValueError: If `index` or `length` is negative.
    """
    if index is None:
        index = self.position
    if length is None:
        length = max(0, len(self._data) - index)

    if index < 0:
        raise ValueError(f"negative index: {index}")

    if length < 0:
        raise ValueError(f"negative length: {length}")

    begin = max(0, min(len(self._data), index))
    end = begin + min(len(self._data) - begin, length)

    return EoReader(self._data[begin:end])

get_byte()

Reads a raw byte from the input data.

Returns:

Name Type Description
int int

A raw byte.

Source code in src/eolib/data/eo_reader.py
76
77
78
79
80
81
82
83
def get_byte(self) -> int:
    """
    Reads a raw byte from the input data.

    Returns:
        int: A raw byte.
    """
    return self._read_byte()

get_bytes(length)

Reads an array of raw bytes from the input data.

Parameters:

Name Type Description Default
length int

The number of bytes to read.

required

Returns:

Name Type Description
bytearray bytearray

An array of raw bytes.

Source code in src/eolib/data/eo_reader.py
85
86
87
88
89
90
91
92
93
94
95
def get_bytes(self, length: int) -> bytearray:
    """
    Reads an array of raw bytes from the input data.

    Args:
        length (int): The number of bytes to read.

    Returns:
        bytearray: An array of raw bytes.
    """
    return self._read_bytes(length)

get_char()

Reads an encoded 1-byte integer from the input data.

Returns:

Name Type Description
int int

A decoded 1-byte integer.

Source code in src/eolib/data/eo_reader.py
 97
 98
 99
100
101
102
103
104
def get_char(self) -> int:
    """
    Reads an encoded 1-byte integer from the input data.

    Returns:
        int: A decoded 1-byte integer.
    """
    return decode_number(self._read_bytes(1))

get_short()

Reads an encoded 2-byte integer from the input data.

Returns:

Name Type Description
int int

A decoded 2-byte integer.

Source code in src/eolib/data/eo_reader.py
106
107
108
109
110
111
112
113
def get_short(self) -> int:
    """
    Reads an encoded 2-byte integer from the input data.

    Returns:
        int: A decoded 2-byte integer.
    """
    return decode_number(self._read_bytes(2))

get_three()

Reads an encoded 3-byte integer from the input data.

Returns:

Name Type Description
int int

A decoded 3-byte integer.

Source code in src/eolib/data/eo_reader.py
115
116
117
118
119
120
121
122
def get_three(self) -> int:
    """
    Reads an encoded 3-byte integer from the input data.

    Returns:
        int: A decoded 3-byte integer.
    """
    return decode_number(self._read_bytes(3))

get_int()

Reads an encoded 4-byte integer from the input data.

Returns:

Name Type Description
int int

A decoded 4-byte integer.

Source code in src/eolib/data/eo_reader.py
124
125
126
127
128
129
130
131
def get_int(self) -> int:
    """
    Reads an encoded 4-byte integer from the input data.

    Returns:
        int: A decoded 4-byte integer.
    """
    return decode_number(self._read_bytes(4))

get_string()

Reads a string from the input data.

Returns:

Name Type Description
str str

A string.

Source code in src/eolib/data/eo_reader.py
133
134
135
136
137
138
139
140
141
def get_string(self) -> str:
    """
    Reads a string from the input data.

    Returns:
        str: A string.
    """
    string_bytes = self._read_bytes(self.remaining)
    return self._decode_ansi(string_bytes)

get_fixed_string(length, padded=False)

Reads a string with a fixed length from the input data.

Parameters:

Name Type Description Default
length int

The length of the string.

required
padded bool

True if the string is padded with trailing 0xFF bytes.

False

Returns:

Name Type Description
str str

A decoded string.

Raises:

Type Description
ValueError

If the length is negative.

Source code in src/eolib/data/eo_reader.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
def get_fixed_string(self, length: int, padded: bool = False) -> str:
    """
    Reads a string with a fixed length from the input data.

    Args:
        length (int): The length of the string.
        padded (bool, optional): True if the string is padded with trailing `0xFF` bytes.

    Returns:
        str: A decoded string.

    Raises:
        ValueError: If the length is negative.
    """
    if length < 0:
        raise ValueError("Negative length")
    bytes_ = self._read_bytes(length)
    if padded:
        bytes_ = self._remove_padding(bytes_)
    return self._decode_ansi(bytes_)

get_encoded_string()

Reads an encoded string from the input data.

Returns:

Name Type Description
str str

A decoded string.

Source code in src/eolib/data/eo_reader.py
164
165
166
167
168
169
170
171
172
173
def get_encoded_string(self) -> str:
    """
    Reads an encoded string from the input data.

    Returns:
        str: A decoded string.
    """
    bytes_ = self._read_bytes(self.remaining)
    decode_string(bytes_)
    return self._decode_ansi(bytes_)

get_fixed_encoded_string(length, padded=False)

Reads an encoded string with a fixed length from the input data.

Parameters:

Name Type Description Default
length int

The length of the string.

required
padded bool

True if the string is padded with trailing 0xFF bytes.

False

Returns:

Name Type Description
str str

A decoded string.

Raises:

Type Description
ValueError

If the length is negative.

Source code in src/eolib/data/eo_reader.py
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
def get_fixed_encoded_string(self, length: int, padded: bool = False) -> str:
    """
    Reads an encoded string with a fixed length from the input data.

    Args:
        length (int): The length of the string.
        padded (bool, optional): True if the string is padded with trailing `0xFF` bytes.

    Returns:
        str: A decoded string.

    Raises:
        ValueError: If the length is negative.
    """
    if length < 0:
        raise ValueError("Negative length")
    bytes_ = self._read_bytes(length)
    decode_string(bytes_)
    if padded:
        bytes_ = self._remove_padding(bytes_)
    return self._decode_ansi(bytes_)

next_chunk()

Moves the reader position to the start of the next chunk in the input data.

Raises:

Type Description
RuntimeError

If not in chunked reading mode.

Source code in src/eolib/data/eo_reader.py
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
def next_chunk(self) -> None:
    """
    Moves the reader position to the start of the next chunk in the input data.

    Raises:
        RuntimeError: If not in chunked reading mode.
    """
    if not self.chunked_reading_mode:
        raise RuntimeError("Not in chunked reading mode.")

    self._position = self._next_break
    if self._position < len(self._data):
        # Skip the break byte
        self._position += 1

    self._chunk_start = self._position
    self._next_break = self._find_next_break_index()

MapWarpRow

A row of warp entities

Source code in src/eolib/protocol/_generated/map/map_warp_row.py
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
class MapWarpRow:
    """
    A row of warp entities
    """
    _byte_size: int = 0
    _y: int = None # type: ignore [assignment]
    _tiles_count: int = None # type: ignore [assignment]
    _tiles: list[MapWarpRowTile] = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def y(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._y

    @y.setter
    def y(self, y: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._y = y

    @property
    def tiles(self) -> list[MapWarpRowTile]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._tiles

    @tiles.setter
    def tiles(self, tiles: list[MapWarpRowTile]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._tiles = tiles
        self._tiles_count = len(self._tiles)

    @staticmethod
    def serialize(writer: EoWriter, data: "MapWarpRow") -> None:
        """
        Serializes an instance of `MapWarpRow` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapWarpRow): The data to serialize.
        """
        if data._y is None:
            raise SerializationError("y must be provided.")
        writer.add_char(data._y)
        if data._tiles_count is None:
            raise SerializationError("tiles_count must be provided.")
        writer.add_char(data._tiles_count)
        if data._tiles is None:
            raise SerializationError("tiles must be provided.")
        if len(data._tiles) > 252:
            raise SerializationError(f"Expected length of tiles to be 252 or less, got {len(data._tiles)}.")
        for i in range(data._tiles_count):
            MapWarpRowTile.serialize(writer, data._tiles[i])

    @staticmethod
    def deserialize(reader: EoReader) -> "MapWarpRow":
        """
        Deserializes an instance of `MapWarpRow` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapWarpRow: The data to serialize.
        """
        data: MapWarpRow = MapWarpRow()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._y = reader.get_char()
            data._tiles_count = reader.get_char()
            data._tiles = []
            for i in range(data._tiles_count):
                data._tiles.append(MapWarpRowTile.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapWarpRow(byte_size={repr(self._byte_size)}, y={repr(self._y)}, tiles={repr(self._tiles)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

y: int property writable

Note
  • Value range is 0-252.

tiles: list[MapWarpRowTile] property writable

Note
  • Length must be 252 or less.

serialize(writer, data) staticmethod

Serializes an instance of MapWarpRow to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapWarpRow

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_warp_row.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@staticmethod
def serialize(writer: EoWriter, data: "MapWarpRow") -> None:
    """
    Serializes an instance of `MapWarpRow` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapWarpRow): The data to serialize.
    """
    if data._y is None:
        raise SerializationError("y must be provided.")
    writer.add_char(data._y)
    if data._tiles_count is None:
        raise SerializationError("tiles_count must be provided.")
    writer.add_char(data._tiles_count)
    if data._tiles is None:
        raise SerializationError("tiles must be provided.")
    if len(data._tiles) > 252:
        raise SerializationError(f"Expected length of tiles to be 252 or less, got {len(data._tiles)}.")
    for i in range(data._tiles_count):
        MapWarpRowTile.serialize(writer, data._tiles[i])

deserialize(reader) staticmethod

Deserializes an instance of MapWarpRow from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapWarpRow 'MapWarpRow'

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_warp_row.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
@staticmethod
def deserialize(reader: EoReader) -> "MapWarpRow":
    """
    Deserializes an instance of `MapWarpRow` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapWarpRow: The data to serialize.
    """
    data: MapWarpRow = MapWarpRow()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._y = reader.get_char()
        data._tiles_count = reader.get_char()
        data._tiles = []
        for i in range(data._tiles_count):
            data._tiles.append(MapWarpRowTile.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapType

Bases: IntEnum

Source code in src/eolib/protocol/_generated/map/map_type.py
 9
10
11
class MapType(IntEnum, metaclass=ProtocolEnumMeta):
    Normal = 0
    Pk = 3

Normal = 0 class-attribute instance-attribute

Pk = 3 class-attribute instance-attribute

MapTimedEffect

Bases: IntEnum

A timed effect that can occur on a map

Source code in src/eolib/protocol/_generated/map/map_timed_effect.py
 9
10
11
12
13
14
15
16
17
18
19
class MapTimedEffect(IntEnum, metaclass=ProtocolEnumMeta):
    """
    A timed effect that can occur on a map
    """
    None_ = 0
    HpDrain = 1
    TpDrain = 2
    Quake1 = 3
    Quake2 = 4
    Quake3 = 5
    Quake4 = 6

None_ = 0 class-attribute instance-attribute

HpDrain = 1 class-attribute instance-attribute

TpDrain = 2 class-attribute instance-attribute

Quake1 = 3 class-attribute instance-attribute

Quake2 = 4 class-attribute instance-attribute

Quake3 = 5 class-attribute instance-attribute

Quake4 = 6 class-attribute instance-attribute

MapTileSpecRow

A row of tilespecs

Source code in src/eolib/protocol/_generated/map/map_tile_spec_row.py
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
class MapTileSpecRow:
    """
    A row of tilespecs
    """
    _byte_size: int = 0
    _y: int = None # type: ignore [assignment]
    _tiles_count: int = None # type: ignore [assignment]
    _tiles: list[MapTileSpecRowTile] = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def y(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._y

    @y.setter
    def y(self, y: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._y = y

    @property
    def tiles(self) -> list[MapTileSpecRowTile]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._tiles

    @tiles.setter
    def tiles(self, tiles: list[MapTileSpecRowTile]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._tiles = tiles
        self._tiles_count = len(self._tiles)

    @staticmethod
    def serialize(writer: EoWriter, data: "MapTileSpecRow") -> None:
        """
        Serializes an instance of `MapTileSpecRow` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapTileSpecRow): The data to serialize.
        """
        if data._y is None:
            raise SerializationError("y must be provided.")
        writer.add_char(data._y)
        if data._tiles_count is None:
            raise SerializationError("tiles_count must be provided.")
        writer.add_char(data._tiles_count)
        if data._tiles is None:
            raise SerializationError("tiles must be provided.")
        if len(data._tiles) > 252:
            raise SerializationError(f"Expected length of tiles to be 252 or less, got {len(data._tiles)}.")
        for i in range(data._tiles_count):
            MapTileSpecRowTile.serialize(writer, data._tiles[i])

    @staticmethod
    def deserialize(reader: EoReader) -> "MapTileSpecRow":
        """
        Deserializes an instance of `MapTileSpecRow` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapTileSpecRow: The data to serialize.
        """
        data: MapTileSpecRow = MapTileSpecRow()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._y = reader.get_char()
            data._tiles_count = reader.get_char()
            data._tiles = []
            for i in range(data._tiles_count):
                data._tiles.append(MapTileSpecRowTile.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapTileSpecRow(byte_size={repr(self._byte_size)}, y={repr(self._y)}, tiles={repr(self._tiles)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

y: int property writable

Note
  • Value range is 0-252.

tiles: list[MapTileSpecRowTile] property writable

Note
  • Length must be 252 or less.

serialize(writer, data) staticmethod

Serializes an instance of MapTileSpecRow to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapTileSpecRow

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_tile_spec_row.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@staticmethod
def serialize(writer: EoWriter, data: "MapTileSpecRow") -> None:
    """
    Serializes an instance of `MapTileSpecRow` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapTileSpecRow): The data to serialize.
    """
    if data._y is None:
        raise SerializationError("y must be provided.")
    writer.add_char(data._y)
    if data._tiles_count is None:
        raise SerializationError("tiles_count must be provided.")
    writer.add_char(data._tiles_count)
    if data._tiles is None:
        raise SerializationError("tiles must be provided.")
    if len(data._tiles) > 252:
        raise SerializationError(f"Expected length of tiles to be 252 or less, got {len(data._tiles)}.")
    for i in range(data._tiles_count):
        MapTileSpecRowTile.serialize(writer, data._tiles[i])

deserialize(reader) staticmethod

Deserializes an instance of MapTileSpecRow from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapTileSpecRow 'MapTileSpecRow'

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_tile_spec_row.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
@staticmethod
def deserialize(reader: EoReader) -> "MapTileSpecRow":
    """
    Deserializes an instance of `MapTileSpecRow` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapTileSpecRow: The data to serialize.
    """
    data: MapTileSpecRow = MapTileSpecRow()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._y = reader.get_char()
        data._tiles_count = reader.get_char()
        data._tiles = []
        for i in range(data._tiles_count):
            data._tiles.append(MapTileSpecRowTile.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapSign

Sign EMF entity

Source code in src/eolib/protocol/_generated/map/map_sign.py
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class MapSign:
    """
    Sign EMF entity
    """
    _byte_size: int = 0
    _coords: Coords = None # type: ignore [assignment]
    _string_data_length: int = None # type: ignore [assignment]
    _string_data: str = None # type: ignore [assignment]
    _title_length: int = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def coords(self) -> Coords:
        return self._coords

    @coords.setter
    def coords(self, coords: Coords) -> None:
        self._coords = coords

    @property
    def string_data(self) -> str:
        """
        Note:
          - Length must be 64007 or less.
        """
        return self._string_data

    @string_data.setter
    def string_data(self, string_data: str) -> None:
        """
        Note:
          - Length must be 64007 or less.
        """
        self._string_data = string_data
        self._string_data_length = len(self._string_data)

    @property
    def title_length(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._title_length

    @title_length.setter
    def title_length(self, title_length: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._title_length = title_length

    @staticmethod
    def serialize(writer: EoWriter, data: "MapSign") -> None:
        """
        Serializes an instance of `MapSign` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapSign): The data to serialize.
        """
        if data._coords is None:
            raise SerializationError("coords must be provided.")
        Coords.serialize(writer, data._coords)
        if data._string_data_length is None:
            raise SerializationError("string_data_length must be provided.")
        writer.add_short(data._string_data_length + 1)
        if data._string_data is None:
            raise SerializationError("string_data must be provided.")
        if len(data._string_data) > 64007:
            raise SerializationError(f"Expected length of string_data to be 64007 or less, got {len(data._string_data)}.")
        writer.add_fixed_encoded_string(data._string_data, data._string_data_length, False)
        if data._title_length is None:
            raise SerializationError("title_length must be provided.")
        writer.add_char(data._title_length)

    @staticmethod
    def deserialize(reader: EoReader) -> "MapSign":
        """
        Deserializes an instance of `MapSign` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapSign: The data to serialize.
        """
        data: MapSign = MapSign()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._coords = Coords.deserialize(reader)
            data._string_data_length = reader.get_short() - 1
            data._string_data = reader.get_fixed_encoded_string(data._string_data_length, False)
            data._title_length = reader.get_char()
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapSign(byte_size={repr(self._byte_size)}, coords={repr(self._coords)}, string_data={repr(self._string_data)}, title_length={repr(self._title_length)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

coords: Coords property writable

string_data: str property writable

Note
  • Length must be 64007 or less.

title_length: int property writable

Note
  • Value range is 0-252.

serialize(writer, data) staticmethod

Serializes an instance of MapSign to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapSign

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_sign.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@staticmethod
def serialize(writer: EoWriter, data: "MapSign") -> None:
    """
    Serializes an instance of `MapSign` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapSign): The data to serialize.
    """
    if data._coords is None:
        raise SerializationError("coords must be provided.")
    Coords.serialize(writer, data._coords)
    if data._string_data_length is None:
        raise SerializationError("string_data_length must be provided.")
    writer.add_short(data._string_data_length + 1)
    if data._string_data is None:
        raise SerializationError("string_data must be provided.")
    if len(data._string_data) > 64007:
        raise SerializationError(f"Expected length of string_data to be 64007 or less, got {len(data._string_data)}.")
    writer.add_fixed_encoded_string(data._string_data, data._string_data_length, False)
    if data._title_length is None:
        raise SerializationError("title_length must be provided.")
    writer.add_char(data._title_length)

deserialize(reader) staticmethod

Deserializes an instance of MapSign from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapSign MapSign

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_sign.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
@staticmethod
def deserialize(reader: EoReader) -> "MapSign":
    """
    Deserializes an instance of `MapSign` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapSign: The data to serialize.
    """
    data: MapSign = MapSign()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._coords = Coords.deserialize(reader)
        data._string_data_length = reader.get_short() - 1
        data._string_data = reader.get_fixed_encoded_string(data._string_data_length, False)
        data._title_length = reader.get_char()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapNpc

NPC spawn EMF entity

Source code in src/eolib/protocol/_generated/map/map_npc.py
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
class MapNpc:
    """
    NPC spawn EMF entity
    """
    _byte_size: int = 0
    _coords: Coords = None # type: ignore [assignment]
    _id: int = None # type: ignore [assignment]
    _spawn_type: int = None # type: ignore [assignment]
    _spawn_time: int = None # type: ignore [assignment]
    _amount: int = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def coords(self) -> Coords:
        return self._coords

    @coords.setter
    def coords(self, coords: Coords) -> None:
        self._coords = coords

    @property
    def id(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._id

    @id.setter
    def id(self, id: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._id = id

    @property
    def spawn_type(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._spawn_type

    @spawn_type.setter
    def spawn_type(self, spawn_type: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._spawn_type = spawn_type

    @property
    def spawn_time(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._spawn_time

    @spawn_time.setter
    def spawn_time(self, spawn_time: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._spawn_time = spawn_time

    @property
    def amount(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._amount

    @amount.setter
    def amount(self, amount: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._amount = amount

    @staticmethod
    def serialize(writer: EoWriter, data: "MapNpc") -> None:
        """
        Serializes an instance of `MapNpc` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapNpc): The data to serialize.
        """
        if data._coords is None:
            raise SerializationError("coords must be provided.")
        Coords.serialize(writer, data._coords)
        if data._id is None:
            raise SerializationError("id must be provided.")
        writer.add_short(data._id)
        if data._spawn_type is None:
            raise SerializationError("spawn_type must be provided.")
        writer.add_char(data._spawn_type)
        if data._spawn_time is None:
            raise SerializationError("spawn_time must be provided.")
        writer.add_short(data._spawn_time)
        if data._amount is None:
            raise SerializationError("amount must be provided.")
        writer.add_char(data._amount)

    @staticmethod
    def deserialize(reader: EoReader) -> "MapNpc":
        """
        Deserializes an instance of `MapNpc` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapNpc: The data to serialize.
        """
        data: MapNpc = MapNpc()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._coords = Coords.deserialize(reader)
            data._id = reader.get_short()
            data._spawn_type = reader.get_char()
            data._spawn_time = reader.get_short()
            data._amount = reader.get_char()
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapNpc(byte_size={repr(self._byte_size)}, coords={repr(self._coords)}, id={repr(self._id)}, spawn_type={repr(self._spawn_type)}, spawn_time={repr(self._spawn_time)}, amount={repr(self._amount)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

coords: Coords property writable

id: int property writable

Note
  • Value range is 0-64008.

spawn_type: int property writable

Note
  • Value range is 0-252.

spawn_time: int property writable

Note
  • Value range is 0-64008.

amount: int property writable

Note
  • Value range is 0-252.

serialize(writer, data) staticmethod

Serializes an instance of MapNpc to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapNpc

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_npc.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@staticmethod
def serialize(writer: EoWriter, data: "MapNpc") -> None:
    """
    Serializes an instance of `MapNpc` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapNpc): The data to serialize.
    """
    if data._coords is None:
        raise SerializationError("coords must be provided.")
    Coords.serialize(writer, data._coords)
    if data._id is None:
        raise SerializationError("id must be provided.")
    writer.add_short(data._id)
    if data._spawn_type is None:
        raise SerializationError("spawn_type must be provided.")
    writer.add_char(data._spawn_type)
    if data._spawn_time is None:
        raise SerializationError("spawn_time must be provided.")
    writer.add_short(data._spawn_time)
    if data._amount is None:
        raise SerializationError("amount must be provided.")
    writer.add_char(data._amount)

deserialize(reader) staticmethod

Deserializes an instance of MapNpc from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapNpc MapNpc

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_npc.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@staticmethod
def deserialize(reader: EoReader) -> "MapNpc":
    """
    Deserializes an instance of `MapNpc` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapNpc: The data to serialize.
    """
    data: MapNpc = MapNpc()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._coords = Coords.deserialize(reader)
        data._id = reader.get_short()
        data._spawn_type = reader.get_char()
        data._spawn_time = reader.get_short()
        data._amount = reader.get_char()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapMusicControl

Bases: IntEnum

How background music should be played on a map

Source code in src/eolib/protocol/_generated/map/map_music_control.py
 9
10
11
12
13
14
15
16
17
18
19
class MapMusicControl(IntEnum, metaclass=ProtocolEnumMeta):
    """
    How background music should be played on a map
    """
    InterruptIfDifferentPlayOnce = 0
    InterruptPlayOnce = 1
    FinishPlayOnce = 2
    InterruptIfDifferentPlayRepeat = 3
    InterruptPlayRepeat = 4
    FinishPlayRepeat = 5
    InterruptPlayNothing = 6

InterruptIfDifferentPlayOnce = 0 class-attribute instance-attribute

InterruptPlayOnce = 1 class-attribute instance-attribute

FinishPlayOnce = 2 class-attribute instance-attribute

InterruptIfDifferentPlayRepeat = 3 class-attribute instance-attribute

InterruptPlayRepeat = 4 class-attribute instance-attribute

FinishPlayRepeat = 5 class-attribute instance-attribute

InterruptPlayNothing = 6 class-attribute instance-attribute

MapLegacyDoorKey

Legacy EMF entity used to specify a key on a door

Source code in src/eolib/protocol/_generated/map/map_legacy_door_key.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class MapLegacyDoorKey:
    """
    Legacy EMF entity used to specify a key on a door
    """
    _byte_size: int = 0
    _coords: Coords = None # type: ignore [assignment]
    _key: int = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def coords(self) -> Coords:
        return self._coords

    @coords.setter
    def coords(self, coords: Coords) -> None:
        self._coords = coords

    @property
    def key(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._key

    @key.setter
    def key(self, key: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._key = key

    @staticmethod
    def serialize(writer: EoWriter, data: "MapLegacyDoorKey") -> None:
        """
        Serializes an instance of `MapLegacyDoorKey` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapLegacyDoorKey): The data to serialize.
        """
        if data._coords is None:
            raise SerializationError("coords must be provided.")
        Coords.serialize(writer, data._coords)
        if data._key is None:
            raise SerializationError("key must be provided.")
        writer.add_short(data._key)

    @staticmethod
    def deserialize(reader: EoReader) -> "MapLegacyDoorKey":
        """
        Deserializes an instance of `MapLegacyDoorKey` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapLegacyDoorKey: The data to serialize.
        """
        data: MapLegacyDoorKey = MapLegacyDoorKey()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._coords = Coords.deserialize(reader)
            data._key = reader.get_short()
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapLegacyDoorKey(byte_size={repr(self._byte_size)}, coords={repr(self._coords)}, key={repr(self._key)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

coords: Coords property writable

key: int property writable

Note
  • Value range is 0-64008.

serialize(writer, data) staticmethod

Serializes an instance of MapLegacyDoorKey to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapLegacyDoorKey

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_legacy_door_key.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@staticmethod
def serialize(writer: EoWriter, data: "MapLegacyDoorKey") -> None:
    """
    Serializes an instance of `MapLegacyDoorKey` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapLegacyDoorKey): The data to serialize.
    """
    if data._coords is None:
        raise SerializationError("coords must be provided.")
    Coords.serialize(writer, data._coords)
    if data._key is None:
        raise SerializationError("key must be provided.")
    writer.add_short(data._key)

deserialize(reader) staticmethod

Deserializes an instance of MapLegacyDoorKey from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapLegacyDoorKey MapLegacyDoorKey

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_legacy_door_key.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@staticmethod
def deserialize(reader: EoReader) -> "MapLegacyDoorKey":
    """
    Deserializes an instance of `MapLegacyDoorKey` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapLegacyDoorKey: The data to serialize.
    """
    data: MapLegacyDoorKey = MapLegacyDoorKey()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._coords = Coords.deserialize(reader)
        data._key = reader.get_short()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapItem

Item spawn EMF entity

Source code in src/eolib/protocol/_generated/map/map_item.py
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
class MapItem:
    """
    Item spawn EMF entity
    """
    _byte_size: int = 0
    _coords: Coords = None # type: ignore [assignment]
    _key: int = None # type: ignore [assignment]
    _chest_slot: int = None # type: ignore [assignment]
    _item_id: int = None # type: ignore [assignment]
    _spawn_time: int = None # type: ignore [assignment]
    _amount: int = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def coords(self) -> Coords:
        return self._coords

    @coords.setter
    def coords(self, coords: Coords) -> None:
        self._coords = coords

    @property
    def key(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._key

    @key.setter
    def key(self, key: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._key = key

    @property
    def chest_slot(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._chest_slot

    @chest_slot.setter
    def chest_slot(self, chest_slot: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._chest_slot = chest_slot

    @property
    def item_id(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._item_id

    @item_id.setter
    def item_id(self, item_id: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._item_id = item_id

    @property
    def spawn_time(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._spawn_time

    @spawn_time.setter
    def spawn_time(self, spawn_time: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._spawn_time = spawn_time

    @property
    def amount(self) -> int:
        """
        Note:
          - Value range is 0-16194276.
        """
        return self._amount

    @amount.setter
    def amount(self, amount: int) -> None:
        """
        Note:
          - Value range is 0-16194276.
        """
        self._amount = amount

    @staticmethod
    def serialize(writer: EoWriter, data: "MapItem") -> None:
        """
        Serializes an instance of `MapItem` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapItem): The data to serialize.
        """
        if data._coords is None:
            raise SerializationError("coords must be provided.")
        Coords.serialize(writer, data._coords)
        if data._key is None:
            raise SerializationError("key must be provided.")
        writer.add_short(data._key)
        if data._chest_slot is None:
            raise SerializationError("chest_slot must be provided.")
        writer.add_char(data._chest_slot)
        if data._item_id is None:
            raise SerializationError("item_id must be provided.")
        writer.add_short(data._item_id)
        if data._spawn_time is None:
            raise SerializationError("spawn_time must be provided.")
        writer.add_short(data._spawn_time)
        if data._amount is None:
            raise SerializationError("amount must be provided.")
        writer.add_three(data._amount)

    @staticmethod
    def deserialize(reader: EoReader) -> "MapItem":
        """
        Deserializes an instance of `MapItem` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapItem: The data to serialize.
        """
        data: MapItem = MapItem()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._coords = Coords.deserialize(reader)
            data._key = reader.get_short()
            data._chest_slot = reader.get_char()
            data._item_id = reader.get_short()
            data._spawn_time = reader.get_short()
            data._amount = reader.get_three()
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapItem(byte_size={repr(self._byte_size)}, coords={repr(self._coords)}, key={repr(self._key)}, chest_slot={repr(self._chest_slot)}, item_id={repr(self._item_id)}, spawn_time={repr(self._spawn_time)}, amount={repr(self._amount)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

coords: Coords property writable

key: int property writable

Note
  • Value range is 0-64008.

chest_slot: int property writable

Note
  • Value range is 0-252.

item_id: int property writable

Note
  • Value range is 0-64008.

spawn_time: int property writable

Note
  • Value range is 0-64008.

amount: int property writable

Note
  • Value range is 0-16194276.

serialize(writer, data) staticmethod

Serializes an instance of MapItem to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapItem

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_item.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@staticmethod
def serialize(writer: EoWriter, data: "MapItem") -> None:
    """
    Serializes an instance of `MapItem` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapItem): The data to serialize.
    """
    if data._coords is None:
        raise SerializationError("coords must be provided.")
    Coords.serialize(writer, data._coords)
    if data._key is None:
        raise SerializationError("key must be provided.")
    writer.add_short(data._key)
    if data._chest_slot is None:
        raise SerializationError("chest_slot must be provided.")
    writer.add_char(data._chest_slot)
    if data._item_id is None:
        raise SerializationError("item_id must be provided.")
    writer.add_short(data._item_id)
    if data._spawn_time is None:
        raise SerializationError("spawn_time must be provided.")
    writer.add_short(data._spawn_time)
    if data._amount is None:
        raise SerializationError("amount must be provided.")
    writer.add_three(data._amount)

deserialize(reader) staticmethod

Deserializes an instance of MapItem from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapItem MapItem

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_item.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
@staticmethod
def deserialize(reader: EoReader) -> "MapItem":
    """
    Deserializes an instance of `MapItem` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapItem: The data to serialize.
    """
    data: MapItem = MapItem()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._coords = Coords.deserialize(reader)
        data._key = reader.get_short()
        data._chest_slot = reader.get_char()
        data._item_id = reader.get_short()
        data._spawn_time = reader.get_short()
        data._amount = reader.get_three()
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

MapGraphicLayer

A layer of map graphics

Source code in src/eolib/protocol/_generated/map/map_graphic_layer.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class MapGraphicLayer:
    """
    A layer of map graphics
    """
    _byte_size: int = 0
    _graphic_rows_count: int = None # type: ignore [assignment]
    _graphic_rows: list[MapGraphicRow] = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def graphic_rows(self) -> list[MapGraphicRow]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._graphic_rows

    @graphic_rows.setter
    def graphic_rows(self, graphic_rows: list[MapGraphicRow]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._graphic_rows = graphic_rows
        self._graphic_rows_count = len(self._graphic_rows)

    @staticmethod
    def serialize(writer: EoWriter, data: "MapGraphicLayer") -> None:
        """
        Serializes an instance of `MapGraphicLayer` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (MapGraphicLayer): The data to serialize.
        """
        if data._graphic_rows_count is None:
            raise SerializationError("graphic_rows_count must be provided.")
        writer.add_char(data._graphic_rows_count)
        if data._graphic_rows is None:
            raise SerializationError("graphic_rows must be provided.")
        if len(data._graphic_rows) > 252:
            raise SerializationError(f"Expected length of graphic_rows to be 252 or less, got {len(data._graphic_rows)}.")
        for i in range(data._graphic_rows_count):
            MapGraphicRow.serialize(writer, data._graphic_rows[i])

    @staticmethod
    def deserialize(reader: EoReader) -> "MapGraphicLayer":
        """
        Deserializes an instance of `MapGraphicLayer` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            MapGraphicLayer: The data to serialize.
        """
        data: MapGraphicLayer = MapGraphicLayer()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            data._graphic_rows_count = reader.get_char()
            data._graphic_rows = []
            for i in range(data._graphic_rows_count):
                data._graphic_rows.append(MapGraphicRow.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"MapGraphicLayer(byte_size={repr(self._byte_size)}, graphic_rows={repr(self._graphic_rows)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

graphic_rows: list[MapGraphicRow] property writable

Note
  • Length must be 252 or less.

serialize(writer, data) staticmethod

Serializes an instance of MapGraphicLayer to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data MapGraphicLayer

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/map_graphic_layer.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@staticmethod
def serialize(writer: EoWriter, data: "MapGraphicLayer") -> None:
    """
    Serializes an instance of `MapGraphicLayer` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (MapGraphicLayer): The data to serialize.
    """
    if data._graphic_rows_count is None:
        raise SerializationError("graphic_rows_count must be provided.")
    writer.add_char(data._graphic_rows_count)
    if data._graphic_rows is None:
        raise SerializationError("graphic_rows must be provided.")
    if len(data._graphic_rows) > 252:
        raise SerializationError(f"Expected length of graphic_rows to be 252 or less, got {len(data._graphic_rows)}.")
    for i in range(data._graphic_rows_count):
        MapGraphicRow.serialize(writer, data._graphic_rows[i])

deserialize(reader) staticmethod

Deserializes an instance of MapGraphicLayer from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
MapGraphicLayer 'MapGraphicLayer'

The data to serialize.

Source code in src/eolib/protocol/_generated/map/map_graphic_layer.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@staticmethod
def deserialize(reader: EoReader) -> "MapGraphicLayer":
    """
    Deserializes an instance of `MapGraphicLayer` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        MapGraphicLayer: The data to serialize.
    """
    data: MapGraphicLayer = MapGraphicLayer()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        data._graphic_rows_count = reader.get_char()
        data._graphic_rows = []
        for i in range(data._graphic_rows_count):
            data._graphic_rows.append(MapGraphicRow.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode

Emf

Endless Map File

Source code in src/eolib/protocol/_generated/map/emf.py
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
class Emf:
    """
    Endless Map File
    """
    _byte_size: int = 0
    _rid: list[int] = None # type: ignore [assignment]
    _name: str = None # type: ignore [assignment]
    _type: MapType = None # type: ignore [assignment]
    _timed_effect: MapTimedEffect = None # type: ignore [assignment]
    _music_id: int = None # type: ignore [assignment]
    _music_control: MapMusicControl = None # type: ignore [assignment]
    _ambient_sound_id: int = None # type: ignore [assignment]
    _width: int = None # type: ignore [assignment]
    _height: int = None # type: ignore [assignment]
    _fill_tile: int = None # type: ignore [assignment]
    _map_available: bool = None # type: ignore [assignment]
    _can_scroll: bool = None # type: ignore [assignment]
    _relog_x: int = None # type: ignore [assignment]
    _relog_y: int = None # type: ignore [assignment]
    _npcs_count: int = None # type: ignore [assignment]
    _npcs: list[MapNpc] = None # type: ignore [assignment]
    _legacy_door_keys_count: int = None # type: ignore [assignment]
    _legacy_door_keys: list[MapLegacyDoorKey] = None # type: ignore [assignment]
    _items_count: int = None # type: ignore [assignment]
    _items: list[MapItem] = None # type: ignore [assignment]
    _tile_spec_rows_count: int = None # type: ignore [assignment]
    _tile_spec_rows: list[MapTileSpecRow] = None # type: ignore [assignment]
    _warp_rows_count: int = None # type: ignore [assignment]
    _warp_rows: list[MapWarpRow] = None # type: ignore [assignment]
    _graphic_layers: list[MapGraphicLayer] = None # type: ignore [assignment]
    _signs_count: int = None # type: ignore [assignment]
    _signs: list[MapSign] = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def rid(self) -> list[int]:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        return self._rid

    @rid.setter
    def rid(self, rid: list[int]) -> None:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        self._rid = rid

    @property
    def name(self) -> str:
        """
        Note:
          - Length must be `24` or less.
        """
        return self._name

    @name.setter
    def name(self, name: str) -> None:
        """
        Note:
          - Length must be `24` or less.
        """
        self._name = name

    @property
    def type(self) -> MapType:
        return self._type

    @type.setter
    def type(self, type: MapType) -> None:
        self._type = type

    @property
    def timed_effect(self) -> MapTimedEffect:
        return self._timed_effect

    @timed_effect.setter
    def timed_effect(self, timed_effect: MapTimedEffect) -> None:
        self._timed_effect = timed_effect

    @property
    def music_id(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._music_id

    @music_id.setter
    def music_id(self, music_id: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._music_id = music_id

    @property
    def music_control(self) -> MapMusicControl:
        return self._music_control

    @music_control.setter
    def music_control(self, music_control: MapMusicControl) -> None:
        self._music_control = music_control

    @property
    def ambient_sound_id(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._ambient_sound_id

    @ambient_sound_id.setter
    def ambient_sound_id(self, ambient_sound_id: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._ambient_sound_id = ambient_sound_id

    @property
    def width(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._width

    @width.setter
    def width(self, width: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._width = width

    @property
    def height(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._height

    @height.setter
    def height(self, height: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._height = height

    @property
    def fill_tile(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._fill_tile

    @fill_tile.setter
    def fill_tile(self, fill_tile: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._fill_tile = fill_tile

    @property
    def map_available(self) -> bool:
        return self._map_available

    @map_available.setter
    def map_available(self, map_available: bool) -> None:
        self._map_available = map_available

    @property
    def can_scroll(self) -> bool:
        return self._can_scroll

    @can_scroll.setter
    def can_scroll(self, can_scroll: bool) -> None:
        self._can_scroll = can_scroll

    @property
    def relog_x(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._relog_x

    @relog_x.setter
    def relog_x(self, relog_x: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._relog_x = relog_x

    @property
    def relog_y(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._relog_y

    @relog_y.setter
    def relog_y(self, relog_y: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._relog_y = relog_y

    @property
    def npcs(self) -> list[MapNpc]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._npcs

    @npcs.setter
    def npcs(self, npcs: list[MapNpc]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._npcs = npcs
        self._npcs_count = len(self._npcs)

    @property
    def legacy_door_keys(self) -> list[MapLegacyDoorKey]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._legacy_door_keys

    @legacy_door_keys.setter
    def legacy_door_keys(self, legacy_door_keys: list[MapLegacyDoorKey]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._legacy_door_keys = legacy_door_keys
        self._legacy_door_keys_count = len(self._legacy_door_keys)

    @property
    def items(self) -> list[MapItem]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._items

    @items.setter
    def items(self, items: list[MapItem]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._items = items
        self._items_count = len(self._items)

    @property
    def tile_spec_rows(self) -> list[MapTileSpecRow]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._tile_spec_rows

    @tile_spec_rows.setter
    def tile_spec_rows(self, tile_spec_rows: list[MapTileSpecRow]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._tile_spec_rows = tile_spec_rows
        self._tile_spec_rows_count = len(self._tile_spec_rows)

    @property
    def warp_rows(self) -> list[MapWarpRow]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._warp_rows

    @warp_rows.setter
    def warp_rows(self, warp_rows: list[MapWarpRow]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._warp_rows = warp_rows
        self._warp_rows_count = len(self._warp_rows)

    @property
    def graphic_layers(self) -> list[MapGraphicLayer]:
        """
        The 9 layers of map graphics.
        Order is [Ground, Object, Overlay, Down Wall, Right Wall, Roof, Top, Shadow, Overlay2]

        Note:
          - Length must be `9`.
        """
        return self._graphic_layers

    @graphic_layers.setter
    def graphic_layers(self, graphic_layers: list[MapGraphicLayer]) -> None:
        """
        The 9 layers of map graphics.
        Order is [Ground, Object, Overlay, Down Wall, Right Wall, Roof, Top, Shadow, Overlay2]

        Note:
          - Length must be `9`.
        """
        self._graphic_layers = graphic_layers

    @property
    def signs(self) -> list[MapSign]:
        """
        Note:
          - Length must be 252 or less.
        """
        return self._signs

    @signs.setter
    def signs(self, signs: list[MapSign]) -> None:
        """
        Note:
          - Length must be 252 or less.
        """
        self._signs = signs
        self._signs_count = len(self._signs)

    @staticmethod
    def serialize(writer: EoWriter, data: "Emf") -> None:
        """
        Serializes an instance of `Emf` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (Emf): The data to serialize.
        """
        writer.add_fixed_string("EMF", 3, False)
        if data._rid is None:
            raise SerializationError("rid must be provided.")
        if len(data._rid) != 2:
            raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
        for i in range(2):
            writer.add_short(data._rid[i])
        if data._name is None:
            raise SerializationError("name must be provided.")
        if len(data._name) > 24:
            raise SerializationError(f"Expected length of name to be 24 or less, got {len(data._name)}.")
        writer.add_fixed_encoded_string(data._name, 24, True)
        if data._type is None:
            raise SerializationError("type must be provided.")
        writer.add_char(int(data._type))
        if data._timed_effect is None:
            raise SerializationError("timed_effect must be provided.")
        writer.add_char(int(data._timed_effect))
        if data._music_id is None:
            raise SerializationError("music_id must be provided.")
        writer.add_char(data._music_id)
        if data._music_control is None:
            raise SerializationError("music_control must be provided.")
        writer.add_char(int(data._music_control))
        if data._ambient_sound_id is None:
            raise SerializationError("ambient_sound_id must be provided.")
        writer.add_short(data._ambient_sound_id)
        if data._width is None:
            raise SerializationError("width must be provided.")
        writer.add_char(data._width)
        if data._height is None:
            raise SerializationError("height must be provided.")
        writer.add_char(data._height)
        if data._fill_tile is None:
            raise SerializationError("fill_tile must be provided.")
        writer.add_short(data._fill_tile)
        if data._map_available is None:
            raise SerializationError("map_available must be provided.")
        writer.add_char(1 if data._map_available else 0)
        if data._can_scroll is None:
            raise SerializationError("can_scroll must be provided.")
        writer.add_char(1 if data._can_scroll else 0)
        if data._relog_x is None:
            raise SerializationError("relog_x must be provided.")
        writer.add_char(data._relog_x)
        if data._relog_y is None:
            raise SerializationError("relog_y must be provided.")
        writer.add_char(data._relog_y)
        writer.add_char(0)
        if data._npcs_count is None:
            raise SerializationError("npcs_count must be provided.")
        writer.add_char(data._npcs_count)
        if data._npcs is None:
            raise SerializationError("npcs must be provided.")
        if len(data._npcs) > 252:
            raise SerializationError(f"Expected length of npcs to be 252 or less, got {len(data._npcs)}.")
        for i in range(data._npcs_count):
            MapNpc.serialize(writer, data._npcs[i])
        if data._legacy_door_keys_count is None:
            raise SerializationError("legacy_door_keys_count must be provided.")
        writer.add_char(data._legacy_door_keys_count)
        if data._legacy_door_keys is None:
            raise SerializationError("legacy_door_keys must be provided.")
        if len(data._legacy_door_keys) > 252:
            raise SerializationError(f"Expected length of legacy_door_keys to be 252 or less, got {len(data._legacy_door_keys)}.")
        for i in range(data._legacy_door_keys_count):
            MapLegacyDoorKey.serialize(writer, data._legacy_door_keys[i])
        if data._items_count is None:
            raise SerializationError("items_count must be provided.")
        writer.add_char(data._items_count)
        if data._items is None:
            raise SerializationError("items must be provided.")
        if len(data._items) > 252:
            raise SerializationError(f"Expected length of items to be 252 or less, got {len(data._items)}.")
        for i in range(data._items_count):
            MapItem.serialize(writer, data._items[i])
        if data._tile_spec_rows_count is None:
            raise SerializationError("tile_spec_rows_count must be provided.")
        writer.add_char(data._tile_spec_rows_count)
        if data._tile_spec_rows is None:
            raise SerializationError("tile_spec_rows must be provided.")
        if len(data._tile_spec_rows) > 252:
            raise SerializationError(f"Expected length of tile_spec_rows to be 252 or less, got {len(data._tile_spec_rows)}.")
        for i in range(data._tile_spec_rows_count):
            MapTileSpecRow.serialize(writer, data._tile_spec_rows[i])
        if data._warp_rows_count is None:
            raise SerializationError("warp_rows_count must be provided.")
        writer.add_char(data._warp_rows_count)
        if data._warp_rows is None:
            raise SerializationError("warp_rows must be provided.")
        if len(data._warp_rows) > 252:
            raise SerializationError(f"Expected length of warp_rows to be 252 or less, got {len(data._warp_rows)}.")
        for i in range(data._warp_rows_count):
            MapWarpRow.serialize(writer, data._warp_rows[i])
        if data._graphic_layers is None:
            raise SerializationError("graphic_layers must be provided.")
        if len(data._graphic_layers) != 9:
            raise SerializationError(f"Expected length of graphic_layers to be exactly 9, got {len(data._graphic_layers)}.")
        for i in range(9):
            MapGraphicLayer.serialize(writer, data._graphic_layers[i])
        if data._signs_count is None:
            raise SerializationError("signs_count must be provided.")
        writer.add_char(data._signs_count)
        if data._signs is None:
            raise SerializationError("signs must be provided.")
        if len(data._signs) > 252:
            raise SerializationError(f"Expected length of signs to be 252 or less, got {len(data._signs)}.")
        for i in range(data._signs_count):
            MapSign.serialize(writer, data._signs[i])

    @staticmethod
    def deserialize(reader: EoReader) -> "Emf":
        """
        Deserializes an instance of `Emf` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            Emf: The data to serialize.
        """
        data: Emf = Emf()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            data._rid = []
            for i in range(2):
                data._rid.append(reader.get_short())
            data._name = reader.get_fixed_encoded_string(24, True)
            data._type = MapType(reader.get_char())
            data._timed_effect = MapTimedEffect(reader.get_char())
            data._music_id = reader.get_char()
            data._music_control = MapMusicControl(reader.get_char())
            data._ambient_sound_id = reader.get_short()
            data._width = reader.get_char()
            data._height = reader.get_char()
            data._fill_tile = reader.get_short()
            data._map_available = reader.get_char() != 0
            data._can_scroll = reader.get_char() != 0
            data._relog_x = reader.get_char()
            data._relog_y = reader.get_char()
            reader.get_char()
            data._npcs_count = reader.get_char()
            data._npcs = []
            for i in range(data._npcs_count):
                data._npcs.append(MapNpc.deserialize(reader))
            data._legacy_door_keys_count = reader.get_char()
            data._legacy_door_keys = []
            for i in range(data._legacy_door_keys_count):
                data._legacy_door_keys.append(MapLegacyDoorKey.deserialize(reader))
            data._items_count = reader.get_char()
            data._items = []
            for i in range(data._items_count):
                data._items.append(MapItem.deserialize(reader))
            data._tile_spec_rows_count = reader.get_char()
            data._tile_spec_rows = []
            for i in range(data._tile_spec_rows_count):
                data._tile_spec_rows.append(MapTileSpecRow.deserialize(reader))
            data._warp_rows_count = reader.get_char()
            data._warp_rows = []
            for i in range(data._warp_rows_count):
                data._warp_rows.append(MapWarpRow.deserialize(reader))
            data._graphic_layers = []
            for i in range(9):
                data._graphic_layers.append(MapGraphicLayer.deserialize(reader))
            data._signs_count = reader.get_char()
            data._signs = []
            for i in range(data._signs_count):
                data._signs.append(MapSign.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"Emf(byte_size={repr(self._byte_size)}, rid={repr(self._rid)}, name={repr(self._name)}, type={repr(self._type)}, timed_effect={repr(self._timed_effect)}, music_id={repr(self._music_id)}, music_control={repr(self._music_control)}, ambient_sound_id={repr(self._ambient_sound_id)}, width={repr(self._width)}, height={repr(self._height)}, fill_tile={repr(self._fill_tile)}, map_available={repr(self._map_available)}, can_scroll={repr(self._can_scroll)}, relog_x={repr(self._relog_x)}, relog_y={repr(self._relog_y)}, npcs={repr(self._npcs)}, legacy_door_keys={repr(self._legacy_door_keys)}, items={repr(self._items)}, tile_spec_rows={repr(self._tile_spec_rows)}, warp_rows={repr(self._warp_rows)}, graphic_layers={repr(self._graphic_layers)}, signs={repr(self._signs)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

rid: list[int] property writable

Note
  • Length must be 2.
  • Element value range is 0-64008.

name: str property writable

Note
  • Length must be 24 or less.

type: MapType property writable

timed_effect: MapTimedEffect property writable

music_id: int property writable

Note
  • Value range is 0-252.

music_control: MapMusicControl property writable

ambient_sound_id: int property writable

Note
  • Value range is 0-64008.

width: int property writable

Note
  • Value range is 0-252.

height: int property writable

Note
  • Value range is 0-252.

fill_tile: int property writable

Note
  • Value range is 0-64008.

map_available: bool property writable

can_scroll: bool property writable

relog_x: int property writable

Note
  • Value range is 0-252.

relog_y: int property writable

Note
  • Value range is 0-252.

npcs: list[MapNpc] property writable

Note
  • Length must be 252 or less.

legacy_door_keys: list[MapLegacyDoorKey] property writable

Note
  • Length must be 252 or less.

items: list[MapItem] property writable

Note
  • Length must be 252 or less.

tile_spec_rows: list[MapTileSpecRow] property writable

Note
  • Length must be 252 or less.

warp_rows: list[MapWarpRow] property writable

Note
  • Length must be 252 or less.

graphic_layers: list[MapGraphicLayer] property writable

The 9 layers of map graphics. Order is [Ground, Object, Overlay, Down Wall, Right Wall, Roof, Top, Shadow, Overlay2]

Note
  • Length must be 9.

signs: list[MapSign] property writable

Note
  • Length must be 252 or less.

serialize(writer, data) staticmethod

Serializes an instance of Emf to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data Emf

The data to serialize.

required
Source code in src/eolib/protocol/_generated/map/emf.py
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
@staticmethod
def serialize(writer: EoWriter, data: "Emf") -> None:
    """
    Serializes an instance of `Emf` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (Emf): The data to serialize.
    """
    writer.add_fixed_string("EMF", 3, False)
    if data._rid is None:
        raise SerializationError("rid must be provided.")
    if len(data._rid) != 2:
        raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
    for i in range(2):
        writer.add_short(data._rid[i])
    if data._name is None:
        raise SerializationError("name must be provided.")
    if len(data._name) > 24:
        raise SerializationError(f"Expected length of name to be 24 or less, got {len(data._name)}.")
    writer.add_fixed_encoded_string(data._name, 24, True)
    if data._type is None:
        raise SerializationError("type must be provided.")
    writer.add_char(int(data._type))
    if data._timed_effect is None:
        raise SerializationError("timed_effect must be provided.")
    writer.add_char(int(data._timed_effect))
    if data._music_id is None:
        raise SerializationError("music_id must be provided.")
    writer.add_char(data._music_id)
    if data._music_control is None:
        raise SerializationError("music_control must be provided.")
    writer.add_char(int(data._music_control))
    if data._ambient_sound_id is None:
        raise SerializationError("ambient_sound_id must be provided.")
    writer.add_short(data._ambient_sound_id)
    if data._width is None:
        raise SerializationError("width must be provided.")
    writer.add_char(data._width)
    if data._height is None:
        raise SerializationError("height must be provided.")
    writer.add_char(data._height)
    if data._fill_tile is None:
        raise SerializationError("fill_tile must be provided.")
    writer.add_short(data._fill_tile)
    if data._map_available is None:
        raise SerializationError("map_available must be provided.")
    writer.add_char(1 if data._map_available else 0)
    if data._can_scroll is None:
        raise SerializationError("can_scroll must be provided.")
    writer.add_char(1 if data._can_scroll else 0)
    if data._relog_x is None:
        raise SerializationError("relog_x must be provided.")
    writer.add_char(data._relog_x)
    if data._relog_y is None:
        raise SerializationError("relog_y must be provided.")
    writer.add_char(data._relog_y)
    writer.add_char(0)
    if data._npcs_count is None:
        raise SerializationError("npcs_count must be provided.")
    writer.add_char(data._npcs_count)
    if data._npcs is None:
        raise SerializationError("npcs must be provided.")
    if len(data._npcs) > 252:
        raise SerializationError(f"Expected length of npcs to be 252 or less, got {len(data._npcs)}.")
    for i in range(data._npcs_count):
        MapNpc.serialize(writer, data._npcs[i])
    if data._legacy_door_keys_count is None:
        raise SerializationError("legacy_door_keys_count must be provided.")
    writer.add_char(data._legacy_door_keys_count)
    if data._legacy_door_keys is None:
        raise SerializationError("legacy_door_keys must be provided.")
    if len(data._legacy_door_keys) > 252:
        raise SerializationError(f"Expected length of legacy_door_keys to be 252 or less, got {len(data._legacy_door_keys)}.")
    for i in range(data._legacy_door_keys_count):
        MapLegacyDoorKey.serialize(writer, data._legacy_door_keys[i])
    if data._items_count is None:
        raise SerializationError("items_count must be provided.")
    writer.add_char(data._items_count)
    if data._items is None:
        raise SerializationError("items must be provided.")
    if len(data._items) > 252:
        raise SerializationError(f"Expected length of items to be 252 or less, got {len(data._items)}.")
    for i in range(data._items_count):
        MapItem.serialize(writer, data._items[i])
    if data._tile_spec_rows_count is None:
        raise SerializationError("tile_spec_rows_count must be provided.")
    writer.add_char(data._tile_spec_rows_count)
    if data._tile_spec_rows is None:
        raise SerializationError("tile_spec_rows must be provided.")
    if len(data._tile_spec_rows) > 252:
        raise SerializationError(f"Expected length of tile_spec_rows to be 252 or less, got {len(data._tile_spec_rows)}.")
    for i in range(data._tile_spec_rows_count):
        MapTileSpecRow.serialize(writer, data._tile_spec_rows[i])
    if data._warp_rows_count is None:
        raise SerializationError("warp_rows_count must be provided.")
    writer.add_char(data._warp_rows_count)
    if data._warp_rows is None:
        raise SerializationError("warp_rows must be provided.")
    if len(data._warp_rows) > 252:
        raise SerializationError(f"Expected length of warp_rows to be 252 or less, got {len(data._warp_rows)}.")
    for i in range(data._warp_rows_count):
        MapWarpRow.serialize(writer, data._warp_rows[i])
    if data._graphic_layers is None:
        raise SerializationError("graphic_layers must be provided.")
    if len(data._graphic_layers) != 9:
        raise SerializationError(f"Expected length of graphic_layers to be exactly 9, got {len(data._graphic_layers)}.")
    for i in range(9):
        MapGraphicLayer.serialize(writer, data._graphic_layers[i])
    if data._signs_count is None:
        raise SerializationError("signs_count must be provided.")
    writer.add_char(data._signs_count)
    if data._signs is None:
        raise SerializationError("signs must be provided.")
    if len(data._signs) > 252:
        raise SerializationError(f"Expected length of signs to be 252 or less, got {len(data._signs)}.")
    for i in range(data._signs_count):
        MapSign.serialize(writer, data._signs[i])

deserialize(reader) staticmethod

Deserializes an instance of Emf from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
Emf 'Emf'

The data to serialize.

Source code in src/eolib/protocol/_generated/map/emf.py
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
@staticmethod
def deserialize(reader: EoReader) -> "Emf":
    """
    Deserializes an instance of `Emf` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        Emf: The data to serialize.
    """
    data: Emf = Emf()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        data._rid = []
        for i in range(2):
            data._rid.append(reader.get_short())
        data._name = reader.get_fixed_encoded_string(24, True)
        data._type = MapType(reader.get_char())
        data._timed_effect = MapTimedEffect(reader.get_char())
        data._music_id = reader.get_char()
        data._music_control = MapMusicControl(reader.get_char())
        data._ambient_sound_id = reader.get_short()
        data._width = reader.get_char()
        data._height = reader.get_char()
        data._fill_tile = reader.get_short()
        data._map_available = reader.get_char() != 0
        data._can_scroll = reader.get_char() != 0
        data._relog_x = reader.get_char()
        data._relog_y = reader.get_char()
        reader.get_char()
        data._npcs_count = reader.get_char()
        data._npcs = []
        for i in range(data._npcs_count):
            data._npcs.append(MapNpc.deserialize(reader))
        data._legacy_door_keys_count = reader.get_char()
        data._legacy_door_keys = []
        for i in range(data._legacy_door_keys_count):
            data._legacy_door_keys.append(MapLegacyDoorKey.deserialize(reader))
        data._items_count = reader.get_char()
        data._items = []
        for i in range(data._items_count):
            data._items.append(MapItem.deserialize(reader))
        data._tile_spec_rows_count = reader.get_char()
        data._tile_spec_rows = []
        for i in range(data._tile_spec_rows_count):
            data._tile_spec_rows.append(MapTileSpecRow.deserialize(reader))
        data._warp_rows_count = reader.get_char()
        data._warp_rows = []
        for i in range(data._warp_rows_count):
            data._warp_rows.append(MapWarpRow.deserialize(reader))
        data._graphic_layers = []
        for i in range(9):
            data._graphic_layers.append(MapGraphicLayer.deserialize(reader))
        data._signs_count = reader.get_char()
        data._signs = []
        for i in range(data._signs_count):
            data._signs.append(MapSign.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode