We-the-People-civ4col-mod / Mod

This is the repository where the mod resides.
90 stars 37 forks source link

Roads, country roads and the railroad-type road disappear randomly when outside the cities radii #47

Closed ShadesOT closed 3 years ago

abmpicoli commented 6 years ago

You mean only visually, right?

ShadesOT commented 6 years ago

no, they disappear fully. pioneers build a road. the next turn the road is gone. and movement is like the road was not built. units can get stuck in large swats of mountains.

ShadesOT commented 6 years ago

do you know of a bug where roads disappear only visually?

abmpicoli commented 6 years ago

Yep, I don't even pay attention anymore... when I hover over the tile, it mentions that there is a road, but I just don't see it... It is something so old I haven't even bothered to mention.

abmpicoli commented 6 years ago

Some models for resources are so tiny they get hidden under the jungle/forest . sometimes they "hide" under the mountains...

abmpicoli commented 6 years ago

Well, regarding the specific bug of roads disappearing... Well, we will certainly need a save... Maybe this is correlated to jungle/forest growth routines?

abmpicoli commented 6 years ago

Also there is the "forest fire" event that can destroy improvements... Just wondering if one of these events destroyed the road...

abmpicoli commented 6 years ago

This bug is very annoying, I'm considering it 2.7.1

ShadesOT commented 6 years ago

save AD-1700-July.zip The attached save shows the issue. Explanation The natives to the north are my brothers and sisters. I want them to be powerful and productive. Pioneers have been sent to enhance their land plots and build a road network. But because the roads keep disappearing I built 3 small villages (rm1, rm2, rm3), just to have all roads within a 2 plot city radius.

Steps to reproduce the issue

Expected behavior

Observed behavior

I guess more roads will disappear.

abmpicoli commented 6 years ago

Oh, so the issue is only when you build the roads around the indians? Maybe they are the ones removing them? (pillaging)?

devolution79 commented 6 years ago

Here are some ideas regarding debugging:

Put a breakpoint in CvUnit::pillage and see if the route or improvement is removed by pillaging. If that's the case, get the x and y coordinate from the debugger and check against the tile coordinates (visible in cheat mode).

ShadesOT commented 6 years ago

I believe I have seen roads disappear, also if no natives were anywhere near it. In the attached save there are no native units on the mentioned plots. And I think pillaging would end the units turn. So there should be a unit on the plot if the road was pillaged. Additionally I formed a lasting alliance with the native nation in question.

So I believe, unless the code is very buggy, native units are not the cause of the disappearing roads.

devolution79 commented 6 years ago

That is most peculiar! I admit that I didn't load the save (don't have access to the game atm)

Here's another idea, put a break in all calls to setRouteType(NO_ROUTE) and then determine the context of the caller(s).

It's possible that this is a yield cache bug, so have a look at what's happening inside CvPlot::setRouteType as well

devolution79 commented 6 years ago

I've been inspecting what's going on in the debugger and the natives are clearly pillaging the roads. I guess they're anti-progress or something 😆

devolution79 commented 6 years ago

The callstack pasting ability of VS clearly sucks compared to Eclipse, so this is all the context that I was able to easily get out of it:

CvGameCoreDLL.dll!CvUnit::pillage() Line 6136   C++
CvGameCoreDLL.dll!CvUnitAI::AI_pillageRange(int iRange, bool bSafe) Line 14232  C++
CvGameCoreDLL.dll!CvUnitAI::AI_counterBraveMove() Line 3666 C++
CvGameCoreDLL.dll!CvUnitAI::AI_update() Line 287    C++
CvGameCoreDLL.dll!CvPlayerAI::AI_unitUpdate() Line 994  C++
CvGameCoreDLL.dll!CvGame::updateMoves() Line 5884   C++
CvGameCoreDLL.dll!CvGame::update() Line 1454    C++

I forgot to say, that this is a feature and not a bug

Nightinggale commented 6 years ago

This opens up for a new question: why are they pillaging the roads? It didn't happen in 2.5. It kills the strategy of building roads to settlements for faster training of the units you need.

devolution79 commented 6 years ago

Sorry, I closed this ticket accidentally.

This opens up for a new question: why are they pillaging the roads? It didn't happen in 2.5. It kills the strategy of building roads to settlements for faster training of the units you need.

This behaviour has been in the game since before my time (2.6). I don't have easy access to older versions of RaR to compare with, but I don't think this code has been changed since perhaps TAC ?

I guess that pillaging roads in neutral territory is fair game for the indians.

Nightinggale commented 6 years ago

I'm not sure I like this change, at least not in general. I suspect pillaging routes was added to natives with xml at some point, but I can't find the precise time for it.

Either natives will be banned from pillaging routes or we make the AI more clever about it. We could assign an owner to routes (int in CvPlot telling the player who last built a route on the plot) and then the native can check relationship with that player when deciding if it wants to remove the route. Right now there is no memory of who built it, meaning the AI has no idea who it goes against. You can have a perfect relationship and they still pillage at random.

Also the alert about being pillaged should trigger for the player owning the plot and the owner of the route if the owners differs. Your routes shouldn't vanish without adding an event entry telling the player what happened.

ShadesOT commented 6 years ago

Nice that you nailed that down devolution. There are several things that itch me with that finding:

1) Can you verify that there is no native unit on the plot, where the road disappeared? How did the AI do it? Cheat? Is AI_pillageRange an indicator for the ability to "remotely" pillage? ... That would explain why I have seen roads disappear with no natives around.

2) Maybe the natives dont like roads, so they pillage them. Fair enough. Let's assume it is a valid/intended game mechanic. But then ...

raystuttgart commented 4 years ago

This is known and it is not a really bug. It is actually coded that way (already in vanilla) and does also make sense generally because they don't like Europeans just building roads in their environment.

Natives will destroy / pillage roads sometimes that they walk over if they are in neutral territory or in territory of an enemy. (I am currently not sure if there is some other condition like the "Threat"-Feeling that they have build up due to expansion of Europeans.)

The code might however be adjusted. I just don't know if this is necessary or a good idea.

Nightinggale commented 4 years ago

We could add a "route owner" meaning the AI can check against attitude towards the player in question when it decides if it should remove a road in a non-European owned plot. This means if you are on friendly terms with the natives, you can be allowed to build a road through their land. If not, then they will remove it as soon as you build it.

Maybe a new diplo status can be used here, kind of like open borders, but it also protects the routes you build.

raystuttgart commented 4 years ago

Actually this (Natives destroying my routes) almost never happens to me when I keep them happy (e.g. with Missionaries and Trading). I do believe however that this happens a lot once they get pissed or feel threatened by expansion.

If this is true, then there would be no issue for me here to fix. That would be a mechanic that makes sense.

Then the "route owner" (probably in the Plot) and Attitude check would not really be nessary in my opinion. Because it would already more or less work that way.

If they however just randomly pillage all roads (on neutral or their own territory) then we should fix this with a solution like you suggested.

But of course the code must be checked first to know what really happens.

The Diplo-Option in Diplo-Dialog would be an oversized solution for me. Also, what should Natives demand for it? What would the player be willing to pay?

Nightinggale commented 4 years ago

I think there has been a change at some point, which makes allows natives to remove routes on unowned plots and the AI is like "I can do that, then I will do it". The best option really is to make the AI able to do so, but restrict it to only do it if the relationship to the route owner is "raids are ok" or something like that.

devolution79 commented 3 years ago

Closing, it's clear that this is not a bug and more of a discussion about changing an existing feature.