Fix ruby sale goal counting gems twice (#1489).

shapetextures
Sven Eberhardt 2015-12-06 21:45:06 -05:00
parent 019cc0d583
commit c5f12523aa
3 changed files with 8 additions and 4 deletions

View File

@ -42,12 +42,12 @@ func FxSparkleTimer(target, effect, effect_time)
func IsValuable() { return true; }
func QueryOnSell()
func OnSale(int to_player, object sale_base)
{
// Inform goal of gem sale
var goal = FindObject(Find_ID(Goal_SellGems));
if (goal) goal->OnGemSold();
return false; // do perform selling
return true;
}
func Hit()

View File

@ -387,9 +387,11 @@ func DoSell(object pObj, int iPlr, bool bRight)
break;
}
}
// OnSale callback to object e.g. for goal callbacks
pObj->~OnSale(iPlr, this);
// And remove the object
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;
}

View File

@ -196,8 +196,10 @@ public func Collection(object obj)
if (obj->~IsValuable() && !obj->~QueryOnSell(obj->GetController()))
{
DoWealth(obj->GetController(), obj->GetValue());
obj->RemoveObject();
Sound("Cash");
// OnSale callback to object e.g. for goal updates
obj->~OnSale(obj->GetController(), this);
if (obj) obj->RemoveObject();
}
return _inherited(obj, ...);
}