Skip to content

Commit

Permalink
Add: estimate the new ticks_playing field for older servers
Browse files Browse the repository at this point in the history
This field was added in Game Info v7, and although the master-server
doesn't (need to) support this, for simplicity it is easier if it
does calculate it with a rough estimate.
  • Loading branch information
TrueBrain committed Jan 27, 2024
1 parent daaa914 commit e078c9b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions master_server/openttd/receive.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def receive_PACKET_UDP_SERVER_RESPONSE(source, data):
"map_height",
"map_type",
"is_dedicated",
"ticks_playing",
]
}

Expand Down Expand Up @@ -163,6 +164,8 @@ def receive_PACKET_UDP_SERVER_RESPONSE(source, data):
payload["map_type"], data = read_uint8(data)
payload["is_dedicated"], data = read_uint8(data)

payload["ticks_playing"] = max(0, (payload["game_date"] - payload["start_date"]) * 74)

if len(data) != 0:
raise PacketInvalidData("more bytes than expected")

Expand Down

0 comments on commit e078c9b

Please sign in to comment.