- 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: protected:
FRandom * rng; FRandom * rng;
TArray<FxExpression*> min; TDeletingArray<FxExpression*> min;
public: public:

View File

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