]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
also add DistributeEvenly_GetRandomized for randomized rounding
authorRudolf Polzer <divverent@xonotic.org>
Fri, 13 Jul 2012 15:30:32 +0000 (17:30 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 13 Jul 2012 15:30:32 +0000 (17:30 +0200)
qcsrc/server/miscfunctions.qc

index 25b42821ed3621735722e23194374d4922396458..70523892a114ae8d244a5696c95496a7d36700ad 100644 (file)
@@ -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)