887 const int r = dpi->left + dpi->width; |
887 const int r = dpi->left + dpi->width; |
888 const int t = dpi->top; |
888 const int t = dpi->top; |
889 const int b = dpi->top + dpi->height; |
889 const int b = dpi->top + dpi->height; |
890 |
890 |
891 /* The hash area to scan */ |
891 /* The hash area to scan */ |
892 const int xl = GB(l - 70, 7, 6); |
892 int xl, xu, yl, yu; |
893 const int xu = GB(r, 7, 6); |
893 |
894 const int yl = GB(t - 70, 6, 6) << 6; |
894 if (dpi->width + 70 < (1 << (7 + 6))) { |
895 const int yu = GB(b, 6, 6) << 6; |
895 xl = GB(l - 70, 7, 6); |
896 |
896 xu = GB(r, 7, 6); |
897 int x; |
897 } else { |
898 int y; |
898 /* scan whole hash row */ |
899 |
899 xl = 0; |
900 for (y = yl;; y = (y + (1 << 6)) & (0x3F << 6)) { |
900 xu = 0x3F; |
901 for (x = xl;; x = (x + 1) & 0x3F) { |
901 } |
902 const Vehicle *v = _vehicle_position_hash[(x + y) & 0xFFFF]; |
902 |
|
903 if (dpi->height + 70 < (1 << (6 + 6))) { |
|
904 yl = GB(t - 70, 6, 6) << 6; |
|
905 yu = GB(b, 6, 6) << 6; |
|
906 } else { |
|
907 /* scan whole column */ |
|
908 yl = 0; |
|
909 yu = 0x3F << 6; |
|
910 } |
|
911 |
|
912 for (int y = yl;; y = (y + (1 << 6)) & (0x3F << 6)) { |
|
913 for (int x = xl;; x = (x + 1) & 0x3F) { |
|
914 const Vehicle *v = _vehicle_position_hash[x + y]; // already masked & 0xFFF |
903 |
915 |
904 while (v != NULL) { |
916 while (v != NULL) { |
905 if (!(v->vehstatus & VS_HIDDEN) && |
917 if (!(v->vehstatus & VS_HIDDEN) && |
906 l <= v->right_coord && |
918 l <= v->right_coord && |
907 t <= v->bottom_coord && |
919 t <= v->bottom_coord && |