1
0
Fork 0

(svn r20563) -Change: [NoAI] rename AIAbstractList to AIList

release/1.1
yexo 2010-08-19 15:37:28 +00:00
parent 6c7384cabd
commit dc303e550b
48 changed files with 293 additions and 287 deletions

View File

@ -275,7 +275,6 @@ AIRoad.BuildDriveThroughRoadStation <- function(tile, front, road_veh_type, stat
return AIRoad._BuildDriveThroughRoadStation(tile, front, road_veh_type, station_id); return AIRoad._BuildDriveThroughRoadStation(tile, front, road_veh_type, station_id);
} }
AIAbstractList.HasNext <-
AIBridgeList.HasNext <- AIBridgeList.HasNext <-
AIBridgeList_Length.HasNext <- AIBridgeList_Length.HasNext <-
AICargoList.HasNext <- AICargoList.HasNext <-
@ -316,3 +315,5 @@ AIIndustry.IsCargoAccepted <- function(industry_id, cargo_id)
{ {
return AIIndustry._IsCargoAccepted(industry_id, cargo_id) != AIIndustry.CAS_NOT_ACCEPTED; return AIIndustry._IsCargoAccepted(industry_id, cargo_id) != AIIndustry.CAS_NOT_ACCEPTED;
} }
AIAbstractList <- AIList;

View File

@ -25,7 +25,6 @@ AIRoad.BuildDriveThroughRoadStation <- function(tile, front, road_veh_type, stat
return AIRoad._BuildDriveThroughRoadStation(tile, front, road_veh_type, station_id); return AIRoad._BuildDriveThroughRoadStation(tile, front, road_veh_type, station_id);
} }
AIAbstractList.HasNext <-
AIBridgeList.HasNext <- AIBridgeList.HasNext <-
AIBridgeList_Length.HasNext <- AIBridgeList_Length.HasNext <-
AICargoList.HasNext <- AICargoList.HasNext <-
@ -67,3 +66,5 @@ AIIndustry.IsCargoAccepted <- function(industry_id, cargo_id)
{ {
return AIIndustry._IsCargoAccepted(industry_id, cargo_id) != AIIndustry.CAS_NOT_ACCEPTED; return AIIndustry._IsCargoAccepted(industry_id, cargo_id) != AIIndustry.CAS_NOT_ACCEPTED;
} }
AIAbstractList <- AIList;

View File

