Skip to content

Commit c81163d

Browse files
author
LocalIdentity
committed
Use Static Casts
Changes some of the type declarations to use static_cast
1 parent a2e402c commit c81163d

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

engine/render/r_font.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ int r_font_c::StringWidthInternal(f_fontHeight_s* fh, std::u32string_view str, i
178178
++idx;
179179
}
180180
}
181-
return (int)width;
181+
return static_cast<int>(width);
182182
}
183183

184184
int r_font_c::StringWidth(int height, std::u32string_view str)

engine/render/r_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,14 +1883,14 @@ int r_renderer_c::VirtualMap(int properValue) {
18831883
if (apiDpiAware) {
18841884
return properValue;
18851885
}
1886-
return (int)(properValue / sys->video->vid.dpiScale);
1886+
return static_cast<int>(properValue / sys->video->vid.dpiScale);
18871887
}
18881888

18891889
int r_renderer_c::VirtualUnmap(int mappedValue) {
18901890
if (apiDpiAware) {
18911891
return mappedValue;
18921892
}
1893-
return (int)(mappedValue * sys->video->vid.dpiScale);
1893+
return static_cast<int>(mappedValue * sys->video->vid.dpiScale);
18941894
}
18951895

18961896
// =====

ui_api.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,10 @@ static int l_SetViewport(lua_State* L)
800800
for (int i = 1; i <= 4; i++) {
801801
ui->LAssert(L, lua_isnumber(L, i), "SetViewport() argument %d: expected number, got %s", i, luaL_typename(L, i));
802802
}
803-
int vpX = (int)std::lround(lua_tonumber(L, 1) * dpiScale);
804-
int vpY = (int)std::lround(lua_tonumber(L, 2) * dpiScale);
805-
int vpWidth = (int)std::ceil(lua_tonumber(L, 3) * dpiScale);
806-
int vpHeight = (int)std::ceil(lua_tonumber(L, 4) * dpiScale);
803+
int vpX = static_cast<int>(std::lround(lua_tonumber(L, 1) * dpiScale));
804+
int vpY = static_cast<int>(std::lround(lua_tonumber(L, 2) * dpiScale));
805+
int vpWidth = static_cast<int>(std::ceil(lua_tonumber(L, 3) * dpiScale));
806+
int vpHeight = static_cast<int>(std::ceil(lua_tonumber(L, 4) * dpiScale));
807807
ui->renderer->SetViewport(vpX, vpY, vpWidth, vpHeight);
808808
}
809809
else {
@@ -1105,7 +1105,7 @@ static int l_DrawStringWidth(lua_State* L)
11051105
static const char* fontMap[4] = { "FIXED", "VAR", "VAR BOLD", NULL };
11061106
const float dpiScale = ui->renderer->VirtualScreenScaleFactor();
11071107
const lua_Number logicalHeight = lua_tonumber(L, 1);
1108-
int scaledHeight = (int)std::lround(logicalHeight * dpiScale);
1108+
int scaledHeight = static_cast<int>(std::lround(logicalHeight * dpiScale));
11091109
if (scaledHeight <= 1) {
11101110
scaledHeight = std::max(1, scaledHeight);
11111111
}
@@ -1136,20 +1136,20 @@ static int l_DrawStringCursorIndex(lua_State* L)
11361136
const lua_Number logicalHeight = lua_tonumber(L, 1);
11371137
const lua_Number logicalCursorX = lua_tonumber(L, 4);
11381138
const lua_Number logicalCursorY = lua_tonumber(L, 5);
1139-
int scaledHeight = (int)std::lround(logicalHeight * dpiScale);
1139+
int scaledHeight = static_cast<int>(std::lround(logicalHeight * dpiScale));
11401140
if (scaledHeight <= 1) {
11411141
scaledHeight = std::max(1, scaledHeight);
11421142
}
11431143
else {
11441144
scaledHeight = (scaledHeight + 1) & ~1;
11451145
}
1146-
const int scaledCursorX = (int)std::lround(logicalCursorX * dpiScale);
1147-
const int scaledCursorY = (int)std::lround(logicalCursorY * dpiScale);
1148-
lua_pushinteger(L, ui->renderer->DrawStringCursorIndex(
1146+
const int scaledCursorX = static_cast<int>(std::lround(logicalCursorX * dpiScale));
1147+
const int scaledCursorY = static_cast<int>(std::lround(logicalCursorY * dpiScale));
1148+
lua_pushinteger(L, static_cast<lua_Integer>(ui->renderer->DrawStringCursorIndex(
11491149
scaledHeight,
11501150
luaL_checkoption(L, 2, "FIXED", fontMap),
11511151
lua_tostring(L, 3),
1152-
scaledCursorX, scaledCursorY) + 1);
1152+
scaledCursorX, scaledCursorY) + 1));
11531153
return 1;
11541154
}
11551155

0 commit comments

Comments
 (0)