Ticket #1574: shallowsOnMinimap.patch

File shallowsOnMinimap.patch, 1.9 KB (added by wraitii, 12 years ago)
  • source/gui/MiniMap.h

     
    7777
    7878    // 1.f if map is circular or 1.414f if square (to shrink it inside the circle)
    7979    float m_MapScale;
     80   
     81    // maximal water height to allow the passage of a unit (for underwater shallows).
     82    float m_ShallowPassageHeight;
    8083
    8184    void DrawTexture(float coordMax, float angle, float x, float y, float x2, float y2, float z);
    8285
  • source/gui/MiniMap.cpp

     
    4141#include "simulation2/Simulation2.h"
    4242#include "simulation2/components/ICmpMinimap.h"
    4343#include "simulation2/components/ICmpTerritoryManager.h"
     44#include "simulation2/components/ICmpTerritoryManager.h"
     45#include "simulation2/system/ParamNode.h"
    4446
    4547bool g_GameRestarted = false;
    4648
     
    6062    AddSetting(GUIST_CStr,      "tooltip_style");
    6163    m_Clicking = false;
    6264    m_MouseHovering = false;
     65   
     66    // Get the maximum height for unit passage in water.
     67    CParamNode externalParamNode;
     68    CParamNode::LoadXML(externalParamNode, L"simulation/data/pathfinder.xml");
     69    const CParamNode pathingSettings = externalParamNode.GetChild("Pathfinder").GetChild("PassabilityClasses");
     70    m_ShallowPassageHeight = pathingSettings.GetChild("default").GetChild("MaxWaterDepth").ToFloat();
    6371}
    6472
    6573CMiniMap::~CMiniMap()
     
    498506                    + m_Terrain->GetVertexGroundLevel((int)i+1, (int)j+1)
    499507                ) / 4.0f;
    500508
    501             if(avgHeight < waterHeight)
     509            if(avgHeight < waterHeight && avgHeight > waterHeight - m_ShallowPassageHeight)
    502510            {
     511                // shallow water
     512                *dataPtr++ = 0xff7098c0;
     513            } else if (avgHeight < waterHeight)
     514            {
    503515                // Set water as constant color for consistency on different maps
    504516                *dataPtr++ = 0xff5078a0;
    505517            }