Skip to content

Commit

Permalink
Fix Unreal and KillingFloor Protocol issue
Browse files Browse the repository at this point in the history
Resolve the problem where the _read_string function is not functioning correctly.
  • Loading branch information
BattlefieldDuck committed Jan 18, 2024
1 parent 902271f commit 27e6c66
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion opengsq/binary_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, data: bytes):
def remaining_bytes(self) -> int:
return len(self.__data) - self.stream_position

def is_end(self) -> int:
def is_end(self) -> bool:
return self.stream_position >= len(self.__data)

def prepend_bytes(self, data):
Expand Down
2 changes: 1 addition & 1 deletion opengsq/protocols/killingfloor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def get_details(self):

async def main_async():
# killingfloor
killingFloor = KillingFloor(host='104.234.65.235', port=7708, timeout=10.0)
killingFloor = KillingFloor(host='185.80.128.168', port=7708, timeout=10.0)
details = await killingFloor.get_details()
print(json.dumps(details, indent=None) + '\n')
rules = await killingFloor.get_rules()
Expand Down
12 changes: 2 additions & 10 deletions opengsq/protocols/unreal2.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,8 @@ def strip_colors(text: bytes):

def _read_string(self, br: BinaryReader):
length = br.read_byte()
string = br.read_string()

if length == len(string) + 1:
b = bytes(string, encoding='utf-8')
else:
b = bytes(string, encoding='utf-16')

b = Unreal2.strip_colors(b)

return b.decode('utf-8', 'ignore')
b = br.read_bytes(length)
return Unreal2.strip_colors(b).decode('utf-8', 'ignore')


if __name__ == '__main__':
Expand Down

0 comments on commit 27e6c66

Please sign in to comment.