@@ -262,4 +262,35 @@ And that's that.
262262
2632632. Why are functions that do nothing even in the game?
264264
265- This is a commonly asked question
265+ This is a commonly asked question for a good reason and there are multiple answers.
266+
267+ A common reason might be that the original game code
268+ had certain debugging code that might have been stripped out
269+ during the release build.
270+ There are at least 35 empty functions that contain the word "debug" that do nothing.
271+ `zNPCBPlankton::render_debug()` for example.
272+ You can imagine that the actual source code for this probably looked something like this:
273+ ```cpp
274+ void zNPCBPlankton::render_debug()
275+ {
276+ #ifdef DEBUG
277+ // ...
278+ // A bunch of code to debug the plankton boss...
279+ // ...
280+ #endif
281+ }
282+ ```
283+ Naturally when releasing, none of that code would have been included,
284+ leaving us with empty functions.
285+ These functions are still included in the game
286+ and not optimized out by the compiler despite being empty in this case
287+ because they are called from other areas of the code.
288+ The compiler isn't smart enough to know that the function call itself
289+ wouldn't create side effects, so it keeps the function in the game
290+ despite it doing nothing in a release build.
291+
292+ Whew. This was a longer chapter than anticipated,
293+ but we have learned quite a lot.
294+ Whenever you're ready let's head on to the next example
295+ and start decompiling functions that have
296+ some actual code in them.
0 commit comments