* Adds vehicles to the smallmap. * @param dpi the part of the smallmap to be drawn into * @param blitter current blitter */
| 948 | * @param blitter current blitter |
| 949 | */ |
| 950 | void DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) const |
| 951 | { |
| 952 | for (const Vehicle *v : Vehicle::Iterate()) { |
| 953 | if (v->type == VEH_EFFECT) continue; |
| 954 | if (v->vehstatus.Any({VehState::Hidden, VehState::Unclickable})) continue; |
| 955 | |
| 956 | /* Remap into flat coordinates. */ |
| 957 | Point pt = this->RemapTile(v->x_pos / (int)TILE_SIZE, v->y_pos / (int)TILE_SIZE); |
| 958 | |
| 959 | int y = pt.y - dpi->top; |
| 960 | if (!IsInsideMM(y, 0, dpi->height)) continue; // y is out of bounds. |
| 961 | |
| 962 | bool skip = false; // Default is to draw both pixels. |
| 963 | int x = pt.x - this->subscroll - 3 - dpi->left; // Offset X coordinate. |
| 964 | if (x < 0) { |
| 965 | /* if x+1 is 0, that means we're on the very left edge, |
| 966 | * and should thus only draw a single pixel */ |
| 967 | if (++x != 0) continue; |
| 968 | skip = true; |
| 969 | } else if (x >= dpi->width - 1) { |
| 970 | /* Check if we're at the very right edge, and if so draw only a single pixel */ |
| 971 | if (x != dpi->width - 1) continue; |
| 972 | skip = true; |
| 973 | } |
| 974 | |
| 975 | /* Calculate pointer to pixel and the colour */ |
| 976 | PixelColour colour = (this->map_type == SMT_VEHICLES) ? _vehicle_type_colours[v->type] : PC_WHITE; |
| 977 | |
| 978 | /* And draw either one or two pixels depending on clipping */ |
| 979 | blitter->SetPixel(dpi->dst_ptr, x, y, colour); |
| 980 | if (!skip) blitter->SetPixel(dpi->dst_ptr, x + 1, y, colour); |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | /** |
| 985 | * Adds town names to the smallmap. |
no test coverage detected