Skip to content

Commit bb95e72

Browse files
Code cleanup and minor fixes in protocol modules
Removed unnecessary blank lines and improved formatting in flatout2.py, palworld.py, and ut3.py. Fixed main entrypoint in flatout2.py to use asyncio.run. Updated flake8 linting scope in GitHub Actions workflow to only check the opengsq directory.
1 parent 76d9d29 commit bb95e72

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
# stop the build if there are Python syntax errors or undefined names
3535
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3636
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=221 --statistics --exclude tests
37+
flake8 opengsq --count --exit-zero --max-complexity=10 --max-line-length=221 --statistics --exclude tests
3838
# - name: Test with pytest
3939
# run: |
4040
# pytest

opengsq/protocols/flatout2.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ class Flatout2(ProtocolBase):
8383
0x3: 2, # Modified + High (Byte -6 Bit 7 = 1, Byte -7 Bit 0 = 1)
8484
}
8585

86-
87-
8886
# Complete track type mapping (byte at offset 94)
8987
TRACK_TYPE_NAMES = {
9088
0x10: "Wald", # Forest tracks (Timberlands, Pinegrove, City Central, Downtown)
@@ -220,8 +218,6 @@ async def get_status(self) -> Status:
220218
# Send broadcast and receive response
221219
data = await UdpClient.communicate(self, request_data, source_port=self.FLATOUT2_PORT)
222220

223-
224-
225221
# Verify response packet
226222
if not self._verify_packet(data):
227223
raise InvalidPacketException("Invalid response packet received")
@@ -654,4 +650,6 @@ async def main_async():
654650
# Use broadcast address for LAN discovery
655651
flatout2 = Flatout2(host="255.255.255.255", port=23757, timeout=5.0)
656652
status = await flatout2.get_status()
657-
print(status)
653+
print(status)
654+
655+
asyncio.run(main_async())

opengsq/protocols/palworld.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ def __init__(self, host: str, port: int, api_username: str, api_password: str, t
3333
self.api_username = api_username
3434
self.api_password = api_password
3535

36-
async def api_request(self,url):
36+
async def api_request(self, url):
3737
"""
3838
Asynchronously retrieves data from the game server through the REST API.
3939
"""
40-
auth = aiohttp.BasicAuth(self.api_username,self.api_password)
40+
auth = aiohttp.BasicAuth(self.api_username, self.api_password)
4141
async with aiohttp.ClientSession(auth=auth) as session:
4242
async with session.get(url) as response:
4343
data = await response.json()
@@ -73,6 +73,7 @@ async def get_players(self) -> list[Player]:
7373
)
7474
return players
7575

76+
7677
if __name__ == "__main__":
7778
import asyncio
7879

opengsq/protocols/ut3.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ class UT3(UDK):
3737
}
3838

3939
BOT_SKILL_NAMES = {
40-
0: "Novice",
41-
1: "Average",
42-
2: "Experienced",
43-
3: "Skilled",
44-
4: "Adept",
45-
5: "Masterful",
46-
6: "Inhuman",
47-
7: "Godlike"
40+
0: "Novice",
41+
1: "Average",
42+
2: "Experienced",
43+
3: "Skilled",
44+
4: "Adept",
45+
5: "Masterful",
46+
6: "Inhuman",
47+
7: "Godlike"
4848
}
4949

5050
VS_BOTS_NAMES = {
51-
0: "None",
52-
1: "1:1",
53-
2: "3:2",
54-
3: "2:1"
51+
0: "None",
52+
1: "1:1",
53+
2: "3:2",
54+
3: "2:1"
5555
}
5656

5757
full_name = "Unreal Tournament 3 Protocol"

0 commit comments

Comments
 (0)