mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-25 00:08:14 +00:00
Fixed bug that was causing population to go negative. It was due to a unit being killed by multiple enemies in the same frame, which led to multiple calls of the death event handler. The fix is twofold: First, kill() only calls the event handler the first time the unit is killed. Second, damage() (in JS), which apart from killing things also loots them, makes sure that the unit is not already being destroyed. This latter fix is to ensure that we don't get a huge amount of loot by simply attacking a low-HP unit with many soldiers simultaneously, so they kill it in the same frame.
This was SVN commit r6276.
This commit is contained in:
@@ -57,6 +57,7 @@ void CEntity::ScriptingInit()
|
||||
AddMethod<jsval_t, &CEntity::TerminateOrder>( "terminateOrder", 1 );
|
||||
AddMethod<bool, &CEntity::Kill>( "kill", 0 );
|
||||
AddMethod<bool, &CEntity::IsIdle>( "isIdle", 0 );
|
||||
AddMethod<bool, &CEntity::IsDestroyed>( "isDestroyed", 0 );
|
||||
AddMethod<bool, &CEntity::HasClass>( "hasClass", 1 );
|
||||
AddMethod<jsval_t, &CEntity::GetSpawnPoint>( "getSpawnPoint", 1 );
|
||||
AddMethod<jsval_t, &CEntity::AddAura>( "addAura", 3 );
|
||||
@@ -364,9 +365,6 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, CEntityOrder::EOrde
|
||||
|
||||
bool CEntity::Kill( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) )
|
||||
{
|
||||
CEventDeath evt;
|
||||
DispatchEvent( &evt );
|
||||
|
||||
Kill(true);
|
||||
|
||||
return( true );
|
||||
|
||||
Reference in New Issue
Block a user