summaryrefslogtreecommitdiff
path: root/misc_gui.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2004-11-21 10:49:40 +0000
committertron <tron@openttd.org>2004-11-21 10:49:40 +0000
commit57adc97733fc0cc226f7d8f71c7e6b62dab690e0 (patch)
tree3fa8e5167fbe6804668a83cddbd662bdb0e8de2c /misc_gui.c
parent75d002690ac43c3a1c9bdbd16ca0eb48c9a2c50e (diff)
downloadopenttd-57adc97733fc0cc226f7d8f71c7e6b62dab690e0.tar.xz
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
This especially enables houses to accept passengers, mail, goods AND food. Add string templates for up to 5 cargo types for the tile info window. If more are needed just add them. Simplify (de-uglify) the logic for cargo acceptence for houses and split the goods/food table into two. The acceptance is unmodified, but accepting goods AND food is now trivially possible. The exact amounts have to be decided. This is based on Celestar's changes in the map branch plus some further bits that will be merged there soon.
Diffstat (limited to 'misc_gui.c')
-rw-r--r--misc_gui.c46
1 files changed, 15 insertions, 31 deletions
diff --git a/misc_gui.c b/misc_gui.c
index 04deaacd4..7ca26c09e 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -32,6 +32,8 @@ static void LandInfoWndProc(Window *w, WindowEvent *e)
uint32 *b;
if (e->event == WE_PAINT) {
+ int i;
+
DrawWindowWidgets(w);
lid = WP(w,void_d).data;
@@ -68,37 +70,19 @@ static void LandInfoWndProc(Window *w, WindowEvent *e)
str = STR_01CE_CARGO_ACCEPTED - 1;
- if (lid->ac.amount_1 != 0) {
- if (lid->ac.amount_1 < 8) {
- SET_DPARAMX16(b, 0, STR_01D1_8);
- SET_DPARAMX8(b, 1, lid->ac.amount_1);
- b += 2;
- }
- SET_DPARAMX16(b, 0, _cargoc.names_s[lid->ac.type_1]);
- b++;
- str++;
- }
-
- if (lid->ac.amount_2 != 0) {
- if (lid->ac.amount_2 < 8) {
- SET_DPARAMX16(b, 0, STR_01D1_8);
- SET_DPARAMX8(b, 1, lid->ac.amount_2);
- b += 2;
- }
- SET_DPARAMX16(b, 0, _cargoc.names_s[lid->ac.type_2]);
- b++;
- str++;
- }
-
- if (lid->ac.amount_3 != 0) {
- if (lid->ac.amount_3 < 8) {
- SET_DPARAMX16(b, 0, STR_01D1_8);
- SET_DPARAMX8(b, 1, lid->ac.amount_3);
- b += 2;
+ /* XXX if a tile accepts more cargo types than there are template strings
+ * this breaks */
+ for (i = 0; i < NUM_CARGO; ++i) {
+ if (lid->ac[i] > 0) {
+ if (lid->ac[i] < 8) {
+ SET_DPARAMX16(b, 0, STR_01D1_8);
+ SET_DPARAMX8(b, 1, lid->ac[i]);
+ b += 2;
+ }
+ SET_DPARAMX16(b, 0, _cargoc.names_s[i]);
+ b++;
+ str++;
}
- SET_DPARAMX16(b, 0, _cargoc.names_s[lid->ac.type_3]);
- b++;
- str++;
}
if (str != (STR_01CE_CARGO_ACCEPTED - 1))
@@ -155,7 +139,7 @@ static void Place_LandInfo(uint tile)
// Becuase build_date is not set yet in every TileDesc, we make sure it is empty
lid.td.build_date = 0;
- GetAcceptedCargo(tile, &lid.ac);
+ GetAcceptedCargo(tile, lid.ac);
GetTileDesc(tile, &lid.td);
#if defined(_DEBUG)