Well, I think I may have some good news, finally. IssMneur's suggestion (which I have implemented and which seems to work) got me thinking about another part of the code that was giving me an access violation bug, and I realised that I had to convert from an SCP_string to a C-style string before writing to the campaign file during the save process. Once I did that, lo and behold, everything worked! At least everything I have tested so far works. I'll put the patch I'm using up so that people can test, because this will need rigorous testing by at least two other people apart from me. I know mjn.mixael will participate, but I'd like another viewpoint as well just in case.
NOTE: This is an ANTIPODES patch. Do NOT apply this patch to trunk!
EDIT: What this patch actually does as far as the modder is concerned: Firstly, we can now have a dynamic number of mainhalls, so potentially as many as you want. Secondly, name identifiers have been added, so you can add +Name entries to your mainhall.tbl entries (the names for both resolutions of the same entry must match). Syntax is just +Name: (string), added directly under the $Main Hall string in mainhall.tbl. You only need to add a name to the 640x480 entry and it will be automatically applied to the 1024x768 entry. You will notice the campaign editor in FRED has changed slightly and you must now use the name identifiers to distinguish your mainhalls. Mainhalls without names will be given numbers automatically, so using 0 and 1 for the retail mainhalls as was previously done will still work.
What you should be testing for: first, when playing retail or existing mods, everything should function as it did previously. This goes for both in-game and FRED-side, though obviously the UI has changed slightly as mentioned before. In particular, a mainhall changing campaign needs to be tested to see if the mainhalls do change correctly during the course of the campaign.
Name identifiers should be tested. Try omitting names, try giving different resolutions of the same mainhall different names (the code should warn you and compensate). Try using your mainhall names in the campaign editor and see if the game brings up the correct mainhall.
Lastly, Mjn's probably the only one in a position to test this, but try testing with a large number of mainhalls in mainhall.tbl, seeing as we should now be able to have as many as we want.
More info will be posted as I think of it, but that's the main part.
[attachment deleted by a ninja]