Skip to content

Development Notes

Victor Roemer edited this page Aug 17, 2022 · 1 revision

TODO

UI Initialization

  1. UI Module has 2 global references to displayContextDef_t.

NOTE: Try to consolidate these:

  • ::uiInfo.uiDC
  • ::DC
  1. UI_Init() calls UI_InitMemory() multiple times.

NOTE: UI_InitMemory() is called 2x in the Init routine, the 2nd call is unnecessary.

ui_main.cpp::UI_Init(bool)
  ...

  UI_InitMemory();
  BG_InitMemory();

  ... display context initialization ...

  String_Init() // FIXME
    -> UI_InitMemory()
  1. Cleanup keywordHash_t

No need for hand-rolled hash tables with C++

These functions are duplicating the data from ParseKeywords into the Hash table, this is unnecessary. These tables are also very sparse, there far larger than is necessary.

void ui_shared.cpp::Item_SetupKeywordHash(void)
    itemParseKeywordHash
    itemParseKeywords
  • itemParseKeywordHash has 512 slots.
  • itemParseKeywords only has 68 elements.
  • 414 slots are unused.
void Menu_SetupKeywordHash(void)
    menuParseKeywordHash
    menuParseKeywords
  • menuParseKeywordHash has 512 slots.
  • menuParseKeywords has 29 elements.
  • 482 slots are unused.
print sizeof(menuParseKeywordHash)/sizeof(menuParseKeywordHash[0])
(unsigned long) $4 = 512

print sizeof(menuParseKeywordHash)
(unsigned long) $5 = 4096

print sizeof(menuParseKeywordHash[0])
(unsigned long) $6 = 8

print sizeof(menuParseKeywords)
(unsigned long) $7 = 960
  1. Unnecessary Check for DC && DC->getBindingBuf
void ui_shared.cpp:String_Init(void)
...
    if (DC && DC->getBindingBuf)
        Controls_GetConfig();
  1. Controls_GetKeyAssignment() Loops 13,312 times

This function implments a very slow search algorithm. The purpose of this function is to map the Users configured bindings into a UI g_bindings table which is used in UI menu's.

  • for each command in g_bindings[52].command
  • for each keynum in (0..256)
  • if keys[keynum].binding == command
  • set g_bindings[i].twokeys = keys[keynum].tokeys
  1. A better search can be implemented

  2. Keys and Command Bindings could be broken out into it's own namespace/module/utility.

  3. More global hash tables

tr_shader.cpp:

#define FILE_HASH_SIZE		1024
static	shader_t*		hashTable[FILE_HASH_SIZE];

1024

  1. AssetCache() Loads the actual UI assets.

  2. AVI recording, increase the default aviFrameRate

print cl_aviFrameRate->integer (int) $22 = 25