forked from Mirrors/openclonk
Fix ruby sale goal counting gems twice (#1489).
parent
019cc0d583
commit
c5f12523aa
|
@ -42,12 +42,12 @@ func FxSparkleTimer(target, effect, effect_time)
|
||||||
|
|
||||||
func IsValuable() { return true; }
|
func IsValuable() { return true; }
|
||||||
|
|
||||||
func QueryOnSell()
|
func OnSale(int to_player, object sale_base)
|
||||||
{
|
{
|
||||||
// Inform goal of gem sale
|
// Inform goal of gem sale
|
||||||
var goal = FindObject(Find_ID(Goal_SellGems));
|
var goal = FindObject(Find_ID(Goal_SellGems));
|
||||||
if (goal) goal->OnGemSold();
|
if (goal) goal->OnGemSold();
|
||||||
return false; // do perform selling
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
func Hit()
|
func Hit()
|
||||||
|
|
|
@ -387,9 +387,11 @@ func DoSell(object pObj, int iPlr, bool bRight)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// OnSale callback to object e.g. for goal callbacks
|
||||||
|
pObj->~OnSale(iPlr, this);
|
||||||
// And remove the object
|
// And remove the object
|
||||||
pObj->RemoveObject();
|
pObj->RemoveObject();
|
||||||
if(bFound) return DoSell(pNewObj, iPlr, bRight);
|
if(bFound) return DoSell(pNewObj, iPlr, bRight); // wtf why is this recursive? will fail with too many objects
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,8 +196,10 @@ public func Collection(object obj)
|
||||||
if (obj->~IsValuable() && !obj->~QueryOnSell(obj->GetController()))
|
if (obj->~IsValuable() && !obj->~QueryOnSell(obj->GetController()))
|
||||||
{
|
{
|
||||||
DoWealth(obj->GetController(), obj->GetValue());
|
DoWealth(obj->GetController(), obj->GetValue());
|
||||||
obj->RemoveObject();
|
|
||||||
Sound("Cash");
|
Sound("Cash");
|
||||||
|
// OnSale callback to object e.g. for goal updates
|
||||||
|
obj->~OnSale(obj->GetController(), this);
|
||||||
|
if (obj) obj->RemoveObject();
|
||||||
}
|
}
|
||||||
return _inherited(obj, ...);
|
return _inherited(obj, ...);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue