Skip to content

Commit

Permalink
Add dump_ammo_types and dump_ammo_types_client
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Aug 4, 2024
1 parent 3c0e11d commit bbb5a40
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cl_dll/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ void __CmdFunc_HUDColor()
{
gHUD.HUDColorCmd();
}

extern void ReportRegisteredAmmoTypes();

// This is called every time the DLL is loaded
void CHud::Init( void )
Expand Down Expand Up @@ -743,6 +745,8 @@ void CHud::Init( void )

hudRenderer.Init();

gEngfuncs.pfnAddCommand("dump_ammo_types_client", ReportRegisteredAmmoTypes);

MsgFunc_ResetHUD( 0, 0, NULL );
ClientCmd( "richpresence_gamemode\n" );
ClientCmd( "richpresence_update\n" );
Expand Down
10 changes: 8 additions & 2 deletions dlls/ammoregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ void AmmoRegistry::RegisterOnClient(const char *name, int maxAmmo, int index, bo
type.id = index;
type.exhaustible = exhaustible;

ReportRegisteredType(type);
if (type.id > lastAmmoIndex)
lastAmmoIndex = type.id;
}

const AmmoType* AmmoRegistry::GetByName(const char *name) const
Expand Down Expand Up @@ -157,7 +158,12 @@ void AmmoRegistry::ReportRegisteredTypes()

void AmmoRegistry::ReportRegisteredType(const AmmoType& ammoType)
{
AMMO_LOG("Registered ammo type: '%s' (max: %d, index: %d)\n", ammoType.name, ammoType.maxAmmo, ammoType.id);
AMMO_LOG("%s. Max ammo: %d. Index: %d. %s\n", ammoType.name, ammoType.maxAmmo, ammoType.id, ammoType.exhaustible ? "Exhaustible" : "");
}

AmmoRegistry g_AmmoRegistry;

void ReportRegisteredAmmoTypes()
{
g_AmmoRegistry.ReportRegisteredTypes();
}
2 changes: 2 additions & 0 deletions dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,7 @@ cvar_t sv_pushable_fixed_tick_fudge = { "sv_pushable_fixed_tick_fudge", "15" };
cvar_t sv_busters = { "sv_busters", "0" };

extern void RegisterAmmoTypes();
extern void ReportRegisteredAmmoTypes();
extern void LoadWarpballTemplates();
extern void ReadInventorySpec();

Expand Down Expand Up @@ -1964,6 +1965,7 @@ void GameDLLInit( void )
g_engfuncs.pfnAddServerCommand("calc_position", Cmd_CalcPosition);
g_engfuncs.pfnAddServerCommand("calc_velocity", Cmd_CalcVelocity);
g_engfuncs.pfnAddServerCommand("calc_state", Cmd_CalcState);
g_engfuncs.pfnAddServerCommand("dump_ammo_types", ReportRegisteredAmmoTypes);
g_engfuncs.pfnAddServerCommand("dump_warpballs", DumpWarpballTemplates);
}

Expand Down
1 change: 0 additions & 1 deletion dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ void RegisterAmmoTypes()
{
g_AmmoRegistry.SetMaxAmmo(g_modFeatures.maxAmmos[i].name, g_modFeatures.maxAmmos[i].maxAmmo);
}
g_AmmoRegistry.ReportRegisteredTypes();
}

// called by worldspawn
Expand Down

0 comments on commit bbb5a40

Please sign in to comment.