Anecdotes from the past month of gamedev. Focused on the decisions and thinking behind the RPC rewrite.
Unturned uses "remote procedure calls" (RPC) for all gameplay netcode. This is a fancy way of saying that when you press the "pick up item [F]" key, the client asks the server to call a PickUpItem method, and then the server responds by telling the client to call an AddItemToInventory method.
Prior to the rewrite it looked something like:
public void askChat(CSteamID senderId, byte flags, string text)
channel.send("askChat", ESteamCall.SERVER, ESteamPacket.UPDATE_RELIABLE_BUFFER, flags, text);
This works fine, but there are a lot of aspects to improve:
- Back when most of this old code was rewritten nameof() was not available in Unity's c# version, so a typo could break the call and not be found until runtime.