C
C#6mo ago
n9tro

List changed by first function gets reset by second function

I am playing around with websockets and have an issue:
No description
No description
No description
3 Replies
n9tro
n9troOP6mo ago
The first function, Handle, is calling the second function RemovePlayer, after that Handle calls HandleRoomUpdate we have GameManager.Instance.Rooms which is a List<GameRoom>. in the case that im testing, room.PlayerCount is 2, when RemovePlayer gets called room.PlayerCount is 1. but when the function HandleRoomUpdate gets the room, PlayerCount is 2. the change from RemovePlayer is not propagating My suspicion is that GetPlayerTeam inside RemovePlayer is returning a copy, instead it should return a reference I just tried passing in the index of the team instead of a copy and still doesnt work, issue is somewhere else
n9tro
n9troOP6mo ago
its worth noting: handle is called from here
No description
n9tro
n9troOP6mo ago
i beleive the issue is coming from RemovePlayer, changing the room internally seems to not propagate... but if i change it from inside Handle it works Some further notes, modifying the room variable directly in Handle propagates the changes, implying that the issue is in the RemovePlayer function, following the stack ind debug shows that its the same one, but for some reason the changes made by RemovePlayer dont propagate the issue was a multithreading issue, the package im using setup multithreading and i had no clue haha, i setup mutexes
Want results from more Discord servers?
Add your server