Browse Source

🎨 Apply agreeable part of clang-tidy to appfat and automap

pull/1604/head
Anders Jenbo 5 years ago
parent
commit
660eeb19d2
  1. 16
      Source/appfat.cpp
  2. 271
      Source/automap.cpp
  3. 22
      Source/automap.h

16
Source/appfat.cpp

@ -38,11 +38,11 @@ void MsgBox(const char *pszFmt, va_list va)
*/
void FreeDlg()
{
if (terminating && cleanup_thread_id != SDL_GetThreadID(NULL))
if (terminating && cleanup_thread_id != SDL_GetThreadID(nullptr))
SDL_Delay(20000);
terminating = true;
cleanup_thread_id = SDL_GetThreadID(NULL);
cleanup_thread_id = SDL_GetThreadID(nullptr);
if (gbIsMultiplayer) {
if (SNetLeaveGame(3))
@ -66,7 +66,7 @@ void app_fatal(const char *pszFmt, ...)
va_start(va, pszFmt);
FreeDlg();
if (pszFmt)
if (pszFmt != nullptr)
MsgBox(pszFmt, va);
va_end(va);
@ -116,7 +116,7 @@ void ErrDlg(const char *title, const char *error, const char *log_file_path, int
snprintf(text, 1024, "%s\n\nThe error occurred at: %s line %d", error, log_file_path, log_line_nr);
UiErrorOkDialog(title, text);
app_fatal(NULL);
app_fatal(nullptr);
}
/**
@ -128,7 +128,7 @@ void FileErrDlg(const char *error)
FreeDlg();
if (!error)
if (error == nullptr)
error = "";
snprintf(
text,
@ -143,7 +143,7 @@ void FileErrDlg(const char *error)
error);
UiErrorOkDialog("Data File Error", text);
app_fatal(NULL);
app_fatal(nullptr);
}
/**
@ -160,7 +160,7 @@ void InsertCDDlg()
"Make sure that it is in the game folder and that the file name is in all lowercase.");
UiErrorOkDialog("Data File Error", text);
app_fatal(NULL);
app_fatal(nullptr);
}
/**
@ -173,7 +173,7 @@ void DirErrorDlg(const char *error)
snprintf(text, 1024, "Unable to write to location:\n%s", error);
UiErrorOkDialog("Read-Only Directory Error", text);
app_fatal(NULL);
app_fatal(nullptr);
}
} // namespace devilution

271
Source/automap.cpp

@ -4,6 +4,7 @@
* Implementation of the in-game map overlay.
*/
#include "automap.h"
#include "control.h"
#include "inv.h"
#include "miniwin/miniwin.h"
@ -20,7 +21,7 @@ namespace {
* Maps from tile_id to automap type.
* BUGFIX: only the first 256 elements are ever read
*/
Uint16 automaptype[512];
uint16_t automaptype[512];
static Sint32 AutoMapX;
static Sint32 AutoMapY;
@ -48,13 +49,11 @@ static Sint32 AutoMapY;
/**
* @brief Renders the given automap shape at the specified screen coordinates.
*/
void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_type)
void DrawAutomapTile(const CelOutputBuffer &out, int sx, int sy, uint16_t automap_type)
{
Sint32 x1, y1, x2, y2;
Uint8 flags = automap_type >> 8;
uint8_t flags = automap_type >> 8;
if (flags & MAPFLAG_DIRT) {
if ((flags & MAPFLAG_DIRT) != 0) {
SetPixel(out, sx, sy, COLOR_DIM);
SetPixel(out, sx - AmLine8, sy - AmLine4, COLOR_DIM);
SetPixel(out, sx - AmLine8, sy + AmLine4, COLOR_DIM);
@ -73,7 +72,7 @@ void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_t
SetPixel(out, sx, sy + AmLine16, COLOR_DIM);
}
if (flags & MAPFLAG_STAIRS) {
if ((flags & MAPFLAG_STAIRS) != 0) {
DrawLineTo(out, sx - AmLine8, sy - AmLine8 - AmLine4, sx + AmLine8 + AmLine16, sy + AmLine4, COLOR_BRIGHT);
DrawLineTo(out, sx - AmLine16, sy - AmLine8, sx + AmLine16, sy + AmLine8, COLOR_BRIGHT);
DrawLineTo(out, sx - AmLine16 - AmLine8, sy - AmLine4, sx + AmLine8, sy + AmLine8 + AmLine4, COLOR_BRIGHT);
@ -85,16 +84,17 @@ void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_t
bool do_cave_horz = false;
bool do_cave_vert = false;
switch (automap_type & MAPFLAG_TYPE) {
case 1: // stand-alone column or other unpassable object
x1 = sx - AmLine16;
y1 = sy - AmLine16;
x2 = x1 + AmLine32;
y2 = sy - AmLine8;
case 1: { // stand-alone column or other unpassable object
int x1 = sx - AmLine16;
int y1 = sy - AmLine16;
int x2 = x1 + AmLine32;
int y2 = sy - AmLine8;
DrawLineTo(out, sx, y1, x1, y2, COLOR_DIM);
DrawLineTo(out, sx, y1, x2, y2, COLOR_DIM);
DrawLineTo(out, sx, sy, x1, y2, COLOR_DIM);
DrawLineTo(out, sx, sy, x2, y2, COLOR_DIM);
break;
} break;
case 2:
case 5:
do_vert = true;
@ -127,12 +127,12 @@ void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_t
break;
}
if (do_vert) { // right-facing obstacle
if (flags & MAPFLAG_VERTDOOR) { // two wall segments with a door in the middle
x1 = sx - AmLine32;
x2 = sx - AmLine16;
y1 = sy - AmLine16;
y2 = sy - AmLine8;
if (do_vert) { // right-facing obstacle
if ((flags & MAPFLAG_VERTDOOR) != 0) { // two wall segments with a door in the middle
int x1 = sx - AmLine32;
int x2 = sx - AmLine16;
int y1 = sy - AmLine16;
int y2 = sy - AmLine8;
DrawLineTo(out, sx, y1, sx - AmLine8, y1 + AmLine4, COLOR_DIM);
DrawLineTo(out, x1, sy, x1 + AmLine8, sy - AmLine4, COLOR_DIM);
@ -141,15 +141,15 @@ void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_t
DrawLineTo(out, x2, sy, x1, y2, COLOR_BRIGHT);
DrawLineTo(out, x2, sy, sx, y2, COLOR_BRIGHT);
}
if (flags & MAPFLAG_VERTGRATE) { // right-facing half-wall
if ((flags & MAPFLAG_VERTGRATE) != 0) { // right-facing half-wall
DrawLineTo(out, sx - AmLine16, sy - AmLine8, sx - AmLine32, sy, COLOR_DIM);
flags |= MAPFLAG_VERTARCH;
}
if (flags & MAPFLAG_VERTARCH) { // window or passable column
x1 = sx - AmLine16;
y1 = sy - AmLine16;
x2 = x1 + AmLine32;
y2 = sy - AmLine8;
if ((flags & MAPFLAG_VERTARCH) != 0) { // window or passable column
int x1 = sx - AmLine16;
int y1 = sy - AmLine16;
int x2 = x1 + AmLine32;
int y2 = sy - AmLine8;
DrawLineTo(out, sx, y1, x1, y2, COLOR_DIM);
DrawLineTo(out, sx, y1, x2, y2, COLOR_DIM);
@ -161,11 +161,11 @@ void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_t
}
if (do_horz) { // left-facing obstacle
if (flags & MAPFLAG_HORZDOOR) {
x1 = sx + AmLine16;
x2 = sx + AmLine32;
y1 = sy - AmLine16;
y2 = sy - AmLine8;
if ((flags & MAPFLAG_HORZDOOR) != 0) {
int x1 = sx + AmLine16;
int x2 = sx + AmLine32;
int y1 = sy - AmLine16;
int y2 = sy - AmLine8;
DrawLineTo(out, sx, y1, sx + AmLine8, y1 + AmLine4, COLOR_DIM);
DrawLineTo(out, x2, sy, x2 - AmLine8, sy - AmLine4, COLOR_DIM);
@ -174,15 +174,15 @@ void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_t
DrawLineTo(out, x1, sy, sx, y2, COLOR_BRIGHT);
DrawLineTo(out, x1, sy, x2, y2, COLOR_BRIGHT);
}
if (flags & MAPFLAG_HORZGRATE) {
if ((flags & MAPFLAG_HORZGRATE) != 0) {
DrawLineTo(out, sx + AmLine16, sy - AmLine8, sx + AmLine32, sy, COLOR_DIM);
flags |= MAPFLAG_HORZARCH;
}
if (flags & MAPFLAG_HORZARCH) {
x1 = sx - AmLine16;
y1 = sy - AmLine16;
x2 = x1 + AmLine32;
y2 = sy - AmLine8;
if ((flags & MAPFLAG_HORZARCH) != 0) {
int x1 = sx - AmLine16;
int y1 = sy - AmLine16;
int x2 = x1 + AmLine32;
int y2 = sy - AmLine8;
DrawLineTo(out, sx, y1, x1, y2, COLOR_DIM);
DrawLineTo(out, sx, y1, x2, y2, COLOR_DIM);
@ -195,11 +195,11 @@ void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_t
// for caves the horz/vert flags are switched
if (do_cave_horz) {
if (flags & MAPFLAG_VERTDOOR) {
x1 = sx - AmLine32;
x2 = sx - AmLine16;
y1 = sy + AmLine16;
y2 = sy + AmLine8;
if ((flags & MAPFLAG_VERTDOOR) != 0) {
int x1 = sx - AmLine32;
int x2 = sx - AmLine16;
int y1 = sy + AmLine16;
int y2 = sy + AmLine8;
DrawLineTo(out, sx, y1, sx - AmLine8, y1 - AmLine4, COLOR_DIM);
DrawLineTo(out, x1, sy, x1 + AmLine8, sy + AmLine4, COLOR_DIM);
@ -212,11 +212,11 @@ void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_t
}
if (do_cave_vert) {
if (flags & MAPFLAG_HORZDOOR) {
x1 = sx + AmLine16;
x2 = sx + AmLine32;
y1 = sy + AmLine16;
y2 = sy + AmLine8;
if ((flags & MAPFLAG_HORZDOOR) != 0) {
int x1 = sx + AmLine16;
int x2 = sx + AmLine32;
int y1 = sy + AmLine16;
int y2 = sy + AmLine8;
DrawLineTo(out, sx, y1, sx + AmLine8, y1 - AmLine4, COLOR_DIM);
DrawLineTo(out, x2, sy, x2 - AmLine8, sy + AmLine4, COLOR_DIM);
@ -230,22 +230,22 @@ void DrawAutomapTile(CelOutputBuffer out, Sint32 sx, Sint32 sy, Uint16 automap_t
}
}
void DrawAutomapItem(CelOutputBuffer out, Sint32 x, Sint32 y, Uint8 color)
void DrawAutomapItem(const CelOutputBuffer &out, int x, int y, uint8_t color)
{
Sint32 x1 = x - AmLine32 / 2;
Sint32 y1 = y - AmLine16 / 2;
Sint32 x2 = x1 + AmLine64 / 2;
Sint32 y2 = y1 + AmLine32 / 2;
int x1 = x - AmLine32 / 2;
int y1 = y - AmLine16 / 2;
int x2 = x1 + AmLine64 / 2;
int y2 = y1 + AmLine32 / 2;
DrawLineTo(out, x, y1, x1, y, color);
DrawLineTo(out, x, y1, x2, y, color);
DrawLineTo(out, x, y2, x1, y, color);
DrawLineTo(out, x, y2, x2, y, color);
}
void SearchAutomapItem(CelOutputBuffer out)
void SearchAutomapItem(const CelOutputBuffer &out)
{
Sint32 x = plr[myplr]._px;
Sint32 y = plr[myplr]._py;
int x = plr[myplr]._px;
int y = plr[myplr]._py;
if (plr[myplr]._pmode == PM_WALK3) {
x = plr[myplr]._pfutx;
y = plr[myplr]._pfuty;
@ -255,35 +255,35 @@ void SearchAutomapItem(CelOutputBuffer out)
y++;
}
Sint32 x1 = x - 8;
int x1 = x - 8;
if (x1 < 0)
x1 = 0;
else if (x1 > MAXDUNX)
x1 = MAXDUNX;
Sint32 y1 = y - 8;
int y1 = y - 8;
if (y1 < 0)
y1 = 0;
else if (y1 > MAXDUNY)
y1 = MAXDUNY;
Sint32 x2 = x + 8;
int x2 = x + 8;
if (x2 < 0)
x2 = 0;
else if (x2 > MAXDUNX)
x2 = MAXDUNX;
Sint32 y2 = y + 8;
int y2 = y + 8;
if (y2 < 0)
y2 = 0;
else if (y2 > MAXDUNY)
y2 = MAXDUNY;
for (Sint32 i = x1; i < x2; i++) {
for (Sint32 j = y1; j < y2; j++) {
for (int i = x1; i < x2; i++) {
for (int j = y1; j < y2; j++) {
if (dItem[i][j] != 0) {
Sint32 px = i - 2 * AutoMapXOfs - ViewX;
Sint32 py = j - 2 * AutoMapYOfs - ViewY;
int px = i - 2 * AutoMapXOfs - ViewX;
int py = j - 2 * AutoMapYOfs - ViewY;
x = (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AmLine16 + gnScreenWidth / 2;
y = (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AmLine8 + (gnScreenHeight - PANEL_HEIGHT) / 2;
@ -304,13 +304,12 @@ void SearchAutomapItem(CelOutputBuffer out)
/**
* @brief Renders an arrow on the automap, centered on and facing the direction of the player.
*/
void DrawAutomapPlr(CelOutputBuffer out, int pnum)
void DrawAutomapPlr(const CelOutputBuffer &out, int pnum)
{
int px, py;
int x, y;
int playerColor;
int x;
int y;
playerColor = COLOR_PLAYER + (8 * pnum) % 128;
int playerColor = COLOR_PLAYER + (8 * pnum) % 128;
if (plr[pnum]._pmode == PM_WALK3) {
x = plr[pnum]._pfutx;
@ -323,8 +322,8 @@ void DrawAutomapPlr(CelOutputBuffer out, int pnum)
x = plr[pnum]._px;
y = plr[pnum]._py;
}
px = x - 2 * AutoMapXOfs - ViewX;
py = y - 2 * AutoMapYOfs - ViewY;
int px = x - 2 * AutoMapXOfs - ViewX;
int py = y - 2 * AutoMapYOfs - ViewY;
x = (plr[pnum]._pxoff * AutoMapScale / 100 >> 1) + (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AmLine16 + gnScreenWidth / 2;
y = (plr[pnum]._pyoff * AutoMapScale / 100 >> 1) + (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AmLine8 + (gnScreenHeight - PANEL_HEIGHT) / 2;
@ -385,24 +384,20 @@ void DrawAutomapPlr(CelOutputBuffer out, int pnum)
/**
* @brief Returns the automap shape at the given coordinate.
*/
WORD GetAutomapType(int x, int y, bool view)
uint16_t GetAutomapType(int x, int y, bool view)
{
WORD rv;
if (view && x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) {
if (GetAutomapType(0, y, false) & (MAPFLAG_DIRT << 8)) {
if ((GetAutomapType(0, y, false) & (MAPFLAG_DIRT << 8)) != 0) {
return 0;
} else {
return MAPFLAG_DIRT << 8;
}
return MAPFLAG_DIRT << 8;
}
if (view && y == -1 && x >= 0 && x < DMAXY && automapview[x][0]) {
if (GetAutomapType(x, 0, false) & (MAPFLAG_DIRT << 8)) {
if ((GetAutomapType(x, 0, false) & (MAPFLAG_DIRT << 8)) != 0) {
return 0;
} else {
return MAPFLAG_DIRT << 8;
}
return MAPFLAG_DIRT << 8;
}
if (x < 0 || x >= DMAXX) {
@ -415,10 +410,10 @@ WORD GetAutomapType(int x, int y, bool view)
return 0;
}
rv = automaptype[(BYTE)dungeon[x][y]];
uint16_t rv = automaptype[(BYTE)dungeon[x][y]];
if (rv == 7) {
if ((GetAutomapType(x - 1, y, false) >> 8) & MAPFLAG_HORZARCH) {
if ((GetAutomapType(x, y - 1, false) >> 8) & MAPFLAG_VERTARCH) {
if (((GetAutomapType(x - 1, y, false) >> 8) & MAPFLAG_HORZARCH) != 0) {
if (((GetAutomapType(x, y - 1, false) >> 8) & MAPFLAG_VERTARCH) != 0) {
rv = 1;
}
}
@ -429,7 +424,7 @@ WORD GetAutomapType(int x, int y, bool view)
/**
* @brief Renders game info, such as the name of the current level, and in multi player the name of the game and the game password.
*/
void DrawAutomapText(CelOutputBuffer out)
void DrawAutomapText(const CelOutputBuffer &out)
{
// TODO: Use the `out` buffer instead of the global one.
@ -440,7 +435,7 @@ void DrawAutomapText(CelOutputBuffer out)
strcat(strcpy(desc, "game: "), szPlayerName);
PrintGameStr(out, 8, 20, desc, COL_GOLD);
nextline = 35;
if (szPlayerDescript[0]) {
if (szPlayerDescript[0] != 0) {
strcat(strcpy(desc, "password: "), szPlayerDescript);
PrintGameStr(out, 8, 35, desc, COL_GOLD);
nextline = 50;
@ -465,14 +460,14 @@ void DrawAutomapText(CelOutputBuffer out)
bool automapflag;
bool automapview[DMAXX][DMAXY];
Sint32 AutoMapScale;
Sint32 AutoMapXOfs;
Sint32 AutoMapYOfs;
Sint32 AmLine64;
Sint32 AmLine32;
Sint32 AmLine16;
Sint32 AmLine8;
Sint32 AmLine4;
int AutoMapScale;
int AutoMapXOfs;
int AutoMapYOfs;
int AmLine64;
int AmLine32;
int AmLine16;
int AmLine8;
int AmLine4;
void InitAutomapOnce()
{
@ -487,11 +482,8 @@ void InitAutomapOnce()
void InitAutomap()
{
BYTE b1, b2;
DWORD dwTiles;
int x, y;
BYTE *pAFile, *pTmp;
DWORD i;
BYTE *pAFile;
memset(automaptype, 0, sizeof(automaptype));
@ -519,19 +511,19 @@ void InitAutomap()
}
dwTiles /= 2;
pTmp = pAFile;
BYTE *pTmp = pAFile;
for (i = 1; i <= dwTiles; i++) {
b1 = *pTmp++;
b2 = *pTmp++;
for (unsigned i = 1; i <= dwTiles; i++) {
uint8_t b1 = *pTmp++;
uint8_t b2 = *pTmp++;
automaptype[i] = b1 + (b2 << 8);
}
mem_free_dbg(pAFile);
memset(automapview, 0, sizeof(automapview));
for (y = 0; y < MAXDUNY; y++) {
for (x = 0; x < MAXDUNX; x++)
for (int y = 0; y < MAXDUNY; y++) {
for (int x = 0; x < MAXDUNX; x++)
dFlags[x][y] &= ~BFLAG_EXPLORED;
}
}
@ -591,12 +583,10 @@ void AutomapZoomOut()
}
}
void DrawAutomap(CelOutputBuffer out)
void DrawAutomap(const CelOutputBuffer &out)
{
int cells;
int sx, sy;
int i, j, d;
int mapx, mapy;
int sx;
int sy;
if (leveltype == DTYPE_TOWN) {
DrawAutomapText(out);
@ -617,30 +607,30 @@ void DrawAutomap(CelOutputBuffer out)
AutoMapYOfs--;
AutoMapY += AutoMapYOfs;
d = (AutoMapScale << 6) / 100;
cells = 2 * (gnScreenWidth / 2 / d) + 1;
if ((gnScreenWidth / 2) % d)
int d = (AutoMapScale << 6) / 100;
int cells = 2 * (gnScreenWidth / 2 / d) + 1;
if (((gnScreenWidth / 2) % d) != 0)
cells++;
if ((gnScreenWidth / 2) % d >= (AutoMapScale << 5) / 100)
cells++;
if (ScrollInfo._sxoff + ScrollInfo._syoff)
if ((ScrollInfo._sxoff + ScrollInfo._syoff) != 0)
cells++;
mapx = AutoMapX - cells;
mapy = AutoMapY - 1;
int mapx = AutoMapX - cells;
int mapy = AutoMapY - 1;
if (cells & 1) {
if ((cells & 1) != 0) {
sx = gnScreenWidth / 2 - AmLine64 * ((cells - 1) >> 1);
sy = (gnScreenHeight - PANEL_HEIGHT) / 2 - AmLine32 * ((cells + 1) >> 1);
} else {
sx = gnScreenWidth / 2 - AmLine64 * (cells >> 1) + AmLine32;
sy = (gnScreenHeight - PANEL_HEIGHT) / 2 - AmLine32 * (cells >> 1) - AmLine16;
}
if (ViewX & 1) {
if ((ViewX & 1) != 0) {
sx -= AmLine16;
sy -= AmLine8;
}
if (ViewY & 1) {
if ((ViewY & 1) != 0) {
sx += AmLine16;
sy -= AmLine8;
}
@ -656,12 +646,12 @@ void DrawAutomap(CelOutputBuffer out)
}
}
for (i = 0; i <= cells + 1; i++) {
for (int i = 0; i <= cells + 1; i++) {
int x = sx;
int y;
for (j = 0; j < cells; j++) {
WORD maptype = GetAutomapType(mapx + j, mapy - j, true);
for (int j = 0; j < cells; j++) {
uint16_t maptype = GetAutomapType(mapx + j, mapy - j, true);
if (maptype != 0)
DrawAutomapTile(out, x, sy, maptype);
x += AmLine64;
@ -669,8 +659,8 @@ void DrawAutomap(CelOutputBuffer out)
mapy++;
x = sx - AmLine32;
y = sy + AmLine16;
for (j = 0; j <= cells; j++) {
WORD maptype = GetAutomapType(mapx + j, mapy - j, true);
for (int j = 0; j <= cells; j++) {
uint16_t maptype = GetAutomapType(mapx + j, mapy - j, true);
if (maptype != 0)
DrawAutomapTile(out, x, y, maptype);
x += AmLine64;
@ -689,13 +679,10 @@ void DrawAutomap(CelOutputBuffer out)
DrawAutomapText(out);
}
void SetAutomapView(Sint32 x, Sint32 y)
void SetAutomapView(int x, int y)
{
WORD maptype, solid;
int xx, yy;
xx = (x - 16) >> 1;
yy = (y - 16) >> 1;
int xx = (x - 16) >> 1;
int yy = (y - 16) >> 1;
if (xx < 0 || xx >= DMAXX || yy < 0 || yy >= DMAXY) {
return;
@ -703,58 +690,58 @@ void SetAutomapView(Sint32 x, Sint32 y)
automapview[xx][yy] = true;
maptype = GetAutomapType(xx, yy, false);
solid = maptype & 0x4000;
uint16_t maptype = GetAutomapType(xx, yy, false);
uint16_t solid = maptype & 0x4000;
switch (maptype & MAPFLAG_TYPE) {
case 2:
if (solid) {
if (solid != 0) {
if (GetAutomapType(xx, yy + 1, false) == 0x4007)
automapview[xx][yy + 1] = true;
} else if (GetAutomapType(xx - 1, yy, false) & 0x4000) {
} else if ((GetAutomapType(xx - 1, yy, false) & 0x4000) != 0) {
automapview[xx - 1][yy] = true;
}
break;
case 3:
if (solid) {
if (solid != 0) {
if (GetAutomapType(xx + 1, yy, false) == 0x4007)
automapview[xx + 1][yy] = true;
} else if (GetAutomapType(xx, yy - 1, false) & 0x4000) {
} else if ((GetAutomapType(xx, yy - 1, false) & 0x4000) != 0) {
automapview[xx][yy - 1] = true;
}
break;
case 4:
if (solid) {
if (solid != 0) {
if (GetAutomapType(xx, yy + 1, false) == 0x4007)
automapview[xx][yy + 1] = true;
if (GetAutomapType(xx + 1, yy, false) == 0x4007)
automapview[xx + 1][yy] = true;
} else {
if (GetAutomapType(xx - 1, yy, false) & 0x4000)
if ((GetAutomapType(xx - 1, yy, false) & 0x4000) != 0)
automapview[xx - 1][yy] = true;
if (GetAutomapType(xx, yy - 1, false) & 0x4000)
if ((GetAutomapType(xx, yy - 1, false) & 0x4000) != 0)
automapview[xx][yy - 1] = true;
if (GetAutomapType(xx - 1, yy - 1, false) & 0x4000)
if ((GetAutomapType(xx - 1, yy - 1, false) & 0x4000) != 0)
automapview[xx - 1][yy - 1] = true;
}
break;
case 5:
if (solid) {
if (GetAutomapType(xx, yy - 1, false) & 0x4000)
if (solid != 0) {
if ((GetAutomapType(xx, yy - 1, false) & 0x4000) != 0)
automapview[xx][yy - 1] = true;
if (GetAutomapType(xx, yy + 1, false) == 0x4007)
automapview[xx][yy + 1] = true;
} else if (GetAutomapType(xx - 1, yy, false) & 0x4000) {
} else if ((GetAutomapType(xx - 1, yy, false) & 0x4000) != 0) {
automapview[xx - 1][yy] = true;
}
break;
case 6:
if (solid) {
if (GetAutomapType(xx - 1, yy, false) & 0x4000)
if (solid != 0) {
if ((GetAutomapType(xx - 1, yy, false) & 0x4000) != 0)
automapview[xx - 1][yy] = true;
if (GetAutomapType(xx + 1, yy, false) == 0x4007)
automapview[xx + 1][yy] = true;
} else if (GetAutomapType(xx, yy - 1, false) & 0x4000) {
} else if ((GetAutomapType(xx, yy - 1, false) & 0x4000) != 0) {
automapview[xx][yy - 1] = true;
}
break;

22
Source/automap.h

@ -5,6 +5,8 @@
*/
#pragma once
#include <stdint.h>
#include "engine.h"
#include "gendung.h"
@ -15,14 +17,14 @@ extern bool automapflag;
/** Tracks the explored areas of the map. */
extern bool automapview[DMAXX][DMAXY];
/** Specifies the scale of the automap. */
extern Sint32 AutoMapScale;
extern Sint32 AutoMapXOfs;
extern Sint32 AutoMapYOfs;
extern Sint32 AmLine64;
extern Sint32 AmLine32;
extern Sint32 AmLine16;
extern Sint32 AmLine8;
extern Sint32 AmLine4;
extern int AutoMapScale;
extern int AutoMapXOfs;
extern int AutoMapYOfs;
extern int AmLine64;
extern int AmLine32;
extern int AmLine16;
extern int AmLine8;
extern int AmLine4;
/**
* @brief Initializes the automap.
@ -72,12 +74,12 @@ void AutomapZoomOut();
/**
* @brief Renders the automap to the given buffer.
*/
void DrawAutomap(CelOutputBuffer out);
void DrawAutomap(const CelOutputBuffer &out);
/**
* @brief Marks the given coordinate as within view on the automap.
*/
void SetAutomapView(Sint32 x, Sint32 y);
void SetAutomapView(int x, int y);
/**
* @brief Resets the zoom level of the automap.

Loading…
Cancel
Save