Skip to content
This repository was archived by the owner on Apr 27, 2019. It is now read-only.

Commit 61a1f6f

Browse files
committed
Updated to work with 679. Hacky solution for conversion of ByteArray data to a HashMap. Will need to clean this up eventually.
I really hate solutions like these, but oh well.
1 parent 027f67c commit 61a1f6f

2 files changed

Lines changed: 18 additions & 24 deletions

File tree

packets/data_types.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from construct import Construct, Struct, Byte, BFloat64, Flag, \
2+
from construct import Construct, Struct, Byte, BFloat32, BFloat64, Flag, \
33
String, Container, Field
44
from construct.core import _read_stream, _write_stream, Adapter
55

@@ -85,6 +85,18 @@ def _parse(self, stream, context):
8585
l = VLQ("").parse_stream(stream)
8686
return [Variant("").parse_stream(stream) for _ in range(l)]
8787

88+
class ChunkVariant(Construct):
89+
def _parse(self, stream, context):
90+
l = VLQ("").parse_stream(stream)
91+
c = {}
92+
for x in range(l):
93+
junk1 = Byte("").parse_stream(stream)
94+
junk2 = Byte("").parse_stream(stream)
95+
junk3 = BFloat32("").parse_stream(stream)
96+
junk4 = Byte("").parse_stream(stream)
97+
junk5 = StarByteArray("").parse_stream(stream)
98+
return c
99+
88100
class DictVariant(Construct):
89101
def _parse(self, stream, context):
90102
l = VLQ("").parse_stream(stream)

packets/packet_types.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from construct import *
22
from enum import IntEnum
33
from data_types import SignedVLQ, VLQ, Variant, star_string, DictVariant, StarByteArray
4-
#from data_types import WarpVariant
4+
from data_types import ChunkVariant
55

66

77
class Direction(IntEnum):
@@ -218,20 +218,19 @@ def _decode(self, obj, context):
218218

219219
# (9) - ClientConnect : C -> S
220220
client_connect = lambda name="client_connect": Struct(name,
221-
VLQ("asset_digest_length"),
222-
String("asset_digest",
223-
lambda ctx: ctx.asset_digest_length),
221+
StarByteArray("asset_digest"),
224222
HexAdapter(Field("uuid", 16)),
225223
star_string("name"),
226224
star_string("species"),
227-
StarByteArray("ship_data"),
225+
ChunkVariant("ship_data"),
228226
UBInt32("ship_level"),
229227
UBInt32("max_fuel"),
230228
VLQ("capabilities_length"),
231229
Array(lambda ctx: ctx.capabilities_length,
232230
Struct("capabilities",
233231
star_string("value"))),
234-
star_string("account"))
232+
star_string("account")
233+
)
235234

236235
# (4) - HandshakeChallenge : S -> C
237236
handshake_challenge = lambda name="handshake_challenge": Struct(name,
@@ -241,23 +240,6 @@ def _decode(self, obj, context):
241240
handshake_response = lambda name="handshake_response": Struct(name,
242241
star_string("hash"))
243242

244-
## (2) - ConnectResponse : S -> C
245-
#connect_response = lambda name="connect_response": Struct(name,
246-
# Flag("success"),
247-
# VLQ("client_id"),
248-
# star_string("reject_reason"),
249-
# Flag("celestial_info_exists"),
250-
# If(lambda ctx: ctx.celestial_info_exists,
251-
# Struct(
252-
# "celestial_data",
253-
# SBInt32("planet_orbital_levels"),
254-
# SBInt32("satellite_orbital_levels"),
255-
# SBInt32("chunk_size"),
256-
# SBInt32("xy_min"),
257-
# SBInt32("xy_max"),
258-
# SBInt32("z_min"),
259-
# SBInt32("z_max"))))
260-
261243
# (2) - ConnectSuccess : S -> C
262244
connect_success = lambda name="connect_success": Struct(name,
263245
VLQ("client_id"),

0 commit comments

Comments
 (0)