shovel: fix the Destruction functionality

Previously, it was checked incorrectly whether the action was "Dig". Then the check was thrown out completely in https://git.openclonk.org/openclonk.git/commit/39e86474fccbd54eb357175d2b8fbec5c60639ab - which did remove the warning but not solve the defect.
This should be a proper fix. The shovel only does stuff when the user is digging AND actually using this very shovel for it.
epoxy
David Dormagen 2016-02-01 20:15:01 +01:00
parent a390f8f248
commit 76ac759533
1 changed files with 7 additions and 5 deletions

View File

@ -7,12 +7,14 @@ private func Hit()
private func Destruction()
{
if (Contained())
if (Contained()->GetAction())
// Stop shoveling when using the shovel when it's destroyed.
var user = Contained();
if (user)
if (user->GetAction() == "Dig" && user->~GetUsedObject() == this)
{
// We assume that the clonk digs with this shovel. If not, too bad. You stop shoveling.
Contained()->SetAction("Walk");
Contained()->SetComDir(COMD_Stop);
user->CancelUse();
user->SetAction("Walk");
user->SetComDir(COMD_Stop);
}
}