Files
@ r28278:1fc682037ca2
Branch filter:
Location: cpp/openttd-patchpack/source/src/script/api/script_newgrf.cpp - annotation
r28278:1fc682037ca2
1.9 KiB
text/x-c
Codechange: Use Ticks for BaseConsist timetable fields
r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25876:7da167ac72e9 r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r26979:a9bdfd2db2b5 r25871:df053d6fe8cb r26979:a9bdfd2db2b5 r25876:7da167ac72e9 r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r26979:a9bdfd2db2b5 r25871:df053d6fe8cb r26979:a9bdfd2db2b5 r25876:7da167ac72e9 r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r27364:db69a5f5c496 r25871:df053d6fe8cb r26979:a9bdfd2db2b5 r25876:7da167ac72e9 r25871:df053d6fe8cb r25871:df053d6fe8cb r27364:db69a5f5c496 r25871:df053d6fe8cb r25871:df053d6fe8cb r25871:df053d6fe8cb r27364:db69a5f5c496 r25871:df053d6fe8cb | /*
* 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_newgrf.cpp Implementation of ScriptNewGRF and friends. */
#include "../../stdafx.h"
#include "script_newgrf.hpp"
#include "../../core/bitmath_func.hpp"
#include "../../newgrf_config.h"
#include "../../string_func.h"
#include "../../safeguards.h"
ScriptNewGRFList::ScriptNewGRFList()
{
for (auto c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) {
this->AddItem(BSWAP32(c->ident.grfid));
}
}
}
/* static */ bool ScriptNewGRF::IsLoaded(SQInteger grfid)
{
grfid = BSWAP32(GB(grfid, 0, 32)); // Match people's expectations.
for (auto c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC) && c->ident.grfid == grfid) {
return true;
}
}
return false;
}
/* static */ SQInteger ScriptNewGRF::GetVersion(SQInteger grfid)
{
grfid = BSWAP32(GB(grfid, 0, 32)); // Match people's expectations.
for (auto c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC) && c->ident.grfid == grfid) {
return c->version;
}
}
return 0;
}
/* static */ std::optional<std::string> ScriptNewGRF::GetName(SQInteger grfid)
{
grfid = BSWAP32(GB(grfid, 0, 32)); // Match people's expectations.
for (auto c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC) && c->ident.grfid == grfid) {
return c->GetName();
}
}
return std::nullopt;
}
|