Skip to content

Commit c78591b

Browse files
more maint
1 parent 4fd82c4 commit c78591b

20 files changed

+186
-178
lines changed

src/Etterna/Actor/Base/ActorFrame.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ ActorFrame::AddChild(Actor* pActor)
156156
#endif
157157

158158
ASSERT(pActor != nullptr);
159-
ASSERT(static_cast<void*>(pActor) != (void*)0xC0000005);
160159
m_SubActors.push_back(pActor);
161160

162161
pActor->SetParent(this);

src/Etterna/Actor/Base/ActorMultiVertex.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -631,21 +631,23 @@ void
631631
ActorMultiVertex::AMV_TweenState::SetDrawState(DrawMode dm, int first, int num)
632632
{
633633
if (first >= static_cast<int>(vertices.size()) && !vertices.empty()) {
634-
LuaHelpers::ReportScriptErrorFmt("ActorMultiVertex:SetDrawState: "
635-
"FirstToDraw > vertices.size(), %d > "
636-
"%u",
637-
FirstToDraw + 1,
638-
(unsigned int)vertices.size());
634+
LuaHelpers::ReportScriptErrorFmt(
635+
"ActorMultiVertex:SetDrawState: "
636+
"FirstToDraw > vertices.size(), %d > "
637+
"%u",
638+
FirstToDraw + 1,
639+
static_cast<unsigned int>(vertices.size()));
639640
return;
640641
}
641642
const auto safe_num = GetSafeNumToDraw(dm, num);
642643
if (num != safe_num && num != -1) {
643-
LuaHelpers::ReportScriptErrorFmt("ActorMultiVertex:SetDrawState: "
644-
"NumToDraw %d is not valid for %u "
645-
"vertices with DrawMode %s",
646-
num,
647-
(unsigned int)vertices.size(),
648-
DrawModeNames[dm]);
644+
LuaHelpers::ReportScriptErrorFmt(
645+
"ActorMultiVertex:SetDrawState: "
646+
"NumToDraw %d is not valid for %u "
647+
"vertices with DrawMode %s",
648+
num,
649+
static_cast<unsigned int>(vertices.size()),
650+
DrawModeNames[dm]);
649651
return;
650652
}
651653
_DrawMode = dm;
@@ -726,7 +728,7 @@ class LunaActorMultiVertex : public Luna<ActorMultiVertex>
726728
LuaHelpers::ReportScriptErrorFmt(
727729
"ActorMultiVertex::SetVertex: non-table parameter %u "
728730
"supplied inside table of parameters, table expected.",
729-
(unsigned int)i);
731+
static_cast<unsigned int>(i));
730732
return;
731733
}
732734
auto pushes = 1;
@@ -758,8 +760,8 @@ class LunaActorMultiVertex : public Luna<ActorMultiVertex>
758760
LuaHelpers::ReportScriptErrorFmt(
759761
"ActorMultiVertex::SetVertex: Parameter %u has %u elements "
760762
"supplied. 2, 3, or 4 expected.",
761-
(unsigned int)i,
762-
(unsigned int)DataPieceElements);
763+
static_cast<unsigned int>(i),
764+
static_cast<unsigned int>(DataPieceElements));
763765
}
764766
// Avoid a stack underflow by only popping the amount we pushed.
765767
lua_pop(L, pushes);
@@ -780,12 +782,13 @@ class LunaActorMultiVertex : public Luna<ActorMultiVertex>
780782
if (Index == static_cast<int>(p->GetNumVertices())) {
781783
p->AddVertices(1);
782784
} else if (Index > static_cast<int>(p->GetNumVertices())) {
783-
LuaHelpers::ReportScriptErrorFmt("ActorMultiVertex::SetVertex: "
784-
"Cannot set vertex %d if there is "
785-
"no vertex %d, only %u vertices.",
786-
Index + 1,
787-
Index,
788-
(unsigned int)p->GetNumVertices());
785+
LuaHelpers::ReportScriptErrorFmt(
786+
"ActorMultiVertex::SetVertex: "
787+
"Cannot set vertex %d if there is "
788+
"no vertex %d, only %u vertices.",
789+
Index + 1,
790+
Index,
791+
static_cast<unsigned int>(p->GetNumVertices()));
789792
COMMON_RETURN_SELF;
790793
}
791794
SetVertexFromStack(p, L, Index, lua_gettop(L));

