Author Topic: Adding PlayerColor enum to Outpost2DLL NonExportedEnums.h  (Read 2289 times)

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Adding PlayerColor enum to Outpost2DLL NonExportedEnums.h
« on: March 25, 2016, 06:22:12 PM »
I'd like to add an enum for player colors so I don't have to search the forums or trial/error test whenever I want to select a different player color. I'm guessing since the rest of the code uses unscoped enums, we should stick with an unscoped enum.

NonExportedEnums.h
Code: [Select]
// Color of structures and units belonging to a given player
enum PlayerColor
{
PlayerBlue = 0, //Standard Eden color
PlayerRed, //Standard Plymouth color
PlayerGreen, //Standard third party color during campaign scenarios
PlayerYellow,
PlayerCyan,
PlayerMagenta,
PlayerBlack //Not selectable as a player color from the multiplayer game initialization screen
};

I think a scoped enum would be cleaner to use and wouldn't add all the color names directly into the main namespace (or lack of namespace I guess?), but it would have to be cast whenever used with the SetColorNumber function. It would also be the only one in the project. So probably just stick with a traditional unscoped enum.

Code: [Select]
// Color of structures and units belonging to a given player
enum class PlayerColor
{
Blue = 0, //Standard Eden color
Red, //Standard Plymouth color
Green, //Standard third party color during campaign scenarios.
Yellow,
Cyan,
Magenta,
Black //Not selectable as a player color from the multiplayer game initialization screen.
};

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Adding PlayerColor enum to Outpost2DLL NonExportedEnums.h
« Reply #1 on: March 26, 2016, 09:40:40 PM »
I like this idea. It would be handy to easily choose player colors like this.

I'm not sure about the "standard" part of "//Standard third party color during campaign scenarios". Can you clarify what you mean here? I don't remember there being a third party in the official campaigns.

You bring up a good point about the scoped enums. I would prefer scoped enums. I believe scoped enums have different name decoration though, so the core enums can't be scoped without breaking the linking to functions from Outpost2.exe. Any functions that used an enum in their signature would likely fail to link. This might be worth testing though.

For non-core SDK files that don't link with Outpost2.exe functions, we might want to consider changing to scoped enums. Such a change breaks source compatibility though, so we'd need to bump the SDK version number if we do this.

I'm going to suggest a non-scoped enum to conform with existing expectations for now.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Re: Adding PlayerColor enum to Outpost2DLL NonExportedEnums.h
« Reply #2 on: March 28, 2016, 05:39:02 PM »
@Hooman,

I thought the color of the evacuation transport carrying the Plymouth children for Eden to launch was green in the Eden campaign. Although I cannot think of another example, and it wasn't apparent to you, so standard is probably not the right word. I went ahead and deleted the comment after green.

Thank you for the insight on scoped/unscoped enums.

PlayerColor as an unscoped enum is now committed to the repository.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Adding PlayerColor enum to Outpost2DLL NonExportedEnums.h
« Reply #3 on: March 29, 2016, 04:46:53 AM »
Ahh, I'd forgotten about that. It's been a very long time since I've played he campaigns.

Thank you for all the commits you've been making recently. It's great having someone work on stuff.