X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Flib%2Frandom.qc;h=a5ff69356a21f516ba290bac01761eac2a7cce88;hp=aff961c55da56b9dcde016c90335dbee7026d5e9;hb=243779445dc4a2c35354ecd17d304f62c1547a7b;hpb=c741e6b3f012aa525f23e1df30d1d933b383fbc5 diff --git a/qcsrc/lib/random.qc b/qcsrc/lib/random.qc index aff961c55..a5ff69356 100644 --- a/qcsrc/lib/random.qc +++ b/qcsrc/lib/random.qc @@ -1,5 +1,6 @@ #include "random.qh" +ERASEABLE void RandomSelection_Init() { RandomSelection_totalweight = 0; @@ -9,7 +10,8 @@ void RandomSelection_Init() RandomSelection_best_priority = -1; } -void RandomSelection_Add(entity e, float f, string s, float weight, float priority) +ERASEABLE +void RandomSelection_Add(entity e, float f, string s, vector v, float weight, float priority) { if (priority > RandomSelection_best_priority) { @@ -17,6 +19,7 @@ void RandomSelection_Add(entity e, float f, string s, float weight, float priori RandomSelection_chosen_ent = e; RandomSelection_chosen_float = f; RandomSelection_chosen_string = s; + RandomSelection_chosen_vec = v; RandomSelection_totalweight = weight; } else if (priority == RandomSelection_best_priority) @@ -27,6 +30,7 @@ void RandomSelection_Add(entity e, float f, string s, float weight, float priori RandomSelection_chosen_ent = e; RandomSelection_chosen_float = f; RandomSelection_chosen_string = s; + RandomSelection_chosen_vec = v; } } } @@ -34,18 +38,19 @@ void RandomSelection_Add(entity e, float f, string s, float weight, float priori float DistributeEvenly_amount; float DistributeEvenly_totalweight; +ERASEABLE void DistributeEvenly_Init(float amount, float totalweight) { if (DistributeEvenly_amount) { - LOG_TRACE("DistributeEvenly_Init: UNFINISHED DISTRIBUTION (", ftos(DistributeEvenly_amount), " for "); - LOG_TRACE(ftos(DistributeEvenly_totalweight), " left!)\n"); + LOG_TRACE("DistributeEvenly_Init: UNFINISHED DISTRIBUTION (", ftos(DistributeEvenly_amount), " for ", ftos(DistributeEvenly_totalweight), " left!)"); } if (totalweight == 0) DistributeEvenly_amount = 0; else DistributeEvenly_amount = amount; DistributeEvenly_totalweight = totalweight; } +ERASEABLE float DistributeEvenly_Get(float weight) { float f; @@ -56,6 +61,7 @@ float DistributeEvenly_Get(float weight) return f; } +ERASEABLE float DistributeEvenly_GetRandomized(float weight) { float f; @@ -69,6 +75,7 @@ float DistributeEvenly_GetRandomized(float weight) // from the GNU Scientific Library float gsl_ran_gaussian_lastvalue; float gsl_ran_gaussian_lastvalue_set; +ERASEABLE float gsl_ran_gaussian(float sigma) { if (gsl_ran_gaussian_lastvalue_set) @@ -97,7 +104,7 @@ float gsl_ran_gaussian(float sigma) prandom_seed = c; #ifdef USE_PRANDOM_DEBUG - LOG_TRACE("RANDOM -> ", ftos(c), "\n"); + LOG_TRACE("RANDOM -> ", ftos(c)); #endif return c / 65536; // in [0..1[ @@ -122,14 +129,14 @@ float gsl_ran_gaussian(float sigma) { prandom_seed = seed; #ifdef USE_PRANDOM_DEBUG - LOG_TRACE("SRANDOM ", ftos(seed), "\n"); + LOG_TRACE("SRANDOM ", ftos(seed)); #endif } #ifdef USE_PRANDOM_DEBUG void prandom_debug() { - LOG_TRACE("Current random seed = ", ftos(prandom_seed), "\n"); + LOG_TRACE("Current random seed = ", ftos(prandom_seed)); } #endif #endif