arkhometha / Historical-Project-Mod

A mod for Victoria 2 - Heart of Darkness 3.04
158 stars 52 forks source link

[BUG] rebel sieges can invalidate CBs #114

Closed moretrim closed 4 years ago

moretrim commented 4 years ago

System Information: The attached archived save was generated on 0.4.6.1 but it reproduces locally with 0.4.6.2 on my end.

Describe the bug In the save acquire_state is temporarily unavailable on overseas countries. The player country is Bavaria with bits all over the world, mostly inherited from a British dismantlement. Following shenanigans it is also mostly covered in (but not occupied by) rebels. Due to this the CB is valid for fabrication on some neighbouring countries, but not for overseas countries.

To Reproduce Load the save as Bavaria and run e.g. debug cb_use acquire_state BAV GRE. The CB requirements should show green all across the board. However acquire_state cannot be picked for fabrication against Greece. Other spurious targets include Turkey, New World countries, etc.

If the game is unpaused, the CB can made available by clearing a path of rebel-free provinces from the capital to a port.

Debugging methodology It took me a few tries to figure what's happening. I suggest using a debug decision to keep track of the number of ports:

how_many_ports = {
    potential = {}
    allow = {
        num_of_ports = 1
    }
    effect = {}
    ai_will_do = { factor = 0 }
}

Here is an example of a path I cut through the rebels from Munich to Hamburg. At this point the CB is back on the table again against overseas countries.

cut_them_down

I did not test what happens if foreign troops block the capital–port path.

Expected behaviour Honestly I may have expected occupied ports to restrict CBs, but mere sieges definitively came off as a surprise. If this is expected behaviour, then I suppose there is no bug. If you agree occupation is a better condition I can whip up a PR for this. Should it just look out for rebel control, or any loss of control?

arkhometha commented 4 years ago

Hi @moretrim, this is definitively not expected behaviour. Feel free to do a PR for this - I guess replacing it with any_owned_province = { has_building = naval_base } might fix it?

moretrim commented 4 years ago

That's right.

I did further digging and it turns out that it's much harder to fudge num_of_ports if the capital is itself coastal. This might explain why this went on so long before being discovered.

moretrim commented 4 years ago

Closed with #116.

moretrim commented 4 years ago

I do not believe the following warrants a new issue. I can't really think of a way to fix it, and I'm mostly posting it for posterity & to demonstrate how pervasive the underlying issue is.

siege_to_coast

The country of Danzig is able to connect its capital of Lemberg (don't ask) to the Baltic coast during a war with Russia, using a siege to bypass the choke point that is Krakow. This permits the queuing of e.g. battleships in those Baltic naval bases, which is otherwise not allowed in overseas provinces:

https://github.com/arkhometha/Historical-Project-Mod/blob/6819d3214d6787247ce7558fa7376fc591cadc92/HPM/units/battleship.txt#L13

The constructions persist if the connection is broken (e.g. the war ends).