@ -58,7 +58,7 @@ function Regression::TestInit()
} }
list = AIList(); list = AIList();
list.Sort(AIAbstractList.SORT_BY_VALUE, AIAbstractList.SORT_ASCENDING); list.Sort(AIList.SORT_BY_VALUE, AIList.SORT_ASCENDING);
print(""); print("");
print(" Value Ascending"); print(" Value Ascending");
list.AddItem( 5, 10); list.AddItem( 5, 10);
@ -93,7 +93,7 @@ function Regression::TestInit()
} }
list = AIList(); list = AIList();
list.Sort(AIAbstractList.SORT_BY_ITEM, AIAbstractList.SORT_DESCENDING); list.Sort(AIList.SORT_BY_ITEM, AIList.SORT_DESCENDING);
print(""); print("");
print(" Item Descending"); print(" Item Descending");
list.AddItem( 5, 10); list.AddItem( 5, 10);
@ -128,7 +128,7 @@ function Regression::TestInit()
} }
list = AIList(); list = AIList();
list.Sort(AIAbstractList.SORT_BY_ITEM, AIAbstractList.SORT_ASCENDING); list.Sort(AIList.SORT_BY_ITEM, AIList.SORT_ASCENDING);
print(""); print("");
print(" Item Ascending"); print(" Item Ascending");
list.AddItem( 5, 10); list.AddItem( 5, 10);
@ -585,7 +585,7 @@ function Regression::Industry()
print("--Industry--"); print("--Industry--");
print(" GetIndustryCount(): " + AIIndustry.GetIndustryCount()); print(" GetIndustryCount(): " + AIIndustry.GetIndustryCount());
local list = AIIndustryList(); local list = AIIndustryList();
list.Sort(AIAbstractList.SORT_BY_ITEM, AIAbstractList.SORT_ASCENDING); list.Sort(AIList.SORT_BY_ITEM, AIList.SORT_ASCENDING);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
if (AIIndustry.IsValidIndustry(i)) j++; if (AIIndustry.IsValidIndustry(i)) j++;
print(" Industry " + i); print(" Industry " + i);
@ -704,12 +704,12 @@ function Regression::List()
} }
list.RemoveItem(1050); list.RemoveItem(1050);
list.RemoveItem(1150); list.RemoveItem(1150);
list.ChangeItem(1051, 12); list.SetValue(1051, 12);
print(" Count(): " + list.Count()); print(" Count(): " + list.Count());
print(" HasItem(1050): " + list.HasItem(1050)); print(" HasItem(1050): " + list.HasItem(1050));
print(" HasItem(1051): " + list.HasItem(1051)); print(" HasItem(1051): " + list.HasItem(1051));
print(" IsEmpty(): " + list.IsEmpty()); print(" IsEmpty(): " + list.IsEmpty());
list.Sort(AIAbstractList.SORT_BY_ITEM, AIAbstractList.SORT_ASCENDING); list.Sort(AIList.SORT_BY_ITEM, AIList.SORT_ASCENDING);
print(" List Dump:"); print(" List Dump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i)); print(" " + i + " => " + list.GetValue(i));
@ -1198,7 +1198,7 @@ function Regression::Sign()
print(" RemoveSign(" + sign_id + "): " + AISign.RemoveSign(sign_id)); print(" RemoveSign(" + sign_id + "): " + AISign.RemoveSign(sign_id));
print(""); print("");
local list = AISignList(); local list = AISignList();
list.Sort(AIAbstractList.SORT_BY_ITEM, AIAbstractList.SORT_ASCENDING); list.Sort(AIList.SORT_BY_ITEM, AIList.SORT_ASCENDING);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
j++; j++;
print(" Sign " + i); print(" Sign " + i);
@ -1467,7 +1467,7 @@ function Regression::Town()
print("--Town--"); print("--Town--");
print(" GetTownCount(): " + AITown.GetTownCount()); print(" GetTownCount(): " + AITown.GetTownCount());
local list = AITownList(); local list = AITownList();
list.Sort(AIAbstractList.SORT_BY_ITEM, AIAbstractList.SORT_ASCENDING); list.Sort(AIList.SORT_BY_ITEM, AIList.SORT_ASCENDING);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
if (AITown.IsValidTown(i)) j++; if (AITown.IsValidTown(i)) j++;
print(" Town " + i); print(" Town " + i);

View File

@ -845,7 +845,6 @@
<ClCompile Include="..\src\ai\ai_scanner.cpp" /> <ClCompile Include="..\src\ai\ai_scanner.cpp" />
<ClInclude Include="..\src\ai\ai_scanner.hpp" /> <ClInclude Include="..\src\ai\ai_scanner.hpp" />
<ClInclude Include="..\src\ai\ai_storage.hpp" /> <ClInclude Include="..\src\ai\ai_storage.hpp" />
<ClInclude Include="..\src\ai\api\ai_abstractlist.hpp" />
<ClInclude Include="..\src\ai\api\ai_accounting.hpp" /> <ClInclude Include="..\src\ai\api\ai_accounting.hpp" />
<ClInclude Include="..\src\ai\api\ai_airport.hpp" /> <ClInclude Include="..\src\ai\api\ai_airport.hpp" />
<ClInclude Include="..\src\ai\api\ai_base.hpp" /> <ClInclude Include="..\src\ai\api\ai_base.hpp" />
@ -873,6 +872,7 @@
<ClInclude Include="..\src\ai\api\ai_industrytype.hpp" /> <ClInclude Include="..\src\ai\api\ai_industrytype.hpp" />
<ClInclude Include="..\src\ai\api\ai_industrytypelist.hpp" /> <ClInclude Include="..\src\ai\api\ai_industrytypelist.hpp" />
<ClInclude Include="..\src\ai\api\ai_info_docs.hpp" /> <ClInclude Include="..\src\ai\api\ai_info_docs.hpp" />
<ClInclude Include="..\src\ai\api\ai_list.hpp" />
<ClInclude Include="..\src\ai\api\ai_log.hpp" /> <ClInclude Include="..\src\ai\api\ai_log.hpp" />
<ClInclude Include="..\src\ai\api\ai_map.hpp" /> <ClInclude Include="..\src\ai\api\ai_map.hpp" />
<ClInclude Include="..\src\ai\api\ai_marine.hpp" /> <ClInclude Include="..\src\ai\api\ai_marine.hpp" />
@ -898,7 +898,6 @@
<ClInclude Include="..\src\ai\api\ai_vehiclelist.hpp" /> <ClInclude Include="..\src\ai\api\ai_vehiclelist.hpp" />
<ClInclude Include="..\src\ai\api\ai_waypoint.hpp" /> <ClInclude Include="..\src\ai\api\ai_waypoint.hpp" />
<ClInclude Include="..\src\ai\api\ai_waypointlist.hpp" /> <ClInclude Include="..\src\ai\api\ai_waypointlist.hpp" />
<ClCompile Include="..\src\ai\api\ai_abstractlist.cpp" />
<ClCompile Include="..\src\ai\api\ai_accounting.cpp" /> <ClCompile Include="..\src\ai\api\ai_accounting.cpp" />
<ClCompile Include="..\src\ai\api\ai_airport.cpp" /> <ClCompile Include="..\src\ai\api\ai_airport.cpp" />
<ClCompile Include="..\src\ai\api\ai_base.cpp" /> <ClCompile Include="..\src\ai\api\ai_base.cpp" />
@ -924,6 +923,7 @@
<ClCompile Include="..\src\ai\api\ai_industrylist.cpp" /> <ClCompile Include="..\src\ai\api\ai_industrylist.cpp" />
<ClCompile Include="..\src\ai\api\ai_industrytype.cpp" /> <ClCompile Include="..\src\ai\api\ai_industrytype.cpp" />
<ClCompile Include="..\src\ai\api\ai_industrytypelist.cpp" /> <ClCompile Include="..\src\ai\api\ai_industrytypelist.cpp" />
<ClCompile Include="..\src\ai\api\ai_list.cpp" />
<ClCompile Include="..\src\ai\api\ai_log.cpp" /> <ClCompile Include="..\src\ai\api\ai_log.cpp" />
<ClCompile Include="..\src\ai\api\ai_map.cpp" /> <ClCompile Include="..\src\ai\api\ai_map.cpp" />
<ClCompile Include="..\src\ai\api\ai_marine.cpp" /> <ClCompile Include="..\src\ai\api\ai_marine.cpp" />

View File

@ -1738,9 +1738,6 @@
<ClInclude Include="..\src\ai\ai_storage.hpp"> <ClInclude Include="..\src\ai\ai_storage.hpp">
<Filter>AI Core</Filter> <Filter>AI Core</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\ai\api\ai_abstractlist.hpp">
<Filter>AI API</Filter>
</ClInclude>
<ClInclude Include="..\src\ai\api\ai_accounting.hpp"> <ClInclude Include="..\src\ai\api\ai_accounting.hpp">
<Filter>AI API</Filter> <Filter>AI API</Filter>
</ClInclude> </ClInclude>
@ -1822,6 +1819,9 @@
<ClInclude Include="..\src\ai\api\ai_info_docs.hpp"> <ClInclude Include="..\src\ai\api\ai_info_docs.hpp">
<Filter>AI API</Filter> <Filter>AI API</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\ai\api\ai_list.hpp">
<Filter>AI API</Filter>
</ClInclude>
<ClInclude Include="..\src\ai\api\ai_log.hpp"> <ClInclude Include="..\src\ai\api\ai_log.hpp">
<Filter>AI API</Filter> <Filter>AI API</Filter>
</ClInclude> </ClInclude>
@ -1897,9 +1897,6 @@
<ClInclude Include="..\src\ai\api\ai_waypointlist.hpp"> <ClInclude Include="..\src\ai\api\ai_waypointlist.hpp">
<Filter>AI API</Filter> <Filter>AI API</Filter>
</ClInclude> </ClInclude>
<ClCompile Include="..\src\ai\api\ai_abstractlist.cpp">
<Filter>AI API Implementation</Filter>
</ClCompile>
<ClCompile Include="..\src\ai\api\ai_accounting.cpp"> <ClCompile Include="..\src\ai\api\ai_accounting.cpp">
<Filter>AI API Implementation</Filter> <Filter>AI API Implementation</Filter>
</ClCompile> </ClCompile>
@ -1975,6 +1972,9 @@
<ClCompile Include="..\src\ai\api\ai_industrytypelist.cpp"> <ClCompile Include="..\src\ai\api\ai_industrytypelist.cpp">
<Filter>AI API Implementation</Filter> <Filter>AI API Implementation</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\ai\api\ai_list.cpp">
<Filter>AI API Implementation</Filter>
</ClCompile>
<ClCompile Include="..\src\ai\api\ai_log.cpp"> <ClCompile Include="..\src\ai\api\ai_log.cpp">
<Filter>AI API Implementation</Filter> <Filter>AI API Implementation</Filter>
</ClCompile> </ClCompile>

View File

@ -2695,10 +2695,6 @@
<Filter <Filter
Name="AI API" Name="AI API"
> >
<File
RelativePath=".\..\src\ai\api\ai_abstractlist.hpp"
>
</File>
<File <File
RelativePath=".\..\src\ai\api\ai_accounting.hpp" RelativePath=".\..\src\ai\api\ai_accounting.hpp"
> >
@ -2807,6 +2803,10 @@
RelativePath=".\..\src\ai\api\ai_info_docs.hpp" RelativePath=".\..\src\ai\api\ai_info_docs.hpp"
> >
</File> </File>
<File
RelativePath=".\..\src\ai\api\ai_list.hpp"
>
</File>
<File <File
RelativePath=".\..\src\ai\api\ai_log.hpp" RelativePath=".\..\src\ai\api\ai_log.hpp"
> >
@ -2911,10 +2911,6 @@
<Filter <Filter
Name="AI API Implementation" Name="AI API Implementation"
> >
<File
RelativePath=".\..\src\ai\api\ai_abstractlist.cpp"
>
</File>
<File <File
RelativePath=".\..\src\ai\api\ai_accounting.cpp" RelativePath=".\..\src\ai\api\ai_accounting.cpp"
> >
@ -3015,6 +3011,10 @@
RelativePath=".\..\src\ai\api\ai_industrytypelist.cpp" RelativePath=".\..\src\ai\api\ai_industrytypelist.cpp"
> >
</File> </File>
<File
RelativePath=".\..\src\ai\api\ai_list.cpp"
>
</File>
<File <File
RelativePath=".\..\src\ai\api\ai_log.cpp" RelativePath=".\..\src\ai\api\ai_log.cpp"
> >

View File

@ -2692,10 +2692,6 @@
<Filter <Filter
Name="AI API" Name="AI API"
> >
<File
RelativePath=".\..\src\ai\api\ai_abstractlist.hpp"
>
</File>
<File <File
RelativePath=".\..\src\ai\api\ai_accounting.hpp" RelativePath=".\..\src\ai\api\ai_accounting.hpp"
> >
@ -2804,6 +2800,10 @@
RelativePath=".\..\src\ai\api\ai_info_docs.hpp" RelativePath=".\..\src\ai\api\ai_info_docs.hpp"
> >
</File> </File>
<File
RelativePath=".\..\src\ai\api\ai_list.hpp"
>
</File>
<File <File
RelativePath=".\..\src\ai\api\ai_log.hpp" RelativePath=".\..\src\ai\api\ai_log.hpp"
> >
@ -2908,10 +2908,6 @@
<Filter <Filter
Name="AI API Implementation" Name="AI API Implementation"
> >
<File
RelativePath=".\..\src\ai\api\ai_abstractlist.cpp"
>
</File>
<File <File
RelativePath=".\..\src\ai\api\ai_accounting.cpp" RelativePath=".\..\src\ai\api\ai_accounting.cpp"
> >
@ -3012,6 +3008,10 @@
RelativePath=".\..\src\ai\api\ai_industrytypelist.cpp" RelativePath=".\..\src\ai\api\ai_industrytypelist.cpp"
> >
</File> </File>
<File
RelativePath=".\..\src\ai\api\ai_list.cpp"
>
</File>
<File <File
RelativePath=".\..\src\ai\api\ai_log.cpp" RelativePath=".\..\src\ai\api\ai_log.cpp"
> >

View File

@ -611,7 +611,6 @@ ai/ai_scanner.hpp
ai/ai_storage.hpp ai/ai_storage.hpp
# AI API # AI API
ai/api/ai_abstractlist.hpp
ai/api/ai_accounting.hpp ai/api/ai_accounting.hpp
ai/api/ai_airport.hpp ai/api/ai_airport.hpp
ai/api/ai_base.hpp ai/api/ai_base.hpp
@ -639,6 +638,7 @@ ai/api/ai_industrylist.hpp
ai/api/ai_industrytype.hpp ai/api/ai_industrytype.hpp
ai/api/ai_industrytypelist.hpp ai/api/ai_industrytypelist.hpp
ai/api/ai_info_docs.hpp ai/api/ai_info_docs.hpp
ai/api/ai_list.hpp
ai/api/ai_log.hpp ai/api/ai_log.hpp
ai/api/ai_map.hpp ai/api/ai_map.hpp
ai/api/ai_marine.hpp ai/api/ai_marine.hpp
@ -666,7 +666,6 @@ ai/api/ai_waypoint.hpp
ai/api/ai_waypointlist.hpp ai/api/ai_waypointlist.hpp
# AI API Implementation # AI API Implementation
ai/api/ai_abstractlist.cpp
ai/api/ai_accounting.cpp ai/api/ai_accounting.cpp
ai/api/ai_airport.cpp ai/api/ai_airport.cpp
ai/api/ai_base.cpp ai/api/ai_base.cpp
@ -692,6 +691,7 @@ ai/api/ai_industry.cpp
ai/api/ai_industrylist.cpp ai/api/ai_industrylist.cpp
ai/api/ai_industrytype.cpp ai/api/ai_industrytype.cpp
ai/api/ai_industrytypelist.cpp ai/api/ai_industrytypelist.cpp
ai/api/ai_list.cpp
ai/api/ai_log.cpp ai/api/ai_log.cpp
ai/api/ai_map.cpp ai/api/ai_map.cpp
ai/api/ai_marine.cpp ai/api/ai_marine.cpp

View File

@ -26,7 +26,6 @@
/* Convert all AI related classes to Squirrel data. /* Convert all AI related classes to Squirrel data.
* Note: this line a marker in squirrel_export.sh. Do not change! */ * Note: this line a marker in squirrel_export.sh. Do not change! */
#include "api/ai_abstractlist.hpp.sq"
#include "api/ai_accounting.hpp.sq" #include "api/ai_accounting.hpp.sq"
#include "api/ai_airport.hpp.sq" #include "api/ai_airport.hpp.sq"
#include "api/ai_base.hpp.sq" #include "api/ai_base.hpp.sq"
@ -52,6 +51,7 @@
#include "api/ai_industrylist.hpp.sq" #include "api/ai_industrylist.hpp.sq"
#include "api/ai_industrytype.hpp.sq" #include "api/ai_industrytype.hpp.sq"
#include "api/ai_industrytypelist.hpp.sq" #include "api/ai_industrytypelist.hpp.sq"
#include "api/ai_list.hpp.sq"
#include "api/ai_log.hpp.sq" #include "api/ai_log.hpp.sq"
#include "api/ai_map.hpp.sq" #include "api/ai_map.hpp.sq"
#include "api/ai_marine.hpp.sq" #include "api/ai_marine.hpp.sq"
@ -171,7 +171,7 @@ void AIInstance::RegisterAPI()
{ {
/* Register all classes */ /* Register all classes */
squirrel_register_std(this->engine); squirrel_register_std(this->engine);
SQAIAbstractList_Register(this->engine); SQAIList_Register(this->engine);
SQAIAccounting_Register(this->engine); SQAIAccounting_Register(this->engine);
SQAIAirport_Register(this->engine); SQAIAirport_Register(this->engine);
SQAIBase_Register(this->engine); SQAIBase_Register(this->engine);

View File

@ -1,72 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
#include "ai_abstractlist.hpp"
namespace SQConvert {
/* Allow enums to be used as Squirrel parameters */
template <> AIAbstractList::SorterType GetParam(ForceType<AIAbstractList::SorterType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIAbstractList::SorterType)tmp; }
template <> int Return<AIAbstractList::SorterType>(HSQUIRRELVM vm, AIAbstractList::SorterType res) { sq_pushinteger(vm, (int32)res); return 1; }
/* Allow AIAbstractList to be used as Squirrel parameter */
template <> AIAbstractList *GetParam(ForceType<AIAbstractList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIAbstractList *)instance; }
template <> AIAbstractList &GetParam(ForceType<AIAbstractList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIAbstractList *)instance; }
template <> const AIAbstractList *GetParam(ForceType<const AIAbstractList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIAbstractList *)instance; }
template <> const AIAbstractList &GetParam(ForceType<const AIAbstractList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIAbstractList *)instance; }
template <> int Return<AIAbstractList *>(HSQUIRRELVM vm, AIAbstractList *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIAbstractList", res, NULL, DefSQDestructorCallback<AIAbstractList>); return 1; }
} // namespace SQConvert
void SQAIAbstractList_Register(Squirrel *engine)
{
DefSQClass <AIAbstractList> SQAIAbstractList("AIAbstractList");
SQAIAbstractList.PreRegister(engine);
SQAIAbstractList.AddConstructor<void (AIAbstractList::*)(), 1>(engine, "x");
SQAIAbstractList.DefSQConst(engine, AIAbstractList::SORT_BY_VALUE, "SORT_BY_VALUE");
SQAIAbstractList.DefSQConst(engine, AIAbstractList::SORT_BY_ITEM, "SORT_BY_ITEM");
SQAIAbstractList.DefSQConst(engine, AIAbstractList::SORT_ASCENDING, "SORT_ASCENDING");
SQAIAbstractList.DefSQConst(engine, AIAbstractList::SORT_DESCENDING, "SORT_DESCENDING");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::AddItem, "AddItem", 3, "xii");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::RemoveItem, "RemoveItem", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::Clear, "Clear", 1, "x");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::HasItem, "HasItem", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::Begin, "Begin", 1, "x");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::Next, "Next", 1, "x");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::IsEmpty, "IsEmpty", 1, "x");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::IsEnd, "IsEnd", 1, "x");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::Count, "Count", 1, "x");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::GetValue, "GetValue", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::SetValue, "SetValue", 3, "xii");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::Sort, "Sort", 3, "xib");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::AddList, "AddList", 2, "xx");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::RemoveAboveValue, "RemoveAboveValue", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::RemoveBelowValue, "RemoveBelowValue", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::RemoveBetweenValue, "RemoveBetweenValue", 3, "xii");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::RemoveValue, "RemoveValue", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::RemoveTop, "RemoveTop", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::RemoveBottom, "RemoveBottom", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::RemoveList, "RemoveList", 2, "xx");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::KeepAboveValue, "KeepAboveValue", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::KeepBelowValue, "KeepBelowValue", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::KeepBetweenValue, "KeepBetweenValue", 3, "xii");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::KeepValue, "KeepValue", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::KeepTop, "KeepTop", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::KeepBottom, "KeepBottom", 2, "xi");
SQAIAbstractList.DefSQMethod(engine, &AIAbstractList::KeepList, "KeepList", 2, "xx");
SQAIAbstractList.DefSQAdvancedMethod(engine, &AIAbstractList::_get, "_get");
SQAIAbstractList.DefSQAdvancedMethod(engine, &AIAbstractList::_set, "_set");
SQAIAbstractList.DefSQAdvancedMethod(engine, &AIAbstractList::_nexti, "_nexti");
SQAIAbstractList.DefSQAdvancedMethod(engine, &AIAbstractList::Valuate, "Valuate");
SQAIAbstractList.PostRegister(engine);
}

