I think the level SDK has become a bit dated. The more I look at it, the more I realize certain things are wrong with it. I'm starting this thread for anyone that feels something was implemented in an obscure way, or in a bad way, or is just plain wrong.
If you feel something needs to be explained better, or more sample code posted on some topic, then post about it here. Such as, the SDK needs to include more sample or template levels, particularly showing how to make an AI do <X>.
As for what I think is wrong with it, these things are mainly aimed at BlackBox to read over. You're welcome to read it, but if you get lost you should probably just ignore it.
First of all, I think the file division needs to change a bit. Groups.h should probably be split or renamed (ScStub.h maybe?). Currently it contains Triggers because they're also derived from ScStub, but they really have nothing to do with groups. Similar thought on Functions.h, which contains mostly Trigger related functions.
We should also redo RequiredExports.h. The way this header file is now, it forces all DLLs compiled with this API to be level DLLs, but there are other types of DLLs that we could make for Outpost2 that aren't levels. One example might be some sort of plugin AI project. I've worked on a few projects that used this API, but weren't level DLLs, and I needed some way to prevent declaring those exports. I used a hacked #define method to do it, or just avoided the API completely.
Instead, we should only define the needed structures and enumerations. (BufferDesc, SDescBlock/AIModDesc, and MissionTypes). We should also keep a macro to make exporting easier/cleaner looking, and it should be named something obvious. Perhaps:
#define Export extern "C" __declspec(dllexport)
Instead of the current:
#define SCRIPT_API extern "C" __declspec(dllexport)
We should also document the required (and standard, but not required) exports, both function and data. We should probably only do this as comments though, and not as actual declared exports.
Instead, the Export macro can be used when and where the data is declared. Such as in:
Export char MapName[] = "on1_01.map"; // The .map file used for this level
Instead of the old way we've usually done it:
char MapName[] = "on1_01.map"; // The .map file used for this level
Note that we didn't need to declare the variable as exported before, because it was already declared as exported in the header file. My suggestion is thus to move the Export from the header to the implementation file. This applies to both exported data and exported functions.
We should provide an easy level setup macro, and probably use the full AIModDesc structure. Perhaps using a syntax like:
ExportLevelDetails("Colony Builder - game description", "on1_01.map", "Multitek.txt", Colony, 2);
We can do this using the following macro:
#define ExportLevelDetails(levelDesc, mapName, techTreeName, missionType, numPlayers) \
Export char MapName[] = mapName; \
Export char LevelDesc[] = levelDesc; \
Export char TechtreeName[] = techTreeName; \
Export AIModDesc DescBlock = { missionType, numPlayers, (missionType > 0) ? missionType : 12, false, MapName, LevelDesc, TechtreeName, 0 }; \
Note that I made a few assumptions in this macro. Namely, bUnitOnlyMission is set to false, and techLevel is set to the campaign level number (if it's positive), or 12 for any multiplayer or colony games. As these two options don't seem to be changed much, this simplification seems useful. If you want to specify those extra two parameters for some special level that needs them, then we can provide an alternate macro such as:
#define ExportLevelDetailsEx(levelDesc, mapName, techTreeName, missionType, numPlayers, maxTechLevel, bUnitOnlyMission) \
Export char MapName[] = mapName; \
Export char LevelDesc[] = levelDesc; \
Export char TechtreeName[] = techTreeName; \
Export AIModDesc DescBlock = { missionType, numPlayers, maxTechLevel, bUnitOnlyMission, MapName, LevelDesc, TechtreeName, 0 };
By building a template project where DllMain is seperated into it's own file, we could potentially reduce compile times. Having to parse all of windows.h can take a noticable amount of time. This header is usually only used to help with DllMain. By keeping all the Outpost2 specific stuff seperate, people can work on their level without having to recompile whatever file DllMain is stuck into. Yet, it's still available for those cases when you need to edit it. (Don't go sticking it in a library please).
We should standardize header access between DevStudio and CodeBlocks. This is actually an easy one. We just need to specify additional include folders in the project setup. Then it doesn't matter if the headers have to be moved between the two environments, since the extra include folders will catch the SDK headers. It'd be nice if code people gave you actually compiled in your environment without having to go through all the headers and fix the paths. The only problem, is getting people to "fix" their existing projects.
Maybe we should add a function for SetLavaPossible, that is compatible with how the original Sierra levels works? It's not a particularly great method, but it might be nice to have in some sort of extra section, such as OP2Helper.
We need to fix a few errors. Was it CreateEscapeTrigger that has a parameter listed wrong? I can't remember now. I also found another typo in my headers that's been there since forever. The UnitClassifications enum had a typo.
Some functions or classes probably also need a few more comments describing how to use them.
We need to complete some of the info in there. We have left a number of unknowns that we could actually determine. We mostly just haven't bothered, probably due to lack of interest. It seems that not all of the SDK has really been explored by very many.
I'm finding reasons to reuse some enums between the ForcedExport project and the standard SDK. I used to have some issues with name clashes, and still have some compatability issues when mixing functions. If I declare an enum in a namespace, which also exists in the SDK, then they won't be treated as the same since their names are different. The exported names in the SDK obviously can't be put into namespaces, since this affects their name decoration. It'd be nice to somehow seperate the enums from the rest of the SDK so they could be reused, and more enums could be added for other projects. It would be helpful if just the enums could be included without bringing in the rest.
The SDK should include certain sample code. At least one blank template. One simple multiplayer mission with no AI. Maybe even a sandbox colony game without AI? It would also be good to include something with a bit of AI in it. Just using the standard functions, and a cheating AI. Perhaps we can reverse engineer an existing DLL and rewrite it in C++. I've got a large part of CPS2.dll worked out. Source for CES1.dll would also be nice, as well as the two multi maps ml2_21.dll and ml4_21.dll. (This is partly why I suggesting code to implement the SetLavaPossible function, the way Sierra does it).
Better base layout/creation utility functions. (OP2Helper type thing). There were some limitations in the last release that were discovered pretty fast, but were never fixed. A few people wrote their own solutions, and some nonstandard code got passed around. It'd be nice to just fix the API and make something better. (Suggestions?)
And of course try to make it nicer to use for the non-coders. I've seen a few people mention the SDK could use some more work, but not so much why or how. Ideas?