summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2019-02-15 20:14:50 +0000
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-03-03 09:15:39 +0100
commit5a5944867dfeaa556ec78c23af4796adb28a6a9f (patch)
treef735f1c944bbf765bbcdfe9311cc7ed86ed71135 /src
parent5d3ccae6c5bd3f328ad0d8e68ae7c69451b9ca48 (diff)
downloadopenttd-5a5944867dfeaa556ec78c23af4796adb28a6a9f.tar.xz
Add: Add parent_group_id parameter to CreateGroup()
Diffstat (limited to 'src')
-rw-r--r--src/script/api/ai/ai_group.hpp.sq2
-rw-r--r--src/script/api/ai_changelog.hpp1
-rw-r--r--src/script/api/script_group.cpp4
-rw-r--r--src/script/api/script_group.hpp3
4 files changed, 6 insertions, 4 deletions
diff --git a/src/script/api/ai/ai_group.hpp.sq b/src/script/api/ai/ai_group.hpp.sq
index cae6cb3ac..5fa50ae1b 100644
--- a/src/script/api/ai/ai_group.hpp.sq
+++ b/src/script/api/ai/ai_group.hpp.sq
@@ -26,7 +26,7 @@ void SQAIGroup_Register(Squirrel *engine)
SQAIGroup.DefSQConst(engine, ScriptGroup::GROUP_INVALID, "GROUP_INVALID");
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::IsValidGroup, "IsValidGroup", 2, ".i");
- SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::CreateGroup, "CreateGroup", 2, ".i");
+ SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::CreateGroup, "CreateGroup", 3, ".ii");
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::DeleteGroup, "DeleteGroup", 2, ".i");
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::GetVehicleType, "GetVehicleType", 2, ".i");
SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::SetName, "SetName", 3, ".i.");
diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp
index 24b5d5b51..0afe4e08c 100644
--- a/src/script/api/ai_changelog.hpp
+++ b/src/script/api/ai_changelog.hpp
@@ -29,6 +29,7 @@
*
* Other changes:
* \li AIBridge::GetName takes one extra parameter to refer the vehicle type
+ * \li AIGroup::CreateGroup gains parent_group_id parameter
*
* \b 1.8.0
*
diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp
index 0e89c3c60..16a50bc17 100644
--- a/src/script/api/script_group.cpp
+++ b/src/script/api/script_group.cpp
@@ -28,9 +28,9 @@
return g != NULL && g->owner == ScriptObject::GetCompany();
}
-/* static */ ScriptGroup::GroupID ScriptGroup::CreateGroup(ScriptVehicle::VehicleType vehicle_type)
+/* static */ ScriptGroup::GroupID ScriptGroup::CreateGroup(ScriptVehicle::VehicleType vehicle_type, GroupID parent_group_id)
{
- if (!ScriptObject::DoCommand(0, (::VehicleType)vehicle_type, INVALID_GROUP, CMD_CREATE_GROUP, NULL, &ScriptInstance::DoCommandReturnGroupID)) return GROUP_INVALID;
+ if (!ScriptObject::DoCommand(0, (::VehicleType)vehicle_type, parent_group_id, CMD_CREATE_GROUP, NULL, &ScriptInstance::DoCommandReturnGroupID)) return GROUP_INVALID;
/* In case of test-mode, we return GroupID 0 */
return (ScriptGroup::GroupID)0;
diff --git a/src/script/api/script_group.hpp b/src/script/api/script_group.hpp
index a41196718..9e88eaff1 100644
--- a/src/script/api/script_group.hpp
+++ b/src/script/api/script_group.hpp
@@ -42,11 +42,12 @@ public:
/**
* 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, INVALID_GROUP for top-level.
* @return The GroupID of the new group, or an invalid GroupID when
* it failed. Check the return value using IsValidGroup(). In test-mode
* 0 is returned if it was successful; any other value indicates failure.
*/
- static GroupID CreateGroup(ScriptVehicle::VehicleType vehicle_type);
+ static GroupID CreateGroup(ScriptVehicle::VehicleType vehicle_type, GroupID parent_group_id);
/**
* Delete the given group. When the deletion succeeds all vehicles in the