In a nutshell, this "finishes" the merge by merging what MergePlugins can't merge (the scripts and LODGen)
EDIT: As I said before, I made this on hishy's instructions. See this post.
Slightly inaccurate. The only scripts Merge Plugins "can't merge" are ones with GetFormFromFile calls (also GetModByName, checkModPresence, and IsPluginLoaded calls). That's what you're handling here. Merge Plugins handles script fragments and ordinary scripts don't need any special handling.
EDIT: Seems other people covered that already.
I explained all of this to hishy in depth at some point. It's cool that he managed to remember the details enough to get someone to make a solution.
Merge Plugins COULD handle it, but it would have to function similar to how Ganda has this programmed in that it'd have to check all scripts after each merge because each merge can require the alteration of any number of scripts from any number of other mods/merges.
Really awesome to see this! I wanted to program it but I've been programming my ass off on Mod Picker so I haven't had the time. Nice work Ganda, I'll check out the code sometime soon-ish. :)
The patch is only needed for compiling when running the CK through MO. Else the compiler in the CK will fail. It's not likely needed in any other situations such as this.
I kinda see this being absorbed into Mator's tool since that is just local. Would you be okay if he added this into Mator Smash? Though I don't think he's worked on that tool in a long time. Not since he started his website project.
I think it'd be better to absorb it into Merge Plugins because Smash doesn't have the hooks into the Papyrus Compiler/Decompiler integrations yet. It'd be a "post-merge fix things patch". The LODGen stuff can be handled immediately during the merging process like other file specific assets though.
Line 278 LMAO.
This feels a bit inefficient. The way I'd do this is to process all the script files once and build a dictionary of all the GetFormFromFile, GetModByName, checkModPresence, and IsPluginLoaded calls in all scripts, then iterate over that dictionary and for each dictionary item iterate across all the maps. Or just combine all the maps into a single map and use a simple indexOf call on a single map to see if a plugin is merged. The main reason this would be faster is you only have to load the script files once to build the dictionary of the calls, then load them once more to actually replace the calls as necessary. Right now you're loading the files n times, where n is the number of maps in merge_data_list, which is a lot of Disk I/O which is slow (even with tiny files).
Alternatively you could also just reverse the loop order (so iterate over the files and per file iterate over the maps). This would force the LODGEN to be a separate loop as well.
Looks pretty good overall though. Only other thing I'd suggest is breaking things into more functions so you don't have quite as much nesting going on and so the main procedure is abstracted a bit.
Edited by Mator, 16 August 2016 - 04:16 PM.