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

pull/155/head
yexo 14 years ago
parent 0d57e6c193
commit f30cc9e6ca

@ -275,7 +275,6 @@ AIRoad.BuildDriveThroughRoadStation <- function(tile, front, road_veh_type, stat
return AIRoad._BuildDriveThroughRoadStation(tile, front, road_veh_type, station_id);
}
AIAbstractList.HasNext <-
AIBridgeList.HasNext <-
AIBridgeList_Length.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;
}
AIAbstractList <- AIList;

@ -25,7 +25,6 @@ AIRoad.BuildDriveThroughRoadStation <- function(tile, front, road_veh_type, stat
return AIRoad._BuildDriveThroughRoadStation(tile, front, road_veh_type, station_id);
}
AIAbstractList.HasNext <-
AIBridgeList.HasNext <-
AIBridgeList_Length.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;
}
AIAbstractList <- AIList;

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

@ -845,7 +845,6 @@
<ClCompile Include="..\src\ai\ai_scanner.cpp" />
<ClInclude Include="..\src\ai\ai_scanner.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_airport.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_industrytypelist.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_map.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_waypoint.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_airport.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_industrytype.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_map.cpp" />
<ClCompile Include="..\src\ai\api\ai_marine.cpp" />

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

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

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

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

@ -26,7 +26,6 @@
/* Convert all AI related classes to Squirrel data.
* 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_airport.hpp.sq"
#include "api/ai_base.hpp.sq"
@ -52,6 +51,7 @@
#include "api/ai_industrylist.hpp.sq"
#include "api/ai_industrytype.hpp.sq"
#include "api/ai_industrytypelist.hpp.sq"
#include "api/ai_list.hpp.sq"
#include "api/ai_log.hpp.sq"
#include "api/ai_map.hpp.sq"
#include "api/ai_marine.hpp.sq"
@ -171,7 +171,7 @@ void AIInstance::RegisterAPI()
{
/* Register all classes */
squirrel_register_std(this->engine);
SQAIAbstractList_Register(this->engine);
SQAIList_Register(this->engine);
SQAIAccounting_Register(this->engine);
SQAIAirport_Register(this->engine);
SQAIBase_Register(this->engine);

