Skip to content

Commit

Permalink
Fix some MSVC warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
obligaron authored and glebm committed Dec 2, 2023
1 parent f445bb4 commit 22ec684
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Source/levels/gendung.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ void LoadTransparency(const uint16_t *dunData)

for (WorldTileCoord j = 0; j < size.height; j++) {
for (WorldTileCoord i = 0; i < size.width; i++) {
dTransVal[16 + i][16 + j] = SDL_SwapLE16(*transparentLayer);
dTransVal[16 + i][16 + j] = static_cast<int8_t>(SDL_SwapLE16(*transparentLayer));
transparentLayer++;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ float GetIniFloat(const char *sectionName, const char *keyName, float defaultVal
return (float)GetIni().GetDoubleValue(sectionName, keyName, defaultValue);
}

bool GetIniValue(std::string_view sectionName, std::string_view keyName, char *string, int stringSize, const char *defaultString = "")
bool GetIniValue(std::string_view sectionName, std::string_view keyName, char *string, size_t stringSize, const char *defaultString = "")
{
std::string sectionNameStr { sectionName };
std::string keyNameStr { keyName };
Expand Down Expand Up @@ -941,7 +941,7 @@ std::string_view OptionEntryAudioDevice::GetDeviceName(size_t index) const
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
if (index != 0)
return SDL_GetAudioDeviceName(index - 1, false);
return SDL_GetAudioDeviceName(static_cast<int>(index) - 1, false);
#endif
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion Source/panels/charpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void DrawShadowString(const Surface &out, const PanelEntry &entry)

// If the text is less tall than the field, we center it vertically relative to the field.
// Otherwise, we draw from the top of the field.
const int textHeight = (c_count(wrapped, '\n') + 1) * GetLineHeight(wrapped, GameFont12);
const int textHeight = static_cast<int>((c_count(wrapped, '\n') + 1) * GetLineHeight(wrapped, GameFont12));
const int labelHeight = std::max(PanelFieldHeight, textHeight);

DrawString(out, text, { labelPosition + Displacement { -2, 2 }, { entry.labelLength, labelHeight } },
Expand Down
6 changes: 3 additions & 3 deletions Source/panels/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ const ConsoleLine &GetConsoleLineFromEnd(int index)
void SetHistoryIndex(int index)
{
CurrentInputTextState = InputTextState::RestoredFromHistory;
HistoryIndex = std::ssize(ConsoleLines) - (index + 1);
HistoryIndex = static_cast<int>(std::ssize(ConsoleLines)) - (index + 1);
if (HistoryIndex == -1) {
ConsoleInputState.assign(DraftInput);
return;
Expand All @@ -335,7 +335,7 @@ void PrevHistoryItem(tl::function_ref<bool(const ConsoleLine &line)> filter)
if (HistoryIndex == -1) {
DraftInput = ConsoleInputState.value();
}
const int n = std::ssize(ConsoleLines);
const int n = static_cast<int>(std::ssize(ConsoleLines));
for (int i = HistoryIndex + 1; i < n; ++i) {
const int index = n - (i + 1);
if (filter(ConsoleLines[index])) {
Expand All @@ -347,7 +347,7 @@ void PrevHistoryItem(tl::function_ref<bool(const ConsoleLine &line)> filter)

void NextHistoryItem(tl::function_ref<bool(const ConsoleLine &line)> filter)
{
const int n = std::ssize(ConsoleLines);
const int n = static_cast<int>(std::ssize(ConsoleLines));
for (int i = n - HistoryIndex; i < n; ++i) {
if (filter(ConsoleLines[i])) {
SetHistoryIndex(i);
Expand Down
2 changes: 1 addition & 1 deletion Source/plrmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ std::array<PlayerMessage, 8> Messages;

int CountLinesOfText(std::string_view text)
{
return 1 + c_count(text, '\n');
return static_cast<int>(1 + c_count(text, '\n'));
}

PlayerMessage &GetNextMessage()
Expand Down
2 changes: 1 addition & 1 deletion Source/qol/autopickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void AutoPickup(const Player &player)
int itemIndex = dItem[tile.x][tile.y] - 1;
auto &item = Items[itemIndex];
if (DoPickup(item)) {
NetSendCmdGItem(true, CMD_REQUESTAGITEM, player.getId(), itemIndex);
NetSendCmdGItem(true, CMD_REQUESTAGITEM, static_cast<uint8_t>(player.getId()), itemIndex);
item._iRequest = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void RepeatMouseAction()
break;
case MouseActionType::AttackPlayerTarget:
if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode)
NetSendCmdParam1(true, rangedAttack ? CMD_RATTACKPID : CMD_ATTACKPID, PlayerUnderCursor->getId());
NetSendCmdParam1(true, rangedAttack ? CMD_RATTACKPID : CMD_ATTACKPID, static_cast<uint16_t>(PlayerUnderCursor->getId()));
break;
case MouseActionType::Spell:
if (ControlMode != ControlTypes::KeyboardAndMouse) {
Expand Down

0 comments on commit 22ec684

Please sign in to comment.