From 0c9cf51d81a460d7f06cd74cf25b050680aa82e3 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Thu, 6 Aug 2015 11:12:43 +0200 Subject: [PATCH] Address comments on commit d7bc28a --- src/graphics/engine/planet.cpp | 13 +++++------- src/graphics/engine/planet.h | 15 +++---------- src/graphics/engine/planet_type.h | 35 +++++++++++++++++++++++++++++++ src/object/level/parserparam.cpp | 11 ++++++++++ src/object/level/parserparam.h | 2 ++ src/object/robotmain.cpp | 2 +- src/sound/oalsound/check.cpp | 19 +++++++++++++++++ 7 files changed, 76 insertions(+), 21 deletions(-) create mode 100644 src/graphics/engine/planet_type.h diff --git a/src/graphics/engine/planet.cpp b/src/graphics/engine/planet.cpp index 8329c62e..f5427d5e 100644 --- a/src/graphics/engine/planet.cpp +++ b/src/graphics/engine/planet.cpp @@ -20,6 +20,8 @@ #include "graphics/engine/planet.h" +#include "common/event.h" + #include "graphics/core/device.h" #include "graphics/engine/engine.h" @@ -31,7 +33,7 @@ namespace Gfx namespace { -const int PLANET_PREALLOCATE_COUNT = 10; +const int PLANET_PREALLOCATE_COUNT = 20; } // anonymous namespace @@ -39,7 +41,6 @@ CPlanet::CPlanet(CEngine* engine) : m_engine(engine) { m_planets.reserve(PLANET_PREALLOCATE_COUNT); - } CPlanet::~CPlanet() @@ -143,17 +144,13 @@ void CPlanet::Draw() } } -void CPlanet::Create(int mode, Math::Point start, float dim, float speed, +void CPlanet::Create(PlanetType type, Math::Point start, float dim, float speed, float dir, const std::string& name, Math::Point uv1, Math::Point uv2, bool transparent) { - if (mode < 0) mode = 0; - if (mode > 1) mode = 1; - Planet planet; - // TODO: refactor mode to planet type in interface - planet.type = (mode == 0) ? PlanetType::Sky : PlanetType::OuterSpace; + planet.type = type; planet.start = start; planet.angle = start; planet.dim = dim; diff --git a/src/graphics/engine/planet.h b/src/graphics/engine/planet.h index 567a3315..f30a47a6 100644 --- a/src/graphics/engine/planet.h +++ b/src/graphics/engine/planet.h @@ -24,12 +24,13 @@ #pragma once -#include "common/event.h" +#include "graphics/engine/planet_type.h" #include "math/point.h" #include +struct Event; // Graphics module namespace namespace Gfx @@ -37,16 +38,6 @@ namespace Gfx class CEngine; -/** - * \enum PlanetType - * \brief Type of planet which determines when it is displayed - */ -enum PlanetType -{ - Sky, //!< normal planets, orbiting in the sky - OuterSpace //!< only visible during spaceship flight -}; - /** * \class CPlanet * \brief Planet manager @@ -66,7 +57,7 @@ public: //! Management of an event bool EventProcess(const Event &event); //! Creates a new planet - void Create(int mode, Math::Point start, float dim, float speed, float dir, + void Create(PlanetType type, Math::Point start, float dim, float speed, float dir, const std::string& name, Math::Point uv1, Math::Point uv2, bool transparent); //! Indicates if there is at least one planet diff --git a/src/graphics/engine/planet_type.h b/src/graphics/engine/planet_type.h new file mode 100644 index 00000000..2d4cd483 --- /dev/null +++ b/src/graphics/engine/planet_type.h @@ -0,0 +1,35 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ + +#pragma once + +namespace Gfx +{ + +/** + * \enum PlanetType + * \brief Type of planet which determines when it is displayed + */ +enum PlanetType +{ + Sky, //!< normal planets, orbiting in the sky + OuterSpace //!< only visible during spaceship flight +}; + +} // namespace Gfx diff --git a/src/object/level/parserparam.cpp b/src/object/level/parserparam.cpp index 585a86b7..b552173c 100644 --- a/src/object/level/parserparam.cpp +++ b/src/object/level/parserparam.cpp @@ -895,6 +895,17 @@ MissionType CLevelParserParam::AsMissionType(MissionType def) return AsMissionType(); } +Gfx::PlanetType CLevelParserParam::AsPlanetType() +{ + Gfx::PlanetType planetType{}; + + if (m_value == "0") + planetType = Gfx::PlanetType::Sky; + else if (m_value == "1") + planetType = Gfx::PlanetType::OuterSpace; + + return planetType; +} void CLevelParserParam::ParseArray() { diff --git a/src/object/level/parserparam.h b/src/object/level/parserparam.h index e57c9a7d..b02a6999 100644 --- a/src/object/level/parserparam.h +++ b/src/object/level/parserparam.h @@ -27,6 +27,7 @@ #include "graphics/core/color.h" #include "graphics/engine/camera.h" +#include "graphics/engine/planet_type.h" #include "graphics/engine/pyro_type.h" #include "graphics/engine/water.h" @@ -88,6 +89,7 @@ public: Gfx::CameraType AsCameraType(); MissionType AsMissionType(); const CLevelParserParamVec& AsArray(); + Gfx::PlanetType AsPlanetType(); //@} //! Get value (returns default if not found, throws exception if unable to process) diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index ebde1b4d..0100ae52 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3152,7 +3152,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) ppos = line->GetParam("pos")->AsPoint(); uv1 = line->GetParam("uv1")->AsPoint(); uv2 = line->GetParam("uv2")->AsPoint(); - m_planet->Create(line->GetParam("mode")->AsInt(0), + m_planet->Create(line->GetParam("mode")->AsPlanetType(), Math::Point(ppos.x, ppos.z), line->GetParam("dim")->AsFloat(0.2f), line->GetParam("speed")->AsFloat(0.0f), diff --git a/src/sound/oalsound/check.cpp b/src/sound/oalsound/check.cpp index b208b5f0..e19ab084 100644 --- a/src/sound/oalsound/check.cpp +++ b/src/sound/oalsound/check.cpp @@ -1,3 +1,22 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ + #include "sound/oalsound/check.h" namespace