Browse Source

Fix MSVC warnings in qol\*

pull/6823/head
obligaron 2 years ago committed by Anders Jenbo
parent
commit
f31def7c33
  1. 8
      Source/qol/chatlog.cpp
  2. 6
      Source/qol/floatingnumbers.cpp
  3. 4
      Source/qol/xpbar.cpp

8
Source/qol/chatlog.cpp

@ -41,7 +41,7 @@ struct MultiColoredText {
};
bool UnreadFlag = false;
unsigned int SkipLines;
size_t SkipLines;
unsigned int MessageCounter = 0;
std::vector<MultiColoredText> ChatLogLines;
@ -122,7 +122,7 @@ void AddMessageToChatLog(std::string_view message, Player *player, UiFlags flags
const std::tm *localtimeResult = localtime(&timeResult);
std::string timestamp = localtimeResult != nullptr ? fmt::format("[#{:d}] {:02}:{:02}:{:02}", MessageCounter, localtimeResult->tm_hour, localtimeResult->tm_min, localtimeResult->tm_sec)
: fmt::format("[#{:d}] ", MessageCounter);
int oldSize = ChatLogLines.size();
size_t oldSize = ChatLogLines.size();
if (player == nullptr) {
ChatLogLines.emplace_back(MultiColoredText { "{0} {1}", { { timestamp, UiFlags::ColorRed }, { std::string(message), flags } } });
} else {
@ -136,14 +136,14 @@ void AddMessageToChatLog(std::string_view message, Player *player, UiFlags flags
for (std::string s; getline(ss, s, '\n');) {
lines.push_back(s);
}
for (int i = lines.size() - 1; i >= 1; i--) {
for (int i = static_cast<int>(lines.size()) - 1; i >= 1; i--) {
ChatLogLines.emplace_back(MultiColoredText { lines[i], {} });
}
lines[0].erase(0, prefix.length());
ChatLogLines.emplace_back(MultiColoredText { "{0} - {1}{2}", { { timestamp, UiFlags::ColorRed }, { playerInfo, nameColor }, { lines[0], UiFlags::ColorWhite } } });
}
unsigned int diff = ChatLogLines.size() - oldSize;
size_t diff = ChatLogLines.size() - oldSize;
// only autoscroll when on top of the log
if (SkipLines != 0) {
SkipLines += diff;

6
Source/qol/floatingnumbers.cpp

@ -24,7 +24,7 @@ struct FloatingNumber {
UiFlags style;
DamageType type;
int value;
int index;
size_t index;
bool reverseDirection;
};
@ -91,7 +91,7 @@ void UpdateFloatingData(FloatingNumber &num)
}
}
void AddFloatingNumber(Point pos, Displacement offset, DamageType type, int value, int index, bool damageToPlayer)
void AddFloatingNumber(Point pos, Displacement offset, DamageType type, int value, size_t index, bool damageToPlayer)
{
// 45 deg angles to avoid jitter caused by px alignment
Displacement goodAngles[] = {
@ -199,7 +199,7 @@ void DrawFloatingNumbers(const Surface &out, Point viewPosition, Displacement of
void ClearFloatingNumbers()
{
srand(time(nullptr));
srand(static_cast<unsigned int>(time(nullptr)));
FloatingQueue.clear();
}

4
Source/qol/xpbar.cpp

@ -100,10 +100,10 @@ void DrawXPBar(const Surface &out)
const uint64_t fade = (prevXpDelta1 - lastFullPx) * (SilverGradient.size() - 1) / onePx;
// Draw beginning of bar full brightness
DrawBar(out, position, fullBar, SilverGradient);
DrawBar(out, position, static_cast<int>(fullBar), SilverGradient);
// End pixels appear gradually
DrawEndCap(out, position + Displacement { static_cast<int>(fullBar), 0 }, fade, SilverGradient);
DrawEndCap(out, position + Displacement { static_cast<int>(fullBar), 0 }, static_cast<int>(fade), SilverGradient);
}
bool CheckXPBarInfo()

Loading…
Cancel
Save