diff --git a/src/lib/game/data/map/mapfieldview.h b/src/lib/game/data/map/mapfieldview.h index 1c3993cc..fafc59c7 100644 --- a/src/lib/game/data/map/mapfieldview.h +++ b/src/lib/game/data/map/mapfieldview.h @@ -67,7 +67,7 @@ class cMapFieldView private: const cMapField& mapField; const sTerrain& terrain; - const cPlayer* player; // may be null + const cPlayer* player = nullptr; // may be null }; #endif diff --git a/src/lib/game/logic/pathcalculator.cpp b/src/lib/game/logic/pathcalculator.cpp index 21d61b15..c8b472db 100644 --- a/src/lib/game/logic/pathcalculator.cpp +++ b/src/lib/game/logic/pathcalculator.cpp @@ -184,12 +184,9 @@ void cPathCalculator::expandNodes (sPathNode* ParentNode) // when we have a group of units, the units will not block each other if (group) { + const auto& field = Map->getField (currentPosition); // get the blocking unit - cVehicle* blockingUnit; - if (Vehicle->getStaticUnitData().factorAir > 0) - blockingUnit = Map->getField (currentPosition).getPlane(); - else - blockingUnit = Map->getField (currentPosition).getVehicle(); + cVehicle* blockingUnit = (Vehicle->getStaticUnitData().factorAir > 0) ? field.getPlane() : field.getVehicle(); // check whether the blocking unit is the group bool isInGroup = ranges::contains (*group, blockingUnit); if (!isInGroup) continue; diff --git a/src/lib/game/logic/pathcalculator.h b/src/lib/game/logic/pathcalculator.h index 9cb1a4b9..fac622a8 100644 --- a/src/lib/game/logic/pathcalculator.h +++ b/src/lib/game/logic/pathcalculator.h @@ -38,9 +38,11 @@ struct sPathNode /* x and y coords */ cPosition position; /* the different cost types */ - int costF, costG, costH; + int costF = 0; + int costG = 0; + int costH = 0; /* previous node of this one in the hole path */ - sPathNode* prev; + sPathNode* prev = nullptr; }; enum class ePathDestinationType @@ -54,9 +56,9 @@ class cPathDestHandler { ePathDestinationType type; - const cVehicle* srcVehicle; + const cVehicle* srcVehicle = nullptr; - const cUnit* destUnit; + const cUnit* destUnit = nullptr; cPosition destination; public: @@ -90,23 +92,24 @@ class cPathCalculator static int calcNextCost (const cPosition& source, const cPosition& destination, const cVehicle*, const T* map); /* the map on which the path will be calculated */ - const cMapView* Map; + const cMapView* Map = nullptr; /* the moving vehicle */ - const cVehicle* Vehicle; + const cVehicle* Vehicle = nullptr; /* if more then one vehicle is moving in a group this is the list of all moving vehicles */ - const std::vector* group; + const std::vector* group = nullptr; /* source and destination coords */ cPosition source; - bool bPlane, bShip; + bool bPlane = false; + bool bShip = false; std::unique_ptr destHandler; private: /* memoryblocks for the nodes */ std::vector> MemBlocks; /* number of blocks */ - int blocknum; + int blocknum = 0; /* restsize of the last block */ - int blocksize; + int blocksize = 0; /* heaplist where all nodes are sorted by there costF value */ std::vector nodesHeap; @@ -115,7 +118,7 @@ class cPathCalculator /* closed nodes map */ std::vector closedList; /* number of nodes saved on the heaplist; equal to number of nodes in the openlist */ - int heapCount; + int heapCount = 0; /** * expands the nodes around the overgiven one *@author alzi alias DoctorDeath diff --git a/src/lib/input/keyboard/keycombination.cpp b/src/lib/input/keyboard/keycombination.cpp index e968909b..512129d2 100644 --- a/src/lib/input/keyboard/keycombination.cpp +++ b/src/lib/input/keyboard/keycombination.cpp @@ -27,7 +27,7 @@ static const struct { SDL_Keycode key; - const char* name; + const char* name = nullptr; } keyNames[] = { diff --git a/src/lib/mapdownloader/mapdownload.cpp b/src/lib/mapdownloader/mapdownload.cpp index 20662b2d..a4e728c6 100644 --- a/src/lib/mapdownloader/mapdownload.cpp +++ b/src/lib/mapdownloader/mapdownload.cpp @@ -41,8 +41,8 @@ bool MapDownload::isMapOriginal (const std::filesystem::path& mapFilename, int32 const struct { - const char* filename; - int32_t checksum; + const char* filename = nullptr; + int32_t checksum = 0; } maps[] = { {"bottleneck.wrl", 344087468}, diff --git a/src/lib/output/video/video.cpp b/src/lib/output/video/video.cpp index f6b22fcf..bfd5d754 100644 --- a/src/lib/output/video/video.cpp +++ b/src/lib/output/video/video.cpp @@ -568,12 +568,12 @@ static void drawStetchedLine (Type* srcPixelData, int srcWidth, Type* destPixelD SDL_Surface* scaleSurface (SDL_Surface* scr, SDL_Surface* dest, int width, int height) { if (width <= 0 || height <= 0 || !scr) return nullptr; - SDL_Surface* surface; // can not enlage an existing surface if (width > scr->w && dest) width = scr->w; if (height > scr->h && dest) height = scr->h; + SDL_Surface* surface = nullptr; // generate new surface if necessary if (dest == nullptr) surface = SDL_CreateRGBSurface (0, width, height, scr->format->BitsPerPixel, scr->format->Rmask, scr->format->Gmask, scr->format->Bmask, scr->format->Amask); diff --git a/src/lib/utility/string/roman.cpp b/src/lib/utility/string/roman.cpp index 9f99b07a..cb01b500 100644 --- a/src/lib/utility/string/roman.cpp +++ b/src/lib/utility/string/roman.cpp @@ -25,8 +25,8 @@ std::string to_roman (unsigned int value) { struct romandata_t { - unsigned int value; - char const* numeral; + unsigned int value = 0; + char const* numeral = nullptr; }; const struct romandata_t romandata[] = { diff --git a/src/ui/graphical/game/widgets/chatbox.h b/src/ui/graphical/game/widgets/chatbox.h index 7ace20c4..7c7e9bca 100644 --- a/src/ui/graphical/game/widgets/chatbox.h +++ b/src/ui/graphical/game/widgets/chatbox.h @@ -69,21 +69,19 @@ class cChatBox : public cWidget cSignal commandEntered; +private: + void sendCommand(); + void createBackground(); + private: cSignalConnectionManager signalConnectionManager; UniqueSurface nonFocusBackground; UniqueSurface focusBackground; - cLineEdit* chatLineEdit; - - cListView* chatList; - - cListView* playersList; - - void sendCommand(); - - void createBackground(); + cLineEdit* chatLineEdit = nullptr; + cListView* chatList = nullptr; + cListView* playersList = nullptr; }; //------------------------------------------------------------------------------ diff --git a/src/ui/graphical/game/widgets/debugoutputwidget.cpp b/src/ui/graphical/game/widgets/debugoutputwidget.cpp index a32b7f32..cf08d0f7 100644 --- a/src/ui/graphical/game/widgets/debugoutputwidget.cpp +++ b/src/ui/graphical/game/widgets/debugoutputwidget.cpp @@ -417,8 +417,7 @@ void cDebugOutputWidget::trace() if (!gameMap->getArea().withinOrTouches (mouse->getPosition())) return; const auto mapPosition = gameMap->getMapTilePosition (mouse->getPosition()); - - const cMapField* field; + const cMapField* field = nullptr; if (debugTraceServer && server) { diff --git a/src/ui/graphical/menu/control/menucontrollermultiplayerhotseat.h b/src/ui/graphical/menu/control/menucontrollermultiplayerhotseat.h index fe823848..ac5d17e1 100644 --- a/src/ui/graphical/menu/control/menucontrollermultiplayerhotseat.h +++ b/src/ui/graphical/menu/control/menucontrollermultiplayerhotseat.h @@ -48,8 +48,8 @@ class cMenuControllerMultiplayerHotSeat : public cRunnable, public std::enable_s cApplication& application; - cWindowPlayerSelection* windowPlayerSelection; - cWindow* firstWindow; + cWindowPlayerSelection* windowPlayerSelection = nullptr; + cWindow* firstWindow = nullptr; std::shared_ptr game; diff --git a/src/ui/graphical/menu/widgets/combobox.h b/src/ui/graphical/menu/widgets/combobox.h index 0b1443c9..ca70cd73 100644 --- a/src/ui/graphical/menu/widgets/combobox.h +++ b/src/ui/graphical/menu/widgets/combobox.h @@ -62,9 +62,9 @@ class cComboBox : public cWidget UniqueSurface listViewBackground; UniqueSurface lineEditBackground; - cListView* listView; - cCheckBox* downButton; - cLineEdit* lineEdit; + cListView* listView = nullptr; + cCheckBox* downButton = nullptr; + cLineEdit* lineEdit = nullptr; size_t maxVisibleItems; diff --git a/src/ui/graphical/menu/widgets/scrollbar.h b/src/ui/graphical/menu/widgets/scrollbar.h index a55e7a40..3c23f152 100644 --- a/src/ui/graphical/menu/widgets/scrollbar.h +++ b/src/ui/graphical/menu/widgets/scrollbar.h @@ -54,17 +54,14 @@ class cScrollBar : public cWidget private: cSignalConnectionManager signalConnectionManager; - cPushButton* forwardButton; - cPushButton* backButton; + cPushButton* forwardButton = nullptr; + cPushButton* backButton = nullptr; - cSlider* slider; + cSlider* slider = nullptr; eScrollBarStyle style; eOrientationType orientation; - - size_t range; - size_t offset; }; #endif // ui_graphical_menu_widgets_scrollbarH diff --git a/src/ui/graphical/menu/widgets/special/chatboxlandingplayerlistviewitem.h b/src/ui/graphical/menu/widgets/special/chatboxlandingplayerlistviewitem.h index 4c61ceab..26c8f034 100644 --- a/src/ui/graphical/menu/widgets/special/chatboxlandingplayerlistviewitem.h +++ b/src/ui/graphical/menu/widgets/special/chatboxlandingplayerlistviewitem.h @@ -64,9 +64,9 @@ class cChatBoxLandingPlayerListViewItem : public cAbstractListViewItem cSignalConnectionManager signalConnectionManager; cSignalConnectionManager managerSignalConnectionManager; - cLabel* nameLabel; - cImage* colorImage; - cImage* readyImage; + cLabel* nameLabel = nullptr; + cImage* colorImage = nullptr; + cImage* readyImage = nullptr; const cPlayerLandingStatus& playerLandingStatus; diff --git a/src/ui/graphical/menu/widgets/special/lobbychatboxlistviewitem.h b/src/ui/graphical/menu/widgets/special/lobbychatboxlistviewitem.h index a9b248e2..342df80c 100644 --- a/src/ui/graphical/menu/widgets/special/lobbychatboxlistviewitem.h +++ b/src/ui/graphical/menu/widgets/special/lobbychatboxlistviewitem.h @@ -41,8 +41,8 @@ class cLobbyChatBoxListViewItem : public cAbstractListViewItem void handleResized (const cPosition& oldSize) override; private: - cLabel* messageLabel; - cLabel* prefixLabel; + cLabel* messageLabel = nullptr; + cLabel* prefixLabel = nullptr; }; #endif // ui_graphical_menu_widgets_special_lobbychatboxlistviewitemH diff --git a/src/ui/graphical/menu/widgets/special/lobbyplayerlistviewitem.h b/src/ui/graphical/menu/widgets/special/lobbyplayerlistviewitem.h index 420b0571..07ae583e 100644 --- a/src/ui/graphical/menu/widgets/special/lobbyplayerlistviewitem.h +++ b/src/ui/graphical/menu/widgets/special/lobbyplayerlistviewitem.h @@ -45,9 +45,9 @@ class cLobbyPlayerListViewItem : public cAbstractListViewItem private: cSignalConnectionManager signalConnectionManager; - cLabel* nameLabel; - cImage* colorImage; - cImage* readyImage; + cLabel* nameLabel = nullptr; + cImage* colorImage = nullptr; + cImage* readyImage = nullptr; std::shared_ptr player; diff --git a/src/ui/graphical/menu/widgets/special/textlistviewitem.h b/src/ui/graphical/menu/widgets/special/textlistviewitem.h index cd41affb..a5c0b114 100644 --- a/src/ui/graphical/menu/widgets/special/textlistviewitem.h +++ b/src/ui/graphical/menu/widgets/special/textlistviewitem.h @@ -34,7 +34,7 @@ class cTextListViewItem : public cAbstractListViewItem void handleResized (const cPosition& oldSize) override; protected: - cLabel* label; + cLabel* label = nullptr; }; #endif // ui_graphical_menu_widgets_special_textlistviewitemH diff --git a/src/ui/graphical/menu/widgets/special/unitlistviewitem.h b/src/ui/graphical/menu/widgets/special/unitlistviewitem.h index 51c01efb..c0ff05cf 100644 --- a/src/ui/graphical/menu/widgets/special/unitlistviewitem.h +++ b/src/ui/graphical/menu/widgets/special/unitlistviewitem.h @@ -42,8 +42,8 @@ class cUnitListViewItem : public cAbstractListViewItem const sID& getUnitId() const { return unitId; } protected: - cImage* unitImage; - cLabel* nameLabel; + cImage* unitImage = nullptr; + cLabel* nameLabel = nullptr; private: sID unitId; diff --git a/src/ui/graphical/menu/widgets/special/unitlistviewitembuy.h b/src/ui/graphical/menu/widgets/special/unitlistviewitembuy.h index 9baf0ade..68f553bb 100644 --- a/src/ui/graphical/menu/widgets/special/unitlistviewitembuy.h +++ b/src/ui/graphical/menu/widgets/special/unitlistviewitembuy.h @@ -36,8 +36,8 @@ class cUnitListViewItemBuy : public cUnitListViewItem void showPrice(); private: - int cost; - cLabel* costLabel; + int cost = 0; + cLabel* costLabel = nullptr; }; #endif // ui_graphical_menu_widgets_special_unitlistviewitembuyH diff --git a/src/ui/graphical/menu/widgets/special/unitlistviewitemcargo.h b/src/ui/graphical/menu/widgets/special/unitlistviewitemcargo.h index 32464b04..2d965f14 100644 --- a/src/ui/graphical/menu/widgets/special/unitlistviewitemcargo.h +++ b/src/ui/graphical/menu/widgets/special/unitlistviewitemcargo.h @@ -34,9 +34,9 @@ class cUnitListViewItemCargo : public cUnitListViewItem void updateCargoLabel(); private: - cLabel* cargoLabel; + cLabel* cargoLabel = nullptr; int cargo = 0; - int cargoMax; + int cargoMax = 0; }; #endif // ui_graphical_menu_widgets_special_unitlistviewitemcargoH diff --git a/src/ui/graphical/menu/windows/windowadvancedhangar/windowadvancedhangar.h b/src/ui/graphical/menu/windows/windowadvancedhangar/windowadvancedhangar.h index f7a57b44..b4ebae0a 100644 --- a/src/ui/graphical/menu/windows/windowadvancedhangar/windowadvancedhangar.h +++ b/src/ui/graphical/menu/windows/windowadvancedhangar/windowadvancedhangar.h @@ -45,9 +45,9 @@ class cWindowAdvancedHangar : public cWindowHangar // TODO: the following widgets should be private instead. // They are protect at the moment because some inheriting windows need to move/resize the widgets. - cListView* selectedUnitList; - cPushButton* selectedListUpButton; - cPushButton* selectedListDownButton; + cListView* selectedUnitList = nullptr; + cPushButton* selectedListUpButton = nullptr; + cPushButton* selectedListDownButton = nullptr; cSignal selectedUnitSelectionChanged; diff --git a/src/ui/graphical/menu/windows/windowbuildbuildings/windowbuildbuildings.h b/src/ui/graphical/menu/windows/windowbuildbuildings/windowbuildbuildings.h index 4c7d4453..4e72f6d6 100644 --- a/src/ui/graphical/menu/windows/windowbuildbuildings/windowbuildbuildings.h +++ b/src/ui/graphical/menu/windows/windowbuildbuildings/windowbuildbuildings.h @@ -47,7 +47,7 @@ class cWindowBuildBuildings : public cWindowHangar const cVehicle& vehicle; - cBuildSpeedHandlerWidget* speedHandler; + cBuildSpeedHandlerWidget* speedHandler = nullptr; cLabel* titleLabel = nullptr; cPushButton* pathButton = nullptr; diff --git a/src/ui/graphical/menu/windows/windowhangar/windowhangar.h b/src/ui/graphical/menu/windows/windowhangar/windowhangar.h index 2c12514e..bb15843d 100644 --- a/src/ui/graphical/menu/windows/windowhangar/windowhangar.h +++ b/src/ui/graphical/menu/windows/windowhangar/windowhangar.h @@ -70,12 +70,12 @@ class cWindowHangar : public cWindow // TODO: the following widgets should be private instead. // They are protect at the moment because some inheriting windows need to move/resize the widgets. - cListView* selectionUnitList; + cListView* selectionUnitList = nullptr; - cPushButton* okButton; - cPushButton* backButton; - cPushButton* selectionListUpButton; - cPushButton* selectionListDownButton; + cPushButton* okButton = nullptr; + cPushButton* backButton = nullptr; + cPushButton* selectionListUpButton = nullptr; + cPushButton* selectionListDownButton = nullptr; cSignal selectionUnitClickedSecondTime; @@ -87,12 +87,12 @@ class cWindowHangar : public cWindow std::unique_ptr temporaryPlayer; const cPlayer& player; - cImage* infoImage; - cLabel* infoLabel; + cImage* infoImage = nullptr; + cLabel* infoLabel = nullptr; - cUnitDetails* unitDetails; + cUnitDetails* unitDetails = nullptr; - cCheckBox* infoTextCheckBox; + cCheckBox* infoTextCheckBox = nullptr; void initialize(); diff --git a/src/ui/graphical/menu/windows/windowlandingunitselection/windowlandingunitselection.cpp b/src/ui/graphical/menu/windows/windowlandingunitselection/windowlandingunitselection.cpp index 416d00cf..d863e2f5 100644 --- a/src/ui/graphical/menu/windows/windowlandingunitselection/windowlandingunitselection.cpp +++ b/src/ui/graphical/menu/windows/windowlandingunitselection/windowlandingunitselection.cpp @@ -183,7 +183,7 @@ void cWindowLandingUnitSelection::setActiveUnit (const sID& unitId) { cWindowAdvancedHangar::setActiveUnit (unitId); - cUnitUpgrade* unitUpgrade; + cUnitUpgrade* unitUpgrade = nullptr; auto iter = unitUpgrades.find (unitId); if (iter == unitUpgrades.end()) { diff --git a/src/ui/graphical/menu/windows/windowreports/windowreports.h b/src/ui/graphical/menu/windows/windowreports/windowreports.h index 1c9d384a..1211525e 100644 --- a/src/ui/graphical/menu/windows/windowreports/windowreports.h +++ b/src/ui/graphical/menu/windows/windowreports/windowreports.h @@ -104,13 +104,13 @@ class cWindowReports : public cWindow cPushButton* downButton = nullptr; cFrame* unitsFrame = nullptr; - cListView* unitsList; + cListView* unitsList = nullptr; cFrame* disadvantagesFrame = nullptr; cListView* disadvantagesList = nullptr; cFrame* scoreFrame = nullptr; - cPlot* scorePlot; + cPlot* scorePlot = nullptr; cFrame* reportsFrame = nullptr; cListView* reportsList = nullptr; diff --git a/src/ui/graphical/menu/windows/windowstorage/windowstorage.cpp b/src/ui/graphical/menu/windows/windowstorage/windowstorage.cpp index fd12429f..e17430ed 100644 --- a/src/ui/graphical/menu/windows/windowstorage/windowstorage.cpp +++ b/src/ui/graphical/menu/windows/windowstorage/windowstorage.cpp @@ -253,7 +253,7 @@ void cWindowStorage::updateUnitsWidgets() { unitNames[positionIndex]->setText (""); - SDL_Surface* srcSurface; + SDL_Surface* srcSurface = nullptr; if (canStoreShips) srcSurface = GraphicsData.gfx_edock.get(); else if (canStorePlanes) diff --git a/src/ui/graphical/menu/windows/windowupgrades/windowupgrades.cpp b/src/ui/graphical/menu/windows/windowupgrades/windowupgrades.cpp index 548dad3d..a5af2fb1 100644 --- a/src/ui/graphical/menu/windows/windowupgrades/windowupgrades.cpp +++ b/src/ui/graphical/menu/windows/windowupgrades/windowupgrades.cpp @@ -119,7 +119,7 @@ void cWindowUpgrades::setActiveUnit (const sID& unitId) { cWindowHangar::setActiveUnit (unitId); - cUnitUpgrade* unitUpgrade; + cUnitUpgrade* unitUpgrade = nullptr; auto iter = unitUpgrades.find (unitId); if (iter == unitUpgrades.end()) { diff --git a/src/ui/widgets/image.h b/src/ui/widgets/image.h index 7ecc61d9..d8b7eb64 100644 --- a/src/ui/widgets/image.h +++ b/src/ui/widgets/image.h @@ -45,7 +45,7 @@ class cImage : public cClickableWidget private: UniqueSurface image; - cSoundChunk* clickSound; + cSoundChunk* clickSound = nullptr; bool disabledAtTransparent = false; };