فهرست منبع

Made the indentation of the world map module consistent

- Only whitespace changes.
Iñigo Valentin 1 روز پیش
والد
کامیت
8c89ef4b7f

+ 64 - 64
src/modules/worldmap/WorldmapData.cpp

@@ -334,78 +334,78 @@ namespace VGears {
     }
 
     bool IsFootWalkable(uint8 walkability_type){
-      using WalkType = VGears::WorldmapFileSerializer::TriangleWalkMapTypes;
-      switch (walkability_type){
-        case WalkType::GRASS:
-        case WalkType::FOREST:
-        case WalkType::SWAMP:
-        case WalkType::DESERT:
-        case WalkType::WASTELAND:
-        case WalkType::SNOW:
-        case WalkType::RIVERSIDE:
-        case WalkType::COREL_BRIDGE:
-        case WalkType::WUTAI_BRIDGE:
-        case WalkType::HILL_SIDE:
-        case WalkType::BEACH:
-        case WalkType::CANYON:
-        case WalkType::MOUNTAIN_PASS:
-        case WalkType::GOLD_SAUCER_DESERT:
-        case WalkType::JUNGLE:
-        case WalkType::NORTHERND_CAVE:
-        case WalkType::GOLD_SAUCER_DESERT_BORDER:
-        case WalkType::BRIDGE_HEAD:
-        case WalkType::BACK_ENTRANCE:
-          return true;
-        default:
-          return false;
-      }
+        using WalkType = VGears::WorldmapFileSerializer::TriangleWalkMapTypes;
+        switch (walkability_type){
+            case WalkType::GRASS:
+            case WalkType::FOREST:
+            case WalkType::SWAMP:
+            case WalkType::DESERT:
+            case WalkType::WASTELAND:
+            case WalkType::SNOW:
+            case WalkType::RIVERSIDE:
+            case WalkType::COREL_BRIDGE:
+            case WalkType::WUTAI_BRIDGE:
+            case WalkType::HILL_SIDE:
+            case WalkType::BEACH:
+            case WalkType::CANYON:
+            case WalkType::MOUNTAIN_PASS:
+            case WalkType::GOLD_SAUCER_DESERT:
+            case WalkType::JUNGLE:
+            case WalkType::NORTHERND_CAVE:
+            case WalkType::GOLD_SAUCER_DESERT_BORDER:
+            case WalkType::BRIDGE_HEAD:
+            case WalkType::BACK_ENTRANCE:
+            return true;
+            default:
+            return false;
+        }
     }
 
     const std::map<Ogre::String, uint8>& GetWorldMapTerrainTypes(){
-      using WalkType = VGears::WorldmapFileSerializer::TriangleWalkMapTypes;
-      static const std::map<Ogre::String, uint8> terrain_types = {
-        {"GRASS", static_cast<uint8>(WalkType::GRASS)},
-        {"FOREST", static_cast<uint8>(WalkType::FOREST)},
-        {"MOUNTAIN", static_cast<uint8>(WalkType::MOUNTAIN)},
-        {"SEA_DEEP_WATER", static_cast<uint8>(WalkType::SEA_DEEP_WATER)},
-        {"RIVER_CROSSING", static_cast<uint8>(WalkType::RIVER_CROSSING)},
-        {"RIVER", static_cast<uint8>(WalkType::RIVER)},
-        {"WATER", static_cast<uint8>(WalkType::WATER)},
-        {"SWAMP", static_cast<uint8>(WalkType::SWAMP)},
-        {"DESERT", static_cast<uint8>(WalkType::DESERT)},
-        {"WASTELAND", static_cast<uint8>(WalkType::WASTELAND)},
-        {"SNOW", static_cast<uint8>(WalkType::SNOW)},
-        {"RIVERSIDE", static_cast<uint8>(WalkType::RIVERSIDE)},
-        {"CLIFF", static_cast<uint8>(WalkType::CLIFF)},
-        {"COREL_BRIDGE", static_cast<uint8>(WalkType::COREL_BRIDGE)},
-        {"WUTAI_BRIDGE", static_cast<uint8>(WalkType::WUTAI_BRIDGE)},
-        {"UNUSED_1", static_cast<uint8>(WalkType::UNUSED_1)},
-        {"HILL_SIDE", static_cast<uint8>(WalkType::HILL_SIDE)},
-        {"BEACH", static_cast<uint8>(WalkType::BEACH)},
-        {"SUBMARINE_PEN", static_cast<uint8>(WalkType::SUBMARINE_PEN)},
-        {"CANYON", static_cast<uint8>(WalkType::CANYON)},
-        {"MOUNTAIN_PASS", static_cast<uint8>(WalkType::MOUNTAIN_PASS)},
-        {"UNKNOWN_1", static_cast<uint8>(WalkType::UNKNOWN_1)},
-        {"WATERFALL", static_cast<uint8>(WalkType::WATERFALL)},
-        {"UNUSED_2", static_cast<uint8>(WalkType::UNUSED_2)},
-        {"GOLD_SAUCER_DESERT", static_cast<uint8>(WalkType::GOLD_SAUCER_DESERT)},
-        {"JUNGLE", static_cast<uint8>(WalkType::JUNGLE)},
-        {"SEA", static_cast<uint8>(WalkType::SEA)},
-        {"NORTHERND_CAVE", static_cast<uint8>(WalkType::NORTHERND_CAVE)},
-        {"GOLD_SAUCER_DESERT_BORDER", static_cast<uint8>(WalkType::GOLD_SAUCER_DESERT_BORDER)},
-        {"BRIDGE_HEAD", static_cast<uint8>(WalkType::BRIDGE_HEAD)},
-        {"BACK_ENTRANCE", static_cast<uint8>(WalkType::BACK_ENTRANCE)},
-        {"UNUSED_3", static_cast<uint8>(WalkType::UNUSED_3)}
-      };
-      return terrain_types;
+        using WalkType = VGears::WorldmapFileSerializer::TriangleWalkMapTypes;
+        static const std::map<Ogre::String, uint8> terrain_types = {
+            {"GRASS", static_cast<uint8>(WalkType::GRASS)},
+            {"FOREST", static_cast<uint8>(WalkType::FOREST)},
+            {"MOUNTAIN", static_cast<uint8>(WalkType::MOUNTAIN)},
+            {"SEA_DEEP_WATER", static_cast<uint8>(WalkType::SEA_DEEP_WATER)},
+            {"RIVER_CROSSING", static_cast<uint8>(WalkType::RIVER_CROSSING)},
+            {"RIVER", static_cast<uint8>(WalkType::RIVER)},
+            {"WATER", static_cast<uint8>(WalkType::WATER)},
+            {"SWAMP", static_cast<uint8>(WalkType::SWAMP)},
+            {"DESERT", static_cast<uint8>(WalkType::DESERT)},
+            {"WASTELAND", static_cast<uint8>(WalkType::WASTELAND)},
+            {"SNOW", static_cast<uint8>(WalkType::SNOW)},
+            {"RIVERSIDE", static_cast<uint8>(WalkType::RIVERSIDE)},
+            {"CLIFF", static_cast<uint8>(WalkType::CLIFF)},
+            {"COREL_BRIDGE", static_cast<uint8>(WalkType::COREL_BRIDGE)},
+            {"WUTAI_BRIDGE", static_cast<uint8>(WalkType::WUTAI_BRIDGE)},
+            {"UNUSED_1", static_cast<uint8>(WalkType::UNUSED_1)},
+            {"HILL_SIDE", static_cast<uint8>(WalkType::HILL_SIDE)},
+            {"BEACH", static_cast<uint8>(WalkType::BEACH)},
+            {"SUBMARINE_PEN", static_cast<uint8>(WalkType::SUBMARINE_PEN)},
+            {"CANYON", static_cast<uint8>(WalkType::CANYON)},
+            {"MOUNTAIN_PASS", static_cast<uint8>(WalkType::MOUNTAIN_PASS)},
+            {"UNKNOWN_1", static_cast<uint8>(WalkType::UNKNOWN_1)},
+            {"WATERFALL", static_cast<uint8>(WalkType::WATERFALL)},
+            {"UNUSED_2", static_cast<uint8>(WalkType::UNUSED_2)},
+            {"GOLD_SAUCER_DESERT", static_cast<uint8>(WalkType::GOLD_SAUCER_DESERT)},
+            {"JUNGLE", static_cast<uint8>(WalkType::JUNGLE)},
+            {"SEA", static_cast<uint8>(WalkType::SEA)},
+            {"NORTHERND_CAVE", static_cast<uint8>(WalkType::NORTHERND_CAVE)},
+            {"GOLD_SAUCER_DESERT_BORDER", static_cast<uint8>(WalkType::GOLD_SAUCER_DESERT_BORDER)},
+            {"BRIDGE_HEAD", static_cast<uint8>(WalkType::BRIDGE_HEAD)},
+            {"BACK_ENTRANCE", static_cast<uint8>(WalkType::BACK_ENTRANCE)},
+            {"UNUSED_3", static_cast<uint8>(WalkType::UNUSED_3)}
+        };
+        return terrain_types;
     }
 
