From 7cff1728a3488d6c3eed4d31ce599285a90a8d46 Mon Sep 17 00:00:00 2001 From: Li Linfeng Date: Sun, 13 Oct 2019 18:33:13 +0800 Subject: [PATCH] fix warnings --- src/celengine/body.cpp | 2 +- src/celengine/curveplot.cpp | 6 ++--- src/celengine/frametree.cpp | 4 ++-- src/celengine/parser.cpp | 2 +- src/celengine/rectangle.h | 2 +- src/celengine/render.cpp | 2 +- src/celengine/timeline.cpp | 2 +- src/celephem/customorbit.cpp | 2 +- src/celestia/celestiacore.cpp | 45 ++++++++++++++++++++++++++++------- 9 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/celengine/body.cpp b/src/celengine/body.cpp index 1f9266f6..99fa32dd 100644 --- a/src/celengine/body.cpp +++ b/src/celengine/body.cpp @@ -59,7 +59,7 @@ Body::~Body() if(altSurfaces) { - for (const auto s : *altSurfaces) + for (const auto &s : *altSurfaces) delete s.second; delete altSurfaces; } diff --git a/src/celengine/curveplot.cpp b/src/celengine/curveplot.cpp index f5d2ab00..a70bcc4c 100644 --- a/src/celengine/curveplot.cpp +++ b/src/celengine/curveplot.cpp @@ -673,7 +673,7 @@ CurvePlot::setDuration(double duration) * @param nearZ z coordinate of the near plane * @param farZ z coordinate of the far plane * @param viewFrustumPlaneNormals array of four normals (top, bottom, left, and right frustum planes) - * @param subdivisionThreshold + * @param subdivisionThreshold the threashhold for subdivision */ void CurvePlot::render(const Affine3d& modelview, @@ -813,7 +813,7 @@ CurvePlot::render(const Affine3d& modelview, * @param nearZ z coordinate of the near plane * @param farZ z coordinate of the far plane * @param viewFrustumPlaneNormals array of four normals (top, bottom, left, and right frustum planes) - * @param subdivisionThreshold + * @param subdivisionThreshold the threashhold for subdivision * @param startTime the beginning of the time interval * @param endTime the end of the time interval */ @@ -977,7 +977,7 @@ CurvePlot::render(const Affine3d& modelview, * @param nearZ z coordinate of the near plane * @param farZ z coordinate of the far plane * @param viewFrustumPlaneNormals array of four normals (top, bottom, left, and right frustum planes) - * @param subdivisionThreshold + * @param subdivisionThreshold the threashhold for subdivision * @param startTime the beginning of the time interval * @param endTime the end of the time interval * @param fadeStartTime points on the curve before this time are drawn with full opacity diff --git a/src/celengine/frametree.cpp b/src/celengine/frametree.cpp index f13b0c34..b3ab71ac 100644 --- a/src/celengine/frametree.cpp +++ b/src/celengine/frametree.cpp @@ -110,7 +110,7 @@ FrameTree::markUpdated() if (m_changed) { m_changed = false; - for (const auto child : children) + for (const auto &child : children) child->body()->markUpdated(); } } @@ -132,7 +132,7 @@ FrameTree::recomputeBoundingSphere() m_containsSecondaryIlluminators = false; m_childClassMask = 0; - for (const auto phase : children) + for (const auto &phase : children) { double bodyRadius = phase->body()->getRadius(); double r = phase->body()->getCullingRadius() + phase->orbit()->getBoundingRadius(); diff --git a/src/celengine/parser.cpp b/src/celengine/parser.cpp index 55de29e7..1eea6bf7 100644 --- a/src/celengine/parser.cpp +++ b/src/celengine/parser.cpp @@ -314,7 +314,7 @@ AssociativeArray::~AssociativeArray() iter++; } #endif - for (const auto iter : assoc) + for (const auto &iter : assoc) delete iter.second; } diff --git a/src/celengine/rectangle.h b/src/celengine/rectangle.h index 38356a3b..e74d81ae 100644 --- a/src/celengine/rectangle.h +++ b/src/celengine/rectangle.h @@ -25,7 +25,7 @@ class Rect Filled = 0x0002, }; - Rect() = default; + Rect() = delete; Rect(float _x, float _y, float _w, float _h) : x(_x), y(_y), w(_w), h(_h) { diff --git a/src/celengine/render.cpp b/src/celengine/render.cpp index 84222e53..882a6818 100644 --- a/src/celengine/render.cpp +++ b/src/celengine/render.cpp @@ -6567,7 +6567,7 @@ void PointStarRenderer::process(const Star& star, float distance, float appMag) Vector3d hPos = astrocentricPosition(observer->getPosition(), star, observer->getTime()); - relPos = hPos.cast() * -astro::kilometersToLightYears(1.0f), + relPos = hPos.cast() * -astro::kilometersToLightYears(1.0f); distance = relPos.norm(); // Recompute apparent magnitude using new distance computation diff --git a/src/celengine/timeline.cpp b/src/celengine/timeline.cpp index 457a69a7..8dee834b 100644 --- a/src/celengine/timeline.cpp +++ b/src/celengine/timeline.cpp @@ -127,7 +127,7 @@ Timeline::markChanged() } else { - for (const auto phase : phases) + for (const auto &phase : phases) phase->getFrameTree()->markChanged(); } } diff --git a/src/celephem/customorbit.cpp b/src/celephem/customorbit.cpp index af10d422..efff52e2 100644 --- a/src/celephem/customorbit.cpp +++ b/src/celephem/customorbit.cpp @@ -2286,7 +2286,7 @@ class TitanOrbit : public CachingOrbit double g = W4 - Om_ - psi; // Three successive approximations will always be enough - double om; + double om = 0.0; for (int n = 0; n < 3; n++) { om = W4 + 0.37515 * (sinD(2 * g) - sinD(2 * g0)); diff --git a/src/celestia/celestiacore.cpp b/src/celestia/celestiacore.cpp index 5174bef2..c81bbe43 100644 --- a/src/celestia/celestiacore.cpp +++ b/src/celestia/celestiacore.cpp @@ -2586,13 +2586,25 @@ static void displayRotationPeriod(Overlay& overlay, double days) const char *p; if (days > 1.0) - n = FormattedNumber(days, 3, FormattedNumber::GroupThousands), p = _("days"); + { + n = FormattedNumber(days, 3, FormattedNumber::GroupThousands); + p = _("days"); + } else if (days > 1.0 / 24.0) - n = FormattedNumber(days * 24.0, 3, FormattedNumber::GroupThousands), p = _("hours"); + { + n = FormattedNumber(days * 24.0, 3, FormattedNumber::GroupThousands); + p = _("hours"); + } else if (days > 1.0 / (24.0 * 60.0)) - n = FormattedNumber(days * 24.0 * 60.0, 3, FormattedNumber::GroupThousands), p = _("minutes"); + { + n = FormattedNumber(days * 24.0 * 60.0, 3, FormattedNumber::GroupThousands); + p = _("minutes"); + } else - n = FormattedNumber(days * 24.0 * 60.0 * 60.0, 3, FormattedNumber::GroupThousands), p = _("seconds"); + { + n = FormattedNumber(days * 24.0 * 60.0 * 60.0, 3, FormattedNumber::GroupThousands); + p = _("seconds"); + } fmt::fprintf(overlay, _("Rotation period: %s %s\n"), n, p); } @@ -2603,15 +2615,30 @@ static void displaySpeed(Overlay& overlay, float speed) const char *u; if (speed < 1.0f) - n = SigDigitNum(speed * 1000.0f, 3), u = _("m/s"); + { + n = SigDigitNum(speed * 1000.0f, 3); + u = _("m/s"); + } else if (speed < 10000.0f) - n = SigDigitNum(speed, 3), u = _("km/s"); + { + n = SigDigitNum(speed, 3); + u = _("km/s"); + } else if (speed < (float) astro::speedOfLight * 100.0f) - n = SigDigitNum(speed / astro::speedOfLight, 3), u = "c"; + { + n = SigDigitNum(speed / astro::speedOfLight, 3); + u = "c"; + } else if (speed < astro::AUtoKilometers(1000.0f)) - n = SigDigitNum(astro::kilometersToAU(speed), 3), u = _("AU/s"); + { + n = SigDigitNum(astro::kilometersToAU(speed), 3); + u = _("AU/s"); + } else - n = SigDigitNum(astro::kilometersToLightYears(speed), 3), u = _("ly/s"); + { + n = SigDigitNum(astro::kilometersToLightYears(speed), 3); + u = _("ly/s"); + } fmt::fprintf(overlay, _("Speed: %s %s\n"), n, u); }