EmperorFool
Deity
I'm adding a new feature to BULL now that will both solve an existing problem (OOS when players have different Pre-Chop and/or Sentry Healing settings) and provide a new capability (options that have a single setting shared among all players in MP games). Special thanks to Afforess for the idea for the shared options and being a sounding board for the design.
I'm seeking feedback from any modders that might make use of this--or anyone else with an interest for that matter.
This new info class has four fields:
Obviously the <Description> and <Help> elements reference <Text> entries in a CIV4GameText.xml file. The help probably isn't needed but better to add it now than need it later.
Step 2: Store Settings [complete]
CvPlayer and CvInitCore will both get an int array of option values. Each class will have similar accessors for getting and setting the values.
Step 3: Synchronize Settings [complete]
I will add a new net message to BULL for sending an option value to all players. This will need to happen for all options when a game is started/loaded and whenever an option is changed by any player.
Shared options: Only player 0 will be able to change shared options in the BUG Options screen. While they will be grayed out for other players in MP games, they will see the up-to-date value and get an event message whenever it is changed.
Step 4: Add BUG Support
The <option> and <list> elements will gain two new optional attributes:
BUG likely needs just one function to set the value in BULL on CyGlobalContext. BULL will use the info class to pick where to store the value locally and how to send the message.
BULL needs a function to all it to push a new shared option setting to BUG when it receives it in a net message.
BugOptionsScreen needs to know to disable a shared option when the active player isn't the host (player 0).
Important: Works with BULL alone but not BUG alone.
BUG is only involved to allow the settings to be changed easily via the BUG Options screen. Other than that this feature is handled entirely in BULL: storing, syncing, etc. This means that mods based on BUG without BULL will not be able to make use of this feature. This is probably the one thing that could bite me on the ass.
With some work I could implement this in BUG as well as a fallback for when BULL isn't available, but that's not very appealing. I've got a lot of other things I could be working on. Does anyone have a case where they'll need this feature in BUG alone?
I'm seeking feedback from any modders that might make use of this--or anyone else with an interest for that matter.
- There are some names that I'm not totally happy with (e.g. sync) for which I'd love some suggested alternatives.
- Does anyone foresee any potential problems with this?
- Is the limit of bool and int option values going to be too severe?
- What have I not anticipated?
This new info class has four fields:
- shared - boolean, true means one value for all players, controlled by player 0
- default - int, 0/1 for a boolean option, float and strings not supported
- option ID - string, used to look up the option in BUG
- define name - string, used to look up the value in GlobalDefinesAlt.xml when BUG isn't present.
Code:
[B]// CvEnum.h[/B]
MODOPTION_PRECHOP_FORESTS,
[B]<!-- CvModOptionInfos.xml -->[/B]
<ModOptionInfo>
<Type>MODOPTION_PRECHOP_FORESTS</Type>
<Description>TXT_KEY_MOD_OPTION_PRECHOP_FORESTS</Description>
<Help>TXT_KEY_MOD_OPTION_PRECHOP_FORESTS_HELP</Help>
<bShared>0</bShared>
<iDefault>1</iDefault>
<OptionId>Actions__PreChopForests</OptionId>
<DefineName>BUG_PRECHOP_FORESTS</DefineName>
</ModOptionInfo>
Obviously the <Description> and <Help> elements reference <Text> entries in a CIV4GameText.xml file. The help probably isn't needed but better to add it now than need it later.
Step 2: Store Settings [complete]
CvPlayer and CvInitCore will both get an int array of option values. Each class will have similar accessors for getting and setting the values.
Step 3: Synchronize Settings [complete]
I will add a new net message to BULL for sending an option value to all players. This will need to happen for all options when a game is started/loaded and whenever an option is changed by any player.
Shared options: Only player 0 will be able to change shared options in the BUG Options screen. While they will be grayed out for other players in MP games, they will see the up-to-date value and get an event message whenever it is changed.
EmperorFool has turned on Global Warming
EmperorFool has changed Global Warming Chance to 15
EmperorFool has changed Global Warming Chance to 15
Step 4: Add BUG Support
The <option> and <list> elements will gain two new optional attributes:
- sync - string, the enum name minus the MODOPTION_ prefix
- shared - bool, I don't think this is needed anymore since it's in the info
Code:
<option id="PreChopForests" key="Pre Chop Forests"
type="boolean" default="True"
[B]sync="PRECHOP_FORESTS" shared="False"[/B]/>
BUG likely needs just one function to set the value in BULL on CyGlobalContext. BULL will use the info class to pick where to store the value locally and how to send the message.
BULL needs a function to all it to push a new shared option setting to BUG when it receives it in a net message.
BugOptionsScreen needs to know to disable a shared option when the active player isn't the host (player 0).
Important: Works with BULL alone but not BUG alone.
BUG is only involved to allow the settings to be changed easily via the BUG Options screen. Other than that this feature is handled entirely in BULL: storing, syncing, etc. This means that mods based on BUG without BULL will not be able to make use of this feature. This is probably the one thing that could bite me on the ass.
Is this too restrictive?
With some work I could implement this in BUG as well as a fallback for when BULL isn't available, but that's not very appealing. I've got a lot of other things I could be working on. Does anyone have a case where they'll need this feature in BUG alone?