Browse Source

Fully apply clang-tidy/format to all files

pull/2296/head
Anders Jenbo 5 years ago
parent
commit
a7c7fa0030
  1. 2
      Source/DiabloUI/dialogs.cpp
  2. 2
      Source/DiabloUI/dialogs.h
  3. 2
      Source/controls/keymapper.cpp
  4. 2
      Source/diablo.cpp
  5. 8
      Source/diablo.h
  6. 12
      Source/drlg_l1.cpp
  7. 16
      Source/dthread.cpp
  8. 3
      Source/engine/random.hpp
  9. 6
      Source/engine/surface.hpp
  10. 16
      Source/init.cpp
  11. 10
      Source/interfac.cpp
  12. 8
      Source/itemdat.h
  13. 22
      Source/items.cpp
  14. 134
      Source/lighting.cpp
  15. 24
      Source/loadsave.cpp
  16. 16
      Source/missiles.cpp
  17. 4
      Source/missiles.h
  18. 1707
      Source/monster.cpp
  19. 8
      Source/movie.cpp
  20. 70
      Source/mpqapi.cpp
  21. 6
      Source/msg.cpp
  22. 38
      Source/multi.cpp
  23. 4
      Source/nthread.cpp
  24. 112
      Source/objects.cpp
  25. 24
      Source/palette.cpp
  26. 98
      Source/path.cpp
  27. 66
      Source/pfile.cpp
  28. 2
      Source/platform/ctr/asio/sys/socket.c
  29. 4
      Source/platform/switch/asio/sys/signal.c
  30. 8
      Source/player.cpp
  31. 8
      Source/plrmsg.cpp
  32. 6
      Source/qol/xpbar.cpp
  33. 50
      Source/scrollrt.cpp
  34. 82
      Source/sha.cpp
  35. 6
      Source/sound.cpp
  36. 12
      Source/storm/storm_svid.cpp
  37. 2
      Source/towners.h
  38. 6
      Source/track.cpp
  39. 32
      Source/utils/log.hpp

2
Source/DiabloUI/dialogs.cpp

@ -299,7 +299,7 @@ void UiErrorOkDialog(const char *text, const char *caption, bool error)
UiOkDialog(text, caption, error, vecNULL);
}
void UiErrorOkDialog(const char *text, const std::vector<UiItemBase *>& renderBehind)
void UiErrorOkDialog(const char *text, const std::vector<UiItemBase *> &renderBehind)
{
UiErrorOkDialog(text, nullptr, renderBehind);
}

2
Source/DiabloUI/dialogs.h

@ -6,7 +6,7 @@
namespace devilution {
void UiErrorOkDialog(const char *text, const std::vector<UiItemBase *>& renderBehind);
void UiErrorOkDialog(const char *text, const std::vector<UiItemBase *> &renderBehind);
void UiErrorOkDialog(const char *text, const char *caption, const std::vector<UiItemBase *> &renderBehind);
void UiOkDialog(const char *text, const char *caption, bool error, const std::vector<UiItemBase *> &renderBehind);

2
Source/controls/keymapper.cpp

@ -2,7 +2,7 @@
#include <cassert>
#include <fmt/format.h>
#include <utility>
#include <utility>
#include <SDL.h>

2
Source/diablo.cpp

@ -410,7 +410,7 @@ static void RunGameLoop(interface_mode uMsg)
}
if (gbIsMultiplayer) {
pfile_write_hero(/*write_game_data=*/false, /*clear_tables=*/true);
pfile_write_hero(/*writeGameData=*/false, /*clearTables=*/true);
}
PaletteFadeOut(8);

8
Source/diablo.h

@ -101,10 +101,10 @@ extern int debug_mode_key_j;
#endif
struct QuickMessage {
/** Config variable names for quick message */
const char *const key;
/** Default quick message */
const char *const message;
/** Config variable names for quick message */
const char *const key;
/** Default quick message */
const char *const message;
};
constexpr size_t QUICK_MESSAGE_OPTIONS = 4;

12
Source/drlg_l1.cpp

@ -1483,12 +1483,12 @@ static void L5makeDungeon()
{
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
int i_2 = i * 2;
int j_2 = j * 2;
L5dungeon[i_2][j_2] = dungeon[i][j];
L5dungeon[i_2][j_2 + 1] = dungeon[i][j];
L5dungeon[i_2 + 1][j_2] = dungeon[i][j];
L5dungeon[i_2 + 1][j_2 + 1] = dungeon[i][j];
int i2 = i * 2;
int j2 = j * 2;
L5dungeon[i2][j2] = dungeon[i][j];
L5dungeon[i2][j2 + 1] = dungeon[i][j];
L5dungeon[i2 + 1][j2] = dungeon[i][j];
L5dungeon[i2 + 1][j2 + 1] = dungeon[i][j];
}
}
}

16
Source/dthread.cpp

