OnServerAddPlayer uses NetworkMessage parameter instead of NetworkReader. Removes last dependency on NetworkReader.ReadMessage (#307)

This commit is contained in:
vis2k 2019-01-18 13:08:19 +01:00 committed by GitHub
parent 183afac99a
commit ce8ede3db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -78,6 +78,7 @@ public static bool AddPlayer(NetworkConnection readyConn)
} }
// use this to implicitly become ready // use this to implicitly become ready
// -> extraMessage can contain character selection, etc.
public static bool AddPlayer(NetworkConnection readyConn, MessageBase extraMessage) public static bool AddPlayer(NetworkConnection readyConn, MessageBase extraMessage)
{ {
// ensure valid ready connection // ensure valid ready connection

View File

@ -518,8 +518,12 @@ internal void OnServerAddPlayerMessageInternal(NetworkMessage netMsg)
if (msg.value != null && msg.value.Length > 0) if (msg.value != null && msg.value.Length > 0)
{ {
NetworkReader reader = new NetworkReader(msg.value); // convert payload to extra message and call OnServerAddPlayer
OnServerAddPlayer(netMsg.conn, reader); // (usually for character selection information)
NetworkMessage extraMessage = new NetworkMessage();
extraMessage.reader = new NetworkReader(msg.value);
extraMessage.conn = netMsg.conn;
OnServerAddPlayer(netMsg.conn, extraMessage);
} }
else else
{ {
@ -629,7 +633,7 @@ public virtual void OnServerReady(NetworkConnection conn)
NetworkServer.SetClientReady(conn); NetworkServer.SetClientReady(conn);
} }
public virtual void OnServerAddPlayer(NetworkConnection conn, NetworkReader extraMessageReader) public virtual void OnServerAddPlayer(NetworkConnection conn, NetworkMessage extraMessage)
{ {
OnServerAddPlayerInternal(conn); OnServerAddPlayerInternal(conn);
} }