I am currently restructuring my entire codebase, which is likely the most challenging and open-ended problem I’ve encountered so far. I haven’t found much reliable information on how to approach this task, probably because it’s a very general problem, unlike specific topics like rendering techniques, which have many decent papers and articles. I also find that popular concepts, such as Clean Code, don’t feel intuitively sound to me. The best resource I’ve found is episode 26 of Casey Muratori’s Handmade Hero, titled “Introduction to Game Architecture.” After watching it, I believe I have a solid starting point.
I’ve never shied away from large functions, unlike many supposed developers. A significant portion of my code resides in main.c, and I follow the rule that if a method is used in only one place, it shouldn’t be turned into a reusable function. Adhering to a few simple rules has allowed me to implement features aggressively and made it easier to identify errors. If I were developing a single-player game, I would likely continue down this path. However, the challenge I face—and I hope I’m not creating it myself—stems from the fact that I’m building three programs: a client, a server, and a map editor. Technically, the server is a thread launched by the client, but that’s just semantics. Essentially, I have rendering, physics, and gameplay functions shared across all three programs. I’m starting by identifying the data structures and functions needed by all three, while also splitting them across more files and reevaluating the hierarchies to make them more logical (I hope).
This restructuring may keep me busy for a while. My goal is to have a working “deathmatch” mode as soon as possible. I already have all the necessary code written and tested from previous work; I just need to organize it better, this time.