Author Topic: Territories Importer issues  (Read 1345 times)

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #30 on: July 21, 2021, 10:10:12 AM »
Thanks. But I can't quite get things to look correctly. I'll try to explain more.
After using the Territories Importer and running the game, I would expect the map to look as the example in "WorldMapStrategyKit\Demos\General Examples\103 Province Expansion".
Green frontiers around each country, and a black border only around the country that's currently highlighted. And white borders for provinces using 'Show Provinces'.


Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #31 on: July 21, 2021, 10:14:15 AM »
When using the importer with these textures, and running the game (without doing the load game or using CountryTransferProvince), there is permanent
black borders between countries which shouldn't be there.

Use the Detail:Fine and Snap to country frontiers when importing.

« Last Edit: July 21, 2021, 10:19:37 AM by Pollyfun »

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #32 on: July 21, 2021, 10:36:17 AM »
UPDATE. When I did what I described in a completely new project, the first steps looks correct. It must be I have some custom code that's disturbing the highlighting/border system.

I will test more, and update more if there's still an issue. Thanks

« Last Edit: July 21, 2021, 10:37:52 AM by Pollyfun »

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #33 on: July 21, 2021, 10:36:18 PM »
I finally got time to test a bit more. The first phase works, where five countries are used (1 land and 4 sea countries).
- The frontiers are correct
- Highlighted country gets a black border inside the green frontier
- Province borders are always white

After looping through the provinces and using CountryTransferProvince() to assign them to either Ocean, Argentine or United Kingdom, the following problems occur:
- The frontiers are not updated. It's still showing the old frontiers.
- Highlighted country gets a black border that follows the frontiers, but
- Province borders are black when the country is highlighted

I'll sent a video in PM.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #34 on: July 21, 2021, 11:46:43 PM »
CountryTransferProvince has its limitations as itís intended to just reassign provinces to countries without border matching/updating.
I wonder if you get the right results using the robust CountryTransferProvinceRegion method instead (although slower since youíre calling it for many provinces).

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #35 on: July 22, 2021, 07:46:10 PM »
Try latest beta. It should now remove the original regions from the source country.

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #36 on: July 23, 2021, 12:00:37 AM »
When I use CountryTransferProvinceRegion instead of CountryTransferProvince, it takes a very long time (more than a minute),
and some frontiers and borders are better, but some frontiers are also incorrect.


Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #37 on: July 23, 2021, 12:03:29 AM »
The latest beta didn't behave differently. But I notice that new statements are never executed:

if (sourceCountry.regions.Contains(provinceRegion)) {   <--- always false
  sourceCountry.regions.Remove(provinceRegion);
  requireCountryGeometryRefresh = true;
}


Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #38 on: July 23, 2021, 12:05:27 AM »
I will create a minimal Unity project containing these texture and relevant code and zip it. Then perhaps you can more easily find a fix. I'll look at it tomorrow.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #39 on: July 23, 2021, 09:09:43 AM »
Thanks, it looks like the best way to tackle these issues.

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #40 on: July 24, 2021, 12:31:56 AM »
I've sent the project. After unzipping, the Assets\WorldMapStrategyKit folder has to be added.
Then open MapTest5\Assets\Scenes\SampleScene.unity.

Borders and frontiers intially looks correct. After clicking the "Assign provinces" button which
use CountryTransferProvince() they are off.

You can use Countries_3px.png and Provinces 3px.png above if you want to rerun Territories Importer.

Thanks for checking.

« Last Edit: July 24, 2021, 12:41:18 AM by Pollyfun »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #41 on: July 26, 2021, 09:48:27 AM »
Thank you, will take a look and get back soon.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #42 on: July 28, 2021, 12:44:12 PM »
Hi,

Using your repro I noticed something I should have warned before. When merging all the provinces that are adjacent to the world edges, you will end in a big outer polygon which is just a big quad, plus the interior border. This is not supported because regions are defined by a single polygon so it's recommended that the "ocean country" is split in at least 2 or 3 parts. Fortunately you have already split the ocean in 4 countries ("Ocean North East", "Ocean North West" and so on) so I have improved the CountryTransferCountry method to accept a new parameter called "mergeRegions" which we can use to just add up the 4 ocean countries as 4 regions of a same country and rename it. For example:

Code
_map.CountryTransferCountry(_map.GetCountryIndex("Ocean South West"), _map.GetCountryIndex("Ocean South East"), redraw: false, mergeRegions: false);
_map.CountryTransferCountry(_map.GetCountryIndex("Ocean South West"), _map.GetCountryIndex("Ocean North East"), redraw: false, mergeRegions: false);
_map.CountryTransferCountry(_map.GetCountryIndex("Ocean South West"), _map.GetCountryIndex("Ocean North West"), redraw: false, mergeRegions: false);
_map.CountryRename("Ocean South West", "Ocean");
_map.Redraw();

The code above does the following:
1) It transfer each other country to "Ocean South West". Passing "mergeRegions = false" produces that the other countries are just added as regions to the first country in the function call. Borders are not merged so the operation is fast and we don't have the limitation of having a single country that covers the entire world.
2) The resulting country is "Ocean South West" which we can rename to just "Ocean" (so you don't need to create an artifical country called Ocean in your code).

The only downside is that you can still see tiny black borders between the 4 big regions although they're not very apparent.

Please get the latest beta and try the code above. You can just replace the "AssignOwners" code in Logic.cs with this code.

Note: also it's worth noting that tranferring provinces using CountryTransferProvinceRegion should work fine when you're just transfering one or two provinces at the same time. However in terms of gameplay, the recommended way to illustrate ownership is to use colors or textures or other symbols, instead of merging regions because this is an operation that can't be reversed (in case you want players to conquer and reconquer the same provinces for example). Allowing players to conquer other provinces and using CountryTransferProvinceRegion can lead to unexpected results if the resulting geometry is too complex like in this case where all ocean provinces where surrounding the whole map.
« Last Edit: July 28, 2021, 12:50:10 PM by Kronnect »

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #43 on: July 28, 2021, 10:14:57 PM »
Ok, thanks for the update. It sounds like it should simplify the handling of ocean regions a bit. Iím away for a couple of days but Iíll try it out soon.

About  frontiers between countries. Are they saved in the geodata (and difficult to recreate/refresh)?




Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #44 on: July 28, 2021, 10:27:15 PM »
Geodata files only get modified using the MapEditor.