mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
(svn r16579) -Codechange: rework smallmap code a bit; remove goto, remove some unneeded variables, return value directly instead of writing it to a variable to later return that
This commit is contained in:
parent
238872d3bd
commit
20f73b2f50
@ -230,12 +230,11 @@ static uint _industry_to_list_pos[NUM_INDUSTRYTYPES];
|
|||||||
*/
|
*/
|
||||||
void BuildIndustriesLegend()
|
void BuildIndustriesLegend()
|
||||||
{
|
{
|
||||||
const IndustrySpec *indsp;
|
|
||||||
uint j = 0;
|
uint j = 0;
|
||||||
|
|
||||||
/* Add each name */
|
/* Add each name */
|
||||||
for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) {
|
for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) {
|
||||||
indsp = GetIndustrySpec(i);
|
const IndustrySpec *indsp = GetIndustrySpec(i);
|
||||||
if (indsp->enabled) {
|
if (indsp->enabled) {
|
||||||
_legend_from_industries[j].legend = indsp->name;
|
_legend_from_industries[j].legend = indsp->name;
|
||||||
_legend_from_industries[j].colour = indsp->map_colour;
|
_legend_from_industries[j].colour = indsp->map_colour;
|
||||||
@ -348,53 +347,6 @@ static const AndOr _smallmap_vegetation_andor[] = {
|
|||||||
|
|
||||||
typedef uint32 GetSmallMapPixels(TileIndex tile); // typedef callthrough function
|
typedef uint32 GetSmallMapPixels(TileIndex tile); // typedef callthrough function
|
||||||
|
|
||||||
/**
|
|
||||||
* Draws one column of the small map in a certain mode onto the screen buffer. This
|
|
||||||
* function looks exactly the same for all types
|
|
||||||
*
|
|
||||||
* @param dst Pointer to a part of the screen buffer to write to.
|
|
||||||
* @param xc The X coordinate of the first tile in the column.
|
|
||||||
* @param yc The Y coordinate of the first tile in the column
|
|
||||||
* @param pitch Number of pixels to advance in the screen buffer each time a pixel is written.
|
|
||||||
* @param reps Number of lines to draw
|
|
||||||
* @param mask ?
|
|
||||||
* @param proc Pointer to the colour function
|
|
||||||
* @see GetSmallMapPixels(TileIndex)
|
|
||||||
*/
|
|
||||||
static void DrawSmallMapStuff(void *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc)
|
|
||||||
{
|
|
||||||
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
|
||||||
void *dst_ptr_abs_end = blitter->MoveTo(_screen.dst_ptr, 0, _screen.height);
|
|
||||||
void *dst_ptr_end = blitter->MoveTo(dst_ptr_abs_end, -4, 0);
|
|
||||||
|
|
||||||
do {
|
|
||||||
/* check if the tile (xc,yc) is within the map range */
|
|
||||||
uint min_xy = _settings_game.construction.freeform_edges ? 1 : 0;
|
|
||||||
if (IsInsideMM(xc, min_xy, MapMaxX()) && IsInsideMM(yc, min_xy, MapMaxY())) {
|
|
||||||
/* check if the dst pointer points to a pixel inside the screen buffer */
|
|
||||||
if (dst < _screen.dst_ptr) continue;
|
|
||||||
if (dst >= dst_ptr_abs_end) continue;
|
|
||||||
|
|
||||||
uint32 val = proc(TileXY(xc, yc)) & mask;
|
|
||||||
uint8 *val8 = (uint8 *)&val;
|
|
||||||
|
|
||||||
if (dst <= dst_ptr_end) {
|
|
||||||
blitter->SetPixelIfEmpty(dst, 0, 0, val8[0]);
|
|
||||||
blitter->SetPixelIfEmpty(dst, 1, 0, val8[1]);
|
|
||||||
blitter->SetPixelIfEmpty(dst, 2, 0, val8[2]);
|
|
||||||
blitter->SetPixelIfEmpty(dst, 3, 0, val8[3]);
|
|
||||||
} else {
|
|
||||||
/* It happens that there are only 1, 2 or 3 pixels left to fill, so in that special case, write till the end of the video-buffer */
|
|
||||||
int i = 0;
|
|
||||||
do {
|
|
||||||
blitter->SetPixelIfEmpty(dst, 0, 0, val8[i]);
|
|
||||||
} while (i++, dst = blitter->MoveTo(dst, 1, 0), dst < dst_ptr_abs_end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* switch to next tile in the column */
|
|
||||||
} while (xc++, yc++, dst = blitter->MoveTo(dst, pitch, 0), --reps != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline TileType GetEffectiveTileType(TileIndex tile)
|
static inline TileType GetEffectiveTileType(TileIndex tile)
|
||||||
{
|
{
|
||||||
@ -421,8 +373,7 @@ static inline uint32 GetSmallMapContoursPixels(TileIndex tile)
|
|||||||
{
|
{
|
||||||
TileType t = GetEffectiveTileType(tile);
|
TileType t = GetEffectiveTileType(tile);
|
||||||
|
|
||||||
return
|
return ApplyMask(_map_height_bits[TileHeight(tile)], &_smallmap_contours_andor[t]);
|
||||||
ApplyMask(_map_height_bits[TileHeight(tile)], &_smallmap_contours_andor[t]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -470,22 +421,20 @@ static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile)
|
|||||||
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile)
|
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile)
|
||||||
{
|
{
|
||||||
TileType t = GetEffectiveTileType(tile);
|
TileType t = GetEffectiveTileType(tile);
|
||||||
uint32 bits;
|
|
||||||
|
|
||||||
if (t == MP_STATION) {
|
if (t == MP_STATION) {
|
||||||
switch (GetStationType(tile)) {
|
switch (GetStationType(tile)) {
|
||||||
case STATION_RAIL: bits = MKCOLOUR(0x56565656); break;
|
case STATION_RAIL: return MKCOLOUR(0x56565656);
|
||||||
case STATION_AIRPORT: bits = MKCOLOUR(0xB8B8B8B8); break;
|
case STATION_AIRPORT: return MKCOLOUR(0xB8B8B8B8);
|
||||||
case STATION_TRUCK: bits = MKCOLOUR(0xC2C2C2C2); break;
|
case STATION_TRUCK: return MKCOLOUR(0xC2C2C2C2);
|
||||||
case STATION_BUS: bits = MKCOLOUR(0xBFBFBFBF); break;
|
case STATION_BUS: return MKCOLOUR(0xBFBFBFBF);
|
||||||
case STATION_DOCK: bits = MKCOLOUR(0x98989898); break;
|
case STATION_DOCK: return MKCOLOUR(0x98989898);
|
||||||
default: bits = MKCOLOUR(0xFFFFFFFF); break;
|
default: return MKCOLOUR(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
/* ground colour */
|
/* ground colour */
|
||||||
bits = ApplyMask(MKCOLOUR(0x54545454), &_smallmap_contours_andor[t]);
|
return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_contours_andor[t]);
|
||||||
}
|
|
||||||
return bits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -503,35 +452,23 @@ static const uint32 _vegetation_clear_bits[] = {
|
|||||||
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile)
|
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile)
|
||||||
{
|
{
|
||||||
TileType t = GetEffectiveTileType(tile);
|
TileType t = GetEffectiveTileType(tile);
|
||||||
uint32 bits;
|
|
||||||
|
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case MP_CLEAR:
|
case MP_CLEAR:
|
||||||
if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) {
|
return (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) ? MKCOLOUR(0x37373737) : _vegetation_clear_bits[GetClearGround(tile)];
|
||||||
bits = MKCOLOUR(0x37373737);
|
|
||||||
} else {
|
|
||||||
bits = _vegetation_clear_bits[GetClearGround(tile)];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MP_INDUSTRY:
|
case MP_INDUSTRY:
|
||||||
bits = GetIndustrySpec(GetIndustryByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOUR(0xD0D0D0D0) : MKCOLOUR(0xB5B5B5B5);
|
return GetIndustrySpec(GetIndustryByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOUR(0xD0D0D0D0) : MKCOLOUR(0xB5B5B5B5);
|
||||||
break;
|
|
||||||
|
|
||||||
case MP_TREES:
|
case MP_TREES:
|
||||||
if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) {
|
if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) {
|
||||||
bits = (_settings_game.game_creation.landscape == LT_ARCTIC) ? MKCOLOUR(0x98575798) : MKCOLOUR(0xC25757C2);
|
return (_settings_game.game_creation.landscape == LT_ARCTIC) ? MKCOLOUR(0x98575798) : MKCOLOUR(0xC25757C2);
|
||||||
} else {
|
|
||||||
bits = MKCOLOUR(0x54575754);
|
|
||||||
}
|
}
|
||||||
break;
|
return MKCOLOUR(0x54575754);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
bits = ApplyMask(MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[t]);
|
return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[t]);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -623,6 +560,75 @@ class SmallMapWindow : public Window
|
|||||||
static const int COLUMN_WIDTH = 119;
|
static const int COLUMN_WIDTH = 119;
|
||||||
static const int MIN_LEGEND_HEIGHT = 6 * 7;
|
static const int MIN_LEGEND_HEIGHT = 6 * 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remap a map's tile X coordinate (TileX(TileIndex)) to
|
||||||
|
* a location on this smallmap.
|
||||||
|
* @param tile_x the tile's X coordinate.
|
||||||
|
* @return the X coordinate to draw on.
|
||||||
|
*/
|
||||||
|
inline int RemapX(int tile_x)
|
||||||
|
{
|
||||||
|
return tile_x - this->scroll_x / TILE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remap a map's tile Y coordinate (TileY(TileIndex)) to
|
||||||
|
* a location on this smallmap.
|
||||||
|
* @param tile_y the tile's Y coordinate.
|
||||||
|
* @return the Y coordinate to draw on.
|
||||||
|
*/
|
||||||
|
inline int RemapY(int tile_y)
|
||||||
|
{
|
||||||
|
return tile_y - this->scroll_y / TILE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws one column of the small map in a certain mode onto the screen buffer. This
|
||||||
|
* function looks exactly the same for all types
|
||||||
|
*
|
||||||
|
* @param dst Pointer to a part of the screen buffer to write to.
|
||||||
|
* @param xc The X coordinate of the first tile in the column.
|
||||||
|
* @param yc The Y coordinate of the first tile in the column
|
||||||
|
* @param pitch Number of pixels to advance in the screen buffer each time a pixel is written.
|
||||||
|
* @param reps Number of lines to draw
|
||||||
|
* @param mask ?
|
||||||
|
* @param proc Pointer to the colour function
|
||||||
|
* @see GetSmallMapPixels(TileIndex)
|
||||||
|
*/
|
||||||
|
inline void DrawSmallMapStuff(void *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc)
|
||||||
|
{
|
||||||
|
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
||||||
|
void *dst_ptr_abs_end = blitter->MoveTo(_screen.dst_ptr, 0, _screen.height);
|
||||||
|
void *dst_ptr_end = blitter->MoveTo(dst_ptr_abs_end, -4, 0);
|
||||||
|
|
||||||
|
do {
|
||||||
|
/* check if the tile (xc,yc) is within the map range */
|
||||||
|
uint min_xy = _settings_game.construction.freeform_edges ? 1 : 0;
|
||||||
|
if (IsInsideMM(xc, min_xy, MapMaxX()) && IsInsideMM(yc, min_xy, MapMaxY())) {
|
||||||
|
/* check if the dst pointer points to a pixel inside the screen buffer */
|
||||||
|
if (dst < _screen.dst_ptr) continue;
|
||||||
|
if (dst >= dst_ptr_abs_end) continue;
|
||||||
|
|
||||||
|
uint32 val = proc(TileXY(xc, yc)) & mask;
|
||||||
|
uint8 *val8 = (uint8 *)&val;
|
||||||
|
|
||||||
|
if (dst <= dst_ptr_end) {
|
||||||
|
blitter->SetPixelIfEmpty(dst, 0, 0, val8[0]);
|
||||||
|
blitter->SetPixelIfEmpty(dst, 1, 0, val8[1]);
|
||||||
|
blitter->SetPixelIfEmpty(dst, 2, 0, val8[2]);
|
||||||
|
blitter->SetPixelIfEmpty(dst, 3, 0, val8[3]);
|
||||||
|
} else {
|
||||||
|
/* It happens that there are only 1, 2 or 3 pixels left to fill, so in that special case, write till the end of the video-buffer */
|
||||||
|
int i = 0;
|
||||||
|
do {
|
||||||
|
blitter->SetPixelIfEmpty(dst, 0, 0, val8[i]);
|
||||||
|
} while (i++, dst = blitter->MoveTo(dst, 1, 0), dst < dst_ptr_abs_end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* switch to next tile in the column */
|
||||||
|
} while (xc++, yc++, dst = blitter->MoveTo(dst, pitch, 0), --reps != 0);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Draws the small map.
|
* Draws the small map.
|
||||||
@ -642,11 +648,6 @@ public:
|
|||||||
{
|
{
|
||||||
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
||||||
DrawPixelInfo *old_dpi;
|
DrawPixelInfo *old_dpi;
|
||||||
int dx, dy, x, y, x2, y2;
|
|
||||||
void *ptr;
|
|
||||||
int tile_x;
|
|
||||||
int tile_y;
|
|
||||||
ViewPort *vp;
|
|
||||||
|
|
||||||
old_dpi = _cur_dpi;
|
old_dpi = _cur_dpi;
|
||||||
_cur_dpi = dpi;
|
_cur_dpi = dpi;
|
||||||
@ -671,15 +672,15 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tile_x = this->scroll_x / TILE_SIZE;
|
int tile_x = this->scroll_x / TILE_SIZE;
|
||||||
tile_y = this->scroll_y / TILE_SIZE;
|
int tile_y = this->scroll_y / TILE_SIZE;
|
||||||
|
|
||||||
dx = dpi->left + this->subscroll;
|
int dx = dpi->left + this->subscroll;
|
||||||
tile_x -= dx / 4;
|
tile_x -= dx / 4;
|
||||||
tile_y += dx / 4;
|
tile_y += dx / 4;
|
||||||
dx &= 3;
|
dx &= 3;
|
||||||
|
|
||||||
dy = dpi->top;
|
int dy = dpi->top;
|
||||||
tile_x += dy / 2;
|
tile_x += dy / 2;
|
||||||
tile_y += dy / 2;
|
tile_y += dy / 2;
|
||||||
|
|
||||||
@ -693,24 +694,22 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = blitter->MoveTo(dpi->dst_ptr, -dx - 4, 0);
|
void *ptr = blitter->MoveTo(dpi->dst_ptr, -dx - 4, 0);
|
||||||
x = - dx - 4;
|
int x = - dx - 4;
|
||||||
y = 0;
|
int y = 0;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
uint32 mask = 0xFFFFFFFF;
|
uint32 mask = 0xFFFFFFFF;
|
||||||
int reps;
|
|
||||||
int t;
|
|
||||||
|
|
||||||
/* distance from left edge */
|
/* distance from left edge */
|
||||||
|
if (x >= -3) {
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
if (x < -3) goto skip_column;
|
|
||||||
/* mask to use at the left edge */
|
/* mask to use at the left edge */
|
||||||
mask = _smallmap_mask_left[x + 3];
|
mask = _smallmap_mask_left[x + 3];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* distance from right edge */
|
/* distance from right edge */
|
||||||
t = dpi->width - x;
|
int t = dpi->width - x;
|
||||||
if (t < 4) {
|
if (t < 4) {
|
||||||
if (t <= 0) break; // exit loop
|
if (t <= 0) break; // exit loop
|
||||||
/* mask to use at the right edge */
|
/* mask to use at the right edge */
|
||||||
@ -718,12 +717,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* number of lines */
|
/* number of lines */
|
||||||
reps = (dpi->height - y + 1) / 2;
|
int reps = (dpi->height - y + 1) / 2;
|
||||||
if (reps > 0) {
|
if (reps > 0) {
|
||||||
DrawSmallMapStuff(ptr, tile_x, tile_y, dpi->pitch * 2, reps, mask, _smallmap_draw_procs[this->map_type]);
|
this->DrawSmallMapStuff(ptr, tile_x, tile_y, dpi->pitch * 2, reps, mask, _smallmap_draw_procs[this->map_type]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_column:
|
|
||||||
if (y == 0) {
|
if (y == 0) {
|
||||||
tile_y++;
|
tile_y++;
|
||||||
y++;
|
y++;
|
||||||
@ -740,16 +739,14 @@ public:
|
|||||||
/* draw vehicles? */
|
/* draw vehicles? */
|
||||||
if (this->map_type == SMT_CONTOUR || this->map_type == SMT_VEHICLES) {
|
if (this->map_type == SMT_CONTOUR || this->map_type == SMT_VEHICLES) {
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
bool skip;
|
|
||||||
byte colour;
|
|
||||||
|
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->type != VEH_EFFECT &&
|
if (v->type != VEH_EFFECT &&
|
||||||
(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
|
(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
|
||||||
/* Remap into flat coordinates. */
|
/* Remap into flat coordinates. */
|
||||||
Point pt = RemapCoords(
|
Point pt = RemapCoords(
|
||||||
v->x_pos / TILE_SIZE - this->scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world
|
this->RemapX(v->x_pos / TILE_SIZE),
|
||||||
v->y_pos / TILE_SIZE - this->scroll_y / TILE_SIZE, // dtto
|
this->RemapY(v->y_pos / TILE_SIZE),
|
||||||
0);
|
0);
|
||||||
x = pt.x;
|
x = pt.x;
|
||||||
y = pt.y;
|
y = pt.y;
|
||||||
@ -759,7 +756,7 @@ public:
|
|||||||
if (!IsInsideMM(y, 0, dpi->height)) continue;
|
if (!IsInsideMM(y, 0, dpi->height)) continue;
|
||||||
|
|
||||||
/* Default is to draw both pixels. */
|
/* Default is to draw both pixels. */
|
||||||
skip = false;
|
bool skip = false;
|
||||||
|
|
||||||
/* Offset X coordinate */
|
/* Offset X coordinate */
|
||||||
x -= this->subscroll + 3 + dpi->left;
|
x -= this->subscroll + 3 + dpi->left;
|
||||||
@ -776,7 +773,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate pointer to pixel and the colour */
|
/* Calculate pointer to pixel and the colour */
|
||||||
colour = (this->map_type == SMT_VEHICLES) ? _vehicle_type_colours[v->type] : 0xF;
|
byte colour = (this->map_type == SMT_VEHICLES) ? _vehicle_type_colours[v->type] : 0xF;
|
||||||
|
|
||||||
/* And draw either one or two pixels depending on clipping */
|
/* And draw either one or two pixels depending on clipping */
|
||||||
blitter->SetPixel(dpi->dst_ptr, x, y, colour);
|
blitter->SetPixel(dpi->dst_ptr, x, y, colour);
|
||||||
@ -791,8 +788,8 @@ public:
|
|||||||
FOR_ALL_TOWNS(t) {
|
FOR_ALL_TOWNS(t) {
|
||||||
/* Remap the town coordinate */
|
/* Remap the town coordinate */
|
||||||
Point pt = RemapCoords(
|
Point pt = RemapCoords(
|
||||||
(int)(TileX(t->xy) * TILE_SIZE - this->scroll_x) / TILE_SIZE,
|
this->RemapX(TileX(t->xy)),
|
||||||
(int)(TileY(t->xy) * TILE_SIZE - this->scroll_y) / TILE_SIZE,
|
this->RemapY(TileY(t->xy)),
|
||||||
0);
|
0);
|
||||||
x = pt.x - this->subscroll + 3 - (t->sign.width_2 >> 1);
|
x = pt.x - this->subscroll + 3 - (t->sign.width_2 >> 1);
|
||||||
y = pt.y;
|
y = pt.y;
|
||||||
@ -809,19 +806,16 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw map indicators */
|
|
||||||
{
|
|
||||||
Point pt;
|
|
||||||
|
|
||||||
/* Find main viewport. */
|
/* Find main viewport. */
|
||||||
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
|
ViewPort *vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
|
||||||
|
|
||||||
pt = RemapCoords(this->scroll_x, this->scroll_y, 0);
|
/* Draw map indicators */
|
||||||
|
Point pt = RemapCoords(this->scroll_x, this->scroll_y, 0);
|
||||||
|
|
||||||
x = vp->virtual_left - pt.x;
|
x = vp->virtual_left - pt.x;
|
||||||
y = vp->virtual_top - pt.y;
|
y = vp->virtual_top - pt.y;
|
||||||
x2 = (x + vp->virtual_width) / TILE_SIZE;
|
int x2 = (x + vp->virtual_width) / TILE_SIZE;
|
||||||
y2 = (y + vp->virtual_height) / TILE_SIZE;
|
int y2 = (y + vp->virtual_height) / TILE_SIZE;
|
||||||
x /= TILE_SIZE;
|
x /= TILE_SIZE;
|
||||||
y /= TILE_SIZE;
|
y /= TILE_SIZE;
|
||||||
|
|
||||||
@ -833,18 +827,15 @@ public:
|
|||||||
|
|
||||||
DrawHorizMapIndicator(x, y, x2, y);
|
DrawHorizMapIndicator(x, y, x2, y);
|
||||||
DrawHorizMapIndicator(x, y2, x2, y2);
|
DrawHorizMapIndicator(x, y2, x2, y2);
|
||||||
}
|
|
||||||
_cur_dpi = old_dpi;
|
_cur_dpi = old_dpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmallMapCenterOnCurrentPos()
|
void SmallMapCenterOnCurrentPos()
|
||||||
{
|
{
|
||||||
int x, y;
|
ViewPort *vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
|
||||||
ViewPort *vp;
|
|
||||||
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
|
|
||||||
|
|
||||||
x = ((vp->virtual_width - (this->widget[SM_WIDGET_MAP].right - this->widget[SM_WIDGET_MAP].left) * TILE_SIZE) / 2 + vp->virtual_left) / 4;
|
int x = ((vp->virtual_width - (this->widget[SM_WIDGET_MAP].right - this->widget[SM_WIDGET_MAP].left) * TILE_SIZE) / 2 + vp->virtual_left) / 4;
|
||||||
y = ((vp->virtual_height - (this->widget[SM_WIDGET_MAP].bottom - this->widget[SM_WIDGET_MAP].top ) * TILE_SIZE) / 2 + vp->virtual_top ) / 2 - TILE_SIZE * 2;
|
int y = ((vp->virtual_height - (this->widget[SM_WIDGET_MAP].bottom - this->widget[SM_WIDGET_MAP].top ) * TILE_SIZE) / 2 + vp->virtual_top ) / 2 - TILE_SIZE * 2;
|
||||||
this->scroll_x = (y - x) & ~0xF;
|
this->scroll_x = (y - x) & ~0xF;
|
||||||
this->scroll_y = (x + y) & ~0xF;
|
this->scroll_y = (x + y) & ~0xF;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
Loading…
Reference in New Issue
Block a user