mirror of https://github.com/AxioDL/metaforce.git
CIntElement: Remove const_cast
CIESampleAndHold caches values internally for use later in a non-visible manner to the user of the class. This is a good place for mutable to be used. This improves the readability of the GetValue() implementation.
This commit is contained in:
parent
36ac0a8d78
commit
a2517a504e
|
@ -189,12 +189,12 @@ bool CIESampleAndHold::GetValue(int frame, int& valOut) const {
|
||||||
int b, c;
|
int b, c;
|
||||||
xc_waitFramesMin->GetValue(frame, b);
|
xc_waitFramesMin->GetValue(frame, b);
|
||||||
x10_waitFramesMax->GetValue(frame, c);
|
x10_waitFramesMax->GetValue(frame, c);
|
||||||
/* const-correctness, who needs it? */
|
x8_nextSampleFrame = CRandom16::GetRandomNumber()->Range(b, c) + frame;
|
||||||
const_cast<CIESampleAndHold*>(this)->x8_nextSampleFrame = CRandom16::GetRandomNumber()->Range(b, c) + frame;
|
|
||||||
x4_sampleSource->GetValue(frame, valOut);
|
x4_sampleSource->GetValue(frame, valOut);
|
||||||
const_cast<CIESampleAndHold*>(this)->x14_holdVal = valOut;
|
x14_holdVal = valOut;
|
||||||
} else
|
} else {
|
||||||
valOut = x14_holdVal;
|
valOut = x14_holdVal;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,10 +134,10 @@ public:
|
||||||
|
|
||||||
class CIESampleAndHold : public CIntElement {
|
class CIESampleAndHold : public CIntElement {
|
||||||
std::unique_ptr<CIntElement> x4_sampleSource;
|
std::unique_ptr<CIntElement> x4_sampleSource;
|
||||||
int x8_nextSampleFrame = 0;
|
mutable int x8_nextSampleFrame = 0;
|
||||||
std::unique_ptr<CIntElement> xc_waitFramesMin;
|
std::unique_ptr<CIntElement> xc_waitFramesMin;
|
||||||
std::unique_ptr<CIntElement> x10_waitFramesMax;
|
std::unique_ptr<CIntElement> x10_waitFramesMax;
|
||||||
int x14_holdVal;
|
mutable int x14_holdVal;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CIESampleAndHold(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
|
CIESampleAndHold(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
|
||||||
|
|
Loading…
Reference in New Issue