- Home /
Editor forgets elements of array after saving changes to code
[SOLVED]I actually solved this problem already, but it costed me few hours and didn't see anything similar over the Internet. I just want to leave this question as a tip for anyone else facing this strange issue, anyone knowing sources explaining the matter more precisely is welcome to leave them!
Here is the thing: I'm working on mutliplayer game with dedicated-ish server and want players to be able reconnect. Code is in C#, im using VisualStudio C# 2010. I have a nice little structure holding information about connections on server side:
public struct ConnectionData{
public NetworkPlayer networkInfo;
public int clientID;
public bool isConnected;
}
Array of such structures is used to hold information about players. isConnected is set to true/false OnPlayerConnected/Disconnected (on server side), everything is working more or less smoothly - until ANY change is applied in compiler and saved while remaining in a game mode. This will cause game to "forget" members of array, attempts to relate to or modify any of its elements will cause a NullReferenceException: Object reference not set to an instance of an object error.
If anyone has any idea WHY this is happening, please leave a comment or something. My only bet is that it's the way c# handles memory, this could be garbage collector going rampage during saving updated code - but it's only a guess. Anyone?