Skip to content

Commit

Permalink
Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
kierio04 committed Feb 26, 2024
1 parent 4af5ffc commit 19bbb14
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 91 deletions.
46 changes: 26 additions & 20 deletions scripts/Modules/TimeDifference information.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
This file contains information about the Time Difference functions in infodisplay,
as well as the different settings you will find within infodisplay.ini

By default, "Time Difference" is set to "False". When set to "True", Projected and ToFinish will be displayed.
If you wish to display all other calculations, use the "(Extra)" option. These are not recommended for TASing.
By default, "Time Difference" is set to "False". When set to "True", Projected and
ToFinish will be displayed. If you wish to display all other calculations, use the
"(Extra)" option. These are not recommended for TASing.

By default, "Comparison Type" is set to "Player" - it has 4 possible values:
"Player": Which compares the Player against the Ghost (generally the most useful)
Expand All @@ -11,27 +12,31 @@ By default, "Comparison Type" is set to "Player" - it has 4 possible values:
"Behind": Which compares who is behind against who is ahead
NOTE: Any other value will default to "Player" too.

By default, "History Size" is set to 200. It determines how many frames of history are stored for certain parts
of infodisplay (in Time Difference, it's used for the RaceComp calculation to store previous race completions).
WARNING: If you use a number too large, it will take up a large amount of your computer's memory.
By default, "History Size" is set to 200. It determines how many frames of history are
stored for certain parts of infodisplay (in Time Difference, it's used for the RaceComp
calculation to store previous race completions). WARNING: If you use a number too large,
it will take up a large amount of your computer's memory.

NOTE: Not all Time Difference calculations are symmetrical, since for most of them, the speeds and angles of
only one of the player and the ghost are considered. This doesn't make the calculations any less accurate, as
it's perfectly normal to have the time taken for the player to reach the ghost to be different to the time taken
for the ghost to reach the player. As such, we say "Time Difference FROM player TO ghost" or vice versa.
NOTE: Not all Time Difference calculations are symmetrical, since for most of them, the
speeds and angles of only one of the player and the ghost are considered. This doesn't
make the calculations any less accurate, as it's perfectly normal to have the time taken
for the player to reach the ghost to be different to the time taken for the ghost to
reach the player. As such, we say "Time Difference FROM player TO ghost" or vice versa.

Descriptions for each calculation:

[DEFAULT]

- Projected (P1 -> P2)
- Returns D / S1 (Speed of P1) where D is the distance represented here: https://blounard.s-ul.eu/iMDYhZDI.png
- Returns D / S1 (Speed of P1) where D is the distance represented here:
https://blounard.s-ul.eu/iMDYhZDI.png
- Best general-purpose calculation for non-race-end time difference
- Forward movement is taken to be the direction P1 is moving
- As with all but RaceComp, becomes more inaccurate mid-turn

- ToFinish (P1 -> P2)
- Returns T1-T2 where T is Time taken for a player to cross the finish line if they continue at a constant speed
- Returns T1-T2 where T is Time taken for a player to cross the finish line if they
continue at a constant speed
- Perfectly accurate approaching the finish line
- Useless for all non-race-end calculations
- Symmetrical, as both players are fully considered
Expand All @@ -45,20 +50,21 @@ Descriptions for each calculation:
- Will probably be removed in the future; mostly misleading calculation

- Relative (P1 -> P2)
- Same as Absolute but S1 is the speed of P1 directed "toward" P2, using a dot product
- Same as Absolute but S1 is the speed of P1 directed at P2, using a dot product
- Still incorrectly assumes "forward" is wherever the other player is
- However correctly calculates speed with this "forward" direction in mind
- So, rarely useful, but at least accurate for some niche scenario

- CrossPath (P1 -> P2) (Another good one for short distances, lacks evolving gain/loss from skewed angles)
- Returns T1-T2 where T is Time taken for a player to cross the other player's path, as so: https://blounard.s-ul.eu/WYbotlks.png
- Technically accurate long-term, but lacks the evolving time difference from skewed angles
- CrossPath (P1 -> P2)
- Returns T1-T2 where T are Times taken for a player to cross the other player's
path, as so: https://blounard.s-ul.eu/WYbotlks.png
- Technically accurate long-term, but lacks evolving difference from skewed angles
- Symmetrical, as both players are fully considered

- RaceComp (P1 -> P2)
- Returns how long ago P1 was at the race completion of P2 by storing Race Completion history in memory
- Accurate only if P1 and P2 take near-identical paths, due to the nature of Race Completion
- Returns how long ago P1 was at the race completion of P2 by storing history
- Accurate only if P1 and P2 take near-identical paths
- Has a delay of however far ahead P1 is to return an accurate result
- Takes up a lot of memory very quickly (60 frames of Race Completion history per second of gameplay)
- Allows for long distance time difference calculations (irrelevant as this is a micro-optimisation tool)
- Symmetrical, as no calculations involving physical values from either player are used
- Takes up a lot of memory very quickly
- Allows for long distance time difference calculations (not relevant/useful)
- Symmetrical, as no physical values are used in any calculations
5 changes: 3 additions & 2 deletions scripts/Modules/mkw_classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
from .common import RegionError
from .common import vec2, vec3, mat34, quatf, eulerAngle
from .common import ExactTimer
from .common import CupId, CourseId, VehicleId, CharacterId, ControllerId, WheelCount, VehicleType
from .common import SpecialFloor, TrickType, SurfaceProperties, RaceConfigPlayerType
from .common import CupId, CourseId, VehicleId, CharacterId, ControllerId
from .common import WheelCount, VehicleType, SpecialFloor, TrickType
from .common import SurfaceProperties, RaceConfigPlayerType

from .input_mgr import InputMgr
from .player_input import PlayerInput
Expand Down
37 changes: 21 additions & 16 deletions scripts/Modules/mkw_files/rkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class RKGFileHeader:
A class representing the header of an RKG.
Attributes:
file_id (str): "RKGD" in ASCII. Revolution Kart Ghost Data file identifier.
file_id (str): "RKGD" in ASCII. File identifier.
minutes (int): Minutes field of finishing time.
seconds (int): Seconds field of finishing time.
milliseconds (int): Milliseconds field of finishing time.
Expand All @@ -20,14 +20,14 @@ class RKGFileHeader:
compressed (bool): Compressed flag
ghost_type (str): Ghost type ghost is stored as.
drift_type (str): Drift type ghost used.
input_data_length (int): Length of input data when decompressed and without padding.
input_data_length (int): Length of input data when decompressed without padding.
lap_count (int): Total laps ghost drove.
lap_split_minutes (list): Minutes field for each of the 5 lap splits. Unused split times are set to 0.
lap_split_seconds (list): Seconds field for each of the 5 lap splits. Unused split times are set to 0.
lap_split_milliseconds (list): Milliseconds field for each of the 5 lap splits. Unused split times are set to 0.
lap_split_min (list): Minutes field for each of the 5 lap splits.
lap_split_sec (list): Seconds field for each of the 5 lap splits.
lap_split_ms (list): Milliseconds field for each of the 5 lap splits.
country (str): Country ghost was set in, or 0xFF if sharing location disabled.
state (int): Raw State code for Town/State/Province ghost was set in, or 0xFF if sharing location disabled.
location (int): Raw Location code for Location ghost was set in. Typically 0x0000; 0xFFFF if sharing location disabled.
state (int): Raw State code for Town/State/Province ghost was set in.
location (int): Raw Location code for Location ghost was set in.
mii_data (list): Raw Mii Data for Mii ghost was set with.
mii_crc (int): CRC16-CCITT-Xmodem of Mii
"""
Expand All @@ -48,9 +48,9 @@ class RKGFileHeader:
drift_type: str
input_data_length: int
lap_count: int
lap_split_minutes: list
lap_split_seconds: list
lap_split_milliseconds: list
lap_split_min: list
lap_split_sec: list
lap_split_ms: list
country: str
state: int
location: int
Expand All @@ -68,13 +68,15 @@ def __init__(self, raw: list):
self.milliseconds = ((raw[0x05] & 0x03) << 8) + raw[0x06]
self.track = translate.course(raw[0x07] >> 2)
self.vehicle = translate.vehicle(raw[0x08] >> 2)
self.character = translate.character((raw[0x08] & 0x03) << 4) + (raw[0x09] >> 4)
self.character = translate.character(
(raw[0x08] & 0x03) << 4) + (raw[0x09] >> 4)
self.year = ((raw[0x09] & 0x0F) << 3) + (raw[0x0A] >> 5)
self.month = calendar.month_name[(raw[0x0A] & 0x1E) >> 1]
self.day = ((raw[0x0A] & 0x01) << 4) + (raw[0x0B] >> 4)
self.controller = translate.controller(raw[0x0B] & 0x0F)
self.compressed = ((raw[0x0C] & 0x1000) >> 3) != 0
self.ghost_type = translate.ghost_type(((raw[0x0C] & 0x01) << 6) + (raw[0x0D] >> 2))
self.ghost_type = translate.ghost_type(
((raw[0x0C] & 0x01) << 6) + (raw[0x0D] >> 2))
self.drift_type = translate.drift_type((raw[0x0D] & 0x10) >> 1)
self.input_data_length = (raw[0x0E] << 8) + raw[0x0F]
self.lap_count = raw[0x10]
Expand All @@ -87,14 +89,17 @@ def __init__(self, raw: list):

def read_lap_splits(self, raw: list) -> list:
"""
Reads Minutes, Seconds, and Milliseconds fields from raw lap splits and parses into lists.
Reads Minutes, Seconds, and Milliseconds fields from raw lap splits
and parses into lists.
"""

for lap in range(5):
offset = 0x11 + lap*0x03
self.lap_split_minutes.append(raw[offset] >> 1)
self.lap_split_seconds.append(((raw[offset] & 0x01) << 6) + (raw[offset+0x01] >> 2))
self.lap_split_milliseconds.append(((raw[offset+0x01] & 0x03) << 8) + (raw[offset+0x02]))
self.lap_split_min.append(raw[offset] >> 1)
self.lap_split_sec.append(
((raw[offset] & 0x01) << 6) + (raw[offset+0x01] >> 2))
self.lap_split_ms.append(
((raw[offset+0x01] & 0x03) << 8) + (raw[offset+0x02]))

class RKGInputDataHeader:
"""
Expand Down
Loading

0 comments on commit 19bbb14

Please sign in to comment.