@ -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);
}

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

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIBridgeList_Register(Squirrel *engine)
{
DefSQClass <AIBridgeList> SQAIBridgeList("AIBridgeList");
SQAIBridgeList.PreRegister(engine, "AIAbstractList");
SQAIBridgeList.PreRegister(engine, "AIList");
SQAIBridgeList.AddConstructor<void (AIBridgeList::*)(), 1>(engine, "x");
SQAIBridgeList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAIBridgeList_Length_Register(Squirrel *engine)
{
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.PostRegister(engine);

@ -12,13 +12,13 @@
#ifndef 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.
* @ingroup AIList
*/
class AICargoList : public AIAbstractList {
class AICargoList : public AIList {
public:
/** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AICargoList"; }
@ -31,7 +31,7 @@ public:
* by this industry, @see AIIndustry::IsCargoAccepted.
* @ingroup AIList
*/
class AICargoList_IndustryAccepting : public AIAbstractList {
class AICargoList_IndustryAccepting : public AIList {
public:
/** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AICargoList_IndustryAccepting"; }
@ -46,7 +46,7 @@ public:
* Creates a list of cargos that the given industry can produce.
* @ingroup AIList
*/
class AICargoList_IndustryProducing : public AIAbstractList {
class AICargoList_IndustryProducing : public AIList {
public:
/** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AICargoList_IndustryProducing"; }

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAICargoList_Register(Squirrel *engine)
{
DefSQClass <AICargoList> SQAICargoList("AICargoList");
SQAICargoList.PreRegister(engine, "AIAbstractList");
SQAICargoList.PreRegister(engine, "AIList");
SQAICargoList.AddConstructor<void (AICargoList::*)(), 1>(engine, "x");
SQAICargoList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAICargoList_IndustryAccepting_Register(Squirrel *engine)
{
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.PostRegister(engine);
@ -59,7 +59,7 @@ namespace SQConvert {
void SQAICargoList_IndustryProducing_Register(Squirrel *engine)
{
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.PostRegister(engine);

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

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

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

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

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

@ -12,14 +12,14 @@
#ifndef 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.
* @note Neither AIGroup::GROUP_ALL nor AIGroup::GROUP_DEFAULT is in this list.
* @ingroup AIList
*/
class AIGroupList : public AIAbstractList {
class AIGroupList : public AIList {
public:
/** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIGroupList"; }

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

@ -12,13 +12,13 @@
#ifndef 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.
* @ingroup AIList
*/
class AIIndustryList : public AIAbstractList {
class AIIndustryList : public AIList {
public:
/** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIIndustryList"; }
@ -29,7 +29,7 @@ public:
* Creates a list of industries that accepts a given cargo.
* @ingroup AIList
*/
class AIIndustryList_CargoAccepting : public AIAbstractList {
class AIIndustryList_CargoAccepting : public AIList {
public:
/** Get the name of this class to identify it towards squirrel. */
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.
* @ingroup AIList
*/
class AIIndustryList_CargoProducing : public AIAbstractList {
class AIIndustryList_CargoProducing : public AIList {
public:
/** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AIIndustryList_CargoProducing"; }

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIIndustryList_Register(Squirrel *engine)
{
DefSQClass <AIIndustryList> SQAIIndustryList("AIIndustryList");
SQAIIndustryList.PreRegister(engine, "AIAbstractList");
SQAIIndustryList.PreRegister(engine, "AIList");
SQAIIndustryList.AddConstructor<void (AIIndustryList::*)(), 1>(engine, "x");
SQAIIndustryList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAIIndustryList_CargoAccepting_Register(Squirrel *engine)
{
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.PostRegister(engine);
@ -59,7 +59,7 @@ namespace SQConvert {
void SQAIIndustryList_CargoProducing_Register(Squirrel *engine)
{
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.PostRegister(engine);

@ -58,13 +58,13 @@
return industrytype_name;
}
/* static */ AIAbstractList *AIIndustryType::GetProducedCargo(IndustryType industry_type)
/* static */ AIList *AIIndustryType::GetProducedCargo(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return NULL;
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++) {
if (ins->produced_cargo[i] != CT_INVALID) list->AddItem(ins->produced_cargo[i]);
}
@ -72,13 +72,13 @@
return list;
}
/* static */ AIAbstractList *AIIndustryType::GetAcceptedCargo(IndustryType industry_type)
/* static */ AIList *AIIndustryType::GetAcceptedCargo(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return NULL;
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++) {
if (ins->accepts_cargo[i] != CT_INVALID) list->AddItem(ins->accepts_cargo[i]);
}

@ -14,7 +14,7 @@
#include "ai_object.hpp"
#include "ai_error.hpp"
#include "ai_abstractlist.hpp"
#include "ai_list.hpp"
/**
* Class that handles all industry-type related functions.
@ -55,7 +55,7 @@ public:
* @pre IsValidIndustryType(industry_type).
* @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.
@ -65,7 +65,7 @@ public:
* @pre IsValidIndustryType(industry_type).
* @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?

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

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

@ -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/>.
*/
/** @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 "../../script/squirrel.hpp"
/**
* Base class for any AIAbstractList sorter.
* Base class for any AIList sorter.
*/
class AIAbstractListSorter {
class AIListSorter {
protected:
AIAbstractList *list;
AIList *list;
public:
/**
* Virtual dtor, needed to mute warnings.
*/
virtual ~AIAbstractListSorter() { }
virtual ~AIListSorter() { }
/**
* Get the first item of the sorter.
@ -55,16 +55,16 @@ public:
/**
* Sort by value, ascending.
*/
class AIAbstractListSorterValueAscending : public AIAbstractListSorter {
class AIListSorterValueAscending : public AIListSorter {
private:
AIAbstractList::AIAbstractListBucket::iterator bucket_iter;
AIAbstractList::AIItemList *bucket_list;
AIAbstractList::AIItemList::iterator bucket_list_iter;
AIList::AIListBucket::iterator bucket_iter;
AIList::AIItemList *bucket_list;
AIList::AIItemList::iterator bucket_list_iter;
bool has_no_more_items;
int32 item_next;
public:
AIAbstractListSorterValueAscending(AIAbstractList *list)
AIListSorterValueAscending(AIList *list)
{
this->list = list;
this->End();
@ -141,16 +141,16 @@ public:
/**
* Sort by value, descending.
*/
class AIAbstractListSorterValueDescending : public AIAbstractListSorter {
class AIListSorterValueDescending : public AIListSorter {
private:
AIAbstractList::AIAbstractListBucket::iterator bucket_iter;
AIAbstractList::AIItemList *bucket_list;
AIAbstractList::AIItemList::iterator bucket_list_iter;
AIList::AIListBucket::iterator bucket_iter;
AIList::AIItemList *bucket_list;
AIList::AIItemList::iterator bucket_list_iter;
bool has_no_more_items;
int32 item_next;
public:
AIAbstractListSorterValueDescending(AIAbstractList *list)
AIListSorterValueDescending(AIList *list)
{
this->list = list;
this->End();
@ -235,14 +235,14 @@ public:
/**
* Sort by item, ascending.
*/
class AIAbstractListSorterItemAscending : public AIAbstractListSorter {
class AIListSorterItemAscending : public AIListSorter {
private:
AIAbstractList::AIAbstractListMap::iterator item_iter;
AIList::AIListMap::iterator item_iter;
bool has_no_more_items;
int32 item_next;
public:
AIAbstractListSorterItemAscending(AIAbstractList *list)
AIListSorterItemAscending(AIList *list)
{
this->list = list;
this->End();
@ -305,14 +305,14 @@ public:
/**
* Sort by item, descending.
*/
class AIAbstractListSorterItemDescending : public AIAbstractListSorter {
class AIListSorterItemDescending : public AIListSorter {
private:
AIAbstractList::AIAbstractListMap::iterator item_iter;
AIList::AIListMap::iterator item_iter;
bool has_no_more_items;
int32 item_next;
public:
AIAbstractListSorterItemDescending(AIAbstractList *list)
AIListSorterItemDescending(AIList *list)
{
this->list = list;
this->End();
@ -375,27 +375,27 @@ public:
AIAbstractList::AIAbstractList()
AIList::AIList()
{
/* Default sorter */
this->sorter = new AIAbstractListSorterValueDescending(this);
this->sorter = new AIListSorterValueDescending(this);
this->sorter_type = SORT_BY_VALUE;
this->sort_ascending = false;
this->initialized = false;
this->modifications = 0;
}
AIAbstractList::~AIAbstractList()
AIList::~AIList()
{
delete this->sorter;
}
bool AIAbstractList::HasItem(int32 item)
bool AIList::HasItem(int32 item)
{
return this->items.count(item) == 1;
}
void AIAbstractList::Clear()
void AIList::Clear()
{
this->modifications++;
@ -404,7 +404,7 @@ void AIAbstractList::Clear()
this->sorter->End();
}
void AIAbstractList::AddItem(int32 item, int32 value)
void AIList::AddItem(int32 item, int32 value)
{
this->modifications++;
@ -416,7 +416,7 @@ void AIAbstractList::AddItem(int32 item, int32 value)
this->SetValue(item, value);
}
void AIAbstractList::RemoveItem(int32 item)
void AIList::RemoveItem(int32 item)
{
this->modifications++;
@ -430,13 +430,13 @@ void AIAbstractList::RemoveItem(int32 item)
this->items.erase(item);
}
int32 AIAbstractList::Begin()
int32 AIList::Begin()
{
this->initialized = true;
return this->sorter->Begin();
}
int32 AIAbstractList::Next()
int32 AIList::Next()
{
if (this->initialized == false) {
DEBUG(ai, 0, "Next() is invalid as Begin() is never called");
@ -445,12 +445,12 @@ int32 AIAbstractList::Next()
return this->sorter->Next();
}
bool AIAbstractList::IsEmpty()
bool AIList::IsEmpty()
{
return this->items.empty();
}
bool AIAbstractList::IsEnd()
bool AIList::IsEnd()
{
if (this->initialized == false) {
DEBUG(ai, 0, "IsEnd() is invalid as Begin() is never called");
@ -459,19 +459,19 @@ bool AIAbstractList::IsEnd()
return this->sorter->IsEnd();
}
int32 AIAbstractList::Count()
int32 AIList::Count()
{
return (int32)this->items.size();
}
int32 AIAbstractList::GetValue(int32 item)
int32 AIList::GetValue(int32 item)
{
if (!this->HasItem(item)) return 0;
return this->items[item];
}
bool AIAbstractList::SetValue(int32 item, int32 value)
bool AIList::SetValue(int32 item, int32 value)
{
this->modifications++;
@ -489,7 +489,7 @@ bool AIAbstractList::SetValue(int32 item, int32 value)
return true;
}
void AIAbstractList::Sort(SorterType sorter, bool ascending)
void AIList::Sort(SorterType sorter, bool ascending)
{
this->modifications++;
@ -500,17 +500,17 @@ void AIAbstractList::Sort(SorterType sorter, bool ascending)
switch (sorter) {
case SORT_BY_ITEM:
if (ascending) {
this->sorter = new AIAbstractListSorterItemAscending(this);
this->sorter = new AIListSorterItemAscending(this);
} else {
this->sorter = new AIAbstractListSorterItemDescending(this);
this->sorter = new AIListSorterItemDescending(this);
}
break;
case SORT_BY_VALUE:
if (ascending) {
this->sorter = new AIAbstractListSorterValueAscending(this);
this->sorter = new AIListSorterValueAscending(this);
} else {
this->sorter = new AIAbstractListSorterValueDescending(this);
this->sorter = new AIListSorterValueDescending(this);
}
break;
@ -523,56 +523,56 @@ void AIAbstractList::Sort(SorterType sorter, bool ascending)
this->initialized = false;
}
void AIAbstractList::AddList(AIAbstractList *list)
void AIList::AddList(AIList *list)
{
AIAbstractListMap *list_items = &list->items;
for (AIAbstractListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) {
AIListMap *list_items = &list->items;
for (AIListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) {
this->AddItem((*iter).first);
this->SetValue((*iter).first, (*iter).second);
}
}
void AIAbstractList::RemoveAboveValue(int32 value)
void AIList::RemoveAboveValue(int32 value)
{
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++;
if ((*iter).second > value) this->RemoveItem((*iter).first);
}
}
void AIAbstractList::RemoveBelowValue(int32 value)
void AIList::RemoveBelowValue(int32 value)
{
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++;
if ((*iter).second < value) this->RemoveItem((*iter).first);
}
}
void AIAbstractList::RemoveBetweenValue(int32 start, int32 end)
void AIList::RemoveBetweenValue(int32 start, int32 end)
{
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++;
if ((*iter).second > start && (*iter).second < end) this->RemoveItem((*iter).first);
}
}
void AIAbstractList::RemoveValue(int32 value)
void AIList::RemoveValue(int32 value)
{
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++;
if ((*iter).second == value) this->RemoveItem((*iter).first);
}
}
void AIAbstractList::RemoveTop(int32 count)
void AIList::RemoveTop(int32 count)
{
this->modifications++;
@ -586,7 +586,7 @@ void AIAbstractList::RemoveTop(int32 count)
switch (this->sorter_type) {
default: NOT_REACHED();
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;
size_t size = items->size();
for (AIItemList::iterator iter = items->begin(); iter != items->end(); iter = items->begin()) {
@ -601,7 +601,7 @@ void AIAbstractList::RemoveTop(int32 count)
break;
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;
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++;
@ -623,7 +623,7 @@ void AIAbstractList::RemoveBottom(int32 count)
switch (this->sorter_type) {
default: NOT_REACHED();
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;
size_t size = items->size();
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:
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;
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++;
AIAbstractListMap *list_items = &list->items;
for (AIAbstractListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) {
AIListMap *list_items = &list->items;
for (AIListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) {
this->RemoveItem((*iter).first);
}
}
void AIAbstractList::KeepAboveValue(int32 value)
void AIList::KeepAboveValue(int32 value)
{
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++;
if ((*iter).second <= value) this->RemoveItem((*iter).first);
}
}
void AIAbstractList::KeepBelowValue(int32 value)
void AIList::KeepBelowValue(int32 value)
{
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++;
if ((*iter).second >= value) this->RemoveItem((*iter).first);
}
}
void AIAbstractList::KeepBetweenValue(int32 start, int32 end)
void AIList::KeepBetweenValue(int32 start, int32 end)
{
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++;
if ((*iter).second <= start || (*iter).second >= end) this->RemoveItem((*iter).first);
}
}
void AIAbstractList::KeepValue(int32 value)
void AIList::KeepValue(int32 value)
{
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++;
if ((*iter).second != value) this->RemoveItem((*iter).first);
}
}
void AIAbstractList::KeepTop(int32 count)
void AIList::KeepTop(int32 count)
{
this->modifications++;
this->RemoveBottom(this->Count() - count);
}
void AIAbstractList::KeepBottom(int32 count)
void AIList::KeepBottom(int32 count)
{
this->modifications++;
this->RemoveTop(this->Count() - count);
}
void AIAbstractList::KeepList(AIAbstractList *list)
void AIList::KeepList(AIList *list)
{
this->modifications++;
AIAbstractList tmp;
for (AIAbstractListMap::iterator iter = this->items.begin(); iter != this->items.end(); iter++) {
AIList tmp;
for (AIListMap::iterator iter = this->items.begin(); iter != this->items.end(); iter++) {
tmp.AddItem((*iter).first);
tmp.SetValue((*iter).first, (*iter).second);
}
@ -723,7 +723,7 @@ void AIAbstractList::KeepList(AIAbstractList *list)
this->RemoveList(&tmp);
}
SQInteger AIAbstractList::_get(HSQUIRRELVM vm)
SQInteger AIList::_get(HSQUIRRELVM vm)
{
if (sq_gettype(vm, 2) != OT_INTEGER) return SQ_ERROR;
@ -736,7 +736,7 @@ SQInteger AIAbstractList::_get(HSQUIRRELVM vm)
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, 3) != OT_INTEGER || sq_gettype(vm, 3) == OT_NULL) {
@ -760,7 +760,7 @@ SQInteger AIAbstractList::_set(HSQUIRRELVM vm)
return 0;
}
SQInteger AIAbstractList::_nexti(HSQUIRRELVM vm)
SQInteger AIList::_nexti(HSQUIRRELVM vm)
{
if (sq_gettype(vm, 2) == OT_NULL) {
if (this->IsEmpty()) {
@ -784,15 +784,15 @@ SQInteger AIAbstractList::_nexti(HSQUIRRELVM vm)
return 1;
}
SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm)
SQInteger AIList::Valuate(HSQUIRRELVM vm)
{
this->modifications++;
/* The first parameter is the instance of AIAbstractList. */
/* The first parameter is the instance of AIList. */
int nparam = sq_gettop(vm) - 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
@ -811,7 +811,7 @@ SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm)
/* Push the function to call */
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. */
int previous_modification_count = this->modifications;
@ -873,7 +873,7 @@ SQInteger AIAbstractList::Valuate(HSQUIRRELVM vm)
* 1. The root stable (as instance object).
* 2. The valuator function.
* 3. The parameters given to this function.
* 4. The AIAbstractList instance object. */
* 4. The AIList instance object. */
sq_pop(vm, nparam + 3);
AIObject::SetAllowDoCommand(backup_allow);

@ -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/>.
*/
/** @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. */
#ifndef AI_ABSTRACTLIST_HPP
#define AI_ABSTRACTLIST_HPP
#ifndef AI_LIST_HPP
#define AI_LIST_HPP
#include "ai_object.hpp"
#include <map>
#include <set>
class AIAbstractListSorter;
class AIListSorter;
/**
* Class that creates a list which can keep item/value pairs, which you can walk.
*/
class AIAbstractList : public AIObject {
class AIList : public AIObject {
public:
/** 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 */
enum SorterType {
@ -39,22 +39,22 @@ public:
static const bool SORT_DESCENDING = false;
private:
AIAbstractListSorter *sorter; ///< Sorting algorithm
AIListSorter *sorter; ///< Sorting algorithm
SorterType sorter_type; ///< Sorting type
bool sort_ascending; ///< Whether to sort ascending or descending
bool initialized; ///< Whether an iteration has been started
int modifications; ///< Number of modification that has been done. To prevent changing data while valuating.
public:
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, int32> AIAbstractListMap; ///< List per item
typedef std::set<int32> AIItemList; ///< The list of items inside the bucket
typedef std::map<int32, AIItemList> AIListBucket; ///< The bucket list per value
typedef std::map<int32, int32> AIListMap; ///< List per item
AIAbstractListMap items; ///< The items in the list
AIAbstractListBucket buckets; ///< The items in the list, sorted by value
AIListMap items; ///< The items in the list
AIListBucket buckets; ///< The items in the list, sorted by value
AIAbstractList();
~AIAbstractList();
AIList();
~AIList();
/**
* 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
* 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'.
@ -193,7 +193,7 @@ public:
* @param list the list of items to remove.
* @pre list != NULL
*/
void RemoveList(AIAbstractList *list);
void RemoveList(AIList *list);
/**
* Keep all items with a higher value than 'value'.
@ -237,7 +237,7 @@ public:
* @param list the list of items to keep.
* @pre list != NULL
*/
void KeepList(AIAbstractList *list);
void KeepList(AIList *list);
#ifndef DOXYGEN_SKIP
/**

@ -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);
}

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

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

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

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

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

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

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

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

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

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

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

@ -12,13 +12,13 @@
#ifndef 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.
* @ingroup AIList
*/
class AITownList : public AIAbstractList {
class AITownList : public AIList {
public:
/** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AITownList"; }

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

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

@ -23,7 +23,7 @@ namespace SQConvert {
void SQAIVehicleList_Register(Squirrel *engine)
{
DefSQClass <AIVehicleList> SQAIVehicleList("AIVehicleList");
SQAIVehicleList.PreRegister(engine, "AIAbstractList");
SQAIVehicleList.PreRegister(engine, "AIList");
SQAIVehicleList.AddConstructor<void (AIVehicleList::*)(), 1>(engine, "x");
SQAIVehicleList.PostRegister(engine);
@ -41,7 +41,7 @@ namespace SQConvert {
void SQAIVehicleList_Station_Register(Squirrel *engine)
{
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.PostRegister(engine);
@ -59,7 +59,7 @@ namespace SQConvert {
void SQAIVehicleList_Depot_Register(Squirrel *engine)
{
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.PostRegister(engine);
@ -77,7 +77,7 @@ namespace SQConvert {
void SQAIVehicleList_SharedOrders_Register(Squirrel *engine)
{
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.PostRegister(engine);
@ -95,7 +95,7 @@ namespace SQConvert {
void SQAIVehicleList_Group_Register(Squirrel *engine)
{
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.PostRegister(engine);
@ -113,7 +113,7 @@ namespace SQConvert {
void SQAIVehicleList_DefaultGroup_Register(Squirrel *engine)
{
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.PostRegister(engine);

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

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

@ -89,7 +89,9 @@ echo "
print \$0
gsub(\"^.*/\", \"\")
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++) {
if (regs[i] == \"SQAIController_Register(this->engine);\") continue

Loading…
Cancel
Save