Currently Online

Latest Posts

Topic: Carriers management

Kontorotsui
Avatar
Joined: 2021-05-20, 15:35
Posts: 28
Ranking
Pry about Widelands
Posted at: 2022-10-12, 17:58

Hello, a question about the carriers.

I'm trying to make a custom tribe, and I'm stuck with the carriers.

According to the code, you can define several carriers in the carriers entry in units.lua file, in this way:

carriers = {"carrier_normal", "carrier_extra", "carrier_donkey"}

Now my question is: why are the carrier_normal and carrier_extra always kept at 100 units in warehouse? That is, they are unlimited. I want carrier_extra to require a tool to be created in a building. Yet, they are created "for free" and kept at 100 in the headquarters.

Also, I would like the basic carrier (carrier_normal) not to stay at 100 but recharge freely yet slowly. That is, if you use too many of them, they will eventually run out and slowly fill up.

Is there a way to do that? I cannot find anything in the code or documentation.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1728
OS: Ubuntu MATE 22.10
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2022-10-12, 20:05

This behaviour is called the "buildable" property: Such workers are always spawned at 100 units per warehouse for free. A worker is made buildable by giving it an empty buildcost in its init.lua:

   buildcost = {},

To make them buildable in warehouses with a tool requirement, simply add it to the buildcost like for every other worker:

   buildcost = {
      carrier_normal = 1,
      insert_toolname_here = 1
   },

To prevent their creation in warehouses altogether and make them recruitable only in a specialised productionsite, omit the buildcost key entirely, like for donkeys. Or set it to nil which in Lua amounts to the same thing:

   buildcost = nil,

The spawn rate and target amount for free workers are hardcoded and can not be changed.


Top Quote
Kontorotsui
Avatar
Joined: 2021-05-20, 15:35
Posts: 28
Ranking
Pry about Widelands
Posted at: 2022-10-13, 11:27

Thanks, I studied the code and found that buildcost = {} entry to be deleted and reached the same conclusions.

Interesting that after I made the carriers not free but taking time to build, the game gets much harder and impossible to power start.

I have found a problem, anyway, for some reasons, after I did the carriers in this way, the exit game, and load game are VERY slow, with almost a minute at 100% CPU usage. How can check what is slowing it down so much?


Top Quote
Kontorotsui
Avatar
Joined: 2021-05-20, 15:35
Posts: 28
Ranking
Pry about Widelands
Posted at: 2022-10-13, 15:46

I get thousands of these:

[00:15:37.972 real] DEBUG: MO(15382,water): cancel_moving
[00:15:37.972 real] DEBUG: MO(15381,water): cancel_moving
[00:15:37.972 real] DEBUG: MO(15380,snack): cancel_moving
[00:15:37.972 real] DEBUG: MO(15379,water): cancel_moving
[00:15:37.972 real] DEBUG: MO(15378,water): cancel_moving
[00:15:37.972 real] DEBUG: MO(15377,water): cancel_moving
[00:15:37.972 real] DEBUG: MO(15376,water): cancel_moving
[00:15:37.972 real] DEBUG: MO(15375,water): cancel_moving
[00:15:37.973 real] DEBUG: MO(15374,snack): cancel_moving
[00:15:37.973 real] DEBUG: MO(15373,log): cancel_moving

Seems there are some wares stuck at the base of the headquarters and they don't move, even if I cancel all the roads and put them back, they are not moved anymore.

(edited by Nordfriese: formatting)

Edited: 2022-10-13, 21:45

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1728
OS: Ubuntu MATE 22.10
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2022-10-13, 21:45

I have found a problem, anyway, for some reasons, after I did the carriers in this way, the exit game, and load game are VERY slow, with almost a minute at 100% CPU usage. How can check what is slowing it down so much?

You can compile/download a debug build of Widelands, run it in a debugger (e.g. GDB), and during the stalling, press Ctrl+C and type bt to get a backtrace that shows which part of the code is being executed currently. Then c to continue.

DEBUG: MO(15382,water): cancel_moving

Does this happen only during loading or afterwards as well? During loading it is normal because of saveloading internals. If it keeps happening a lot during the actual game your economy seems to be pretty messed up face-wink.png

By the way, writing large amounts of log output is slow, so running Widelands with --verbose output may also contribute to the high loading time.


Top Quote
Kontorotsui
Avatar
Joined: 2021-05-20, 15:35
Posts: 28
Ranking
Pry about Widelands
Posted at: 2022-10-15, 09:03

The cancel_moving happens when loading, closing and during the game. I have a fast PC, when loading and closing it takes several seconds (up to 20-30) , other games are almost immediately loaded and closed.

To do what you say will take me time, meanwhile I figure what is going on.

Seems that the problem is the limited number of carriers that shows the bug. I play with a modified tribe and I made the carriers not unlimited (that is, I deleted the empty build cost line) and make them in a specialized building. When the warehouse needs to put out a lot of wares, they use several carriers stored there to bring them out. If they are not enough (like there are 3-4 only, but the warehouse uses many more), after a few time the bug shows: the wares are left at the flag at the entrance of the warehouse/headquarter (happens on both) and is never moved anymore.

That is unfortunate, since I wanted this feature: to limit the number of roads you can make quickly (so you have to manage a road economy) and be forced to invest in building more carriers, if you ran out of them you're even unable to put the wares out of the warehouse so you're forced to cancel some roads. A pity that this triggers the bug.

