mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-31 10:29:10 +00:00
Fix 8706dcd9
: [Script] Byte-swap grfids to match normal expectations.
This commit is contained in:
@@ -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());
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
static uint32 GetVersion(uint32 grfid);
|
||||
|
||||
/**
|
||||
* Get the BridgeID of a bridge at a given tile.
|
||||
* Get the name of a loaded NewGRF.
|
||||
* @param grfid The NewGRF to query.
|
||||
* @pre ScriptNewGRF::IsLoaded(grfid).
|
||||
* @return The name of the NewGRF or nullptr if no name is defined.
|
||||
|
Reference in New Issue
Block a user