Add: precondition checks to functions that work with both valid company and deity
These are functions that either use ScriptObject::Command or ScriptObject::GetCompany. This is a bit over-protective, but having the check everywhere makes it easier to validate that no check is missing automatically instead of by review. At this moment these checks will not do anything useful, as either IsValid or IsDeity from ScriptCompanyMode returns true, but that will change later.
This commit is contained in:
@@ -72,6 +72,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
|
||||
/* static */ bool ScriptBridge::BuildBridge(ScriptVehicle::VehicleType vehicle_type, BridgeID bridge_id, TileIndex start, TileIndex end)
|
||||
{
|
||||
EnforceDeityOrCompanyModeValid(false);
|
||||
EnforcePrecondition(false, start != end);
|
||||
EnforcePrecondition(false, ::IsValidTile(start) && ::IsValidTile(end));
|
||||
EnforcePrecondition(false, TileX(start) == TileX(end) || TileY(start) == TileY(end));
|
||||
@@ -95,6 +96,8 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
|
||||
/* static */ bool ScriptBridge::_BuildBridgeRoad1()
|
||||
{
|
||||
EnforceDeityOrCompanyModeValid(false);
|
||||
|
||||
/* Build the piece of road on the 'start' side of the bridge */
|
||||
TileIndex end = ScriptObject::GetCallbackVariable(0);
|
||||
TileIndex start = ScriptObject::GetCallbackVariable(1);
|
||||
@@ -107,6 +110,8 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
|
||||
/* static */ bool ScriptBridge::_BuildBridgeRoad2()
|
||||
{
|
||||
EnforceDeityOrCompanyModeValid(false);
|
||||
|
||||
/* Build the piece of road on the 'end' side of the bridge */
|
||||
TileIndex end = ScriptObject::GetCallbackVariable(0);
|
||||
TileIndex start = ScriptObject::GetCallbackVariable(1);
|
||||
|
Reference in New Issue
Block a user