1
\$\begingroup\$

I read here a spectacular story of someone (scrappily) fixing some things in a game's source code, making it load 4 times faster!

How did the developer get the source code in the first place? Is there a common pattern to getting game source code?

Link to the GitHub repository talked about in the article: https://github.com/tostercx/GTAO_Booster_PoC

\$\endgroup\$
3

1 Answer 1

5
\$\begingroup\$

Getting access to a game's sourcecode can be anything between trivial to impossible. Factors which decide that are:

  • What technology was used to create the game? Decompiling executables to readable sourcecode can be easy (like in Java) to hard (like C++). Some technologies even require to include the sourcecode with the game, because they interpret the sourcecode at runtime (like browser-based javascript, for example).
  • Did the developers take measures to make sourcecode access easier or harder? They might run their code trough an obfuscator before creating the game build to make it harder to read. With compiled languages, they might run the exe through some additional obfuscation steps to make decompiling harder. Or they might even offer parts of their sourcecode in a public repository for players to view, perhaps even with documentation.
  • Are there server-sided components? When parts of the game run on a server, then the code for those components is inaccessible to players, unless it gets leaked by an insider or hacker.

But if you want to know more about how a player going by the synonym t0st troubleshot the loading time problem in GTA 5 and fixed it, they wrote an essay about that. tl;dr:

  1. They used a profiler to find the parts of the code which took the most time to execute.
  2. They disassembled the game executable by dumping the memory at runtime and running it through a C++ decompiler.
  3. They dug through the barely readable C++ sourcecode and found out that the slow parts parse strings containing JSON data.
  4. They found out that the JSON data in question contained the data about items, and that they were parsed in a very inefficient manner.
  5. They created a more efficient implementation and injected it as a DLL, which is a popular method for modding parts of games which weren't intended to be accessible to modders.
\$\endgroup\$
3
  • 1
    \$\begingroup\$ The specific steps described here for fixing GTA 5 are extremely advanced. Don't get your hopes up on being able to make the same kinds of modifications on your own. \$\endgroup\$
    – Kevin
    Mar 16, 2021 at 20:27
  • \$\begingroup\$ I came across this great example of someone reconstructed the source code of the game Duke Nukem II, based on disassembly of the original executable. cont. \$\endgroup\$
    – stevec
    Oct 19, 2022 at 1:31
  • \$\begingroup\$ The author says: The semantics and to some extent also syntax are identical, but the code organization, formatting, and naming of identifiers are completely made up by me. We know that the semantics of the code are 100% accurate, since the executable built from the source code is byte-for-byte identical to the original binary after LZEXE compression \$\endgroup\$
    – stevec
    Oct 19, 2022 at 1:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .