YaLTeR / BunnymodXT

Speedrun and TAS tool for Half-Life & friends.
Other
199 stars 37 forks source link

feature: bxt_hud_sprites #210

Open SmileyAG opened 2 years ago

SmileyAG commented 2 years ago

Enables display of sprites being played in the moment, similar to what bxt_hud_entities or s_show does.

Useful for cases when you want to find name of sprite to mask out with null one sprite (already in use for segmenting or rendering runs, e.g. when some of explosion sprite blocks your visibility), but you don't want to reverse-engineering game code or search manually through each file to find a right sprite for hiding.

SmileyAG commented 7 months ago

I looked into SPR functions and see that accessing this list is quite simple, so the code would be something like this:

typedef struct spritelist_s
{
    struct model_t *pSprite;
    char *pName;
    int frameCount;
} SPRITELIST;
if (gSpriteList && gSpriteCount)
{
  std::ostringstream ss;
  for (int i = 0; i < gSpriteCount; i++) // gSpriteCount is always set to 256 in the engine code, so perhaps you shouldn’t even intercept that, but rather make the const value instead? Although it prevents from the issue if Valve suddenly change the limit in future.
  {
    ss << "index: " << i << ", name:" << gSpriteList[i].pName << "\n";
  }
  ORIG_Con_Printf("%s", ss.str().c_str());
}

I'm not sure if there need HUD for that, looks like the console print is would be enough