Browse Source

Apply clang-format

pull/2568/head
obligaron 5 years ago committed by Anders Jenbo
parent
commit
82cea78def
  1. 4
      Source/DiabloUI/selhero.cpp
  2. 4
      Source/diablo.cpp
  3. 1
      Source/gendung.cpp
  4. 2
      Source/monster.cpp
  5. 8
      Source/options.cpp
  6. 2
      Source/platform/ctr/locale.cpp
  7. 4
      Source/player.cpp
  8. 2
      Source/scrollrt.cpp
  9. 32
      Source/utils/log.hpp
  10. 2
      test/path_test.cpp
  11. 3
      test/random_test.cpp

4
Source/DiabloUI/selhero.cpp

@ -300,11 +300,11 @@ void SelheroClassSelectorEsc()
void SelheroNameSelect(int /*value*/) void SelheroNameSelect(int /*value*/)
{ {
// only check names in multiplayer, we don't care about them in single // only check names in multiplayer, we don't care about them in single
if (selhero_isMultiPlayer && !UiValidPlayerName(selhero_heroInfo.name)) { if (selhero_isMultiPlayer && !UiValidPlayerName(selhero_heroInfo.name)) {
ArtBackground.Unload(); ArtBackground.Unload();
UiSelOkDialog(title, _("Invalid name. A name cannot contain spaces, reserved characters, or reserved words.\n"), false); UiSelOkDialog(title, _("Invalid name. A name cannot contain spaces, reserved characters, or reserved words.\n"), false);
LoadBackgroundArt("ui_art\\selhero.pcx"); LoadBackgroundArt("ui_art\\selhero.pcx");
} else{ } else {
if (gfnHeroCreate(&selhero_heroInfo)) { if (gfnHeroCreate(&selhero_heroInfo)) {
SelheroLoadSelect(1); SelheroLoadSelect(1);
return; return;

4
Source/diablo.cpp

@ -396,8 +396,8 @@ void RightMouseDown()
return; return;
} }
if ((!sbookflag || !RightPanel.Contains(MousePosition)) if ((!sbookflag || !RightPanel.Contains(MousePosition))
&& !TryIconCurs() && !TryIconCurs()
&& (pcursinvitem == -1 || !UseInvItem(MyPlayerId, pcursinvitem))) { && (pcursinvitem == -1 || !UseInvItem(MyPlayerId, pcursinvitem))) {
if (pcurs == CURSOR_HAND) { if (pcurs == CURSOR_HAND) {
if (pcursinvitem == -1 || !UseInvItem(MyPlayerId, pcursinvitem)) if (pcursinvitem == -1 || !UseInvItem(MyPlayerId, pcursinvitem))
CheckPlrSpell(); CheckPlrSpell();

1
Source/gendung.cpp

@ -613,5 +613,4 @@ void FloodTransparencyValues(uint8_t floorID)
} }
} }
} // namespace devilution } // namespace devilution

2
Source/monster.cpp

@ -1172,7 +1172,7 @@ void Teleport(int i)
monster._mdir = GetMonsterDirection(monster); monster._mdir = GetMonsterDirection(monster);
if (monster.mlid != NO_LIGHT) { if (monster.mlid != NO_LIGHT) {
ChangeLightXY(monster.mlid, { x, y }); ChangeLightXY(monster.mlid, { x, y });
} }
} }
} }

8
Source/options.cpp

@ -303,7 +303,7 @@ void LoadOptions()
env->DeleteLocalRef(clazz); env->DeleteLocalRef(clazz);
#elif defined(__vita__) #elif defined(__vita__)
int32_t language = SCE_SYSTEM_PARAM_LANG_ENGLISH_US; // default to english int32_t language = SCE_SYSTEM_PARAM_LANG_ENGLISH_US; // default to english
const char* vita_locales[] = { const char *vita_locales[] = {
"ja_JP", "ja_JP",
"en_US", "en_US",
"fr_FR", "fr_FR",
@ -327,9 +327,9 @@ void LoadOptions()
}; };
SceAppUtilInitParam initParam; SceAppUtilInitParam initParam;
SceAppUtilBootParam bootParam; SceAppUtilBootParam bootParam;
memset( &initParam, 0, sizeof(SceAppUtilInitParam) ); memset(&initParam, 0, sizeof(SceAppUtilInitParam));
memset( &bootParam, 0, sizeof(SceAppUtilBootParam) ); memset(&bootParam, 0, sizeof(SceAppUtilBootParam));
sceAppUtilInit( &initParam, &bootParam ); sceAppUtilInit(&initParam, &bootParam);
sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_LANG, &language); sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_LANG, &language);
if (language < 0 || language > SCE_SYSTEM_PARAM_LANG_TURKISH) if (language < 0 || language > SCE_SYSTEM_PARAM_LANG_TURKISH)
language = SCE_SYSTEM_PARAM_LANG_ENGLISH_US; // default to english language = SCE_SYSTEM_PARAM_LANG_ENGLISH_US; // default to english

