Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/library.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/library.js +++ ps/trunk/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: ps/trunk/source/graphics/LOSTexture.cpp =================================================================== --- ps/trunk/source/graphics/LOSTexture.cpp +++ ps/trunk/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 MAP_EDGE_TILES. static const size_t g_BlurSize = 7; // Alignment (in bytes) of the pixel data passed into glTexSubImage2D. Index: ps/trunk/source/graphics/MapGenerator.cpp =================================================================== --- ps/trunk/source/graphics/MapGenerator.cpp +++ ps/trunk/source/graphics/MapGenerator.cpp @@ -34,6 +34,7 @@ #include "scriptinterface/ScriptRuntime.h" #include "scriptinterface/ScriptConversions.h" #include "scriptinterface/ScriptInterface.h" +#include "simulation2/helpers/MapEdgeTiles.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", static_cast(MAP_EDGE_TILES)); // Globalscripts may use VFS script functions m_ScriptInterface->LoadGlobalScripts(); Index: ps/trunk/source/simulation2/components/CCmpPathfinder.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpPathfinder.cpp +++ ps/trunk/source/simulation2/components/CCmpPathfinder.cpp @@ -36,6 +36,7 @@ #include "simulation2/components/ICmpWaterManager.h" #include "simulation2/helpers/HierarchicalPathfinder.h" #include "simulation2/helpers/LongPathfinder.h" +#include "simulation2/helpers/MapEdgeTiles.h" #include "simulation2/helpers/Rasterize.h" #include "simulation2/helpers/VertexPathfinder.h" #include "simulation2/serialization/SerializeTemplates.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 = MAP_EDGE_TILES * Pathfinding::NAVCELLS_PER_TILE; NavcellData edgeMask = 0; for (PathfinderPassability& passability : m_PassClasses) Index: ps/trunk/source/simulation2/components/CCmpRangeManager.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpRangeManager.cpp +++ ps/trunk/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 @@ -32,6 +32,7 @@ #include "simulation2/components/ICmpVisibility.h" #include "simulation2/components/ICmpVision.h" #include "simulation2/components/ICmpWaterManager.h" +#include "simulation2/helpers/MapEdgeTiles.h" #include "simulation2/helpers/Render.h" #include "simulation2/helpers/Spatial.h" @@ -2020,9 +2021,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 +2028,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 - MAP_EDGE_TILES + 1; // subtract a bit from the radius to ensure nice // SoD blurring around the edges of the map @@ -2040,8 +2038,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 < MAP_EDGE_TILES || j < MAP_EDGE_TILES || + i >= m_TerrainVerticesPerSide - MAP_EDGE_TILES || + j >= m_TerrainVerticesPerSide - MAP_EDGE_TILES; } } @@ -2439,3 +2438,6 @@ }; REGISTER_COMPONENT_TYPE(RangeManager) + +#undef LOS_TILES_RATIO +#undef DEBUG_RANGE_MANAGER_BOUNDS Index: ps/trunk/source/simulation2/helpers/MapEdgeTiles.h =================================================================== --- ps/trunk/source/simulation2/helpers/MapEdgeTiles.h +++ ps/trunk/source/simulation2/helpers/MapEdgeTiles.h @@ -0,0 +1,27 @@ +/* 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 + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * 0 A.D. 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 0 A.D. If not, see . + */ + +#ifndef INCLUDED_MAP_EDGE_TILES +#define INCLUDED_MAP_EDGE_TILES + +/** + * Number of impassable, unexplorable tiles at the map border. + * Keep it in relation to the shadow blur size in CLOSTexture. + */ +static const ssize_t MAP_EDGE_TILES = 3; + +#endif // INCLUDED_MAP_EDGE_TILES