1
0
Fork 0

Codechange: Simplify some CodeQL-flagged trivial switches

pull/10537/merge
Tyler Trahan 2023-03-25 15:40:59 -04:00
parent a15e584e40
commit 066ae6f3fb
5 changed files with 25 additions and 44 deletions

View File

@ -328,12 +328,9 @@ void GamelogPrint(std::function<void(const char*)> proc)
case GLCT_GRFBUG: { case GLCT_GRFBUG: {
/* A specific bug in a NewGRF, that could cause wide spread problems, has been noted during the execution of the game. */ /* A specific bug in a NewGRF, that could cause wide spread problems, has been noted during the execution of the game. */
GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid); GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid);
switch (lc->grfbug.bug) { assert (lc->grfbug.bug == GBUG_VEH_LENGTH);
default: NOT_REACHED();
case GBUG_VEH_LENGTH:
buf += seprintf(buf, lastof(buffer), "Rail vehicle changes length outside a depot: GRF ID %08X, internal ID 0x%X", BSWAP32(lc->grfbug.grfid), (uint)lc->grfbug.data); buf += seprintf(buf, lastof(buffer), "Rail vehicle changes length outside a depot: GRF ID %08X, internal ID 0x%X", BSWAP32(lc->grfbug.grfid), (uint)lc->grfbug.data);
break;
}
buf = PrintGrfInfo(buf, lastof(buffer), lc->grfbug.grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr); buf = PrintGrfInfo(buf, lastof(buffer), lc->grfbug.grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
if (gm == grf_names.End()) buf += seprintf(buf, lastof(buffer), ". Gamelog inconsistency: GrfID was never added!"); if (gm == grf_names.End()) buf += seprintf(buf, lastof(buffer), ". Gamelog inconsistency: GrfID was never added!");
break; break;

View File

@ -360,12 +360,9 @@ public:
void OnInvalidateData(int data = 0, bool gui_scope = true) override void OnInvalidateData(int data = 0, bool gui_scope = true) override
{ {
if (!gui_scope) return; if (!gui_scope) return;
switch (data) {
case 1:
/* ReInit, "debug" sprite might have changed */ /* ReInit, "debug" sprite might have changed */
this->ReInit(); if (data == 1) this->ReInit();
break;
}
} }
}; };

View File

@ -565,9 +565,8 @@ public:
{ {
if (pt.x == -1) return; if (pt.x == -1) return;
switch (select_proc) { assert(select_proc == DDSP_BUILD_OBJECT);
default: NOT_REACHED();
case DDSP_BUILD_OBJECT:
if (!_settings_game.construction.freeform_edges) { if (!_settings_game.construction.freeform_edges) {
/* When end_tile is MP_VOID, the error tile will not be visible to the /* When end_tile is MP_VOID, the error tile will not be visible to the
* user. This happens when terraforming at the southern border. */ * user. This happens when terraforming at the southern border. */
@ -577,8 +576,6 @@ public:
const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index); const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
Command<CMD_BUILD_OBJECT_AREA>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, Command<CMD_BUILD_OBJECT_AREA>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER,
end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false)); end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false));
break;
}
} }
void OnPlaceObjectAbort() override void OnPlaceObjectAbort() override

View File

@ -552,9 +552,7 @@ static CallBackFunction ToolbarSubsidiesClick(Window *w)
*/ */
static CallBackFunction MenuClickSubsidies(int index) static CallBackFunction MenuClickSubsidies(int index)
{ {
switch (index) { ShowSubsidiesList();
case 0: ShowSubsidiesList(); break;
}
return CBF_NONE; return CBF_NONE;
} }

View File

@ -955,14 +955,10 @@ bool OpenGLBackend::Resize(int w, int h, bool force)
_glActiveTexture(GL_TEXTURE0); _glActiveTexture(GL_TEXTURE0);
_glBindTexture(GL_TEXTURE_2D, this->vid_texture); _glBindTexture(GL_TEXTURE_2D, this->vid_texture);
switch (bpp) { if (bpp == 8) {
case 8:
_glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, nullptr); _glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, nullptr);
break; } else {
default:
_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr); _glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
break;
} }
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
@ -1224,14 +1220,10 @@ void OpenGLBackend::ReleaseVideoBuffer(const Rect &update_rect)
_glActiveTexture(GL_TEXTURE0); _glActiveTexture(GL_TEXTURE0);
_glBindTexture(GL_TEXTURE_2D, this->vid_texture); _glBindTexture(GL_TEXTURE_2D, this->vid_texture);
_glPixelStorei(GL_UNPACK_ROW_LENGTH, _screen.pitch); _glPixelStorei(GL_UNPACK_ROW_LENGTH, _screen.pitch);
switch (BlitterFactory::GetCurrentBlitter()->GetScreenDepth()) { if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 8) {
case 8:
_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_RED, GL_UNSIGNED_BYTE, (GLvoid*)(size_t)(update_rect.top * _screen.pitch + update_rect.left)); _glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_RED, GL_UNSIGNED_BYTE, (GLvoid*)(size_t)(update_rect.top * _screen.pitch + update_rect.left));
break; } else {
default:
_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (GLvoid*)(size_t)(update_rect.top * _screen.pitch * 4 + update_rect.left * 4)); _glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (GLvoid*)(size_t)(update_rect.top * _screen.pitch * 4 + update_rect.left * 4));
break;
} }
#ifndef NO_GL_BUFFER_SYNC #ifndef NO_GL_BUFFER_SYNC