Skip to content

Commit

Permalink
Plugin/Monitor: update exposed game structures with new members.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIronWolfModding committed Dec 7, 2018
1 parent 3775f23 commit eb5de36
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 16 deletions.
29 changes: 24 additions & 5 deletions Include/rF2State.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ struct rF2Wheel
unsigned char mSurfaceType; // 0=dry, 1=wet, 2=grass, 3=dirt, 4=gravel, 5=rumblestrip, 6=special
bool mFlat; // whether tire is flat
bool mDetached; // whether wheel is detached
unsigned char mStaticUndeflectedRadius; // tire radius in centimeters

double mVerticalTireDeflection;// how much is tire deflected from its (speed-sensitive) radius
double mWheelYLocation; // wheel's y location relative to vehicle y location
Expand Down Expand Up @@ -347,6 +348,7 @@ struct rF2ScoringInfo
// 6 Full course yellow / safety car
// 7 Session stopped
// 8 Session over
// 9 Paused (tag.2015.09.14 - this is new, and indicates that this is a heartbeat call to the plugin)
unsigned char mGamePhase;

// Yellow flag states (applies to full-course only)
Expand Down Expand Up @@ -377,8 +379,19 @@ struct rF2ScoringInfo
double mMinPathWetness; // minimum wetness on main path 0.0-1.0
double mMaxPathWetness; // maximum wetness on main path 0.0-1.0

// multiplayer
unsigned char mGameMode; // 1 = server, 2 = client, 3 = server and client
bool mIsPasswordProtected; // is the server password protected
unsigned short mServerPort; // the port of the server (if on a server)
unsigned long mServerPublicIP; // the public IP address of the server (if on a server)
long mMaxPlayers; // maximum number of vehicles that can be in the session
char mServerName[32]; // name of the server
float mStartET; // start time (seconds since midnight) of the event

double mAvgPathWetness; // average wetness on main path 0.0-1.0

// Future use
unsigned char mExpansion[256];
unsigned char mExpansion[200];

// MM_NOT_USED
// keeping this at the end of the structure to make it easier to replace in future versions
Expand Down Expand Up @@ -464,9 +477,14 @@ struct rF2VehicleScoring

unsigned char mUpgradePack[16]; // Coded upgrades

float mPitLapDist; // location of pit in terms of lap distance

float mBestLapSector1; // sector 1 time from best lap (not necessarily the best sector 1 time)
float mBestLapSector2; // sector 2 time from best lap (not necessarily the best sector 2 time)

// Future use
// tag.2012.04.06 - SEE ABOVE!
unsigned char mExpansion[60]; // for future use
unsigned char mExpansion[48]; // for future use
};
static_assert(sizeof(rF2VehicleScoring) == sizeof(VehicleScoringInfoV01), "rF2VehicleScoring and VehicleScoringInfoV01 structures are out of sync");

Expand Down Expand Up @@ -583,8 +601,9 @@ struct rF2TrackRulesParticipant
long mRelativeLaps; // current formation/caution laps relative to safety car (should generally be zero except when safety car crosses s/f line); this can be decremented to implement 'wave around' or 'beneficiary rule' (a.k.a. 'lucky dog' or 'free pass')
rF2TrackRulesColumn mColumnAssignment;// which column (line/lane) that participant is supposed to be in
long mPositionAssignment; // 0-based position within column (line/lane) that participant is supposed to be located at (-1 is invalid)
bool mAllowedToPit; // whether the rules allow this particular vehicle to enter pits right now
bool mUnused[ 3 ]; //
unsigned char mPitsOpen; // whether the rules allow this particular vehicle to enter pits right now (input is 2=false or 3=true; if you want to edit it, set to 0=false or 1=true)
bool mUpToSpeed; // while in the frozen order, this flag indicates whether the vehicle can be followed (this should be false for somebody who has temporarily spun and hasn't gotten back up to speed yet)
bool mUnused[2]; //
double mGoalRelativeDistance; // calculated based on where the leader is, and adjusted by the desired column spacing and the column/position assignments
char mMessage[ 96 ]; // a message for this participant to explain what is going on (untranslated; it will get run through translator on client machines)

Expand Down Expand Up @@ -633,7 +652,7 @@ struct rF2TrackRules
long mNumParticipants; // number of participants (vehicles)

bool mYellowFlagDetected; // whether yellow flag was requested or sum of participant mYellowSeverity's exceeds mSafetyCarThreshold
bool mYellowFlagLapsWasOverridden; // whether mYellowFlagLaps (below) is an admin request
unsigned char mYellowFlagLapsWasOverridden; // whether mYellowFlagLaps (below) is an admin request (0=no 1=yes 2=clear yellow)

