Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Get/Set WindowsParameters being inverted compared to everything else #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/SampSharp.Entities/SAMP/Components/Vehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,11 @@ public void SetWindowsParameters(bool driver, bool passenger, bool backLeft, boo
public void SetWindowsParameters(VehicleParameterValue driver, VehicleParameterValue passenger, VehicleParameterValue backLeft,
VehicleParameterValue backRight)
{
if (driver != VehicleParameterValue.Unset) driver = (VehicleParameterValue)(driver == VehicleParameterValue.On ? 0 : 1);
if (passenger != VehicleParameterValue.Unset) passenger = (VehicleParameterValue)(passenger == VehicleParameterValue.On ? 0 : 1);
if (backLeft != VehicleParameterValue.Unset) backLeft = (VehicleParameterValue)(backLeft == VehicleParameterValue.On ? 0 : 1);
if (backRight != VehicleParameterValue.Unset) backRight = (VehicleParameterValue)(backRight == VehicleParameterValue.On ? 0 : 1);

GetComponent<NativeVehicle>()
.SetVehicleParamsCarWindows((int)driver, (int)passenger, (int)backLeft, (int)backRight);
}
Expand All @@ -633,6 +638,12 @@ public void GetWindowsParameters(out VehicleParameterValue driver, out VehiclePa
GetComponent<NativeVehicle>()
.GetVehicleParamsCarWindows(out var tmpDriver, out var tmpPassenger, out var tmpBackLeft, out var tmpBackRight);

if (tmpDriver != -1) tmpDriver = (tmpDriver == 0 ? 1 : 0);
if (tmpPassenger != -1) tmpPassenger = (tmpPassenger == 0 ? 1 : 0);
if (tmpBackLeft != -1) tmpBackLeft = (tmpBackLeft == 0 ? 1 : 0);
if (tmpBackRight != -1) tmpBackRight = (tmpBackRight == 0 ? 1 : 0);


driver = (VehicleParameterValue)tmpDriver;
passenger = (VehicleParameterValue)tmpPassenger;
backLeft = (VehicleParameterValue)tmpBackLeft;
Expand Down
19 changes: 16 additions & 3 deletions src/SampSharp.GameMode/World/BaseVehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,13 @@ public virtual void SetWindowsParameters(VehicleParameterValue driver, VehiclePa
{
AssertNotDisposed();

VehicleInternal.Instance.SetVehicleParamsCarWindows(Id, (int)driver, (int)passenger, (int)backleft, (int)backright);
if (driver != VehicleParameterValue.Unset) driver = (VehicleParameterValue)(driver == VehicleParameterValue.On ? 0 : 1);
if (passenger != VehicleParameterValue.Unset) passenger = (VehicleParameterValue)(passenger == VehicleParameterValue.On ? 0 : 1);
if (backleft != VehicleParameterValue.Unset) backleft = (VehicleParameterValue)(backleft == VehicleParameterValue.On ? 0 : 1);
if (backright != VehicleParameterValue.Unset) backright = (VehicleParameterValue)(backright == VehicleParameterValue.On ? 0 : 1);


VehicleInternal.Instance.SetVehicleParamsCarWindows(Id,(int)driver,(int)passenger,(int)backleft,(int)backright);
}

/// <summary>Gets the windows parameters.</summary>
Expand All @@ -784,8 +790,15 @@ public virtual void GetWindowsParameters(out VehicleParameterValue driver, out V
AssertNotDisposed();
VehicleInternal.Instance.GetVehicleParamsCarWindows(Id, out var tmpDriver, out var tmpPassenger, out var tmpBackleft, out var tmpBackright);

driver = (VehicleParameterValue)tmpDriver;
passenger = (VehicleParameterValue)tmpPassenger;
if (tmpDriver != -1) tmpDriver = (tmpDriver == 0 ? 1 : 0);
if (tmpPassenger != -1) tmpPassenger = (tmpPassenger == 0 ? 1 : 0);
if (tmpBackleft != -1) tmpBackleft = (tmpBackleft == 0 ? 1 : 0);
if (tmpBackright != -1) tmpBackright = (tmpBackright == 0 ? 1 : 0);



driver = (VehicleParameterValue) tmpDriver;
passenger = (VehicleParameterValue)tmpPassenger;
backleft = (VehicleParameterValue)tmpBackleft;
backright = (VehicleParameterValue)tmpBackright;
}
Expand Down