Since OpenTTD v1.13 the function AIGroup.CreateGroup() requires two parameters. Some AIs can crash because older versions of AIGroup.CreateGroup() function requires only one parameter.
In SuperSimpleAI v39 I fixed this with this class:
Code: Select all
/**
* This file is part of SuperSimpleAI: An OpenTTD AI.
*
* Author: Jaume Sabater
*
* It's free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* You should have received a copy of the GNU General Public License
* with it. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Define the MyAIGroup class which extends the AIGroup functions.
*/
class MyAIGroup /* extends AIGroup */
{
/**
* Create a new group.
* @param vehicle_type The type of vehicle to create a group for.
* @param parent_group_id The parent group id to create this group under,
* GROUP_INVALID for top-level (default and optional).
* @return The GroupID of the new greup, or an invalid GroupID when it failed.
* Check the return value using AIGroup.IsValidGroup(). In test-mode 0
* is returned if it was successful; any other value indicates failure.
*/
static function CreateGroup(vehicle_type, parent_group_id = AIGroup.GROUP_INVALID);
}
local ottd_v = AIController.GetVersion();
local ottd_major = (ottd_v & 0xF0000000) >> 28;
local ottd_minor = (ottd_v & 0x0F000000) >> 24;
if (ottd_major > 0 && ottd_minor > 12) {
// Since OpenTTD 1.13 AIGroup.CreateGroup() requires two parameters.
function MyAIGroup::CreateGroup(vehicle_type, parent_group_id = AIGroup.GROUP_INVALID)
{
return AIGroup.CreateGroup(vehicle_type, parent_group_id);
}
} else {
function MyAIGroup::CreateGroup(vehicle_type, parent_group_id = AIGroup.GROUP_INVALID)
{
return AIGroup.CreateGroup(vehicle_type);
}
}