Server lags when switching menus
Describe the bug Using modules that contain a large number of items causes server latency. This problem does not occur in the original version (FrozDark version)
To Reproduce Steps to reproduce the behavior:
- Load any module. For example auras
- Add a large number of items, like this config with a lot of items
- Toggle on
net_graph 1in the console - Go to the server and open shop menu
- Select the "Buy" category
- Observe the increasing server var as you switch the category list
- Select any category and go back
- Observe a similar thing as in item 6
Expected behavior Switching menus does not cause performance degradation
Server:
- OS: Linux
- Sourcemod version: 1.11.0.6913
- Version: 3.0E7
Additional context
- Game: CS:GO
🤔 Presumably the occurrence of server lags when opening any of the categories in the menu causes a one-time addition of all existing items in this menu. In addition, each item undergoes a series of checks before being added.
There is a category, it has 100 items, when a player opens this category, he is shown the entire menu with all the items in it, and not a specific number of items on this page (up to 6 pieces).
Ways to solve the problem from the side of the core rights:
- Complicated. Rewriting the menu for displaying category items to
Panelwill give more control to the developer, since he creates the menu completely from scratch (element layout, markup and button styles). Each page will be drawn as needed, and category items will be added to this page. All the complexity lies in the management of pages, nothing more. - Average. When entering a category, only show the player the first 8 items. Why not as much as fits on the page? - because the
Next buttonis shown only if the number of buttons exceeds the maximum number of buttons on the page. The difficulty lies in keeping track of the current page in theMenu, as I know - this is impossible with the standard approach (meaning without crutches).