Quote:
Originally Posted by asherkin
Which version of CEntity are you using? Also, any code you can provide will speed up debugging.
|
The output I posted was done from latest version of your TF DodgeBall source extension. I wanted to test if problem is w/ our plugin or not and in the end issue seemed exactly the same as in our plugin. I did modify your extension slightly, like adding/using IServerTools interface (for entity loop), adding IsBaseObject hook to CEntity and adding GetCurrentWeapon to CPlayer to return current m_hActiveWeapon (though this was not needed).
Here is the code I used (I know, not the best way to test it but it got job done). This assumes that player is in server (hence grabbing CPlayer by entity index of 1).
Code:
CON_COMMAND(dmg_to_bld, "")
{
CPlayer *pPlayer = pHelpers->UTIL_PlayerByIndex(1);
if (!pPlayer)
{
Msg("bad CPlayer instance \n");
return;
}
CEntityTakeDamageInfo info;
info.m_hAttacker = pPlayer->BaseEntity();
info.m_hInflictor = pPlayer->GetCurrentWeapon()->BaseEntity();
info.m_hWeapon = pPlayer->GetCurrentWeapon()->BaseEntity();
info.m_flDamage = atof(args.Arg(1));
info.m_bitsDamageType = DMG_BLAST;
for (void *ent = servertools->FirstEntity(); ent; ent = servertools->NextEntity(ent))
{
CEntity *pEntity = CEntity::Instance((CBaseEntity*)ent);
if (pEntity && pEntity->IsBaseObject() && pEntity->GetTeam() != pPlayer->GetTeam())
{
Msg("Pre-Damage: pEntity @ 0x%p BaseEntity @ 0x%p pEdict @ 0x%p [%s] [%i]\n", pEntity, pEntity->BaseEntity(), pEntity->edict(), pEntity->GetClassname(), pEntity->entindex());
pEntity->OnTakeDamage(info);
Msg("Post-Damage: pEntity @ 0x%p BaseEntity @ 0x%p pEdict @ 0x%p \n\n", pEntity, pEntity->BaseEntity(), pEntity->edict());
}
}
}
So here's what I did step by step:
1. Start dedicated server (I found koth_sawmill as a good test map since this test involves bots)
2. Set tf_bot_force_class CVar to "engineer"
3. Join the server
4. Add bots (I did tf_bot_add 30 so I could have a decent sample size)
5. I gave bots about a minute to build then executed the command: dmg_to_bld 999 from SRCDS (to make sure it destroyed buildings)
That's about it. As stated in previous post, this issue occurs mostly with Dispensers and Sentry Guns. Teleporters usually worked just fine (same CBaseEntity / edict_t pointer address after being destroyed and no corruption either).
Thanks again for the help.