Update to 13.1 (github source package)
This commit is contained in:
@@ -218,20 +218,27 @@ public:
|
||||
* store the current configuration of Scripts. Required.
|
||||
* - description A single line describing the setting. Required.
|
||||
* - min_value The minimum value of this setting. Required for integer
|
||||
* settings and not allowed for boolean settings.
|
||||
* settings and not allowed for boolean settings. The value will be
|
||||
* clamped in the range [MIN(int32), MAX(int32)] (inclusive).
|
||||
* - max_value The maximum value of this setting. Required for integer
|
||||
* settings and not allowed for boolean settings.
|
||||
* settings and not allowed for boolean settings. The value will be
|
||||
* clamped in the range [MIN(int32), MAX(int32)] (inclusive).
|
||||
* - easy_value The default value if the easy difficulty level
|
||||
* is selected. Required.
|
||||
* is selected. Required. The value will be clamped in the range
|
||||
* [MIN(int32), MAX(int32)] (inclusive).
|
||||
* - medium_value The default value if the medium difficulty level
|
||||
* is selected. Required.
|
||||
* is selected. Required. The value will be clamped in the range
|
||||
* [MIN(int32), MAX(int32)] (inclusive).
|
||||
* - hard_value The default value if the hard difficulty level
|
||||
* is selected. Required.
|
||||
* is selected. Required. The value will be clamped in the range
|
||||
* [MIN(int32), MAX(int32)] (inclusive).
|
||||
* - custom_value The default value if the custom difficulty level
|
||||
* is selected. Required.
|
||||
* is selected. Required. The value will be clamped in the range
|
||||
* [MIN(int32), MAX(int32)] (inclusive).
|
||||
* - random_deviation If this property has a nonzero value, then the
|
||||
* actual value of the setting in game will be randomized in the range
|
||||
* [user_configured_value - random_deviation, user_configured_value + random_deviation] (inclusive).
|
||||
* random_deviation sign is ignored and the value is clamped in the range [0, MAX(int32)] (inclusive).
|
||||
* Not allowed if the CONFIG_RANDOM flag is set, otherwise optional.
|
||||
* - step_size The increase/decrease of the value every time the user
|
||||
* clicks one of the up/down arrow buttons. Optional, default is 1.
|
||||
@@ -247,13 +254,16 @@ public:
|
||||
* user will see the corresponding name.
|
||||
* @param setting_name The name of the setting.
|
||||
* @param value_names A table that maps values to names. The first
|
||||
* character of every identifier is ignored and the rest should
|
||||
* character of every identifier is ignored, the second character
|
||||
* could be '_' to indicate the value is negative, and the rest should
|
||||
* be an integer of the value you define a name for. The value
|
||||
* is a short description of that value.
|
||||
* To define labels for a setting named "competition_level" you could
|
||||
* for example call it like this:
|
||||
* AddLabels("competition_level", {_0 = "no competition", _1 = "some competition",
|
||||
* _2 = "a lot of competition"});
|
||||
* Another example, for a setting with a negative value:
|
||||
* AddLabels("amount", {__1 = "less than one", _0 = "none", _1 = "more than one"});
|
||||
*
|
||||
* @note This is a function provided by OpenTTD, you don't have to
|
||||
* include it in your Script but should just call it from GetSettings.
|
||||
|
||||
@@ -82,20 +82,18 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
return GetStorage()->mode_instance;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetLastCommand(TileIndex tile, const CommandDataBuffer &data, Commands cmd)
|
||||
/* static */ void ScriptObject::SetLastCommand(const CommandDataBuffer &data, Commands cmd)
|
||||
{
|
||||
ScriptStorage *s = GetStorage();
|
||||
Debug(script, 6, "SetLastCommand company={:02d} tile={:06x} cmd={} data={}", s->root_company, tile, cmd, FormatArrayAsHex(data));
|
||||
s->last_tile = tile;
|
||||
Debug(script, 6, "SetLastCommand company={:02d} cmd={} data={}", s->root_company, cmd, FormatArrayAsHex(data));
|
||||
s->last_data = data;
|
||||
s->last_cmd = cmd;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, const CommandDataBuffer &data, Commands cmd)
|
||||
/* static */ bool ScriptObject::CheckLastCommand(const CommandDataBuffer &data, Commands cmd)
|
||||
{
|
||||
ScriptStorage *s = GetStorage();
|
||||
Debug(script, 6, "CheckLastCommand company={:02d} tile={:06x} cmd={} data={}", s->root_company, tile, cmd, FormatArrayAsHex(data));
|
||||
if (s->last_tile != tile) return false;
|
||||
Debug(script, 6, "CheckLastCommand company={:02d} cmd={} data={}", s->root_company, cmd, FormatArrayAsHex(data));
|
||||
if (s->last_cmd != cmd) return false;
|
||||
if (s->last_data != data) return false;
|
||||
return true;
|
||||
|
||||
@@ -105,12 +105,12 @@ protected:
|
||||
/**
|
||||
* Store the latest command executed by the script.
|
||||
*/
|
||||
static void SetLastCommand(TileIndex tile, const CommandDataBuffer &data, Commands cmd);
|
||||
static void SetLastCommand(const CommandDataBuffer &data, Commands cmd);
|
||||
|
||||
/**
|
||||
* Check if it's the latest command executed by the script.
|
||||
*/
|
||||
static bool CheckLastCommand(TileIndex tile, const CommandDataBuffer &data, Commands cmd);
|
||||
static bool CheckLastCommand(const CommandDataBuffer &data, Commands cmd);
|
||||
|
||||
/**
|
||||
* Sets the DoCommand costs counter to a value.
|
||||
@@ -340,7 +340,7 @@ bool ScriptObject::ScriptDoCommandHelper<Tcmd, Tret(*)(DoCommandFlag, Targs...)>
|
||||
if constexpr ((::GetCommandFlags<Tcmd>() & CMD_CLIENT_ID) != 0) ScriptObjectInternal::SetClientIds(args, std::index_sequence_for<Targs...>{});
|
||||
|
||||
/* Store the command for command callback validation. */
|
||||
if (!estimate_only && networking) ScriptObject::SetLastCommand(tile, EndianBufferWriter<CommandDataBuffer>::FromValue(args), Tcmd);
|
||||
if (!estimate_only && networking) ScriptObject::SetLastCommand(EndianBufferWriter<CommandDataBuffer>::FromValue(args), Tcmd);
|
||||
|
||||
/* Try to perform the command. */
|
||||
Tret res = ::Command<Tcmd>::Unsafe((StringID)0, networking ? ScriptObject::GetDoCommandCallback() : nullptr, false, estimate_only, tile, args);
|
||||
|
||||
Reference in New Issue
Block a user