src/Etterna/Actor/Base/BitmapText.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ BitmapText::BuildChars()
285285
{
286286
m_iLineWidths.push_back(
287287
m_pFont->GetLineWidthInSourcePixels(m_wTextLine));
288-
m_size.x = max(m_size.x, (float)m_iLineWidths.back());
288+
m_size.x = max(m_size.x, static_cast<float>(m_iLineWidths.back()));
289289
}
290290

291291
/* Ensure that the width is always even. This maintains pixel alignment;

src/Etterna/Actor/Base/RollingNumbers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ RollingNumbers::DrawPrimitives()
6767
auto s = this->GetText();
6868
int i;
6969
// find the first non-zero non-comma character, or the last character
70-
for (i = 0; i < (int)(s.length() - 1); i++) {
70+
for (i = 0; i < static_cast<int>(s.length() - 1); i++) {
7171
if (s[i] != '0' && s[i] != ',')
7272
break;
7373
}

src/Etterna/Actor/Gameplay/LifeMeterBar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
static std::string
1616
LIFE_PERCENT_CHANGE_NAME(size_t i)
1717
{
18-
return "LifePercentChange" + ScoreEventToString((ScoreEvent)i);
18+
return "LifePercentChange" + ScoreEventToString(static_cast<ScoreEvent>(i));
1919
}
2020

2121
float

src/Etterna/Actor/Gameplay/Player.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,8 +2076,7 @@ Player::Step(int col,
20762076
if (iSongRow < skipstart || iSongRow > static_cast<int>(nerv.size()) - 10) {
20772077
iStepSearchRows =
20782078
max(BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
2079-
GAMESTATE->m_Position.m_fMusicSeconds +
2080-
StepSearchDistance)) -
2079+
GAMESTATE->m_Position.m_fMusicSeconds + StepSearchDistance)) -
20812080
iSongRow,
20822081
iSongRow - BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
20832082
GAMESTATE->m_Position.m_fMusicSeconds -
@@ -2709,8 +2708,7 @@ Player::UpdateJudgedRows(float /*fDeltaTime*/)
27092708
{
27102709
// Look into the future only as far as we need to
27112710
const auto iEndRow = BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
2712-
GAMESTATE->m_Position.m_fMusicSeconds +
2713-
GetMaxStepDistanceSeconds()));
2711+
GAMESTATE->m_Position.m_fMusicSeconds + GetMaxStepDistanceSeconds()));
27142712
auto bAllJudged = true;
27152713

27162714
if (!GAMESTATE->CountNotesSeparately()) {

src/Etterna/Actor/Gameplay/ReceptorArrowRow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ ReceptorArrowRow::DrawOverlay()
122122
void
123123
ReceptorArrowRow::Step(int iCol, TapNoteScore score)
124124
{
125-
ASSERT(iCol >= 0 && iCol < (int)m_ReceptorArrow.size());
125+
ASSERT(iCol >= 0 && iCol < static_cast<int>(m_ReceptorArrow.size()));
126126
m_ReceptorArrow[iCol]->Step(score);
127127
}
128128

129129
void
130130
ReceptorArrowRow::SetPressed(int iCol)
131131
{
132-
ASSERT(iCol >= 0 && iCol < (int)m_ReceptorArrow.size());
132+
ASSERT(iCol >= 0 && iCol < static_cast<int>(m_ReceptorArrow.size()));
133133
m_ReceptorArrow[iCol]->SetPressed();
134134
}

src/RageUtil/Graphics/RageDisplay_D3D.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,10 @@ class RageCompiledGeometrySWD3D : public RageCompiledGeometry
948948
public:
949949
void Allocate(const vector<msMesh>& /*vMeshes*/) override
950950
{
951-
m_vVertex.resize(std::max(1U, (unsigned)GetTotalVertices()));
952-
m_vTriangles.resize(std::max(1U, (unsigned)GetTotalTriangles()));
951+
m_vVertex.resize(
952+
std::max(1U, static_cast<unsigned>(GetTotalVertices())));
953+
m_vTriangles.resize(
954+
std::max(1U, static_cast<unsigned>(GetTotalTriangles())));
953955
}
954956

955957
void Change(const vector<msMesh>& vMeshes) override
@@ -1660,7 +1662,7 @@ RageDisplay_D3D::DeleteTexture(intptr_t iTexHandle)
16601662
return;
16611663
}
16621664

