This is my first question, so please tell me when I have to clarify something.
Making a multi-player game inside a LAN was easy, as you don't have to deal with interpolation, client-side prediction etc. But how should you implement the logic on both the client and the server for client-side prediction? Implement it two times, or make on class and create a kind of wrapper for the client and the server?
Also, is it usual to share all the data to have the client fully synced or should you send only some variables like if an object is solid, its position and shape...?
So I have basically two questions:
Side note: I am talking about client side prediction on the character you are controlling. I will use interpolation for the other entities.
After a lot of reading and some experience, I came to some conclusions:
In many cases the exact same classes can be used. A popular way to handle the synchronization is by letting these classes inherit from a Realizable class. This class will provide (pure) virtual functions to read and write data to a stream. In case the program is hosting a server, it will request the object to write its data to a stream, otherwise it will read a stream received from the server.
Generally, you would only sync the needed data in the functions that read from or write to a stream.
One solution to client-side prediction seems to be to create a PlayerHandler on the client which handles input and such. The client should know which is the player they control. The handler can then temporarily overwrite the position and such of the object. You will need to write some custom code specific to your game to handle the rest.