Skip to content

Commit

Permalink
Client: Nakama integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Makkkkus committed Jul 9, 2023
1 parent 0769721 commit 1850572
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 91 deletions.
1 change: 1 addition & 0 deletions OpenHellion/Networking/GSConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal void Start(int port)
ReceiveQueueLimit = 1000
#if DEBUG || HELLION_SP
,SendTimeout = 0
,ReceiveTimeout = 0
#endif
};

Expand Down
10 changes: 5 additions & 5 deletions OpenHellion/Networking/NetworkController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void LogInRequestListener(NetworkData data)
// TODO: Ignoring this for now.
if (req.ClientHash != Server.CombinedHash)
{
Dbg.Warning("Server/client hash mismatch.", req.ServerID, ServerID);
Dbg.Info("Server/client hash mismatch.", req.ServerID, ServerID);
SendToGameClient(req.Sender, new LogInResponse
{
Response = ResponseResult.ClientVersionError
Expand All @@ -146,7 +146,7 @@ public void LogInRequestListener(NetworkData data)
#if !HELLION_SP
if (req.ServerID != ServerID)
{
Dbg.Warning("LogInRequest server ID doesn't match this server ID.", req.ServerID, ServerID);
Dbg.Info("LogInRequest server ID doesn't match this server ID.", req.ServerID, ServerID);
SendToGameClient(req.Sender, new LogInResponse
{
Response = ResponseResult.Error
Expand All @@ -162,7 +162,7 @@ public void LogInRequestListener(NetworkData data)
// Password check.
if (req.Password != Server.Instance.ServerPassword)
{
Dbg.Warning("LogInRequest server password doesn't match this server's password.", req.ServerID, ServerID);
Dbg.Info("LogInRequest server password doesn't match this server's password.", req.ServerID, ServerID);
SendToGameClient(req.Sender, new LogInResponse
{
Response = ResponseResult.WrongPassword
Expand All @@ -173,7 +173,7 @@ public void LogInRequestListener(NetworkData data)
// Check if player id is valid.
if (!Guid.TryParse(req.PlayerId, out _))
{
Dbg.Warning("Player id isn't valid.", req.ServerID, ServerID);
Dbg.Info("Player id isn't valid.", req.ServerID, ServerID);
SendToGameClient(req.Sender, new LogInResponse
{
Response = ResponseResult.Error
Expand All @@ -184,7 +184,7 @@ public void LogInRequestListener(NetworkData data)
long guid = GUIDFactory.PlayerIdToGuid(req.PlayerId);
if (PatchClient(guid, req.Sender))
{
Server.Instance.LoginPlayer(guid, req.PlayerId, req.NativeId, req.CharacterData);
Server.Instance.LoginPlayer(guid, req.PlayerId, req.CharacterData);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Threading;
using OpenHellion;
using ZeroGravity;
using ZeroGravity.Network;

Expand Down
2 changes: 0 additions & 2 deletions ZeroGravity/Data/AuthorizedPerson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ public class AuthorizedPerson : ISceneData
{
public AuthorizedPersonRank Rank;

public string PlayerNativeId;

public string PlayerId;

public string Name;
Expand Down
2 changes: 0 additions & 2 deletions ZeroGravity/Network/CharacterDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public class CharacterDetails

public string Name;

public string NativeId;

public string PlayerId;

public CharacterTransformData TransformData;
Expand Down
2 changes: 0 additions & 2 deletions ZeroGravity/Network/LogInRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ public class LogInRequest : NetworkData

public string PlayerId;

public string NativeId;

public CharacterData CharacterData;
}
2 changes: 0 additions & 2 deletions ZeroGravity/Network/PlayerOnServerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace ZeroGravity.Network;
[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class PlayerOnServerData
{
public string PlayerNativeId;

public string PlayerId;

public string Name;
Expand Down
4 changes: 2 additions & 2 deletions ZeroGravity/Network/SpawnPointStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public class SpawnPointStats

public string PlayerName;

public string PlayerSteamID;
public string PlayerId;

public bool? PlayerInvite;

public string InvitedPlayerSteamID;
public string InvitedPlayerId;

public string InvitedPlayerName;
}
2 changes: 0 additions & 2 deletions ZeroGravity/Network/VesselSecurityAuthorizedPerson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public class VesselSecurityAuthorizedPerson
{
public AuthorizedPersonRank Rank;

public string PlayerNativeId;

public string PlayerId;

public string Name;
Expand Down
8 changes: 1 addition & 7 deletions ZeroGravity/Objects/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public class Player : SpaceObjectTransferable, IPersistantObject, IAirConsumer

public string Name;

public string NativeId;

public string PlayerId;

public Gender Gender;
Expand Down Expand Up @@ -273,13 +271,12 @@ public float AirQualityDegradationRate

public bool AffectsQuantity => false;

public Player(long guid, Vector3D localPosition, QuaternionD localRotation, string name, string playerId, string nativeId, Gender gender, byte headType, byte hairType, bool addToServerList = true, Player clone = null)
public Player(long guid, Vector3D localPosition, QuaternionD localRotation, string name, string playerId, Gender gender, byte headType, byte hairType, bool addToServerList = true, Player clone = null)
: base(guid, localPosition, localRotation)
{
FakeGuid = GUIDFactory.NextPlayerFakeGUID();
Name = name;
PlayerId = playerId;
NativeId = nativeId;
Gender = gender;
HeadType = headType;
HairType = hairType;
Expand Down Expand Up @@ -1184,7 +1181,6 @@ public CharacterDetails GetDetails(bool checkAlive = false)
Gender = Gender,
HeadType = HeadType,
HairType = HairType,
NativeId = NativeId,
PlayerId = PlayerId,
ParentID = (Parent != null) ? Parent.GUID : (-1),
ParentType = (Parent != null) ? Parent.ObjectType : SpaceObjectType.None,
Expand Down Expand Up @@ -1443,7 +1439,6 @@ public PersistenceObjectData GetPersistenceData()
data.IsAlive = IsAlive;
data.Name = Name;
data.PlayerId = PlayerId;
data.NativeId = NativeId;
data.Gender = Gender;
data.HeadType = HeadType;
data.HairType = HairType;
Expand Down Expand Up @@ -1495,7 +1490,6 @@ public void LoadPersistenceData(PersistenceObjectData persistenceData)
IsAlive = data.IsAlive;
Name = data.Name;
PlayerId = data.PlayerId;
NativeId = data.NativeId;
Gender = data.Gender;
HeadType = data.HeadType;
HairType = data.HairType;
Expand Down
36 changes: 18 additions & 18 deletions ZeroGravity/Objects/ShipSpawnPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ShipSpawnPoint

public bool IsPlayerInSpawnPoint;

public string InvitedPlayerSteamID;
public string InvitedPlayerId;

public string InvitedPlayerName;

Expand Down Expand Up @@ -43,17 +43,17 @@ public SpawnPointStats SetStats(SpawnPointStats stats, Player sender)
}
State = SpawnPointState.Locked;
Player = sender;
if (!Server.Instance.PlayerInviteChanged(this, stats.InvitedPlayerSteamID, stats.InvitedPlayerName, sender))
if (!Server.Instance.PlayerInviteChanged(this, stats.InvitedPlayerId, stats.InvitedPlayerName, sender))
{
return new SpawnPointStats
{
InSceneID = SpawnPointID,
NewState = State,
PlayerGUID = ((Player != null) ? Player.FakeGuid : (-1)),
PlayerName = ((Player != null) ? Player.Name : ""),
PlayerSteamID = ((Player != null) ? Player.PlayerId : ""),
PlayerGUID = (Player is not null) ? Player.FakeGuid : (-1),
PlayerName = (Player is not null) ? Player.Name : "",
PlayerId = (Player is not null) ? Player.PlayerId : "",
InvitedPlayerName = InvitedPlayerName,
InvitedPlayerSteamID = InvitedPlayerSteamID
InvitedPlayerId = InvitedPlayerId
};
}
return null;
Expand All @@ -66,7 +66,7 @@ public SpawnPointStats SetStats(SpawnPointStats stats, Player sender)
{
State = SpawnPointState.Unlocked;
Player = null;
if (InvitedPlayerSteamID.IsNullOrEmpty())
if (InvitedPlayerId.IsNullOrEmpty())
{
return new SpawnPointStats
{
Expand All @@ -85,7 +85,7 @@ public SpawnPointStats SetStats(SpawnPointStats stats, Player sender)
{
Use = true
});
if (InvitedPlayerSteamID.IsNullOrEmpty())
if (InvitedPlayerId.IsNullOrEmpty())
{
return new SpawnPointStats
{
Expand All @@ -108,7 +108,7 @@ public SpawnPointStats SetStats(SpawnPointStats stats, Player sender)
NewState = State,
PlayerGUID = sender.FakeGuid,
PlayerName = sender.Name,
PlayerSteamID = sender.PlayerId
PlayerId = sender.PlayerId
};
}
if (stats.NewState == SpawnPointState.Authorized)
Expand All @@ -129,7 +129,7 @@ public SpawnPointStats SetStats(SpawnPointStats stats, Player sender)
NewState = sender.AuthorizedSpawnPoint.State,
PlayerGUID = sender.FakeGuid,
PlayerName = sender.Name,
PlayerSteamID = sender.PlayerId
PlayerId = sender.PlayerId
});
retMsg.SelfDestructTime = sender.AuthorizedSpawnPoint.Ship.SelfDestructTimer?.Time;
NetworkController.Instance.SendToClientsSubscribedTo(retMsg, -1L, sender.AuthorizedSpawnPoint.Ship);
Expand All @@ -143,7 +143,7 @@ public SpawnPointStats SetStats(SpawnPointStats stats, Player sender)
NewState = State,
PlayerGUID = sender.FakeGuid,
PlayerName = sender.Name,
PlayerSteamID = sender.PlayerId
PlayerId = sender.PlayerId
};
}
}
Expand All @@ -152,9 +152,9 @@ public SpawnPointStats SetStats(SpawnPointStats stats, Player sender)

public void SetInvitation(string id, string name, bool sendMessage)
{
if (!(id == InvitedPlayerSteamID) && (!InvitedPlayerSteamID.IsNullOrEmpty() || !id.IsNullOrEmpty()))
if (!(id == InvitedPlayerId) && (!InvitedPlayerId.IsNullOrEmpty() || !id.IsNullOrEmpty()))
{
InvitedPlayerSteamID = id;
InvitedPlayerId = id;
InvitedPlayerName = name;
if (sendMessage)
{
Expand All @@ -169,12 +169,12 @@ public void SetInvitation(string id, string name, bool sendMessage)
{
InSceneID = SpawnPointID,
NewState = State,
PlayerGUID = ((Player != null) ? Player.FakeGuid : (-1)),
PlayerName = ((Player != null) ? Player.Name : ""),
PlayerSteamID = ((Player != null) ? Player.PlayerId : ""),
PlayerGUID = (Player is not null) ? Player.FakeGuid : (-1),
PlayerName = (Player is not null) ? Player.Name : "",
PlayerId = (Player is not null) ? Player.PlayerId : "",
PlayerInvite = true,
InvitedPlayerName = InvitedPlayerName,
InvitedPlayerSteamID = InvitedPlayerSteamID
InvitedPlayerId = InvitedPlayerId
});
retMsg.SelfDestructTime = Ship.SelfDestructTimer?.Time;
NetworkController.Instance.SendToClientsSubscribedTo(retMsg, -1L, Ship);
Expand Down Expand Up @@ -204,7 +204,7 @@ public void AuthorizePlayerToSpawnPoint(Player pl, bool sendMessage)
NewState = State,
PlayerGUID = Player.FakeGuid,
PlayerName = Player.Name,
PlayerSteamID = Player.PlayerId
PlayerId = Player.PlayerId
});
retMsg.SelfDestructTime = Ship.SelfDestructTimer?.Time;
NetworkController.Instance.SendToClientsSubscribedTo(retMsg, -1L, Ship);
Expand Down
15 changes: 6 additions & 9 deletions ZeroGravity/Objects/SpaceObjectVessel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public ShipSpawnPoint GetPlayerSpawnPoint(Player pl)
{
foreach (ShipSpawnPoint point in SpawnPoints)
{
if ((point.Player == null && point.Type == SpawnPointType.SimpleSpawn) || point.Player == pl || point.InvitedPlayerSteamID == pl.PlayerId)
if ((point.Player == null && point.Type == SpawnPointType.SimpleSpawn) || point.Player == pl || point.InvitedPlayerId == pl.PlayerId)
{
return point;
}
Expand Down Expand Up @@ -745,7 +745,7 @@ public bool AddAuthorizedPerson(Player executingPl, Player pl, string name, Auth
{
if (commander != null && commander.PlayerId != pl.PlayerId)
{
AddModifyPlayerPosition(commander.PlayerNativeId, commander.PlayerId, commander.Name, AuthorizedPersonRank.Crewman);
AddModifyPlayerPosition(commander.PlayerId, commander.Name, AuthorizedPersonRank.Crewman);
}

addModifyPlayer = true;
Expand All @@ -754,7 +754,7 @@ public bool AddAuthorizedPerson(Player executingPl, Player pl, string name, Auth
{
if (officer != null && officer.PlayerId != pl.PlayerId)
{
AddModifyPlayerPosition(officer.PlayerNativeId, officer.PlayerId, officer.Name, AuthorizedPersonRank.Crewman);
AddModifyPlayerPosition(officer.PlayerId, officer.Name, AuthorizedPersonRank.Crewman);
}

addModifyPlayer = true;
Expand All @@ -766,7 +766,7 @@ public bool AddAuthorizedPerson(Player executingPl, Player pl, string name, Auth

if (addModifyPlayer)
{
AddModifyPlayerPosition(pl.NativeId, pl.PlayerId, name, rank);
AddModifyPlayerPosition(pl.PlayerId, name, rank);
CopyAuthorizedPersonelListToChildren();

return true;
Expand All @@ -775,13 +775,12 @@ public bool AddAuthorizedPerson(Player executingPl, Player pl, string name, Auth
return false;
}

private void AddModifyPlayerPosition(string nativeId, string playerId, string name, AuthorizedPersonRank rank)
private void AddModifyPlayerPosition(string playerId, string name, AuthorizedPersonRank rank)
{
AuthorizedPerson existing = AuthorizedPersonel.Find((AuthorizedPerson m) => m.PlayerId == playerId);
if (existing != null)
{
existing.Rank = rank;
existing.PlayerNativeId = nativeId;
existing.PlayerId = playerId;
existing.Name = name;
}
Expand All @@ -790,7 +789,6 @@ private void AddModifyPlayerPosition(string nativeId, string playerId, string na
AuthorizedPersonel.Add(new AuthorizedPerson
{
Rank = rank,
PlayerNativeId = nativeId,
PlayerId = playerId,
Name = name
});
Expand Down Expand Up @@ -868,7 +866,6 @@ public VesselSecurityData GetVesselSecurityData(bool includeName = false)
Player pl = Server.Instance.GetPlayerFromPlayerId(per.PlayerId);
authPersonel.Add(new VesselSecurityAuthorizedPerson
{
PlayerNativeId = per.PlayerNativeId,
PlayerId = per.PlayerId,
Name = (pl != null) ? pl.Name : per.Name,
Rank = per.Rank
Expand Down Expand Up @@ -1721,7 +1718,7 @@ public VesselObjects GetVesselObjects()
NewType = sp.Type,
PlayerGUID = ((sp.Player != null) ? sp.Player.FakeGuid : (-1)),
PlayerName = ((sp.Player != null) ? sp.Player.Name : null),
PlayerSteamID = ((sp.Player != null) ? sp.Player.PlayerId : null)
PlayerId = ((sp.Player != null) ? sp.Player.PlayerId : null)
});
}
ss.EmblemId = EmblemId;
Expand Down
2 changes: 1 addition & 1 deletion ZeroGravity/Persistence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static bool Load(string filename = null)
{
foreach (PersistenceObjectDataPlayer playerData in persistence.Players.Cast<PersistenceObjectDataPlayer>())
{
Player player = new Player(playerData.GUID, Vector3D.Zero, QuaternionD.Identity, "PersistenceLoad", "", "", playerData.Gender, playerData.HeadType, playerData.HairType, addToServerList: false);
Player player = new Player(playerData.GUID, Vector3D.Zero, QuaternionD.Identity, "PersistenceLoad", "", playerData.Gender, playerData.HeadType, playerData.HairType, addToServerList: false);
player.LoadPersistenceData(playerData);
}
}
Expand Down
2 changes: 0 additions & 2 deletions ZeroGravity/PersistenceObjectDataPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public class PersistenceObjectDataPlayer : PersistenceObjectData

public string PlayerId;

public string NativeId;

public Gender Gender;

public byte HeadType;
Expand Down
Loading

0 comments on commit 1850572

Please sign in to comment.