Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MSVC warnings in qol\* #6817

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Source/qol/chatlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct MultiColoredText {
};

bool UnreadFlag = false;
unsigned int SkipLines;
size_t SkipLines;
unsigned int MessageCounter = 0;

std::vector<MultiColoredText> ChatLogLines;
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Source/qol/floatingnumbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct FloatingNumber {
UiFlags style;
DamageType type;
int value;
int index;
size_t index;
bool reverseDirection;
};

Expand Down Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/qol/xpbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading