Merge branch 'master' of github.com:Saltosion/Cyber

This commit is contained in:
excitedneon 2017-05-12 02:03:41 +03:00
commit 1231201390
2 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,5 @@
using Cyber.Entities.SyncBases; using Cyber.Entities.SyncBases;
using UnityEngine.Networking;
namespace Cyber.Networking.Serverside { namespace Cyber.Networking.Serverside {
@ -11,7 +12,7 @@ namespace Cyber.Networking.Serverside {
/// <summary> /// <summary>
/// The player's connection ID. /// The player's connection ID.
/// </summary> /// </summary>
public readonly int ConnectionID; public readonly NetworkConnection Connection;
/// <summary> /// <summary>
/// The player's controlled character /// The player's controlled character
@ -19,11 +20,11 @@ namespace Cyber.Networking.Serverside {
public Character Character; public Character Character;
/// <summary> /// <summary>
/// Create a connected player and give it a connection ID; /// Create a connected player and give it a connection;
/// </summary> /// </summary>
/// <param name="connectionID">The player's connection ID</param> /// <param name="connectionID">The player's connection</param>
public SConnectedPlayer(int connectionID) { public SConnectedPlayer(NetworkConnection connectionID) {
ConnectionID = connectionID; Connection = connectionID;
} }
} }

View File

@ -194,11 +194,11 @@ namespace Cyber.Networking.Serverside {
Controlled.Move(MoveCreature.Direction); Controlled.Move(MoveCreature.Direction);
foreach (var Player in Players) { foreach (var Player in Players) {
if (Player.Value.ConnectionID == msg.conn.connectionId) { if (Player.Value.Connection.connectionId == msg.conn.connectionId) {
continue; continue;
} }
MoveCreature.Timestamp = NetworkHelper.GetCurrentSystemTime(); MoveCreature.Timestamp = NetworkHelper.GetCurrentSystemTime();
NetworkServer.SendToClient(Player.Value.ConnectionID, PktType.MoveCreature, MoveCreature); NetworkServer.SendToClient(Player.Value.Connection.connectionId, PktType.MoveCreature, MoveCreature);
} }
break; break;
case PktType.Interact: case PktType.Interact:
@ -251,15 +251,15 @@ namespace Cyber.Networking.Serverside {
int[] IdList = new int[Players.Count]; int[] IdList = new int[Players.Count];
int TempCounter = 0; int TempCounter = 0;
foreach (SConnectedPlayer P in Players.Values) { foreach (SConnectedPlayer P in Players.Values) {
IdList[TempCounter++] = P.ConnectionID; IdList[TempCounter++] = P.Connection.connectionId;
NetworkServer.SendToClient(P.ConnectionID, PktType.Identity, new IdentityPkt(Id, false)); NetworkServer.SendToClient(P.Connection.connectionId, PktType.Identity, new IdentityPkt(Id, false));
} }
// Then send the client a list of all other clients // Then send the client a list of all other clients
NetworkServer.SendToClient(Id, PktType.MassIdentity, new IntListPkt(IdList)); NetworkServer.SendToClient(Id, PktType.MassIdentity, new IntListPkt(IdList));
// Add the player to the list // Add the player to the list
SConnectedPlayer Player = new SConnectedPlayer(msg.conn.connectionId); SConnectedPlayer Player = new SConnectedPlayer(msg.conn);
Players.Add(Id, Player); Players.Add(Id, Player);
// Send the previously collected list to the player // Send the previously collected list to the player