Skip to content

Comment on Jedi Knight 2 And 3 Source Code Releasedparent

Comments

Skimming through the academy source, some are fine, some are not.

For example, codemp/game/g_saga.c uses goto just fine. Three "goto failure" jump to the end of the function to handle the error case differently than a normal return. Not a very good example for proper goto use, but ok.

In contrast, codemp/cgame/cg_players.c should be refactored. It seems to be model loading code. If the loading fails, some gotos jump to the start of the function and using a flag variable a default model "kyle" is used instead of the arguments. If the default model is broken, this becomes an infinite loop. My style suggestion:

  if (loadModel(foo)) return;
  if (loadModel(default)) return;
  assert (false && "fallback/default model broken");
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.