View File

@ -12,13 +12,13 @@
#ifndef AI_BRIDGELIST_HPP #ifndef AI_BRIDGELIST_HPP
#define AI_BRIDGELIST_HPP #define AI_BRIDGELIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
/** /**
* Create a list of bridges. * Create a list of bridges.
* @ingroup AIList * @ingroup AIList
*/ */
class AIBridgeList : public AIAbstractList { class AIBridgeList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIBridgeList"; } static const char *GetClassName() { return "AIBridgeList"; }
@ -29,7 +29,7 @@ public:
* Create a list of bridges that can be built on a specific length. * Create a list of bridges that can be built on a specific length.
* @ingroup AIList * @ingroup AIList
*/ */
class AIBridgeList_Length : public AIAbstractList { class AIBridgeList_Length : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIBridgeList_Length"; } static const char *GetClassName() { return "AIBridgeList_Length"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIBridgeList_Register(Squirrel *engine) void SQAIBridgeList_Register(Squirrel *engine)
{ {
DefSQClass <AIBridgeList> SQAIBridgeList("AIBridgeList"); DefSQClass <AIBridgeList> SQAIBridgeList("AIBridgeList");
SQAIBridgeList.PreRegister(engine, "AIAbstractList"); SQAIBridgeList.PreRegister(engine, "AIList");
SQAIBridgeList.AddConstructor<void (AIBridgeList::*)(), 1>(engine, "x"); SQAIBridgeList.AddConstructor<void (AIBridgeList::*)(), 1>(engine, "x");
SQAIBridgeList.PostRegister(engine); SQAIBridgeList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAIBridgeList_Length_Register(Squirrel *engine) void SQAIBridgeList_Length_Register(Squirrel *engine)
{ {
DefSQClass <AIBridgeList_Length> SQAIBridgeList_Length("AIBridgeList_Length"); DefSQClass <AIBridgeList_Length> SQAIBridgeList_Length("AIBridgeList_Length");
SQAIBridgeList_Length.PreRegister(engine, "AIAbstractList"); SQAIBridgeList_Length.PreRegister(engine, "AIList");
SQAIBridgeList_Length.AddConstructor<void (AIBridgeList_Length::*)(uint length), 2>(engine, "xi"); SQAIBridgeList_Length.AddConstructor<void (AIBridgeList_Length::*)(uint length), 2>(engine, "xi");
SQAIBridgeList_Length.PostRegister(engine); SQAIBridgeList_Length.PostRegister(engine);

View File

@ -12,13 +12,13 @@
#ifndef AI_CARGOLIST_HPP #ifndef AI_CARGOLIST_HPP
#define AI_CARGOLIST_HPP #define AI_CARGOLIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
/** /**
* Creates a list of cargos that can be produced in the current game. * Creates a list of cargos that can be produced in the current game.
* @ingroup AIList * @ingroup AIList
*/ */
class AICargoList : public AIAbstractList { class AICargoList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AICargoList"; } static const char *GetClassName() { return "AICargoList"; }
@ -31,7 +31,7 @@ public:
* by this industry, @see AIIndustry::IsCargoAccepted. * by this industry, @see AIIndustry::IsCargoAccepted.
* @ingroup AIList * @ingroup AIList
*/ */
class AICargoList_IndustryAccepting : public AIAbstractList { class AICargoList_IndustryAccepting : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AICargoList_IndustryAccepting"; } static const char *GetClassName() { return "AICargoList_IndustryAccepting"; }
@ -46,7 +46,7 @@ public:
* Creates a list of cargos that the given industry can produce. * Creates a list of cargos that the given industry can produce.
* @ingroup AIList * @ingroup AIList
*/ */
class AICargoList_IndustryProducing : public AIAbstractList { class AICargoList_IndustryProducing : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AICargoList_IndustryProducing"; } static const char *GetClassName() { return "AICargoList_IndustryProducing"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAICargoList_Register(Squirrel *engine) void SQAICargoList_Register(Squirrel *engine)
{ {
DefSQClass <AICargoList> SQAICargoList("AICargoList"); DefSQClass <AICargoList> SQAICargoList("AICargoList");
SQAICargoList.PreRegister(engine, "AIAbstractList"); SQAICargoList.PreRegister(engine, "AIList");
SQAICargoList.AddConstructor<void (AICargoList::*)(), 1>(engine, "x"); SQAICargoList.AddConstructor<void (AICargoList::*)(), 1>(engine, "x");
SQAICargoList.PostRegister(engine); SQAICargoList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAICargoList_IndustryAccepting_Register(Squirrel *engine) void SQAICargoList_IndustryAccepting_Register(Squirrel *engine)
{ {
DefSQClass <AICargoList_IndustryAccepting> SQAICargoList_IndustryAccepting("AICargoList_IndustryAccepting"); DefSQClass <AICargoList_IndustryAccepting> SQAICargoList_IndustryAccepting("AICargoList_IndustryAccepting");
SQAICargoList_IndustryAccepting.PreRegister(engine, "AIAbstractList"); SQAICargoList_IndustryAccepting.PreRegister(engine, "AIList");
SQAICargoList_IndustryAccepting.AddConstructor<void (AICargoList_IndustryAccepting::*)(IndustryID industry_id), 2>(engine, "xi"); SQAICargoList_IndustryAccepting.AddConstructor<void (AICargoList_IndustryAccepting::*)(IndustryID industry_id), 2>(engine, "xi");
SQAICargoList_IndustryAccepting.PostRegister(engine); SQAICargoList_IndustryAccepting.PostRegister(engine);
@ -59,7 +59,7 @@ namespace SQConvert {
void SQAICargoList_IndustryProducing_Register(Squirrel *engine) void SQAICargoList_IndustryProducing_Register(Squirrel *engine)
{ {
DefSQClass <AICargoList_IndustryProducing> SQAICargoList_IndustryProducing("AICargoList_IndustryProducing"); DefSQClass <AICargoList_IndustryProducing> SQAICargoList_IndustryProducing("AICargoList_IndustryProducing");
SQAICargoList_IndustryProducing.PreRegister(engine, "AIAbstractList"); SQAICargoList_IndustryProducing.PreRegister(engine, "AIList");
SQAICargoList_IndustryProducing.AddConstructor<void (AICargoList_IndustryProducing::*)(IndustryID industry_id), 2>(engine, "xi"); SQAICargoList_IndustryProducing.AddConstructor<void (AICargoList_IndustryProducing::*)(IndustryID industry_id), 2>(engine, "xi");
SQAICargoList_IndustryProducing.PostRegister(engine); SQAICargoList_IndustryProducing.PostRegister(engine);

View File

@ -28,6 +28,8 @@
* *
* API removals: * API removals:
* \li HasNext for all lists. * \li HasNext for all lists.
* \li AIAbstractList, use AIList instead.
* \li AIList::ChangeItem, use AIList::SetValue instead.
* *
* Other changes: * Other changes:
* \li AIEngine::GetMaxTractiveEffort can be used for road vehicles. * \li AIEngine::GetMaxTractiveEffort can be used for road vehicles.

View File

@ -12,14 +12,14 @@
#ifndef AI_DEPOTLIST_HPP #ifndef AI_DEPOTLIST_HPP
#define AI_DEPOTLIST_HPP #define AI_DEPOTLIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
#include "ai_tile.hpp" #include "ai_tile.hpp"
/** /**
* Creates a list of the locations of the depots (and hangars) of which you are the owner. * Creates a list of the locations of the depots (and hangars) of which you are the owner.
* @ingroup AIList * @ingroup AIList
*/ */
class AIDepotList : public AIAbstractList { class AIDepotList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIDepotList"; } static const char *GetClassName() { return "AIDepotList"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIDepotList_Register(Squirrel *engine) void SQAIDepotList_Register(Squirrel *engine)
{ {
DefSQClass <AIDepotList> SQAIDepotList("AIDepotList"); DefSQClass <AIDepotList> SQAIDepotList("AIDepotList");
SQAIDepotList.PreRegister(engine, "AIAbstractList"); SQAIDepotList.PreRegister(engine, "AIList");
SQAIDepotList.AddConstructor<void (AIDepotList::*)(AITile::TransportType transport_type), 2>(engine, "xi"); SQAIDepotList.AddConstructor<void (AIDepotList::*)(AITile::TransportType transport_type), 2>(engine, "xi");
SQAIDepotList.PostRegister(engine); SQAIDepotList.PostRegister(engine);

View File

@ -12,14 +12,14 @@
#ifndef AI_ENGINELIST_HPP #ifndef AI_ENGINELIST_HPP
#define AI_ENGINELIST_HPP #define AI_ENGINELIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
#include "ai_vehicle.hpp" #include "ai_vehicle.hpp"
/** /**
* Create a list of engines based on a vehicle type. * Create a list of engines based on a vehicle type.
* @ingroup AIList * @ingroup AIList
*/ */
class AIEngineList : public AIAbstractList { class AIEngineList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIEngineList"; } static const char *GetClassName() { return "AIEngineList"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIEngineList_Register(Squirrel *engine) void SQAIEngineList_Register(Squirrel *engine)
{ {
DefSQClass <AIEngineList> SQAIEngineList("AIEngineList"); DefSQClass <AIEngineList> SQAIEngineList("AIEngineList");
SQAIEngineList.PreRegister(engine, "AIAbstractList"); SQAIEngineList.PreRegister(engine, "AIList");
SQAIEngineList.AddConstructor<void (AIEngineList::*)(AIVehicle::VehicleType vehicle_type), 2>(engine, "xi"); SQAIEngineList.AddConstructor<void (AIEngineList::*)(AIVehicle::VehicleType vehicle_type), 2>(engine, "xi");
SQAIEngineList.PostRegister(engine); SQAIEngineList.PostRegister(engine);

View File

@ -12,14 +12,14 @@
#ifndef AI_GROUPLIST_HPP #ifndef AI_GROUPLIST_HPP
#define AI_GROUPLIST_HPP #define AI_GROUPLIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
/** /**
* Creates a list of groups of which you are the owner. * Creates a list of groups of which you are the owner.
* @note Neither AIGroup::GROUP_ALL nor AIGroup::GROUP_DEFAULT is in this list. * @note Neither AIGroup::GROUP_ALL nor AIGroup::GROUP_DEFAULT is in this list.
* @ingroup AIList * @ingroup AIList
*/ */
class AIGroupList : public AIAbstractList { class AIGroupList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIGroupList"; } static const char *GetClassName() { return "AIGroupList"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIGroupList_Register(Squirrel *engine) void SQAIGroupList_Register(Squirrel *engine)
{ {
DefSQClass <AIGroupList> SQAIGroupList("AIGroupList"); DefSQClass <AIGroupList> SQAIGroupList("AIGroupList");
SQAIGroupList.PreRegister(engine, "AIAbstractList"); SQAIGroupList.PreRegister(engine, "AIList");
SQAIGroupList.AddConstructor<void (AIGroupList::*)(), 1>(engine, "x"); SQAIGroupList.AddConstructor<void (AIGroupList::*)(), 1>(engine, "x");
SQAIGroupList.PostRegister(engine); SQAIGroupList.PostRegister(engine);

View File

@ -12,13 +12,13 @@
#ifndef AI_INDUSTRYLIST_HPP #ifndef AI_INDUSTRYLIST_HPP
#define AI_INDUSTRYLIST_HPP #define AI_INDUSTRYLIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
/** /**
* Creates a list of industries that are currently on the map. * Creates a list of industries that are currently on the map.
* @ingroup AIList * @ingroup AIList
*/ */
class AIIndustryList : public AIAbstractList { class AIIndustryList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIIndustryList"; } static const char *GetClassName() { return "AIIndustryList"; }
@ -29,7 +29,7 @@ public:
* Creates a list of industries that accepts a given cargo. * Creates a list of industries that accepts a given cargo.
* @ingroup AIList * @ingroup AIList
*/ */
class AIIndustryList_CargoAccepting : public AIAbstractList { class AIIndustryList_CargoAccepting : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIIndustryList_CargoAccepting"; } static const char *GetClassName() { return "AIIndustryList_CargoAccepting"; }
@ -45,7 +45,7 @@ public:
* @note It also contains industries that currently produces 0 units of the cargo. * @note It also contains industries that currently produces 0 units of the cargo.
* @ingroup AIList * @ingroup AIList
*/ */
class AIIndustryList_CargoProducing : public AIAbstractList { class AIIndustryList_CargoProducing : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIIndustryList_CargoProducing"; } static const char *GetClassName() { return "AIIndustryList_CargoProducing"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIIndustryList_Register(Squirrel *engine) void SQAIIndustryList_Register(Squirrel *engine)
{ {
DefSQClass <AIIndustryList> SQAIIndustryList("AIIndustryList"); DefSQClass <AIIndustryList> SQAIIndustryList("AIIndustryList");
SQAIIndustryList.PreRegister(engine, "AIAbstractList"); SQAIIndustryList.PreRegister(engine, "AIList");
SQAIIndustryList.AddConstructor<void (AIIndustryList::*)(), 1>(engine, "x"); SQAIIndustryList.AddConstructor<void (AIIndustryList::*)(), 1>(engine, "x");
SQAIIndustryList.PostRegister(engine); SQAIIndustryList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAIIndustryList_CargoAccepting_Register(Squirrel *engine) void SQAIIndustryList_CargoAccepting_Register(Squirrel *engine)
{ {
DefSQClass <AIIndustryList_CargoAccepting> SQAIIndustryList_CargoAccepting("AIIndustryList_CargoAccepting"); DefSQClass <AIIndustryList_CargoAccepting> SQAIIndustryList_CargoAccepting("AIIndustryList_CargoAccepting");
SQAIIndustryList_CargoAccepting.PreRegister(engine, "AIAbstractList"); SQAIIndustryList_CargoAccepting.PreRegister(engine, "AIList");
SQAIIndustryList_CargoAccepting.AddConstructor<void (AIIndustryList_CargoAccepting::*)(CargoID cargo_id), 2>(engine, "xi"); SQAIIndustryList_CargoAccepting.AddConstructor<void (AIIndustryList_CargoAccepting::*)(CargoID cargo_id), 2>(engine, "xi");
SQAIIndustryList_CargoAccepting.PostRegister(engine); SQAIIndustryList_CargoAccepting.PostRegister(engine);
@ -59,7 +59,7 @@ namespace SQConvert {
void SQAIIndustryList_CargoProducing_Register(Squirrel *engine) void SQAIIndustryList_CargoProducing_Register(Squirrel *engine)
{ {
DefSQClass <AIIndustryList_CargoProducing> SQAIIndustryList_CargoProducing("AIIndustryList_CargoProducing"); DefSQClass <AIIndustryList_CargoProducing> SQAIIndustryList_CargoProducing("AIIndustryList_CargoProducing");
SQAIIndustryList_CargoProducing.PreRegister(engine, "AIAbstractList"); SQAIIndustryList_CargoProducing.PreRegister(engine, "AIList");
SQAIIndustryList_CargoProducing.AddConstructor<void (AIIndustryList_CargoProducing::*)(CargoID cargo_id), 2>(engine, "xi"); SQAIIndustryList_CargoProducing.AddConstructor<void (AIIndustryList_CargoProducing::*)(CargoID cargo_id), 2>(engine, "xi");
SQAIIndustryList_CargoProducing.PostRegister(engine); SQAIIndustryList_CargoProducing.PostRegister(engine);

View File

@ -58,13 +58,13 @@
return industrytype_name; return industrytype_name;
} }
/* static */ AIAbstractList *AIIndustryType::GetProducedCargo(IndustryType industry_type) /* static */ AIList *AIIndustryType::GetProducedCargo(IndustryType industry_type)
{ {
if (!IsValidIndustryType(industry_type)) return NULL; if (!IsValidIndustryType(industry_type)) return NULL;
const IndustrySpec *ins = ::GetIndustrySpec(industry_type); const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
AIAbstractList *list = new AIAbstractList(); AIList *list = new AIList();
for (size_t i = 0; i < lengthof(ins->produced_cargo); i++) { for (size_t i = 0; i < lengthof(ins->produced_cargo); i++) {
if (ins->produced_cargo[i] != CT_INVALID) list->AddItem(ins->produced_cargo[i]); if (ins->produced_cargo[i] != CT_INVALID) list->AddItem(ins->produced_cargo[i]);
} }
@ -72,13 +72,13 @@
return list; return list;
} }
/* static */ AIAbstractList *AIIndustryType::GetAcceptedCargo(IndustryType industry_type) /* static */ AIList *AIIndustryType::GetAcceptedCargo(IndustryType industry_type)
{ {
if (!IsValidIndustryType(industry_type)) return NULL; if (!IsValidIndustryType(industry_type)) return NULL;
const IndustrySpec *ins = ::GetIndustrySpec(industry_type); const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
AIAbstractList *list = new AIAbstractList(); AIList *list = new AIList();
for (size_t i = 0; i < lengthof(ins->accepts_cargo); i++) { for (size_t i = 0; i < lengthof(ins->accepts_cargo); i++) {
if (ins->accepts_cargo[i] != CT_INVALID) list->AddItem(ins->accepts_cargo[i]); if (ins->accepts_cargo[i] != CT_INVALID) list->AddItem(ins->accepts_cargo[i]);
} }

View File

@ -14,7 +14,7 @@
#include "ai_object.hpp" #include "ai_object.hpp"
#include "ai_error.hpp" #include "ai_error.hpp"
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
/** /**
* Class that handles all industry-type related functions. * Class that handles all industry-type related functions.
@ -55,7 +55,7 @@ public:
* @pre IsValidIndustryType(industry_type). * @pre IsValidIndustryType(industry_type).
* @return The CargoIDs of all cargotypes this industry could produce. * @return The CargoIDs of all cargotypes this industry could produce.
*/ */
static AIAbstractList *GetProducedCargo(IndustryType industry_type); static AIList *GetProducedCargo(IndustryType industry_type);
/** /**
* Get a list of CargoID accepted by this industry-type. * Get a list of CargoID accepted by this industry-type.
@ -65,7 +65,7 @@ public:
* @pre IsValidIndustryType(industry_type). * @pre IsValidIndustryType(industry_type).
* @return The CargoIDs of all cargotypes this industry accepts. * @return The CargoIDs of all cargotypes this industry accepts.
*/ */
static AIAbstractList *GetAcceptedCargo(IndustryType industry_type); static AIList *GetAcceptedCargo(IndustryType industry_type);
/** /**
* Is this industry type a raw industry? * Is this industry type a raw industry?

View File

@ -12,14 +12,14 @@
#ifndef AI_INDUSTRYTYPELIST_HPP #ifndef AI_INDUSTRYTYPELIST_HPP
#define AI_INDUSTRYTYPELIST_HPP #define AI_INDUSTRYTYPELIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
#include "ai_industrytype.hpp" #include "ai_industrytype.hpp"
/** /**
* Creates a list of valid industry types. * Creates a list of valid industry types.
* @ingroup AIList * @ingroup AIList
*/ */
class AIIndustryTypeList : public AIAbstractList { class AIIndustryTypeList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIIndustryTypeList"; } static const char *GetClassName() { return "AIIndustryTypeList"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIIndustryTypeList_Register(Squirrel *engine) void SQAIIndustryTypeList_Register(Squirrel *engine)
{ {
DefSQClass <AIIndustryTypeList> SQAIIndustryTypeList("AIIndustryTypeList"); DefSQClass <AIIndustryTypeList> SQAIIndustryTypeList("AIIndustryTypeList");
SQAIIndustryTypeList.PreRegister(engine, "AIAbstractList"); SQAIIndustryTypeList.PreRegister(engine, "AIList");
SQAIIndustryTypeList.AddConstructor<void (AIIndustryTypeList::*)(), 1>(engine, "x"); SQAIIndustryTypeList.AddConstructor<void (AIIndustryTypeList::*)(), 1>(engine, "x");
SQAIIndustryTypeList.PostRegister(engine); SQAIIndustryTypeList.PostRegister(engine);

View File

@ -7,24 +7,24 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file ai_abstractlist.cpp Implementation of AIAbstractList. */ /** @file ai_list.cpp Implementation of AIList. */
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
#include "../../debug.h" #include "../../debug.h"
#include "../../script/squirrel.hpp" #include "../../script/squirrel.hpp"
/** /**
* Base class for any AIAbstractList sorter. * Base class for any AIList sorter.
*/ */
class AIAbstractListSorter { class AIListSorter {
protected: protected:
AIAbstractList *list; AIList *list;
public: public:
/** /**
* Virtual dtor, needed to mute warnings. * Virtual dtor, needed to mute warnings.
*/ */
virtual ~AIAbstractListSorter() { } virtual ~AIListSorter() { }
/** /**
* Get the first item of the sorter. * Get the first item of the sorter.
@ -55,16 +55,16 @@ public:
/** /**
* Sort by value, ascending. * Sort by value, ascending.
*/ */
class AIAbstractListSorterValueAscending : public AIAbstractListSorter { class AIListSorterValueAscending : public AIListSorter {
private: private:
AIAbstractList::AIAbstractListBucket::iterator bucket_iter; AIList::AIListBucket::iterator bucket_iter;
AIAbstractList::AIItemList *bucket_list; AIList::AIItemList *bucket_list;
AIAbstractList::AIItemList::iterator bucket_list_iter; AIList::AIItemList::iterator bucket_list_iter;
bool has_no_more_items; bool has_no_more_items;
int32 item_next; int32 item_next;
public: public:
AIAbstractListSorterValueAscending(AIAbstractList *list) AIListSorterValueAscending(AIList *list)
{ {
this->list = list; this->list = list;
this->End(); this->End();
@ -141,16 +141,16 @@ public:
/** /**
* Sort by value, descending. * Sort by value, descending.
*/ */
class AIAbstractListSorterValueDescending : public AIAbstractListSorter { class AIListSorterValueDescending : public AIListSorter {
private: private:
AIAbstractList::AIAbstractListBucket::iterator bucket_iter; AIList::AIListBucket::iterator bucket_iter;
AIAbstractList::AIItemList *bucket_list; AIList::AIItemList *bucket_list;
AIAbstractList::AIItemList::iterator bucket_list_iter; AIList::AIItemList::iterator bucket_list_iter;
bool has_no_more_items; bool has_no_more_items;
int32 item_next; int32 item_next;
public: public:
AIAbstractListSorterValueDescending(AIAbstractList *list) AIListSorterValueDescending(AIList *list)
{ {
this->list = list; this->list = list;
this->End(); this->End();
@ -235,14 +235,14 @@ public:
/** /**
* Sort by item, ascending. * Sort by item, ascending.
*/ */
class AIAbstractListSorterItemAscending : public AIAbstractListSorter { class AIListSorterItemAscending : public AIListSorter {
private: private:
AIAbstractList::AIAbstractListMap::iterator item_iter; AIList::AIListMap::iterator item_iter;
bool has_no_more_items; bool has_no_more_items;
int32 item_next; int32 item_next;
public: public:
AIAbstractListSorterItemAscending(AIAbstractList *list) AIListSorterItemAscending(AIList *list)
{ {
this->list = list; this->list = list;
this->End(); this->End();
@ -305,14 +305,14 @@ public:
/** /**
* Sort by item, descending. * Sort by item, descending.
*/ */
class AIAbstractListSorterItemDescending : public AIAbstractListSorter { class AIListSorterItemDescending : public AIListSorter {
private: private:
AIAbstractList::AIAbstractListMap::iterator item_iter; AIList::AIListMap::iterator item_iter;
bool has_no_more_items; bool has_no_more_items;
int32 item_next; int32 item_next;
public: public:
AIAbstractListSorterItemDescending(AIAbstractList *list) AIListSorterItemDescending(AIList *list)
{ {
this->list = list; this->list = list;
this->End(); this->End();
@ -375,27 +375,27 @@ public:
AIAbstractList::AIAbstractList() AIList::AIList()
{ {
/* Default sorter */ /* Default sorter */
this->sorter = new AIAbstractListSorterValueDescending(this); this->sorter = new AIListSorterValueDescending(this);
this->sorter_type = SORT_BY_VALUE; this->sorter_type = SORT_BY_VALUE;
this->sort_ascending = false; this->sort_ascending = false;
this->initialized = false; this->initialized = false;
this->modifications = 0; this->modifications = 0;
} }
AIAbstractList::~AIAbstractList() AIList::~AIList()
{ {
delete this->sorter; delete this->sorter;
} }
bool AIAbstractList::HasItem(int32 item) bool AIList::HasItem(int32 item)
{ {
return this->items.count(item) == 1; return this->items.count(item) == 1;
} }
void AIAbstractList::Clear() void AIList::Clear()
{ {
this->modifications++; this->modifications++;
@ -404,7 +404,7 @@ void AIAbstractList::Clear()
this->sorter->End(); this->sorter->End();
} }
void AIAbstractList::AddItem(int32 item, int32 value) void AIList::AddItem(int32 item, int32 value)
{ {
this->modifications++; this->modifications++;
@ -416,7 +416,7 @@ void AIAbstractList::AddItem(int32 item, int32 value)
this->SetValue(item, value); this->SetValue(item, value);
} }
void AIAbstractList::RemoveItem(int32 item) void AIList::RemoveItem(int32 item)
{ {
this->modifications++; this->modifications++;
@ -430,13 +430,13 @@ void AIAbstractList::RemoveItem(int32 item)
this->items.erase(item); this->items.erase(item);
} }
int32 AIAbstractList::Begin() int32 AIList::Begin()
{ {
this->initialized = true; this->initialized = true;
return this->sorter->Begin(); return this->sorter->Begin();
} }
int32 AIAbstractList::Next() int32 AIList::Next()
{ {
if (this->initialized == false) { if (this->initialized == false) {
DEBUG(ai, 0, "Next() is invalid as Begin() is never called"); DEBUG(ai, 0, "Next() is invalid as Begin() is never called");
@ -445,12 +445,12 @@ int32 AIAbstractList::Next()
return this->sorter->Next(); return this->sorter->Next();
} }
bool AIAbstractList::IsEmpty() bool AIList::IsEmpty()
{ {
return this->items.empty(); return this->items.empty();
} }
bool AIAbstractList::IsEnd() bool AIList::IsEnd()
{ {
if (this->initialized == false) { if (this->initialized == false) {
DEBUG(ai, 0, "IsEnd() is invalid as Begin() is never called"); DEBUG(ai, 0, "IsEnd() is invalid as Begin() is never called");
@ -459,19 +459,19 @@ bool AIAbstractList::IsEnd()
return this->sorter->IsEnd(); return this->sorter->IsEnd();
} }
int32 AIAbstractList::Count() int32 AIList::Count()
{ {
return (int32)this->items.size(); return (int32)this->items.size();
} }
int32 AIAbstractList::GetValue(int32 item) int32 AIList::GetValue(int32 item)
{ {
if (!this->HasItem(item)) return 0; if (!this->HasItem(item)) return 0;
return this->items[item]; return this->items[item];
} }
bool AIAbstractList::SetValue(int32 item, int32 value) bool AIList::SetValue(int32 item, int32 value)
{ {
this->modifications++; this->modifications++;
@ -489,7 +489,7 @@ bool AIAbstractList::SetValue(int32 item, int32 value)
return true; return true;
} }
void AIAbstractList::Sort(SorterType sorter, bool ascending) void AIList::Sort(SorterType sorter, bool ascending)
{ {
this->modifications++; this->modifications++;
@ -500,17 +500,17 @@ void AIAbstractList::Sort(SorterType sorter, bool ascending)
switch (sorter) { switch (sorter) {
case SORT_BY_ITEM: case SORT_BY_ITEM:
if (ascending) { if (ascending) {
this->sorter = new AIAbstractListSorterItemAscending(this); this->sorter = new AIListSorterItemAscending(this);
} else { } else {
this->sorter = new AIAbstractListSorterItemDescending(this); this->sorter = new AIListSorterItemDescending(this);
} }
break; break;
case SORT_BY_VALUE: case SORT_BY_VALUE:
if (ascending) { if (ascending) {
this->sorter = new AIAbstractListSorterValueAscending(this); this->sorter = new AIListSorterValueAscending(this);
} else { } else {
this->sorter = new AIAbstractListSorterValueDescending(this); this->sorter = new AIListSorterValueDescending(this);
} }
break; break;
@ -523,56 +523,56 @@ void AIAbstractList::Sort(SorterType sorter, bool ascending)
this->initialized = false; this->initialized = false;
} }
void AIAbstractList::AddList(AIAbstractList *list) void AIList::AddList(AIList *list)
{ {
AIAbstractListMap *list_items = &list->items; AIListMap *list_items = &list->items;
for (AIAbstractListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) { for (AIListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) {
this->AddItem((*iter).first); this->AddItem((*iter).first);
this->SetValue((*iter).first, (*iter).second); this->SetValue((*iter).first, (*iter).second);
} }
} }
void AIAbstractList::RemoveAboveValue(int32 value) void AIList::RemoveAboveValue(int32 value)
{ {
this->modifications++; this->modifications++;
for (AIAbstractListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) { for (AIListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) {
next_iter = iter; next_iter++; next_iter = iter; next_iter++;
if ((*iter).second > value) this->RemoveItem((*iter).first); if ((*iter).second > value) this->RemoveItem((*iter).first);
} }
} }
void AIAbstractList::RemoveBelowValue(int32 value) void AIList::RemoveBelowValue(int32 value)
{ {
this->modifications++; this->modifications++;
for (AIAbstractListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) { for (AIListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) {
next_iter = iter; next_iter++; next_iter = iter; next_iter++;
if ((*iter).second < value) this->RemoveItem((*iter).first); if ((*iter).second < value) this->RemoveItem((*iter).first);
} }
} }
void AIAbstractList::RemoveBetweenValue(int32 start, int32 end) void AIList::RemoveBetweenValue(int32 start, int32 end)
{ {
this->modifications++; this->modifications++;
for (AIAbstractListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) { for (AIListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) {
next_iter = iter; next_iter++; next_iter = iter; next_iter++;
if ((*iter).second > start && (*iter).second < end) this->RemoveItem((*iter).first); if ((*iter).second > start && (*iter).second < end) this->RemoveItem((*iter).first);
} }
} }
void AIAbstractList::RemoveValue(int32 value) void AIList::RemoveValue(int32 value)
{ {
this->modifications++; this->modifications++;
for (AIAbstractListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) { for (AIListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) {
next_iter = iter; next_iter++; next_iter = iter; next_iter++;
if ((*iter).second == value) this->RemoveItem((*iter).first); if ((*iter).second == value) this->RemoveItem((*iter).first);
} }
} }
void AIAbstractList::RemoveTop(int32 count) void AIList::RemoveTop(int32 count)
{ {
this->modifications++; this->modifications++;
@ -586,7 +586,7 @@ void AIAbstractList::RemoveTop(int32 count)
switch (this->sorter_type) { switch (this->sorter_type) {
default: NOT_REACHED(); default: NOT_REACHED();
case SORT_BY_VALUE: case SORT_BY_VALUE:
for (AIAbstractListBucket::iterator iter = this->buckets.begin(); iter != this->buckets.end(); iter = this->buckets.begin()) { for (AIListBucket::iterator iter = this->buckets.begin(); iter != this->buckets.end(); iter = this->buckets.begin()) {
AIItemList *items = &(*iter).second; AIItemList *items = &(*iter).second;
size_t size = items->size(); size_t size = items->size();
for (AIItemList::iterator iter = items->begin(); iter != items->end(); iter = items->begin()) { for (AIItemList::iterator iter = items->begin(); iter != items->end(); iter = items->begin()) {
@ -601,7 +601,7 @@ void AIAbstractList::RemoveTop(int32 count)
break; break;
case SORT_BY_ITEM: case SORT_BY_ITEM:
for (AIAbstractListMap::iterator iter = this->items.begin(); iter != this->items.end(); iter = this->items.begin()) { for (AIListMap::iterator iter = this->items.begin(); iter != this->items.end(); iter = this->items.begin()) {
if (--count < 0) return; if (--count < 0) return;
this->RemoveItem((*iter).first); this->RemoveItem((*iter).first);
} }
@ -609,7 +609,7 @@ void AIAbstractList::RemoveTop(int32 count)
} }
} }
void AIAbstractList::RemoveBottom(int32 count) void AIList::RemoveBottom(int32 count)
{ {
this->modifications++; this->modifications++;
@ -623,7 +623,7 @@ void AIAbstractList::RemoveBottom(int32 count)
switch (this->sorter_type) { switch (this->sorter_type) {
default: NOT_REACHED(); default: NOT_REACHED();
case SORT_BY_VALUE: case SORT_BY_VALUE:
for (AIAbstractListBucket::reverse_iterator iter = this->buckets.rbegin(); iter != this->buckets.rend(); iter = this->buckets.rbegin()) { for (AIListBucket::reverse_iterator iter = this->buckets.rbegin(); iter != this->buckets.rend(); iter = this->buckets.rbegin()) {
AIItemList *items = &(*iter).second; AIItemList *items = &(*iter).second;
size_t size = items->size(); size_t size = items->size();
for (AIItemList::reverse_iterator iter = items->rbegin(); iter != items->rend(); iter = items->rbegin()) { for (AIItemList::reverse_iterator iter = items->rbegin(); iter != items->rend(); iter = items->rbegin()) {
@ -637,7 +637,7 @@ void AIAbstractList::RemoveBottom(int32 count)
} }
case SORT_BY_ITEM: case SORT_BY_ITEM:
for (AIAbstractListMap::reverse_iterator iter = this->items.rbegin(); iter != this->items.rend(); iter = this->items.rbegin()) { for (AIListMap::reverse_iterator iter = this->items.rbegin(); iter != this->items.rend(); iter = this->items.rbegin()) {
if (--count < 0) return; if (--count < 0) return;
this->RemoveItem((*iter).first); this->RemoveItem((*iter).first);
} }
@ -645,76 +645,76 @@ void AIAbstractList::RemoveBottom(int32 count)
} }
} }
void AIAbstractList::RemoveList(AIAbstractList *list) void AIList::RemoveList(AIList *list)
{ {
this->modifications++; this->modifications++;
AIAbstractListMap *list_items = &list->items; AIListMap *list_items = &list->items;
for (AIAbstractListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) { for (AIListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) {
this->RemoveItem((*iter).first); this->RemoveItem((*iter).first);
} }
} }
void AIAbstractList::KeepAboveValue(int32 value) void AIList::KeepAboveValue(int32 value)
{ {
this->modifications++; this->modifications++;
for (AIAbstractListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) { for (AIListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) {
next_iter = iter; next_iter++; next_iter = iter; next_iter++;
if ((*iter).second <= value) this->RemoveItem((*iter).first); if ((*iter).second <= value) this->RemoveItem((*iter).first);
} }
} }
void AIAbstractList::KeepBelowValue(int32 value) void AIList::KeepBelowValue(int32 value)
{ {
this->modifications++; this->modifications++;
for (AIAbstractListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) { for (AIListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) {
next_iter = iter; next_iter++; next_iter = iter; next_iter++;
if ((*iter).second >= value) this->RemoveItem((*iter).first); if ((*iter).second >= value) this->RemoveItem((*iter).first);
} }
} }
void AIAbstractList::KeepBetweenValue(int32 start, int32 end) void AIList::KeepBetweenValue(int32 start, int32 end)
{ {
this->modifications++; this->modifications++;
for (AIAbstractListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) { for (AIListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) {
next_iter = iter; next_iter++; next_iter = iter; next_iter++;
if ((*iter).second <= start || (*iter).second >= end) this->RemoveItem((*iter).first); if ((*iter).second <= start || (*iter).second >= end) this->RemoveItem((*iter).first);
} }
} }
void AIAbstractList::KeepValue(int32 value) void AIList::KeepValue(int32 value)
{ {
this->modifications++; this->modifications++;
for (AIAbstractListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) { for (AIListMap::iterator next_iter, iter = this->items.begin(); iter != this->items.end(); iter = next_iter) {
next_iter = iter; next_iter++; next_iter = iter; next_iter++;
if ((*iter).second != value) this->RemoveItem((*iter).first); if ((*iter).second != value) this->RemoveItem((*iter).first);
} }
} }
void AIAbstractList::KeepTop(int32 count) void AIList::KeepTop(int32 count)
{ {
this->modifications++; this->modifications++;
this->RemoveBottom(this->Count() - count); this->RemoveBottom(this->Count() - count);
} }
void AIAbstractList::KeepBottom(int32 count) void AIList::KeepBottom(int32 count)
{ {
this->modifications++; this->modifications++;
this->RemoveTop(this->Count() - count); this->RemoveTop(this->Count() - count);
} }
void AIAbstractList::KeepList(AIAbstractList *list) void AIList::KeepList(AIList *list)
{ {
this->modifications++; this->modifications++;
AIAbstractList tmp; AIList tmp;
for (AIAbstractListMap::iterator iter = this->items.begin(); iter != this->items.end(); iter++) { for (AIListMap::iterator iter = this->items.begin(); iter != this->items.end(); iter++) {
tmp.AddItem((*iter).first); tmp.AddItem((*iter).first);
tmp.SetValue((*iter).first, (*iter).second); tmp.SetValue((*iter).first, (*iter).second);
} }
@ -723,7 +723,7 @@ void AIAbstractList::KeepList(AIAbstractList *list)
this->RemoveList(&tmp); this->RemoveList(&tmp);
} }
SQInteger AIAbstractList::_get(HSQUIRRELVM vm) SQInteger AIList::_get(HSQUIRRELVM vm)
{ {
if (sq_gettype(vm, 2) != OT_INTEGER) return SQ_ERROR; if (sq_gettype(vm, 2) != OT_INTEGER) return SQ_ERROR;
@ -736,7 +736,7 @@ SQInteger AIAbstractList::_get(HSQUIRRELVM vm)
return 1; return 1;
} }
SQInteger AIAbstractList::_set(HSQUIRRELVM vm) SQInteger AIList::_set(HSQUIRRELVM vm)
{ {
if (sq_gettype(vm, 2) != OT_INTEGER) return SQ_ERROR; if (sq_gettype(vm, 2) != OT_INTEGER) return SQ_ERROR;
if (sq_gettype(vm, 3) != OT_INTEGER || sq_gettype(vm, 3) == OT_NULL) { if (sq_gettype(vm, 3) != OT_INTEGER || sq_gettype(vm, 3) == OT_NULL) {
@ -760,7 +760,7 @@ SQInteger AIAbstractList::_set(HSQUIRRELVM vm)
return 0; return 0;
} }
SQInteger AIAbstractList::_nexti(HSQUIRRELVM vm) SQInteger AIList::_nexti(HSQUIRRELVM vm)
{ {
if (sq_gettype(vm, 2) == OT_NULL) { if (sq_gettype(vm, 2) == OT_NULL) {
if (this->IsEmpty()) { if (this->IsEmpty()) {
@ -784,15 +784,15 @@ SQInteger AIAbstractList::_nexti(HSQUIRRELVM vm)
return 1; return 1;
} }
SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm) SQInteger AIList::Valuate(HSQUIRRELVM vm)
{ {
this->modifications++; this->modifications++;
/* The first parameter is the instance of AIAbstractList. */ /* The first parameter is the instance of AIList. */
int nparam = sq_gettop(vm) - 1; int nparam = sq_gettop(vm) - 1;
if (nparam < 1) { if (nparam < 1) {
return sq_throwerror(vm, _SC("You need to give a least a Valuator as parameter to AIAbstractList::Valuate")); return sq_throwerror(vm, _SC("You need to give a least a Valuator as parameter to AIList::Valuate"));
} }
/* Make sure the valuator function is really a function, and not any /* Make sure the valuator function is really a function, and not any
@ -811,7 +811,7 @@ SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm)
/* Push the function to call */ /* Push the function to call */
sq_push(vm, 2); sq_push(vm, 2);
for (AIAbstractListMap::iterator iter = this->items.begin(); iter != this->items.end(); iter++) { for (AIListMap::iterator iter = this->items.begin(); iter != this->items.end(); iter++) {
/* Check for changing of items. */ /* Check for changing of items. */
int previous_modification_count = this->modifications; int previous_modification_count = this->modifications;
@ -873,7 +873,7 @@ SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm)
* 1. The root stable (as instance object). * 1. The root stable (as instance object).
* 2. The valuator function. * 2. The valuator function.
* 3. The parameters given to this function. * 3. The parameters given to this function.
* 4. The AIAbstractList instance object. */ * 4. The AIList instance object. */
sq_pop(vm, nparam + 3); sq_pop(vm, nparam + 3);
AIObject::SetAllowDoCommand(backup_allow); AIObject::SetAllowDoCommand(backup_allow);

View File

@ -7,25 +7,25 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file ai_abstractlist.hpp A list which can keep item/value pairs, which you can walk. */ /** @file ai_list.hpp A list which can keep item/value pairs, which you can walk. */
/** @defgroup AIList Classes that create a list of items. */ /** @defgroup AIList Classes that create a list of items. */
#ifndef AI_ABSTRACTLIST_HPP #ifndef AI_LIST_HPP
#define AI_ABSTRACTLIST_HPP #define AI_LIST_HPP
#include "ai_object.hpp" #include "ai_object.hpp"
#include <map> #include <map>
#include <set> #include <set>
class AIAbstractListSorter; class AIListSorter;
/** /**
* Class that creates a list which can keep item/value pairs, which you can walk. * Class that creates a list which can keep item/value pairs, which you can walk.
*/ */
class AIAbstractList : public AIObject { class AIList : public AIObject {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIAbstractList"; } static const char *GetClassName() { return "AIList"; }
/** Type of sorter */ /** Type of sorter */
enum SorterType { enum SorterType {
@ -39,22 +39,22 @@ public:
static const bool SORT_DESCENDING = false; static const bool SORT_DESCENDING = false;
private: private:
AIAbstractListSorter *sorter; ///< Sorting algorithm AIListSorter *sorter; ///< Sorting algorithm
SorterType sorter_type; ///< Sorting type SorterType sorter_type; ///< Sorting type
bool sort_ascending; ///< Whether to sort ascending or descending bool sort_ascending; ///< Whether to sort ascending or descending
bool initialized; ///< Whether an iteration has been started bool initialized; ///< Whether an iteration has been started
int modifications; ///< Number of modification that has been done. To prevent changing data while valuating. int modifications; ///< Number of modification that has been done. To prevent changing data while valuating.
public: public:
typedef std::set<int32> AIItemList; ///< The list of items inside the bucket typedef std::set<int32> AIItemList; ///< The list of items inside the bucket
typedef std::map<int32, AIItemList> AIAbstractListBucket; ///< The bucket list per value typedef std::map<int32, AIItemList> AIListBucket; ///< The bucket list per value
typedef std::map<int32, int32> AIAbstractListMap; ///< List per item typedef std::map<int32, int32> AIListMap; ///< List per item
AIAbstractListMap items; ///< The items in the list AIListMap items; ///< The items in the list
AIAbstractListBucket buckets; ///< The items in the list, sorted by value AIListBucket buckets; ///< The items in the list, sorted by value
AIAbstractList(); AIList();
~AIAbstractList(); ~AIList();
/** /**
* Add a single item to the list. * Add a single item to the list.
@ -149,7 +149,7 @@ public:
* @note If the item already exists inside the caller, the value of the * @note If the item already exists inside the caller, the value of the
* list that is added is set on the item. * list that is added is set on the item.
*/ */
void AddList(AIAbstractList *list); void AddList(AIList *list);
/** /**
* Removes all items with a higher value than 'value'. * Removes all items with a higher value than 'value'.
@ -193,7 +193,7 @@ public:
* @param list the list of items to remove. * @param list the list of items to remove.
* @pre list != NULL * @pre list != NULL
*/ */
void RemoveList(AIAbstractList *list); void RemoveList(AIList *list);
/** /**
* Keep all items with a higher value than 'value'. * Keep all items with a higher value than 'value'.
@ -237,7 +237,7 @@ public:
* @param list the list of items to keep. * @param list the list of items to keep.
* @pre list != NULL * @pre list != NULL
*/ */
void KeepList(AIAbstractList *list); void KeepList(AIList *list);
#ifndef DOXYGEN_SKIP #ifndef DOXYGEN_SKIP
/** /**

View File

@ -0,0 +1,72 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
#include "ai_list.hpp"
namespace SQConvert {
/* Allow enums to be used as Squirrel parameters */
template <> AIList::SorterType GetParam(ForceType<AIList::SorterType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIList::SorterType)tmp; }
template <> int Return<AIList::SorterType>(HSQUIRRELVM vm, AIList::SorterType res) { sq_pushinteger(vm, (int32)res); return 1; }
/* Allow AIList to be used as Squirrel parameter */
template <> AIList *GetParam(ForceType<AIList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIList *)instance; }
template <> AIList &GetParam(ForceType<AIList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIList *)instance; }
template <> const AIList *GetParam(ForceType<const AIList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIList *)instance; }
template <> const AIList &GetParam(ForceType<const AIList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIList *)instance; }
template <> int Return<AIList *>(HSQUIRRELVM vm, AIList *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIList", res, NULL, DefSQDestructorCallback<AIList>); return 1; }
} // namespace SQConvert
void SQAIList_Register(Squirrel *engine)
{
DefSQClass <AIList> SQAIList("AIList");
SQAIList.PreRegister(engine);
SQAIList.AddConstructor<void (AIList::*)(), 1>(engine, "x");
SQAIList.DefSQConst(engine, AIList::SORT_BY_VALUE, "SORT_BY_VALUE");
SQAIList.DefSQConst(engine, AIList::SORT_BY_ITEM, "SORT_BY_ITEM");
SQAIList.DefSQConst(engine, AIList::SORT_ASCENDING, "SORT_ASCENDING");
SQAIList.DefSQConst(engine, AIList::SORT_DESCENDING, "SORT_DESCENDING");
SQAIList.DefSQMethod(engine, &AIList::AddItem, "AddItem", 3, "xii");
SQAIList.DefSQMethod(engine, &AIList::RemoveItem, "RemoveItem", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::Clear, "Clear", 1, "x");
SQAIList.DefSQMethod(engine, &AIList::HasItem, "HasItem", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::Begin, "Begin", 1, "x");
SQAIList.DefSQMethod(engine, &AIList::Next, "Next", 1, "x");
SQAIList.DefSQMethod(engine, &AIList::IsEmpty, "IsEmpty", 1, "x");
SQAIList.DefSQMethod(engine, &AIList::IsEnd, "IsEnd", 1, "x");
SQAIList.DefSQMethod(engine, &AIList::Count, "Count", 1, "x");
SQAIList.DefSQMethod(engine, &AIList::GetValue, "GetValue", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::SetValue, "SetValue", 3, "xii");
SQAIList.DefSQMethod(engine, &AIList::Sort, "Sort", 3, "xib");
SQAIList.DefSQMethod(engine, &AIList::AddList, "AddList", 2, "xx");
SQAIList.DefSQMethod(engine, &AIList::RemoveAboveValue, "RemoveAboveValue", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::RemoveBelowValue, "RemoveBelowValue", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::RemoveBetweenValue, "RemoveBetweenValue", 3, "xii");
SQAIList.DefSQMethod(engine, &AIList::RemoveValue, "RemoveValue", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::RemoveTop, "RemoveTop", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::RemoveBottom, "RemoveBottom", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::RemoveList, "RemoveList", 2, "xx");
SQAIList.DefSQMethod(engine, &AIList::KeepAboveValue, "KeepAboveValue", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::KeepBelowValue, "KeepBelowValue", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::KeepBetweenValue, "KeepBetweenValue", 3, "xii");
SQAIList.DefSQMethod(engine, &AIList::KeepValue, "KeepValue", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::KeepTop, "KeepTop", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::KeepBottom, "KeepBottom", 2, "xi");
SQAIList.DefSQMethod(engine, &AIList::KeepList, "KeepList", 2, "xx");
SQAIList.DefSQAdvancedMethod(engine, &AIList::_get, "_get");
SQAIList.DefSQAdvancedMethod(engine, &AIList::_set, "_set");
SQAIList.DefSQAdvancedMethod(engine, &AIList::_nexti, "_nexti");
SQAIList.DefSQAdvancedMethod(engine, &AIList::Valuate, "Valuate");
SQAIList.PostRegister(engine);
}

View File

@ -12,13 +12,13 @@
#ifndef AI_RAILTYPELIST_HPP #ifndef AI_RAILTYPELIST_HPP
#define AI_RAILTYPELIST_HPP #define AI_RAILTYPELIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
/** /**
* Creates a list of all available railtypes. * Creates a list of all available railtypes.
* @ingroup AIList * @ingroup AIList
*/ */
class AIRailTypeList : public AIAbstractList { class AIRailTypeList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIRailTypeList"; } static const char *GetClassName() { return "AIRailTypeList"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIRailTypeList_Register(Squirrel *engine) void SQAIRailTypeList_Register(Squirrel *engine)
{ {
DefSQClass <AIRailTypeList> SQAIRailTypeList("AIRailTypeList"); DefSQClass <AIRailTypeList> SQAIRailTypeList("AIRailTypeList");
SQAIRailTypeList.PreRegister(engine, "AIAbstractList"); SQAIRailTypeList.PreRegister(engine, "AIList");
SQAIRailTypeList.AddConstructor<void (AIRailTypeList::*)(), 1>(engine, "x"); SQAIRailTypeList.AddConstructor<void (AIRailTypeList::*)(), 1>(engine, "x");
SQAIRailTypeList.PostRegister(engine); SQAIRailTypeList.PostRegister(engine);

View File

@ -12,13 +12,13 @@
#ifndef AI_SIGNLIST_HPP #ifndef AI_SIGNLIST_HPP
#define AI_SIGNLIST_HPP #define AI_SIGNLIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
/** /**
* Create a list of signs your company has created. * Create a list of signs your company has created.
* @ingroup AIList * @ingroup AIList
*/ */
class AISignList : public AIAbstractList { class AISignList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AISignList"; } static const char *GetClassName() { return "AISignList"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAISignList_Register(Squirrel *engine) void SQAISignList_Register(Squirrel *engine)
{ {
DefSQClass <AISignList> SQAISignList("AISignList"); DefSQClass <AISignList> SQAISignList("AISignList");
SQAISignList.PreRegister(engine, "AIAbstractList"); SQAISignList.PreRegister(engine, "AIList");
SQAISignList.AddConstructor<void (AISignList::*)(), 1>(engine, "x"); SQAISignList.AddConstructor<void (AISignList::*)(), 1>(engine, "x");
SQAISignList.PostRegister(engine); SQAISignList.PostRegister(engine);

View File

@ -12,14 +12,14 @@
#ifndef AI_STATIONLIST_HPP #ifndef AI_STATIONLIST_HPP
#define AI_STATIONLIST_HPP #define AI_STATIONLIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
#include "ai_station.hpp" #include "ai_station.hpp"
/** /**
* Creates a list of stations of which you are the owner. * Creates a list of stations of which you are the owner.
* @ingroup AIList * @ingroup AIList
*/ */
class AIStationList : public AIAbstractList { class AIStationList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIStationList"; } static const char *GetClassName() { return "AIStationList"; }
@ -34,7 +34,7 @@ public:
* Creates a list of stations which the vehicle has in its orders. * Creates a list of stations which the vehicle has in its orders.
* @ingroup AIList * @ingroup AIList
*/ */
class AIStationList_Vehicle : public AIAbstractList { class AIStationList_Vehicle : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIStationList_Vehicle"; } static const char *GetClassName() { return "AIStationList_Vehicle"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIStationList_Register(Squirrel *engine) void SQAIStationList_Register(Squirrel *engine)
{ {
DefSQClass <AIStationList> SQAIStationList("AIStationList"); DefSQClass <AIStationList> SQAIStationList("AIStationList");
SQAIStationList.PreRegister(engine, "AIAbstractList"); SQAIStationList.PreRegister(engine, "AIList");
SQAIStationList.AddConstructor<void (AIStationList::*)(AIStation::StationType station_type), 2>(engine, "xi"); SQAIStationList.AddConstructor<void (AIStationList::*)(AIStation::StationType station_type), 2>(engine, "xi");
SQAIStationList.PostRegister(engine); SQAIStationList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAIStationList_Vehicle_Register(Squirrel *engine) void SQAIStationList_Vehicle_Register(Squirrel *engine)
{ {
DefSQClass <AIStationList_Vehicle> SQAIStationList_Vehicle("AIStationList_Vehicle"); DefSQClass <AIStationList_Vehicle> SQAIStationList_Vehicle("AIStationList_Vehicle");
SQAIStationList_Vehicle.PreRegister(engine, "AIAbstractList"); SQAIStationList_Vehicle.PreRegister(engine, "AIList");
SQAIStationList_Vehicle.AddConstructor<void (AIStationList_Vehicle::*)(VehicleID vehicle_id), 2>(engine, "xi"); SQAIStationList_Vehicle.AddConstructor<void (AIStationList_Vehicle::*)(VehicleID vehicle_id), 2>(engine, "xi");
SQAIStationList_Vehicle.PostRegister(engine); SQAIStationList_Vehicle.PostRegister(engine);

View File

@ -12,13 +12,13 @@
#ifndef AI_SUBSIDYLIST_HPP #ifndef AI_SUBSIDYLIST_HPP
#define AI_SUBSIDYLIST_HPP #define AI_SUBSIDYLIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
/** /**
* Creates a list of all current subsidies. * Creates a list of all current subsidies.
* @ingroup AIList * @ingroup AIList
*/ */
class AISubsidyList : public AIAbstractList { class AISubsidyList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AISubsidyList"; } static const char *GetClassName() { return "AISubsidyList"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAISubsidyList_Register(Squirrel *engine) void SQAISubsidyList_Register(Squirrel *engine)
{ {
DefSQClass <AISubsidyList> SQAISubsidyList("AISubsidyList"); DefSQClass <AISubsidyList> SQAISubsidyList("AISubsidyList");
SQAISubsidyList.PreRegister(engine, "AIAbstractList"); SQAISubsidyList.PreRegister(engine, "AIList");
SQAISubsidyList.AddConstructor<void (AISubsidyList::*)(), 1>(engine, "x"); SQAISubsidyList.AddConstructor<void (AISubsidyList::*)(), 1>(engine, "x");
SQAISubsidyList.PostRegister(engine); SQAISubsidyList.PostRegister(engine);

View File

@ -12,7 +12,7 @@
#ifndef AI_TILE_HPP #ifndef AI_TILE_HPP
#define AI_TILE_HPP #define AI_TILE_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
#include "ai_error.hpp" #include "ai_error.hpp"
#include "ai_company.hpp" #include "ai_company.hpp"

View File

@ -12,14 +12,14 @@
#ifndef AI_TILELIST_HPP #ifndef AI_TILELIST_HPP
#define AI_TILELIST_HPP #define AI_TILELIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
#include "ai_station.hpp" #include "ai_station.hpp"
/** /**
* Creates an empty list, in which you can add tiles. * Creates an empty list, in which you can add tiles.
* @ingroup AIList * @ingroup AIList
*/ */
class AITileList : public AIAbstractList { class AITileList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AITileList"; } static const char *GetClassName() { return "AITileList"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAITileList_Register(Squirrel *engine) void SQAITileList_Register(Squirrel *engine)
{ {
DefSQClass <AITileList> SQAITileList("AITileList"); DefSQClass <AITileList> SQAITileList("AITileList");
SQAITileList.PreRegister(engine, "AIAbstractList"); SQAITileList.PreRegister(engine, "AIList");
SQAITileList.AddConstructor<void (AITileList::*)(), 1>(engine, "x"); SQAITileList.AddConstructor<void (AITileList::*)(), 1>(engine, "x");
SQAITileList.DefSQMethod(engine, &AITileList::AddRectangle, "AddRectangle", 3, "xii"); SQAITileList.DefSQMethod(engine, &AITileList::AddRectangle, "AddRectangle", 3, "xii");

View File

@ -12,13 +12,13 @@
#ifndef AI_TOWNLIST_HPP #ifndef AI_TOWNLIST_HPP
#define AI_TOWNLIST_HPP #define AI_TOWNLIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
/** /**
* Creates a list of towns that are currently on the map. * Creates a list of towns that are currently on the map.
* @ingroup AIList * @ingroup AIList
*/ */
class AITownList : public AIAbstractList { class AITownList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AITownList"; } static const char *GetClassName() { return "AITownList"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAITownList_Register(Squirrel *engine) void SQAITownList_Register(Squirrel *engine)
{ {
DefSQClass <AITownList> SQAITownList("AITownList"); DefSQClass <AITownList> SQAITownList("AITownList");
SQAITownList.PreRegister(engine, "AIAbstractList"); SQAITownList.PreRegister(engine, "AIList");
SQAITownList.AddConstructor<void (AITownList::*)(), 1>(engine, "x"); SQAITownList.AddConstructor<void (AITownList::*)(), 1>(engine, "x");
SQAITownList.PostRegister(engine); SQAITownList.PostRegister(engine);

View File

@ -12,14 +12,14 @@
#ifndef AI_VEHICLELIST_HPP #ifndef AI_VEHICLELIST_HPP
#define AI_VEHICLELIST_HPP #define AI_VEHICLELIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
#include "ai_vehicle.hpp" #include "ai_vehicle.hpp"
/** /**
* Creates a list of vehicles of which you are the owner. * Creates a list of vehicles of which you are the owner.
* @ingroup AIList * @ingroup AIList
*/ */
class AIVehicleList : public AIAbstractList { class AIVehicleList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIVehicleList"; } static const char *GetClassName() { return "AIVehicleList"; }
@ -30,7 +30,7 @@ public:
* Creates a list of vehicles that have orders to a given station. * Creates a list of vehicles that have orders to a given station.
* @ingroup AIList * @ingroup AIList
*/ */
class AIVehicleList_Station : public AIAbstractList { class AIVehicleList_Station : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIVehicleList_Station"; } static const char *GetClassName() { return "AIVehicleList_Station"; }
@ -50,7 +50,7 @@ public:
* an empty list will be returned. * an empty list will be returned.
* @ingroup AIList * @ingroup AIList
*/ */
class AIVehicleList_Depot : public AIAbstractList { class AIVehicleList_Depot : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIVehicleList_Depot"; } static const char *GetClassName() { return "AIVehicleList_Depot"; }
@ -65,7 +65,7 @@ public:
* Creates a list of vehicles that share orders. * Creates a list of vehicles that share orders.
* @ingroup AIList * @ingroup AIList
*/ */
class AIVehicleList_SharedOrders : public AIAbstractList { class AIVehicleList_SharedOrders : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIVehicleList_SharedOrders"; } static const char *GetClassName() { return "AIVehicleList_SharedOrders"; }
@ -80,7 +80,7 @@ public:
* Creates a list of vehicles that are in a group. * Creates a list of vehicles that are in a group.
* @ingroup AIList * @ingroup AIList
*/ */
class AIVehicleList_Group : public AIAbstractList { class AIVehicleList_Group : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIVehicleList_Group"; } static const char *GetClassName() { return "AIVehicleList_Group"; }
@ -95,7 +95,7 @@ public:
* Creates a list of vehicles that are in the default group. * Creates a list of vehicles that are in the default group.
* @ingroup AIList * @ingroup AIList
*/ */
class AIVehicleList_DefaultGroup : public AIAbstractList { class AIVehicleList_DefaultGroup : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIVehicleList_DefaultGroup"; } static const char *GetClassName() { return "AIVehicleList_DefaultGroup"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIVehicleList_Register(Squirrel *engine) void SQAIVehicleList_Register(Squirrel *engine)
{ {
DefSQClass <AIVehicleList> SQAIVehicleList("AIVehicleList"); DefSQClass <AIVehicleList> SQAIVehicleList("AIVehicleList");
SQAIVehicleList.PreRegister(engine, "AIAbstractList"); SQAIVehicleList.PreRegister(engine, "AIList");
SQAIVehicleList.AddConstructor<void (AIVehicleList::*)(), 1>(engine, "x"); SQAIVehicleList.AddConstructor<void (AIVehicleList::*)(), 1>(engine, "x");
SQAIVehicleList.PostRegister(engine); SQAIVehicleList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAIVehicleList_Station_Register(Squirrel *engine) void SQAIVehicleList_Station_Register(Squirrel *engine)
{ {
DefSQClass <AIVehicleList_Station> SQAIVehicleList_Station("AIVehicleList_Station"); DefSQClass <AIVehicleList_Station> SQAIVehicleList_Station("AIVehicleList_Station");
SQAIVehicleList_Station.PreRegister(engine, "AIAbstractList"); SQAIVehicleList_Station.PreRegister(engine, "AIList");
SQAIVehicleList_Station.AddConstructor<void (AIVehicleList_Station::*)(StationID station_id), 2>(engine, "xi"); SQAIVehicleList_Station.AddConstructor<void (AIVehicleList_Station::*)(StationID station_id), 2>(engine, "xi");
SQAIVehicleList_Station.PostRegister(engine); SQAIVehicleList_Station.PostRegister(engine);
@ -59,7 +59,7 @@ namespace SQConvert {
void SQAIVehicleList_Depot_Register(Squirrel *engine) void SQAIVehicleList_Depot_Register(Squirrel *engine)
{ {
DefSQClass <AIVehicleList_Depot> SQAIVehicleList_Depot("AIVehicleList_Depot"); DefSQClass <AIVehicleList_Depot> SQAIVehicleList_Depot("AIVehicleList_Depot");
SQAIVehicleList_Depot.PreRegister(engine, "AIAbstractList"); SQAIVehicleList_Depot.PreRegister(engine, "AIList");
SQAIVehicleList_Depot.AddConstructor<void (AIVehicleList_Depot::*)(TileIndex tile), 2>(engine, "xi"); SQAIVehicleList_Depot.AddConstructor<void (AIVehicleList_Depot::*)(TileIndex tile), 2>(engine, "xi");
SQAIVehicleList_Depot.PostRegister(engine); SQAIVehicleList_Depot.PostRegister(engine);
@ -77,7 +77,7 @@ namespace SQConvert {
void SQAIVehicleList_SharedOrders_Register(Squirrel *engine) void SQAIVehicleList_SharedOrders_Register(Squirrel *engine)
{ {
DefSQClass <AIVehicleList_SharedOrders> SQAIVehicleList_SharedOrders("AIVehicleList_SharedOrders"); DefSQClass <AIVehicleList_SharedOrders> SQAIVehicleList_SharedOrders("AIVehicleList_SharedOrders");
SQAIVehicleList_SharedOrders.PreRegister(engine, "AIAbstractList"); SQAIVehicleList_SharedOrders.PreRegister(engine, "AIList");
SQAIVehicleList_SharedOrders.AddConstructor<void (AIVehicleList_SharedOrders::*)(VehicleID vehicle_id), 2>(engine, "xi"); SQAIVehicleList_SharedOrders.AddConstructor<void (AIVehicleList_SharedOrders::*)(VehicleID vehicle_id), 2>(engine, "xi");
SQAIVehicleList_SharedOrders.PostRegister(engine); SQAIVehicleList_SharedOrders.PostRegister(engine);
@ -95,7 +95,7 @@ namespace SQConvert {
void SQAIVehicleList_Group_Register(Squirrel *engine) void SQAIVehicleList_Group_Register(Squirrel *engine)
{ {
DefSQClass <AIVehicleList_Group> SQAIVehicleList_Group("AIVehicleList_Group"); DefSQClass <AIVehicleList_Group> SQAIVehicleList_Group("AIVehicleList_Group");
SQAIVehicleList_Group.PreRegister(engine, "AIAbstractList"); SQAIVehicleList_Group.PreRegister(engine, "AIList");
SQAIVehicleList_Group.AddConstructor<void (AIVehicleList_Group::*)(GroupID group_id), 2>(engine, "xi"); SQAIVehicleList_Group.AddConstructor<void (AIVehicleList_Group::*)(GroupID group_id), 2>(engine, "xi");
SQAIVehicleList_Group.PostRegister(engine); SQAIVehicleList_Group.PostRegister(engine);
@ -113,7 +113,7 @@ namespace SQConvert {
void SQAIVehicleList_DefaultGroup_Register(Squirrel *engine) void SQAIVehicleList_DefaultGroup_Register(Squirrel *engine)
{ {
DefSQClass <AIVehicleList_DefaultGroup> SQAIVehicleList_DefaultGroup("AIVehicleList_DefaultGroup"); DefSQClass <AIVehicleList_DefaultGroup> SQAIVehicleList_DefaultGroup("AIVehicleList_DefaultGroup");
SQAIVehicleList_DefaultGroup.PreRegister(engine, "AIAbstractList"); SQAIVehicleList_DefaultGroup.PreRegister(engine, "AIList");
SQAIVehicleList_DefaultGroup.AddConstructor<void (AIVehicleList_DefaultGroup::*)(AIVehicle::VehicleType vehicle_type), 2>(engine, "xi"); SQAIVehicleList_DefaultGroup.AddConstructor<void (AIVehicleList_DefaultGroup::*)(AIVehicle::VehicleType vehicle_type), 2>(engine, "xi");
SQAIVehicleList_DefaultGroup.PostRegister(engine); SQAIVehicleList_DefaultGroup.PostRegister(engine);

View File

@ -12,14 +12,14 @@
#ifndef AI_WAYPOINTLIST_HPP #ifndef AI_WAYPOINTLIST_HPP
#define AI_WAYPOINTLIST_HPP #define AI_WAYPOINTLIST_HPP
#include "ai_abstractlist.hpp" #include "ai_list.hpp"
#include "ai_waypoint.hpp" #include "ai_waypoint.hpp"
/** /**
* Creates a list of waypoints of which you are the owner. * Creates a list of waypoints of which you are the owner.
* @ingroup AIList * @ingroup AIList
*/ */
class AIWaypointList : public AIAbstractList { class AIWaypointList : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIWaypointList"; } static const char *GetClassName() { return "AIWaypointList"; }
@ -34,7 +34,7 @@ public:
* Creates a list of waypoints which the vehicle has in its orders. * Creates a list of waypoints which the vehicle has in its orders.
* @ingroup AIList * @ingroup AIList
*/ */
class AIWaypointList_Vehicle : public AIAbstractList { class AIWaypointList_Vehicle : public AIList {
public: public:
/** Get the name of this class to identify it towards squirrel. */ /** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIWaypointList_Vehicle"; } static const char *GetClassName() { return "AIWaypointList_Vehicle"; }

View File

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIWaypointList_Register(Squirrel *engine) void SQAIWaypointList_Register(Squirrel *engine)
{ {
DefSQClass <AIWaypointList> SQAIWaypointList("AIWaypointList"); DefSQClass <AIWaypointList> SQAIWaypointList("AIWaypointList");
SQAIWaypointList.PreRegister(engine, "AIAbstractList"); SQAIWaypointList.PreRegister(engine, "AIList");
SQAIWaypointList.AddConstructor<void (AIWaypointList::*)(AIWaypoint::WaypointType waypoint_type), 2>(engine, "xi"); SQAIWaypointList.AddConstructor<void (AIWaypointList::*)(AIWaypoint::WaypointType waypoint_type), 2>(engine, "xi");
SQAIWaypointList.PostRegister(engine); SQAIWaypointList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAIWaypointList_Vehicle_Register(Squirrel *engine) void SQAIWaypointList_Vehicle_Register(Squirrel *engine)
{ {
DefSQClass <AIWaypointList_Vehicle> SQAIWaypointList_Vehicle("AIWaypointList_Vehicle"); DefSQClass <AIWaypointList_Vehicle> SQAIWaypointList_Vehicle("AIWaypointList_Vehicle");
SQAIWaypointList_Vehicle.PreRegister(engine, "AIAbstractList"); SQAIWaypointList_Vehicle.PreRegister(engine, "AIList");
SQAIWaypointList_Vehicle.AddConstructor<void (AIWaypointList_Vehicle::*)(VehicleID vehicle_id), 2>(engine, "xi"); SQAIWaypointList_Vehicle.AddConstructor<void (AIWaypointList_Vehicle::*)(VehicleID vehicle_id), 2>(engine, "xi");
SQAIWaypointList_Vehicle.PostRegister(engine); SQAIWaypointList_Vehicle.PostRegister(engine);

View File

@ -89,7 +89,9 @@ echo "
print \$0 print \$0
gsub(\"^.*/\", \"\") gsub(\"^.*/\", \"\")
print \" squirrel_register_std(this->engine);\" \$0 print \" squirrel_register_std(this->engine);\" \$0
split(\"`grep '^void SQAI.*_Register(Squirrel \*engine)$' *.hpp.sq | sed 's/^.*void //;s/Squirrel \*/this->/;s/$/;/;s/_Register/0000Register/g;' | sort | sed 's/0000Register/_Register/g' | tr -d '\r' | tr '\n' ' '`\", regs, \" \") # AIList needs to be registered with squirrel before all AIList subclasses.
print \" SQAIList_Register(this->engine);\" \$0
split(\"`grep '^void SQAI.*_Register(Squirrel \*engine)$' *.hpp.sq | grep -v 'SQAIList_Register' | sed 's/^.*void //;s/Squirrel \*/this->/;s/$/;/;s/_Register/0000Register/g;' | sort | sed 's/0000Register/_Register/g' | tr -d '\r' | tr '\n' ' '`\", regs, \" \")
for (i = 1; regs[i] != \"\"; i++) { for (i = 1; regs[i] != \"\"; i++) {
if (regs[i] == \"SQAIController_Register(this->engine);\") continue if (regs[i] == \"SQAIController_Register(this->engine);\") continue