[!] FIX unicycle

[!] FIX BeamMP bug
[~] Minor
This commit is contained in:
2024-07-25 17:00:09 +03:00
parent 06942e8a71
commit f1f80cc94c
5 changed files with 9 additions and 10 deletions

View File

@@ -504,10 +504,10 @@ class Client:
pass
if cid == self.cid or allow or admin_allow:
if car['snowman']:
if car['unicycle']:
unicycle_id = self._unicycle['id']
self._unicycle['id'] = -1
self.log.debug(f"Delete snowman")
self.log.debug(f"Delete unicycle")
await self._send(f"Od:{self.cid}-{unicycle_id}", to_all=True, to_self=True)
self._cars[unicycle_id] = None
else:
@@ -521,8 +521,8 @@ class Client:
self.log.debug(f"Invalid car: car_id={car_id}")
async def reset_car(self, car_id, x, y, z, rot=None):
self.log.debug(f"Resetting car from plugin")
jpkt = {"rot": {"y": 0, "w": 0, "x": 0, "z": 0}, "pos": {"y": int(y), "x": int(x), "z": int(z)}}
self.log.debug(f"Resetting car from plugin {x, y, z}; {rot=}")
jpkt = {"pos": {"y": float(y), "x": float(x), "z": float(z)}, "rot": {"y": 0, "w": 0, "x": 0, "z": 0}}
if rot:
jpkt['rot'] = rot
await self._send(f"Or:{self.cid}-{car_id}:{json.dumps(jpkt)}", True)

View File

@@ -10,7 +10,7 @@ __title__ = 'KuiToi-Server'
__description__ = 'BeamingDrive Multiplayer server compatible with BeamMP clients.'
__url__ = 'https://github.com/kuitoi/kuitoi-Server'
__version__ = '0.4.6'
__build__ = 2437 # Я это считаю лог файлами
__build__ = 2459 # Я это считаю лог файлами
__author__ = 'SantaSpeen'
__author_email__ = 'admin@kuitoi.su'
__license__ = "FPA"

View File

@@ -54,7 +54,7 @@ class Core:
ev.register("_get_player", lambda x: self.get_client(**x['kwargs']))
def get_client(self, cid=None, nick=None):
if cid is None and nick is None:
if (cid, nick) == (None, None):
return None
if cid is not None:
if cid == -1:

View File

@@ -35,12 +35,11 @@ class TCPServer:
await client.kick(i18n.core_player_kick_outdated)
return False, client
else:
# await client._send(b"S") # Accepted client version
await client._send(b"A") # Accepted client version
data = await client._recv(True)
self.log.debug(f"Key: {data}")
if len(data) > 50:
if not data or len(data) > 50:
await client.kick(i18n.core_player_kick_bad_key)
return False, client
client._key = data.decode("utf-8")

View File

@@ -36,7 +36,7 @@ class UDPServer(asyncio.DatagramTransport):
client = self._core.get_client(cid=cid)
if client:
if not client.alive:
self.log.debug(f"{client.nick}:{cid} still sending UDP data: {data}")
client.log.debug(f"Still sending UDP data: {data}")
match code:
case "p": # Ping packet
ev.call_event("onSentPing")
@@ -45,7 +45,6 @@ class UDPServer(asyncio.DatagramTransport):
if client._udp_sock != (self.transport, addr):
client._udp_sock = (self.transport, addr)
self.log.debug(f"Set UDP Sock for CID: {cid}")
ev.call_event("onChangePosition", data=data)
sub = data.find("{", 1)
last_pos = data[sub:]
try:
@@ -54,6 +53,7 @@ class UDPServer(asyncio.DatagramTransport):
last_pos = json.loads(last_pos)
client._last_position = last_pos
client._cars[car_id]['pos'] = last_pos
ev.call_event("onChangePosition", data, player=client, pos=last_pos)
except Exception as e:
self.log.warning(f"Cannot parse position packet: {e}")
self.log.debug(f"data: '{data}', sup: {sub}")