1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-24 04:34:16 +01:00

Codechange: replace BSWAP32/BSWAP16 with std::byteswap

This commit is contained in:
Rubidium
2025-01-28 07:30:53 +01:00
committed by rubidium42
parent 2481f2e085
commit 4099acb946
25 changed files with 93 additions and 96 deletions

View File

@@ -162,6 +162,6 @@
{
EnforcePrecondition(IT_INVALID, IsInsideBS(grf_local_id, 0x00, NUM_INDUSTRYTYPES_PER_GRF));
grfid = BSWAP32(GB(grfid, 0, 32)); // Match people's expectations.
grfid = std::byteswap(GB(grfid, 0, 32)); // Match people's expectations.
return _industry_mngr.GetID(grf_local_id, grfid);
}

View File

@@ -19,14 +19,14 @@ ScriptNewGRFList::ScriptNewGRFList()
{
for (auto c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) {
this->AddItem(BSWAP32(c->ident.grfid));
this->AddItem(std::byteswap(c->ident.grfid));
}
}
}
/* static */ bool ScriptNewGRF::IsLoaded(SQInteger grfid)
{
grfid = BSWAP32(GB(grfid, 0, 32)); // Match people's expectations.
grfid = std::byteswap(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) {
@@ -39,7 +39,7 @@ ScriptNewGRFList::ScriptNewGRFList()
/* static */ SQInteger ScriptNewGRF::GetVersion(SQInteger grfid)
{
grfid = BSWAP32(GB(grfid, 0, 32)); // Match people's expectations.
grfid = std::byteswap(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) {
@@ -52,7 +52,7 @@ ScriptNewGRFList::ScriptNewGRFList()
/* static */ std::optional<std::string> ScriptNewGRF::GetName(SQInteger grfid)
{
grfid = BSWAP32(GB(grfid, 0, 32)); // Match people's expectations.
grfid = std::byteswap(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) {

View File

@@ -51,6 +51,6 @@
{
EnforcePrecondition(INVALID_OBJECT_TYPE, IsInsideBS(grf_local_id, 0x00, NUM_OBJECTS_PER_GRF));
grfid = BSWAP32(GB(grfid, 0, 32)); // Match people's expectations.
grfid = std::byteswap(GB(grfid, 0, 32)); // Match people's expectations.
return _object_mngr.GetID(grf_local_id, grfid);
}