mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-16 00:42:45 +01:00
Add: [Script] Cloning ScriptList
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
* \li AIWaypoint::GetWaypointID now returns the StationID of any type of waypoint
|
||||
* \li AIList instances can now be saved
|
||||
* \li AIVehicleList_Station accepts an optional AIVehicle::VehicleType parameter
|
||||
* \li AIList instances can now be cloned
|
||||
*
|
||||
* \b 14.0
|
||||
*
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
* \li GSWaypoint::GetWaypointID now returns the StationID of any type of waypoint
|
||||
* \li GSList instances can now be saved
|
||||
* \li GSVehicleList_Station accepts an optional GSVehicle::VehicleType parameter
|
||||
* \li GSList instances can now be cloned
|
||||
*
|
||||
* \b 14.0
|
||||
*
|
||||
|
||||
@@ -453,6 +453,20 @@ bool ScriptList::LoadObject(HSQUIRRELVM vm)
|
||||
return true;
|
||||
}
|
||||
|
||||
ScriptObject *ScriptList::CloneObject()
|
||||
{
|
||||
ScriptList *clone = new ScriptList();
|
||||
clone->CopyList(this);
|
||||
return clone;
|
||||
}
|
||||
|
||||
void ScriptList::CopyList(const ScriptList *list)
|
||||
{
|
||||
this->Sort(list->sorter_type, list->sort_ascending);
|
||||
this->items = list->items;
|
||||
this->buckets = list->buckets;
|
||||
}
|
||||
|
||||
ScriptList::ScriptList()
|
||||
{
|
||||
/* Default sorter */
|
||||
|
||||
@@ -145,6 +145,13 @@ protected:
|
||||
|
||||
virtual bool SaveObject(HSQUIRRELVM vm) override;
|
||||
virtual bool LoadObject(HSQUIRRELVM vm) override;
|
||||
virtual ScriptObject *CloneObject() override;
|
||||
|
||||
/**
|
||||
* Copy the content of a list.
|
||||
* @param list The list that will be copied.
|
||||
*/
|
||||
void CopyList(const ScriptList *list);
|
||||
|
||||
public:
|
||||
typedef std::set<SQInteger> ScriptItemList; ///< The list of items inside the bucket
|
||||
|
||||
@@ -23,6 +23,13 @@ bool ScriptTileList::SaveObject(HSQUIRRELVM vm)
|
||||
return true;
|
||||
}
|
||||
|
||||
ScriptObject *ScriptTileList::CloneObject()
|
||||
{
|
||||
ScriptTileList *clone = new ScriptTileList();
|
||||
clone->CopyList(this);
|
||||
return clone;
|
||||
}
|
||||
|
||||
void ScriptTileList::AddRectangle(TileIndex t1, TileIndex t2)
|
||||
{
|
||||
if (!::IsValidTile(t1)) return;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
class ScriptTileList : public ScriptList {
|
||||
protected:
|
||||
virtual bool SaveObject(HSQUIRRELVM) override;
|
||||
virtual ScriptObject *CloneObject() override;
|
||||
public:
|
||||
/**
|
||||
* Adds the rectangle between tile_from and tile_to to the to-be-evaluated tiles.
|
||||
|
||||
Reference in New Issue
Block a user