Project Zomboid

Project Zomboid

3,348 ratings
Fix Inventory Tooltip lag
21
12
8
14
12
6
8
2
2
6
3
3
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
197 Comments
КидСмоук69 21 Jun @ 9:41am 
Я думал у меня комп калище, а теперь понятно что не у меня одного такая проблема, ОЧЕНЬ БЛАГОДАРЕН ЗА МОД!!! ЛЮБЛЮ ЦЕЛУЮ:CrashMetal5:
Kar33a 21 Jun @ 7:31am 
luv u so much ty!
60threin 17 May @ 4:05pm 
W mod
iihiromichie 2 May @ 4:56am 
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
GODDESS
Lucasif 21 Apr @ 12:34pm 
Yes
Fred 21 Apr @ 9:40am 
@Lucasif you mean in b42?
Bl4ckD3ad06 11 Apr @ 4:07pm 
o7
Lucasif 23 Mar @ 12:14pm 
They all do the same thing, but this mod isn't needed right now as they fixed it in the game.
marshmallow justice 23 Mar @ 4:30am 
I'm surprised there's so many mods like this on the workshop, do they all do the same thing? I've been using your one for the longest time without issue (we started playing after a few years break and after adding some mods instantly ran into this vanilla problem lol) but see quite a few others that seem to tackle the same problem, like "Authentic Z Stutter Fix" and "Fix Crafting Context Menu Stutter".
Are they all the same, and just use whichever works?
Zizou 9 Mar @ 8:19am 
Awesome mod. Fixes annoying lag :steamthumbsup: