summaryrefslogtreecommitdiff
path: root/lib/PacketManager
diff options
context:
space:
mode:
authorRitabrata Das <[email protected]>2025-02-11 00:11:56 +0530
committerRitabrata Das <[email protected]>2025-02-11 00:11:56 +0530
commit3d29b59dae6b93c28c321c2df3cbc49d20d5661c (patch)
treed6348b5eeed358f2dad5a8e4dc2e66bafbbce1b5 /lib/PacketManager
parent2a0fc41e642228b10502ff83036cd79195ea92c0 (diff)
Work on G Limiter
Diffstat (limited to 'lib/PacketManager')
-rw-r--r--lib/PacketManager/packets/FSNETCMD_AIRCMD.py5
-rw-r--r--lib/PacketManager/packets/FSNETCMD_AIRPLANESTATE.py20
-rw-r--r--lib/PacketManager/packets/FSNETCMD_GETDAMAGE.py13
3 files changed, 23 insertions, 15 deletions
diff --git a/lib/PacketManager/packets/FSNETCMD_AIRCMD.py b/lib/PacketManager/packets/FSNETCMD_AIRCMD.py
index 98d782c..094da7d 100644
--- a/lib/PacketManager/packets/FSNETCMD_AIRCMD.py
+++ b/lib/PacketManager/packets/FSNETCMD_AIRCMD.py
@@ -40,7 +40,7 @@ class FSNETCMD_AIRCMD: #30
if with_size:
return pack("I",len(buffer))+buffer
return buffer
-
+
@staticmethod
def setPayload(aircraft_id:int, payload:int, units:str='kg', with_size:bool=False):
"""
@@ -51,3 +51,6 @@ class FSNETCMD_AIRCMD: #30
payload = str(payload)
message = f"INITLOAD {payload} {units}"
return FSNETCMD_AIRCMD.encode(aircraft_id, message, with_size)
+
+ def __str__(self):
+ return "Aircraft ID : {self.aircraft_id}; Message : {self.message}; Command : {self.command}"
diff --git a/lib/PacketManager/packets/FSNETCMD_AIRPLANESTATE.py b/lib/PacketManager/packets/FSNETCMD_AIRPLANESTATE.py
index 071db5e..2282367 100644
--- a/lib/PacketManager/packets/FSNETCMD_AIRPLANESTATE.py
+++ b/lib/PacketManager/packets/FSNETCMD_AIRPLANESTATE.py
@@ -1,6 +1,7 @@
from struct import pack, unpack
from math import pi
import math
+from logging import debug
class FSNETCMD_AIRPLANESTATE: #11
"""
@@ -73,8 +74,8 @@ class FSNETCMD_AIRPLANESTATE: #11
# self.atti = list(unpack("HHH", self.buffer[26:32]))
self.atti = list(map(lambda x: x * (pi / 32768.0),
unpack("HHH", self.buffer[26:32])))
- print(self.atti)
-
+ debug(self.atti)
+
self.velocity = list(map(lambda x: x/10,
unpack("HHH", self.buffer[32:38])))
self.atti_velocity = list(map(lambda x: x * (pi / 32768.0),
@@ -101,12 +102,11 @@ class FSNETCMD_AIRPLANESTATE: #11
self.flags["firing"] = bool(flags &8)
self.flags["smoke"] = 0
if flags & 2:
-
- self.flags["smoke"] = (flags >> 8) & 255 # bitshift 8 to the right,
+ self.flags["smoke"] = (flags >> 8) & 255 # bitshift 8 to the right,
#then mask with 255
if self.flags["smoke"] == 0:
self.flags["smoke"] = 255 # Need to review what this actuall does!
-
+
if flags & 16:
self.flags["beacon"] = True
if flags & 32:
@@ -140,10 +140,10 @@ class FSNETCMD_AIRPLANESTATE: #11
self.atti = list(map(lambda x: x * (pi / 32768.0),
unpack("HHH", self.buffer[28:34])))
-
+
self.velocity = list(map(lambda x: x/10,
unpack("HHH", self.buffer[34:40])))
-
+
self.atti_velocity = list(map(lambda x: x / (pi / 32768.0),
unpack("HHH", self.buffer[40:46])))
self.g_value = unpack("h", self.buffer[46:48])[0]/100.0
@@ -199,13 +199,13 @@ class FSNETCMD_AIRPLANESTATE: #11
return pack('I',len(packet)) + packet
else:
flag = unpack('h',self.buffer[74:75])[0]
-
+
flag &= ~((255<<8)|2)
flag |= (255<<8) | 2
- print(flag)
+ debug(flag)
packet = self.buffer[:74] + pack('h',flag) + self.buffer[76:]
return pack('I',len(packet)) + packet
-
+
def stop_firing(self):
if self.packet_version == 4 or self.packet_version == 5:
flag = unpack('h',self.buffer[56:58])[0]
diff --git a/lib/PacketManager/packets/FSNETCMD_GETDAMAGE.py b/lib/PacketManager/packets/FSNETCMD_GETDAMAGE.py
index 1becb40..165da4d 100644
--- a/lib/PacketManager/packets/FSNETCMD_GETDAMAGE.py
+++ b/lib/PacketManager/packets/FSNETCMD_GETDAMAGE.py
@@ -19,8 +19,8 @@ class FSNETCMD_GETDAMAGE: #22
def decode(self):
variables = unpack("IIIIIHHH", self.buffer[0:26])
- self.victim_id = variables[2]
self.victim_type = variables[1]
+ self.victim_id = variables[2]
self.attacker_type = variables[3]
self.attacker_id = variables[4]
self.damage = variables[5]
@@ -28,7 +28,7 @@ class FSNETCMD_GETDAMAGE: #22
self.weapon_type = variables[7]
if self.weapon_type in FSWEAPON_DICT:
self.weapon_type = FSWEAPON_DICT[self.weapon_type]
-
+
@staticmethod
def encode(victim_id, victim_type, attacker_type, attacker_id, damage, died_of,
@@ -36,8 +36,13 @@ class FSNETCMD_GETDAMAGE: #22
if weapon_type in FSWEAPON_DICT and not isinstance(weapon_type,int):
weapon_type = list(FSWEAPON_DICT.keys())[list(FSWEAPON_DICT.values()).index(weapon_type)]
- buffer = pack("I",22)+pack("IIIIIHHH", victim_id, victim_type, attacker_type,
- attacker_id, damage, died_of, weapon_type)
+ buffer = pack("I",22)+pack("4I3H", victim_type, victim_id, attacker_type,attacker_id,
+ damage, died_of, weapon_type)
if with_size:
return pack("I", len(buffer))+buffer
return buffer
+
+ def __str__(self):
+ return f"Victim ID : {self.victim_id}; Victim Type : {self.victim_type}; \
+ Attacker Type : {self.attacker_type}; Attacker ID : {self.attacker_id} \
+ Damage : {self.damage}; Died Of : {self.died_of}; weapon : {self.weapon_type}"