CleanUp() removed

This commit is contained in:
EntenKoeniq
2021-11-28 22:57:39 +01:00
parent 2836953d89
commit 12a2ddf625
5 changed files with 14 additions and 20 deletions

View File

@ -11,7 +11,7 @@ namespace CoopClient.Entities
public EntitiesThread()
{
Tick += OnTick;
Interval = (int)(1f / (Game.FPS > 60f ? 60f : Game.FPS) * 1000f);
Interval = Util.GetGameMs<int>();
}
private void OnTick(object sender, EventArgs e)

View File

@ -62,6 +62,8 @@ namespace CoopClient
{
RelationshipGroup = World.AddRelationshipGroup("SYNCPED");
Game.Player.Character.RelationshipGroup = RelationshipGroup;
GTA.UI.Notification.Show(GTA.UI.NotificationIcon.AllPlayersConf, "GTACOOP:R", "Welcome!", "Press ~g~F9~s~ to open the menu.");
}
#if !NON_INTERACTIVE
@ -104,7 +106,7 @@ namespace CoopClient
}
#endif
if ((Util.GetTickCount64() - LastDataSend) < ((ulong)(1f / (Game.FPS > 60f ? 60f : Game.FPS) * 1000f)))
if ((Util.GetTickCount64() - LastDataSend) < Util.GetGameMs<ulong>())
{
return;
}
@ -203,17 +205,6 @@ namespace CoopClient
Npc.Value.Character?.Delete();
}
Npcs.Clear();
foreach (Ped entity in World.GetAllPeds().Where(p => p.Handle != Game.Player.Character.Handle))
{
entity.Kill();
entity.Delete();
}
foreach (Vehicle veh in World.GetAllVehicles().Where(v => v.Handle != Game.Player.Character.CurrentVehicle?.Handle))
{
veh.Delete();
}
}
#if DEBUG

View File

@ -114,12 +114,6 @@ namespace CoopClient
Main.LocalClientID = handshakePacket.ID;
Main.NpcsAllowed = handshakePacket.NpcsAllowed;
Main.CleanUp();
Function.Call(Hash.SET_GARBAGE_TRUCKS, 0);
Function.Call(Hash.SET_RANDOM_BOATS, 0);
Function.Call(Hash.SET_RANDOM_TRAINS, 0);
Main.MainChat.Init();
// Send player connect packet
@ -153,6 +147,7 @@ namespace CoopClient
}
Main.CleanUp();
#if !NON_INTERACTIVE
Main.MainMenu.DisconnectedMenuSetting();
#endif
@ -244,6 +239,9 @@ namespace CoopClient
case NetIncomingMessageType.ErrorMessage:
case NetIncomingMessageType.WarningMessage:
case NetIncomingMessageType.VerboseDebugMessage:
#if DEBUG
// TODO?
#endif
break;
default:
break;

View File

@ -47,6 +47,11 @@ namespace CoopClient
}
#endregion
public static T GetGameMs<T>() where T : IConvertible
{
return (T)Convert.ChangeType(1f / (Game.FPS > 60f ? 60f : Game.FPS) * 1000f, typeof(T));
}
public static Model ModelRequest(this int hash)
{
Model model = new Model(hash);

View File

@ -13,7 +13,7 @@ namespace CoopClient
public WorldThread()
{
Tick += OnTick;
Interval = (int)(1f / (Game.FPS > 60f ? 60f : Game.FPS) * 1000f);
Interval = Util.GetGameMs<int>();
Aborted += (sender, e) =>
{
if (LastDisableTraffic)