diff options
author | rubidium <rubidium@openttd.org> | 2007-06-13 23:43:00 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-06-13 23:43:00 +0000 |
commit | 3b5203dbc6972daf7b8e0d4006a22f2d3c6ddd85 (patch) | |
tree | 2f8ff8f5c8b6b3190c543618eb33ce76803bd031 | |
parent | 991996eb3617ebe091bcc06679c4c92e9eb824ee (diff) | |
download | openttd-3b5203dbc6972daf7b8e0d4006a22f2d3c6ddd85.tar.xz |
(svn r10154) -Fix [FS#870]: some vehicles were not drawn when having a high resolution and a high zoom-out level. Patch by B. N. SmatZ!.
-rw-r--r-- | src/vehicle.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 2b9dfb025..78afd5eb6 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -889,17 +889,29 @@ void ViewportAddVehicles(DrawPixelInfo *dpi) const int b = dpi->top + dpi->height; /* The hash area to scan */ - const int xl = GB(l - 70, 7, 6); - const int xu = GB(r, 7, 6); - const int yl = GB(t - 70, 6, 6) << 6; - const int yu = GB(b, 6, 6) << 6; + int xl, xu, yl, yu; - int x; - int y; + if (dpi->width + 70 < (1 << (7 + 6))) { + xl = GB(l - 70, 7, 6); + xu = GB(r, 7, 6); + } else { + /* scan whole hash row */ + xl = 0; + xu = 0x3F; + } + + if (dpi->height + 70 < (1 << (6 + 6))) { + yl = GB(t - 70, 6, 6) << 6; + yu = GB(b, 6, 6) << 6; + } else { + /* scan whole column */ + yl = 0; + yu = 0x3F << 6; + } - for (y = yl;; y = (y + (1 << 6)) & (0x3F << 6)) { - for (x = xl;; x = (x + 1) & 0x3F) { - const Vehicle *v = _vehicle_position_hash[(x + y) & 0xFFFF]; + for (int y = yl;; y = (y + (1 << 6)) & (0x3F << 6)) { + for (int x = xl;; x = (x + 1) & 0x3F) { + const Vehicle *v = _vehicle_position_hash[x + y]; // already masked & 0xFFF while (v != NULL) { if (!(v->vehstatus & VS_HIDDEN) && |