From b5fead8f53a555b62c9de2dc23b0f2ce9a136e8e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 18 Mar 2016 20:34:04 +0300 Subject: Add custom rand function implimentation, based on precreated random sequence. --- src/resources/sprite/animatedsprite.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/resources/sprite/animatedsprite.cpp') diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp index 34aca4706..f0af74f08 100644 --- a/src/resources/sprite/animatedsprite.cpp +++ b/src/resources/sprite/animatedsprite.cpp @@ -36,6 +36,7 @@ #include "resources/sprite/animationdelayload.h" #include "utils/delete2.h" +#include "utils/mrand.h" #include "debug.h" @@ -240,7 +241,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2 !mFrame->nextAction.empty()) { if (mFrame->rand == 100 || - mFrame->rand >= rand() % 100) + mFrame->rand >= mrand() % 100) { for (size_t i = 0; i < mAnimation->getLength(); i ++) { @@ -272,7 +273,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2 !mFrame->nextAction.empty()) { if (mFrame->rand == 100 || - mFrame->rand >= rand() % 100) + mFrame->rand >= mrand() % 100) { play(mFrame->nextAction); return true; @@ -283,7 +284,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2 mFrame->type == Frame::ANIMATION) { if (mFrame->rand == 100 || - mFrame->rand >= rand() % 100) + mFrame->rand >= mrand() % 100) { mAnimation = nullptr; mFrame = nullptr; @@ -299,7 +300,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2 } else { - if (rand() % 100 <= mFrame->rand) + if (mrand() % 100 <= mFrame->rand) fail = false; } } -- cgit v1.2.3-60-g2f50