Codechange: [Script] Use helper function over direct casting CompanyID
In the script's API `COMPANY_INVALID` has a value of -1, whereas the internal game's `INVALID_COMPANY` has a value of 255. Since the script's API also has a `COMPANY_SPECTATOR` with a value of 255, these enumerations cannot be easily reconciled by casting. As such, replace all casts in the script API with either ScriptCompany::FromScriptCompanyID or ScriptCompany::ToScriptCompanyID. Also make clear whether CompanyID is ::CompanyID or ScriptCompany::CompanyID by using either one of those over CompanyID in the script's API.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#define SCRIPT_COMPANYMODE_HPP
|
||||
|
||||
#include "script_object.hpp"
|
||||
#include "script_company.hpp"
|
||||
|
||||
/**
|
||||
* Class to switch the current company.
|
||||
@@ -30,7 +31,7 @@
|
||||
*/
|
||||
class ScriptCompanyMode : public ScriptObject {
|
||||
private:
|
||||
CompanyID last_company; ///< The previous company we were in.
|
||||
::CompanyID last_company; ///< The previous company we were in.
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -40,7 +41,7 @@ public:
|
||||
* @note When the instance is destroyed, it restores the company that was
|
||||
* current when the instance was created!
|
||||
*/
|
||||
ScriptCompanyMode(SQInteger company);
|
||||
ScriptCompanyMode(ScriptCompany::CompanyID company);
|
||||
|
||||
/**
|
||||
* Destroying this instance reset the company to that what it was
|
||||
|
||||
Reference in New Issue
Block a user