1663-
auto* pTex = (IDirect3DTexture9*)iTexHandle;
1665+
auto* pTex = reinterpret_cast<IDirect3DTexture9*>(iTexHandle);
16641666
pTex->Release();
16651667

16661668
// Delete render target (if any)
@@ -1707,7 +1709,7 @@ RageDisplay_D3D::CreateTexture(RagePixelFormat pixfmt,
17071709
GetErrorString(hr).c_str());
17081710
}
17091711

1710-
const auto uTexHandle = (intptr_t)pTex;
1712+
const auto uTexHandle = reinterpret_cast<intptr_t>(pTex);
17111713

17121714
if (pixfmt == RagePixelFormat_PAL) {
17131715
// Save palette
@@ -1739,7 +1741,7 @@ RageDisplay_D3D::UpdateTexture(intptr_t uTexHandle,
17391741
int width,
17401742
int height)
17411743
{
1742-
auto* pTex = (IDirect3DTexture9*)uTexHandle;
1744+
auto* pTex = reinterpret_cast<IDirect3DTexture9*>(uTexHandle);
17431745
ASSERT(pTex != nullptr);
17441746

17451747
RECT rect;
@@ -1815,7 +1817,7 @@ class D3DRenderTarget_FramebufferObject : public RenderTarget
18151817
int& iTextureHeightOut) override;
18161818
[[nodiscard]] auto GetTexture() const -> intptr_t override
18171819
{
1818-
return (intptr_t)m_uTexHandle;
1820+
return reinterpret_cast<intptr_t>(m_uTexHandle);
18191821
}
18201822
void StartRenderingTo() override;
18211823
void FinishRenderingTo() override;

src/RageUtil/Graphics/RageDisplay_OGL.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,11 +1116,13 @@ class RageCompiledGeometrySWOGL : public RageCompiledGeometry
11161116
void Allocate(const vector<msMesh>& vMeshes) override
11171117
{
11181118
/* Always allocate at least 1 entry, so &x[0] is valid. */
1119-
m_vPosition.resize(max(1U, (unsigned)GetTotalVertices()));
1120-
m_vTexture.resize(max(1U, (unsigned)GetTotalVertices()));
1121-
m_vNormal.resize(max(1U, (unsigned)GetTotalVertices()));
1122-
m_vTexMatrixScale.resize(max(1U, (unsigned)GetTotalVertices()));
1123-
m_vTriangles.resize(max(1U, (unsigned)GetTotalTriangles()));
1119+
m_vPosition.resize(max(1U, static_cast<unsigned>(GetTotalVertices())));
1120+
m_vTexture.resize(max(1U, static_cast<unsigned>(GetTotalVertices())));
1121+
m_vNormal.resize(max(1U, static_cast<unsigned>(GetTotalVertices())));
1122+
m_vTexMatrixScale.resize(
1123+
max(1U, static_cast<unsigned>(GetTotalVertices())));
1124+
m_vTriangles.resize(
1125+
max(1U, static_cast<unsigned>(GetTotalTriangles())));
11241126
}
11251127
void Change(const vector<msMesh>& vMeshes) override
11261128
{

src/RageUtil/Graphics/RageDisplay_OGL_Helpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ RageDisplay_Legacy_Helpers::GLToString(GLenum e)
5353
if (g_Strings.find(e) != g_Strings.end())
5454
return g_Strings[e];
5555

56-
return ssprintf("%i", int(e));
56+
return ssprintf("%i", static_cast<int>(e));
5757
}

src/RageUtil/Misc/RageInputDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ DeviceButtonToString(DeviceButton key)
152152

153153
// Check the name map first to allow making names for keys that are inside
154154
// the ascii range. -Kyz
155-
std::map<DeviceButton, std::string>::const_iterator it =
155+
const std::map<DeviceButton, std::string>::const_iterator it =
156156
g_mapNamesToString.find(key);
157157
if (it != g_mapNamesToString.end())
158158
return it->second;
@@ -194,7 +194,7 @@ StringToDeviceButton(const std::string& s)
194194
if (sscanf(s.c_str(), "Mouse %i", &i) == 1)
195195
return enum_add2(MOUSE_LEFT, i);
196196

197-
std::map<std::string, DeviceButton>::const_iterator it =
197+
const std::map<std::string, DeviceButton>::const_iterator it =
198198
g_mapStringToNames.find(s);
199199
if (it != g_mapStringToNames.end())
200200
return it->second;

src/RageUtil/Misc/RageLog.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ RageLog::Trace(const char* fmt, ...)
215215
{
216216
va_list va;
217217
va_start(va, fmt);
218-
std::string sBuff = vssprintf(fmt, va);
218+
const std::string sBuff = vssprintf(fmt, va);
219219
va_end(va);
220220

221221
Write(0, sBuff);
@@ -228,7 +228,7 @@ RageLog::Info(const char* fmt, ...)
228228
{
229229
va_list va;
230230
va_start(va, fmt);
231-
std::string sBuff = vssprintf(fmt, va);
231+
const std::string sBuff = vssprintf(fmt, va);
232232
va_end(va);
233233

234234
Write(WRITE_TO_INFO, sBuff);
@@ -239,7 +239,7 @@ RageLog::Warn(const char* fmt, ...)
239239
{
240240
va_list va;
241241
va_start(va, fmt);
242-
std::string sBuff = vssprintf(fmt, va);
242+
const std::string sBuff = vssprintf(fmt, va);
243243
va_end(va);
244244

245245
Write(WRITE_TO_INFO | WRITE_LOUD, sBuff);
@@ -250,7 +250,7 @@ RageLog::Time(const char* fmt, ...)
250250
{
251251
va_list va;
252252
va_start(va, fmt);
253-
std::string sBuff = vssprintf(fmt, va);
253+
const std::string sBuff = vssprintf(fmt, va);
254254
va_end(va);
255255

256256
Write(WRITE_TO_TIME, sBuff);
@@ -291,7 +291,7 @@ RageLog::Write(int where, const std::string& sLine)
291291
puts(sWarningSeparator);
292292
}
293293

294-
std::string sTimestamp =
294+
const std::string sTimestamp =
295295
SecondsToMMSSMsMsMs(RageTimer::GetTimeSinceStart()) + ": ";
296296
std::string sWarning;
297297
if (where & WRITE_LOUD)
@@ -354,12 +354,13 @@ RageLog::AddToInfo(const std::string& str)
354354
if (limit_reached)
355355
return;
356356

357-
unsigned len = str.size() + strlen(NEWLINE);
357+
const unsigned len = str.size() + strlen(NEWLINE);
358358
if (staticlog_size + len > sizeof(staticlog)) {
359359
const std::string txt(NEWLINE "Staticlog limit reached" NEWLINE);
360360

361361
const unsigned pos =
362-
std::min(staticlog_size, unsigned(sizeof(staticlog) - txt.size()));
362+
std::min(staticlog_size,
363+
static_cast<unsigned>(sizeof(staticlog) - txt.size()));
363364
memcpy(staticlog + pos, txt.data(), txt.size());
364365
limit_reached = true;
365366
return;
@@ -431,8 +432,8 @@ RageLog::UpdateMappedLog()
431432
const char*
432433
RageLog::GetAdditionalLog()
433434
{
434-
int size =
435-
std::min(g_AdditionalLogSize, (int)sizeof(g_AdditionalLogStr) - 1);
435+
const int size = std::min(g_AdditionalLogSize,
436+
static_cast<int>(sizeof(g_AdditionalLogStr)) - 1);
436437
g_AdditionalLogStr[size] = 0;
437438
return g_AdditionalLogStr;
438439
}

0 commit comments

Comments
 (0)