Skip to content

Commit

Permalink
Update broken references
Browse files Browse the repository at this point in the history
  • Loading branch information
Reousa committed Jan 15, 2024
1 parent e3561a0 commit 5729f38
Show file tree
Hide file tree
Showing 34 changed files with 119 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ protected override void ProcessPacket(ChatCommandWhisperPacket packet, NebulaCon
}

// second case, relay message to recipient
var recipient = Multiplayer.Session.Network
.PlayerManager.GetConnectedPlayerByUsername(packet.RecipientUsername);
var recipient = Players.Get(packet.RecipientUsername);
if (recipient == null)
{
Log.Warn($"Recipient not found {packet.RecipientUsername}");
var sender = Multiplayer.Session.Network.PlayerManager.GetPlayer(conn);
var sender = Players.Get(conn);
sender.SendPacket(new ChatCommandWhisperPacket("SYSTEM".Translate(), packet.SenderUsername,
string.Format("User not found {0}".Translate(), packet.RecipientUsername)));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void ProcessPacket(ChatCommandWhoPacket packet, NebulaConnect
{
if (IsHost)
{
var recipient = Multiplayer.Session.Network.PlayerManager.GetPlayer(conn);
var recipient = Players.Get(conn);
var playerDatas = Multiplayer.Session.Server.Players.GetAllPlayerData().ToArray();
var hostPlayer = Multiplayer.Session.LocalPlayer;
var resultPayload = WhoCommandHandler.BuildResultPayload(playerDatas, hostPlayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ protected override void ProcessPacket(NewChatMessagePacket packet, NebulaConnect

if (IsHost)
{
var player = Multiplayer.Session.Network.PlayerManager?.GetPlayer(conn);
Multiplayer.Session.Network.PlayerManager?.SendPacketToOtherPlayers(packet, player);
var player = Players.Get(conn);
Server.SendPacketExclude(packet, conn);
}

var sentAt = packet.SentAt == 0 ? DateTime.Now : DateTime.FromBinary(packet.SentAt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private string Login(NebulaConnection conn, string passwordHash)
return string.Format("Cooldown: {0}s".Translate(), cdtime);
}
LastLoginTime = DateTime.Now;
var playerData = Multiplayer.Session.Network.PlayerManager.GetPlayer(conn)?.Data;
var playerData = Players.Get(conn)?.Data;
var salt = playerData != null ? playerData.Username + playerData.PlayerId : "";
var hash = CryptoUtils.Hash(Config.Options.RemoteAccessPassword + salt);
if (hash != passwordHash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ namespace NebulaNetwork.PacketProcessors.GameHistory;
[RegisterPacketProcessor]
internal class GameHistoryEnqueueTechProcessor : PacketProcessor<GameHistoryEnqueueTechPacket>
{
private readonly IPlayerManager playerManager;

public GameHistoryEnqueueTechProcessor()
{
playerManager = Multiplayer.Session.Network.PlayerManager;
}

protected override void ProcessPacket(GameHistoryEnqueueTechPacket packet, NebulaConnection conn)
{
if (IsHost)
{
var player = playerManager.GetPlayer(conn);
var player = Players.Get(conn);
if (player == null)
{
return;
Expand All @@ -34,7 +31,7 @@ protected override void ProcessPacket(GameHistoryEnqueueTechPacket packet, Nebul
{
GameMain.history.EnqueueTech(packet.TechId);
}
playerManager.SendPacketToOtherPlayers(packet, player);
Server.SendPacketExclude(packet, conn);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@ namespace NebulaNetwork.PacketProcessors.GameHistory;
[RegisterPacketProcessor]
internal class GameHistoryRemoveTechProcessor : PacketProcessor<GameHistoryRemoveTechPacket>
{
private readonly IPlayerManager playerManager;

public GameHistoryRemoveTechProcessor()
{
playerManager = Multiplayer.Session.Network.PlayerManager;
}

protected override void ProcessPacket(GameHistoryRemoveTechPacket packet, NebulaConnection conn)
{
var valid = true;
if (IsHost)
{
var player = playerManager.GetPlayer(conn);
var player = Players.Get(conn);
if (player != null)
{
playerManager.SendPacketToOtherPlayers(packet, player);
Server.SendPacketExclude(packet, conn);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using NebulaAPI.GameState;
using NebulaAPI.Networking;
using NebulaAPI.Packets;
using NebulaModel.Networking;
using NebulaModel.Packets;
Expand All @@ -20,16 +21,14 @@ namespace NebulaNetwork.PacketProcessors.Logistics;
[RegisterPacketProcessor]
internal class ILSArriveStarPlanetRequestProcessor : PacketProcessor<ILSArriveStarPlanetRequest>
{
private readonly IPlayerManager playerManager = Multiplayer.Session.Network.PlayerManager;

protected override void ProcessPacket(ILSArriveStarPlanetRequest packet, NebulaConnection conn)
{
if (IsClient)
{
return;
}

var player = playerManager.GetPlayer(conn) ?? playerManager.GetSyncingPlayer(conn);
var player = Players.Get(conn, EConnectionStatus.Connected) ?? Players.Get(conn, EConnectionStatus.Syncing);
if (player == null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using NebulaAPI.DataStructures;
using NebulaAPI.GameState;
using NebulaAPI.Networking;
using NebulaAPI.Packets;
using NebulaModel.Networking;
using NebulaModel.Packets;
Expand All @@ -22,21 +23,20 @@ namespace NebulaNetwork.PacketProcessors.Logistics;
[RegisterPacketProcessor]
public class ILSRequestShipDockProcessor : PacketProcessor<ILSRequestShipDock>
{
private readonly IPlayerManager playerManager = Multiplayer.Session.Network.PlayerManager;

protected override void ProcessPacket(ILSRequestShipDock packet, NebulaConnection conn)
{
if (IsClient)
{
return;
}

var player = playerManager.GetPlayer(conn) ?? playerManager.GetSyncingPlayer(conn);
var player = Players.Get(conn, EConnectionStatus.Connected) ?? Players.Get(conn, EConnectionStatus.Syncing);

if (player == null || GameMain.data.galacticTransport.stationCapacity <= packet.StationGId)
{
return;
}

var shipOtherGId = new List<int>();
var shipIndex = new List<int>();
var shipPos = new List<Double3>();
Expand All @@ -51,6 +51,7 @@ protected override void ProcessPacket(ILSRequestShipDock packet, NebulaConnectio
{
continue;
}

var shipData = GameMain.data.galacticTransport.stationPool[i].workShipDatas;

for (var j = 0; j < shipData.Length; j++)
Expand All @@ -59,6 +60,7 @@ protected override void ProcessPacket(ILSRequestShipDock packet, NebulaConnectio
{
continue;
}

shipOtherGId.Add(shipData[j].otherGId);
shipIndex.Add(j);
shipPos.Add(new Double3(shipData[j].uPos.x, shipData[j].uPos.y, shipData[j].uPos.z));
Expand All @@ -68,6 +70,7 @@ protected override void ProcessPacket(ILSRequestShipDock packet, NebulaConnectio
shipPRotTemp.Add(new Float4(shipData[j].pRotTemp));
}
}

// also add add ships of current station as they use the dock pos too in the pos calculation
// NOTE: we need to set this stations gid as otherStationGId so that the client accesses the array in the right way
var shipData2 = GameMain.data.galacticTransport.stationPool[packet.StationGId].workShipDatas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using NebulaAPI.DataStructures;
using NebulaAPI.GameState;
using NebulaAPI.Networking;
using NebulaAPI.Packets;
using NebulaModel.Networking;
using NebulaModel.Packets;
Expand All @@ -21,16 +22,14 @@ namespace NebulaNetwork.PacketProcessors.Logistics;
[RegisterPacketProcessor]
public class ILSgStationPoolSyncRequestProcessor : PacketProcessor<ILSRequestgStationPoolSync>
{
private readonly IPlayerManager playerManager = Multiplayer.Session.Network.PlayerManager;

protected override void ProcessPacket(ILSRequestgStationPoolSync packet, NebulaConnection conn)
{
if (IsClient)
{
return;
}

var player = playerManager.GetPlayer(conn) ?? playerManager.GetSyncingPlayer(conn);
var player = Players.Get(conn, EConnectionStatus.Connected) ?? Players.Get(conn, EConnectionStatus.Syncing);
if (player == null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ protected override void ProcessPacket(StationUI packet, NebulaConnection conn)
StationUIManager.UpdateStation(ref packet);

// broadcast to other clients
var playerManager = Multiplayer.Session.Network.PlayerManager;
var player = playerManager.GetPlayer(conn);
playerManager.SendPacketToOtherPlayers(packet, player);
var player = Players.Get(conn);
Server.SendPacketExclude(packet, conn);

// as we block the normal method for the client he must run it once he receives this packet.
// but only the one issued the request should get items refund
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ namespace NebulaNetwork.PacketProcessors.Logistics;
[RegisterPacketProcessor]
internal class StorageUIProcessor : PacketProcessor<StorageUI>
{
private readonly IPlayerManager playerManager = Multiplayer.Session.Network.PlayerManager;

protected override void ProcessPacket(StorageUI packet, NebulaConnection conn)
{
if (IsHost)
Expand All @@ -25,8 +23,8 @@ protected override void ProcessPacket(StorageUI packet, NebulaConnection conn)
Multiplayer.Session.StationsUI.UpdateStorage(packet);

// broadcast to other clients
var player = playerManager.GetPlayer(conn);
playerManager.SendPacketToOtherPlayers(packet, player);
var player = Players.Get(conn);
Server.SendPacketExclude(packet, conn);

// as we block some methods for the client he must run it once he receives this packet.
// but only the one issued the request should get items refund
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ namespace NebulaNetwork.PacketProcessors.Players;
[RegisterPacketProcessor]
public class PlayerMechaArmorProcessor : PacketProcessor<PlayerMechaArmor>
{
private readonly IPlayerManager playerManager = Multiplayer.Session.Network.PlayerManager;

protected override void ProcessPacket(PlayerMechaArmor packet, NebulaConnection conn)
{
INebulaPlayer player = null;
if (IsHost)
{
// broadcast to other players
player = playerManager.GetPlayer(conn);
player = Players.Get(conn);
if (player != null)
{
playerManager.SendPacketToOtherPlayers(packet, player);
Server.SendPacketExclude(packet, conn);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ namespace NebulaNetwork.PacketProcessors.Players;
[RegisterPacketProcessor]
public class PlayerMechaDIYArmorProcessor : PacketProcessor<PlayerMechaDIYArmor>
{
private readonly IPlayerManager playerManager = Multiplayer.Session.Network.PlayerManager;

protected override void ProcessPacket(PlayerMechaDIYArmor packet, NebulaConnection conn)
{
// store DIYAppearance and items to serve them when player connects again
if (IsHost)
{
using var reader = new BinaryUtils.Reader(packet.DIYAppearanceData);
var player = playerManager.GetPlayer(conn);
var player = Players.Get(conn);
if (player == null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override void ProcessPacket(PlayerMechaStat packet, NebulaConnection c
return;
}

var player = Multiplayer.Session.Network.PlayerManager.GetPlayer(conn);
var player = Players.Get(conn);
if (player == null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ namespace NebulaNetwork.PacketProcessors.Players;
[RegisterPacketProcessor]
public class PlayerMovementProcessor : PacketProcessor<PlayerMovement>
{
private readonly IPlayerManager playerManager;

public PlayerMovementProcessor()
{
playerManager = Multiplayer.Session.Network.PlayerManager;
}

protected override void ProcessPacket(PlayerMovement packet, NebulaConnection conn)
{
var valid = true;
if (IsHost)
{
var player = playerManager.GetPlayer(conn);
var player = Players.Get(conn);
if (player != null)
{
player.Data.LocalPlanetId = packet.LocalPlanetId;
Expand All @@ -35,7 +32,7 @@ protected override void ProcessPacket(PlayerMovement packet, NebulaConnection co
player.Data.BodyRotation = packet.BodyRotation;
player.Data.LocalPlanetPosition = packet.LocalPlanetPosition;

playerManager.SendPacketToOtherPlayers(packet, player);
Server.SendPacketExclude(packet, conn);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ namespace NebulaNetwork.PacketProcessors.Players;
[RegisterPacketProcessor]
internal class PlayerUpdateLocalStarIdProcessor : PacketProcessor<PlayerUpdateLocalStarId>
{
private readonly IPlayerManager playerManager;

public PlayerUpdateLocalStarIdProcessor()
{
playerManager = Multiplayer.Session.Network.PlayerManager;
}

protected override void ProcessPacket(PlayerUpdateLocalStarId packet, NebulaConnection conn)
Expand All @@ -28,7 +25,7 @@ protected override void ProcessPacket(PlayerUpdateLocalStarId packet, NebulaConn
return;
}

var player = playerManager.GetPlayer(conn);
var player = Players.Get(conn);
if (player != null)
{
player.Data.LocalStarId = packet.StarId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override void ProcessPacket(RemoveDroneOrdersPacket packet, NebulaConn
// host needs to remove targets from DroneManager
// but he also needs to RecycleDrone any rendered drone of this player
// and as clients only send this when they are unable to handle a NewDroneOrder the host should search for the next closest player to ask for construction.
var player = Multiplayer.Session.Network.PlayerManager.GetPlayer(conn);
var player = Players.Get(conn);
var factory = GameMain.galaxy.PlanetById(player.Data.LocalPlanetId)?.factory;
Vector3 vector;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ namespace NebulaNetwork.PacketProcessors.Routers;
[RegisterPacketProcessor]
internal class PlanetBroadcastProcessor : PacketProcessor<PlanetBroadcastPacket>
{
private readonly IPlayerManager playerManager;

public PlanetBroadcastProcessor()
{
playerManager = Multiplayer.Session.Network.PlayerManager;
}

protected override void ProcessPacket(PlanetBroadcastPacket packet, NebulaConnection conn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ namespace NebulaNetwork.PacketProcessors.Routers;
[RegisterPacketProcessor]
internal class StarBroadcastProcessor: PacketProcessor<StarBroadcastPacket>
{
private readonly IPlayerManager playerManager;

public StarBroadcastProcessor()
{
playerManager = Multiplayer.Session.Network.PlayerManager;
}

protected override void ProcessPacket(StarBroadcastPacket packet, NebulaConnection conn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,20 @@ namespace NebulaNetwork.PacketProcessors.Session;
[RegisterPacketProcessor]
public class HandshakeRequestProcessor : PacketProcessor<HandshakeRequest>
{
private readonly IPlayerManager playerManager = Multiplayer.Session.Network.PlayerManager;

protected override void ProcessPacket(HandshakeRequest packet, NebulaConnection conn)
{
if (IsClient)
{
return;
}

using (playerManager.GetPendingPlayers(out var pendingPlayers))
var pendingPlayer = Players.Get(conn, EConnectionStatus.Pending);
if (pendingPlayer is null)
{
if (!pendingPlayers.TryGetValue(conn, out _))
{
Multiplayer.Session.Server.Disconnect(conn, DisconnectionReason.InvalidData);
Log.Warn(
"WARNING: Player tried to handshake without being in the pending list. And he uses an outdated nebula version.");
return;
}
Multiplayer.Session.Server.Disconnect(conn, DisconnectionReason.InvalidData);
Log.Warn(
"WARNING: Player tried to handshake without being in the pending list. And he uses an outdated nebula version.");
return;
}

Multiplayer.Session.Server.Disconnect(conn, DisconnectionReason.ModVersionMismatch, "Nebula;0.7.7 or earlier;0.7.8 or greater");
Expand Down
Loading

0 comments on commit 5729f38

Please sign in to comment.