Mercurial > hg > openttd
changeset 4776:ccd5477eaa87 draft
(svn r6690) - Fix (r6602): Translate global to per-climate cargo ids before... doing anything with them. (Thanks to MeusH for pointing this out...)
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Sun, 08 Oct 2006 19:28:55 +0000 |
parents | 971d37499e53 |
children | c5a8bc19f7b2 |
files | vehicle_gui.c |
diffstat | 1 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -216,9 +216,14 @@ /* Loop through all cargos in the refit mask */ for (cid = 0; cmask != 0 && num_lines < max_lines; cmask >>= 1, cid++) { + CargoID lcid; + /* Skip cargo type if it's not listed */ if (!HASBIT(cmask, 0)) continue; + lcid = _local_cargo_id_ctype[cid]; + if (lcid == CT_INVALID) continue; + /* Check the vehicle's callback mask for cargo suffixes */ if (HASBIT(callbackmask, CBM_CARGO_SUFFIX)) { /* Make a note of the original cargo type. It has to be @@ -227,7 +232,7 @@ byte temp_subtype = u->cargo_subtype; byte refit_cyc; - u->cargo_type = cid; + u->cargo_type = lcid; for (refit_cyc = 0; refit_cyc < 16 && num_lines < max_lines; refit_cyc++) { bool duplicate = false; @@ -241,12 +246,12 @@ /* Check if this cargo and subtype combination are listed */ for (i = 0; i < num_lines && !duplicate; i++) { - if (refit[i].cargo == cid && refit[i].value == callback) duplicate = true; + if (refit[i].cargo == lcid && refit[i].value == callback) duplicate = true; } if (duplicate) continue; - refit[num_lines].cargo = cid; + refit[num_lines].cargo = lcid; refit[num_lines].subtype = refit_cyc; refit[num_lines].value = callback; refit[num_lines].engine = u->engine_type; @@ -261,11 +266,11 @@ bool duplicate = false; for (i = 0; i < num_lines && !duplicate; i++) { - if (refit[i].cargo == cid && refit[i].value == CALLBACK_FAILED) duplicate = true; + if (refit[i].cargo == lcid && refit[i].value == CALLBACK_FAILED) duplicate = true; } if (!duplicate) { - refit[num_lines].cargo = cid; + refit[num_lines].cargo = lcid; refit[num_lines].subtype = 0; refit[num_lines].value = CALLBACK_FAILED; refit[num_lines].engine = INVALID_ENGINE; @@ -306,7 +311,7 @@ if (i >= pos && i < pos + rows) { /* Draw the cargo name */ - int last_x = DrawString(2, y, _cargoc.names_s[_local_cargo_id_ctype[refit[i].cargo]], colour); + int last_x = DrawString(2, y, _cargoc.names_s[refit[i].cargo], colour); /* If the callback succeeded, draw the cargo suffix */ if (refit[i].value != CALLBACK_FAILED) {