Project Zomboid

Project Zomboid

2,775 ratings
Fix Inventory Tooltip lag
19
10
8
12
12
6
2
2
6
3
5
2
3
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
85.646 KB
9 Jan, 2023 @ 5:34am
1 Change Note ( view )

Subscribe to download
Fix Inventory Tooltip lag

Description
Fix Inventory Tooltip lag

This mod fixes a performance issue in the game that causes it to freeze up for a period of time, most commonly whenever you rip up clothing.

The problem becomes exponentially worse with the more clothing item mods you have, hence why it's the primary culprit.

The code is a classic example of "accidentally quadratic" If you care about the details, read on. If not, just download it.

What the vanilla game does that causes this problem

The game wants to show you a tooltip of the top 10 items that are valid for a given recipe, so it:

1. Builds a complete list of all valid items, in no particular order.

2. Sorts this complete list to move all items you actually have to the top - O(n) complexity.

3. Removes any items that are considered duplicates by virtue of being applicable to different slots (e.g. Left/right handed wristwatch) - O(n^2) complexity!

4. Renders the top 10 items of the list, ignoring anything else.

This is wasteful because it processes the full list of items, even though we only care about the top 10.

What this mod makes it do

1. We build a complete list of valid items, but any items that exist in your inventory are sent to the start of the list, at the point of insertion.

2. The list is truncated to the first 10 items and only these are sorted. We store the original length of the list for later - O(1) complexity.

3. Deduplication occurs as in vanilla, but, again, the list is now only 10 items long - O(1) complexity.

4. We render the list again. If there were more than 10 items, we ensure that the "and X more" text is computed correctly from the pre-truncation list size.

Workshop ID: 2915430406
Mod ID: FixTooltipLag
Popular Discussions View All (2)
0
21 Jun, 2023 @ 3:58am
LUA Error
Kyrox
0
13 Apr, 2023 @ 6:25am
1
Taew
175 Comments
киф чиф 3 Nov @ 9:54pm 
гигахарош
FictionalBiscuits 29 Oct @ 3:44pm 
finally, i can rip and tear
Drez08 27 Oct @ 3:15pm 
now i feel confident in adding clothing mods again, thanks bro.
////:set''FF'' 19 Oct @ 6:27pm 
ЙОУ:steamthumbsup:
ZaidIsm 17 Oct @ 9:41pm 
Safe for mid save?
gl_plov "TS" 16 Oct @ 6:40am 
love u:SmokingGlock::MMWhataday:
MIN 10 Oct @ 12:29am 
That's what I was looking for!:lunar2019wavingpig:
Cuttlas 9 Oct @ 3:33pm 
AMAZING MOD, I was annoyed by those freezes, thank you!
Mia 8 Oct @ 11:36am 
Perfecto
Leather Staff 4 Oct @ 12:49pm 
THANK YOU BRO O LOVE U:steamhappy: