Rename stack_json_load() to the new, public patch_json_merge().
Use the flexible array loop for dependencies.

Should have done this before changing the CSV parser on the server!
MSG patching: Increment the line counter correctly to repair hard line patching.

What the hell?!? Dialog patching in th06, th07 and parts of th08 was completely broken as a result, since state->cur_line was at set to at least 1, thus completely skipping the first line...
Remove superfluous CRT debug calls in thcrap's DLL initialization.

Memory leaks are dumped to the on-screen console just fine without them.
Cleanup: Fix some comments.
Cleanup: Const-correctness
Cleanup: Random fixes
Introduce a system to allow customization of files loaded during resolving.

Previously, the sequence of generic and build-specific files had to be hardcoded into every single resolving function. This new "resolving chain" system keeps this sequence of file names in an array.

Not only does this eliminate a great deal of redundancy when writing new file resolvers for new formats. This also allows adding new files to the chain to customize existing resolvers for certain file formats, which would previously have required duplication of code.
Add a function to create a resolving chain based on a game-local file name.
Use a custom resolving chain for global.js and the game's main JSON files.

Previously, game-specific settings from patches at a lower position in the stack would overwrite global settings from higher up. Pushing global.js at the beginning of the resolving chain fixes this.
Add a bidirectional stack+chain iterator.

This removes the final instance of code duplication between stack resolvers!
repo_update.py: Dump JSON with Git-compatible whitespace.
Move thcrap updating information from patch.js to the run configuration.

In a time without both global.js and the slightest idea of how popular the engine (not the patches) will eventually be, patch.js was of course the most obvious place to put that. However, now that we've actually *come* across a situation where there will be multiple download URLs, and it turns out that the best way to handle this is to just let patch stacking take care it.

Also choosing better key names.
thcrap_update: Link to the default zlib1.dll instead of zlibwapi.dll.

We've been using a __stdcall build of that library all the time anyway, and it turned out that we really don't want to use the included minizip code anyway...
Remove the typed memory patching functions.

They have never been used, will probably never be used (we have binary hacks, you know), and with the upcoming change to make [prev] optional, the pointer indirection will have made these even more confusing.
PatchRegion(): Make [prev] optional, remove the *NoCheck() function.
func_detour(): Remove duplicated code.
Remove the <f$> ruby layout parser introduced in 2013-08-20.

Well yeah, it *did* work everywhere, but the results were not exactly pretty, and barely legible at 640x480.
repo_update.py: Refactor JSON loading into its own helper function.
repo_update.py: Explicitly set UTF-8 encoding for text I/O.