(svn r24982) -Fix [FS#5465]: [Script] Crash when passing too many parameters

This commit is contained in:
rubidium
2013-02-08 20:34:27 +00:00
parent bb225ae39e
commit 4e61c1770d
13 changed files with 151 additions and 121 deletions

View File

@@ -38,6 +38,21 @@
return returnval; \
}
/**
* Helper to write precondition enforcers for the script API in an abbreviated manner for encoded texts.
* @param returnval The value to return on failure.
* @param string The string that is checked.
*/
#define EnforcePreconditionEncodedText(returnval, string) \
if ((string) == NULL) { \
ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_TOO_MANY_PARAMETERS); \
return returnval; \
} \
if (StrEmpty(string)) { \
ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_FAILED); \
return returnval; \
}
/**
* Class that handles all error related functions.
* @api ai game
@@ -81,6 +96,8 @@ public:
ERR_PRECONDITION_FAILED, // []
/** A string supplied was too long */
ERR_PRECONDITION_STRING_TOO_LONG, // []
/** A string had too many parameters */
ERR_PRECONDITION_TOO_MANY_PARAMETERS, // []
/** The company you use is invalid */
ERR_PRECONDITION_INVALID_COMPANY, // []
/** An error returned by a NewGRF. No possibility to get the exact error in an script readable format */