What I've noticed, is using
Program.cs has
public static List<Client> clients = new List<Client>();
the Button
private void button1_Click(object sender, EventArgs e)
{
Client client = new Client(combobox1.selecteditem);
Program.clients.Add(client);
}
Client.cs All variables are non-static public. But there is an eventhandler where on packetrecv, a class is called, this class is then filtered and processes
Where it is called is
public void recieved(short op, string str, Client c)
{
switch (op)
{
case (short)OpCodes.matches:
{
c.something(c, str);
break;
}
}
}
Handler.cs
public void something(Client c, string movement)
{
if (movement == null)
c.coords = movement;
c.freeSpot = true;
}
And in the above ^ the variables would overlap and freespotwould be made true throughout all the instances
will work find with one instance. But I'm trying to compile with multiple instances.
So creating a button_onclick
would create a new instance using the above.
As the program is running, it runs flawlessly on one instance, but with 2+ instances, the variables in MyClass
start to overlap. Is there a way to prevent this?