whoward69
DLL Minion
Anyone who's ever tried directly manipulating the visibility of a tile via Lua knows it's broken - in that once a plot is visible to a team you can never hide it again.
The bug is in the CvLuaPlot.cpp file
One simple change and tiles can be made invisible again!
Fortunately the lua method is only used by the debug code (in InGame.lua) and the LiveTuner Map panel, so the change won't affect anything in the core game - but it could break mods
Code:
> pPlot:GetVisibilityCount()
2
> pPlot:ChangeVisibilityCount(0, 10); pPlot:GetVisibilityCount()
3
> pPlot:ChangeVisibilityCount(0, -1); pPlot:GetVisibilityCount()
4
> pPlot:ChangeVisibilityCount(0, 0); pPlot:GetVisibilityCount()
5
> pPlot:ChangeVisibilityCount(0); pPlot:GetVisibilityCount()
5
> pPlot:ChangeVisibilityCount(0, false); pPlot:GetVisibilityCount()
5
> pPlot:ChangeVisibilityCount(0, true); pPlot:GetVisibilityCount()
6
The bug is in the CvLuaPlot.cpp file
Code:
//void changeVisibilityCount(TeamTypes eTeam, int iChange, InvisibleTypes eSeeInvisibleType = false, bool bInformExplorationTracking = false, bool bAlwaysSeeInvisible = false);
int CvLuaPlot::lChangeVisibilityCount(lua_State* L)
{
CvPlot* pkPlot = GetInstance(L);
const TeamTypes eTeam = (TeamTypes)lua_tointeger(L, 2);
const int iChange = [B][COLOR="Red"]lua_toboolean[/COLOR][/B](L, 3); // This is a bug, it should be lua_tointeger
const int eSeeInvisible = lua_tointeger(L, 4);
const bool bInformExplorationTracking = lua_toboolean(L, 5);
const bool bAlwaysSeeInvisible = lua_toboolean(L, 6);
pkPlot->changeVisibilityCount(eTeam, iChange, static_cast<InvisibleTypes>(eSeeInvisible), bInformExplorationTracking, bAlwaysSeeInvisible);
return 0;
}
One simple change and tiles can be made invisible again!
Code:
> pPlot:GetVisibilityCount()
0
> pPlot:ChangeVisibilityCount(0, 1); pPlot:GetVisibilityCount()
1
> pPlot:ChangeVisibilityCount(0, -1); pPlot:GetVisibilityCount()
0
> pPlot:ChangeVisibilityCount(0, true); pPlot:GetVisibilityCount()
0
> pPlot:ChangeVisibilityCount(0, false); pPlot:GetVisibilityCount()
0
Fortunately the lua method is only used by the debug code (in InGame.lua) and the LiveTuner Map panel, so the change won't affect anything in the core game - but it could break mods