From 24100c25a938564b523889b270a445a8bb44f21f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 25 Feb 2008 15:43:22 +0000 Subject: [PATCH] - Fixed: The DECORATE expression evaluator's random function could produce incorrect results for ranges > 255. Changed so that FRandom's default implementation is used instead. SVN r769 (trunk) --- docs/rh-log.txt | 5 +++++ src/thingdef/thingdef_exp.cpp | 18 +----------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index b0ec5eab9..69cdf4b4e 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,8 @@ +February 25, 2008 (Changes by Graf Zahl) +- Fixed: The DECORATE expression evaluator's random function could produce + incorrect results for ranges > 255. Changed so that FRandom's default + implementation is used instead. + February 21, 2008 - Fixed: DThinker::SerializeAll() did not serialize any thinkers in the FreshThinkers lists. These thinkers would still be saved in the savegame if diff --git a/src/thingdef/thingdef_exp.cpp b/src/thingdef/thingdef_exp.cpp index d0f882443..62b6f0337 100644 --- a/src/thingdef/thingdef_exp.cpp +++ b/src/thingdef/thingdef_exp.cpp @@ -1477,23 +1477,7 @@ static ExpVal EvalExpression (ExpData *data, AActor *self, const PClass *cls) swap (max, min); } - if (max - min > 255) - { - int num1,num2,num3,num4; - - num1 = (*data->RNG)(); - num2 = (*data->RNG)(); - num3 = (*data->RNG)(); - num4 = (*data->RNG)(); - - val.Int = ((num1 << 24) | (num2 << 16) | (num3 << 8) | num4); - } - else - { - val.Int = (*data->RNG)(); - } - val.Int %= (max - min + 1); - val.Int += min; + val.Int = (*data->RNG)(max - min + 1) + min; } break;