Ticket #6888: simple_fix.diff

File simple_fix.diff, 1.8 KB (added by Vladislav Belov, 3 months ago)

Patch by elexis to fix the preview bug

  • binaries/data/mods/public/simulation/components/Identity.js

    diff --git a/binaries/data/mods/public/simulation/components/Identity.js b/binaries/data/mods/public/simulation/components/Identity.js
    index f2ebd7568e..b7f72a34e0 100644
    a b Identity.prototype.Init = function()  
    9292    this.classesList = GetIdentityClasses(this.template);
    9393    this.visibleClassesList = GetVisibleIdentityClasses(this.template);
    9494    if (this.template.Phenotype)
    95         this.phenotype = pickRandom(this.GetPossiblePhenotypes());
     95    {
     96        const phenotypes = this.GetPossiblePhenotypes();
     97
     98        // Avoid calling Math.random to avoid out of sync RNG caused by preview entities
     99        this.phenotype = phenotypes[this.entity % phenotypes.length];
     100    }
    96101    else
    97102        this.phenotype = "default";
    98103
  • binaries/data/mods/public/simulation/templates/special/filter/preview.xml

    diff --git a/binaries/data/mods/public/simulation/templates/special/filter/preview.xml b/binaries/data/mods/public/simulation/templates/special/filter/preview.xml
    index 53984d80c9..dc07f5b76a 100644
    a b  
    22<Entity filtered="">
    33  <!-- We only want to include components which are necessary (for the visual previewing of an entity)
    44       and safe (i.e. won't do anything that affects the synchronised simulation state), so additions
    5        to this list should be carefully considered -->
     5       to this list should be carefully considered.
     6
     7       Any Init function of any component listed here may not call Math.random, otherwise the RNG state
     8       would become out of sync with the RNG state of the other clients.
     9  -->
    610  <!-- Attack is needed for the Actor Viewer and attack range overlay -->
    711  <Attack merge=""/>
    812  <BuildRestrictions merge=""/>