Ticket #4294: retry_simplegroups_v1.patch

File retry_simplegroups_v1.patch, 3.6 KB (added by elexis, 7 years ago)
  • binaries/data/mods/public/maps/random/guadalquivir_river.js

    commit d356b8a1ac8729945be0467ca3f4bd56696b4cac
    Author: elexis <elexis1@users.noreply.github.com>
    Date:   Wed Oct 26 14:28:53 2016 +0200
    
        Fix a serious map placement bug that for example caused latium to have nearly no metal and corinthian isthmus to have very few fish.
        
        Reason being the place functions of SimpleGroup and RandomGroup not returning an array with the results but only a boolean.
        For the createObjectGroup function that wasn't needed (because the objects were placed in the place group, contrary to other placer prototypes),
        but createObjectGroups and createObjectGroupsByAreas would parse the returned false by these two affected placer prototypes as a success (!== undefined), thus abort placing early.
    
    diff --git a/binaries/data/mods/public/maps/random/guadalquivir_river.js b/binaries/data/mods/public/maps/random/guadalquivir_river.js
    index 005e70c..88ce089 100644
    a b createDecoration  
    364364  [new SimpleObject(aLillies, 1,2, 0,1)]
    365365 ],
    366366 [
    367   scaleByMapSize(800, 12800),
    368   scaleByMapSize(800, 12800)
     367  scaleByMapSize(750, 1500),
     368  scaleByMapSize(750, 1500)
    369369 ],
    370370 stayClasses(clShallow, 0)
    371371);
    createFood  
    405405  [new SimpleObject(oFish, 2,3, 0,2)]
    406406 ],
    407407 [
    408   25 * numPlayers
     408  scaleByMapSize(10, 50)
    409409 ],
    410  avoidClasses(clLand, 2, clRiver, 1)
     410 avoidClasses(clLand, 2, clRiver, 1, clFood, 12)
    411411);
    412412
    413413RMS.SetProgress(85);
  • binaries/data/mods/public/maps/random/rmgen/placer.js

    diff --git a/binaries/data/mods/public/maps/random/rmgen/placer.js b/binaries/data/mods/public/maps/random/rmgen/placer.js
    index 41e8a83..4a87d8f 100644
    a b SimpleGroup.prototype.place = function(player, constraint)  
    527527        var objs = element.place(this.x, this.z, player, this.avoidSelf, constraint);
    528528
    529529        if (objs === undefined)
    530             return false;
     530            return undefined;
    531531
    532532        resultObjs = resultObjs.concat(objs);
    533533    }
    SimpleGroup.prototype.place = function(player, constraint)  
    543543            this.tileClass.add(Math.floor(obj.position.x/CELL_SIZE), Math.floor(obj.position.z/CELL_SIZE));
    544544    }
    545545
    546     return true;
     546    return resultObjs;
    547547};
    548548
    549549/////////////////////////////////////////////////////////////////////////////////////////
    RandomGroup.prototype.place = function(player, constraint)  
    574574
    575575    var resultObjs = placer.place(this.x, this.z, player, this.avoidSelf, constraint);
    576576    if (resultObjs === undefined)
    577         return false;
     577        return undefined;
    578578
    579579    // Add placed objects to map
    580580    for (let obj of resultObjs)
    RandomGroup.prototype.place = function(player, constraint)  
    586586            this.tileClass.add(Math.floor(obj.position.x/CELL_SIZE), Math.floor(obj.position.z/CELL_SIZE));
    587587    }
    588588
    589     return true;
     589    return resultObjs;
    590590};
  • binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js

    diff --git a/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js b/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js
    index 869add6..bd107ca 100644
    a b function createForests(terrainset, constraint, tileclass, numMultiplier, biomeID  
    9898    {
    9999        var MIN_TREES = 1000 * numMultiplier;
    100100        var MAX_TREES = 6000 * numMultiplier;
    101         var P_FOREST = 0.52;
     101        var P_FOREST = 0.75;
    102102    }
    103103    else
    104104    {
    105105        var MIN_TREES = 500 * numMultiplier;
    106106        var MAX_TREES = 3000 * numMultiplier;
    107         var P_FOREST = 0.7;
     107        var P_FOREST = 0.85;
    108108    }
    109109    var totalTrees = scaleByMapSize(MIN_TREES, MAX_TREES);
    110110    var numForest = totalTrees * P_FOREST;