-      Ogre::String GetWorldMapTerrainName(const uint8 walkability_type){
+    Ogre::String GetWorldMapTerrainName(const uint8 walkability_type){
         for (const auto& terrain : GetWorldMapTerrainTypes()){
-          if (terrain.second == walkability_type) return terrain.first;
+            if (terrain.second == walkability_type) return terrain.first;
         }
         return "";
-      }
+    }
 
     MapLayout GetMapLayout(const int map_id){
         switch (map_id){

+ 4 - 4
src/modules/worldmap/WorldmapEntities.cpp

@@ -115,10 +115,10 @@ namespace VGears {
             player_entity_ = submarine_entity_;
             player_height_offset_ = 0;
             if (dive_requested_){
-              // Same heading as in WM0.
-              submarine_entity_->GetModel()->getParentSceneNode()->getParentSceneNode()
-                ->setOrientation(Ogre::Quaternion(Ogre::Radian(dive_heading_), Ogre::Vector3::UNIT_Y));
-              dive_requested_ = false;
+                // Same heading as in WM0.
+                submarine_entity_->GetModel()->getParentSceneNode()->getParentSceneNode()
+                  ->setOrientation(Ogre::Quaternion(Ogre::Radian(dive_heading_), Ogre::Vector3::UNIT_Y));
+                dive_requested_ = false;
             }
             // It floats over the seabed.
             submarine_entity_->SetPosition(

+ 132 - 132
src/modules/worldmap/WorldmapModule.cpp

@@ -80,7 +80,7 @@ namespace VGears {
     {}
 
     WorldmapModule::~WorldmapModule(){
-      if (frame_listener_attached_) Root::getSingleton().removeFrameListener(this);
+        if (frame_listener_attached_) Root::getSingleton().removeFrameListener(this);
     }
 
     bool WorldmapModule::frameStarted(const Ogre::FrameEvent& event){
@@ -265,7 +265,7 @@ namespace VGears {
         return true;
     }
 
-      void WorldmapModule::UpdateCamera(Ogre::Real delta_time, bool snap_to_player){
+    void WorldmapModule::UpdateCamera(Ogre::Real delta_time, bool snap_to_player){
         ::Entity* active_entity = EntityManager::getSingleton().ScriptGetPlayerEntity();
         if (active_entity == nullptr) return;
         const Ogre::Vector3 target
@@ -285,8 +285,8 @@ namespace VGears {
         float pitch = std::atan2(1.5f, 2.25f);
         const auto camera_settings = camera_settings_.find(camera_name);
         if (camera_settings != camera_settings_.end()){
-          distance = camera_settings->second.distance;
-          pitch = Ogre::Math::DegreesToRadians(camera_settings->second.pitch_degrees);
+            distance = camera_settings->second.distance;
+            pitch = Ogre::Math::DegreesToRadians(camera_settings->second.pitch_degrees);
         }
         const Ogre::Vector3 camera_offset
           = Ogre::Quaternion(Ogre::Radian(yaw), Ogre::Vector3::UNIT_Y)
@@ -294,17 +294,17 @@ namespace VGears {
         Ogre::Camera* camera = CameraManager::getSingleton().GetCurrentCamera();
         const Ogre::Vector3 desired_position = target + camera_offset;
         if (snap_to_player){
-          camera->setPosition(desired_position);
+            camera->setPosition(desired_position);
         }
         else{
-          const Ogre::Real follow_amount = std::min(1.0f, delta_time * 8.0f);
-          camera->setPosition(
-            camera->getPosition()
-            + (desired_position - camera->getPosition()) * follow_amount
-          );
+            const Ogre::Real follow_amount = std::min(1.0f, delta_time * 8.0f);
+            camera->setPosition(
+              camera->getPosition()
+              + (desired_position - camera->getPosition()) * follow_amount
+            );
         }
         camera->lookAt(target);
-      }
+    }
 
     void WorldmapModule::PauseForBattle(){
         paused_for_battle_ = true;
@@ -325,152 +325,152 @@ namespace VGears {
 
     /// Names of the entities of the overworld whose state is kept when the map is replaced.
     static const char* const OVERWORLD_ENTITY_NAMES[] = {
-      "WorldMapCloud", "WorldMapChocobo", "WorldMapHighwind", "WorldMapBuggy",
-      "WorldMapSubmarine", "WorldMapTinyBronco"
+        "WorldMapCloud", "WorldMapChocobo", "WorldMapHighwind", "WorldMapBuggy",
+        "WorldMapSubmarine", "WorldMapTinyBronco"
     };
 
     void WorldmapModule::SaveOverworldSnapshot(){
-      overworld_snapshot_.clear();
-      for (const char* name : OVERWORLD_ENTITY_NAMES){
-        ::Entity* entity = EntityManager::getSingleton().GetEntity(name);
-        if (entity == nullptr) continue;
-        EntityState state;
-        state.name = name;
-        state.position = entity->GetPosition();
-        state.orientation = static_cast<EntityModel*>(entity)->GetModel()->getParentSceneNode()
-          ->getParentSceneNode()->getOrientation();
-        state.visible = entity->IsVisible();
-        state.solid = entity->IsSolid();
-        state.talkable = entity->IsTalkable();
-        overworld_snapshot_.push_back(state);
-      }
+        overworld_snapshot_.clear();
+        for (const char* name : OVERWORLD_ENTITY_NAMES){
+            ::Entity* entity = EntityManager::getSingleton().GetEntity(name);
+            if (entity == nullptr) continue;
+            EntityState state;
+            state.name = name;
+            state.position = entity->GetPosition();
+            state.orientation = static_cast<EntityModel*>(entity)->GetModel()->getParentSceneNode()
+              ->getParentSceneNode()->getOrientation();
+            state.visible = entity->IsVisible();
+            state.solid = entity->IsSolid();
+            state.talkable = entity->IsTalkable();
+            overworld_snapshot_.push_back(state);
+        }
     }
 
     void WorldmapModule::RestoreOverworldSnapshot(){
-      for (const EntityState& state : overworld_snapshot_){
-        ::Entity* entity = EntityManager::getSingleton().GetEntity(state.name);
-        if (entity == nullptr) continue;
-        entity->SetPosition(state.position);
-        static_cast<EntityModel*>(entity)->GetModel()->getParentSceneNode()->getParentSceneNode()
-          ->setOrientation(state.orientation);
-        entity->SetVisible(state.visible);
-        entity->SetSolid(state.solid);
-        entity->SetTalkable(state.talkable);
-      }
-      overworld_snapshot_.clear();
+        for (const EntityState& state : overworld_snapshot_){
+            ::Entity* entity = EntityManager::getSingleton().GetEntity(state.name);
+            if (entity == nullptr) continue;
+            entity->SetPosition(state.position);
+            static_cast<EntityModel*>(entity)->GetModel()->getParentSceneNode()->getParentSceneNode()
+              ->setOrientation(state.orientation);
+            entity->SetVisible(state.visible);
+            entity->SetSolid(state.solid);
+            entity->SetTalkable(state.talkable);
+        }
+        overworld_snapshot_.clear();
     }
 
     void WorldmapModule::DestroyWorldMap(){
-      // The overworld is built again when the submarine surfaces: keep where everything was.
-      if (map_id_ == 0) SaveOverworldSnapshot();
-      Suspend();
-      terrain_.Clear();
-      encounters_.Clear();
-      // The entities of the old map (player, vehicles, models and scripts).
-      EntityManager::getSingleton().ClearWorld();
-      initialized_ = false;
-      map_id_ = -1;
+        // The overworld is built again when the submarine surfaces: keep where everything was.
+        if (map_id_ == 0) SaveOverworldSnapshot();
+        Suspend();
+        terrain_.Clear();
+        encounters_.Clear();
+        // The entities of the old map (player, vehicles, models and scripts).
+        EntityManager::getSingleton().ClearWorld();
+        initialized_ = false;
+        map_id_ = -1;
     }
 
     void WorldmapModule::Enter(const int map_id){
-      if (initialized_) DestroyWorldMap();
-      Init(map_id);
+        if (initialized_) DestroyWorldMap();
+        Init(map_id);
     }
 
     void WorldmapModule::Init(const int map_id){
-      if (map_id < 0 || map_id >= WORLD_MAP_COUNT){
-        LogManager::getSingleton().logMessage(
-          "Invalid world map " + std::to_string(map_id) + ". Valid maps are 0 to "
-            + std::to_string(WORLD_MAP_COUNT - 1) + "."
-        );
-        return;
-      }
-      if (initialized_ && map_id != map_id_){
-        DestroyWorldMap();
-      }
-      if (initialized_){
-        if (frame_listener_attached_) return;
+        if (map_id < 0 || map_id >= WORLD_MAP_COUNT){
+            LogManager::getSingleton().logMessage(
+              "Invalid world map " + std::to_string(map_id) + ". Valid maps are 0 to "
+                + std::to_string(WORLD_MAP_COUNT - 1) + "."
+            );
+            return;
+        }
+        if (initialized_ && map_id != map_id_){
+            DestroyWorldMap();
+        }
+        if (initialized_){
+            if (frame_listener_attached_) return;
+            EntityManager::getSingleton().SetWorldModule();
+            DialogsManager::getSingleton().SetWorldModule();
+            terrain_.SetVisible(true);
+            // The music starts again (a field or a battle had its own).
+            music_timer_ = 1.0f;
+            ScriptManager::getSingleton().RunString("if WorldMusic then WorldMusic.reset() end");
+            CreatePlayer();
+            Root::getSingleton().addFrameListener(this);
+            frame_listener_attached_ = true;
+            return;
+        }
+        map_id_ = map_id;
+        camera_yaw_ = 0;
         EntityManager::getSingleton().SetWorldModule();
         DialogsManager::getSingleton().SetWorldModule();
-        terrain_.SetVisible(true);
-        // The music starts again (a field or a battle had its own).
+        terrain_.Load(Root::getSingleton().getSceneManager("Scene"), map_id_);
+        const Ogre::Vector3 center = terrain_.GetCenter();
+        Ogre::Camera* camera = CameraManager::getSingleton().GetCurrentCamera();
+        camera->setPosition(Ogre::Vector3(center.x, 80.0f, center.z + 90.0f));
+        camera->lookAt(Ogre::Vector3(center.x, 0.0f, center.z));
+        // Underwater (WM2): everything fades to black with the distance to the camera.
+        if (map_id_ == 1){
+            Root::getSingleton().getSceneManager("Scene")->setFog(
+              Ogre::FOG_LINEAR, Ogre::ColourValue::Black, 0.0f, UNDERWATER_FOG_START, UNDERWATER_FOG_END
+            );
+        }
+        else Root::getSingleton().getSceneManager("Scene")->setFog(Ogre::FOG_NONE);
+        // Snow map (WM3): it always snows.
+        snow_.SetVisible(map_id_ == 2);
+        // The music of the map starts in the first frame.
         music_timer_ = 1.0f;
         ScriptManager::getSingleton().RunString("if WorldMusic then WorldMusic.reset() end");
+        // The button that was used to get here (a menu, a field) must not count as the first pole.
+        confirm_was_pressed_ = InputManager::getSingleton().IsGameEventPressed("CONFIRM");
+        snow_.Reset();
+        ScriptManager::getSingleton().RunFile(
+          "game/world/scripts/wm" + std::to_string(WORLD_MAP_FILE_NUMBERS[map_id_]) + ".lua"
+        );
+        // The debug spawn points, if debug_data.lua has them.
+        spawn_overrides_.clear();
+        hidden_vehicles_.clear();
+        ScriptManager::getSingleton().RunString(
+          "if WorldMapDebug and WorldMapDebug.spawn then "
+          "for name, point in pairs(WorldMapDebug.spawn) do "
+          "world_map_module:set_spawn(name, point[1], point[2]) end end"
+        );
+        // The positions that the scripts give to the vehicles, for the story (debug ones have priority).
+        ScriptManager::getSingleton().RunString(
+          "if WorldVM then WorldVM.prepare(" + std::to_string(map_id_) + ") end"
+        );
         CreatePlayer();
+        // The models that the scripts place (scenery).
+        ScriptManager::getSingleton().RunString(
+          "if WorldVM then WorldVM.place_models(" + std::to_string(map_id_) + ") end"
+        );
+        encounters_.Load();
+        initialized_ = true;
         Root::getSingleton().addFrameListener(this);
         frame_listener_attached_ = true;
-        return;
-      }
-      map_id_ = map_id;
-      camera_yaw_ = 0;
-      EntityManager::getSingleton().SetWorldModule();
-      DialogsManager::getSingleton().SetWorldModule();
-      terrain_.Load(Root::getSingleton().getSceneManager("Scene"), map_id_);
-      const Ogre::Vector3 center = terrain_.GetCenter();
-      Ogre::Camera* camera = CameraManager::getSingleton().GetCurrentCamera();
-      camera->setPosition(Ogre::Vector3(center.x, 80.0f, center.z + 90.0f));
-      camera->lookAt(Ogre::Vector3(center.x, 0.0f, center.z));
-      // Underwater (WM2): everything fades to black with the distance to the camera.
-      if (map_id_ == 1){
-        Root::getSingleton().getSceneManager("Scene")->setFog(
-          Ogre::FOG_LINEAR, Ogre::ColourValue::Black, 0.0f, UNDERWATER_FOG_START, UNDERWATER_FOG_END
-        );
-      }
-      else Root::getSingleton().getSceneManager("Scene")->setFog(Ogre::FOG_NONE);
-      // Snow map (WM3): it always snows.
-      snow_.SetVisible(map_id_ == 2);
-      // The music of the map starts in the first frame.
-      music_timer_ = 1.0f;
-      ScriptManager::getSingleton().RunString("if WorldMusic then WorldMusic.reset() end");
-      // The button that was used to get here (a menu, a field) must not count as the first pole.
-      confirm_was_pressed_ = InputManager::getSingleton().IsGameEventPressed("CONFIRM");
-      snow_.Reset();
-      ScriptManager::getSingleton().RunFile(
-        "game/world/scripts/wm" + std::to_string(WORLD_MAP_FILE_NUMBERS[map_id_]) + ".lua"
-      );
-      // The debug spawn points, if debug_data.lua has them.
-      spawn_overrides_.clear();
-      hidden_vehicles_.clear();
-      ScriptManager::getSingleton().RunString(
-        "if WorldMapDebug and WorldMapDebug.spawn then "
-        "for name, point in pairs(WorldMapDebug.spawn) do "
-        "world_map_module:set_spawn(name, point[1], point[2]) end end"
-      );
-      // The positions that the scripts give to the vehicles, for the story (debug ones have priority).
-      ScriptManager::getSingleton().RunString(
-        "if WorldVM then WorldVM.prepare(" + std::to_string(map_id_) + ") end"
-      );
-      CreatePlayer();
-      // The models that the scripts place (scenery).
-      ScriptManager::getSingleton().RunString(
-        "if WorldVM then WorldVM.place_models(" + std::to_string(map_id_) + ") end"
-      );
-      encounters_.Load();
-      initialized_ = true;
-      Root::getSingleton().addFrameListener(this);
-      frame_listener_attached_ = true;
     }
 
     void WorldmapModule::Suspend(){
-      if (!frame_listener_attached_) return;
-      Root::getSingleton().removeFrameListener(this);
-      frame_listener_attached_ = false;
-      terrain_.SetVisible(false);
-      snow_.SetVisible(false);
-      player_entity_ = nullptr;
-      highwind_entity_ = nullptr;
-      buggy_entity_ = nullptr;
-      chocobo_entity_ = nullptr;
-      submarine_entity_ = nullptr;
-      tiny_bronco_entity_ = nullptr;
-      current_vehicle_ = VehicleType::ON_FOOT;
-      active_vehicle_terrain_types_.clear();
-      active_function_mesh_index_ = -1;
-      active_function_id_ = -1;
-      flight_active_ = false;
-      flight_entity_ = nullptr;
-      cancel_was_pressed_ = false;
-      confirm_was_pressed_ = false;
+        if (!frame_listener_attached_) return;
+        Root::getSingleton().removeFrameListener(this);
+        frame_listener_attached_ = false;
+        terrain_.SetVisible(false);
+        snow_.SetVisible(false);
+        player_entity_ = nullptr;
+        highwind_entity_ = nullptr;
+        buggy_entity_ = nullptr;
+        chocobo_entity_ = nullptr;
+        submarine_entity_ = nullptr;
+        tiny_bronco_entity_ = nullptr;
+        current_vehicle_ = VehicleType::ON_FOOT;
+        active_vehicle_terrain_types_.clear();
+        active_function_mesh_index_ = -1;
+        active_function_id_ = -1;
+        flight_active_ = false;
+        flight_entity_ = nullptr;
+        cancel_was_pressed_ = false;
+        confirm_was_pressed_ = false;
     }
 
 } // namespace VGears

+ 9 - 9
src/modules/worldmap/WorldmapModule.h

@@ -215,15 +215,15 @@ namespace VGears {
             std::set<Ogre::String> hidden_vehicles_;
 
             void CreatePlayer();
-                        void CreateCompanionModels();
-                        void AddWorldModel(
-                            const Ogre::String& name, const Ogre::String& mesh_name,
-                            const Ogre::Vector3& desired_position, Ogre::Real target_size,
-                            const Ogre::Quaternion& orientation,
-                            Ogre::Real collision_radius_scale = 1.0f,
-                            bool talkable = false,
-                            Ogre::Real explicit_scale = 0.0f
-                        );
+            void CreateCompanionModels();
+            void AddWorldModel(
+                const Ogre::String& name, const Ogre::String& mesh_name,
+                const Ogre::Vector3& desired_position, Ogre::Real target_size,
+                const Ogre::Quaternion& orientation,
+                Ogre::Real collision_radius_scale = 1.0f,
+                bool talkable = false,
+                Ogre::Real explicit_scale = 0.0f
+            );
             void UpdateCamera(Ogre::Real delta_time, bool snap_to_player);
 
             /**

+ 23 - 23
src/modules/worldmap/WorldmapSnow.cpp

@@ -137,32 +137,32 @@ namespace VGears {
     }
 
     float WorldmapSnow::UpdateCamera(const float delta_time){
-      if (snow_camera_remaining_ == 0.0f){
-        snow_camera_timer_ -= delta_time;
-        if (snow_camera_timer_ > 0.0f) return 0.0f;
-        const float degrees = Ogre::Math::RangeRandom(SNOW_CAMERA_MIN_DEGREES, SNOW_CAMERA_MAX_DEGREES);
-        const float direction = Ogre::Math::UnitRandom() < 0.5f ? -1.0f : 1.0f;
-        snow_camera_remaining_ = direction * Ogre::Math::DegreesToRadians(degrees);
-        snow_camera_timer_ = Ogre::Math::RangeRandom(SNOW_CAMERA_MIN_WAIT, SNOW_CAMERA_MAX_WAIT);
-      }
-      const float step = std::min(std::abs(snow_camera_remaining_), CAMERA_ROTATION_SPEED * delta_time);
-      const float signed_step = snow_camera_remaining_ < 0.0f ? -step : step;
-      snow_camera_remaining_ -= signed_step;
-      if (std::abs(snow_camera_remaining_) < 0.0001f) snow_camera_remaining_ = 0.0f;
-      return signed_step;
+        if (snow_camera_remaining_ == 0.0f){
+            snow_camera_timer_ -= delta_time;
+            if (snow_camera_timer_ > 0.0f) return 0.0f;
+            const float degrees = Ogre::Math::RangeRandom(SNOW_CAMERA_MIN_DEGREES, SNOW_CAMERA_MAX_DEGREES);
+            const float direction = Ogre::Math::UnitRandom() < 0.5f ? -1.0f : 1.0f;
+            snow_camera_remaining_ = direction * Ogre::Math::DegreesToRadians(degrees);
+            snow_camera_timer_ = Ogre::Math::RangeRandom(SNOW_CAMERA_MIN_WAIT, SNOW_CAMERA_MAX_WAIT);
+        }
+        const float step = std::min(std::abs(snow_camera_remaining_), CAMERA_ROTATION_SPEED * delta_time);
+        const float signed_step = snow_camera_remaining_ < 0.0f ? -step : step;
+        snow_camera_remaining_ -= signed_step;
+        if (std::abs(snow_camera_remaining_) < 0.0001f) snow_camera_remaining_ = 0.0f;
+        return signed_step;
     }
 
     void WorldmapSnow::PlacePole(const PoleCreator& create){
-      // The oldest pole goes away when there is no room for another one.
-      while (snow_poles_.size() >= SNOW_MAX_POLES){
-        EntityManager::getSingleton().RemoveWorldMapEntity(snow_poles_.front());
-        snow_poles_.pop_front();
-      }
-      const std::string name = "snowpole_" + std::to_string(snow_pole_counter_++);
-      create(name);
-      if (EntityManager::getSingleton().GetEntity("WorldMap" + name) != nullptr){
-        snow_poles_.push_back("WorldMap" + name);
-      }
+        // The oldest pole goes away when there is no room for another one.
+        while (snow_poles_.size() >= SNOW_MAX_POLES){
+            EntityManager::getSingleton().RemoveWorldMapEntity(snow_poles_.front());
+            snow_poles_.pop_front();
+        }
+        const std::string name = "snowpole_" + std::to_string(snow_pole_counter_++);
+        create(name);
+        if (EntityManager::getSingleton().GetEntity("WorldMap" + name) != nullptr){
+            snow_poles_.push_back("WorldMap" + name);
+        }
     }
 
 } // namespace VGears

+ 1 - 1
src/modules/worldmap/WorldmapSubmarine.cpp

@@ -80,7 +80,7 @@ namespace VGears {
                             continue;
                         }
                         const size_t indices[3] = {
-                          triangle.vertex_0_index, triangle.vertex_1_index, triangle.vertex_2_index
+                            triangle.vertex_0_index, triangle.vertex_1_index, triangle.vertex_2_index
                         };
                         Triangle result;
                         for (int i = 0; i < 3; ++i){

+ 15 - 15
src/modules/worldmap/WorldmapTerrain.cpp

@@ -66,24 +66,24 @@ namespace VGears {
     }
 
     void WorldmapTerrain::Load(SceneManager* scene_manager, const int map_id){
-      scene_manager_ = scene_manager;
-      // The node is kept when a map is replaced.
-      if (world_map_node_ == nullptr){
-        world_map_node_ = scene_manager_->getRootSceneNode()
-          ->createChildSceneNode("WorldMapTerrain");
-      }
-      world_map_node_->setVisible(true);
-      const MapLayout layout = GetMapLayout(map_id);
-      grid_width_ = layout.width;
-      grid_height_ = layout.height;
-      origin_x_ = layout.origin_x;
-      origin_y_ = layout.origin_y;
+        scene_manager_ = scene_manager;
+        // The node is kept when a map is replaced.
+        if (world_map_node_ == nullptr){
+            world_map_node_ = scene_manager_->getRootSceneNode()
+              ->createChildSceneNode("WorldMapTerrain");
+        }
+        world_map_node_->setVisible(true);
+        const MapLayout layout = GetMapLayout(map_id);
+        grid_width_ = layout.width;
+        grid_height_ = layout.height;
+        origin_x_ = layout.origin_x;
+        origin_y_ = layout.origin_y;
         std::vector<VGears::WorldmapFileSerializer::Block> blocks
           = LoadWorldMap("WM" + std::to_string(WORLD_MAP_FILE_NUMBERS[map_id]) + ".MAP");
         if (GetTextureIdOffset(map_id) != 0){
-          for (auto& block : blocks) for (auto& mesh : block.meshes) for (auto& triangle : mesh.triangles){
-            triangle.TextureInfo += GetTextureIdOffset(map_id);
-          }
+            for (auto& block : blocks) for (auto& mesh : block.meshes) for (auto& triangle : mesh.triangles){
+                triangle.TextureInfo += GetTextureIdOffset(map_id);
+            }
         }
         const size_t texture_count = WORLD_MAP_TEXTURE_COUNT;
         // WM0 has extra blocks after the 9x7 grid: the alternate shapes of the story progress.

+ 3 - 3
src/modules/worldmap/WorldmapTextures.cpp

@@ -40,9 +40,9 @@ namespace VGears {
 
     struct ImageDataDeleter{
 
-      void operator()(Ogre::ImageCodec::ImageData* image_data) const{
-        OGRE_DELETE image_data;
-      }
+        void operator()(Ogre::ImageCodec::ImageData* image_data) const{
+            OGRE_DELETE image_data;
+        }
     };
 
     TexturePtr LoadWorldMapTexture(const std::string& name){

+ 6 - 6
src/modules/worldmap/WorldmapTriggers.cpp

@@ -81,7 +81,7 @@ namespace VGears {
         );
     }
 
-      Ogre::String WorldmapModule::GetTerrainTypeUnderEntity(const char* entity_name) const{
+    Ogre::String WorldmapModule::GetTerrainTypeUnderEntity(const char* entity_name) const{
         if (entity_name == nullptr) return "";
         const ::Entity* entity = EntityManager::getSingleton().GetEntity(entity_name);
         if (entity == nullptr) return "";
@@ -89,12 +89,12 @@ namespace VGears {
         Ogre::Vector3 surface;
         uint8 walkability_type = 0;
         if (!FindWalkableSurface(entity->GetPosition(), surface, false, false, &walkability_type)){
-          return "";
+            return "";
         }
         return GetWorldMapTerrainName(walkability_type);
-      }
+    }
 
-      int WorldmapModule::GetTerrainTriangleUnderEntity(const char* entity_name) const{
+    int WorldmapModule::GetTerrainTriangleUnderEntity(const char* entity_name) const{
         if (entity_name == nullptr) return -1;
         const ::Entity* entity = EntityManager::getSingleton().GetEntity(entity_name);
         if (entity == nullptr) return -1;
@@ -102,9 +102,9 @@ namespace VGears {
         Ogre::Vector3 surface;
         size_t triangle_index = 0;
         if (!FindWalkableSurface(entity->GetPosition(), surface, false, false, nullptr, &triangle_index)){
-          return -1;
+            return -1;
         }
         return static_cast<int>(triangle_index);
-      }
+    }
 
 } // namespace VGears

+ 50 - 50
src/modules/worldmap/WorldmapVehicles.cpp

@@ -203,7 +203,7 @@ namespace VGears {
         }
     }
 
-      bool WorldmapModule::UnboardVehicle(const char* vehicle_name){
+    bool WorldmapModule::UnboardVehicle(const char* vehicle_name){
         if (vehicle_name == nullptr) return false;
 
         EntityManager& entity_manager = EntityManager::getSingleton();
@@ -213,7 +213,7 @@ namespace VGears {
           player_entity == nullptr || vehicle_entity == nullptr
           || player_entity != vehicle_entity || player_entity == player_entity_
         ){
-          return false;
+            return false;
         }
 
         const Ogre::Vector3 vehicle_position = vehicle_entity->GetPosition();
@@ -221,60 +221,60 @@ namespace VGears {
           = vehicle_entity->GetSolidRadius() + player_entity_->GetSolidRadius() + 0.1f;
         const Ogre::Real diagonal_distance = unboard_distance * 0.70710678f;
         const Ogre::Vector3 directions[] = {
-          Ogre::Vector3(1, 0, 0), Ogre::Vector3(-1, 0, 0),
-          Ogre::Vector3(0, 0, 1), Ogre::Vector3(0, 0, -1),
-          Ogre::Vector3(1, 0, 1), Ogre::Vector3(-1, 0, 1),
-          Ogre::Vector3(1, 0, -1), Ogre::Vector3(-1, 0, -1)
+            Ogre::Vector3(1, 0, 0), Ogre::Vector3(-1, 0, 0),
+            Ogre::Vector3(0, 0, 1), Ogre::Vector3(0, 0, -1),
+            Ogre::Vector3(1, 0, 1), Ogre::Vector3(-1, 0, 1),
+            Ogre::Vector3(1, 0, -1), Ogre::Vector3(-1, 0, -1)
         };
 
         for (size_t i = 0; i < sizeof(directions) / sizeof(directions[0]); ++i){
-          const Ogre::Real distance = i < 4 ? unboard_distance : diagonal_distance;
-          const Ogre::Vector3 requested_position
-            = vehicle_position + directions[i] * distance;
-          Ogre::Vector3 surface;
-          uint8 walkability_type = 0;
-          if (!FindWalkableSurface(
-              requested_position, surface, false, false, &walkability_type
-            ) || !IsFootWalkable(walkability_type)){
-            continue;
-          }
-          surface.y += player_height_offset_;
-          if (entity_manager.IsWorldPositionBlocked(player_entity_, surface)) continue;
+            const Ogre::Real distance = i < 4 ? unboard_distance : diagonal_distance;
+            const Ogre::Vector3 requested_position
+              = vehicle_position + directions[i] * distance;
+            Ogre::Vector3 surface;
+            uint8 walkability_type = 0;
+            if (!FindWalkableSurface(
+                requested_position, surface, false, false, &walkability_type
+              ) || !IsFootWalkable(walkability_type)){
+                continue;
+            }
+            surface.y += player_height_offset_;
+            if (entity_manager.IsWorldPositionBlocked(player_entity_, surface)) continue;
 
-          if (vehicle_entity == highwind_entity_){
-            // The Highwind lands. It can't be left higher up, Cloud couldn't board it again.
-            Ogre::Vector3 ground;
-            if (!FindWalkableSurface(vehicle_position, ground, false, false)) return false;
-            if (vehicle_position.y - ground.y > HIGHWIND_MAX_LANDING_HEIGHT) return false;
-            vehicle_entity->SetPosition(Ogre::Vector3(vehicle_position.x, ground.y, vehicle_position.z));
-            // Landing on the terrain of the northern cave enters it (the function of the triangle runs).
-            uint8 landing_terrain = 0;
-            size_t landing_triangle = 0;
-            if (FindWalkableSurface(vehicle_position, ground, false, false, &landing_terrain, &landing_triangle)
-              && landing_terrain == VGears::WorldmapFileSerializer::NORTHERND_CAVE
-              && terrain_.GetTriangles()[landing_triangle].function_id >= 3){
-              landing_after_unboard_ = &terrain_.GetTriangles()[landing_triangle];
+            if (vehicle_entity == highwind_entity_){
+                // The Highwind lands. It can't be left higher up, Cloud couldn't board it again.
+                Ogre::Vector3 ground;
+                if (!FindWalkableSurface(vehicle_position, ground, false, false)) return false;
+                if (vehicle_position.y - ground.y > HIGHWIND_MAX_LANDING_HEIGHT) return false;
+                vehicle_entity->SetPosition(Ogre::Vector3(vehicle_position.x, ground.y, vehicle_position.z));
+                // Landing on the terrain of the northern cave enters it (the function of the triangle runs).
+                uint8 landing_terrain = 0;
+                size_t landing_triangle = 0;
+                if (FindWalkableSurface(vehicle_position, ground, false, false, &landing_terrain, &landing_triangle)
+                  && landing_terrain == VGears::WorldmapFileSerializer::NORTHERND_CAVE
+                  && terrain_.GetTriangles()[landing_triangle].function_id >= 3){
+                    landing_after_unboard_ = &terrain_.GetTriangles()[landing_triangle];
+                }
             }
-          }
-          player_entity_->SetPosition(surface);
-          // The boarding scripts hide Cloud and make him non-solid.
-          player_entity_->SetVisible(true);
-          player_entity_->SetSolid(true);
-          vehicle_entity->SetTalkable(true);
-          entity_manager.ScriptSetPlayerEntity("WorldMapCloud");
-          ClearVehicleTerrains();
-          if (landing_after_unboard_ != nullptr){
-            // The Highwind is what entered (the vehicle of the trigger).
-            current_vehicle_ = VehicleType::HIGHWIND;
-            landing_trigger_ = true;
-            TriggerTriangleFunction(*landing_after_unboard_);
-            landing_trigger_ = false;
-            landing_after_unboard_ = nullptr;
-          }
-          current_vehicle_ = VehicleType::ON_FOOT;
-          return true;
+            player_entity_->SetPosition(surface);
+            // The boarding scripts hide Cloud and make him non-solid.
+            player_entity_->SetVisible(true);
+            player_entity_->SetSolid(true);
+            vehicle_entity->SetTalkable(true);
+            entity_manager.ScriptSetPlayerEntity("WorldMapCloud");
+            ClearVehicleTerrains();
+            if (landing_after_unboard_ != nullptr){
+                // The Highwind is what entered (the vehicle of the trigger).
+                current_vehicle_ = VehicleType::HIGHWIND;
+                landing_trigger_ = true;
+                TriggerTriangleFunction(*landing_after_unboard_);
+                landing_trigger_ = false;
+                landing_after_unboard_ = nullptr;
+            }
+            current_vehicle_ = VehicleType::ON_FOOT;
+            return true;
         }
         return false;
-      }
+    }
 
 } // namespace VGears