mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r16400) -Add [NoAI]: add AISignList that can be used to get a list of valid signs. This makes AISign::GetMaxSignID obsolete.
This commit is contained in:
parent
8e30f0e75a
commit
0b243d25cb
@ -1077,9 +1077,10 @@ function Regression::Sign()
|
|||||||
print(" BuildSign(33409, 'Some other Sign'): " + sign_id);
|
print(" BuildSign(33409, 'Some other Sign'): " + sign_id);
|
||||||
print(" RemoveSign(" + sign_id + "): " + AISign.RemoveSign(sign_id));
|
print(" RemoveSign(" + sign_id + "): " + AISign.RemoveSign(sign_id));
|
||||||
print("");
|
print("");
|
||||||
print(" GetMaxSignID(): " + AISign.GetMaxSignID());
|
local list = AISignList();
|
||||||
for (local i = -1; i < AISign.GetMaxSignID() + 1; i++) {
|
list.Sort(AIAbstractList.SORT_BY_ITEM, true);
|
||||||
if (AISign.IsValidSign(i)) j++;
|
for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
|
||||||
|
j++;
|
||||||
print(" Sign " + i);
|
print(" Sign " + i);
|
||||||
print(" IsValidSign(): " + AISign.IsValidSign(i));
|
print(" IsValidSign(): " + AISign.IsValidSign(i));
|
||||||
print(" GetName(): " + AISign.GetName(i));
|
print(" GetName(): " + AISign.GetName(i));
|
||||||
|
@ -7242,11 +7242,6 @@
|
|||||||
BuildSign(33409, 'Some other Sign'): 2
|
BuildSign(33409, 'Some other Sign'): 2
|
||||||
RemoveSign(2): true
|
RemoveSign(2): true
|
||||||
|
|
||||||
GetMaxSignID(): 3
|
|
||||||
Sign -1
|
|
||||||
IsValidSign(): false
|
|
||||||
GetName(): (null : 0x00000000)
|
|
||||||
GetLocation(): -1
|
|
||||||
Sign 0
|
Sign 0
|
||||||
IsValidSign(): true
|
IsValidSign(): true
|
||||||
GetName(): Some Sign
|
GetName(): Some Sign
|
||||||
@ -7255,14 +7250,6 @@
|
|||||||
IsValidSign(): true
|
IsValidSign(): true
|
||||||
GetName(): Test2
|
GetName(): Test2
|
||||||
GetLocation(): 33411
|
GetLocation(): 33411
|
||||||
Sign 2
|
|
||||||
IsValidSign(): false
|
|
||||||
GetName(): (null : 0x00000000)
|
|
||||||
GetLocation(): -1
|
|
||||||
Sign 3
|
|
||||||
IsValidSign(): false
|
|
||||||
GetName(): (null : 0x00000000)
|
|
||||||
GetLocation(): -1
|
|
||||||
Valid Signs: 2
|
Valid Signs: 2
|
||||||
|
|
||||||
--Station--
|
--Station--
|
||||||
|
@ -2691,6 +2691,10 @@
|
|||||||
RelativePath=".\..\src\ai\api\ai_sign.hpp"
|
RelativePath=".\..\src\ai\api\ai_sign.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\ai\api\ai_signlist.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\ai\api\ai_station.hpp"
|
RelativePath=".\..\src\ai\api\ai_station.hpp"
|
||||||
>
|
>
|
||||||
@ -2895,6 +2899,10 @@
|
|||||||
RelativePath=".\..\src\ai\api\ai_sign.cpp"
|
RelativePath=".\..\src\ai\api\ai_sign.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\ai\api\ai_signlist.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\ai\api\ai_station.cpp"
|
RelativePath=".\..\src\ai\api\ai_station.cpp"
|
||||||
>
|
>
|
||||||
|
@ -2688,6 +2688,10 @@
|
|||||||
RelativePath=".\..\src\ai\api\ai_sign.hpp"
|
RelativePath=".\..\src\ai\api\ai_sign.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\ai\api\ai_signlist.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\ai\api\ai_station.hpp"
|
RelativePath=".\..\src\ai\api\ai_station.hpp"
|
||||||
>
|
>
|
||||||
@ -2892,6 +2896,10 @@
|
|||||||
RelativePath=".\..\src\ai\api\ai_sign.cpp"
|
RelativePath=".\..\src\ai\api\ai_sign.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\ai\api\ai_signlist.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\ai\api\ai_station.cpp"
|
RelativePath=".\..\src\ai\api\ai_station.cpp"
|
||||||
>
|
>
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#include "api/ai_railtypelist.hpp.sq"
|
#include "api/ai_railtypelist.hpp.sq"
|
||||||
#include "api/ai_road.hpp.sq"
|
#include "api/ai_road.hpp.sq"
|
||||||
#include "api/ai_sign.hpp.sq"
|
#include "api/ai_sign.hpp.sq"
|
||||||
|
#include "api/ai_signlist.hpp.sq"
|
||||||
#include "api/ai_station.hpp.sq"
|
#include "api/ai_station.hpp.sq"
|
||||||
#include "api/ai_stationlist.hpp.sq"
|
#include "api/ai_stationlist.hpp.sq"
|
||||||
#include "api/ai_subsidy.hpp.sq"
|
#include "api/ai_subsidy.hpp.sq"
|
||||||
@ -212,6 +213,7 @@ void AIInstance::RegisterAPI()
|
|||||||
SQAIRailTypeList_Register(this->engine);
|
SQAIRailTypeList_Register(this->engine);
|
||||||
SQAIRoad_Register(this->engine);
|
SQAIRoad_Register(this->engine);
|
||||||
SQAISign_Register(this->engine);
|
SQAISign_Register(this->engine);
|
||||||
|
SQAISignList_Register(this->engine);
|
||||||
SQAIStation_Register(this->engine);
|
SQAIStation_Register(this->engine);
|
||||||
SQAIStationList_Register(this->engine);
|
SQAIStationList_Register(this->engine);
|
||||||
SQAIStationList_Vehicle_Register(this->engine);
|
SQAIStationList_Vehicle_Register(this->engine);
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the maximum sign index; there are no valid signs with a higher index.
|
* Gets the maximum sign index; there are no valid signs with a higher index.
|
||||||
|
* @deprecated This function is deprecated and might be removed in future versions of the API. Use AISignList() instead.
|
||||||
* @return The maximum sign index.
|
* @return The maximum sign index.
|
||||||
* @post Return value is always non-negative.
|
* @post Return value is always non-negative.
|
||||||
*/
|
*/
|
||||||
|
15
src/ai/api/ai_signlist.cpp
Normal file
15
src/ai/api/ai_signlist.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file ai_signlist.cpp Implementation of AISignList and friends. */
|
||||||
|
|
||||||
|
#include "ai_signlist.hpp"
|
||||||
|
#include "ai_sign.hpp"
|
||||||
|
#include "../../signs_base.h"
|
||||||
|
|
||||||
|
AISignList::AISignList()
|
||||||
|
{
|
||||||
|
Sign *s;
|
||||||
|
FOR_ALL_SIGNS(s) {
|
||||||
|
if (AISign::IsValidSign(s->index)) this->AddItem(s->index);
|
||||||
|
}
|
||||||
|
}
|
20
src/ai/api/ai_signlist.hpp
Normal file
20
src/ai/api/ai_signlist.hpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file ai_signlist.hpp List all the signs of your company. */
|
||||||
|
|
||||||
|
#ifndef AI_SIGNLIST_HPP
|
||||||
|
#define AI_SIGNLIST_HPP
|
||||||
|
|
||||||
|
#include "ai_abstractlist.hpp"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a list of signs your company has created.
|
||||||
|
* @ingroup AIList
|
||||||
|
*/
|
||||||
|
class AISignList : public AIAbstractList {
|
||||||
|
public:
|
||||||
|
static const char *GetClassName() { return "AISignList"; }
|
||||||
|
AISignList();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* AI_SIGNLIST_HPP */
|
21
src/ai/api/ai_signlist.hpp.sq
Normal file
21
src/ai/api/ai_signlist.hpp.sq
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
|
||||||
|
|
||||||
|
#include "ai_signlist.hpp"
|
||||||
|
|
||||||
|
namespace SQConvert {
|
||||||
|
/* Allow AISignList to be used as Squirrel parameter */
|
||||||
|
template <> AISignList *GetParam(ForceType<AISignList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AISignList *)instance; }
|
||||||
|
template <> AISignList &GetParam(ForceType<AISignList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AISignList *)instance; }
|
||||||
|
template <> const AISignList *GetParam(ForceType<const AISignList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AISignList *)instance; }
|
||||||
|
template <> const AISignList &GetParam(ForceType<const AISignList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AISignList *)instance; }
|
||||||
|
template <> int Return<AISignList *>(HSQUIRRELVM vm, AISignList *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AISignList", res, NULL, DefSQDestructorCallback<AISignList>); return 1; }
|
||||||
|
}; // namespace SQConvert
|
||||||
|
|
||||||
|
void SQAISignList_Register(Squirrel *engine) {
|
||||||
|
DefSQClass <AISignList> SQAISignList("AISignList");
|
||||||
|
SQAISignList.PreRegister(engine, "AIAbstractList");
|
||||||
|
SQAISignList.AddConstructor<void (AISignList::*)(), 1>(engine, "x");
|
||||||
|
|
||||||
|
SQAISignList.PostRegister(engine);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user