Fixed some uninitialized members

May have caused undefined behavior in few cases, as most of the fixed members were used before being initialized.
This commit is contained in:
Kai Blaschke 2024-02-19 23:29:39 +01:00
parent 42fc1d6714
commit d0099a6d79
No known key found for this signature in database
GPG Key ID: B014B6811527389F
11 changed files with 56 additions and 62 deletions

View File

@ -143,7 +143,7 @@ private:
HashSet<TexturePtr> usedTextures; HashSet<TexturePtr> usedTextures;
List<GlVertexBuffer> vertexBuffers; List<GlVertexBuffer> vertexBuffers;
bool useMultiTexturing; bool useMultiTexturing{true};
}; };
struct EffectParameter { struct EffectParameter {

View File

@ -2,8 +2,13 @@
namespace Star { namespace Star {
CellularLightingCalculator::CellularLightingCalculator(bool monochrome) { CellularLightingCalculator::CellularLightingCalculator(bool monochrome)
setMonochrome(monochrome); : m_monochrome(monochrome)
{
if (monochrome)
m_lightArray.setRight(ScalarCellularLightArray());
else
m_lightArray.setLeft(ColoredCellularLightArray());
} }
void CellularLightingCalculator::setMonochrome(bool monochrome) { void CellularLightingCalculator::setMonochrome(bool monochrome) {

View File

@ -17,7 +17,7 @@ namespace Star {
// individually. // individually.
class CellularLightingCalculator { class CellularLightingCalculator {
public: public:
CellularLightingCalculator(bool monochrome = false); explicit CellularLightingCalculator(bool monochrome = false);
typedef ColoredCellularLightArray::Cell Cell; typedef ColoredCellularLightArray::Cell Cell;

View File

@ -12,7 +12,6 @@ const float vWidth = 960.0f;
const float vHeight = 540.0f; const float vHeight = 540.0f;
Cinematic::Cinematic() { Cinematic::Cinematic() {
m_completionTime = 0;
m_completable = false; m_completable = false;
m_suppressInput = false; m_suppressInput = false;
} }
@ -342,7 +341,7 @@ float Cinematic::currentTimecode() const {
Cinematic::PanelValues Cinematic::determinePanelValues(PanelPtr panel, float timecode) { Cinematic::PanelValues Cinematic::determinePanelValues(PanelPtr panel, float timecode) {
if (panel->endTime != 0) { if (panel->endTime != 0) {
if (timecode > panel->endTime) { if (timecode > panel->endTime) {
Cinematic::PanelValues result; Cinematic::PanelValues result{};
result.alpha = 0; result.alpha = 0;
return result; return result;
} }
@ -350,7 +349,7 @@ Cinematic::PanelValues Cinematic::determinePanelValues(PanelPtr panel, float tim
if (panel->startTime != 0) { if (panel->startTime != 0) {
if (timecode < panel->startTime) { if (timecode < panel->startTime) {
Cinematic::PanelValues result; Cinematic::PanelValues result{};
result.alpha = 0; result.alpha = 0;
return result; return result;
} else { } else {

View File

@ -109,33 +109,33 @@ private:
// these include the time for background fades so they may not reflect the completion timecode // these include the time for background fades so they may not reflect the completion timecode
Clock m_timer; Clock m_timer;
float m_completionTime; float m_completionTime{};
Maybe<Vec4B> m_backgroundColor; Maybe<Vec4B> m_backgroundColor;
float m_backgroundFadeTime; float m_backgroundFadeTime{};
float m_cameraZoom; float m_cameraZoom{1.0f};
Vec2F m_cameraPan; Vec2F m_cameraPan{};
float m_drawableScale; float m_drawableScale{1.0f};
Vec2F m_drawableTranslation; Vec2F m_drawableTranslation{};
Vec2F m_windowSize; Vec2F m_windowSize{};
RectI m_scissorRect; RectI m_scissorRect{};
bool m_scissor; bool m_scissor{true};
bool m_letterbox; bool m_letterbox{true};
PlayerPtr m_player; PlayerPtr m_player;
Vec2F m_offset; Vec2F m_offset{};
bool m_skippable; bool m_skippable{true};
bool m_suppressInput; bool m_suppressInput{false};
bool m_muteSfx; bool m_muteSfx{false};
bool m_muteMusic; bool m_muteMusic{false};
bool m_completable; bool m_completable{false};
}; };
} }

View File

@ -65,24 +65,14 @@ GuiMessage::GuiMessage() : message(), cooldown(), springState() {}
GuiMessage::GuiMessage(String const& message, float cooldown, float spring) GuiMessage::GuiMessage(String const& message, float cooldown, float spring)
: message(message), cooldown(cooldown), springState(spring) {} : message(message), cooldown(cooldown), springState(spring) {}
MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter, CinematicPtr cinematicOverlay) { MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter, CinematicPtr cinematicOverlay)
m_state = Running; : m_guiContext(GuiContext::singletonPtr())
, m_config(MainInterfaceConfig::loadFromAssets())
m_guiContext = GuiContext::singletonPtr(); , m_client(std::move(client))
, m_worldPainter(std::move(painter))
m_client = client; , m_cinematicOverlay(std::move(cinematicOverlay))
m_worldPainter = painter; , m_containerInteractor(make_shared<ContainerInteractor>())
m_cinematicOverlay = cinematicOverlay; {
m_disableHud = false;
m_cursorScreenPos = Vec2I();
m_state = Running;
m_config = MainInterfaceConfig::loadFromAssets();
m_containerInteractor = make_shared<ContainerInteractor>();
GuiReader itemSlotReader; GuiReader itemSlotReader;
m_cursorItem = convert<ItemSlotWidget>(itemSlotReader.makeSingle("cursorItemSlot", m_config->cursorItemSlot)); m_cursorItem = convert<ItemSlotWidget>(itemSlotReader.makeSingle("cursorItemSlot", m_config->cursorItemSlot));
@ -90,9 +80,7 @@ MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter,
m_debugSpatialClearTimer = GameTimer(m_config->debugSpatialClearTime); m_debugSpatialClearTimer = GameTimer(m_config->debugSpatialClearTime);
m_debugMapClearTimer = GameTimer(m_config->debugMapClearTime); m_debugMapClearTimer = GameTimer(m_config->debugMapClearTime);
m_debugTextRect = RectF::null();
m_lastMouseoverTarget = NullEntityId;
m_stickyTargetingTimer = GameTimer(m_config->monsterHealthBarTime); m_stickyTargetingTimer = GameTimer(m_config->monsterHealthBarTime);
m_inventoryWindow = make_shared<InventoryPane>(this, m_client->mainPlayer(), m_containerInteractor); m_inventoryWindow = make_shared<InventoryPane>(this, m_client->mainPlayer(), m_containerInteractor);
@ -183,7 +171,7 @@ MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter,
m_paneManager.registerPane(MainInterfacePanes::PlanetText, PaneLayer::Hud, planetName); m_paneManager.registerPane(MainInterfacePanes::PlanetText, PaneLayer::Hud, planetName);
m_nameplatePainter = make_shared<NameplatePainter>(); m_nameplatePainter = make_shared<NameplatePainter>();
m_questIndicatorPainter = make_shared<QuestIndicatorPainter>(client); m_questIndicatorPainter = make_shared<QuestIndicatorPainter>(m_client);
m_chatBubbleManager = make_shared<ChatBubbleManager>(); m_chatBubbleManager = make_shared<ChatBubbleManager>();
m_paneManager.displayRegisteredPane(MainInterfacePanes::ActionBar); m_paneManager.displayRegisteredPane(MainInterfacePanes::ActionBar);

View File

@ -154,11 +154,11 @@ private:
void displayScriptPane(ScriptPanePtr& scriptPane, EntityId sourceEntity); void displayScriptPane(ScriptPanePtr& scriptPane, EntityId sourceEntity);
GuiContext* m_guiContext; GuiContext* m_guiContext{nullptr};
MainInterfaceConfigConstPtr m_config; MainInterfaceConfigConstPtr m_config;
InterfaceCursor m_cursor; InterfaceCursor m_cursor;
RunningState m_state; RunningState m_state{Running};
UniverseClientPtr m_client; UniverseClientPtr m_client;
WorldPainterPtr m_worldPainter; WorldPainterPtr m_worldPainter;
@ -192,7 +192,7 @@ private:
WirePanePtr m_wireInterface; WirePanePtr m_wireInterface;
ActionBarPtr m_actionBar; ActionBarPtr m_actionBar;
Vec2I m_cursorScreenPos; Vec2I m_cursorScreenPos{};
ItemSlotWidgetPtr m_cursorItem; ItemSlotWidgetPtr m_cursorItem;
Maybe<String> m_cursorTooltip; Maybe<String> m_cursorTooltip;
@ -201,29 +201,29 @@ private:
GameTimer m_debugSpatialClearTimer; GameTimer m_debugSpatialClearTimer;
GameTimer m_debugMapClearTimer; GameTimer m_debugMapClearTimer;
RectF m_debugTextRect; RectF m_debugTextRect{RectF::null()};
NameplatePainterPtr m_nameplatePainter; NameplatePainterPtr m_nameplatePainter;
QuestIndicatorPainterPtr m_questIndicatorPainter; QuestIndicatorPainterPtr m_questIndicatorPainter;
ChatBubbleManagerPtr m_chatBubbleManager; ChatBubbleManagerPtr m_chatBubbleManager;
bool m_disableHud; bool m_disableHud{false};
String m_lastCommand; String m_lastCommand;
LinkedList<GuiMessagePtr> m_messages; LinkedList<GuiMessagePtr> m_messages;
HashMap<ItemDescriptor, std::pair<size_t, GuiMessagePtr>> m_itemDropMessages; HashMap<ItemDescriptor, std::pair<size_t, GuiMessagePtr>> m_itemDropMessages;
unsigned m_messageOverflow; unsigned m_messageOverflow{};
GuiMessagePtr m_overflowMessage; GuiMessagePtr m_overflowMessage;
List<pair<String, RpcPromiseKeeper<P2PJoinRequestReply>>> m_queuedJoinRequests; List<pair<String, RpcPromiseKeeper<P2PJoinRequestReply>>> m_queuedJoinRequests;
EntityId m_lastMouseoverTarget; EntityId m_lastMouseoverTarget{NullEntityId};
GameTimer m_stickyTargetingTimer; GameTimer m_stickyTargetingTimer;
int m_portraitScale; int m_portraitScale{};
EntityId m_specialDamageBarTarget; EntityId m_specialDamageBarTarget{NullEntityId};
float m_specialDamageBarValue; float m_specialDamageBarValue{};
ContainerInteractorPtr m_containerInteractor; ContainerInteractorPtr m_containerInteractor;
}; };

View File

@ -5,9 +5,11 @@
namespace Star { namespace Star {
SystemWorldServerThread::SystemWorldServerThread(Vec3I const& location, SystemWorldServerPtr systemWorld, String storageFile) SystemWorldServerThread::SystemWorldServerThread(Vec3I const& location, SystemWorldServerPtr systemWorld, String storageFile)
: Thread(strf("SystemWorldServer: {}", location)), m_stop(false), m_storageFile(storageFile) { : Thread(strf("SystemWorldServer: {}", location))
m_systemLocation = location; , m_systemLocation(location)
m_systemWorld = move(systemWorld); , m_systemWorld(move(systemWorld))
, m_storageFile(storageFile)
{
} }
SystemWorldServerThread::~SystemWorldServerThread() { SystemWorldServerThread::~SystemWorldServerThread() {

View File

@ -48,9 +48,9 @@ private:
Vec3I m_systemLocation; Vec3I m_systemLocation;
SystemWorldServerPtr m_systemWorld; SystemWorldServerPtr m_systemWorld;
atomic<bool> m_stop; atomic<bool> m_stop{false};
float m_periodicStorage; float m_periodicStorage{300.0f};
bool m_triggerStorage; bool m_triggerStorage{ false};
String m_storageFile; String m_storageFile;
shared_ptr<const atomic<bool>> m_pause; shared_ptr<const atomic<bool>> m_pause;

View File

@ -362,7 +362,7 @@ private:
StringMap<ScriptComponentPtr> m_scriptContexts; StringMap<ScriptComponentPtr> m_scriptContexts;
WorldGeometry m_geometry; WorldGeometry m_geometry;
uint64_t m_currentStep; uint64_t m_currentStep{};
mutable CellularLightIntensityCalculator m_lightIntensityCalculator; mutable CellularLightIntensityCalculator m_lightIntensityCalculator;
SkyPtr m_sky; SkyPtr m_sky;

View File

@ -69,7 +69,7 @@ private:
double m_timer; double m_timer;
PerlinF m_rayPerlin; PerlinF m_rayPerlin;
uint64_t m_starsHash; uint64_t m_starsHash{};
List<TexturePtr> m_starTextures; List<TexturePtr> m_starTextures;
shared_ptr<Random2dPointGenerator<pair<size_t, float>>> m_starGenerator; shared_ptr<Random2dPointGenerator<pair<size_t, float>>> m_starGenerator;
List<shared_ptr<Random2dPointGenerator<pair<String, float>, double>>> m_debrisGenerators; List<shared_ptr<Random2dPointGenerator<pair<String, float>, double>>> m_debrisGenerators;