@ -21,14 +21,14 @@ static SDL_Thread *sghThread = nullptr;
static unsigned int DthreadHandler(void * /*data*/)
{
const char *error_buf;
const char *errorBuf;
TMegaPkt *pkt;
DWORD dwMilliseconds;
while (dthread_running) {
if (sgpInfoHead == nullptr && WaitForEvent(sghWorkToDoEvent) == -1) {
error_buf = SDL_GetError();
app_fatal("dthread4:\n%s", error_buf);
errorBuf = SDL_GetError();
app_fatal("dthread4:\n%s", errorBuf);
}
sgMemCrit.Enter();
@ -97,7 +97,7 @@ void dthread_send_delta(int pnum, _cmd_id cmd, byte *pbSrc, int dwLen)
void dthread_start()
{
const char *error_buf;
const char *errorBuf;
if (!gbIsMultiplayer) {
return;
@ -105,16 +105,16 @@ void dthread_start()
sghWorkToDoEvent = StartEvent();
if (sghWorkToDoEvent == nullptr) {
error_buf = SDL_GetError();
app_fatal("dthread:1\n%s", error_buf);
errorBuf = SDL_GetError();
app_fatal("dthread:1\n%s", errorBuf);
}
dthread_running = true;
sghThread = CreateThread(DthreadHandler, &glpDThreadId);
if (sghThread == nullptr) {
error_buf = SDL_GetError();
app_fatal("dthread2:\n%s", error_buf);
errorBuf = SDL_GetError();
app_fatal("dthread2:\n%s", errorBuf);
}
}

3
Source/engine/random.hpp

@ -9,8 +9,7 @@
#include <cstdint>
namespace devilution
{
namespace devilution {
/**
* @brief Set the state of the RandomNumberEngine used by the base game to the specific seed

6
Source/engine/surface.hpp

@ -44,7 +44,7 @@ struct Surface {
}
Surface(const Surface &other) = default;
Surface& operator=(const Surface &other) = default;
Surface &operator=(const Surface &other) = default;
/**
* @brief Allocate a buffer that owns its underlying data.
@ -132,8 +132,8 @@ struct Surface {
Surface subregionY(int y, int h) const
{
SDL_Rect subregion = region;
subregion.y += static_cast<decltype(SDL_Rect{}.y)>(y);
subregion.h = static_cast<decltype(SDL_Rect{}.h)>(h);
subregion.y += static_cast<decltype(SDL_Rect {}.y)>(y);
subregion.h = static_cast<decltype(SDL_Rect {}.h)>(h);
return Surface(surface, subregion);
}

16
Source/init.cpp

@ -56,16 +56,16 @@ namespace {
HANDLE LoadMPQ(const std::vector<std::string> &paths, const char *mpqName)
{
HANDLE archive;
std::string mpq_abspath;
std::string mpqAbsPath;
for (const auto &path : paths) {
mpq_abspath = path + mpqName;
if (SFileOpenArchive(mpq_abspath.c_str(), 0, MPQ_OPEN_READ_ONLY, &archive)) {
mpqAbsPath = path + mpqName;
if (SFileOpenArchive(mpqAbsPath.c_str(), 0, MPQ_OPEN_READ_ONLY, &archive)) {
LogVerbose(" Found: {} in {}", mpqName, path);
SFileSetBasePath(path.c_str());
return archive;
}
if (SErrGetLastError() != STORM_ERROR_FILE_NOT_FOUND) {
LogError("Open error {}: {}", SErrGetLastError(), mpq_abspath);
LogError("Open error {}: {}", SErrGetLastError(), mpqAbsPath);
}
}
if (SErrGetLastError() == STORM_ERROR_FILE_NOT_FOUND) {
@ -80,7 +80,7 @@ HANDLE LoadMPQ(const std::vector<std::string> &paths, const char *mpqName)
void init_cleanup()
{
if (gbIsMultiplayer && gbRunGame) {
pfile_write_hero(/*write_game_data=*/false, /*clear_tables=*/true);
pfile_write_hero(/*writeGameData=*/false, /*clearTables=*/true);
}
if (spawn_mpq != nullptr) {
@ -242,11 +242,11 @@ void MainWndProc(uint32_t msg)
WNDPROC SetWindowProc(WNDPROC newProc)
{
WNDPROC OldProc;
WNDPROC oldProc;
OldProc = CurrentProc;
oldProc = CurrentProc;
CurrentProc = newProc;
return OldProc;
return oldProc;
}
} // namespace devilution

10
Source/interfac.cpp

@ -189,12 +189,12 @@ static void DrawCutscene()
void interface_msg_pump()
{
tagMSG Msg;
tagMSG msg;
while (FetchMessage(&Msg)) {
if (Msg.message != DVL_WM_QUIT) {
TranslateMessage(&Msg);
PushMessage(&Msg);
while (FetchMessage(&msg)) {
if (msg.message != DVL_WM_QUIT) {
TranslateMessage(&msg);
PushMessage(&msg);
}
}
}

8
Source/itemdat.h

@ -497,10 +497,10 @@ enum item_effect_type : int8_t {
IPL_THORNS,
IPL_NOMANA,
IPL_NOHEALPLR, // unused
IPL_0x30, // Unknown
IPL_0x31, // Unknown
IPL_FIREBALL, /* only used in hellfire */
IPL_0x33, // Unknown
IPL_0x30, // Unknown
IPL_0x31, // Unknown
IPL_FIREBALL, /* only used in hellfire */
IPL_0x33, // Unknown
IPL_ABSHALFTRAP,
IPL_KNOCKBACK,
IPL_NOHEALMON, // unused

22
Source/items.cpp

@ -376,22 +376,22 @@ bool IsUniqueAvailable(int i)
static bool IsPrefixValidForItemType(int i, int flgs)
{
int PLIType = PL_Prefix[i].PLIType;
int itemTypes = PL_Prefix[i].PLIType;
if (!gbIsHellfire) {
if (i > 82)
return false;
if (i >= 12 && i <= 20)
PLIType &= ~PLT_STAFF;
itemTypes &= ~PLT_STAFF;
}
return (flgs & PLIType) != 0;
return (flgs & itemTypes) != 0;
}
static bool IsSuffixValidForItemType(int i, int flgs)
{
int PLIType = PL_Suffix[i].PLIType;
int itemTypes = PL_Suffix[i].PLIType;
if (!gbIsHellfire) {
if (i > 94)
@ -403,17 +403,15 @@ static bool IsSuffixValidForItemType(int i, int flgs)
|| (i >= 34 && i <= 36)
|| (i >= 41 && i <= 44)
|| (i >= 60 && i <= 63))
PLIType &= ~PLT_STAFF;
itemTypes &= ~PLT_STAFF;
}
return (flgs & PLIType) != 0;
return (flgs & itemTypes) != 0;
}
int items_get_currlevel()
{
int lvl;
lvl = currlevel;
int lvl = currlevel;
if (currlevel >= 17 && currlevel <= 20)
lvl = currlevel - 8;
if (currlevel >= 21 && currlevel <= 24)
@ -2747,7 +2745,7 @@ void hex2bin(const char *src, int bytes, char *target)
void CornerstoneLoad(Point position)
{
PkItemStruct PkSItem;
PkItemStruct pkSItem;
if (CornerStone.activated || position.x == 0 || position.y == 0) {
return;
@ -2769,13 +2767,13 @@ void CornerstoneLoad(Point position)
if (strlen(sgOptions.Hellfire.szItem) < sizeof(PkItemStruct) * 2)
return;
hex2bin(sgOptions.Hellfire.szItem, sizeof(PkItemStruct), (char *)&PkSItem);
hex2bin(sgOptions.Hellfire.szItem, sizeof(PkItemStruct), (char *)&pkSItem);
int ii = AllocateItem();
dItem[position.x][position.y] = ii + 1;
UnPackItem(&PkSItem, &items[ii], (PkSItem.dwBuff & CF_HELLFIRE) != 0);
UnPackItem(&pkSItem, &items[ii], (pkSItem.dwBuff & CF_HELLFIRE) != 0);
items[ii].position = position;
RespawnItem(&items[ii], false);
CornerStone.item = items[ii];

134
Source/lighting.cpp

@ -495,10 +495,10 @@ void DoLighting(Point position, int nRadius, int lnum)
{
int xoff = 0;
int yoff = 0;
int light_x = 0;
int light_y = 0;
int block_x = 0;
int block_y = 0;
int lightX = 0;
int lightY = 0;
int blockX = 0;
int blockY = 0;
if (lnum >= 0) {
xoff = LightList[lnum].position.offset.x;
@ -513,24 +513,24 @@ void DoLighting(Point position, int nRadius, int lnum)
}
}
int dist_x = xoff;
int dist_y = yoff;
int distX = xoff;
int distY = yoff;
int min_x = 15;
int minX = 15;
if (position.x - 15 < 0) {
min_x = position.x + 1;
minX = position.x + 1;
}
int max_x = 15;
int maxX = 15;
if (position.x + 15 > MAXDUNX) {
max_x = MAXDUNX - position.x;
maxX = MAXDUNX - position.x;
}
int min_y = 15;
int minY = 15;
if (position.y - 15 < 0) {
min_y = position.y + 1;
minY = position.y + 1;
}
int max_y = 15;
int maxY = 15;
if (position.y + 15 > MAXDUNY) {
max_y = MAXDUNY - position.y;
maxY = MAXDUNY - position.y;
}
if (position.x >= 0 && position.x < MAXDUNX && position.y >= 0 && position.y < MAXDUNY) {
@ -542,61 +542,61 @@ void DoLighting(Point position, int nRadius, int lnum)
}
int mult = xoff + 8 * yoff;
for (int y = 0; y < min_y; y++) {
for (int x = 1; x < max_x; x++) {
int radius_block = lightblock[mult][y][x];
if (radius_block < 128) {
int temp_x = position.x + x;
int temp_y = position.y + y;
int v = lightradius[nRadius][radius_block];
if (temp_x >= 0 && temp_x < MAXDUNX && temp_y >= 0 && temp_y < MAXDUNY)
if (v < GetLight(temp_x, temp_y))
SetLight(temp_x, temp_y, v);
for (int y = 0; y < minY; y++) {
for (int x = 1; x < maxX; x++) {
int radiusBlock = lightblock[mult][y][x];
if (radiusBlock < 128) {
int tempX = position.x + x;
int tempY = position.y + y;
int v = lightradius[nRadius][radiusBlock];
if (tempX >= 0 && tempX < MAXDUNX && tempY >= 0 && tempY < MAXDUNY)
if (v < GetLight(tempX, tempY))
SetLight(tempX, tempY, v);
}
}
}
RotateRadius(&xoff, &yoff, &dist_x, &dist_y, &light_x, &light_y, &block_x, &block_y);
RotateRadius(&xoff, &yoff, &distX, &distY, &lightX, &lightY, &blockX, &blockY);
mult = xoff + 8 * yoff;
for (int y = 0; y < max_y; y++) {
for (int x = 1; x < max_x; x++) {
int radius_block = lightblock[mult][y + block_y][x + block_x];
if (radius_block < 128) {
int temp_x = position.x + y;
int temp_y = position.y - x;
int v = lightradius[nRadius][radius_block];
if (temp_x >= 0 && temp_x < MAXDUNX && temp_y >= 0 && temp_y < MAXDUNY)
if (v < GetLight(temp_x, temp_y))
SetLight(temp_x, temp_y, v);
for (int y = 0; y < maxY; y++) {
for (int x = 1; x < maxX; x++) {
int radiusBlock = lightblock[mult][y + blockY][x + blockX];
if (radiusBlock < 128) {
int tempX = position.x + y;
int tempY = position.y - x;
int v = lightradius[nRadius][radiusBlock];
if (tempX >= 0 && tempX < MAXDUNX && tempY >= 0 && tempY < MAXDUNY)
if (v < GetLight(tempX, tempY))
SetLight(tempX, tempY, v);
}
}
}
RotateRadius(&xoff, &yoff, &dist_x, &dist_y, &light_x, &light_y, &block_x, &block_y);
RotateRadius(&xoff, &yoff, &distX, &distY, &lightX, &lightY, &blockX, &blockY);
mult = xoff + 8 * yoff;
for (int y = 0; y < max_y; y++) {
for (int x = 1; x < min_x; x++) {
int radius_block = lightblock[mult][y + block_y][x + block_x];
if (radius_block < 128) {
int temp_x = position.x - x;
int temp_y = position.y - y;
int v = lightradius[nRadius][radius_block];
if (temp_x >= 0 && temp_x < MAXDUNX && temp_y >= 0 && temp_y < MAXDUNY)
if (v < GetLight(temp_x, temp_y))
SetLight(temp_x, temp_y, v);
for (int y = 0; y < maxY; y++) {
for (int x = 1; x < minX; x++) {
int radiusBlock = lightblock[mult][y + blockY][x + blockX];
if (radiusBlock < 128) {
int tempX = position.x - x;
int tempY = position.y - y;
int v = lightradius[nRadius][radiusBlock];
if (tempX >= 0 && tempX < MAXDUNX && tempY >= 0 && tempY < MAXDUNY)
if (v < GetLight(tempX, tempY))
SetLight(tempX, tempY, v);
}
}
}
RotateRadius(&xoff, &yoff, &dist_x, &dist_y, &light_x, &light_y, &block_x, &block_y);
RotateRadius(&xoff, &yoff, &distX, &distY, &lightX, &lightY, &blockX, &blockY);
mult = xoff + 8 * yoff;
for (int y = 0; y < min_y; y++) {
for (int x = 1; x < min_x; x++) {
int radius_block = lightblock[mult][y + block_y][x + block_x];
if (radius_block < 128) {
int temp_x = position.x - y;
int temp_y = position.y + x;
int v = lightradius[nRadius][radius_block];
if (temp_x >= 0 && temp_x < MAXDUNX && temp_y >= 0 && temp_y < MAXDUNY)
if (v < GetLight(temp_x, temp_y))
SetLight(temp_x, temp_y, v);
for (int y = 0; y < minY; y++) {
for (int x = 1; x < minX; x++) {
int radiusBlock = lightblock[mult][y + blockY][x + blockX];
if (radiusBlock < 128) {
int tempX = position.x - y;
int tempY = position.y + x;
int v = lightradius[nRadius][radiusBlock];
if (tempX >= 0 && tempX < MAXDUNX && tempY >= 0 && tempY < MAXDUNY)
if (v < GetLight(tempX, tempY))
SetLight(tempX, tempY, v);
}
}
}
@ -606,18 +606,18 @@ void DoUnLight(int nXPos, int nYPos, int nRadius)
{
nRadius++;
int min_x = nXPos - nRadius;
int max_x = nXPos + nRadius;
int min_y = nYPos - nRadius;
int max_y = nYPos + nRadius;
int minX = nXPos - nRadius;
int maxX = nXPos + nRadius;
int minY = nYPos - nRadius;
int maxY = nYPos + nRadius;
min_x = std::max(min_x, 0);
max_x = std::max(max_x, MAXDUNX);
min_y = std::max(min_y, 0);
max_y = std::max(max_y, MAXDUNY);
minX = std::max(minX, 0);
maxX = std::max(maxX, MAXDUNX);
minY = std::max(minY, 0);
maxY = std::max(maxY, MAXDUNY);
for (int y = min_y; y < max_y; y++) {
for (int x = min_x; x < max_x; x++) {
for (int y = minY; y < maxY; y++) {
for (int x = minX; x < maxX; x++) {
if (x >= 0 && x < MAXDUNX && y >= 0 && y < MAXDUNY)
dLight[x][y] = dPreLight[x][y];
}

24
Source/loadsave.cpp

@ -187,10 +187,10 @@ public:
~SaveHelper()
{
const auto encoded_len = codec_get_encoded_len(m_cur_);
const auto encodedLen = codec_get_encoded_len(m_cur_);
const char *const password = pfile_get_password();
codec_encode(m_buffer_.get(), m_cur_, encoded_len, password);
mpqapi_write_file(m_szFileName_, m_buffer_.get(), encoded_len);
codec_encode(m_buffer_.get(), m_cur_, encodedLen, password);
mpqapi_write_file(m_szFileName_, m_buffer_.get(), encodedLen);
}
};
@ -361,7 +361,7 @@ static void LoadPlayer(LoadHelper *file, int p)
file->Skip(2); // Alignment
player._pTSpell = static_cast<spell_id>(file->NextLE<int32_t>());
file->Skip(sizeof(int8_t)); // Skip _pTSplType
file->Skip(3); // Alignment
file->Skip(3); // Alignment
player._pRSpell = static_cast<spell_id>(file->NextLE<int32_t>());
player._pRSplType = static_cast<spell_type>(file->NextLE<int8_t>());
file->Skip(3); // Alignment
@ -1189,8 +1189,8 @@ void LoadGame(bool firstflag)
itemId = file.NextLE<int8_t>();
for (int i = 0; i < numitems; i++)
LoadItem(&file, itemactive[i]);
for (bool &UniqueItemFlag : UniqueItemFlags)
UniqueItemFlag = file.NextBool8();
for (bool &uniqueItemFlag : UniqueItemFlags)
uniqueItemFlag = file.NextBool8();
for (int j = 0; j < MAXDUNY; j++) {
for (int i = 0; i < MAXDUNX; i++) // NOLINT(modernize-loop-convert)
@ -1427,7 +1427,7 @@ static void SavePlayer(SaveHelper *file, int p)
file->Skip(2); // Alignment
file->WriteLE<int32_t>(player._pTSpell);
file->Skip(sizeof(int8_t)); // Skip _pTSplType
file->Skip(3); // Alignment
file->Skip(3); // Alignment
file->WriteLE<int32_t>(player._pRSpell);
file->WriteLE<int8_t>(player._pRSplType);
file->Skip(3); // Alignment
@ -1955,8 +1955,8 @@ void SaveGameData()
file.WriteLE<int8_t>(itemId);
for (int i = 0; i < numitems; i++)
SaveItem(&file, &items[itemactive[i]]);
for (bool UniqueItemFlag : UniqueItemFlags)
file.WriteLE<uint8_t>(UniqueItemFlag ? 1 : 0);
for (bool uniqueItemFlag : UniqueItemFlags)
file.WriteLE<uint8_t>(uniqueItemFlag ? 1 : 0);
for (int j = 0; j < MAXDUNY; j++) {
for (int i = 0; i < MAXDUNX; i++) // NOLINT(modernize-loop-convert)
@ -2019,12 +2019,12 @@ void SaveGameData()
void SaveGame()
{
gbValidSaveFile = true;
pfile_write_hero(/*write_game_data=*/true);
pfile_write_hero(/*writeGameData=*/true);
}
void SaveLevel()
{
PFileScopedArchiveWriter scoped_writer;
PFileScopedArchiveWriter scopedWriter;
DoUnVision(plr[myplr].position.tile, plr[myplr]._pLightRad); // fix for vision staying on the level
@ -2185,7 +2185,7 @@ void LoadLevel()
}
for (int j = 0; j < MAXDUNY; j++) {
for (int i = 0; i < MAXDUNX; i++) // NOLINT(modernize-loop-convert)
dMissile[i][j] = 0; /// BUGFIX: supposed to load saved missiles with "file.NextLE<int8_t>()"?
dMissile[i][j] = 0; /// BUGFIX: supposed to load saved missiles with "file.NextLE<int8_t>()"?
}
}

16
Source/missiles.cpp

@ -1683,21 +1683,21 @@ void AddMana(int mi, Point /*src*/, Point /*dst*/, int /*midir*/, int8_t /*miene
{
auto &player = plr[id];
int ManaAmount = (GenerateRnd(10) + 1) << 6;
int manaAmount = (GenerateRnd(10) + 1) << 6;
for (int i = 0; i < player._pLevel; i++) {
ManaAmount += (GenerateRnd(4) + 1) << 6;
manaAmount += (GenerateRnd(4) + 1) << 6;
}
for (int i = 0; i < missile[mi]._mispllvl; i++) {
ManaAmount += (GenerateRnd(6) + 1) << 6;
manaAmount += (GenerateRnd(6) + 1) << 6;
}
if (player._pClass == HeroClass::Sorcerer)
ManaAmount *= 2;
manaAmount *= 2;
if (player._pClass == HeroClass::Rogue || player._pClass == HeroClass::Bard)
ManaAmount += ManaAmount / 2;
player._pMana += ManaAmount;
manaAmount += manaAmount / 2;
player._pMana += manaAmount;
if (player._pMana > player._pMaxMana)
player._pMana = player._pMaxMana;
player._pManaBase += ManaAmount;
player._pManaBase += manaAmount;
if (player._pManaBase > player._pMaxManaBase)
player._pManaBase = player._pMaxManaBase;
UseMana(id, SPL_MANA);
@ -4154,7 +4154,7 @@ void MI_Blood(int i)
void MI_Weapexp(int i)
{
int ExpLight[10] = { 9, 10, 11, 12, 11, 10, 8, 6, 4, 2 };
constexpr int ExpLight[10] = { 9, 10, 11, 12, 11, 10, 8, 6, 4, 2 };
missile[i]._mirange--;
int id = missile[i]._misource;

4
Source/missiles.h

@ -35,7 +35,6 @@ struct MissilePosition {
Displacement traveled;
};
/*
* W sW SW Sw S
* ^
@ -47,8 +46,7 @@ struct MissilePosition {
* |
* N Ne NE nE E
*/
enum Direction16
{
enum Direction16 {
DIR16_S,
DIR16_Sw,
DIR16_SW,

1707
Source/monster.cpp

File diff suppressed because it is too large Load Diff

8
Source/movie.cpp

@ -37,14 +37,14 @@ void play_movie(const char *pszMovie, bool userCanClose)
#endif
if (SVidPlayBegin(pszMovie, loop_movie ? 0x100C0808 : 0x10280808)) {
tagMSG Msg;
tagMSG msg;
while (movie_playing) {
while (movie_playing && FetchMessage(&Msg)) {
switch (Msg.message) {
while (movie_playing && FetchMessage(&msg)) {
switch (msg.message) {
case DVL_WM_KEYDOWN:
case DVL_WM_LBUTTONDOWN:
case DVL_WM_RBUTTONDOWN:
if (userCanClose || (Msg.message == DVL_WM_KEYDOWN && Msg.wParam == DVL_VK_ESCAPE))
if (userCanClose || (msg.message == DVL_WM_KEYDOWN && msg.wParam == DVL_VK_ESCAPE))
movie_playing = false;
break;
case DVL_WM_QUIT:

70
Source/mpqapi.cpp

@ -158,12 +158,12 @@ private:
bool CheckError(const char *fmt, PrintFArgs... args)
{
if (s_->fail()) {
std::string fmt_with_error = fmt;
fmt_with_error.append(": failed with \"{}\"");
const char *error_message = std::strerror(errno);
if (error_message == nullptr)
error_message = "";
LogError(LogCategory::System, fmt_with_error.c_str(), args..., error_message);
std::string fmtWithError = fmt;
fmtWithError.append(": failed with \"{}\"");
const char *errorMessage = std::strerror(errno);
if (errorMessage == nullptr)
errorMessage = "";
LogError(LogCategory::System, fmtWithError.c_str(), args..., errorMessage);
#ifdef _DEBUG
} else {
LogVerbose(LogCategory::System, fmt, args...);
@ -338,13 +338,13 @@ bool IsValidMPQHeader(const Archive &archive, _FILEHEADER *hdr)
bool ReadMPQHeader(Archive *archive, _FILEHEADER *hdr)
{
const bool has_hdr = archive->size >= sizeof(*hdr);
if (has_hdr) {
const bool hasHdr = archive->size >= sizeof(*hdr);
if (hasHdr) {
if (!archive->stream.Read(reinterpret_cast<char *>(hdr), sizeof(*hdr)))
return false;
ByteSwapHdr(hdr);
}
if (!has_hdr || !IsValidMPQHeader(*archive, hdr)) {
if (!hasHdr || !IsValidMPQHeader(*archive, hdr)) {
InitDefaultMpqHeader(archive, hdr);
}
return true;
@ -509,19 +509,19 @@ bool WriteFileContents(const char *pszName, const byte *pbData, size_t dwLen, _B
Hash(pszName, 3);
constexpr size_t SectorSize = 4096;
const uint32_t num_sectors = (dwLen + (SectorSize - 1)) / SectorSize;
const uint32_t offset_table_bytesize = sizeof(uint32_t) * (num_sectors + 1);
pBlk->offset = FindFreeBlock(dwLen + offset_table_bytesize, &pBlk->sizealloc);
const uint32_t numSectors = (dwLen + (SectorSize - 1)) / SectorSize;
const uint32_t offsetTableByteSize = sizeof(uint32_t) * (numSectors + 1);
pBlk->offset = FindFreeBlock(dwLen + offsetTableByteSize, &pBlk->sizealloc);
pBlk->sizefile = dwLen;
pBlk->flags = 0x80000100;
// We populate the table of sector offset while we write the data.
// We can't pre-populate it because we don't know the compressed sector sizes yet.
// First offset is the start of the first sector, last offset is the end of the last sector.
std::unique_ptr<uint32_t[]> sectoroffsettable { new uint32_t[num_sectors + 1] };
std::unique_ptr<uint32_t[]> sectoroffsettable { new uint32_t[numSectors + 1] };
#ifdef CAN_SEEKP_BEYOND_EOF
if (!cur_archive.stream.Seekp(pBlk->offset + offset_table_bytesize, std::ios::beg))
if (!cur_archive.stream.Seekp(pBlk->offset + offsetTableByteSize, std::ios::beg))
return false;
#else
// Ensure we do not Seekp beyond EOF by filling the missing space.
@ -529,31 +529,31 @@ bool WriteFileContents(const char *pszName, const byte *pbData, size_t dwLen, _B
if (!cur_archive.stream.Seekp(0, std::ios::end) || !cur_archive.stream.Tellp(&stream_end))
return false;
const std::uintmax_t cur_size = stream_end - cur_archive.stream_begin;
if (cur_size < pBlk->offset + offset_table_bytesize) {
if (cur_size < pBlk->offset + offsetTableByteSize) {
if (cur_size < pBlk->offset) {
std::unique_ptr<char[]> filler { new char[pBlk->offset - cur_size] };
if (!cur_archive.stream.Write(filler.get(), pBlk->offset - cur_size))
return false;
}
if (!cur_archive.stream.Write(reinterpret_cast<const char *>(sectoroffsettable.get()), offset_table_bytesize))
if (!cur_archive.stream.Write(reinterpret_cast<const char *>(sectoroffsettable.get()), offsetTableByteSize))
return false;
} else {
if (!cur_archive.stream.Seekp(pBlk->offset + offset_table_bytesize, std::ios::beg))
if (!cur_archive.stream.Seekp(pBlk->offset + offsetTableByteSize, std::ios::beg))
return false;
}
#endif
uint32_t destsize = offset_table_bytesize;
byte mpq_buf[SectorSize];
std::size_t cur_sector = 0;
uint32_t destsize = offsetTableByteSize;
byte mpqBuf[SectorSize];
std::size_t curSector = 0;
while (true) {
uint32_t len = std::min(dwLen, SectorSize);
memcpy(mpq_buf, pbData, len);
memcpy(mpqBuf, pbData, len);
pbData += len;
len = PkwareCompress(mpq_buf, len);
if (!cur_archive.stream.Write((char *)mpq_buf, len))
len = PkwareCompress(mpqBuf, len);
if (!cur_archive.stream.Write((char *)mpqBuf, len))
return false;
sectoroffsettable[cur_sector++] = SDL_SwapLE32(destsize);
sectoroffsettable[curSector++] = SDL_SwapLE32(destsize);
destsize += len; // compressed length
if (dwLen > SectorSize)
dwLen -= SectorSize;
@ -561,19 +561,19 @@ bool WriteFileContents(const char *pszName, const byte *pbData, size_t dwLen, _B
break;
}
sectoroffsettable[num_sectors] = SDL_SwapLE32(destsize);
sectoroffsettable[numSectors] = SDL_SwapLE32(destsize);
if (!cur_archive.stream.Seekp(pBlk->offset, std::ios::beg))
return false;
if (!cur_archive.stream.Write(reinterpret_cast<const char *>(sectoroffsettable.get()), offset_table_bytesize))
if (!cur_archive.stream.Write(reinterpret_cast<const char *>(sectoroffsettable.get()), offsetTableByteSize))
return false;
if (!cur_archive.stream.Seekp(destsize - offset_table_bytesize, std::ios::cur))
if (!cur_archive.stream.Seekp(destsize - offsetTableByteSize, std::ios::cur))
return false;
if (destsize < pBlk->sizealloc) {
const uint32_t block_size = pBlk->sizealloc - destsize;
if (block_size >= 1024) {
const uint32_t blockSize = pBlk->sizealloc - destsize;
if (blockSize >= 1024) {
pBlk->sizealloc = destsize;
AllocBlock(pBlk->sizealloc + pBlk->offset, block_size);
AllocBlock(pBlk->sizealloc + pBlk->offset, blockSize);
}
}
return true;
@ -591,10 +591,10 @@ void mpqapi_remove_hash_entry(const char *pszName)
_HASHENTRY *pHashTbl = &cur_archive.sgpHashTbl[hIdx];
_BLOCKENTRY *blockEntry = &cur_archive.sgpBlockTbl[pHashTbl->block];
pHashTbl->block = -2;
int block_offset = blockEntry->offset;
int block_size = blockEntry->sizealloc;
int blockOffset = blockEntry->offset;
int blockSize = blockEntry->sizealloc;
memset(blockEntry, 0, sizeof(*blockEntry));
AllocBlock(block_offset, block_size);
AllocBlock(blockOffset, blockSize);
cur_archive.modified = true;
}
@ -690,13 +690,13 @@ bool OpenMPQ(const char *pszArchive)
}
return true;
on_error:
cur_archive.Close(/*clear_tables=*/true);
cur_archive.Close(/*clearTables=*/true);
return false;
}
bool mpqapi_flush_and_close(bool bFree)
{
return cur_archive.Close(/*clear_tables=*/bFree);
return cur_archive.Close(/*clearTables=*/bFree);
}
} // namespace devilution

6
Source/msg.cpp

@ -543,15 +543,15 @@ void CheckUpdatePlayer(int pnum)
void PlayerMessageFormat(const char *pszFmt, ...)
{
static DWORD msg_err_timer;
static DWORD msgErrTimer;
DWORD ticks;
char msg[256];
va_list va;
va_start(va, pszFmt);
ticks = SDL_GetTicks();
if (ticks - msg_err_timer >= 5000) {
msg_err_timer = ticks;
if (ticks - msgErrTimer >= 5000) {
msgErrTimer = ticks;
vsprintf(msg, pszFmt, va);
ErrorPlrMsg(msg);
}

38
Source/multi.cpp

@ -91,21 +91,21 @@ void CopyPacket(TBuffer *buf, byte *packet, uint8_t size)
byte *ReceivePacket(TBuffer *pBuf, byte *body, size_t *size)
{
if (pBuf->dwNextWriteOffset != 0) {
byte *src_ptr = pBuf->bData;
byte *srcPtr = pBuf->bData;
while (true) {
auto chunk_size = static_cast<uint8_t>(*src_ptr);
if (chunk_size == 0)
auto chunkSize = static_cast<uint8_t>(*srcPtr);
if (chunkSize == 0)
break;
if (chunk_size > *size)
if (chunkSize > *size)
break;
src_ptr++;
memcpy(body, src_ptr, chunk_size);
body += chunk_size;
src_ptr += chunk_size;
*size -= chunk_size;
srcPtr++;
memcpy(body, srcPtr, chunkSize);
body += chunkSize;
srcPtr += chunkSize;
*size -= chunkSize;
}
memcpy(pBuf->bData, src_ptr, (pBuf->bData - src_ptr) + pBuf->dwNextWriteOffset + 1);
pBuf->dwNextWriteOffset += (pBuf->bData - src_ptr);
memcpy(pBuf->bData, srcPtr, (pBuf->bData - srcPtr) + pBuf->dwNextWriteOffset + 1);
pBuf->dwNextWriteOffset += (pBuf->bData - srcPtr);
return body;
}
return body;
@ -367,7 +367,7 @@ void SetupLocalPositions()
void HandleEvents(_SNETEVENT *pEvt)
{
DWORD LeftReason;
DWORD leftReason;
switch (pEvt->eventid) {
case EVENT_TYPE_PLAYER_CREATE_GAME: {
@ -382,11 +382,11 @@ void HandleEvents(_SNETEVENT *pEvt)
sgbPlayerLeftGameTbl[pEvt->playerid] = true;
sgbPlayerTurnBitTbl[pEvt->playerid] = false;
LeftReason = 0;
leftReason = 0;
if (pEvt->data != nullptr && pEvt->databytes >= sizeof(DWORD))
LeftReason = *(DWORD *)pEvt->data;
sgdwPlayerLeftReasonTbl[pEvt->playerid] = LeftReason;
if (LeftReason == LEAVE_ENDING)
leftReason = *(DWORD *)pEvt->data;
sgdwPlayerLeftReasonTbl[pEvt->playerid] = leftReason;
if (leftReason == LEAVE_ENDING)
gbSomebodyWonGameKludge = true;
sgbSendDeltaTbl[pEvt->playerid] = false;
@ -487,9 +487,9 @@ void NetSendHiPri(int playerId, byte *pbMsg, BYTE bLen)
TPkt pkt;
NetReceivePlayerData(&pkt);
size_t size = gdwNormalMsgSize - sizeof(TPktHdr);
byte *hipri_body = ReceivePacket(&sgHiPriBuf, pkt.body, &size);
byte *lowpri_body = ReceivePacket(&sgLoPriBuf, hipri_body, &size);
size = sync_all_monsters(lowpri_body, size);
byte *hipriBody = ReceivePacket(&sgHiPriBuf, pkt.body, &size);
byte *lowpriBody = ReceivePacket(&sgLoPriBuf, hipriBody, &size);
size = sync_all_monsters(lowpriBody, size);
size_t len = gdwNormalMsgSize - size;
pkt.hdr.wLen = len;
if (!SNetSendMessage(-2, &pkt.hdr, len))

4
Source/nthread.cpp

@ -58,9 +58,9 @@ uint32_t nthread_send_and_recv_turn(uint32_t curTurn, int turnDelta)
}
while (curTurnsInTransit++ < gdwTurnsInTransit) {
int turn_tmp = turn_upper_bit | (curTurn & 0x7FFFFFFF);
int turnTmp = turn_upper_bit | (curTurn & 0x7FFFFFFF);
turn_upper_bit = 0;
int turn = turn_tmp;
int turn = turnTmp;
if (!SNetSendTurn((char *)&turn, sizeof(turn))) {
nthread_terminate_game("SNetSendTurn");

112
Source/objects.cpp

@ -671,9 +671,9 @@ void AddObjTraps()
continue;
AddObject(OBJ_TRAPL, xp, j);
int8_t oi_trap = dObject[xp][j] - 1;
object[oi_trap]._oVar1 = i;
object[oi_trap]._oVar2 = j;
int8_t oiTrap = dObject[xp][j] - 1;
object[oiTrap]._oVar1 = i;
object[oiTrap]._oVar2 = j;
object[oi]._oTrapFlag = true;
} else {
int yp = j - 1;
@ -684,9 +684,9 @@ void AddObjTraps()
continue;
AddObject(OBJ_TRAPR, i, yp);
int8_t oi_trap = dObject[i][yp] - 1;
object[oi_trap]._oVar1 = i;
object[oi_trap]._oVar2 = j;
int8_t oiTrap = dObject[i][yp] - 1;
object[oiTrap]._oVar1 = i;
object[oiTrap]._oVar2 = j;
object[oi]._oTrapFlag = true;
}
}
@ -1040,55 +1040,55 @@ void InitObjects()
AddL2Objs(0, 0, MAXDUNX, MAXDUNY);
AddL2Torches();
if (QuestStatus(Q_BLIND)) {
_speech_id sp_id;
_speech_id spId;
switch (plr[myplr]._pClass) {
case HeroClass::Warrior:
sp_id = TEXT_BLINDING;
spId = TEXT_BLINDING;
break;
case HeroClass::Rogue:
sp_id = TEXT_RBLINDING;
spId = TEXT_RBLINDING;
break;
case HeroClass::Sorcerer:
sp_id = TEXT_MBLINDING;
spId = TEXT_MBLINDING;
break;
case HeroClass::Monk:
sp_id = TEXT_HBLINDING;
spId = TEXT_HBLINDING;
break;
case HeroClass::Bard:
sp_id = TEXT_BBLINDING;
spId = TEXT_BBLINDING;
break;
case HeroClass::Barbarian:
sp_id = TEXT_BLINDING;
spId = TEXT_BLINDING;
break;
}
quests[Q_BLIND]._qmsg = sp_id;
AddBookLever(setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1, sp_id);
quests[Q_BLIND]._qmsg = spId;
AddBookLever(setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1, spId);
LoadMapObjs("Levels\\L2Data\\Blind2.DUN", 2 * setpc_x, 2 * setpc_y);
}
if (QuestStatus(Q_BLOOD)) {
_speech_id sp_id;
_speech_id spId;
switch (plr[myplr]._pClass) {
case HeroClass::Warrior:
sp_id = TEXT_BLOODY;
spId = TEXT_BLOODY;
break;
case HeroClass::Rogue:
sp_id = TEXT_RBLOODY;
spId = TEXT_RBLOODY;
break;
case HeroClass::Sorcerer:
sp_id = TEXT_MBLOODY;
spId = TEXT_MBLOODY;
break;
case HeroClass::Monk:
sp_id = TEXT_HBLOODY;
spId = TEXT_HBLOODY;
break;
case HeroClass::Bard:
sp_id = TEXT_BBLOODY;
spId = TEXT_BBLOODY;
break;
case HeroClass::Barbarian:
sp_id = TEXT_BLOODY;
spId = TEXT_BLOODY;
break;
}
quests[Q_BLOOD]._qmsg = sp_id;
AddBookLever(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7, sp_id);
quests[Q_BLOOD]._qmsg = spId;
AddBookLever(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7, spId);
AddObject(OBJ_PEDISTAL, 2 * setpc_x + 25, 2 * setpc_y + 32);
}
InitRndBarrels();
@ -1099,29 +1099,29 @@ void InitObjects()
}
if (leveltype == DTYPE_HELL) {
if (QuestStatus(Q_WARLORD)) {
_speech_id sp_id;
_speech_id spId;
switch (plr[myplr]._pClass) {
case HeroClass::Warrior:
sp_id = TEXT_BLOODWAR;
spId = TEXT_BLOODWAR;
break;
case HeroClass::Rogue:
sp_id = TEXT_RBLOODWAR;
spId = TEXT_RBLOODWAR;
break;
case HeroClass::Sorcerer:
sp_id = TEXT_MBLOODWAR;
spId = TEXT_MBLOODWAR;
break;
case HeroClass::Monk:
sp_id = TEXT_HBLOODWAR;
spId = TEXT_HBLOODWAR;
break;
case HeroClass::Bard:
sp_id = TEXT_BBLOODWAR;
spId = TEXT_BBLOODWAR;
break;
case HeroClass::Barbarian:
sp_id = TEXT_BLOODWAR;
spId = TEXT_BLOODWAR;
break;
}
quests[Q_WARLORD]._qmsg = sp_id;
AddBookLever(setpc_x, setpc_y, setpc_x + setpc_w, setpc_y + setpc_h, sp_id);
quests[Q_WARLORD]._qmsg = spId;
AddBookLever(setpc_x, setpc_y, setpc_x + setpc_w, setpc_y + setpc_h, spId);
LoadMapObjs("Levels\\L4Data\\Warlord.DUN", 2 * setpc_x, 2 * setpc_y);
}
if (QuestStatus(Q_BETRAYER) && !gbIsMultiplayer)
@ -2054,9 +2054,9 @@ void Obj_BCrossDamage(int i)
if (plr[myplr]._pmode == PM_DEATH)
return;
int fire_resist = plr[myplr]._pFireResist;
if (fire_resist > 0)
damage[leveltype - 1] -= fire_resist * damage[leveltype - 1] / 100;
int fireResist = plr[myplr]._pFireResist;
if (fireResist > 0)
damage[leveltype - 1] -= fireResist * damage[leveltype - 1] / 100;
if (plr[myplr].position.tile.x != object[i].position.x || plr[myplr].position.tile.y != object[i].position.y - 1)
return;
@ -2812,8 +2812,8 @@ void OperateBook(int pnum, int i)
if (object[i]._oSelFlag == 0)
return;
if (setlevel && setlvlnum == SL_VILEBETRAYER) {
bool do_add_missile = false;
bool missile_added = false;
bool doAddMissile = false;
bool missileAdded = false;
for (int j = 0; j < nobjects; j++) {
int oi = objectactive[j];
int otype = object[oi]._otype;
@ -2821,22 +2821,22 @@ void OperateBook(int pnum, int i)
dx = 27;
dy = 29;
object[oi]._oVar6 = 4;
do_add_missile = true;
doAddMissile = true;
}
if (otype == OBJ_MCIRCLE2 && object[oi]._oVar6 == 2) {
dx = 43;
dy = 29;
object[oi]._oVar6 = 4;
do_add_missile = true;
doAddMissile = true;
}
if (do_add_missile) {
if (doAddMissile) {
object[dObject[35][36] - 1]._oVar5++;
AddMissile(plr[pnum].position.tile, { dx, dy }, plr[pnum]._pdir, MIS_RNDTELEPORT, TARGET_MONSTERS, pnum, 0, 0);
missile_added = true;
do_add_missile = false;
missileAdded = true;
doAddMissile = false;
}
}
if (!missile_added)
if (!missileAdded)
return;
}
object[i]._oSelFlag = 0;
@ -4809,12 +4809,12 @@ void SyncOpL1Door(int pnum, int cmd, int i)
if (pnum == myplr)
return;
bool do_sync = false;
bool doSync = false;
if (cmd == CMD_OPENDOOR && object[i]._oVar4 == 0)
do_sync = true;
doSync = true;
if (cmd == CMD_CLOSEDOOR && object[i]._oVar4 == 1)
do_sync = true;
if (!do_sync)
doSync = true;
if (!doSync)
return;
if (object[i]._otype == OBJ_L1LDOOR)
@ -4828,12 +4828,12 @@ void SyncOpL2Door(int pnum, int cmd, int i)
if (pnum == myplr)
return;
bool do_sync = false;
bool doSync = false;
if (cmd == CMD_OPENDOOR && object[i]._oVar4 == 0)
do_sync = true;
doSync = true;
if (cmd == CMD_CLOSEDOOR && object[i]._oVar4 == 1)
do_sync = true;
if (!do_sync)
doSync = true;
if (!doSync)
return;
if (object[i]._otype == OBJ_L2LDOOR)
@ -4847,12 +4847,12 @@ void SyncOpL3Door(int pnum, int cmd, int i)
if (pnum == myplr)
return;
bool do_sync = false;
bool doSync = false;
if (cmd == CMD_OPENDOOR && object[i]._oVar4 == 0)
do_sync = true;
doSync = true;
if (cmd == CMD_CLOSEDOOR && object[i]._oVar4 == 1)
do_sync = true;
if (!do_sync)
doSync = true;
if (!doSync)
return;
if (object[i]._otype == OBJ_L3LDOOR)

24
Source/palette.cpp

@ -50,14 +50,14 @@ void ApplyGamma(SDL_Color *dst, const SDL_Color *src, int n)
static void LoadGamma()
{
int gamma_value = sgOptions.Graphics.nGammaCorrection;
int gammaValue = sgOptions.Graphics.nGammaCorrection;
if (gamma_value < 30) {
gamma_value = 30;
} else if (gamma_value > 100) {
gamma_value = 100;
if (gammaValue < 30) {
gammaValue = 30;
} else if (gammaValue > 100) {
gammaValue = 100;
}
sgOptions.Graphics.nGammaCorrection = gamma_value - gamma_value % 5;
sgOptions.Graphics.nGammaCorrection = gammaValue - gammaValue % 5;
}
void palette_init()
@ -136,14 +136,14 @@ void LoadPalette(const char *pszFileName, bool blend /*= true*/)
uint8_t b;
};
std::array<Color, 256> PalData;
std::array<Color, 256> palData;
LoadFileInMem(pszFileName, PalData);
LoadFileInMem(pszFileName, palData);
for (unsigned i = 0; i < PalData.size(); i++) {
orig_palette[i].r = PalData[i].r;
orig_palette[i].g = PalData[i].g;
orig_palette[i].b = PalData[i].b;
for (unsigned i = 0; i < palData.size(); i++) {
orig_palette[i].r = palData[i].r;
orig_palette[i].g = palData[i].g;
orig_palette[i].b = palData[i].b;
#ifndef USE_SDL1
orig_palette[i].a = SDL_ALPHA_OPAQUE;
#endif

98
Source/path.cpp

@ -58,36 +58,36 @@ int FindPath(bool (*posOk)(int, Point), int posOkArg, int sx, int sy, int dx, in
path_2_nodes = path_new_step();
pnode_ptr = path_new_step();
gdwCurPathStep = 0;
PATHNODE *path_start = path_new_step();
path_start->g = 0;
path_start->h = path_get_h_cost(sx, sy, dx, dy);
path_start->position.x = sx;
path_start->f = path_start->h + path_start->g;
path_start->position.y = sy;
path_2_nodes->NextNode = path_start;
PATHNODE *pathStart = path_new_step();
pathStart->g = 0;
pathStart->h = path_get_h_cost(sx, sy, dx, dy);
pathStart->position.x = sx;
pathStart->f = pathStart->h + pathStart->g;
pathStart->position.y = sy;
path_2_nodes->NextNode = pathStart;
// A* search until we find (dx,dy) or fail
PATHNODE *next_node;
while ((next_node = GetNextPath()) != nullptr) {
PATHNODE *nextNode;
while ((nextNode = GetNextPath()) != nullptr) {
// reached the end, success!
if (next_node->position.x == dx && next_node->position.y == dy) {
PATHNODE *current = next_node;
int path_length = 0;
if (nextNode->position.x == dx && nextNode->position.y == dy) {
PATHNODE *current = nextNode;
int pathLength = 0;
while (current->Parent != nullptr) {
if (path_length >= MAX_PATH_LENGTH)
if (pathLength >= MAX_PATH_LENGTH)
break;
pnode_vals[path_length++] = path_directions[3 * (current->position.y - current->Parent->position.y) - current->Parent->position.x + 4 + current->position.x];
pnode_vals[pathLength++] = path_directions[3 * (current->position.y - current->Parent->position.y) - current->Parent->position.x + 4 + current->position.x];
current = current->Parent;
}
if (path_length != MAX_PATH_LENGTH) {
if (pathLength != MAX_PATH_LENGTH) {
int i;
for (i = 0; i < path_length; i++)
path[i] = pnode_vals[path_length - i - 1];
for (i = 0; i < pathLength; i++)
path[i] = pnode_vals[pathLength - i - 1];
return i;
}
return 0;
}
// ran out of nodes, abort!
if (!path_get_path(posOk, posOkArg, next_node, dx, dy))
if (!path_get_path(posOk, posOkArg, nextNode, dx, dy))
return 0;
}
// frontier is empty, no path!
@ -99,11 +99,11 @@ int FindPath(bool (*posOk)(int, Point), int posOkArg, int sx, int sy, int dx, in
*/
int path_get_h_cost(int sx, int sy, int dx, int dy)
{
int delta_x = abs(sx - dx);
int delta_y = abs(sy - dy);
int deltaX = abs(sx - dx);
int deltaY = abs(sy - dy);
int min = delta_x < delta_y ? delta_x : delta_y;
int max = delta_x > delta_y ? delta_x : delta_y;
int min = deltaX < deltaY ? deltaX : deltaY;
int max = deltaX > deltaY ? deltaX : deltaY;
// see path_check_equal for why this is times 2
return 2 * (min + max);
@ -199,11 +199,11 @@ bool path_get_path(bool (*posOk)(int, Point), int posOkArg, PATHNODE *pPath, int
*/
bool path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy)
{
int next_g;
int nextG;
PATHNODE *dxdy;
int i;
next_g = pPath->g + path_check_equal(pPath, dx, dy);
nextG = pPath->g + path_check_equal(pPath, dx, dy);
// 3 cases to consider
// case 1: (dx,dy) is already on the frontier
@ -214,12 +214,12 @@ bool path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy)
break;
}
pPath->Child[i] = dxdy;
if (next_g < dxdy->g) {
if (nextG < dxdy->g) {
if (path_solid_pieces(pPath, dx, dy)) {
// we'll explore it later, just update
dxdy->Parent = pPath;
dxdy->g = next_g;
dxdy->f = next_g + dxdy->h;
dxdy->g = nextG;
dxdy->f = nextG + dxdy->h;
}
}
} else {
@ -231,11 +231,11 @@ bool path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy)
break;
}
pPath->Child[i] = dxdy;
if (next_g < dxdy->g && path_solid_pieces(pPath, dx, dy)) {
if (nextG < dxdy->g && path_solid_pieces(pPath, dx, dy)) {
// update the node
dxdy->Parent = pPath;
dxdy->g = next_g;
dxdy->f = next_g + dxdy->h;
dxdy->g = nextG;
dxdy->f = nextG + dxdy->h;
// already explored, so re-update others starting from that node
path_set_coords(dxdy);
}
@ -245,9 +245,9 @@ bool path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy)
if (dxdy == nullptr)
return false;
dxdy->Parent = pPath;
dxdy->g = next_g;
dxdy->g = nextG;
dxdy->h = path_get_h_cost(dx, dy, sx, sy);
dxdy->f = next_g + dxdy->h;
dxdy->f = nextG + dxdy->h;
dxdy->position = { dx, dy };
// add it to the frontier
path_next_node(dxdy);
@ -317,25 +317,25 @@ void path_next_node(PATHNODE *pPath)
*/
void path_set_coords(PATHNODE *pPath)
{
PATHNODE *PathOld;
PATHNODE *PathAct;
PATHNODE *pathOld;
PATHNODE *pathAct;
int i;
path_push_active_step(pPath);
// while there are path nodes to check
while (gdwCurPathStep > 0) {
PathOld = path_pop_active_step();
pathOld = path_pop_active_step();
for (i = 0; i < 8; i++) {
PathAct = PathOld->Child[i];
if (PathAct == nullptr)
pathAct = pathOld->Child[i];
if (pathAct == nullptr)
break;
if (PathOld->g + path_check_equal(PathOld, PathAct->position.x, PathAct->position.y) < PathAct->g) {
if (path_solid_pieces(PathOld, PathAct->position.x, PathAct->position.y)) {
PathAct->Parent = PathOld;
PathAct->g = PathOld->g + path_check_equal(PathOld, PathAct->position.x, PathAct->position.y);
PathAct->f = PathAct->g + PathAct->h;
path_push_active_step(PathAct);
if (pathOld->g + path_check_equal(pathOld, pathAct->position.x, pathAct->position.y) < pathAct->g) {
if (path_solid_pieces(pathOld, pathAct->position.x, pathAct->position.y)) {
pathAct->Parent = pathOld;
pathAct->g = pathOld->g + path_check_equal(pathOld, pathAct->position.x, pathAct->position.y);
pathAct->f = pathAct->g + pathAct->h;
path_push_active_step(pathAct);
}
}
}
@ -347,9 +347,9 @@ void path_set_coords(PATHNODE *pPath)
*/
void path_push_active_step(PATHNODE *pPath)
{
int stack_index = gdwCurPathStep;
int stackIndex = gdwCurPathStep;
gdwCurPathStep++;
pnode_tblptr[stack_index] = pPath;
pnode_tblptr[stackIndex] = pPath;
}
/**
@ -366,15 +366,15 @@ PATHNODE *path_pop_active_step()
*/
PATHNODE *path_new_step()
{
PATHNODE *new_node;
PATHNODE *newNode;
if (gdwCurNodes == MAXPATHNODES)
return nullptr;
new_node = &path_nodes[gdwCurNodes];
newNode = &path_nodes[gdwCurNodes];
gdwCurNodes++;
memset(new_node, 0, sizeof(PATHNODE));
return new_node;
memset(newNode, 0, sizeof(PATHNODE));
return newNode;
}
} // namespace devilution

66
Source/pfile.cpp

@ -55,9 +55,9 @@ std::string GetSavePath(uint32_t saveNum)
}
}
char save_num_str[21];
snprintf(save_num_str, sizeof(save_num_str) / sizeof(char), "%i", saveNum);
path.append(save_num_str);
char saveNumStr[21];
snprintf(saveNumStr, sizeof(saveNumStr) / sizeof(char), "%i", saveNum);
path.append(saveNumStr);
path.append(ext);
return path;
}
@ -280,7 +280,7 @@ PFileScopedArchiveWriter::~PFileScopedArchiveWriter()
void pfile_write_hero(bool writeGameData, bool clearTables)
{
PFileScopedArchiveWriter scoped_writer(clearTables);
PFileScopedArchiveWriter scopedWriter(clearTables);
if (writeGameData) {
SaveGameData();
RenameTempToPerm();
@ -338,20 +338,20 @@ bool pfile_ui_save_create(_uiheroinfo *heroinfo)
{
PkPlayerStruct pkplr;
uint32_t save_num = GetSaveNumberFromName(heroinfo->name);
if (save_num >= MAX_CHARACTERS) {
for (save_num = 0; save_num < MAX_CHARACTERS; save_num++) {
if (hero_names[save_num][0] == '\0')
uint32_t saveNum = GetSaveNumberFromName(heroinfo->name);
if (saveNum >= MAX_CHARACTERS) {
for (saveNum = 0; saveNum < MAX_CHARACTERS; saveNum++) {
if (hero_names[saveNum][0] == '\0')
break;
}
if (save_num >= MAX_CHARACTERS)
if (saveNum >= MAX_CHARACTERS)
return false;
}
if (!OpenArchive(save_num))
if (!OpenArchive(saveNum))
return false;
mpqapi_remove_hash_entries(GetFileName);
strncpy(hero_names[save_num], heroinfo->name, PLR_NAME_LEN);
hero_names[save_num][PLR_NAME_LEN - 1] = '\0';
strncpy(hero_names[saveNum], heroinfo->name, PLR_NAME_LEN);
hero_names[saveNum][PLR_NAME_LEN - 1] = '\0';
auto &player = plr[0];
CreatePlayer(0, heroinfo->heroclass);
@ -371,10 +371,10 @@ bool pfile_ui_save_create(_uiheroinfo *heroinfo)
bool pfile_delete_save(_uiheroinfo *heroInfo)
{
uint32_t save_num = GetSaveNumberFromName(heroInfo->name);
if (save_num < MAX_CHARACTERS) {
hero_names[save_num][0] = '\0';
RemoveFile(GetSavePath(save_num).c_str());
uint32_t saveNum = GetSaveNumberFromName(heroInfo->name);
if (saveNum < MAX_CHARACTERS) {
hero_names[saveNum][0] = '\0';
RemoveFile(GetSavePath(saveNum).c_str());
}
return true;
}
@ -384,8 +384,8 @@ void pfile_read_player_from_save(char name[16], int playerId)
HANDLE archive;
PkPlayerStruct pkplr;
uint32_t save_num = GetSaveNumberFromName(name);
archive = OpenSaveArchive(save_num);
uint32_t saveNum = GetSaveNumberFromName(name);
archive = OpenSaveArchive(saveNum);
if (archive == nullptr)
app_fatal("%s", _("Unable to open archive"));
if (!ReadHero(archive, &pkplr))
@ -410,13 +410,13 @@ bool LevelFileExists()
GetPermLevelNames(szName);
uint32_t save_num = GetSaveNumberFromName(plr[myplr]._pName);
if (!OpenArchive(save_num))
uint32_t saveNum = GetSaveNumberFromName(plr[myplr]._pName);
if (!OpenArchive(saveNum))
app_fatal("%s", _("Unable to read to save file archive"));
bool has_file = mpqapi_has_file(szName);
bool hasFile = mpqapi_has_file(szName);
mpqapi_flush_and_close(true);
return has_file;
return hasFile;
}
void GetTempLevelNames(char *szTemp)
@ -429,14 +429,14 @@ void GetTempLevelNames(char *szTemp)
void GetPermLevelNames(char *szPerm)
{
uint32_t save_num = GetSaveNumberFromName(plr[myplr]._pName);
uint32_t saveNum = GetSaveNumberFromName(plr[myplr]._pName);
GetTempLevelNames(szPerm);
if (!OpenArchive(save_num))
if (!OpenArchive(saveNum))
app_fatal("%s", _("Unable to read to save file archive"));
bool has_file = mpqapi_has_file(szPerm);
bool hasFile = mpqapi_has_file(szPerm);
mpqapi_flush_and_close(true);
if (!has_file) {
if (!hasFile) {
if (setlevel)
sprintf(szPerm, "perms%02d", setlvlnum);
else
@ -449,8 +449,8 @@ void pfile_remove_temp_files()
if (gbIsMultiplayer)
return;
uint32_t save_num = GetSaveNumberFromName(plr[myplr]._pName);
if (!OpenArchive(save_num))
uint32_t saveNum = GetSaveNumberFromName(plr[myplr]._pName);
if (!OpenArchive(saveNum))
app_fatal("%s", _("Unable to write to save file archive"));
mpqapi_remove_hash_entries(GetTempSaveNames);
mpqapi_flush_and_close(true);
@ -460,8 +460,8 @@ std::unique_ptr<byte[]> pfile_read(const char *pszName, size_t *pdwLen)
{
HANDLE archive;
uint32_t save_num = GetSaveNumberFromName(plr[myplr]._pName);
archive = OpenSaveArchive(save_num);
uint32_t saveNum = GetSaveNumberFromName(plr[myplr]._pName);
archive = OpenSaveArchive(saveNum);
if (archive == nullptr)
return nullptr;
@ -475,16 +475,16 @@ std::unique_ptr<byte[]> pfile_read(const char *pszName, size_t *pdwLen)
void pfile_update(bool forceSave)
{
static Uint32 save_prev_tc;
static Uint32 prevTick;
if (!gbIsMultiplayer)
return;
Uint32 tick = SDL_GetTicks();
if (!forceSave && tick - save_prev_tc <= 60000)
if (!forceSave && tick - prevTick <= 60000)
return;
save_prev_tc = tick;
prevTick = tick;
pfile_write_hero();
}

2
Source/platform/ctr/asio/sys/socket.c

@ -83,7 +83,7 @@ ssize_t stream_sendmsg(int socket, const struct msghdr *message, int flags)
ssize_t dgram_sendmsg(int socket, const struct msghdr *message, int flags)
{
return ENOTSUP;
return ENOTSUP;
}
ssize_t sendmsg(int socket, const struct msghdr *message, int flags)

4
Source/platform/switch/asio/sys/signal.c

@ -1,7 +1,7 @@
#include <sys/signal.h>
#include <errno.h>
int pthread_sigmask (int, const sigset_t *, sigset_t *)
int pthread_sigmask(int, const sigset_t *, sigset_t *)
{
return ENOTSUP;
return ENOTSUP;
}

8
Source/player.cpp

@ -720,11 +720,11 @@ void NewPlrAnim(PlayerStruct &player, player_graphic graphic, Direction dir, int
if (player.AnimationData[static_cast<size_t>(graphic)].RawData == nullptr)
LoadPlrGFX(player, graphic);
auto &CelSprites = player.AnimationData[static_cast<size_t>(graphic)].CelSpritesForDirections;
auto &celSprites = player.AnimationData[static_cast<size_t>(graphic)].CelSpritesForDirections;
CelSprite *pCelSprite = nullptr;
if (CelSprites[dir])
pCelSprite = &*CelSprites[dir];
if (celSprites[dir])
pCelSprite = &*celSprites[dir];
player.AnimInfo.SetNewAnimation(pCelSprite, numberOfFrames, delayLen, flags, numSkippedFrames, distributeFramesBeforeFrame);
}
@ -1622,7 +1622,7 @@ void StartPlrHit(int pnum, int dam, bool forcehit)
Direction pd = player._pdir;
int skippedAnimationFrames = 0;
const int ZenFlags = ISPL_FASTRECOVER | ISPL_FASTERRECOVER | ISPL_FASTESTRECOVER;
constexpr int ZenFlags = ISPL_FASTRECOVER | ISPL_FASTERRECOVER | ISPL_FASTESTRECOVER;
if ((player._pIFlags & ZenFlags) == ZenFlags) { // if multiple hitrecovery modes are present the skipping of frames can go so far, that they skip frames that would skip. so the additional skipping thats skipped. that means we can't add the different modes together.
skippedAnimationFrames = 4;
} else if ((player._pIFlags & ISPL_FASTESTRECOVER) != 0) {

8
Source/plrmsg.cpp

@ -26,17 +26,17 @@ void plrmsg_delay(bool delay)
{
int i;
_plrmsg *pMsg;
static DWORD plrmsg_ticks;
static DWORD plrmsgTicks;
if (delay) {
plrmsg_ticks = -SDL_GetTicks();
plrmsgTicks = -SDL_GetTicks();
return;
}
plrmsg_ticks += SDL_GetTicks();
plrmsgTicks += SDL_GetTicks();
pMsg = plr_msgs;
for (i = 0; i < PMSG_COUNT; i++, pMsg++)
pMsg->time += plrmsg_ticks;
pMsg->time += plrmsgTicks;
}
void ErrorPlrMsg(const char *pszMsg)

6
Source/qol/xpbar.cpp

@ -93,15 +93,15 @@ void DrawXPBar(const Surface &out)
if (player._pExperience < prevXp)
return;
uint64_t prevXpDelta_1 = player._pExperience - prevXp;
uint64_t prevXpDelta1 = player._pExperience - prevXp;
uint64_t prevXpDelta = ExpLvlsTbl[charLevel] - prevXp;
uint64_t fullBar = BarWidth * prevXpDelta_1 / prevXpDelta;
uint64_t fullBar = BarWidth * prevXpDelta1 / prevXpDelta;
// Figure out how much to fill the last pixel of the XP bar, to make it gradually appear with gained XP
uint64_t onePx = prevXpDelta / BarWidth + 1;
uint64_t lastFullPx = fullBar * prevXpDelta / BarWidth;
const uint64_t fade = (prevXpDelta_1 - lastFullPx) * (SilverGradient.size() - 1) / onePx;
const uint64_t fade = (prevXpDelta1 - lastFullPx) * (SilverGradient.size() - 1) / onePx;
// Draw beginning of bar full brightness
DrawBar(out, xPos, yPos, fullBar, SilverGradient);

50
Source/scrollrt.cpp

@ -957,53 +957,53 @@ static void DrawTileContent(const Surface &out, int x, int y, int sx, int sy, in
*/
static void Zoom(const Surface &out)
{
int viewport_width = out.w();
int viewport_offset_x = 0;
int viewportWidth = out.w();
int viewportOffsetX = 0;
if (CanPanelsCoverView()) {
if (chrflag || questlog) {
viewport_width -= SPANEL_WIDTH;
viewport_offset_x = SPANEL_WIDTH;
viewportWidth -= SPANEL_WIDTH;
viewportOffsetX = SPANEL_WIDTH;
} else if (invflag || sbookflag) {
viewport_width -= SPANEL_WIDTH;
viewportWidth -= SPANEL_WIDTH;
}
}
// We round to even for the source width and height.
// If the width / height was odd, we copy just one extra pixel / row later on.
const int src_width = (viewport_width + 1) / 2;
const int doubleable_width = viewport_width / 2;
const int src_height = (out.h() + 1) / 2;
const int doubleable_height = out.h() / 2;
const int srcWidth = (viewportWidth + 1) / 2;
const int doubleableWidth = viewportWidth / 2;
const int srcHeight = (out.h() + 1) / 2;
const int doubleableHeight = out.h() / 2;
BYTE *src = out.at(src_width - 1, src_height - 1);
BYTE *dst = out.at(viewport_offset_x + viewport_width - 1, out.h() - 1);
const bool odd_viewport_width = (viewport_width % 2) == 1;
BYTE *src = out.at(srcWidth - 1, srcHeight - 1);
BYTE *dst = out.at(viewportOffsetX + viewportWidth - 1, out.h() - 1);
const bool oddViewportWidth = (viewportWidth % 2) == 1;
for (int hgt = 0; hgt < doubleable_height; hgt++) {
for (int hgt = 0; hgt < doubleableHeight; hgt++) {
// Double the pixels in the line.
for (int i = 0; i < doubleable_width; i++) {
for (int i = 0; i < doubleableWidth; i++) {
*dst-- = *src;
*dst-- = *src;
--src;
}
// Copy a single extra pixel if the output width is odd.
if (odd_viewport_width) {
if (oddViewportWidth) {
*dst-- = *src;
--src;
}
// Skip the rest of the source line.
src -= (out.pitch() - src_width);
src -= (out.pitch() - srcWidth);
// Double the line.
memcpy(dst - out.pitch() + 1, dst + 1, viewport_width);
memcpy(dst - out.pitch() + 1, dst + 1, viewportWidth);
// Skip the rest of the destination line.
dst -= 2 * out.pitch() - viewport_width;
dst -= 2 * out.pitch() - viewportWidth;
}
if ((out.h() % 2) == 1) {
memcpy(dst - out.pitch() + 1, dst + 1, viewport_width);
memcpy(dst - out.pitch() + 1, dst + 1, viewportWidth);
}
}
@ -1431,7 +1431,7 @@ void EnableFrameCount()
*/
static void DrawFPS(const Surface &out)
{
char String[12];
char string[12];
if (!frameflag || !gbActive) {
return;
@ -1445,8 +1445,8 @@ static void DrawFPS(const Surface &out)
framerate = 1000 * frameend / frames;
frameend = 0;
}
snprintf(String, 12, "%i FPS", framerate);
DrawString(out, String, Point { 8, 65 }, UIS_RED);
snprintf(string, 12, "%i FPS", framerate);
DrawString(out, string, Point { 8, 65 }, UIS_RED);
}
/**
@ -1460,14 +1460,14 @@ static void DoBlitScreen(Sint16 dwX, Sint16 dwY, Uint16 dwWdt, Uint16 dwHgt)
{
// In SDL1 SDL_Rect x and y are Sint16. Cast explicitly to avoid a compiler warning.
using CoordType = decltype(SDL_Rect {}.x);
SDL_Rect src_rect {
SDL_Rect srcRect {
static_cast<CoordType>(dwX),
static_cast<CoordType>(dwY),
dwWdt, dwHgt
};
SDL_Rect dst_rect { dwX, dwY, dwWdt, dwHgt };
SDL_Rect dstRect { dwX, dwY, dwWdt, dwHgt };
BltFast(&src_rect, &dst_rect);
BltFast(&srcRect, &dstRect);
}
/**

82
Source/sha.cpp

@ -50,63 +50,63 @@ static void SHA1Init(SHA1Context *context)
static void SHA1ProcessMessageBlock(SHA1Context *context)
{
std::uint32_t W[80];
std::uint32_t w[80];
auto *buf = (std::uint32_t *)context->buffer;
for (int i = 0; i < 16; i++)
W[i] = SDL_SwapLE32(buf[i]);
w[i] = SDL_SwapLE32(buf[i]);
for (int i = 16; i < 80; i++) {
W[i] = W[i - 16] ^ W[i - 14] ^ W[i - 8] ^ W[i - 3];
w[i] = w[i - 16] ^ w[i - 14] ^ w[i - 8] ^ w[i - 3];
}
std::uint32_t A = context->state[0];
std::uint32_t B = context->state[1];
std::uint32_t C = context->state[2];
std::uint32_t D = context->state[3];
std::uint32_t E = context->state[4];
std::uint32_t a = context->state[0];
std::uint32_t b = context->state[1];
std::uint32_t c = context->state[2];
std::uint32_t d = context->state[3];
std::uint32_t e = context->state[4];
for (int i = 0; i < 20; i++) {
std::uint32_t temp = SHA1CircularShift(5, A) + ((B & C) | ((~B) & D)) + E + W[i] + 0x5A827999;
E = D;
D = C;
C = SHA1CircularShift(30, B);
B = A;
A = temp;
std::uint32_t temp = SHA1CircularShift(5, a) + ((b & c) | ((~b) & d)) + e + w[i] + 0x5A827999;
e = d;
d = c;
c = SHA1CircularShift(30, b);
b = a;
a = temp;
}
for (int i = 20; i < 40; i++) {
std::uint32_t temp = SHA1CircularShift(5, A) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1;
E = D;
D = C;
C = SHA1CircularShift(30, B);
B = A;
A = temp;
std::uint32_t temp = SHA1CircularShift(5, a) + (b ^ c ^ d) + e + w[i] + 0x6ED9EBA1;
e = d;
d = c;
c = SHA1CircularShift(30, b);
b = a;
a = temp;
}
for (int i = 40; i < 60; i++) {
std::uint32_t temp = SHA1CircularShift(5, A) + ((B & C) | (B & D) | (C & D)) + E + W[i] + 0x8F1BBCDC;
E = D;
D = C;
C = SHA1CircularShift(30, B);
B = A;
A = temp;
std::uint32_t temp = SHA1CircularShift(5, a) + ((b & c) | (b & d) | (c & d)) + e + w[i] + 0x8F1BBCDC;
e = d;
d = c;
c = SHA1CircularShift(30, b);
b = a;
a = temp;
}
for (int i = 60; i < 80; i++) {
std::uint32_t temp = SHA1CircularShift(5, A) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6;
E = D;
D = C;
C = SHA1CircularShift(30, B);
B = A;
A = temp;
std::uint32_t temp = SHA1CircularShift(5, a) + (b ^ c ^ d) + e + w[i] + 0xCA62C1D6;
e = d;
d = c;
c = SHA1CircularShift(30, b);
b = a;
a = temp;
}
context->state[0] += A;
context->state[1] += B;
context->state[2] += C;
context->state[3] += D;
context->state[4] += E;
context->state[0] += a;
context->state[1] += b;
context->state[2] += c;
context->state[3] += d;
context->state[4] += e;
}
static void SHA1Input(SHA1Context *context, const char *messageArray, std::uint32_t len)
@ -132,14 +132,14 @@ void SHA1Clear()
void SHA1Result(int n, char messageDigest[SHA1HashSize])
{
std::uint32_t *Message_Digest_Block;
std::uint32_t *messageDigestBlock;
int i;
Message_Digest_Block = (std::uint32_t *)messageDigest;
messageDigestBlock = (std::uint32_t *)messageDigest;
if (messageDigest != nullptr) {
for (i = 0; i < 5; i++) {
*Message_Digest_Block = SDL_SwapLE32(sgSHA1[n].state[i]);
Message_Digest_Block++;
*messageDigestBlock = SDL_SwapLE32(sgSHA1[n].state[i]);
messageDigestBlock++;
}
}
}

6
Source/sound.cpp

@ -180,9 +180,9 @@ std::unique_ptr<TSnd> sound_file_load(const char *path, bool stream)
ErrDlg("SFileOpenFile failed", path, __FILE__, __LINE__);
}
DWORD dwBytes = SFileGetFileSize(file);
auto wave_file = MakeArraySharedPtr<std::uint8_t>(dwBytes);
SFileReadFileThreadSafe(file, wave_file.get(), dwBytes);
error = snd->DSB.SetChunk(wave_file, dwBytes);
auto waveFile = MakeArraySharedPtr<std::uint8_t>(dwBytes);
SFileReadFileThreadSafe(file, waveFile.get(), dwBytes);
error = snd->DSB.SetChunk(waveFile, dwBytes);
SFileCloseFileThreadSafe(file);
}
#endif

12
Source/storm/storm_svid.cpp

@ -150,16 +150,16 @@ bool SVidPlayBegin(const char *filename, int flags)
//0x800000 // Edge detection
//0x200800 // Clear FB
HANDLE video_stream;
SFileOpenFile(filename, &video_stream);
HANDLE videoStream;
SFileOpenFile(filename, &videoStream);
#ifdef DEVILUTIONX_STORM_FILE_WRAPPER_AVAILABLE
FILE *file = FILE_FromStormHandle(video_stream);
FILE *file = FILE_FromStormHandle(videoStream);
SVidSMK = smk_open_filepointer(file, SMK_MODE_DISK);
#else
int bytestoread = SFileGetFileSize(video_stream);
int bytestoread = SFileGetFileSize(videoStream);
SVidBuffer = std::unique_ptr<uint8_t[]> { new uint8_t[bytestoread] };
SFileReadFileThreadSafe(video_stream, SVidBuffer.get(), bytestoread);
SFileCloseFileThreadSafe(video_stream);
SFileReadFileThreadSafe(videoStream, SVidBuffer.get(), bytestoread);
SFileCloseFileThreadSafe(videoStream);
SVidSMK = smk_open_memory(SVidBuffer.get(), bytestoread);
#endif
if (SVidSMK == nullptr) {

2
Source/towners.h

@ -45,7 +45,7 @@ struct TownerStruct {
byte *_tNAnim[8];
std::unique_ptr<byte[]> _tNData;
byte *_tAnimData;
/** Used to get a voice line and text related to active quests when the player speaks to a town npc */
/** Used to get a voice line and text related to active quests when the player speaks to a town npc */
int16_t _tSeed;
/** Tile position of NPC */
Point position;

6
Source/track.cpp

@ -37,10 +37,10 @@ void track_process()
const Point target = player.GetTargetPosition();
if (cursmx != target.x || cursmy != target.y) {
Uint32 tick = SDL_GetTicks();
int TickMultiplier = 6;
int tickMultiplier = 6;
if (currlevel == 0 && sgGameInitInfo.bRunInTown != 0)
TickMultiplier = 3;
if ((int)(tick - sgdwLastWalk) >= gnTickDelay * TickMultiplier) {
tickMultiplier = 3;
if ((int)(tick - sgdwLastWalk) >= gnTickDelay * tickMultiplier) {
sgdwLastWalk = tick;
NetSendCmdLoc(myplr, true, CMD_WALKXY, { cursmx, cursmy });
if (!sgbIsScrolling)

32
Source/utils/log.hpp

@ -39,7 +39,7 @@ enum class LogPriority {
namespace detail {
template <typename... Args>
std::string format(const char *fmt, Args &&... args)
std::string format(const char *fmt, Args &&...args)
{
FMT_TRY
{
@ -56,99 +56,99 @@ std::string format(const char *fmt, Args &&... args)
} // namespace detail
template <typename... Args>
void Log(const char *fmt, Args &&... args)
void Log(const char *fmt, Args &&...args)
{
auto str = detail::format(fmt, std::forward<Args>(args)...);
SDL_Log("%s", str.c_str());
}
template <typename... Args>
void LogVerbose(LogCategory category, const char *fmt, Args &&... args)
void LogVerbose(LogCategory category, const char *fmt, Args &&...args)
{
auto str = detail::format(fmt, std::forward<Args>(args)...);
SDL_LogVerbose(static_cast<int>(category), "%s", str.c_str());
}
template <typename... Args>
void LogVerbose(const char *fmt, Args &&... args)
void LogVerbose(const char *fmt, Args &&...args)
{
LogVerbose(defaultCategory, fmt, std::forward<Args>(args)...);
}
template <typename... Args>
void LogDebug(LogCategory category, const char *fmt, Args &&... args)
void LogDebug(LogCategory category, const char *fmt, Args &&...args)
{
auto str = detail::format(fmt, std::forward<Args>(args)...);
SDL_LogDebug(static_cast<int>(category), "%s", str.c_str());
}
template <typename... Args>
void LogDebug(const char *fmt, Args &&... args)
void LogDebug(const char *fmt, Args &&...args)
{
LogDebug(defaultCategory, fmt, std::forward<Args>(args)...);
}
template <typename... Args>
void LogInfo(LogCategory category, const char *fmt, Args &&... args)
void LogInfo(LogCategory category, const char *fmt, Args &&...args)
{
auto str = detail::format(fmt, std::forward<Args>(args)...);
SDL_LogInfo(static_cast<int>(category), "%s", str.c_str());
}
template <typename... Args>
void LogInfo(const char *fmt, Args &&... args)
void LogInfo(const char *fmt, Args &&...args)
{
LogInfo(defaultCategory, fmt, std::forward<Args>(args)...);
}
template <typename... Args>
void LogWarn(LogCategory category, const char *fmt, Args &&... args)
void LogWarn(LogCategory category, const char *fmt, Args &&...args)
{
auto str = detail::format(fmt, std::forward<Args>(args)...);
SDL_LogWarn(static_cast<int>(category), "%s", str.c_str());
}
template <typename... Args>
void LogWarn(const char *fmt, Args &&... args)
void LogWarn(const char *fmt, Args &&...args)
{
LogWarn(defaultCategory, fmt, std::forward<Args>(args)...);
}
template <typename... Args>
void LogError(LogCategory category, const char *fmt, Args &&... args)
void LogError(LogCategory category, const char *fmt, Args &&...args)
{
auto str = detail::format(fmt, std::forward<Args>(args)...);
SDL_LogError(static_cast<int>(category), "%s", str.c_str());
}
template <typename... Args>
void LogError(const char *fmt, Args &&... args)
void LogError(const char *fmt, Args &&...args)
{
LogError(defaultCategory, fmt, std::forward<Args>(args)...);
}
template <typename... Args>
void LogCritical(LogCategory category, const char *fmt, Args &&... args)
void LogCritical(LogCategory category, const char *fmt, Args &&...args)
{
auto str = detail::format(fmt, std::forward<Args>(args)...);
SDL_LogCritical(static_cast<int>(category), "%s", str.c_str());
}
template <typename... Args>
void LogCritical(const char *fmt, Args &&... args)
void LogCritical(const char *fmt, Args &&...args)
{
LogCritical(defaultCategory, fmt, std::forward<Args>(args)...);
}
template <typename... Args>
void LogMessageV(LogCategory category, LogPriority priority, const char *fmt, Args &&... args)
void LogMessageV(LogCategory category, LogPriority priority, const char *fmt, Args &&...args)
{
auto str = detail::format(fmt, std::forward<Args>(args)...);
SDL_LogMessageV(static_cast<int>(category), static_cast<SDL_LogPriority>(priority), "%s", str.c_str());
}
template <typename... Args>
void LogMessageV(const char *fmt, Args &&... args)
void LogMessageV(const char *fmt, Args &&...args)
{
LogMessageV(defaultCategory, fmt, std::forward<Args>(args)...);
}

Loading…
Cancel
Save