forked from Mirrors/openclonk
Fix suspicious_assignment warnings in Defense
parent
808a90e5af
commit
806357e283
|
@ -74,11 +74,13 @@ func RemovePlayer(int plr)
|
|||
private func TransferInventory(object from, object to)
|
||||
{
|
||||
// Drop some items that cannot be transferred (such as connected pipes and dynamite igniters)
|
||||
var i = from->ContentsCount(), contents;
|
||||
var i = from->ContentsCount();
|
||||
while (i--)
|
||||
if (contents = from->Contents(i))
|
||||
if (contents->~IsDroppedOnDeath(from))
|
||||
contents->Exit();
|
||||
{
|
||||
var contents = from->Contents(i);
|
||||
if (contents && contents->~IsDroppedOnDeath(from))
|
||||
contents->Exit();
|
||||
}
|
||||
return to->GrabContents(from);
|
||||
}
|
||||
|
||||
|
@ -303,10 +305,13 @@ func OnClonkDeath(clonk, killed_by)
|
|||
{
|
||||
// Enemy clonk death
|
||||
// Remove inventory
|
||||
var i = clonk->ContentsCount(), obj;
|
||||
while (i--) if (obj=clonk->Contents(i))
|
||||
if (!obj->~OnContainerDeath())
|
||||
var i = clonk->ContentsCount();
|
||||
while (i--)
|
||||
{
|
||||
var obj = clonk->Contents(i);
|
||||
if (obj && !obj->~OnContainerDeath())
|
||||
obj->RemoveObject();
|
||||
}
|
||||
// Clear enemies from list
|
||||
i = GetIndexOf(g_spawned_enemies, clonk);
|
||||
if (i>=0)
|
||||
|
|
|
@ -20,7 +20,7 @@ public func FindTarget(effect fx, bool parent)
|
|||
private func FindInventoryWeapon(effect fx)
|
||||
{
|
||||
// Extra weapons
|
||||
if (fx.weapon = fx.Target->FindContents(Axe))
|
||||
if (FindInventoryWeaponBase(fx, Axe))
|
||||
{
|
||||
fx.strategy = this.ExecuteMelee;
|
||||
return true;
|
||||
|
@ -357,8 +357,12 @@ private func ExecuteRanged(effect fx)
|
|||
// Path not free or out of range. Just wait for enemy to come...
|
||||
fx.aim_weapon->ControlUseHolding(fx.Target,tx-x,ty-y);
|
||||
// Might also change target if current is unreachable
|
||||
var new_target;
|
||||
if (!Random(3)) if (new_target = this->FindTarget(fx)) fx.target = new_target;
|
||||
if (!Random(3))
|
||||
{
|
||||
var new_target = this->FindTarget(fx);
|
||||
if (new_target)
|
||||
fx.target = new_target;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,11 +74,13 @@ func RemovePlayer(int plr)
|
|||
private func TransferInventory(object from, object to)
|
||||
{
|
||||
// Drop some items that cannot be transferred (such as connected pipes and dynamite igniters)
|
||||
var i = from->ContentsCount(), contents;
|
||||
var i = from->ContentsCount();
|
||||
while (i--)
|
||||
if (contents = from->Contents(i))
|
||||
if (contents->~IsDroppedOnDeath(from))
|
||||
contents->Exit();
|
||||
{
|
||||
var contents = from->Contents(i);
|
||||
if (contents && contents->~IsDroppedOnDeath(from))
|
||||
contents->Exit();
|
||||
}
|
||||
return to->GrabContents(from);
|
||||
}
|
||||
|
||||
|
@ -169,10 +171,13 @@ func OnClonkDeath(clonk, killed_by)
|
|||
{
|
||||
// Enemy clonk death
|
||||
// Remove inventory
|
||||
var i = clonk->ContentsCount(), obj;
|
||||
while (i--) if (obj=clonk->Contents(i))
|
||||
if (!obj->~OnContainerDeath())
|
||||
var i = clonk->ContentsCount();
|
||||
while (i--)
|
||||
{
|
||||
var obj = clonk->Contents(i);
|
||||
if (obj && !obj->~OnContainerDeath())
|
||||
obj->RemoveObject();
|
||||
}
|
||||
// Clear enemies from list
|
||||
i = GetIndexOf(g_spawned_enemies, clonk);
|
||||
if (i>=0)
|
||||
|
@ -516,4 +521,4 @@ func InitWaveData()
|
|||
Arrows = [{ X = 0, Y = 0 },{ X = 2000, Y = 0 },{ X = 0, Y = 300 },{ X = 2000, Y = 300 },{ X = 1000, Y = 0 },{ X = 0, Y = 1250 },{ X = 2000, Y = 1250 },{ X = 200, Y = 2000 },{ X = 1800, Y = 2000 },{ X = 880, Y = 2000 },{ X = 1120, Y = 2000 }]
|
||||
}];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue