summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeterN <peter1138@openttd.org>2021-06-17 23:34:59 +0100
committerGitHub <noreply@github.com>2021-06-17 23:34:59 +0100
commitce7ef4d824b9e6cd852826b6fcc41263487ebd5e (patch)
tree30559785a7c6951996a939d178333073f4dd799e
parent1e6a2163a5ca5fe0e17fbd9adef23571f2c36a8a (diff)
downloadopenttd-ce7ef4d824b9e6cd852826b6fcc41263487ebd5e.tar.xz
Fix: Wrong cargo line position in IndustryCargo window. (#9383)
Resolved by changing calculation to determine the offset based on centring the cargo lines in the available space.
-rw-r--r--src/industry_gui.cpp6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index fd5f5d487..648939975 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -2021,11 +2021,7 @@ struct CargoesField {
assert(this->type == CFT_CARGO);
int n = this->u.cargo.num_cargoes;
- if (n % 2 == 0) {
- return xpos + cargo_field_width / 2 - (CargoesField::cargo_line.width + CargoesField::cargo_space.width / 2) * (n / 2);
- } else {
- return xpos + cargo_field_width / 2 - CargoesField::cargo_line.width / 2 - (CargoesField::cargo_line.width + CargoesField::cargo_space.width) * (n / 2);
- }
+ return xpos + cargo_field_width / 2 - (CargoesField::cargo_line.width * n + CargoesField::cargo_space.width * (n - 1)) / 2;
}
/**