bool mSafetyCarExists; // whether safety car even exists
bool mSafetyCarActive; // whether safety car is active
Expand Down
10 changes: 5 additions & 5 deletions Monitor/rF2SMMonitor/rF2SMMonitor/TransitionTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ internal class Rules
public int mRelativeLaps = -1; // current formation/caution laps relative to safety car (should generally be zero except when safety car crosses s/f line); this can be decremented to implement 'wave around' or 'beneficiary rule' (a.k.a. 'lucky dog' or 'free pass')
public rF2TrackRulesColumn mColumnAssignment = (rF2TrackRulesColumn)Enum.ToObject(typeof(rF2TrackRulesColumn), -255); // which column (line/lane) that participant is supposed to be in
public int mPositionAssignment = -1; // 0-based position within column (line/lane) that participant is supposed to be located at (-1 is invalid)
public byte mAllowedToPit = 255; // whether the rules allow this particular vehicle to enter pits right now
public byte mPitsOpen = 255; // whether the rules allow this particular vehicle to enter pits right now

public double mGoalRelativeDistance = -1.0; // calculated based on where the leader is, and adjusted by the desired column spacing and the column/position assignments

Expand Down Expand Up @@ -1419,7 +1419,7 @@ internal void TrackRules(ref rF2Scoring scoring, ref rF2Telemetry telemetry, ref
rs.mRelativeLaps = playerRules.mRelativeLaps;
rs.mColumnAssignment = playerRules.mColumnAssignment;
rs.mPositionAssignment = playerRules.mPositionAssignment;
rs.mAllowedToPit = playerRules.mAllowedToPit;
rs.mPitsOpen = playerRules.mPitsOpen;
rs.mGoalRelativeDistance = playerRules.mGoalRelativeDistance;
rs.mMessage_Participant = TransitionTracker.GetStringFromBytes(playerRules.mMessage);

Expand Down Expand Up @@ -1457,7 +1457,7 @@ internal void TrackRules(ref rF2Scoring scoring, ref rF2Telemetry telemetry, ref
|| rs.mRelativeLaps != this.prevRules.mRelativeLaps
|| rs.mColumnAssignment != this.prevRules.mColumnAssignment
|| rs.mPositionAssignment != this.prevRules.mPositionAssignment
|| rs.mAllowedToPit != this.prevRules.mAllowedToPit
|| rs.mPitsOpen != this.prevRules.mPitsOpen
|| rs.mGoalRelativeDistance != this.prevRules.mGoalRelativeDistance
|| rs.mMessage_Participant != this.prevRules.mMessage_Participant)
{
Expand Down Expand Up @@ -1494,7 +1494,7 @@ internal void TrackRules(ref rF2Scoring scoring, ref rF2Telemetry telemetry, ref
+ (rs.mRelativeLaps != this.prevRules.mRelativeLaps ? "***\n" : "\n")
+ (rs.mColumnAssignment != this.prevRules.mColumnAssignment ? "***\n" : "\n")
+ (rs.mPositionAssignment != this.prevRules.mPositionAssignment ? "***\n" : "\n")
+ (rs.mAllowedToPit != this.prevRules.mAllowedToPit ? "***\n" : "\n")
+ (rs.mPitsOpen != this.prevRules.mPitsOpen ? "***\n" : "\n")
+ (rs.mGoalRelativeDistance != this.prevRules.mGoalRelativeDistance ? "***\n" : "\n")
+ (rs.mMessage_Participant != this.prevRules.mMessage_Participant ? "***\n" : "\n"));

Expand Down Expand Up @@ -1571,7 +1571,7 @@ internal void TrackRules(ref rF2Scoring scoring, ref rF2Telemetry telemetry, ref
+ $"{rs.mRelativeLaps}\n"
+ $"{rs.mColumnAssignment}\n"
+ $"{rs.mPositionAssignment}\n"
+ $"{rs.mAllowedToPit}\n"
+ $"{rs.mPitsOpen}\n"
+ (rs.mGoalRelativeDistance > 20000 ? $"too large" : $"{rs.mGoalRelativeDistance:N3})") + "\n"
+ $"{rs.mMessage_Participant}\n");

Expand Down
36 changes: 30 additions & 6 deletions Monitor/rF2SMMonitor/rF2SMMonitor/rF2Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ namespace rF2SMMonitor
// signed char -> sbyte
// bool -> byte
// long -> int
// unsigned long -> uint
// short -> short
// unsigned short -> ushort
// ULONGLONG -> Int64
public class rFactor2Constants
{
Expand All @@ -46,6 +48,7 @@ public class rFactor2Constants
// 6 Full course yellow / safety car
// 7 Session stopped
// 8 Session over
// 9 Paused (tag.2015.09.14 - this is new, and indicates that this is a heartbeat call to the plugin)
public enum rF2GamePhase
{
Garage = 0,
Expand All @@ -56,7 +59,8 @@ public enum rF2GamePhase
GreenFlag = 5,
FullCourseYellow = 6,
SessionStopped = 7,
SessionOver = 8
SessionOver = 8,
PausedOrHeartbeat = 9
}

// Yellow flag states (applies to full-course only)
Expand Down Expand Up @@ -210,6 +214,7 @@ public struct rF2Wheel
public byte mSurfaceType; // 0=dry, 1=wet, 2=grass, 3=dirt, 4=gravel, 5=rumblestrip, 6=special
public byte mFlat; // whether tire is flat
public byte mDetached; // whether wheel is detached
public byte mStaticUndeflectedRadius; // tire radius in centimeters

public double mVerticalTireDeflection;// how much is tire deflected from its (speed-sensitive) radius
public double mWheelYLocation; // wheel's y location relative to vehicle y location
Expand Down Expand Up @@ -363,6 +368,7 @@ public struct rF2ScoringInfo
// 6 Full course yellow / safety car
// 7 Session stopped
// 8 Session over
// 9 Paused (tag.2015.09.14 - this is new, and indicates that this is a heartbeat call to the plugin)
public byte mGamePhase;

// Yellow flag states (applies to full-course only)
Expand Down Expand Up @@ -396,8 +402,20 @@ public struct rF2ScoringInfo
public double mMinPathWetness; // minimum wetness on main path 0.0-1.0
public double mMaxPathWetness; // maximum wetness on main path 0.0-1.0

// multiplayer
public byte mGameMode; // 1 = server, 2 = client, 3 = server and client
public byte mIsPasswordProtected; // is the server password protected
public ushort mServerPort; // the port of the server (if on a server)
public uint mServerPublicIP; // the public IP address of the server (if on a server)
public int mMaxPlayers; // maximum number of vehicles that can be in the session
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] mServerName; // name of the server
public float mStartET; // start time (seconds since midnight) of the event

public double mAvgPathWetness; // average wetness on main path 0.0-1.0

// Future use
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 256)]
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 200)]
public byte[] mExpansion;

