Index: binaries/data/mods/public/maps/random/rmgen/library.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/library.js +++ binaries/data/mods/public/maps/random/rmgen/library.js @@ -21,11 +21,6 @@ const SEA_LEVEL = 20.0; const HEIGHT_UNITS_PER_METRE = 92; -/** - * Number of impassable, unexplorable tiles at the map border. - */ -const MAP_BORDER_WIDTH = 3; - const g_DamageTypes = new DamageTypes(); /** Index: source/graphics/LOSTexture.cpp =================================================================== --- source/graphics/LOSTexture.cpp +++ source/graphics/LOSTexture.cpp @@ -49,6 +49,7 @@ // Blur with a NxN filter, where N = g_BlurSize must be an odd number. +// Keep it in relation to the number of impassable tiles in RangeManager::EdgeSize. static const size_t g_BlurSize = 7; // Alignment (in bytes) of the pixel data passed into glTexSubImage2D. Index: source/graphics/MapGenerator.cpp =================================================================== --- source/graphics/MapGenerator.cpp +++ source/graphics/MapGenerator.cpp @@ -34,6 +34,7 @@ #include "scriptinterface/ScriptRuntime.h" #include "scriptinterface/ScriptConversions.h" #include "scriptinterface/ScriptInterface.h" +#include "simulation2/components/ICmpRangeManager.h" #include #include @@ -142,6 +143,7 @@ m_ScriptInterface->RegisterFunction, std::string, bool, CMapGeneratorWorker::FindTemplates>("FindTemplates"); m_ScriptInterface->RegisterFunction, std::string, bool, CMapGeneratorWorker::FindActorTemplates>("FindActorTemplates"); m_ScriptInterface->RegisterFunction("GetTerrainTileSize"); + m_ScriptInterface->SetGlobal("MAP_BORDER_WIDTH", ICmpRangeManager::EdgeTiles); // Globalscripts may use VFS script functions m_ScriptInterface->LoadGlobalScripts(); Index: source/simulation2/components/CCmpPathfinder.cpp =================================================================== --- source/simulation2/components/CCmpPathfinder.cpp +++ source/simulation2/components/CCmpPathfinder.cpp @@ -32,6 +32,7 @@ #include "simulation2/MessageTypes.h" #include "simulation2/components/ICmpObstruction.h" #include "simulation2/components/ICmpObstructionManager.h" +#include "simulation2/components/ICmpRangeManager.h" #include "simulation2/components/ICmpTerrain.h" #include "simulation2/components/ICmpWaterManager.h" #include "simulation2/helpers/HierarchicalPathfinder.h" @@ -637,8 +638,7 @@ } // Compute off-world passability - // WARNING: CCmpRangeManager::LosIsOffWorld needs to be kept in sync with this - const int edgeSize = 3 * Pathfinding::NAVCELLS_PER_TILE; // number of tiles around the edge that will be off-world + const int edgeSize = ICmpRangeManager::EdgeTiles * Pathfinding::NAVCELLS_PER_TILE; NavcellData edgeMask = 0; for (PathfinderPassability& passability : m_PassClasses) Index: source/simulation2/components/CCmpRangeManager.cpp =================================================================== --- source/simulation2/components/CCmpRangeManager.cpp +++ source/simulation2/components/CCmpRangeManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -2020,9 +2020,6 @@ */ inline bool LosIsOffWorld(ssize_t i, ssize_t j) const { - // WARNING: CCmpPathfinder::UpdateGrid needs to be kept in sync with this - const ssize_t edgeSize = 3; // number of vertexes around the edge that will be off-world - if (m_LosCircular) { // With a circular map, vertex is off-world if hypot(i - size/2, j - size/2) >= size/2: @@ -2030,7 +2027,7 @@ ssize_t dist2 = (i - m_TerrainVerticesPerSide/2)*(i - m_TerrainVerticesPerSide/2) + (j - m_TerrainVerticesPerSide/2)*(j - m_TerrainVerticesPerSide/2); - ssize_t r = m_TerrainVerticesPerSide/2 - edgeSize + 1; + ssize_t r = m_TerrainVerticesPerSide / 2 - EdgeTiles + 1; // subtract a bit from the radius to ensure nice // SoD blurring around the edges of the map @@ -2040,8 +2037,9 @@ { // With a square map, the outermost edge of the map should be off-world, // so the SoD texture blends out nicely - - return (i < edgeSize || j < edgeSize || i >= m_TerrainVerticesPerSide-edgeSize || j >= m_TerrainVerticesPerSide-edgeSize); + return i < EdgeTiles || j < EdgeTiles || + i >= m_TerrainVerticesPerSide - EdgeTiles || + j >= m_TerrainVerticesPerSide - EdgeTiles; } } @@ -2439,3 +2437,6 @@ }; REGISTER_COMPONENT_TYPE(RangeManager) + +#undef LOS_TILES_RATIO +#undef DEBUG_RANGE_MANAGER_BOUNDS Index: source/simulation2/components/ICmpRangeManager.h =================================================================== --- source/simulation2/components/ICmpRangeManager.h +++ source/simulation2/components/ICmpRangeManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -69,6 +69,13 @@ class ICmpRangeManager : public IComponent { public: + + /** + * Number of impassable, unexplorable tiles at the map border. + * Keep it in relation to the shadow blur size in CLOSTexture. + */ + static const u8 EdgeTiles; + /** * External identifiers for active queries. */ Index: source/simulation2/components/ICmpRangeManager.cpp =================================================================== --- source/simulation2/components/ICmpRangeManager.cpp +++ source/simulation2/components/ICmpRangeManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -21,6 +21,11 @@ #include "simulation2/system/InterfaceScripted.h" +/** + * Number of impassable, unexplorable tiles at the map border. + */ +const u8 ICmpRangeManager::EdgeTiles = 3; + std::string ICmpRangeManager::GetLosVisibility_wrapper(entity_id_t ent, int player) const { ELosVisibility visibility = GetLosVisibility(ent, player);