Changeset - r23387:5159426b3723
[Not reviewed]
master
0 15 0
Peter Nelson - 5 years ago 2019-02-15 20:14:50
peter1138@openttd.org
Add: Add parent_group_id parameter to CreateGroup()
15 files changed with 77 insertions and 5 deletions:
0 comments (0 inline, 0 general)
bin/ai/compat_0.7.nut
Show inline comments
 
@@ -374,3 +374,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/compat_1.0.nut
Show inline comments
 
@@ -126,3 +126,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/compat_1.1.nut
Show inline comments
 
@@ -63,3 +63,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/compat_1.2.nut
Show inline comments
 
@@ -15,3 +15,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/compat_1.3.nut
Show inline comments
 
@@ -15,3 +15,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/compat_1.4.nut
Show inline comments
 
@@ -15,3 +15,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/compat_1.5.nut
Show inline comments
 
@@ -15,3 +15,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/compat_1.6.nut
Show inline comments
 
@@ -15,3 +15,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/compat_1.7.nut
Show inline comments
 
@@ -15,3 +15,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/compat_1.8.nut
Show inline comments
 
@@ -15,3 +15,10 @@ AIBridge.GetName <- function(bridge_id)
 
{
 
	return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
 
}
 

	
 
/* 1.9 adds parent_group_id to CreateGroup function */
 
AIGroup._CreateGroup <- AIGroup.CreateGroup;
 
AIGroup.CreateGroup <- function(vehicle_type)
 
{
 
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
 
}
bin/ai/regression/tst_regression/main.nut
Show inline comments
 
@@ -574,7 +574,7 @@ function Regression::Group()
 
	local vehicle = AIVehicle.BuildVehicle(10000, 116);
 
	print("  AIVehicle.BuildVehicle(): " + vehicle);
 
	print("  GetNumEngines():          " + AIGroup.GetNumEngines(AIGroup.GROUP_ALL, 116));
 
	local group = AIGroup.CreateGroup(AIVehicle.VT_ROAD);
 
	local group = AIGroup.CreateGroup(AIVehicle.VT_ROAD, AIGroup.GROUP_INVALID);
 
	print("  CreateGroup():            " + group);
 
	print("  MoveVehicle():            " + AIGroup.MoveVehicle(group, vehicle));
 
	print("  GetNumEngines():          " + AIGroup.GetNumEngines(group, 116));
src/script/api/ai/ai_group.hpp.sq
Show inline comments
 
@@ -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.");
src/script/api/ai_changelog.hpp
Show inline comments
 
@@ -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
 
 *
src/script/api/script_group.cpp
Show inline comments
 
@@ -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;
src/script/api/script_group.hpp
Show inline comments
 
@@ -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
0 comments (0 inline, 0 general)