Add: company mode enforcement checks to functions with command or company access

Command functions are those that call ScriptObject::Command, and functions
with company access are any that call ScriptObject::GetCompany. This is a bit
over-protective, but having the check everywhere makes it easier to validate
that no check is missing automatically instead of by review.
This commit is contained in:
Rubidium
2023-03-02 21:22:37 +01:00
committed by rubidium42
parent 534f2419ad
commit 8d443d1379
10 changed files with 87 additions and 0 deletions

View File

@@ -138,6 +138,7 @@ public:
* Set the name of your company.
* @param name The new name of the company (can be either a raw string, or a ScriptText object).
* @pre name != null && len(name) != 0.
* @game @pre ScriptCompanyMode::IsValid().
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
* @return True if the name was changed.
*/
@@ -155,6 +156,7 @@ public:
* Set the name of your president.
* @param name The new name of the president (can be either a raw string, or a ScriptText object).
* @pre name != null && len(name) != 0.
* @game @pre ScriptCompanyMode::IsValid().
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
* @return True if the name was changed.
*/
@@ -172,6 +174,7 @@ public:
* Set the gender of the president of your company.
* @param gender The new gender for your president.
* @pre GetPresidentGender(ScriptCompany.COMPANY_SELF) != gender.
* @game @pre ScriptCompanyMode::IsValid().
* @return True if the gender was changed.
* @note When successful a random face will be created.
* @api -game
@@ -333,6 +336,7 @@ public:
/**
* Set whether autorenew is enabled for your company.
* @param autorenew The new autorenew status.
* @game @pre ScriptCompanyMode::IsValid().
* @return True if autorenew status has been modified.
* @api -game
*/
@@ -350,6 +354,7 @@ public:
* Set the number of months before/after max age to autorenew an engine for your company.
* @param months The new months between autorenew.
* The value will be clamped to MIN(int16) .. MAX(int16).
* @game @pre ScriptCompanyMode::IsValid().
* @return True if autorenew months has been modified.
* @api -game
*/
@@ -366,6 +371,7 @@ public:
/**
* Set the minimum money needed to autorenew an engine for your company.
* @param money The new minimum required money for autorenew to work.
* @game @pre ScriptCompanyMode::IsValid().
* @return True if autorenew money has been modified.
* @pre money >= 0
* @pre money < 2**32
@@ -385,6 +391,7 @@ public:
* Set primary colour for your company.
* @param scheme Livery scheme to set.
* @param colour Colour to set.
* @game @pre ScriptCompanyMode::IsValid().
* @return False if unable to set primary colour of the livery scheme (e.g. colour in use).
*/
static bool SetPrimaryLiveryColour(LiveryScheme scheme, Colours colour);
@@ -393,6 +400,7 @@ public:
* Set secondary colour for your company.
* @param scheme Livery scheme to set.
* @param colour Colour to set.
* @game @pre ScriptCompanyMode::IsValid().
* @return False if unable to set secondary colour of the livery scheme.
*/
static bool SetSecondaryLiveryColour(LiveryScheme scheme, Colours colour);