Minimap use Vec2i for tilepos
This commit is contained in:
parent
e68d435a90
commit
9b0928ac0d
6 changed files with 46 additions and 61 deletions
src
|
@ -244,8 +244,8 @@ void EditTile(const Vec2i &pos, int tile)
|
|||
|
||||
mf->Flags |= Map.Tileset.FlagsTable[GetTileNumber(tile, 0, 0)];
|
||||
|
||||
UI.Minimap.UpdateSeenXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateSeenXY(pos);
|
||||
UI.Minimap.UpdateXY(pos);
|
||||
|
||||
EditorTileChanged(pos);
|
||||
UpdateMinimap = true;
|
||||
|
|
|
@ -436,8 +436,8 @@ static void EditorChangeTile(const Vec2i &pos, int tile, int d)
|
|||
|
||||
mf->Flags |= Map.Tileset.FlagsTable[tile];
|
||||
|
||||
UI.Minimap.UpdateSeenXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateSeenXY(pos);
|
||||
UI.Minimap.UpdateXY(pos);
|
||||
|
||||
EditorTileChanged2(pos, d);
|
||||
}
|
||||
|
|
|
@ -53,13 +53,13 @@ public:
|
|||
WithTerrain(false), ShowSelected(false),
|
||||
Transparent(false), UpdateCache(false) {}
|
||||
|
||||
void UpdateXY(int tx, int ty);
|
||||
void UpdateSeenXY(int, int) {}
|
||||
void Update(void);
|
||||
void Create(void);
|
||||
void FreeOpenGL(void);
|
||||
void Reload(void);
|
||||
void Destroy(void);
|
||||
void UpdateXY(const Vec2i &pos);
|
||||
void UpdateSeenXY(const Vec2i &pos) {}
|
||||
void Update();
|
||||
void Create();
|
||||
void FreeOpenGL();
|
||||
void Reload();
|
||||
void Destroy();
|
||||
void Draw(int vx, int vy);
|
||||
void DrawCursor(int vx, int vy);
|
||||
void AddEvent(int x, int y);
|
||||
|
|
|
@ -129,7 +129,7 @@ void CMap::MarkSeenTile(const unsigned int index)
|
|||
}
|
||||
|
||||
#ifdef MINIMAP_UPDATE
|
||||
UI.Minimap.UpdateXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateXY(pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -517,7 +517,7 @@ void CMap::FixTile(unsigned short type, int seen, const Vec2i &pos)
|
|||
mf->Tile = removedtile;
|
||||
mf->Flags &= ~flags;
|
||||
mf->Value = 0;
|
||||
UI.Minimap.UpdateXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateXY(pos);
|
||||
}
|
||||
} else if (seen && this->Tileset.MixedLookupTable[mf->SeenTile] ==
|
||||
this->Tileset.MixedLookupTable[tile]) { //Same Type
|
||||
|
@ -532,7 +532,7 @@ void CMap::FixTile(unsigned short type, int seen, const Vec2i &pos)
|
|||
|
||||
//maybe isExplored
|
||||
if (IsTileVisible(ThisPlayer, index) > 0) {
|
||||
UI.Minimap.UpdateSeenXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateSeenXY(pos);
|
||||
if (!seen) {
|
||||
MarkSeenTile(pos);
|
||||
}
|
||||
|
@ -588,12 +588,12 @@ void CMap::ClearTile(unsigned short type, const Vec2i &pos)
|
|||
mf->Flags &= ~flags;
|
||||
mf->Value = 0;
|
||||
|
||||
UI.Minimap.UpdateXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateXY(pos);
|
||||
FixNeighbors(type, 0, pos);
|
||||
|
||||
//maybe isExplored
|
||||
if (IsTileVisible(ThisPlayer, index) > 0) {
|
||||
UI.Minimap.UpdateSeenXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateSeenXY(pos);
|
||||
MarkSeenTile(pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ void MapFixSeenWallTile(const Vec2i &pos)
|
|||
|
||||
// FIXME: can this only happen if seen?
|
||||
if (Map.IsFieldVisible(ThisPlayer, pos)) {
|
||||
UI.Minimap.UpdateSeenXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateSeenXY(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -254,10 +254,10 @@ void MapFixWallTile(const Vec2i &pos)
|
|||
|
||||
if (mf->Tile != tile) {
|
||||
mf->Tile = tile;
|
||||
UI.Minimap.UpdateXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateXY(pos);
|
||||
|
||||
if (Map.IsFieldVisible(ThisPlayer, pos)) {
|
||||
UI.Minimap.UpdateSeenXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateSeenXY(pos);
|
||||
Map.MarkSeenTile(pos);
|
||||
}
|
||||
}
|
||||
|
@ -291,12 +291,12 @@ void CMap::RemoveWall(const Vec2i &pos)
|
|||
// FIXME: support more walls of different races.
|
||||
mf->Flags &= ~(MapFieldHuman | MapFieldWall | MapFieldUnpassable);
|
||||
|
||||
UI.Minimap.UpdateXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateXY(pos);
|
||||
MapFixWallTile(pos);
|
||||
MapFixWallNeighbors(pos);
|
||||
|
||||
if (Map.IsFieldVisible(ThisPlayer, pos)) {
|
||||
UI.Minimap.UpdateSeenXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateSeenXY(pos);
|
||||
this->MarkSeenTile(pos);
|
||||
}
|
||||
}
|
||||
|
@ -326,12 +326,12 @@ void CMap::SetWall(const Vec2i &pos, int humanwall)
|
|||
mf->Value = UnitTypeOrcWall->Variable[HP_INDEX].Max;
|
||||
}
|
||||
|
||||
UI.Minimap.UpdateXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateXY(pos);
|
||||
MapFixWallTile(pos);
|
||||
MapFixWallNeighbors(pos);
|
||||
|
||||
if (Map.IsFieldVisible(ThisPlayer, pos)) {
|
||||
UI.Minimap.UpdateSeenXY(pos.x, pos.y);
|
||||
UI.Minimap.UpdateSeenXY(pos);
|
||||
this->MarkSeenTile(pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -311,22 +311,10 @@ void CMinimap::UpdateTerrain(void)
|
|||
/**
|
||||
** Update a single minimap tile after a change
|
||||
**
|
||||
** @param tx The X map position to update in the minimap
|
||||
** @param ty The Y map position to update in the minimap
|
||||
** @param pos The map position to update in the minimap
|
||||
*/
|
||||
void CMinimap::UpdateXY(int tx, int ty)
|
||||
void CMinimap::UpdateXY(const Vec2i &pos)
|
||||
{
|
||||
int mx;
|
||||
int my;
|
||||
int x;
|
||||
int y;
|
||||
int scalex;
|
||||
int scaley;
|
||||
int xofs;
|
||||
int yofs;
|
||||
int tilepitch;
|
||||
int bpp;
|
||||
|
||||
if (!UseOpenGL) {
|
||||
if (!MinimapTerrainSurface) {
|
||||
return;
|
||||
|
@ -337,17 +325,17 @@ void CMinimap::UpdateXY(int tx, int ty)
|
|||
}
|
||||
}
|
||||
|
||||
scalex = MinimapScaleX * SCALE_PRECISION / MINIMAP_FAC;
|
||||
int scalex = MinimapScaleX * SCALE_PRECISION / MINIMAP_FAC;
|
||||
if (scalex == 0) {
|
||||
scalex = 1;
|
||||
}
|
||||
scaley = MinimapScaleY * SCALE_PRECISION / MINIMAP_FAC;
|
||||
int scaley = MinimapScaleY * SCALE_PRECISION / MINIMAP_FAC;
|
||||
if (scaley == 0) {
|
||||
scaley = 1;
|
||||
}
|
||||
|
||||
tilepitch = Map.TileGraphic->Surface->w / TileSizeX;
|
||||
bpp = Map.TileGraphic->Surface->format->BytesPerPixel;
|
||||
const int tilepitch = Map.TileGraphic->Surface->w / TileSizeX;
|
||||
const int bpp = Map.TileGraphic->Surface->format->BytesPerPixel;
|
||||
|
||||
//
|
||||
// Pixel 7,6 7,14, 15,6 15,14 are taken for the minimap picture.
|
||||
|
@ -357,9 +345,10 @@ void CMinimap::UpdateXY(int tx, int ty)
|
|||
}
|
||||
SDL_LockSurface(Map.TileGraphic->Surface);
|
||||
|
||||
ty *= Map.Info.MapWidth;
|
||||
for (my = YOffset; my < H - YOffset; ++my) {
|
||||
y = Minimap2MapY[my];
|
||||
const int ty = pos.y * Map.Info.MapWidth;
|
||||
const int tx = pos.x;
|
||||
for (int my = YOffset; my < H - YOffset; ++my) {
|
||||
const int y = Minimap2MapY[my];
|
||||
if (y < ty) {
|
||||
continue;
|
||||
}
|
||||
|
@ -367,11 +356,9 @@ void CMinimap::UpdateXY(int tx, int ty)
|
|||
break;
|
||||
}
|
||||
|
||||
for (mx = XOffset; mx < W - XOffset; ++mx) {
|
||||
int tile;
|
||||
Uint32 c;
|
||||
for (int mx = XOffset; mx < W - XOffset; ++mx) {
|
||||
const int x = Minimap2MapX[mx];
|
||||
|
||||
x = Minimap2MapX[mx];
|
||||
if (x < tx) {
|
||||
continue;
|
||||
}
|
||||
|
@ -379,24 +366,22 @@ void CMinimap::UpdateXY(int tx, int ty)
|
|||
break;
|
||||
}
|
||||
|
||||
tile = Map.Fields[x + y].SeenTile;
|
||||
int tile = Map.Fields[x + y].SeenTile;
|
||||
if (!tile) {
|
||||
tile = Map.Fields[x + y].Tile;
|
||||
}
|
||||
|
||||
xofs = TileSizeX * (tile % tilepitch);
|
||||
yofs = TileSizeY * (tile / tilepitch);
|
||||
const int xofs = TileSizeX * (tile % tilepitch);
|
||||
const int yofs = TileSizeY * (tile / tilepitch);
|
||||
|
||||
if (!UseOpenGL) {
|
||||
if (bpp == 1) {
|
||||
((Uint8 *)MinimapTerrainSurface->pixels)[mx + my * MinimapTerrainSurface->pitch] =
|
||||
*GetTileGraphicPixel(xofs, yofs, mx, my, scalex, scaley, bpp);
|
||||
} else if (bpp == 3) {
|
||||
Uint8 *d;
|
||||
Uint8 *s;
|
||||
Uint8 *d = &((Uint8 *)MinimapTerrainSurface->pixels)[mx * bpp + my * MinimapTerrainSurface->pitch];
|
||||
Uint8 *s = GetTileGraphicPixel(xofs, yofs, mx, my, scalex, scaley, bpp);
|
||||
|
||||
d = &((Uint8 *)MinimapTerrainSurface->pixels)[mx * bpp + my * MinimapTerrainSurface->pitch];
|
||||
s = GetTileGraphicPixel(xofs, yofs, mx, my, scalex, scaley, bpp);
|
||||
*d++ = *s++;
|
||||
*d++ = *s++;
|
||||
*d++ = *s++;
|
||||
|
@ -405,16 +390,16 @@ void CMinimap::UpdateXY(int tx, int ty)
|
|||
*(Uint32 *)GetTileGraphicPixel(xofs, yofs, mx, my, scalex, scaley, bpp);
|
||||
}
|
||||
} else {
|
||||
if (bpp == 1) {
|
||||
SDL_Color color;
|
||||
Uint32 c;
|
||||
|
||||
if (bpp == 1) {
|
||||
const int colorIndex = *GetTileGraphicPixel(xofs, yofs, mx, my, scalex, scaley, bpp);
|
||||
const SDL_Color color = Map.TileGraphic->Surface->format->palette->colors[colorIndex];
|
||||
|
||||
color = Map.TileGraphic->Surface->format->palette->colors[
|
||||
*GetTileGraphicPixel(xofs, yofs, mx, my, scalex, scaley, bpp)];
|
||||
c = Video.MapRGB(0, color.r, color.g, color.b);
|
||||
} else {
|
||||
SDL_PixelFormat *f;
|
||||
SDL_PixelFormat *f = Map.TileGraphic->Surface->format;
|
||||
|
||||
f = Map.TileGraphic->Surface->format;
|
||||
c = *(Uint32 *)GetTileGraphicPixel(xofs, yofs, mx, my, scalex, scaley, bpp);
|
||||
c = Video.MapRGB(0,
|
||||
((c & f->Rmask) >> f->Rshift),
|
||||
|
|
Loading…
Add table
Reference in a new issue