Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix weirdness of new stations. #10017

Merged
merged 3 commits into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/newgrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,12 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte
}
dts->Clone(tmp_layout.data());
}

/* Number of layouts must be even, alternating X and Y */
if (statspec->renderdata.size() & 1) {
grfmsg(1, "StationChangeInfo: Station %u defines an odd number of sprite layouts, dropping the last item", stid + i);
statspec->renderdata.pop_back();
}
break;
}

Expand Down Expand Up @@ -2070,6 +2076,12 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte
/* On error, bail out immediately. Temporary GRF data was already freed */
if (ReadSpriteLayout(buf, num_building_sprites, false, GSF_STATIONS, true, false, dts)) return CIR_DISABLED;
}

/* Number of layouts must be even, alternating X and Y */
if (statspec->renderdata.size() & 1) {
grfmsg(1, "StationChangeInfo: Station %u defines an odd number of sprite layouts, dropping the last item", stid + i);
statspec->renderdata.pop_back();
}
break;
}

Expand Down
4 changes: 2 additions & 2 deletions src/newgrf_station.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,8 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
if (statspec == nullptr) return false;

if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) {
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0x2110000, 0, statspec, nullptr, INVALID_TILE);
if (callback != CALLBACK_FAILED) tile = callback;
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, nullptr, INVALID_TILE);
if (callback != CALLBACK_FAILED) tile = callback & ~1;
}

uint32 total_offset = rti->GetRailtypeSpriteOffset();
Expand Down