Sight caculations

Inightshade

Chieftain
Joined
Sep 29, 2014
Messages
33
Location
Renis
So somewhere Civ calculates what you (the active player) can visibly see.

However, I do not seem to be able to find it. I've prowled a lot of the source (most through search's for 'Visible' and 'Reveal' as these are tied) but have either glanced over it or are searching for the wrong thing/wrong place.

I've also looked a little at the games (non source) lua, but most of this is UI and Map scripts, and haven't turned up the stone I'm searching for.

I'ma keep looking, but if someone knows it'd help cut out at least the mass of time that seems to be required!

--Note: I'm searching for this to discern how city sight is calculated and see if it's reasonable to increase the city sight as a trait. (presumably by adding to the traits table, though if it's in the lua this would be much easier. Here's to hoping.)

--pss: I've found a section of the source that is lCanSeePlot, and it contains a eFacingDirection, I don't think I've ever noticed something that would use this...
 
Sight range for a city for ranged combat is set by XML IIRC (default 2) or for revealed tiles it's every tile owned by a city plus those immediately adjacent.

Sight range for units is based around CvUnit::visibilityRange(), modified by terrain/feature/plot they are on and/or can see.

Recon range for aircraft is defined in XML (default is 6 tiles around the starting tile of the unit)
 
for revealed tiles it's every tile owned by a city plus those immediately adjacent.

There we go, I thought it might be something like that, rather than functioning like units. That could very well make this overly difficult. Do you know if it's in CvCity or CvPlot? This would verify that it's in the DLL, so I'll crank back on MsVisual and hunt back through. hmm...

Thanks!
 
See CvPlot::setOwner, specifically the lines calling changeAdjacentSight()
 
Alright, so let me start with a HUGE thanks whoward, as that bit helped me hunt everything down!!!

So: Anyone looking for answers!
changeAdjacentSight is called to determine sight for a few things (cities, allies, spies...) So you want to modify the int that it imports when called, both setOwner and updateSight call changeAdjSight to do this for several reasons, the usual variable inserted is a Global hard code of 1(separate, but same # for spies and the default), if you want to do this globally you can just make a define, but if you want to do this via trait you'll have to place parts in all of these (CvPlot.cpp, CvPlayer.h & .cpp, CvTraitClasses.h & .cpp) along with learning how they all interact on the way (which ends up requiring CvPlot.h and CvPlayerAi.h).
Ug, I know how great object oriented programming is, but sometimes the shear convolution makes me wonder about mine (and other programmers) sanity.

Whoward, as I have zero actual c++ knowledge (just java and greenfoot) I cannot for the life of me figure out what's wrong with log printing. I can print when inside a function but not -anywhere- outside. most .h's have masses of things like:
Spoiler :

int GetCityStateCombatModifier() const;
int GetLandBarbarianConversionPercent() const;
int GetLandBarbarianConversionExtraUnits() const;
int GetSeaBarbarianConversionPercent() const;
int GetCapitalBuildingModifier() const;
int GetPlotBuyCostModifier() const;
int GetPlotCultureCostModifier() const;
int GetCultureFromKills() const;
int GetFaithFromKills() const;
#if defined(JFCM_CITY_SIGHT)
int GetCitySight() const;
#endif
int GetCityCultureBonus() const;
int GetCapitalThemingBonusModifier() const;
int GetPolicyCostModifier() const;
int GetCityConnectionTradeRouteChange() const;

But If I place a JFCM_LOG("Whatever") here it throws errors in the compiler (with or w/o ;'s).
Also, I can't seem to get variables to print out at all. -shrugs- Would make a diff only in cutting down debug time a little. Nothing else.
-- I'm going to regret not properly organizing my code at some point (I SHOULD place everything at the dead end of related sections, but I'm too lazy to move things now...)

Another note is that your macro's build up a ton of errors, maybe if I knew more about C++ and could have confidence that the error is :just: that the precompiler hasnt been run vs me being -derpy- like I was when trying to import straight from CvTrait (lols, yea; not from CvPlot, not at all...).
 
Back
Top Bottom