Avoid calling random for phenotype to avoid OOS
Using the same random generator as for the simulation for previewing leads to out-of-sync of the random generator with other clients. This is a quick fix, in the long run one might want to provide an other random generator for non simulation tasks. The patch by elexis was attached by Vladislav to issue #6888 Patch-by: elexis Closes: #6888 Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
9c72741e69
commit
fe78ee12a5
@ -92,7 +92,12 @@ Identity.prototype.Init = function()
|
|||||||
this.classesList = GetIdentityClasses(this.template);
|
this.classesList = GetIdentityClasses(this.template);
|
||||||
this.visibleClassesList = GetVisibleIdentityClasses(this.template);
|
this.visibleClassesList = GetVisibleIdentityClasses(this.template);
|
||||||
if (this.template.Phenotype)
|
if (this.template.Phenotype)
|
||||||
this.phenotype = pickRandom(this.GetPossiblePhenotypes());
|
{
|
||||||
|
const phenotypes = this.GetPossiblePhenotypes();
|
||||||
|
|
||||||
|
// Avoid calling Math.random to avoid out of sync RNG caused by preview entities
|
||||||
|
this.phenotype = phenotypes[this.entity % phenotypes.length];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
this.phenotype = "default";
|
this.phenotype = "default";
|
||||||
|
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
<Entity filtered="">
|
<Entity filtered="">
|
||||||
<!-- We only want to include components which are necessary (for the visual previewing of an entity)
|
<!-- We only want to include components which are necessary (for the visual previewing of an entity)
|
||||||
and safe (i.e. won't do anything that affects the synchronised simulation state), so additions
|
and safe (i.e. won't do anything that affects the synchronised simulation state), so additions
|
||||||
to this list should be carefully considered -->
|
to this list should be carefully considered.
|
||||||
|
|
||||||
|
Any Init function of any component listed here may not call Math.random, otherwise the RNG state
|
||||||
|
would become out of sync with the RNG state of the other clients.
|
||||||
|
-->
|
||||||
<!-- Attack is needed for the Actor Viewer and attack range overlay -->
|
<!-- Attack is needed for the Actor Viewer and attack range overlay -->
|
||||||
<Attack merge=""/>
|
<Attack merge=""/>
|
||||||
<BuildRestrictions merge=""/>
|
<BuildRestrictions merge=""/>
|
||||||
|
Loading…
Reference in New Issue
Block a user