Thanks - that explains a lot.
I think that FRED actually needs completely different code for the vast majority of the functions.
FS2 takes the various files and transforms them into an efficient ingame representation. The inverse of that transformation is not required for the game to run.
FRED takes the various files and user input to produce new versions of the files.
There's not really very much overlap between the two - in fact, the only overlap is that both of them need to load the files.
Even that isn't as much of an overlap as one might think, as an efficient editing representation is different to an efficient in-game representation.
- For example, FS2 needs to process the 'meaning' of SEXPs, while FRED merely needs populate and edit a tree of them.
FRED doesn't actually care what they do, only that they meet defined rules for chaining and stacking. It's actually pretty trivial to build an Event editor if you ignore what they do - for the most part, it's just a nested list of stuff.
If FRED uses the same internal representation as FS2, it makes it much harder for FRED to do things like copy, paste, delete and move them, and it has to come up with some way of exporting the result - because FS2 never has to do any of that. Thus, bugs in FRED are likely to come as a result of fixes and improvements to FS2.