1
0

Got rid of dangerous GetEntity(), not using DoWithEntity()

git-svn-id: http://mc-server.googlecode.com/svn/trunk@278 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth
2012-02-16 17:20:28 +00:00
parent 415d4eaa68
commit 008addf5d7
6 changed files with 31 additions and 55 deletions

View File

@@ -1532,13 +1532,27 @@ void cClientHandle::HandleUseEntity(cPacket_UseEntity * a_Packet)
{
return;
}
cWorld * World = m_Player->GetWorld();
cEntity * Entity = World->GetEntity(a_Packet->m_TargetID);
if ((Entity != NULL) && Entity->IsA("cPawn"))
class cDamageEntity : public cEntityCallback
{
cPawn * Pawn = (cPawn *)Entity;
Pawn->TakeDamage(1, m_Player);
}
virtual bool Item(cEntity * a_Entity) override
{
if( a_Entity->IsA("cPawn") )
{
reinterpret_cast< cPawn* >( a_Entity )->TakeDamage(Damage, Instigator );
}
return true;
}
public:
int Damage;
cEntity * Instigator;
} Callback;
Callback.Damage = 1; // TODO: Find proper damage from current item equipped
Callback.Instigator = m_Player;
cWorld * World = m_Player->GetWorld();
World->DoWithEntity( a_Packet->m_TargetID, Callback );
}