Browse Source

Use explicit types instead of auto

pull/734/head
Anders Jenbo 6 years ago
parent
commit
0da3461d35
  1. 8
      Source/loadsave.cpp
  2. 6
      SourceS/file_util.h
  3. 2
      SourceX/DiabloUI/selhero.cpp
  4. 2
      SourceX/DiabloUI/text_draw.cpp
  5. 10
      SourceX/controls/plrctrls.cpp
  6. 6
      SourceX/display.cpp
  7. 4
      SourceX/display.h
  8. 2
      SourceX/miniwin/misc_msg.cpp
  9. 4
      SourceX/storm/storm.cpp

8
Source/loadsave.cpp

@ -235,8 +235,8 @@ void CopyShort(const void *src, void *dst)
void CopyShorts(const void *src, const int n, void *dst)
{
const auto *s = reinterpret_cast<const unsigned short *>(src);
auto *d = reinterpret_cast<unsigned short *>(dst);
const unsigned short *s = reinterpret_cast<const unsigned short *>(src);
unsigned short *d = reinterpret_cast<unsigned short *>(dst);
for (int i = 0; i < n; i++) {
CopyShort(s, d);
++d;
@ -255,8 +255,8 @@ void CopyInt(const void *src, void *dst)
void CopyInts(const void *src, const int n, void *dst)
{
const auto *s = reinterpret_cast<const unsigned int *>(src);
auto *d = reinterpret_cast<unsigned int *>(dst);
const unsigned int *s = reinterpret_cast<const unsigned int *>(src);
const unsigned int *d = reinterpret_cast<unsigned int *>(dst);
for (int i = 0; i < n; i++) {
CopyInt(s, (void*)d);
++d;

6
SourceS/file_util.h

@ -30,7 +30,7 @@ inline bool FileExists(const char *path)
#if _POSIX_C_SOURCE >= 200112L || defined(_BSD_SOURCE) || defined(__APPLE__)
return ::access(path, F_OK) == 0;
#else
auto *file = std::fopen(path, "rb");
FILE *file = std::fopen(path, "rb");
if (file == NULL) return false;
std::fclose(file);
return true;
@ -42,7 +42,7 @@ inline bool GetFileSize(const char *path, std::uintmax_t *size)
#if defined(_WIN64) || defined(_WIN32)
WIN32_FILE_ATTRIBUTE_DATA attr;
int path_utf16_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
auto path_utf16 = new wchar_t[path_utf16_size];
wchar_t* path_utf16 = new wchar_t[path_utf16_size];
if (MultiByteToWideChar(CP_UTF8, 0, path, -1, path_utf16, path_utf16_size) != path_utf16_size) {
delete[] path_utf16;
return false;
@ -72,7 +72,7 @@ inline bool ResizeFile(const char *path, std::uintmax_t size)
return false;
}
int path_utf16_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
auto path_utf16 = new wchar_t[path_utf16_size];
wchar_t *path_utf16 = new wchar_t[path_utf16_size];
if (MultiByteToWideChar(CP_UTF8, 0, path, -1, path_utf16, path_utf16_size) != path_utf16_size) {
delete[] path_utf16;
return false;

2
SourceX/DiabloUI/selhero.cpp

@ -460,7 +460,7 @@ const char *selhero_GenerateName(std::uint8_t hero_class)
"Horazon",
}
};
const auto seed = std::chrono::system_clock::now().time_since_epoch().count();
const int seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine generator(seed);
std::uniform_int_distribution<std::size_t> dist(0, sizeof(kNames[0]) / sizeof(kNames[0][0]) - 1);
return kNames[hero_class][dist(generator)];

2
SourceX/DiabloUI/text_draw.cpp

@ -44,7 +44,7 @@ void DrawTTF(const char *text, const SDL_Rect &rectIn, int flags,
return;
if (*render_cache == NULL) {
*render_cache = new TtfSurfaceCache();
const auto x_align = XAlignmentFromFlags(flags);
const TextAlignment x_align = XAlignmentFromFlags(flags);
(*render_cache)->text = RenderUTF8_Solid_Wrapped(font, text, text_color, rect.w, x_align);
ScaleSurfaceToOutput(&(*render_cache)->text);
(*render_cache)->shadow = RenderUTF8_Solid_Wrapped(font, text, shadow_color, rect.w, x_align);

10
SourceX/controls/plrctrls.cpp

@ -176,7 +176,7 @@ bool HasRangedSpell()
bool CanTargetMonster(int mi)
{
const auto &monst = monster[mi];
const MonsterStruct &monst = monster[mi];
if (monst._mFlags & (MFLAG_HIDDEN | MFLAG_GOLEM))
return false;
@ -200,7 +200,7 @@ void FindRangedTarget()
// The first MAX_PLRS monsters are reserved for players' golems.
for (int mi = MAX_PLRS; mi < MAXMONSTERS; mi++) {
const auto &monst = monster[mi];
const MonsterStruct &monst = monster[mi];
const int mx = monst._mfutx;
const int my = monst._mfuty;
if (!CanTargetMonster(mi))
@ -947,8 +947,8 @@ void plrctrls_after_game_logic()
void UseBeltItem(int type)
{
for (int i = 0; i < MAXBELTITEMS; i++) {
const auto id = AllItemsList[plr[myplr].SpdList[i].IDidx].iMiscId;
const auto spellId = AllItemsList[plr[myplr].SpdList[i].IDidx].iSpell;
const int id = AllItemsList[plr[myplr].SpdList[i].IDidx].iMiscId;
const int spellId = AllItemsList[plr[myplr].SpdList[i].IDidx].iSpell;
if ((type == BLT_HEALING && (id == IMISC_HEAL || id == IMISC_FULLHEAL || (id == IMISC_SCROLL && spellId == SPL_HEAL)))
|| (type == BLT_MANA && (id == IMISC_MANA || id == IMISC_FULLMANA))
|| id == IMISC_REJUV || id == IMISC_FULLREJUV) {
@ -1017,7 +1017,7 @@ void UpdateSpellTarget()
pcursplr = -1;
pcursmonst = -1;
const auto &player = plr[myplr];
const PlayerStruct &player = plr[myplr];
int range = 1;
if (plr[myplr]._pRSpell == SPL_TELEPORT)

6
SourceX/display.cpp

@ -27,7 +27,7 @@ extern SDL_Surface *renderer_texture_surface; /** defined in dx.cpp */
void SetVideoMode(int width, int height, int bpp, uint32_t flags) {
SDL_Log("Setting video mode %dx%d bpp=%u flags=0x%08X", width, height, bpp, flags);
SDL_SetVideoMode(width, height, bpp, flags);
const auto &current = *SDL_GetVideoInfo();
const SDL_VideoInfo &current = *SDL_GetVideoInfo();
SDL_Log("Video mode is now %dx%d bpp=%u flags=0x%08X",
current.current_w, current.current_h, current.vfmt->BitsPerPixel, SDL_GetVideoSurface()->flags);
ghMainWnd = SDL_GetVideoSurface();
@ -70,7 +70,7 @@ bool SpawnWindow(const char *lpWindowName, int nWidth, int nHeight)
#ifdef USE_SDL1
SDL_WM_SetCaption(lpWindowName, WINDOW_ICON_NAME);
const auto &best = *SDL_GetVideoInfo();
const SDL_VideoInfo &best = *SDL_GetVideoInfo();
SDL_Log("Best video mode reported as: %dx%d bpp=%d hw_available=%u",
best.current_w, best.current_h, best.vfmt->BitsPerPixel, best.hw_available);
SetVideoModeToPrimary(fullscreen);
@ -159,7 +159,7 @@ void ScaleOutputRect(SDL_Rect *rect)
{
if (!OutputRequiresScaling())
return;
const auto *surface = GetOutputSurface();
const SDL_Surface *surface = GetOutputSurface();
rect->x = rect->x * surface->w / SCREEN_WIDTH;
rect->y = rect->y * surface->h / SCREEN_HEIGHT;
rect->w = rect->w * surface->w / SCREEN_WIDTH;

4
SourceX/display.h

@ -60,7 +60,7 @@ void OutputToLogical(T *x, T *y)
#else
if (!OutputRequiresScaling())
return;
const auto *surface = GetOutputSurface();
const SDL_Surface *surface = GetOutputSurface();
*x = *x * SCREEN_WIDTH / surface->w;
*y = *y * SCREEN_HEIGHT / surface->h;
#endif
@ -86,7 +86,7 @@ void LogicalToOutput(T *x, T *y)
#else
if (!OutputRequiresScaling())
return;
const auto *surface = GetOutputSurface();
const SDL_Surface *surface = GetOutputSurface();
*x = *x * surface->w / SCREEN_WIDTH;
*y = *y * surface->h / SCREEN_HEIGHT;
#endif

2
SourceX/miniwin/misc_msg.cpp

@ -74,7 +74,7 @@ void FocusOnCharInfo()
}
if (stat == -1)
return;
const auto &rect = ChrBtnsRect[stat];
const RECT32 &rect = ChrBtnsRect[stat];
SetCursorPos(rect.x + (rect.w / 2), rect.y + (rect.h / 2));
}

4
SourceX/storm/storm.cpp

@ -600,7 +600,7 @@ void SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HA
#else
// Set the video mode close to the SVid resolution while preserving aspect ratio.
{
const auto *display = SDL_GetVideoSurface();
const SDL_Surface *display = SDL_GetVideoSurface();
IsSVidVideoMode = (display->flags & (SDL_FULLSCREEN | SDL_NOFRAME)) != 0;
if (IsSVidVideoMode) {
int w, h;
@ -710,7 +710,7 @@ BOOL SVidPlayContinue(void)
} else
#endif
{
auto *output_surface = GetOutputSurface();
SDL_Surface *output_surface = GetOutputSurface();
int factor;
int wFactor = output_surface->w / SVidWidth;
int hFactor = output_surface->h / SVidHeight;

Loading…
Cancel
Save