I think it is easy to reproduce: fill a warehouse with a lot of goods and only a few limited carriers, attach several ware consuming buildings and see it happen after a while.


Top Quote
Kontorotsui
Avatar
Joined: 2021-05-20, 15:35
Posts: 28
Ranking
Pry about Widelands
Posted at: 2022-10-15, 09:23

Also I have another problem. I created three carriers (one basic, one donkey and one extra carrier which need a ware to be created) and put them in the carriers array in units.lua. I expected the donkey and the extra carrier to go only on busy roads, but they go everywhere. I tried to find in the original tribes some commands to indicate which carrier should go to busy roads only, like the donkey for empire which indeed goes only in the busy roads, but I could not find it. Can you help?


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1728
OS: Ubuntu MATE 22.10
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2022-10-15, 09:58

Kontorotsui wrote:

Also I have another problem. I created three carriers (one basic, one donkey and one extra carrier which need a ware to be created) and put them in the carriers array in units.lua. I expected the donkey and the extra carrier to go only on busy roads, but they go everywhere. I tried to find in the original tribes some commands to indicate which carrier should go to busy roads only, like the donkey for empire which indeed goes only in the busy roads, but I could not find it. Can you help?

The first carrier type in the carriers array is used on all roads, the other types only on busy roads. So that sounds like a bug. If you could upload the tribe definitions and a replay or savegame I could have a look.


Top Quote
Kontorotsui
Avatar
Joined: 2021-05-20, 15:35
Posts: 28
Ranking
Pry about Widelands
Posted at: 2022-10-29, 19:32

Nordfriese wrote:

Kontorotsui wrote:

Also I have another problem. I created three carriers (one basic, one donkey and one extra carrier which need a ware to be created) and put them in the carriers array in units.lua. I expected the donkey and the extra carrier to go only on busy roads, but they go everywhere. I tried to find in the original tribes some commands to indicate which carrier should go to busy roads only, like the donkey for empire which indeed goes only in the busy roads, but I could not find it. Can you help?

The first carrier type in the carriers array is used on all roads, the other types only on busy roads. So that sounds like a bug. If you could upload the tribe definitions and a replay or savegame I could have a look.

I'll try to reproduce the bug somehow and I will post it. It seems that the donkey and second carrier go to not busy roads if I cancel the busy road below them.

Also, sometimes I get two carriers (first carrier type) on the road, one is sitting doing nothing, the other is working, even if there are multiple wares to move. And sometimes they work together.

But the worst happens when you have not enough carriers, like you have 10 carriers in the warehouse but there is a strong request for wares to be sent out. Each carrier takes one and there are not enough carriers, so a sort of extra queue is formed, somehow, especially if there are not enough carriers to pick them once they are out of the warehouse, one or more of these wares sit forever in the warehouse flag and are never picked up. I'll try to reproduce the bug. It is you that codes the carriers?

Ah, also, today I tried the port and expeditions with my modified tribe with limited carriers... seems that if there are no carriers in the target port (the one you just created with the expedition) and you make a new building linked to that new port, the ship bring construction wares to the port, but since it is without carriers, these wares disappear into nothingness. They are still waited by the target building (it has the wares shaded as "incoming") but they simply disappear in the port and are not listed, probably given to ghost carriers... I wold like to fix this by setting the expedition requirements, and add like 20 mandatory carriers to the expedition to avoid this problem, but I cannot find any way to list the expedition requirements, should I assume it is hardwired with the port cost + 1 builder?


Top Quote
Kontorotsui
Avatar
Joined: 2021-05-20, 15:35
Posts: 28
Ranking
Pry about Widelands
Posted at: 2022-11-26, 12:11

Nordfriese wrote:

Kontorotsui wrote:

Also I have another problem. I created three carriers (one basic, one donkey and one extra carrier which need a ware to be created) and put them in the carriers array in units.lua. I expected the donkey and the extra carrier to go only on busy roads, but they go everywhere. I tried to find in the original tribes some commands to indicate which carrier should go to busy roads only, like the donkey for empire which indeed goes only in the busy roads, but I could not find it. Can you help?

The first carrier type in the carriers array is used on all roads, the other types only on busy roads. So that sounds like a bug. If you could upload the tribe definitions and a replay or savegame I could have a look.

Hi Nordfriese, I had a few time to improve my customized version of the Europeans tribe and to test play it, it is getting very nice and challenging, but the limited carriers are a nightmare. Probably, being limited, it exposes several bugs that were covered by the fact that each warehouse and port automatically have always a full 100 carriers for free, replenished without limits. Once you limit them, a lot of troubles happen.

This is especially bad with ports, the new port (call it the target port) starts with zero carriers, and if the ships arrive with wares, typically to build military buildings to enlarge the territory, the wares just disappear at the port, as if they are not "unloaded", and the buildings are stalled and wait forever wares which never arrive. Also, on the other port (the source port) it is very easy to run out of carriers and it filled the flag at the base of the port so the wares cannot exit anymore, and the game is ruined.

If you want to check it, I can upload both the tribe (the whole tree which is put in the addon directory) and the savegame. Want me to upload it here as attachment or send it to you in some way?


Top Quote