Add: New RoadType API functions.
parent
c02ef3e456
commit
3293f08e0b
@ -0,0 +1,25 @@
|
||||
/* $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 "../script_roadtypelist.hpp"
|
||||
#include "../template/template_roadtypelist.hpp.sq"
|
||||
|
||||
|
||||
template <> const char *GetClassName<ScriptRoadTypeList, ST_AI>() { return "AIRoadTypeList"; }
|
||||
|
||||
void SQAIRoadTypeList_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptRoadTypeList, ST_AI> SQAIRoadTypeList("AIRoadTypeList");
|
||||
SQAIRoadTypeList.PreRegister(engine, "AIList");
|
||||
SQAIRoadTypeList.AddConstructor<void (ScriptRoadTypeList::*)(ScriptRoad::RoadTramTypes rtts), 2>(engine, "xi");
|
||||
|
||||
SQAIRoadTypeList.PostRegister(engine);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/* $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 "../script_roadtypelist.hpp"
|
||||
#include "../template/template_roadtypelist.hpp.sq"
|
||||
|
||||
|
||||
template <> const char *GetClassName<ScriptRoadTypeList, ST_GS>() { return "GSRoadTypeList"; }
|
||||
|
||||
void SQGSRoadTypeList_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptRoadTypeList, ST_GS> SQGSRoadTypeList("GSRoadTypeList");
|
||||
SQGSRoadTypeList.PreRegister(engine, "GSList");
|
||||
SQGSRoadTypeList.AddConstructor<void (ScriptRoadTypeList::*)(ScriptRoad::RoadTramTypes rtts), 2>(engine, "xi");
|
||||
|
||||
SQGSRoadTypeList.PostRegister(engine);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/* $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/>.
|
||||
*/
|
||||
|
||||
/** @file script_roadtypelist.cpp Implementation of ScriptRoadTypeList and friends. */
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "script_roadtypelist.hpp"
|
||||
#include "../../road_func.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptRoadTypeList::ScriptRoadTypeList(ScriptRoad::RoadTramTypes rtts)
|
||||
{
|
||||
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
|
||||
if (!HasBit(rtts, GetRoadTramType(rt))) continue;
|
||||
if (ScriptObject::GetCompany() == OWNER_DEITY || ::HasRoadTypeAvail(ScriptObject::GetCompany(), rt)) this->AddItem(rt);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/* $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/>.
|
||||
*/
|
||||
|
||||
/** @file script_roadtypelist.hpp List all available roadtypes. */
|
||||
|
||||
#ifndef SCRIPT_ROADTYPELIST_HPP
|
||||
#define SCRIPT_ROADTYPELIST_HPP
|
||||
|
||||
#include "script_list.hpp"
|
||||
#include "script_road.hpp"
|
||||
|
||||
/**
|
||||
* Creates a list of all available roadtypes.
|
||||
* @api ai game
|
||||
* @ingroup ScriptList
|
||||
*/
|
||||
class ScriptRoadTypeList : public ScriptList {
|
||||
public:
|
||||
/**
|
||||
* @param rtts Bitmask of road/tram types to list.
|
||||
*/
|
||||
ScriptRoadTypeList(ScriptRoad::RoadTramTypes rtts);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_ROADTYPELIST_HPP */
|
@ -0,0 +1,21 @@
|
||||
/* $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 "../script_roadtypelist.hpp"
|
||||
|
||||
namespace SQConvert {
|
||||
/* Allow ScriptRoadTypeList to be used as Squirrel parameter */
|
||||
template <> inline ScriptRoadTypeList *GetParam(ForceType<ScriptRoadTypeList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptRoadTypeList *)instance; }
|
||||
template <> inline ScriptRoadTypeList &GetParam(ForceType<ScriptRoadTypeList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptRoadTypeList *)instance; }
|
||||
template <> inline const ScriptRoadTypeList *GetParam(ForceType<const ScriptRoadTypeList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptRoadTypeList *)instance; }
|
||||
template <> inline const ScriptRoadTypeList &GetParam(ForceType<const ScriptRoadTypeList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptRoadTypeList *)instance; }
|
||||
template <> inline int Return<ScriptRoadTypeList *>(HSQUIRRELVM vm, ScriptRoadTypeList *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "RoadTypeList", res, nullptr, DefSQDestructorCallback<ScriptRoadTypeList>, true); return 1; }
|
||||
} // namespace SQConvert
|
Loading…
Reference in New Issue