From: Rudolf Polzer Date: Fri, 13 Jul 2012 15:30:32 +0000 (+0200) Subject: also add DistributeEvenly_GetRandomized for randomized rounding X-Git-Tag: xonotic-v0.7.0~312^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7e2871d65406c81da0b4b2feb748fabf3f25f25a;p=xonotic%2Fxonotic-data.pk3dir.git also add DistributeEvenly_GetRandomized for randomized rounding --- diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 25b42821e..70523892a 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -67,6 +67,16 @@ float DistributeEvenly_Get(float weight) DistributeEvenly_amount -= f; return f; } +float DistributeEvenly_GetRandomized(float weight) +{ + float f; + if (weight <= 0) + return 0; + f = floor(random() + DistributeEvenly_amount * weight / DistributeEvenly_totalweight); + DistributeEvenly_totalweight -= weight; + DistributeEvenly_amount -= f; + return f; +} #define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)