diff --git a/src/common/HighScoresManager.hxx b/src/common/HighScoresManager.hxx index 6768840c4..3b293c172 100644 --- a/src/common/HighScoresManager.hxx +++ b/src/common/HighScoresManager.hxx @@ -92,7 +92,7 @@ namespace HSM { class HighScoresManager { public: - HighScoresManager(OSystem& osystem); + explicit HighScoresManager(OSystem& osystem); virtual ~HighScoresManager() = default; diff --git a/src/common/PaletteHandler.hxx b/src/common/PaletteHandler.hxx index 42ba37cfc..d5cda3a4b 100644 --- a/src/common/PaletteHandler.hxx +++ b/src/common/PaletteHandler.hxx @@ -65,7 +65,7 @@ class PaletteHandler }; public: - PaletteHandler(OSystem& system); + explicit PaletteHandler(OSystem& system); /** Cycle through available palettes. diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 40b95b0f0..fb1fb6632 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -273,7 +273,7 @@ void SoundSDL2::adjustVolume(int direction) if(percent > 0 && !enabled) { - setEnabled(!enabled); + setEnabled(true); myOSystem.console().initializeAudio(); } diff --git a/src/common/VideoModeHandler.cxx b/src/common/VideoModeHandler.cxx index e15b12b1c..185ce0d61 100644 --- a/src/common/VideoModeHandler.cxx +++ b/src/common/VideoModeHandler.cxx @@ -105,14 +105,12 @@ VideoModeHandler::Mode::Mode(uInt32 iw, uInt32 ih, Stretch smode, VideoModeHandler::Mode::Mode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, Stretch smode, Int32 fsindex, const string& desc, float zoomLevel, float overscan) - : stretch(smode), + : screenS(sw, sh), + stretch(smode), description(desc), zoom(zoomLevel), fsIndex(fsindex) { - // First set default size and positioning - screenS = Common::Size(sw, sh); - // Now resize based on windowed/fullscreen mode and stretch factor if(fsIndex != -1) // fullscreen mode { diff --git a/src/common/tv_filters/NTSCFilter.cxx b/src/common/tv_filters/NTSCFilter.cxx index 5a61dd140..14c38697e 100644 --- a/src/common/tv_filters/NTSCFilter.cxx +++ b/src/common/tv_filters/NTSCFilter.cxx @@ -192,7 +192,7 @@ void NTSCFilter::getAdjustables(Adjustable& adjustable, Preset preset) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void NTSCFilter::setCustomAdjustables(Adjustable& adjustable) +void NTSCFilter::setCustomAdjustables(const Adjustable& adjustable) { #ifdef BLARGG_PALETTE //myCustomSetup.hue = scaleFrom100(adjustable.hue); diff --git a/src/common/tv_filters/NTSCFilter.hxx b/src/common/tv_filters/NTSCFilter.hxx index b4b3aa713..fd5335806 100644 --- a/src/common/tv_filters/NTSCFilter.hxx +++ b/src/common/tv_filters/NTSCFilter.hxx @@ -90,7 +90,7 @@ class NTSCFilter // Set custom adjustables to given values // Values will be scaled to 0 - 100 range, independent of how // they're actually stored internally - void setCustomAdjustables(Adjustable& adjustable); + void setCustomAdjustables(const Adjustable& adjustable); // The following methods cycle through each custom adjustable // They are used in conjunction with the increase/decrease diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index ab988e000..ad2e623d7 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -1516,7 +1516,7 @@ CartDebug::AddrType CartDebug::addressType(uInt16 addr) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartDebug::getBankDirectives(ostream& buf, BankInfo& info) const +void CartDebug::getBankDirectives(ostream& buf, const BankInfo& info) const { // Start with the offset for this bank buf << "ORG " << Base::HEX4 << info.offset << endl; diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index 25dd59e63..21b01d0e2 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -324,7 +324,7 @@ class CartDebug : public DebuggerSystem // Analyze of bank of ROM, generating a list of Distella directives // based on its disassembly - void getBankDirectives(ostream& buf, BankInfo& info) const; + void getBankDirectives(ostream& buf, const BankInfo& info) const; // Get access enum type from 'flags', taking precendence into account Device::AccessType accessTypeAbsolute(Device::AccessFlags flags) const; diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index abfc63ac1..c7c65f2ec 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -716,10 +716,8 @@ bool Debugger::addFunction(const string& name, const string& definition, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Debugger::isBuiltinFunction(const string& name) { - for(const auto& func: ourBuiltinFunctions) - if(name == func.name) - return true; - return false; + return std::any_of(ourBuiltinFunctions.cbegin(), ourBuiltinFunctions.cend(), + [&](const auto& func) { return name == func.name; }); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/CartBUSWidget.cxx b/src/debugger/gui/CartBUSWidget.cxx index 8f6a9b22b..dbfe8c172 100644 --- a/src/debugger/gui/CartBUSWidget.cxx +++ b/src/debugger/gui/CartBUSWidget.cxx @@ -75,7 +75,6 @@ CartridgeBUSWidget::CartridgeBUSWidget( ypos += myLineHeight + 4; new StaticTextWidget(boss, _font, xpos, ypos, lwidth, myFontHeight, "Datastream Pointers", TextAlign::Left); - xpos += lwidth; myDatastreamPointers = new DataGridWidget(boss, _nfont, DS_X, ypos+myLineHeight-2, 4, 4, 6, 32, Common::Base::Fmt::_16_3_2); myDatastreamPointers->setTarget(this); diff --git a/src/debugger/gui/CartDPCWidget.cxx b/src/debugger/gui/CartDPCWidget.cxx index 681b3692d..c626b52fa 100644 --- a/src/debugger/gui/CartDPCWidget.cxx +++ b/src/debugger/gui/CartDPCWidget.cxx @@ -68,11 +68,10 @@ CartridgeDPCWidget::CartridgeDPCWidget( ypos += myLineHeight + V_GAP * 3; // Data fetchers - int lwidth = _font.getStringWidth("Data fetchers "); new StaticTextWidget(boss, _font, xpos, ypos, "Data fetchers "); // Top registers - lwidth = _font.getStringWidth("Counter registers "); + int lwidth = _font.getStringWidth("Counter registers "); xpos = 2 + _font.getMaxCharWidth() * 2; ypos += myLineHeight + 4; new StaticTextWidget(boss, _font, xpos, ypos, "Top registers "); xpos += lwidth; diff --git a/src/debugger/gui/TiaInfoWidget.cxx b/src/debugger/gui/TiaInfoWidget.cxx index fe2ce6d9b..9886da9b6 100644 --- a/src/debugger/gui/TiaInfoWidget.cxx +++ b/src/debugger/gui/TiaInfoWidget.cxx @@ -42,7 +42,6 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont, + COLUMN_GAP + lfont.getStringWidth("Scanline262262") + EditTextWidget::calcWidth(lfont) * 3 <= max_w; const int lineHeight = lfont.getLineHeight(); - int xpos = x, ypos = y + VBORDER; int lwidth = lfont.getStringWidth(longstr ? "Frame Cycls" : "F. Cycls"); int lwidth8 = lwidth - lfont.getMaxCharWidth() * 3; int lwidthR = lfont.getStringWidth(longstr ? "Frame Cnt." : "Frame "); @@ -57,7 +56,7 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont, // Left column // Left: Frame Cycle - xpos = x; + int xpos = x, ypos = y + VBORDER; new StaticTextWidget(boss, lfont, xpos, ypos + 1, longstr ? "Frame Cycls" : "F. Cycls"); myFrameCycles = new EditTextWidget(boss, nfont, xpos + lwidth, ypos - 1, fwidth, lineHeight); myFrameCycles->setToolTip("CPU cycles executed this frame."); diff --git a/src/emucore/AtariVox.cxx b/src/emucore/AtariVox.cxx index 6040b3f6d..95065cbec 100644 --- a/src/emucore/AtariVox.cxx +++ b/src/emucore/AtariVox.cxx @@ -24,9 +24,9 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system, const string& portname, const FilesystemNode& eepromfile, const onMessageCallback& callback) - : SaveKey(jack, event, system, eepromfile, callback, Controller::Type::AtariVox) + : SaveKey(jack, event, system, eepromfile, callback, Controller::Type::AtariVox), + mySerialPort(MediaFactory::createSerialPort()) { - mySerialPort = MediaFactory::createSerialPort(); if(mySerialPort->openPort(portname)) { myCTSFlip = !mySerialPort->isCTS(); diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 75dccc990..992b7b790 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -62,7 +62,7 @@ class FrameBuffer }; public: - FrameBuffer(OSystem& osystem); + explicit FrameBuffer(OSystem& osystem); ~FrameBuffer(); /** diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 40271748c..a07a319a3 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -746,7 +746,7 @@ double OSystem::dispatchEmulation(EmulationWorker& emulationWorker) if (!myConsole) return 0.; TIA& tia(myConsole->tia()); - EmulationTiming& timing(myConsole->emulationTiming()); + const EmulationTiming& timing = myConsole->emulationTiming(); DispatchResult dispatchResult; // Check whether we have a frame pending for rendering... @@ -758,8 +758,8 @@ double OSystem::dispatchEmulation(EmulationWorker& emulationWorker) tia.renderToFrameBuffer(); } - // Start emulation on a dedicated thread. It will do its own scheduling to sync 6507 and real time - // and will run until we stop the worker. + // Start emulation on a dedicated thread. It will do its own scheduling to + // sync 6507 and real time and will run until we stop the worker. emulationWorker.start( timing.cyclesPerSecond(), timing.maxCyclesPerTimeslice(), @@ -768,8 +768,8 @@ double OSystem::dispatchEmulation(EmulationWorker& emulationWorker) &tia ); - // Render the frame. This may block, but emulation will continue to run on the worker, so the - // audio pipeline is kept fed :) + // Render the frame. This may block, but emulation will continue to run on + // the worker, so the audio pipeline is kept fed :) if (framePending) myFrameBuffer->updateInEmulationMode(myFpsMeter.fps()); // Stop the worker and wait until it has finished @@ -805,11 +805,13 @@ double OSystem::dispatchEmulation(EmulationWorker& emulationWorker) } // Handle frying - if (dispatchResult.getStatus() == DispatchResult::Status::ok && myEventHandler->frying()) + if (dispatchResult.getStatus() == DispatchResult::Status::ok && + myEventHandler->frying()) myConsole->fry(); // Return the 6507 time used in seconds - return static_cast(totalCycles) / static_cast(timing.cyclesPerSecond()); + return static_cast(totalCycles) / + static_cast(timing.cyclesPerSecond()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Serializer.cxx b/src/emucore/Serializer.cxx index 7f94dced2..5b5640677 100644 --- a/src/emucore/Serializer.cxx +++ b/src/emucore/Serializer.cxx @@ -23,7 +23,6 @@ using std::ios_base; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Serializer::Serializer(const string& filename, Mode m) - : myStream(nullptr) { if(m == Mode::ReadOnly) { @@ -66,10 +65,8 @@ Serializer::Serializer(const string& filename, Mode m) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Serializer::Serializer() - : myStream(nullptr) + : myStream{make_unique(ios::in | ios::out | ios::binary)} { - myStream = make_unique(ios::in | ios::out | ios::binary); - // For some reason, Windows and possibly macOS needs to store something in // the stream before it is used for the first time if(myStream) diff --git a/src/emucore/Serializer.hxx b/src/emucore/Serializer.hxx index 10164f2a1..9a967a8e0 100644 --- a/src/emucore/Serializer.hxx +++ b/src/emucore/Serializer.hxx @@ -49,7 +49,7 @@ class Serializer The valid() method must immediately be called to verify the stream was correctly initialized. */ - Serializer(const string& filename, Mode m = Mode::ReadWrite); + explicit Serializer(const string& filename, Mode m = Mode::ReadWrite); Serializer(); public: diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index b11ed727b..4063687d9 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -33,9 +33,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Settings::Settings() + : myRespository(make_shared()) { - myRespository = make_shared(); - // If no version is recorded with the persisted settings, we set it to zero setPermanent(SETTINGS_VERSION_KEY, 0); setPermanent("stella.version", "6.2.1"); diff --git a/src/emucore/tia/Missile.cxx b/src/emucore/tia/Missile.cxx index 59c1fb493..2e2e12c31 100644 --- a/src/emucore/tia/Missile.cxx +++ b/src/emucore/tia/Missile.cxx @@ -43,7 +43,6 @@ void Missile::reset() myColor = myObjectColor = myDebugColor = 0; myDebugEnabled = false; collision = myCollisionMaskDisabled; - myIsEnabled = false; myInvertedPhaseClock = false; myUseInvertedPhaseClock = false; } diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 50fcbd295..8b052b032 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -300,7 +300,7 @@ void Dialog::addFocusWidget(Widget* w) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::addToFocusList(WidgetArray& list) +void Dialog::addToFocusList(const WidgetArray& list) { // All focusable widgets should retain focus for(const auto& w: list) @@ -314,7 +314,7 @@ void Dialog::addToFocusList(WidgetArray& list) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::addToFocusList(WidgetArray& list, TabWidget* w, int tabId) +void Dialog::addToFocusList(const WidgetArray& list, TabWidget* w, int tabId) { // Only add the list if the tab actually exists if(!w || w->getID() >= _myTabList.size()) diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index a159a8107..0cc145d55 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -71,9 +71,9 @@ class Dialog : public GuiObject void tick() override; void addFocusWidget(Widget* w) override; - void addToFocusList(WidgetArray& list) override; - void addToFocusList(WidgetArray& list, TabWidget* w, int tabId); - void addBGroupToFocusList(WidgetArray& list) { _buttonGroup = list; } + void addToFocusList(const WidgetArray& list) override; + void addToFocusList(const WidgetArray& list, TabWidget* w, int tabId); + void addBGroupToFocusList(const WidgetArray& list) { _buttonGroup = list; } void addTabWidget(TabWidget* w); void addDefaultWidget(Widget* w) { _defaultWidget = w; } void addOKWidget(Widget* w) { _okWidget = w; } diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 4addb4b10..837aac3bb 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -30,16 +30,15 @@ EditableWidget::EditableWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h, const string& str) : Widget(boss, font, x, y, w, h), CommandSender(boss), - _editString(str), - _filter([](char c) { return isprint(c) && c != '\"'; }) + _editString{str}, + myUndoHandler{make_unique()}, + _filter{[](char c) { return isprint(c) && c != '\"'; }} { _bgcolor = kWidColor; _bgcolorhi = kWidColor; _bgcolorlo = kDlgColor; _textcolor = kTextColor; _textcolorhi = kTextColor; - - myUndoHandler = make_unique(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -359,13 +358,10 @@ void EditableWidget::drawCaretSelection() { FBSurface& s = _boss->dialog().surface(); const Common::Rect& editRect = getEditRect(); - int x = editRect.x(); - int y = editRect.y(); - string text = selectString(); - x = editRect.x(); - y = editRect.y(); + int x = editRect.x(); + int y = editRect.y(); int w = editRect.w(); int h = editRect.h(); int wt = int(text.length()) * _font.getMaxCharWidth() + 1; diff --git a/src/gui/Font.cxx b/src/gui/Font.cxx index 7c2b374e8..e327fa8af 100644 --- a/src/gui/Font.cxx +++ b/src/gui/Font.cxx @@ -18,6 +18,8 @@ // Copyright (C) 2002-2004 The ScummVM project //============================================================================ +#include + #include "Font.hxx" namespace GUI { @@ -53,13 +55,8 @@ int Font::getStringWidth(const string& str) const if(!myFontDesc.width) return myFontDesc.maxwidth * int(str.size()); else - { - int space = 0; - for(auto c: str) - space += getCharWidth(c); - - return space; - } + return std::accumulate(str.cbegin(), str.cend(), 0, + [&](int x, char c) { return x + getCharWidth(c); }); } } // namespace GUI diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 85424a670..dd95d62cc 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -130,7 +130,7 @@ class GuiObject : public CommandReceiver /** Add given widget(s) to the focus list */ virtual void addFocusWidget(Widget* w) = 0; - virtual void addToFocusList(WidgetArray& list) = 0; + virtual void addToFocusList(const WidgetArray& list) = 0; /** Return focus list for this object */ WidgetArray& getFocusList() { return _focusList; } diff --git a/src/gui/HighScoresDialog.cxx b/src/gui/HighScoresDialog.cxx index f689ecd4e..af39c125a 100644 --- a/src/gui/HighScoresDialog.cxx +++ b/src/gui/HighScoresDialog.cxx @@ -100,12 +100,9 @@ HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent, int max_w, int max_h, Menu::AppMode mode) : Dialog(osystem, parent, osystem.frameBuffer().font(), "High Scores"), - myDirty(false), - myHighScoreSaved(false), - _max_w(max_w), - _max_h(max_h), - myInitials(""), - myMode(mode) + _max_w{max_w}, + _max_h{max_h}, + myMode{mode} { myScores.variation = HSM::DEFAULT_VARIATION; diff --git a/src/gui/HighScoresDialog.hxx b/src/gui/HighScoresDialog.hxx index a62351990..c15105f6f 100644 --- a/src/gui/HighScoresDialog.hxx +++ b/src/gui/HighScoresDialog.hxx @@ -76,16 +76,17 @@ class HighScoresDialog : public Dialog }; private: - bool myUserDefVar; // allow the user to define the variation - bool myDirty; - bool myHighScoreSaved; // remember if current high score was already saved (avoids double HS) + bool myUserDefVar{false}; // allow the user to define the variation + bool myDirty{false}; + bool myHighScoreSaved{false}; // remember if current high score was already saved + // (avoids double HS) unique_ptr myConfirmMsg; - int _max_w; - int _max_h; + int _max_w{0}; + int _max_h{0}; string myInitials; - Int32 myEditRank; - Int32 myHighScoreRank; + Int32 myEditRank{-1}; + Int32 myHighScoreRank{-1}; string myNow; HSM::ScoresData myScores; @@ -120,4 +121,5 @@ class HighScoresDialog : public Dialog HighScoresDialog& operator=(const HighScoresDialog&) = delete; HighScoresDialog& operator=(HighScoresDialog&&) = delete; }; + #endif diff --git a/src/gui/Launcher.cxx b/src/gui/Launcher.cxx index 694395cfa..91868282c 100644 --- a/src/gui/Launcher.cxx +++ b/src/gui/Launcher.cxx @@ -27,9 +27,9 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Launcher::Launcher(OSystem& osystem) - : DialogContainer(osystem) + : DialogContainer(osystem), + mySize(myOSystem.settings().getSize("launcherres")) { - mySize = myOSystem.settings().getSize("launcherres"); const Common::Size& d = myOSystem.frameBuffer().desktopSize(); double overscan = 1 - myOSystem.settings().getInt("tia.fs_overscan") / 100.0; diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 0643bd599..13f89e624 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -139,7 +139,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, lblSelect = ""; int lwSelectShort = font.getStringWidth(lblSelect); - wTotal -= lwSelect - lwSelectShort; + // wTotal -= lwSelect - lwSelectShort; // dead code lwSelect = lwSelectShort; noSelect = true; } diff --git a/src/gui/R77HelpDialog.cxx b/src/gui/R77HelpDialog.cxx index 1e4601ced..5d14d3719 100644 --- a/src/gui/R77HelpDialog.cxx +++ b/src/gui/R77HelpDialog.cxx @@ -65,8 +65,7 @@ R77HelpDialog::R77HelpDialog(OSystem& osystem, DialogContainer& parent, myTitle = new StaticTextWidget(this, font, xpos, ypos, _w - HBORDER * 2, fontHeight, "", TextAlign::Center); - int jwidth = 11 * fontWidth; - int bwidth = 11 * fontWidth; + const int jwidth = 11 * fontWidth, bwidth = jwidth; xpos = HBORDER; ypos += lineHeight + 4; for (uInt8 i = 0; i < LINES_PER_PAGE; ++i) { diff --git a/src/gui/RadioButtonWidget.cxx b/src/gui/RadioButtonWidget.cxx index e2b5e34df..658859b97 100644 --- a/src/gui/RadioButtonWidget.cxx +++ b/src/gui/RadioButtonWidget.cxx @@ -221,13 +221,13 @@ RadioButtonWidget::RadioButtonWidget(GuiObject* boss, const GUI::Font& font, int x, int y, const string& label, RadioButtonGroup* group, int cmd) : CheckboxWidget(boss, font, x, y, label, cmd), - myGroup(group) + myGroup(group), + _buttonSize(buttonSize(font)) // 14 | 22 { _flags = Widget::FLAG_ENABLED; _bgcolor = _bgcolorhi = kWidColor; _editable = true; - _buttonSize = buttonSize(font); // 14 | 22 if(_buttonSize == 14) { diff --git a/src/gui/TabWidget.hxx b/src/gui/TabWidget.hxx index 9d6f0837d..d2ca4305c 100644 --- a/src/gui/TabWidget.hxx +++ b/src/gui/TabWidget.hxx @@ -81,7 +81,7 @@ class TabWidget : public Widget, public CommandSender bool enabled{true}; int tabWidth{0}; - Tab(const string& t, int tw = NO_WIDTH, + explicit Tab(const string& t, int tw = NO_WIDTH, Widget* first = nullptr, Widget* parent = nullptr, bool e = true) : title(t), firstWidget(first), parentWidget(parent), enabled(e), tabWidth(tw) { } }; diff --git a/src/gui/VideoAudioDialog.hxx b/src/gui/VideoAudioDialog.hxx index 550617d2d..f0d376140 100644 --- a/src/gui/VideoAudioDialog.hxx +++ b/src/gui/VideoAudioDialog.hxx @@ -59,7 +59,7 @@ class VideoAudioDialog : public Dialog void handleOverscanChange(); void handlePhosphorChange(); void handleCommand(CommandSender* sender, int cmd, int data, int id) override; - void addPalette(int x, int y, int h, int w); + void addPalette(int x, int y, int w, int h); void colorPalette(); void updatePreset(); void updateEnabledState(); diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 38c46bdbe..7f605a6ea 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -138,11 +138,9 @@ void Widget::draw() // Now perform the actual widget draw drawWidget((_flags & Widget::FLAG_HILITED) ? true : false); - // Restore x/y + // Restore w/hy if(hasBorder()) { - _x -= 4; - _y -= 4; _w += 8; _h += 8; } @@ -284,13 +282,10 @@ bool Widget::isWidgetInChain(Widget* w, Widget* find) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Widget::isWidgetInChain(WidgetArray& list, Widget* find) +bool Widget::isWidgetInChain(const WidgetArray& list, Widget* find) { - for(const auto& w: list) - if(w == find) - return true; - - return false; + return std::any_of(list.cbegin(), list.cend(), + [&](Widget* w) { return w == find; }); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index cf4637ea1..f31c2fce0 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -83,7 +83,7 @@ class Widget : public GuiObject void receivedFocus(); void lostFocus(); void addFocusWidget(Widget* w) override { _focusList.push_back(w); } - void addToFocusList(WidgetArray& list) override { + void addToFocusList(const WidgetArray& list) override { Vec::append(_focusList, list); } @@ -157,7 +157,7 @@ class Widget : public GuiObject static bool isWidgetInChain(Widget* start, Widget* find); /** Determine if 'find' is in the widget array */ - static bool isWidgetInChain(WidgetArray& list, Widget* find); + static bool isWidgetInChain(const WidgetArray& list, Widget* find); /** Select either previous, current, or next widget in chain to have focus, and deselects all others */ diff --git a/src/libretro/EventHandlerLIBRETRO.cxx b/src/libretro/EventHandlerLIBRETRO.cxx index 046839032..d74ee3679 100644 --- a/src/libretro/EventHandlerLIBRETRO.cxx +++ b/src/libretro/EventHandlerLIBRETRO.cxx @@ -15,7 +15,6 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include "OSystem.hxx" #include "EventHandlerLIBRETRO.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libretro/FBSurfaceLIBRETRO.cxx b/src/libretro/FBSurfaceLIBRETRO.cxx index 1f3d7e549..9041cc127 100644 --- a/src/libretro/FBSurfaceLIBRETRO.cxx +++ b/src/libretro/FBSurfaceLIBRETRO.cxx @@ -19,15 +19,13 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FBSurfaceLIBRETRO::FBSurfaceLIBRETRO(uInt32 width, uInt32 height) + : myWidth{width}, + myHeight{height}, + myPixelData{make_unique(myWidth * myHeight)} { - myWidth = width; - myHeight = height; - - myPixelData = make_unique(width * height); - //////////////////////////////////////////////////// // These *must* be set for the parent class myPixels = myPixelData.get(); - myPitch = width; + myPitch = myWidth; //////////////////////////////////////////////////// } diff --git a/src/libretro/FBSurfaceLIBRETRO.hxx b/src/libretro/FBSurfaceLIBRETRO.hxx index f6bf3320b..7578ca658 100644 --- a/src/libretro/FBSurfaceLIBRETRO.hxx +++ b/src/libretro/FBSurfaceLIBRETRO.hxx @@ -64,8 +64,8 @@ class FBSurfaceLIBRETRO : public FBSurface void applyAttributes() override { } private: - unique_ptr myPixelData; uInt32 myWidth, myHeight; + unique_ptr myPixelData; Common::Rect mySrcGUIR, myDstGUIR; private: diff --git a/src/libretro/FSNodeLIBRETRO.cxx b/src/libretro/FSNodeLIBRETRO.cxx index f3670f0a2..43fee3d9b 100644 --- a/src/libretro/FSNodeLIBRETRO.cxx +++ b/src/libretro/FSNodeLIBRETRO.cxx @@ -27,15 +27,15 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FilesystemNodeLIBRETRO::FilesystemNodeLIBRETRO() - : _name("rom"), - _path("." + slash) + : _name{"rom"}, + _path{"." + slash} { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FilesystemNodeLIBRETRO::FilesystemNodeLIBRETRO(const string& p) - : _name(p), - _path(p) + : _name{p}, + _path{p} { // TODO: use retro_vfs_mkdir_t (file) or RETRO_MEMORY_SAVE_RAM (stream) or libretro save path if(p == "." + slash + "nvram") diff --git a/src/libretro/SoundLIBRETRO.cxx b/src/libretro/SoundLIBRETRO.cxx index 2c15ce04d..6cee38c1f 100644 --- a/src/libretro/SoundLIBRETRO.cxx +++ b/src/libretro/SoundLIBRETRO.cxx @@ -35,7 +35,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SoundLIBRETRO::SoundLIBRETRO(OSystem& osystem, AudioSettings& audioSettings) : Sound(osystem), - myAudioSettings(audioSettings) + myAudioSettings{audioSettings} { Logger::debug("SoundLIBRETRO::SoundLIBRETRO started ..."); Logger::debug("SoundLIBRETRO::SoundLIBRETRO initialized"); diff --git a/src/libretro/StellaLIBRETRO.cxx b/src/libretro/StellaLIBRETRO.cxx index b80d517d9..8b3541332 100644 --- a/src/libretro/StellaLIBRETRO.cxx +++ b/src/libretro/StellaLIBRETRO.cxx @@ -31,9 +31,9 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - StellaLIBRETRO::StellaLIBRETRO() + : rom_image{make_unique(getROMMax())}, + audio_buffer{make_unique(audio_buffer_max)} { - audio_buffer = make_unique(audio_buffer_max); - rom_image = make_unique(getROMMax()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/unix/FSNodePOSIX.cxx b/src/unix/FSNodePOSIX.cxx index f483dc899..c49d7d1ce 100644 --- a/src/unix/FSNodePOSIX.cxx +++ b/src/unix/FSNodePOSIX.cxx @@ -32,10 +32,8 @@ FilesystemNodePOSIX::FilesystemNodePOSIX() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FilesystemNodePOSIX::FilesystemNodePOSIX(const string& path, bool verify) + : _path{path.length() > 0 ? path : "~"} // Default to home directory { - // Default to home directory - _path = path.length() > 0 ? path : "~"; - // Expand '~' to the HOME environment variable if(_path[0] == '~') { diff --git a/src/unix/FSNodePOSIX.hxx b/src/unix/FSNodePOSIX.hxx index 5bf9e0277..5aba86afa 100644 --- a/src/unix/FSNodePOSIX.hxx +++ b/src/unix/FSNodePOSIX.hxx @@ -58,7 +58,7 @@ class FilesystemNodePOSIX : public AbstractFSNode * @param verify true if the isValid and isDirectory/isFile flags should * be verified during the construction. */ - FilesystemNodePOSIX(const string& path, bool verify = true); + explicit FilesystemNodePOSIX(const string& path, bool verify = true); bool exists() const override { return access(_path.c_str(), F_OK) == 0; } const string& getName() const override { return _displayName; } diff --git a/src/windows/FSNodeWINDOWS.cxx b/src/windows/FSNodeWINDOWS.cxx index c8676e542..82182fe83 100644 --- a/src/windows/FSNodeWINDOWS.cxx +++ b/src/windows/FSNodeWINDOWS.cxx @@ -175,10 +175,8 @@ FilesystemNodeWINDOWS::FilesystemNodeWINDOWS() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FilesystemNodeWINDOWS::FilesystemNodeWINDOWS(const string& p) + : _path(p.length() > 0 ? p : "~") // Default to home directory { - // Default to home directory - _path = p.length() > 0 ? p : "~"; - // Expand '~' to the users 'home' directory if(_path[0] == '~') _path.replace(0, 1, myHomeFinder.getHomePath());