Page 1 of 1

Bugs with custom road types

Posted: Tue Jul 01, 2025 12:03 pm
by Hafting
I am implementing "pack ice" as an extra "road" type for sea terrain. In doing this, I have come across some bugs.
I use a "road extra" so I won't need another terrain type, and with a hex tileset I need only 7 sprites. They combine to form a great variety of icy scenes, for very little drawing effort. Also, a "road extra" allows modification of tile move cost, food and trade. And this is where I see the bugs:

1. Ice gets in the way, therefore I set -1 for food and -1 for trade. Looking at city production when working such an icy tile, I do indeed get only 1 food and one trade (1 0 1) instead of the usual (2 0 2) I get when the city has a port. I confirmed this by looking at city production, while micromanaging which tiles the city works. So the game accounting seems fine, but the display gets all wrong: I set tile production to be visible, so a (1 0 1) tile, should have a little green 1 (food), a little white 0 (no shields), and a little yellow 1 (gold). Instead I see (9 0 9) as if there were a huge food and gold bonus. Apparently, the display code do not like a "road" with negative bonuses, and gives me those weird nines.
Also, right-clicking the tile shows food/prod/trade 65536/0/65537, instead of the expected 1/0/1. There is also an error message: "Trying to put -1 into 16 bits; it will result 65535 at receiving side." Well, negative numbers works for city production; it'd be nice if the display was correct too. -1 is indeed 65535 when expressed in 16 bit, but please interpret that as a signed 16-bit number, which is -1.

2. Ice gets in the way, so I set "move_cost = 18". "move_fragments" is the usual 6, so I expected a ship or trireme to spend 3 full move points going through an icy tile. The idea is that ships can navigate through pack ice, but it will be much slower than open seas. The bug: There were no punishment at all. Ships and triremes move through icy seas as if they were normal seas. Entering ice, exiting ice, or moving from one icy tile to the next, no punishment. I can only guess, the "road" system was only meant for making movement faster, not slower? Or it doesn't work at sea? I can imagine many more use cases for extras that slow down movement: minefields (on land or sea), tank traps, border fences etc. All meant to slow down fast enemy units. I tried making the ice extra "native" to Sea and Trireme, that did not change anything.

Re: Bugs with custom road types

Posted: Tue Jul 01, 2025 12:36 pm
by Ignatus
Hafting wrote: Tue Jul 01, 2025 12:03 pm Itherefore I set -1 for food and -1 for trade
Negative extra outputs are just not intended in the game, contrary to some negative effects. So everything is not guaranteed to work with them. About outputs display on map, they are by just sprites, by default with with digits from 0 to 9, and can't show anything else, wether -1 or +50.
so I set "move_cost = 18"
It does not work that way. A unit always uses the fastest medium to travel by terrain, be it infra or terrain itself. Freeciv now has no obstacles that would block movement. It all seems like you should take the hard road and make pack ice a terrain.

Re: Bugs with custom road types

Posted: Wed Jul 02, 2025 3:53 pm
by Hafting
Ignatus wrote: Tue Jul 01, 2025 12:36 pm Negative extra outputs are just not intended in the game, contrary to some negative effects. So everything is not guaranteed to work with them. About outputs display on map, they are by just sprites, by default with with digits from 0 to 9, and can't show anything else, wether -1 or +50.
I had hoped this would work like pollution, but I see that pollution uses a different mechanism. Still, the tile output was 1/0/1. Positive numbers, that ought to be displayable with digits from 0 to 9. The modifier was negative, but the sum positive. I have no intention of creating negative tile production, that would be trivially avoidable by not working that tile.
It does not work that way. A unit always uses the fastest medium to travel by terrain, be it infra or terrain itself. Freeciv now has no obstacles that would block movement. It all seems like you should take the hard road and make pack ice a terrain.
Thank you for that clarification. Units using the fastest medium makes sense. New terrain types have some disadvantages though. There are already 3 kinds of sea, deep/shallow/lake. All may have ice. And I am planning a fourth type of sea, a rougher shallow sea with reefs and such. There could be a lot of terrain types to cover all combinations. Also, the "ice extra" was nice in that it automatically connects to neighbour ice as well as to any neighbouring land. This seems trickier with terrain types.

There is another approach: make all sea a slow medium, and overlay an invisible "open seas extra" with normal fast movement on all sea not covered in ice. A bit backwards, but a possibility if extras only can make tiles better, and never worse.