Update math.uc

Update math.uc

Fixed problem that was affecting the ^ and \ operators

# math.uc - uCalc Transformation file
# This file was saved with uCalc Transform 2.96 on 5/23/2014 6:15:56 PM
# Comment: Converts math-related code from PowerBASIC to C++

ExternalKeywords: Exclude, Comment, Selected, ParentChild, FindMode, InputFile, OutputFile, BatchAction, SEND
ExternalKeywords: Highlight, ForeColor, BackColor, FontName, FontSize, FontStyle
ExternalKeywords: FilterEndText, FilterSeparator, FilterSort, FilterSortFunc, FilterStartText, FilterUnique, FilterTally

FindMode: Replace

# Definitions

# Search Criteria

Criteria: 0
Enabled: True
Exclude: False
Comment: Converts math-related code from PowerBASIC to C++
Selected: False
Highlight: True
ForeColor: ControlText
BackColor: Aqua
FontName:
FontSize:
FontStyle:
CaseSensitive: False
QuoteSensitive: True
CodeBlockSensitive: True
FilterEndText:
FilterSeparator: {#10}
FilterSort: False
FilterSortFunc:
FilterStartText:
FilterUnique: False
FilterTally: False
Min: 0
Max: -1
MinSoft: 0
MaxSoft: -1
BatchAction: Transform
InputFile:
OutputFile:
SEND:
StartAfter: 0
StopAfter: -1
SkipOver: False
ParentChild: 0
Pass: 0
PassOnce: True
Precedence: 0
RightToLeft: False

Criteria: 1
Find:
Replace: {@Var: Type As String}
         {@Note: rand & srand are in <cstdlib>, the others in <cmath>}
         {@Note: ToDo: \ eqv imp bin }

Criteria: 2
Comment: ^ (power)
Pass: 1

Criteria: 3
SkipOver: True
Find: ' {Comment:".*"}
Replace: [Skip over]

Criteria: 4
BackColor: Gold
Precedence: 100
Find: {x} ^ {y}  {@Note: precedence property set to 100}
Replace: pow({x}, {y})

Criteria: 5
Precedence: 60
Find: {x} \ {y}  {@Note: precedence property set to 60}
Replace: _round({x}, {y})

Criteria: 6
Precedence: 1
Find: = {etc#%}
Replace: = {etc}

Criteria: 7
Comment: Bitwise AND and OR
Pass: 2

Criteria: 8
SkipOver: True
Find: ' {Comment:".*"}
Replace: [Skip over]

Criteria: 9
Comment: Bitwise AND and OR
BackColor: YellowGreen
Find: ({expr})
Replace: ({@Evaluate: Replace(Replace({expr}, "And", "&"), "Or", "|")})

Criteria: 10
Comment: Everything else
Pass: 3

Criteria: 11
SkipOver: True
Find: ' {Comment:".*"}
Replace: [Skip over]

Criteria: 12
Find: Mod
Replace: %

Criteria: 13
BackColor: Yellow
Find: Atn
Replace: atan

Criteria: 14
BackColor: Lime
Find: Sqr
Replace: sqrt

Criteria: 15
BackColor: Pink
Find: Cint
Replace: Integer

Criteria: 16
Find: Int(
Replace: __int64(

Criteria: 17
BackColor: Red
Find: Incr {var:1}
Replace: {var}++

Criteria: 18
BackColor: RoyalBlue
Find: Decr {var:1}
Replace: {var}--

Criteria: 19
Comment: Logical (short-circuit) AND
Find: And
Replace: &&

Criteria: 20
Comment: Logical (short-circuit) OR
BackColor: Purple
Find: Or
Replace: ||

Criteria: 21
BackColor: Khaki
Find: Xor
Replace: ^

Criteria: 22
BackColor: Green
Find: Not
Replace: ~

Criteria: 23
SkipOver: True
Find: #{metastatement:1} Not
Replace: [Skip over]

Criteria: 24
BackColor: Silver
Find: IsTrue {x%}  [{stop-: And | Or | Then | : }]
Replace: (({x}) != 0)

Criteria: 25
BackColor: SandyBrown
Find: IsFalse {x%} [{stop-: And | Or | Then | : }]
Replace: !({x})

Criteria: 26
BackColor: Violet
Find: <>
Replace: !=

Criteria: 27
Find: Randomize {number%}
Replace: srand({number})

Criteria: 28
Find: Rnd[()]
Replace: (rand() / RAND_MAX)

Criteria: 29
Find: Rnd({a%}, {b%})
Replace: (rand() % ({b}) + ({a}))

Criteria: 30
Find: Shift Right {ivar}, {countexpr%}
Replace: {ivar} = ({ivar} >> {countexpr})

Criteria: 31
Find: Shift Left {ivar}, {countexpr%}
Replace: {ivar} = ({ivar} << {countexpr})

Criteria: 32
Find: {func: Abs|Sin|Cos|Tan|Exp|Exp2|Log|Log2|Log10|Ceil}
Replace: {@Evaluate: LCase("{func}", "{'.*'}")}

Criteria: 33
Find: {func: Exp10 | Fix | Frac | Sgn}
Replace: PB_{@Evaluate: UCase("{func}", "{'.*'}")}

Criteria: 34
PassOnce: False
Find: {func: Min | Max}[{ {int: &} | {str: $} | {dbl: } }]
      ({args})
Replace: PB_{@Evaluate:
            Type = "(double)"
            IIf("{int}" <> "", Type = "(int)")
            IIf("{str}" <> "", Type = "(string)")
            UCase("{func}", "{'.*'}")
         }{int:_INT}{str:_STR}(ARGCOUNT({@Evaluate:
         Tally({args}, ",", Skip("({nest})"))+1}), {@Evaluate:
         Type + Replace({args}, ",", ", "+Type, Skip("({nest})"))})

Criteria: 35
Selected: True
Find: )()
Replace: ){@Note:
            because of problem "between = {etc#%}" in pass 1
            & Rnd which leaves a stray ()
         }

# End Search

# math.uc - uCalc Transformation file
# This file was saved with uCalc Transform 2.96 on 5/22/2014 6:30:01 PM
# Comment: Converts math-related code from PowerBASIC to C++

ExternalKeywords: Exclude, Comment, Selected, ParentChild, FindMode, InputFile, OutputFile, BatchAction, SEND
ExternalKeywords: Highlight, ForeColor, BackColor, FontName, FontSize, FontStyle
ExternalKeywords: FilterEndText, FilterSeparator, FilterSort, FilterSortFunc, FilterStartText, FilterUnique, FilterTally

FindMode: Replace

# Definitions

# Search Criteria

Criteria: 0
Enabled: True
Exclude: False
Comment: Converts math-related code from PowerBASIC to C++
Selected: False
Highlight: True
ForeColor: ControlText
BackColor: Aqua
FontName:
FontSize:
FontStyle:
CaseSensitive: False
QuoteSensitive: True
CodeBlockSensitive: True
FilterEndText:
FilterSeparator: {#10}
FilterSort: False
FilterSortFunc:
FilterStartText:
FilterUnique: False
FilterTally: False
Min: 0
Max: -1
MinSoft: 0
MaxSoft: -1
BatchAction: Transform
InputFile:
OutputFile:
SEND:
StartAfter: 0
StopAfter: -1
SkipOver: False
ParentChild: 0
Pass: 0
PassOnce: True
Precedence: 0
RightToLeft: False

Criteria: 1
Find:
Replace: {@Var: Type As String}
         {@Note: rand & srand are in <cstdlib>, the others in <cmath>}
         {@Note: ToDo: \ eqv imp bin }

Criteria: 2
Comment: ^ (power)
Pass: 1

Criteria: 3
SkipOver: True
Find: ' {Comment:".*"}
Replace: [Skip over]

Criteria: 4
BackColor: Gold
Precedence: 100
Find: {x} ^ {y}  {@Note: precedence property set to 100}
Replace: pow({x}, {y})

Criteria: 5
Precedence: 60
Find: {x} \ {y}  {@Note: precedence property set to 60}
Replace: _round({x}, {y})

Criteria: 6
Comment: Bitwise AND and OR
Pass: 2

Criteria: 7
SkipOver: True
Find: ' {Comment:".*"}
Replace: [Skip over]

Criteria: 8
Comment: Bitwise AND and OR
BackColor: YellowGreen
Find: ({expr})
Replace: ({@Evaluate: Replace(Replace({expr}, "And", "&"), "Or", "|")})

Criteria: 9
Comment: Everything else
Pass: 3

Criteria: 10
SkipOver: True
Find: ' {Comment:".*"}
Replace: [Skip over]

Criteria: 11
Find: Mod
Replace: %

Criteria: 12
BackColor: Yellow
Find: Atn
Replace: atan

Criteria: 13
BackColor: Lime
Find: Sqr
Replace: sqrt

Criteria: 14
BackColor: Pink
Find: Cint
Replace: Integer

Criteria: 15
Find: Int(
Replace: __int64(

Criteria: 16
BackColor: Red
Find: Incr {var:1}
Replace: {var}++

Criteria: 17
BackColor: RoyalBlue
Find: Decr {var:1}
Replace: {var}--

Criteria: 18
Comment: Logical (short-circuit) AND
Find: And
Replace: &&

Criteria: 19
Comment: Logical (short-circuit) OR
BackColor: Purple
Find: Or
Replace: ||

Criteria: 20
BackColor: Khaki
Find: Xor
Replace: ^

Criteria: 21
BackColor: Green
Find: Not
Replace: ~

Criteria: 22
SkipOver: True
Find: #{metastatement:1} Not
Replace: [Skip over]

Criteria: 23
BackColor: Silver
Find: IsTrue {x%}  [{stop-: And | Or | Then | : }]
Replace: (({x}) != 0)

Criteria: 24
BackColor: SandyBrown
Find: IsFalse {x%} [{stop-: And | Or | Then | : }]
Replace: !({x})

Criteria: 25
BackColor: Violet
Find: <>
Replace: !=

Criteria: 26
Find: Randomize {number%}
Replace: srand({number})

Criteria: 27
Find: Rnd[()]
Replace: (rand() / RAND_MAX)

Criteria: 28
Find: Rnd({a%}, {b%})
Replace: (rand() % ({b}) + ({a}))

Criteria: 29
Find: Shift Right {ivar}, {countexpr%}
Replace: {ivar} = ({ivar} >> {countexpr})

Criteria: 30
Find: Shift Left {ivar}, {countexpr%}
Replace: {ivar} = ({ivar} << {countexpr})

Criteria: 31
Find: {func: Abs|Sin|Cos|Tan|Exp|Exp2|Log|Log2|Log10|Ceil}
Replace: {@Evaluate: LCase("{func}", "{'.*'}")}

Criteria: 32
Find: {func: Exp10 | Fix | Frac | Sgn}
Replace: PB_{@Evaluate: UCase("{func}", "{'.*'}")}

Criteria: 33
PassOnce: False
Find: {func: Min | Max}[{ {int: &} | {str: $} | {dbl: } }]
      ({args})
Replace: PB_{@Evaluate:
            Type = "(double)"
            IIf("{int}" <> "", Type = "(int)")
            IIf("{str}" <> "", Type = "(string)")
            UCase("{func}", "{'.*'}")
         }{int:_INT}{str:_STR}(ARGCOUNT({@Evaluate:
         Tally({args}, ",", Skip("({nest})"))+1}), {@Evaluate:
         Type + Replace({args}, ",", ", "+Type, Skip("({nest})"))})

# End Search


Add docs for dep checker's ignore button

/// HL-Docs: feature:ModDependencyCheck; issue:524; tags:compatibility
/// Allows mods to declare required and incompatible mods. The Highlander
/// will show popups for missing requirements and detected incompatibilities.
///
/// ## Terminology
///
/// We'll need to distinguish a few identifiers in mod project setups to explain this feature,
/// so here's a short rundown.
///
/// * **`DLCName`** is the actual ID of the mod. It's always the base name of the `.XComMod` file,
/// so `YetAnotherF1.XComMod` has a DLCName of `YetAnotherF1`. This is also the name that mod launchers
/// specify in the `ActiveMods` list, and the way the game knows how to load that mod. Every mod has exactly
/// one DLCName. Mods with the same DLCName can only be enabled or disabled together.
/// The game stores the `DLCName` in the save file, and shows a warning upon attempting to load a save file
/// when it had recorded a mod that's no longer enabled.
/// * **`DLCIdentifier`** is an identifier corresponding to a `X2DownloadableContentInfo` classes.
/// Every mod has zero, one, or several `X2DownloadableContentInfo` classes, and the DLCIdentifier may be empty for
/// any of them. This DLCIdentifier is used for some customization aspects (like part icons or slider names) and
/// narrative content options (for the official DLCs). It's also used in CHL's Run Order (still need docs, sorry)
/// since Run Order is all about `X2DownloadableContentInfo` classes.
///
/// In the default ModBuddy mod project, the mod has exactly one `X2DownloadableContentInfo` subclass
/// with a DLCIdentifier identical to the DLCName. However, config-only mods have no `X2DownloadableContentInfo`
/// at all, and some mods may have one but misconfigured the class so that the `DLCIdentifier` is empty.
///
/// ## CHModDependency
///
/// Now for the actual feature: Let's call the information about a mod provided to
/// the dependency checker *dependency info*, or *DepInfo*. A mod declares dependency
/// info through configuration entries for a class of type `CHModDependency` in `XComGame.ini`.
/// Let's look at an example upfront (taken from [Musashi's RPG Overhaul](https://steamcommunity.com/sharedfiles/filedetails/?id=1280477867)):
///
/// ```ini
/// [XCOM2RPGOverhaul CHModDependency]
/// DisplayName="Musashis RPG Overhaul"
///
/// +IncompatibleMods="NewPromotionScreenbyDefault"
/// +IncompatibleMods="DetailedSoldierListWOTC"
/// +IncompatibleMods="ABetterBarracksTLE"
/// +IncompatibleMods="ABetterBarracks"
/// +IncompatibleMods="ViewLockedSkillsWotc"
/// +IncompatibleMods="AddMintToMyChocolate"
/// +IncompatibleMods="RevisedWeaponUpgrades"
///
/// +RequiredMods="WOTC_LW2SecondaryWeapons"
/// +RequiredMods="PrimarySecondaries"
/// +RequiredMods="BetterSecondWaveSupport"
///
/// +IgnoreRequiredMods="NewPromotionScreenbyDefault"
/// +IgnoreRequiredMods="ViewLockedSkillsWotc"
/// +IgnoreRequiredMods="DetailedSoldierListWOTC"
/// ```
///
/// `CHModDependency` is the class that contains our DepInfo. That class is
/// `perobjectconfig`, so we can provide unique configuration for differently
/// named instances of the class. In this case, since the DLCName of RPGO is
/// `XCOM2RPGOverhaul`, we use that in the header.
///
/// `DisplayName` is a human-readable name of the mod. This is used for the actual
/// popup that says for example "<DisplayName> detected INCOMPATIBLE mods".
///
/// `IncompatibleMods` is a list of DLCNames that should not be enabled together
/// with this mod. For every mod with an enabled incompatible mod, there will be a popup
/// that lists all enabled incompatible mods.
///
/// `RequiredMods` is a list of DLCNames that should be enabled together with
/// this mod. For every mod with a missing required mod, there will be a popup
/// that lists all missing requirements.
///
/// `IgnoreRequiredMods` is a list of DLCNames that should be considered enabled if
/// this mod is enabled. For example, RPGO integrates `NewPromotionScreenbyDefault`,
/// so another mod should not consider `NewPromotionScreenbyDefault` missing if RPGO
/// is enabled.
///
/// There also is a `IgnoreIncompatibleMods` list of DLCNames that allows mods to
/// suppress incompatibilites. For example, an overhaul can consider itself
/// incompatible with a mod that adds a new weapon type unless a "bridge mod" is
/// installed that provides functionality the overhaul expects -- that mod would then
/// add `+IgnoreIncompatibleMods="ThatNewWeaponMod"`.
///
/// This is what the popup for missing requirements looks like:
/// ![Screenshot of RPGO's missing required mods](https://i.imgur.com/D1G6ZF7.png)
/// Since the missing requirements aren't enabled, we don't have any info about their
/// DisplayName.
///
/// ## How the dependency checker retrieves dependency info
///
/// The dependency checker looks at the config objects from
///
/// * All currently enabled DLCNames
/// * All non-empty DLCIdentifiers from found `X2DownloadableContentInfo` classes
///
/// while ignoring duplicates.
/// This means that mods can easily provide dependency info for other mods --
/// the config object will be ignored if the corresponding DLCName isn't
/// enabled. This also allows mods to add friendly names for other mods so
/// that even if the mod isn't installed or doesn't set a `DisplayName`.
///
/// For example, `AddMintToMyChocolate` doesn't participate in the CHL depencency
/// checker at all, but this DLCName is kind of confusing and a reported incompatibility
/// would leave users unable to figure out what the actual conflict is.
///
/// RPGO could add this to its `XComGame.ini` so that the name becomes clearer:
///
/// ```ini
/// [AddMintToMyChocolate CHModDependency]
/// DisplayName="Classless XCOM: MINT"
/// ```
///
/// and the popup would display that incompatibility as "Classless XCOM: MINT (AddMintToMyChocolate)".
/// The same system can also be used to provide a DisplayName for requirements that may be missing
/// and as such can't inform the dependency checker about their DisplayName.
///
/// If the user presses "Do not show me this again", the Highlander will store the object
/// name (DLCName or DLCIdentifier, depending on how the depencency checker found it in
/// the first place) of the mod that provides this data in a user config file
/// (`%USERPROFILE%/Documents/My Games/XCOM 2 War of the Chosen/XComGame/Config/X2WOTCCommunityHighlander_NullConfig.ini`)
/// and won't show this popup again.

class CHModDependency extends Object perobjectconfig Config(Game);

var config array<string> IncompatibleMods;
var config array<string> IgnoreIncompatibleMods;
var config array<string> RequiredMods;
var config array<string> IgnoreRequiredMods;
var config string DisplayName;

final function bool IsInteresting()
{
	return IncompatibleMods.Length > 0 || RequiredMods.Length > 0
		|| IgnoreIncompatibleMods.Length > 0 || IgnoreRequiredMods.Length > 0
		|| DisplayName != "";
}

/// HL-Docs: feature:ModDependencyCheck; issue:524; tags:compatibility
/// Allows mods to declare required and incompatible mods. The Highlander
/// will show popups for missing requirements and detected incompatibilities.
///
/// ## Terminology
///
/// We'll need to distinguish a few identifiers in mod project setups to explain this feature,
/// so here's a short rundown.
///
/// * **`DLCName`** is the actual ID of the mod. It's always the base name of the `.XComMod` file,
/// so `YetAnotherF1.XComMod` has a DLCName of `YetAnotherF1`. This is also the name that mod launchers
/// specify in the `ActiveMods` list, and the way the game knows how to load that mod. Every mod has exactly
/// one DLCName. Mods with the same DLCName can only be enabled or disabled together.
/// The game stores the `DLCName` in the save file, and shows a warning upon attempting to load a save file
/// when it had recorded a mod that's no longer enabled.
/// * **`DLCIdentifier`** is an identifier corresponding to a `X2DownloadableContentInfo` classes.
/// Every mod has zero, one, or several `X2DownloadableContentInfo` classes, and the DLCIdentifier may be empty for
/// any of them. This DLCIdentifier is used for some customization aspects (like part icons or slider names) and
/// narrative content options (for the official DLCs). It's also used in CHL's Run Order (still need docs, sorry)
/// since Run Order is all about `X2DownloadableContentInfo` classes.
///
/// In the default ModBuddy mod project, the mod has exactly one `X2DownloadableContentInfo` subclass
/// with a DLCIdentifier identical to the DLCName. However, config-only mods have no `X2DownloadableContentInfo`
/// at all, and some mods may have one but misconfigured the class so that the `DLCIdentifier` is empty.
///
/// ## CHModDependency
///
/// Now for the actual feature: Let's call the information about a mod provided to
/// the dependency checker *dependency info*, or *DepInfo*. A mod declares dependency
/// info through configuration entries for a class of type `CHModDependency` in `XComGame.ini`.
/// Let's look at an example upfront (taken from [Musashi's RPG Overhaul](https://steamcommunity.com/sharedfiles/filedetails/?id=1280477867)):
///
/// ```ini
/// [XCOM2RPGOverhaul CHModDependency]
/// DisplayName="Musashis RPG Overhaul"
///
/// +IncompatibleMods="NewPromotionScreenbyDefault"
/// +IncompatibleMods="DetailedSoldierListWOTC"
/// +IncompatibleMods="ABetterBarracksTLE"
/// +IncompatibleMods="ABetterBarracks"
/// +IncompatibleMods="ViewLockedSkillsWotc"
/// +IncompatibleMods="AddMintToMyChocolate"
/// +IncompatibleMods="RevisedWeaponUpgrades"
///
/// +RequiredMods="WOTC_LW2SecondaryWeapons"
/// +RequiredMods="PrimarySecondaries"
/// +RequiredMods="BetterSecondWaveSupport"
///
/// +IgnoreRequiredMods="NewPromotionScreenbyDefault"
/// +IgnoreRequiredMods="ViewLockedSkillsWotc"
/// +IgnoreRequiredMods="DetailedSoldierListWOTC"
/// ```
///
/// `CHModDependency` is the class that contains our DepInfo. That class is
/// `perobjectconfig`, so we can provide unique configuration for differently
/// named instances of the class. In this case, since the DLCName of RPGO is
/// `XCOM2RPGOverhaul`, we use that in the header.
///
/// `DisplayName` is a human-readable name of the mod. This is used for the actual
/// popup that says for example "<DisplayName> detected INCOMPATIBLE mods".
///
/// `IncompatibleMods` is a list of DLCNames that should not be enabled together
/// with this mod. For every mod with an enabled incompatible mod, there will be a popup
/// that lists all enabled incompatible mods.
///
/// `RequiredMods` is a list of DLCNames that should be enabled together with
/// this mod. For every mod with a missing required mod, there will be a popup
/// that lists all missing requirements.
///
/// `IgnoreRequiredMods` is a list of DLCNames that should be considered enabled if
/// this mod is enabled. For example, RPGO integrates `NewPromotionScreenbyDefault`,
/// so another mod should not consider `NewPromotionScreenbyDefault` missing if RPGO
/// is enabled.
///
/// There also is a `IgnoreIncompatibleMods` list of DLCNames that allows mods to
/// suppress incompatibilites. For example, an overhaul can consider itself
/// incompatible with a mod that adds a new weapon type unless a "bridge mod" is
/// installed that provides functionality the overhaul expects -- that mod would then
/// add `+IgnoreIncompatibleMods="ThatNewWeaponMod"`.
///
/// This is what the popup for missing requirements looks like:
/// ![Screenshot of RPGO's missing required mods](https://i.imgur.com/D1G6ZF7.png)
/// Since the missing requirements aren't enabled, we don't have any info about their
/// DisplayName.
///
/// ## How the dependency checker retrieves dependency info
///
/// The dependency checker looks at the config objects from
///
/// * All currently enabled DLCNames
/// * All non-empty DLCIdentifiers from found `X2DownloadableContentInfo` classes
///
/// while ignoring duplicates.
/// This means that mods can easily provide dependency info for other mods --
/// the config object will be ignored if the corresponding DLCName isn't
/// enabled. This also allows mods to add friendly names for other mods so
/// that even if the mod isn't installed or doesn't set a `DisplayName`.
///
/// For example, `AddMintToMyChocolate` doesn't participate in the CHL depencency
/// checker at all, but this DLCName is kind of confusing and a reported incompatibility
/// would leave users unable to figure out what the actual conflict is.
///
/// RPGO could add this to its `XComGame.ini` so that the name becomes clearer:
///
/// ```ini
/// [AddMintToMyChocolate CHModDependency]
/// DisplayName="Classless XCOM: MINT"
/// ```
///
/// and the popup would display that incompatibility as "Classless XCOM: MINT (AddMintToMyChocolate)".
/// The same system can also be used to provide a DisplayName for requirements that may be missing
/// and as such can't inform the dependency checker about their DisplayName.

class CHModDependency extends Object perobjectconfig Config(Game);

var config array<string> IncompatibleMods;
var config array<string> IgnoreIncompatibleMods;
var config array<string> RequiredMods;
var config array<string> IgnoreRequiredMods;
var config string DisplayName;

final function bool IsInteresting()
{
	return IncompatibleMods.Length > 0 || RequiredMods.Length > 0
		|| IgnoreIncompatibleMods.Length > 0 || IgnoreRequiredMods.Length > 0
		|| DisplayName != "";
}