Limit amount of units fleeing a destroyed warehouse / headquarters

Bug #1624216 reported by GunChleoc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Low
Unassigned

Bug Description

If there are a few thousand units fleeing a destroyed warehouse/headquarters, the game will lag.

Give them a hard coded upper limit per unit type (500?) and destroy the rest.

Related branches

Revision history for this message
GunChleoc (gunchleoc) wrote :
Revision history for this message
DragonAtma (dragonatma) wrote :

I feel it'd be best to have the individual workers represent multiple units if needed. So if there's a cap of 500 horses, but the destroyed warehouse had 1200 horses in it, then 200 of the horses would represent 3 each, and 300 would represent 2 each.

Revision history for this message
GunChleoc (gunchleoc) wrote :

This won't scale down to types of units that you have only very little of. e.g. how do you represent 1 Miner with a ratio of 3:1?

Let's keep this simple stupid and just have a cap.

Revision history for this message
DragonAtma (dragonatma) wrote :

If there are 500 or less horses (or whatever the cap is), then each horse unit represents one horse, as it does now. Only when there are more horses than the cap would it start assigning horse units to represent 2+ horses.

Remember, I am at best an average programmer. If I can whip up pseudo-code in under five minutes, I'm sure the widelands team can handle it in their sleep.

Revision history for this message
GunChleoc (gunchleoc) wrote :

You can't reassign 3 horses to a new horse, that doesn't make sense coding-wise. They are all identical anyway, so there are no special features to preserve for individual horses.

So, your suggestion would be:

Loop through the horses, keep each nth horse, destroy the other horses.

My suggestion would be: grab the first x horses, destroy the rest.

IMO you're overthinking this ;)

GunChleoc (gunchleoc)
Changed in widelands:
assignee: nobody → GunChleoc (gunchleoc)
status: New → In Progress
Revision history for this message
GunChleoc (gunchleoc) wrote :

I have attached a branch that implements my suggestion, with a cap of 500 per unit type.

GunChleoc (gunchleoc)
Changed in widelands:
status: In Progress → Fix Committed
assignee: GunChleoc (gunchleoc) → nobody
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.