Merge pull request #20 from kblaschke/small-fixes

A few small fixes
This commit is contained in:
Kae 2024-02-20 09:49:50 +11:00 committed by GitHub
commit 00cf86f240
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 60 additions and 63 deletions

View File

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

View File

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

View File

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

View File

@ -184,6 +184,8 @@ tuple<Vec2U, PixelFormat> Image::readPngMetadata(IODevicePtr device) {
channels += 1;
}
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
Vec2U imageSize{img_width, img_height};
PixelFormat pixelFormat = channels == 3 ? PixelFormat::RGB24 : PixelFormat::RGBA32;

View File

@ -2,6 +2,7 @@
#define STAR_STATIC_VECTOR_HPP
#include "StarException.hpp"
#include "StarFormat.hpp"
namespace Star {

View File

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

View File

@ -109,33 +109,33 @@ private:
// these include the time for background fades so they may not reflect the completion timecode
Clock m_timer;
float m_completionTime;
float m_completionTime{};
Maybe<Vec4B> m_backgroundColor;
float m_backgroundFadeTime;
float m_backgroundFadeTime{};
float m_cameraZoom;
Vec2F m_cameraPan;
float m_cameraZoom{1.0f};
Vec2F m_cameraPan{};
float m_drawableScale;
Vec2F m_drawableTranslation;
Vec2F m_windowSize;
RectI m_scissorRect;
float m_drawableScale{1.0f};
Vec2F m_drawableTranslation{};
Vec2F m_windowSize{};
RectI m_scissorRect{};
bool m_scissor;
bool m_letterbox;
bool m_scissor{true};
bool m_letterbox{true};
PlayerPtr m_player;
Vec2F m_offset;
Vec2F m_offset{};
bool m_skippable;
bool m_suppressInput;
bool m_skippable{true};
bool m_suppressInput{false};
bool m_muteSfx;
bool m_muteMusic;
bool m_muteSfx{false};
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)
: message(message), cooldown(cooldown), springState(spring) {}
MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter, CinematicPtr cinematicOverlay) {
m_state = Running;
m_guiContext = GuiContext::singletonPtr();
m_client = client;
m_worldPainter = painter;
m_cinematicOverlay = cinematicOverlay;
m_disableHud = false;
m_cursorScreenPos = Vec2I();
m_state = Running;
m_config = MainInterfaceConfig::loadFromAssets();
m_containerInteractor = make_shared<ContainerInteractor>();
MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter, CinematicPtr cinematicOverlay)
: m_guiContext(GuiContext::singletonPtr())
, m_config(MainInterfaceConfig::loadFromAssets())
, m_client(std::move(client))
, m_worldPainter(std::move(painter))
, m_cinematicOverlay(std::move(cinematicOverlay))
, m_containerInteractor(make_shared<ContainerInteractor>())
{
GuiReader itemSlotReader;
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_debugMapClearTimer = GameTimer(m_config->debugMapClearTime);
m_debugTextRect = RectF::null();
m_lastMouseoverTarget = NullEntityId;
m_stickyTargetingTimer = GameTimer(m_config->monsterHealthBarTime);
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_nameplatePainter = make_shared<NameplatePainter>();
m_questIndicatorPainter = make_shared<QuestIndicatorPainter>(client);
m_questIndicatorPainter = make_shared<QuestIndicatorPainter>(m_client);
m_chatBubbleManager = make_shared<ChatBubbleManager>();
m_paneManager.displayRegisteredPane(MainInterfacePanes::ActionBar);

View File

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

View File

@ -434,7 +434,7 @@ void Voice::update(float dt, PositionalAttenuationFunction positionalAttenuation
speaker->channelVolumes = Vec2F::filled(1.0f);
auto& dbHistory = speaker->dbHistory;
memcpy(&dbHistory[1], &dbHistory[0], (dbHistory.size() - 1) * sizeof(float));
memmove(&dbHistory[1], &dbHistory[0], (dbHistory.size() - 1) * sizeof(float));
dbHistory[0] = speaker->decibelLevel;
float smoothDb = 0.0f;
for (float dB : dbHistory)

View File

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

View File

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

View File

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

View File

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