Merge branch 'master' into jgrpp

# Conflicts:
#	Makefile.bundle.in
#	src/os/macosx/string_osx.cpp
#	src/station_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2019-11-06 17:49:00 +00:00
68 changed files with 1594 additions and 1460 deletions

View File

@@ -50,6 +50,7 @@ void SQAIEvent_Register(Squirrel *engine)
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_GOAL_QUESTION_ANSWER, "ET_GOAL_QUESTION_ANSWER");
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_ROAD_RECONSTRUCTION, "ET_ROAD_RECONSTRUCTION");
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_AUTOREPLACED, "ET_VEHICLE_AUTOREPLACED");
SQAIEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");

View File

@@ -405,3 +405,19 @@ void SQAIEventRoadReconstruction_Register(Squirrel *engine)
SQAIEventRoadReconstruction.PostRegister(engine);
}
template <> const char *GetClassName<ScriptEventVehicleAutoReplaced, ST_AI>() { return "AIEventVehicleAutoReplaced"; }
void SQAIEventVehicleAutoReplaced_Register(Squirrel *engine)
{
DefSQClass<ScriptEventVehicleAutoReplaced, ST_AI> SQAIEventVehicleAutoReplaced("AIEventVehicleAutoReplaced");
SQAIEventVehicleAutoReplaced.PreRegister(engine, "AIEvent");
SQAIEventVehicleAutoReplaced.DefSQStaticMethod(engine, &ScriptEventVehicleAutoReplaced::Convert, "Convert", 2, ".x");
SQAIEventVehicleAutoReplaced.DefSQMethod(engine, &ScriptEventVehicleAutoReplaced::GetOldVehicleID, "GetOldVehicleID", 1, "x");
SQAIEventVehicleAutoReplaced.DefSQMethod(engine, &ScriptEventVehicleAutoReplaced::GetNewVehicleID, "GetNewVehicleID", 1, "x");
SQAIEventVehicleAutoReplaced.PostRegister(engine);
}

View File

@@ -34,6 +34,7 @@
* \li AIEngine::CanRunOnRoad
* \li AIEngine::HasPowerOnRoad
* \li AIRoadTypeList::RoadTypeList
* \li AIEventVehicleAutoReplaced
*
* Other changes:
* \li AITile::DemolishTile works without a selected company

View File

@@ -50,6 +50,7 @@ void SQGSEvent_Register(Squirrel *engine)
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_GOAL_QUESTION_ANSWER, "ET_GOAL_QUESTION_ANSWER");
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_ROAD_RECONSTRUCTION, "ET_ROAD_RECONSTRUCTION");
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_AUTOREPLACED, "ET_VEHICLE_AUTOREPLACED");
SQGSEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");

View File

@@ -55,6 +55,7 @@ public:
ET_GOAL_QUESTION_ANSWER,
ET_EXCLUSIVE_TRANSPORT_RIGHTS,
ET_ROAD_RECONSTRUCTION,
ET_VEHICLE_AUTOREPLACED,
};
/**

View File

@@ -1060,4 +1060,44 @@ public:
static ScriptEventRoadReconstruction *Convert(ScriptEventCompanyTown *instance) { return (ScriptEventRoadReconstruction *)instance; }
};
/**
* Event VehicleAutoReplaced, indicating a vehicle has been auto replaced.
* @api ai
*/
class ScriptEventVehicleAutoReplaced : public ScriptEvent {
public:
/**
* @param old_id The vehicle that has been replaced.
* @param new_id The vehicle that has been created in replacement.
*/
ScriptEventVehicleAutoReplaced(VehicleID old_id, VehicleID new_id) :
ScriptEvent(ET_VEHICLE_AUTOREPLACED),
old_id(old_id),
new_id(new_id)
{}
/**
* Convert an ScriptEvent to the real instance.
* @param instance The instance to convert.
* @return The converted instance.
*/
static ScriptEventVehicleAutoReplaced *Convert(ScriptEvent *instance) { return (ScriptEventVehicleAutoReplaced *)instance; }
/**
* Get the VehicleID of the vehicle that has been replaced.
* @return The VehicleID of the vehicle that has been replaced. This ID is no longer valid for referencing the vehicle.
*/
VehicleID GetOldVehicleID() { return this->old_id; }
/**
* Get the VehicleID of the vehicle that has been created in replacement.
* @return The VehicleID of the vehicle that has been created in replacement.
*/
VehicleID GetNewVehicleID() { return this->new_id; }
private:
VehicleID old_id; ///< The vehicle that has been replaced.
VehicleID new_id; ///< The vehicle that has been created in replacement.
};
#endif /* SCRIPT_EVENT_TYPES_HPP */

