diff --git a/src/gamelog.cpp b/src/gamelog.cpp --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -328,12 +328,9 @@ void GamelogPrint(std::functiongrfrem.grfid); - switch (lc->grfbug.bug) { - 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); - break; - } + assert (lc->grfbug.bug == 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 = 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!"); break; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -360,12 +360,9 @@ public: void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (!gui_scope) return; - switch (data) { - case 1: - /* ReInit, "debug" sprite might have changed */ - this->ReInit(); - break; - } + + /* ReInit, "debug" sprite might have changed */ + if (data == 1) this->ReInit(); } }; diff --git a/src/object_gui.cpp b/src/object_gui.cpp --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -565,20 +565,17 @@ public: { if (pt.x == -1) return; - switch (select_proc) { - default: NOT_REACHED(); - case DDSP_BUILD_OBJECT: - if (!_settings_game.construction.freeform_edges) { - /* When end_tile is MP_VOID, the error tile will not be visible to the - * user. This happens when terraforming at the southern border. */ - if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0); - if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1); - } - const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index); - Command::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, - end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false)); - break; + assert(select_proc == DDSP_BUILD_OBJECT); + + if (!_settings_game.construction.freeform_edges) { + /* When end_tile is MP_VOID, the error tile will not be visible to the + * user. This happens when terraforming at the southern border. */ + if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0); + if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1); } + const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index); + Command::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, + end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false)); } void OnPlaceObjectAbort() override diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -552,9 +552,7 @@ static CallBackFunction ToolbarSubsidies */ static CallBackFunction MenuClickSubsidies(int index) { - switch (index) { - case 0: ShowSubsidiesList(); break; - } + ShowSubsidiesList(); return CBF_NONE; } diff --git a/src/video/opengl.cpp b/src/video/opengl.cpp --- a/src/video/opengl.cpp +++ b/src/video/opengl.cpp @@ -955,14 +955,10 @@ bool OpenGLBackend::Resize(int w, int h, _glActiveTexture(GL_TEXTURE0); _glBindTexture(GL_TEXTURE_2D, this->vid_texture); - switch (bpp) { - case 8: - _glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, nullptr); - break; - - default: - _glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr); - break; + if (bpp == 8) { + _glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, nullptr); + } else { + _glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr); } _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); @@ -1224,14 +1220,10 @@ void OpenGLBackend::ReleaseVideoBuffer(c _glActiveTexture(GL_TEXTURE0); _glBindTexture(GL_TEXTURE_2D, this->vid_texture); _glPixelStorei(GL_UNPACK_ROW_LENGTH, _screen.pitch); - switch (BlitterFactory::GetCurrentBlitter()->GetScreenDepth()) { - 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)); - break; - - 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)); - break; + if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 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)); + } else { + _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)); } #ifndef NO_GL_BUFFER_SYNC