summaryrefslogtreecommitdiff
path: root/src/script/api/script_newgrf.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-08-10 21:09:35 +0200
committerMichael Lutz <michi@icosahedron.de>2021-08-10 21:35:17 +0200
commitb14681891dce4b0060308d6a477a22c4f0b77edd (patch)
tree54eab098108b30706a44539b1a266ce62a7d38dd /src/script/api/script_newgrf.cpp
parent580dd118cb322090e41791199f45e51c0e064bb4 (diff)
downloadopenttd-b14681891dce4b0060308d6a477a22c4f0b77edd.tar.xz
Fix 8706dcd9: [Script] Byte-swap grfids to match normal expectations.
Diffstat (limited to 'src/script/api/script_newgrf.cpp')
-rw-r--r--src/script/api/script_newgrf.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/script/api/script_newgrf.cpp b/src/script/api/script_newgrf.cpp
index 387093092..9cdeeb191 100644
--- a/src/script/api/script_newgrf.cpp
+++ b/src/script/api/script_newgrf.cpp
@@ -19,13 +19,15 @@ ScriptNewGRFList::ScriptNewGRFList()
{
for (auto c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) {
- this->AddItem(c->ident.grfid);
+ this->AddItem(BSWAP32(c->ident.grfid));
}
}
}
/* static */ bool ScriptNewGRF::IsLoaded(uint32 grfid)
{
+ grfid = BSWAP32(grfid); // 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;
@@ -37,6 +39,8 @@ ScriptNewGRFList::ScriptNewGRFList()
/* static */ uint32 ScriptNewGRF::GetVersion(uint32 grfid)
{
+ grfid = BSWAP32(grfid); // 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;
@@ -48,6 +52,8 @@ ScriptNewGRFList::ScriptNewGRFList()
/* static */ char *ScriptNewGRF::GetName(uint32 grfid)
{
+ grfid = BSWAP32(grfid); // Match people's expectations.
+
for (auto c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC) && c->ident.grfid == grfid) {
return ::stredup(c->GetName());