Skip to content

Allow configuration of unit view distance#41

Open
Philiquaz wants to merge 16 commits into
maxpetul:masterfrom
Philiquaz:viewdistance
Open

Allow configuration of unit view distance#41
Philiquaz wants to merge 16 commits into
maxpetul:masterfrom
Philiquaz:viewdistance

Conversation

@Philiquaz

@Philiquaz Philiquaz commented May 22, 2026

Copy link
Copy Markdown
Contributor

Adds configuration of unit visibility ranges.
Adds configuration of terrain visibility behaviours.
Supports fortification bonuses, euclidean radii, the sea being flat, and all the bells and whistles.
The default configuration should match vanilla, but on a basis of caution everything is toggled under 1 flag. There is also a performance reason for this, as at a high visibility with hundreds of units around this can become a taxing system.
Resolves #25

This was tested on the Steam version of the game.
Exe offsets should be correct for GoG as there is where most RE took place, but a test should be performed.

OFFSETS FOR PCG.DE ARE UNCHECKED, AS IS THE GAME.
UPDATE BEFORE MERGE.

@Philiquaz Philiquaz marked this pull request as ready for review June 5, 2026 13:07
@Philiquaz

Copy link
Copy Markdown
Contributor Author

Being clearer on my commenting, someone with the ready ability to check that game version would be helpful. The patches are all in locations calling can_see_tile and the update_visibility function

@maxpetul maxpetul left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for taking so long to have a look at this but I've just been busy with so many other things. It's good work. I was worried that this feature would be gnarly but this is a nice clean implementation. The changes I've requested are just small things. Also I've fixed the PCGames.de addresses and verified that it works on that EXE.

Comment thread injected_code.c Outdated
Comment thread injected_code.c Outdated
Comment thread default.c3x_config.ini Outdated
Comment thread default.c3x_config.ini Outdated
Comment thread C3X.h
@Philiquaz

Copy link
Copy Markdown
Contributor Author

No worries on the wait, there's a lot of stuff and I can fully understand taking time for a hobby.
Will get to the fixes soon(ish)
Thanks for patching up the pcgames.de addresses, it's not easy for me to work with that one :)

@maxpetul

maxpetul commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Looks good except for two things. First, with the default rule "Sea": 2 when-fortified-same-continent, in my testing I see that giving fortified sea units four tiles of visibility over water, not three like under the standard rules. You said you tested it and settled on an unintuitive value, but can you test again? It makes sense that it would be four as: 1 base vis + 2 fortified same continent + 1 flat bonus over water.

Second, when I mentioned dropping "UTC_" from the Land/Sea/Air keywords in the config, I also had in mind that you would make it so that the keywords only applied if they were not in quotes. I.e., Sea in the config should refer to all sea units but "Sea" should refer to only the unit type(s) named Sea. So there should not be quotes in the default rule. It's probably unlikely that anyone will have unit types named Land, Sea, or Air, but we should leave open the possibility.

@Philiquaz

Copy link
Copy Markdown
Contributor Author

Okay, found the energy to actually look at the fortification code. Yes, it was unintentionally stacking with the flat bonus because the total sight distance was being recalculated, which I don't consider to be intentional. I've patched that and the config naming.

I would say the config of 2 is, although initially untuitive, correct. The mechanic works regardless of terrain or sightlines just like radar, so re-including terrain in its calculation is wrong. Relying on the flat bonus would incorrectly mean a tile at distance 3 obscured by land would not be seen when it should be.

Arguably if I spent more time I could configure fortification options to have more customizable stacking behaviour. Though then we're also looking at land height bonuses which is a realm the vanilla game doesn't touch.

@maxpetul

maxpetul commented Jul 9, 2026

Copy link
Copy Markdown
Owner

The mechanic works regardless of terrain or sightlines just like radar, so re-including terrain in its calculation is wrong. Relying on the flat bonus would incorrectly mean a tile at distance 3 obscured by land would not be seen when it should be.

Alright, that makes sense.

I'd consider this PR finished and ready to merge at this point. There's just one very minor issue left which I was reminded of looking at your changes to the config: the grammar mistakes in "base visibility can be give... bonus visibility can be give", but I can fix that no problem. I'll merge this after PR #31 which should be very soon.

@Philiquaz

Copy link
Copy Markdown
Contributor Author

Bruh
Yes, intended to be "can be given" as in the 3rd clause.
Cheers for your work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration of terrain visibility

2 participants