Add: precondition checks to functions that work with both valid company and deity
These are functions that either use ScriptObject::Command or 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. At this moment these checks will not do anything useful, as either IsValid or IsDeity from ScriptCompanyMode returns true, but that will change later.
This commit is contained in:
@@ -62,6 +62,23 @@
|
||||
#define EnforceDeityMode(returnval) \
|
||||
EnforcePreconditionCustomError(returnval, ScriptCompanyMode::IsDeity(), ScriptError::ERR_PRECONDITION_INVALID_COMPANY)
|
||||
|
||||
/**
|
||||
* Helper to enforce the precondition that the company mode is valid or that we are a deity.
|
||||
* @param returnval The value to return on failure.
|
||||
*/
|
||||
#define EnforceDeityOrCompanyModeValid(returnval) \
|
||||
EnforcePreconditionCustomError(returnval, ScriptCompanyMode::IsDeity() || ScriptCompanyMode::IsValid(), ScriptError::ERR_PRECONDITION_INVALID_COMPANY)
|
||||
|
||||
/**
|
||||
* Helper to enforce the precondition that the company mode is valid or that we are a deity.
|
||||
*/
|
||||
#define EnforceDeityOrCompanyModeValid_Void() \
|
||||
if (!(ScriptCompanyMode::IsDeity() || ScriptCompanyMode::IsValid())) { \
|
||||
ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_INVALID_COMPANY); \
|
||||
return; \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class that handles all error related functions.
|
||||
* @api ai game
|
||||
|
Reference in New Issue
Block a user