Categories
Game Development

3000 lines of code in 2 days

This lobby server is turning out to be much more involved than I originally thought. I have to write every query between 6 to 11 times. For example, to add a friend to the friends list for a user I have to: 1. Query the user for the friend 2. Validate the inputs on the […]

This lobby server is turning out to be much more involved than I originally thought. I have to write every query between 6 to 11 times.

For example, to add a friend to the friends list for a user I have to:

1. Query the user for the friend
2. Validate the inputs on the client (we are connected, etc)
3. Serialize the inputs and send them to the server
4. Deserialize the inputs on the server
5. Check the inputs for sanity (don’t add yourself as a friend, you are connected, …). If bad, reply back.
6. Serialize the inputs again in database format, and send to the DB thread.
7. Deserialize the output from the db thread
8. Parse the output from the db thread (doing the actual work of maintaining the internal friends list).
9. Serialize the reply back to the client.
10. Deserialize the reply from the server on the client.
11. Parse the reply (modifying our friends list), and call the output callback for the user.

That’s not even counting that this relies on another previous query to ask/authorize a friend invitation.

This would be even harder and more involved if I had not yet already wrote and tested the DB queries in 3 other projects!

So I did 9 client commands in 2 days for about 3000 lines of code. I have like 50-60 more commands 🙁

The good part is the only painful commands left are the ignore list (which is easier than friends) and sending emails. Friends was probably the hardest to do.

I’ve sort of skipped per-user permissions for now, and moderator commands. Those will also be very involved and painful.

Leave a Reply

Your email address will not be published. Required fields are marked *