- fixed: FxPick leaked the array's content. Also did some cleanup on FxPick code.

This commit is contained in:
Christoph Oelckers 2014-12-14 12:03:55 +01:00
parent 3f3aab42f1
commit 6410428715
2 changed files with 6 additions and 17 deletions

View File

@ -563,7 +563,7 @@ class FxPick : public FxExpression
{
protected:
FRandom * rng;
TArray<FxExpression*> min;
TDeletingArray<FxExpression*> min;
public:

View File

@ -1699,14 +1699,10 @@ ExpVal FxRandom::EvalExpression (AActor *self)
FxPick::FxPick(FRandom * r, TArray<FxExpression*> mi, const FScriptPosition &pos)
: FxExpression(pos)
{
int index = 0;
int max = mi.Size();
if (max > 0)
for (unsigned int index = 0; index < mi.Size(); index++)
{
for (index = 0; index < max; index++)
min.Push(new FxIntCast(mi[index]));
min.Push(new FxIntCast(mi[index]));
}
else min.Clear();
rng = r;
ValueType = VAL_Int;
}
@ -1719,7 +1715,6 @@ FxPick::FxPick(FRandom * r, TArray<FxExpression*> mi, const FScriptPosition &pos
FxPick::~FxPick()
{
min.Clear();
}
//==========================================================================
@ -1730,17 +1725,11 @@ FxPick::~FxPick()
FxExpression *FxPick::Resolve(FCompileContext &ctx)
{
int index = 0;
CHECKRESOLVED();
int max = min.Size();
if (max > 0)
for (unsigned int index = 0; index < min.Size(); index++)
{
for (index = 0; index < max; index++)
{
RESOLVE(min[index], ctx);
ABORT(min[index]);
}
RESOLVE(min[index], ctx);
ABORT(min[index]);
}
return this;
};