// MM_NOT_USED
Expand Down Expand Up @@ -484,9 +502,14 @@ public struct rF2VehicleScoring
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] mUpgradePack; // Coded upgrades

public float mPitLapDist; // location of pit in terms of lap distance

public float mBestLapSector1; // sector 1 time from best lap (not necessarily the best sector 1 time)
public float mBestLapSector2; // sector 2 time from best lap (not necessarily the best sector 2 time)

// Future use
// tag.2012.04.06 - SEE ABOVE!
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 60)]
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 48)]
public byte[] mExpansion; // for future use
}

Expand Down Expand Up @@ -599,9 +622,10 @@ public struct rF2TrackRulesParticipant
public int mRelativeLaps; // current formation/caution laps relative to safety car (should generally be zero except when safety car crosses s/f line); this can be decremented to implement 'wave around' or 'beneficiary rule' (a.k.a. 'lucky dog' or 'free pass')
public rF2TrackRulesColumn mColumnAssignment;// which column (line/lane) that participant is supposed to be in
public int mPositionAssignment; // 0-based position within column (line/lane) that participant is supposed to be located at (-1 is invalid)
public byte mAllowedToPit; // whether the rules allow this particular vehicle to enter pits right now
public byte mPitsOpen; // whether the rules allow this particular vehicle to enter pits right now (input is 2=false or 3=true; if you want to edit it, set to 0=false or 1=true)
public byte mUpToSpeed; // while in the frozen order, this flag indicates whether the vehicle can be followed (this should be false for somebody who has temporarily spun and hasn't gotten back up to speed yet)

[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 3)]
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2)]
public byte[] mUnused; //

public double mGoalRelativeDistance; // calculated based on where the leader is, and adjusted by the desired column spacing and the column/position assignments
Expand Down Expand Up @@ -651,7 +675,7 @@ public struct rF2TrackRules
public int mNumParticipants; // number of participants (vehicles)

public byte mYellowFlagDetected; // whether yellow flag was requested or sum of participant mYellowSeverity's exceeds mSafetyCarThreshold
public byte mYellowFlagLapsWasOverridden; // whether mYellowFlagLaps (below) is an admin request
public byte mYellowFlagLapsWasOverridden; // whether mYellowFlagLaps (below) is an admin request (0=no 1=yes 2=clear yellow)

public byte mSafetyCarExists; // whether safety car even exists
public byte mSafetyCarActive; // whether safety car is active
Expand Down

0 comments on commit eb5de36

Please sign in to comment.