View File

@@ -123,7 +123,8 @@
EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
uint32 seed = ::InteractiveRandom();
return ScriptObject::DoCommand(tile, (1 << 16) | (::InteractiveRandomRange(::GetIndustrySpec(industry_type)->num_table) << 8) | industry_type, seed, CMD_BUILD_INDUSTRY);
uint32 layout_index = ::InteractiveRandomRange((uint32)::GetIndustrySpec(industry_type)->layouts.size());
return ScriptObject::DoCommand(tile, (1 << 16) | (layout_index << 8) | industry_type, seed, CMD_BUILD_INDUSTRY);
}
/* static */ bool ScriptIndustryType::ProspectIndustry(IndustryType industry_type)

View File

@@ -40,7 +40,7 @@ public:
/** The area was already flat */
ERR_AREA_ALREADY_FLAT, // [STR_ERROR_ALREADY_LEVELLED]
/** There is a tunnel underneed */
/** There is a tunnel underneath */
ERR_EXCAVATION_WOULD_DAMAGE, // [STR_ERROR_EXCAVATION_WOULD_DAMAGE]
};
@@ -351,7 +351,7 @@ public:
* @pre width > 0.
* @pre height > 0.
* @pre radius >= 0.
* @return Value below 8 means no acceptance; the more the better.
* @return Values below 8 mean no acceptance; the more the better.
*/
static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);

View File

@@ -266,3 +266,12 @@ namespace SQConvert {
template <> inline const ScriptEventRoadReconstruction &GetParam(ForceType<const ScriptEventRoadReconstruction &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventRoadReconstruction *)instance; }
template <> inline int Return<ScriptEventRoadReconstruction *>(HSQUIRRELVM vm, ScriptEventRoadReconstruction *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventRoadReconstruction", res, nullptr, DefSQDestructorCallback<ScriptEventRoadReconstruction>, true); return 1; }
} // namespace SQConvert
namespace SQConvert {
/* Allow ScriptEventVehicleAutoReplaced to be used as Squirrel parameter */
template <> inline ScriptEventVehicleAutoReplaced *GetParam(ForceType<ScriptEventVehicleAutoReplaced *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventVehicleAutoReplaced *)instance; }
template <> inline ScriptEventVehicleAutoReplaced &GetParam(ForceType<ScriptEventVehicleAutoReplaced &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventVehicleAutoReplaced *)instance; }
template <> inline const ScriptEventVehicleAutoReplaced *GetParam(ForceType<const ScriptEventVehicleAutoReplaced *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventVehicleAutoReplaced *)instance; }
template <> inline const ScriptEventVehicleAutoReplaced &GetParam(ForceType<const ScriptEventVehicleAutoReplaced &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventVehicleAutoReplaced *)instance; }
template <> inline int Return<ScriptEventVehicleAutoReplaced *>(HSQUIRRELVM vm, ScriptEventVehicleAutoReplaced *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventVehicleAutoReplaced", res, nullptr, DefSQDestructorCallback<ScriptEventVehicleAutoReplaced>, true); return 1; }
} // namespace SQConvert