2
Source/platform/ctr/locale.cpp

@ -20,7 +20,7 @@ public:
} }
}; };
} } // namespace
std::string GetLocale() std::string GetLocale()
{ {

4
Source/player.cpp

@ -3546,7 +3546,7 @@ void CheckPlrSpell()
if ( if (
((chrflag || QuestLogIsOpen) && LeftPanel.Contains(MousePosition)) // inside left panel ((chrflag || QuestLogIsOpen) && LeftPanel.Contains(MousePosition)) // inside left panel
|| ((invflag || sbookflag) && RightPanel.Contains(MousePosition)) // inside right panel || ((invflag || sbookflag) && RightPanel.Contains(MousePosition)) // inside right panel
) { ) {
if (rspell != SPL_HEAL if (rspell != SPL_HEAL
&& rspell != SPL_IDENTIFY && rspell != SPL_IDENTIFY
@ -3713,7 +3713,7 @@ void CheckStats(PlayerStruct &player)
int maxStatPoint = player.GetMaximumAttributeValue(attribute); int maxStatPoint = player.GetMaximumAttributeValue(attribute);
switch (attribute) { switch (attribute) {
case CharacterAttribute::Strength: case CharacterAttribute::Strength:
player._pBaseStr = clamp(player._pBaseStr, 0 , maxStatPoint); player._pBaseStr = clamp(player._pBaseStr, 0, maxStatPoint);
break; break;
case CharacterAttribute::Magic: case CharacterAttribute::Magic:
player._pBaseMag = clamp(player._pBaseMag, 0, maxStatPoint); player._pBaseMag = clamp(player._pBaseMag, 0, maxStatPoint);

2
Source/scrollrt.cpp

@ -1212,7 +1212,7 @@ void DrawView(const Surface &out, int startX, int startY)
DrawQuestLog(out); DrawQuestLog(out);
} }
if (!chrflag && Players[MyPlayerId]._pStatPts != 0 && !spselflag if (!chrflag && Players[MyPlayerId]._pStatPts != 0 && !spselflag
&& (!QuestLogIsOpen || !LeftPanel.Contains(MainPanel.position + Displacement { 0, -74 }))) { && (!QuestLogIsOpen || !LeftPanel.Contains(MainPanel.position + Displacement { 0, -74 }))) {
DrawLevelUpIcon(out); DrawLevelUpIcon(out);
} }
if (ShowUniqueItemInfoBox) { if (ShowUniqueItemInfoBox) {

32
Source/utils/log.hpp

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

2
test/path_test.cpp

@ -113,7 +113,7 @@ void CheckPath(Point startPosition, Point destinationPosition, std::vector<int8_
for (auto i = 0; i < pathLength; i++) { for (auto i = 0; i < pathLength; i++) {
EXPECT_EQ(pathSteps[i], expectedSteps[i]) << "Path step " << i << " differs from expectation for a path from " EXPECT_EQ(pathSteps[i], expectedSteps[i]) << "Path step " << i << " differs from expectation for a path from "
<< startPosition << " to " << destinationPosition; // this shouldn't be a requirement but... << startPosition << " to " << destinationPosition; // this shouldn't be a requirement but...
// Path directions are all jacked up compared to the Direction enum. Most consumers have their own mapping definition // Path directions are all jacked up compared to the Direction enum. Most consumers have their own mapping definition
//startPosition += Direction { path[i] - 1 }; //startPosition += Direction { path[i] - 1 };

3
test/random_test.cpp

@ -132,7 +132,8 @@ TEST(RandomTest, ShiftModDistributionSignCarry)
// The Diablo LCG implementation attempts to improve the quality of generated numbers that would only use the low // The Diablo LCG implementation attempts to improve the quality of generated numbers that would only use the low
// bits of the LCG output but due to applying this after taking the absolute value this introduces bias. This may // bits of the LCG output but due to applying this after taking the absolute value this introduces bias. This may
// be an inconsistency with the implementation in devilutionx, see the comment for RandomTest_ShiftModDistributionHighBits // be an inconsistency with the implementation in devilutionx, see the comment for RandomTest_ShiftModDistributionHighBits
TEST(RandomTest, ShiftModDistributionLowBits) { TEST(RandomTest, ShiftModDistributionLowBits)
{
// All the following seeds generate values less than 2^16, so after shifting they give a 0 value // All the following seeds generate values less than 2^16, so after shifting they give a 0 value
constexpr auto maxBound = 65534; constexpr auto maxBound = 65534;

Loading…
Cancel
Save