I finally managed to fix the bug I had yesterday, and it was a pretty unexpected one. Basically calling push_back on the vector of local network objects caused it to reallocate memory, thus calling destructors and contructors which messed up everything. I replaced it with a list, and everything is working.
I also added a variable to each net obj to keep track if it has been modified or not. This helps to reduce the amount of data sent.
In the picture the three client are perfectly synced, while for now the server is not. I have to decide whether to implement the same client logic inside the server, or if it would be better to just have both a client and a server on the same machine. Probably I'll go with the second one.

Nessun commento:
Posta un commento