Unused variables removed. MasterServer connection updated
This commit is contained in:
parent
d64281e582
commit
474cba33fa
@ -274,7 +274,7 @@ namespace CoopClient
|
||||
/// otherwise it will align right
|
||||
/// </summary>
|
||||
/// <param name="leftAlign"></param>
|
||||
public static void SetPlayerListLeftAlign( bool leftAlign )
|
||||
public static void SetPlayerListLeftAlign(bool leftAlign)
|
||||
{
|
||||
PlayerList.LeftAlign = leftAlign;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ namespace CoopClient.Entities.NPC
|
||||
internal Dictionary<byte, short> Clothes { get; set; }
|
||||
|
||||
internal Vector3 Position { get; set; }
|
||||
internal Vector3 Velocity { get; set; }
|
||||
internal Vector3 AimCoords { get; set; }
|
||||
|
||||
internal void DisplayLocally()
|
||||
|
@ -8,15 +8,11 @@ namespace CoopClient.Entities.NPC
|
||||
{
|
||||
internal partial class EntitiesNPC
|
||||
{
|
||||
#region -- ON FOOT --
|
||||
#region -- VARIABLES --
|
||||
/// <summary>
|
||||
/// The latest character rotation (may not have been applied yet)
|
||||
/// </summary>
|
||||
public Vector3 Rotation { get; internal set; }
|
||||
/// <summary>
|
||||
/// The latest character velocity (may not have been applied yet)
|
||||
/// </summary>
|
||||
public Vector3 Velocity { get; internal set; }
|
||||
internal byte Speed { get; set; }
|
||||
private bool LastIsJumping = false;
|
||||
internal bool IsJumping { get; set; }
|
||||
|
@ -25,18 +25,7 @@ namespace CoopClient.Entities.NPC
|
||||
internal short VehicleSeatIndex { get; set; }
|
||||
internal Vehicle MainVehicle { get; set; }
|
||||
internal Quaternion VehicleRotation { get; set; }
|
||||
internal Vector3 VehicleVelocity { get; set; }
|
||||
private float LastVehicleSpeed { get; set; }
|
||||
private float CurrentVehicleSpeed { get; set; }
|
||||
internal float VehicleSpeed
|
||||
{
|
||||
get => CurrentVehicleSpeed;
|
||||
set
|
||||
{
|
||||
LastVehicleSpeed = CurrentVehicleSpeed;
|
||||
CurrentVehicleSpeed = value;
|
||||
}
|
||||
}
|
||||
internal float VehicleSpeed { get; set; }
|
||||
internal float VehicleSteeringAngle { get; set; }
|
||||
internal bool VehIsEngineRunning { get; set; }
|
||||
internal float VehRPM { get; set; }
|
||||
@ -134,15 +123,15 @@ namespace CoopClient.Entities.NPC
|
||||
if (Character.IsOnBike && MainVehicle.ClassType == VehicleClass.Cycles)
|
||||
{
|
||||
bool isFastPedaling = Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, Character.Handle, PedalingAnimDict(), "fast_pedal_char", 3);
|
||||
if (CurrentVehicleSpeed < 0.2f)
|
||||
if (VehicleSpeed < 0.2f)
|
||||
{
|
||||
StopPedalingAnim(isFastPedaling);
|
||||
}
|
||||
else if (CurrentVehicleSpeed < 11f && !Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, Character.Handle, PedalingAnimDict(), "cruise_pedal_char", 3))
|
||||
else if (VehicleSpeed < 11f && !Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, Character.Handle, PedalingAnimDict(), "cruise_pedal_char", 3))
|
||||
{
|
||||
StartPedalingAnim(false);
|
||||
}
|
||||
else if (CurrentVehicleSpeed >= 11f && !isFastPedaling)
|
||||
else if (VehicleSpeed >= 11f && !isFastPedaling)
|
||||
{
|
||||
StartPedalingAnim(true);
|
||||
}
|
||||
@ -252,11 +241,11 @@ namespace CoopClient.Entities.NPC
|
||||
}
|
||||
|
||||
// Good enough for now, but we need to create a better sync
|
||||
if (CurrentVehicleSpeed > 0.05f && MainVehicle.IsInRange(Position, 7.0f))
|
||||
if (VehicleSpeed > 0.05f && MainVehicle.IsInRange(Position, 7.0f))
|
||||
{
|
||||
int forceMultiplier = (Game.Player.Character.IsInVehicle() && MainVehicle.IsTouching(Game.Player.Character.CurrentVehicle)) ? 1 : 3;
|
||||
|
||||
MainVehicle.Velocity = VehicleVelocity + forceMultiplier * (Position - MainVehicle.Position);
|
||||
MainVehicle.Velocity = Velocity + forceMultiplier * (Position - MainVehicle.Position);
|
||||
MainVehicle.Quaternion = Quaternion.Slerp(MainVehicle.Quaternion, VehicleRotation, 0.5f);
|
||||
|
||||
VehicleStopTime = Util.GetTickCount64();
|
||||
|
@ -59,6 +59,7 @@ namespace CoopClient.Entities.Player
|
||||
/// The latest character position (may not have been applied yet)
|
||||
/// </summary>
|
||||
public Vector3 Position { get; internal set; }
|
||||
internal Vector3 Velocity { get; set; }
|
||||
internal Blip PedBlip = null;
|
||||
internal Vector3 AimCoords { get; set; }
|
||||
|
||||
|
@ -9,15 +9,11 @@ namespace CoopClient.Entities.Player
|
||||
{
|
||||
public partial class EntitiesPlayer
|
||||
{
|
||||
#region -- ON FOOT --
|
||||
#region -- VARIABLES --
|
||||
/// <summary>
|
||||
/// The latest character rotation (may not have been applied yet)
|
||||
/// </summary>
|
||||
public Vector3 Rotation { get; internal set; }
|
||||
/// <summary>
|
||||
/// The latest character velocity (may not have been applied yet)
|
||||
/// </summary>
|
||||
public Vector3 Velocity { get; internal set; }
|
||||
internal byte Speed { get; set; }
|
||||
private bool LastIsJumping = false;
|
||||
internal bool IsJumping { get; set; }
|
||||
|
@ -13,20 +13,10 @@ namespace CoopClient.Entities.Player
|
||||
private ulong VehicleStopTime { get; set; }
|
||||
|
||||
internal bool IsInVehicle { get; set; }
|
||||
private int LastVehicleModelHash = 0;
|
||||
private int CurrentVehicleModelHash = 0;
|
||||
/// <summary>
|
||||
/// The latest vehicle model hash (may not have been applied yet)
|
||||
/// </summary>
|
||||
public int VehicleModelHash
|
||||
{
|
||||
get => CurrentVehicleModelHash;
|
||||
internal set
|
||||
{
|
||||
LastVehicleModelHash = CurrentVehicleModelHash == 0 ? value : CurrentVehicleModelHash;
|
||||
CurrentVehicleModelHash = value;
|
||||
}
|
||||
}
|
||||
public int VehicleModelHash { get; internal set; }
|
||||
private byte[] LastVehicleColors = new byte[] { 0, 0 };
|
||||
internal byte[] VehicleColors { get; set; }
|
||||
private Dictionary<int, int> LastVehicleMods = new Dictionary<int, int>();
|
||||
@ -42,18 +32,7 @@ namespace CoopClient.Entities.Player
|
||||
/// The latest vehicle rotation (may not have been applied yet)
|
||||
/// </summary>
|
||||
public Quaternion VehicleRotation { get; internal set; }
|
||||
internal Vector3 VehicleVelocity { get; set; }
|
||||
private float LastVehicleSpeed { get; set; }
|
||||
private float CurrentVehicleSpeed { get; set; }
|
||||
internal float VehicleSpeed
|
||||
{
|
||||
get => CurrentVehicleSpeed;
|
||||
set
|
||||
{
|
||||
LastVehicleSpeed = CurrentVehicleSpeed;
|
||||
CurrentVehicleSpeed = value;
|
||||
}
|
||||
}
|
||||
internal float VehicleSpeed { get; set; }
|
||||
internal float VehicleSteeringAngle { get; set; }
|
||||
private int LastVehicleAim;
|
||||
internal bool VehIsEngineRunning { get; set; }
|
||||
@ -73,11 +52,11 @@ namespace CoopClient.Entities.Player
|
||||
|
||||
private void DisplayInVehicle()
|
||||
{
|
||||
if (MainVehicle == null || !MainVehicle.Exists() || MainVehicle.Model.Hash != CurrentVehicleModelHash)
|
||||
if (MainVehicle == null || !MainVehicle.Exists() || MainVehicle.Model.Hash != VehicleModelHash)
|
||||
{
|
||||
bool vehFound = false;
|
||||
|
||||
Vehicle targetVehicle = World.GetClosestVehicle(Position, 7f, new Model[] { CurrentVehicleModelHash });
|
||||
Vehicle targetVehicle = World.GetClosestVehicle(Position, 7f, new Model[] { VehicleModelHash });
|
||||
|
||||
if (targetVehicle != null)
|
||||
{
|
||||
@ -90,7 +69,7 @@ namespace CoopClient.Entities.Player
|
||||
|
||||
if (!vehFound)
|
||||
{
|
||||
Model vehicleModel = CurrentVehicleModelHash.ModelRequest();
|
||||
Model vehicleModel = VehicleModelHash.ModelRequest();
|
||||
if (vehicleModel == null)
|
||||
{
|
||||
//GTA.UI.Notification.Show($"~r~(Vehicle)Model ({CurrentVehicleModelHash}) cannot be loaded!");
|
||||
@ -157,15 +136,15 @@ namespace CoopClient.Entities.Player
|
||||
if (Character.IsOnBike && MainVehicle.ClassType == VehicleClass.Cycles)
|
||||
{
|
||||
bool isFastPedaling = Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, Character.Handle, PedalingAnimDict(), "fast_pedal_char", 3);
|
||||
if (CurrentVehicleSpeed < 0.2f)
|
||||
if (VehicleSpeed < 0.2f)
|
||||
{
|
||||
StopPedalingAnim(isFastPedaling);
|
||||
}
|
||||
else if (CurrentVehicleSpeed < 11f && !Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, Character.Handle, PedalingAnimDict(), "cruise_pedal_char", 3))
|
||||
else if (VehicleSpeed < 11f && !Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, Character.Handle, PedalingAnimDict(), "cruise_pedal_char", 3))
|
||||
{
|
||||
StartPedalingAnim(false);
|
||||
}
|
||||
else if (CurrentVehicleSpeed >= 11f && !isFastPedaling)
|
||||
else if (VehicleSpeed >= 11f && !isFastPedaling)
|
||||
{
|
||||
StartPedalingAnim(true);
|
||||
}
|
||||
@ -275,11 +254,11 @@ namespace CoopClient.Entities.Player
|
||||
}
|
||||
|
||||
// Good enough for now, but we need to create a better sync
|
||||
if (CurrentVehicleSpeed > 0.05f && MainVehicle.IsInRange(Position, 7.0f))
|
||||
if (VehicleSpeed > 0.05f && MainVehicle.IsInRange(Position, 7.0f))
|
||||
{
|
||||
int forceMultiplier = (Game.Player.Character.IsInVehicle() && MainVehicle.IsTouching(Game.Player.Character.CurrentVehicle)) ? 1 : 3;
|
||||
|
||||
MainVehicle.Velocity = VehicleVelocity + forceMultiplier * (Position - MainVehicle.Position);
|
||||
MainVehicle.Velocity = Velocity + forceMultiplier * (Position - MainVehicle.Position);
|
||||
MainVehicle.Quaternion = Quaternion.Slerp(MainVehicle.Quaternion, VehicleRotation, 0.5f);
|
||||
|
||||
VehicleStopTime = Util.GetTickCount64();
|
||||
@ -306,7 +285,7 @@ namespace CoopClient.Entities.Player
|
||||
|
||||
private string PedalingAnimDict()
|
||||
{
|
||||
switch ((VehicleHash)CurrentVehicleModelHash)
|
||||
switch ((VehicleHash)VehicleModelHash)
|
||||
{
|
||||
case VehicleHash.Bmx:
|
||||
return "veh@bicycle@bmx@front@base";
|
||||
|
@ -210,7 +210,6 @@ namespace CoopClient
|
||||
ulong currentTimestamp = Util.GetTickCount64();
|
||||
PlayerList.Pressed = (currentTimestamp - PlayerList.Pressed) < 5000 ? (currentTimestamp - 6000) : currentTimestamp;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (Game.IsControlJustPressed(GTA.Control.MpTextChatAll))
|
||||
{
|
||||
@ -218,7 +217,6 @@ namespace CoopClient
|
||||
{
|
||||
MainChat.Focused = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -239,7 +237,6 @@ namespace CoopClient
|
||||
ulong currentTimestamp = Util.GetTickCount64();
|
||||
PlayerList.Pressed = (currentTimestamp - PlayerList.Pressed) < 5000 ? (currentTimestamp - 6000) : currentTimestamp;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (Game.IsControlJustPressed(GTA.Control.MpTextChatAll))
|
||||
{
|
||||
@ -247,7 +244,6 @@ namespace CoopClient
|
||||
{
|
||||
MainChat.Focused = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -399,7 +395,7 @@ namespace CoopClient
|
||||
DebugSyncPed.VehicleRotation = veh.Quaternion;
|
||||
DebugSyncPed.VehicleEngineHealth = veh.EngineHealth;
|
||||
DebugSyncPed.VehRPM = veh.CurrentRPM;
|
||||
DebugSyncPed.VehicleVelocity = veh.Velocity;
|
||||
DebugSyncPed.Velocity = veh.Velocity;
|
||||
DebugSyncPed.VehicleSpeed = veh.Speed;
|
||||
DebugSyncPed.VehicleSteeringAngle = veh.SteeringAngle;
|
||||
DebugSyncPed.AimCoords = veh.IsTurretSeat((int)player.SeatIndex) ? Util.GetVehicleAimCoords() : new GTA.Math.Vector3();
|
||||
|
@ -526,7 +526,7 @@ namespace CoopClient
|
||||
player.VehicleRotation = packet.VehRotation.ToQuaternion();
|
||||
player.VehicleEngineHealth = packet.VehEngineHealth;
|
||||
player.VehRPM = packet.VehRPM;
|
||||
player.VehicleVelocity = packet.VehVelocity.ToVector();
|
||||
player.Velocity = packet.VehVelocity.ToVector();
|
||||
player.VehicleSpeed = packet.VehSpeed;
|
||||
player.VehicleSteeringAngle = packet.VehSteeringAngle;
|
||||
player.AimCoords = packet.VehAimCoords.ToVector();
|
||||
@ -593,7 +593,7 @@ namespace CoopClient
|
||||
player.VehicleSeatIndex = packet.VehSeatIndex;
|
||||
player.Position = packet.Position.ToVector();
|
||||
player.VehicleRotation = packet.VehRotation.ToQuaternion();
|
||||
player.VehicleVelocity = packet.VehVelocity.ToVector();
|
||||
player.Velocity = packet.VehVelocity.ToVector();
|
||||
player.VehicleSpeed = packet.VehSpeed;
|
||||
player.VehicleSteeringAngle = packet.VehSteeringAngle;
|
||||
player.AimCoords = packet.AimCoords.ToVector();
|
||||
@ -829,7 +829,7 @@ namespace CoopClient
|
||||
npc.VehicleRotation = packet.VehRotation.ToQuaternion();
|
||||
npc.VehicleEngineHealth = packet.VehEngineHealth;
|
||||
npc.VehRPM = packet.VehRPM;
|
||||
npc.VehicleVelocity = packet.VehVelocity.ToVector();
|
||||
npc.Velocity = packet.VehVelocity.ToVector();
|
||||
npc.VehicleSpeed = packet.VehSpeed;
|
||||
npc.VehicleSteeringAngle = packet.VehSteeringAngle;
|
||||
npc.VehicleColors = packet.VehColors;
|
||||
@ -864,7 +864,7 @@ namespace CoopClient
|
||||
VehicleRotation = packet.VehRotation.ToQuaternion(),
|
||||
VehicleEngineHealth = packet.VehEngineHealth,
|
||||
VehRPM = packet.VehRPM,
|
||||
VehicleVelocity = packet.VehVelocity.ToVector(),
|
||||
Velocity = packet.VehVelocity.ToVector(),
|
||||
VehicleSpeed = packet.VehSpeed,
|
||||
VehicleSteeringAngle = packet.VehSteeringAngle,
|
||||
VehicleColors = packet.VehColors,
|
||||
|
@ -19,7 +19,7 @@ namespace CoopClient
|
||||
private ulong LastUpdate = Util.GetTickCount64();
|
||||
internal static ulong Pressed { get; set; }
|
||||
|
||||
public static bool LeftAlign = true;
|
||||
internal static bool LeftAlign = true;
|
||||
|
||||
/// <summary>
|
||||
/// Don't use it!
|
||||
@ -56,7 +56,7 @@ namespace CoopClient
|
||||
)
|
||||
{
|
||||
Function.Call(Hash.DRAW_SCALEFORM_MOVIE, MainScaleform.Handle,
|
||||
LeftAlign? LEFT_POSITION:RIGHT_POSITION, 0.3f,
|
||||
LeftAlign ? LEFT_POSITION : RIGHT_POSITION, 0.3f,
|
||||
0.28f, 0.6f,
|
||||
255, 255, 255, 255, 0);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ namespace CoopServer
|
||||
|
||||
try
|
||||
{
|
||||
string data = await httpClient.GetStringAsync("https://wimip.info/json");
|
||||
string data = await httpClient.GetStringAsync("https://ipinfo.io/json");
|
||||
|
||||
info = JsonConvert.DeserializeObject<IpInfo>(data);
|
||||
}
|
||||
@ -103,8 +103,6 @@ namespace CoopServer
|
||||
info = new() { ip = MainNetServer.Configuration.LocalAddress.ToString(), country = "?" };
|
||||
}
|
||||
|
||||
byte errorCounter = 3;
|
||||
|
||||
while (!Program.ReadyToStop)
|
||||
{
|
||||
string msg =
|
||||
@ -133,7 +131,7 @@ namespace CoopServer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Error(ex.Message);
|
||||
Logging.Error($"MasterServer: {ex.Message}");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -141,21 +139,11 @@ namespace CoopServer
|
||||
{
|
||||
Logging.Error($"MasterServer: [{(int)response.StatusCode}]{response.StatusCode}");
|
||||
|
||||
if (errorCounter != 0)
|
||||
{
|
||||
Logging.Error($"MasterServer: Remaining attempts {errorCounter--} ...");
|
||||
|
||||
// Wait 5 seconds before trying again
|
||||
Thread.Sleep(5000);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
// Wait 5 seconds before trying again
|
||||
Thread.Sleep(5000);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Reset errorCounter
|
||||
errorCounter = 3;
|
||||
|
||||
// Sleep for 12.5s
|
||||
Thread.Sleep(12500);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user