Which is the best way to keep NCN packets but with some additional information like NCN.IsOfficer?
At the moment im using this method which i copied from SparkCruise and added some by myself.
This code is working fine, but i would like to add extra info to these NCN Packets.
At the moment im using this method which i copied from SparkCruise and added some by myself.
//Global
private Dictionary<byte, IS_NCN> _connections = new Dictionary<byte, IS_NCN>();
private Dictionary<byte, IS_NPL> _players = new Dictionary<byte, IS_NPL>();
//After InSim Initialise
insim.Send(new IS_TINY { SubT = TinyType.TINY_NCN, ReqI = 255 });
insim.Send(new IS_TINY { SubT = TinyType.TINY_NPL, ReqI = 255 });
//Packets
private void onConnectionJoin(InSim insim, IS_NCN NCN)
{
if (_connections.ContainsKey(NCN.UCID)) _connections[NCN.UCID] = NCN;
else _connections.Add(NCN.UCID, NCN);
}
private void onConnectionLeave(InSim insim, IS_CNL CNL)
{
_connections.Remove(CNL.UCID);
}
private void onPlayerJoin(InSim insim, IS_NPL npl)
{
if (_players.ContainsKey(npl.PLID))
{
// Leaving pits, just update NPL object.
_players[npl.PLID] = npl;
}
else
{
// Add new player.
_players.Add(npl.PLID, npl);
}
}
private void onPlayerLeave(InSim insim, IS_PLL pll)
{
_players.Remove(pll.PLID);
}
//Getting Connection for PLID
private IS_NCN GetConnection(byte plid)
{
IS_NPL npl;
if (_players.TryGetValue(plid, out npl))
{
return _connections[npl.UCID];
}
return null;
}
This code is working fine, but i would like to add extra info to these NCN Packets.