Decompress data

This commit is contained in:
Maxim Khomutov 2023-07-08 18:57:18 +03:00
parent f7defaed0c
commit a057004cd2
2 changed files with 9 additions and 6 deletions

View File

@ -15,10 +15,13 @@ BeamingDrive Multiplayer (BeamMP) server compatible with BeamMP clients.
- [x] Connecting to the world - [x] Connecting to the world
- [x] Chat - [x] Chat
- [ ] ABG: (compressed data) - [ ] ABG: (compressed data)
- [ ] Decompress data - [x] Decompress data
- [ ] Vehicle data - [ ] Vehicle data
- [ ] Players synchronizations
- [ ] UDP Server part: - [ ] UDP Server part:
- [ ] Players synchronizations - [ ] Players synchronizations
- [ ] Ping
- [ ] Player counter
- [x] Additional: - [x] Additional:
- [x] Events System - [x] Events System
- [x] Plugins support - [x] Plugins support

View File

@ -5,6 +5,7 @@
# Licence: FPA # Licence: FPA
# (c) kuitoi.su 2023 # (c) kuitoi.su 2023
import asyncio import asyncio
import zlib
from core import utils from core import utils
from .tcp_server import TCPServer from .tcp_server import TCPServer
@ -87,17 +88,16 @@ class Client:
return b"" return b""
data = await self.reader.read(101 * MB) data = await self.reader.read(101 * MB)
self.log.debug(f"header: `{header}`; int_header: `{int_header}`; data: `{data}`;")
if len(data) != int_header: if len(data) != int_header:
self.log.debug(f"WARN Expected to read {int_header} bytes, instead got {len(data)}") self.log.debug(f"WARN Expected to read {int_header} bytes, instead got {len(data)}")
self.log.debug(f"header: `{header}`; int_header: `{int_header}`; data: `{data}`;")
# TODO: ABG: DeComp(Data)
abg = b"ABG:" abg = b"ABG:"
if len(data) > len(abg) and data.startswith(abg): if len(data) > len(abg) and data.startswith(abg):
data = data[len(abg):] data = zlib.decompress(data[len(abg):])
return b"" self.log.debug(f"ABG: {data}")
# return DeComp(Data); return data
return data return data
async def sync_resources(self): async def sync_resources(self):