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
 
@@ -371,6 +371,13 @@ AIOrder.AIOF_INVALID <- AIOrder.OF_INVAL
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -123,6 +123,13 @@ AIOrder.AIOF_INVALID <- AIOrder.OF_INVAL
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -60,6 +60,13 @@ AIOrder.AIOF_INVALID <- AIOrder.OF_INVAL
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -12,6 +12,13 @@ AILog.Info("1.2 API compatibility in eff
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -12,6 +12,13 @@ AILog.Info("1.3 API compatibility in eff
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -12,6 +12,13 @@ AILog.Info("1.4 API compatibility in eff
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -12,6 +12,13 @@ AILog.Info("1.5 API compatibility in eff
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -12,6 +12,13 @@ AILog.Info("1.6 API compatibility in eff
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -12,6 +12,13 @@ AILog.Info("1.7 API compatibility in eff
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -12,6 +12,13 @@ AILog.Info("1.8 API compatibility in eff
 
/* 1.9 adds a vehicle type parameter. */
 
AIBridge._GetName <- AIBridge.GetName;
 
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
 
@@ -571,13 +571,13 @@ function Regression::Group()
 
	print("  GetEngineReplacement():   " + AIGroup.GetEngineReplacement(AIGroup.GROUP_ALL, 116));
 
	print("  GetNumEngines():          " + AIGroup.GetNumEngines(AIGroup.GROUP_ALL, 116));
 
	print("  AIRoad.BuildRoadDepot():  " + AIRoad.BuildRoadDepot(10000, 10001));
 
	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));
 
	print("  GetNumEngines():          " + AIGroup.GetNumEngines(AIGroup.GROUP_ALL, 116));
 
	print("  GetNumEngines():          " + AIGroup.GetNumEngines(AIGroup.GROUP_DEFAULT, 116));
 
	print("  GetName():                " + AIGroup.GetName(0));
src/script/api/ai/ai_group.hpp.sq
Show inline comments
 
@@ -23,13 +23,13 @@ void SQAIGroup_Register(Squirrel *engine
 

	
 
	SQAIGroup.DefSQConst(engine, ScriptGroup::GROUP_ALL,     "GROUP_ALL");
 
	SQAIGroup.DefSQConst(engine, ScriptGroup::GROUP_DEFAULT, "GROUP_DEFAULT");
 
	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.");
 
	SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::GetName,                     "GetName",                     2, ".i");
 
	SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::SetParent,                   "SetParent",                   3, ".ii");
 
	SQAIGroup.DefSQStaticMethod(engine, &ScriptGroup::GetParent,                   "GetParent",                   2, ".i");
src/script/api/ai_changelog.hpp
Show inline comments
 
@@ -26,12 +26,13 @@
 
 * \li AICompany::SetSecondaryLiveryColour
 
 * \li AICompany::GetPrimaryLiveryColour
 
 * \li AICompany::GetSecondaryLiveryColour
 
 *
 
 * 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
 
 *
 
 * No changes
 
 *
 
 * \b 1.7.0 - 1.7.2
src/script/api/script_group.cpp
Show inline comments
 
@@ -25,15 +25,15 @@
 
/* static */ bool ScriptGroup::IsValidGroup(GroupID group_id)
 
{
 
	const Group *g = ::Group::GetIfValid(group_id);
 
	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;
 
}
 

	
 
/* static */ bool ScriptGroup::DeleteGroup(GroupID group_id)
src/script/api/script_group.hpp
Show inline comments
 
@@ -39,17 +39,18 @@ public:
 
	 */
 
	static bool IsValidGroup(GroupID group_id);
 

	
 
	/**
 
	 * 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
 
	 *  given group will move to the GROUP_DEFAULT.
 
	 * @param group_id The group to delete.
 
	 * @pre IsValidGroup(group_id).
0 comments (0 inline, 0 general)