This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9882 for ps


Ignore:
Timestamp:
07/19/11 10:52:17 (13 years ago)
Author:
ben
Message:

Removes hacks for typed array initialization

Location:
ps/trunk/binaries/data/mods/public/maps/random/rmgen
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/maps/random/rmgen/map.js

    r9725 r9882  
    2121    for (var i = 0; i < size; i++)
    2222    {
    23         this.texture[i] = new Uint16Array(Math.floor(size));    // uint16 - texture IDs // HACK: typed arrays require integer arguments
     23        this.texture[i] = new Uint16Array(size);    // uint16 - texture IDs
    2424        this.terrainObjects[i] = new Array(size);               // array of entities
    25         this.area[i] = new Uint16Array(Math.floor(size));       // uint16 - area IDs    // HACK: typed arrays require integer arguments
     25        this.area[i] = new Uint16Array(size);       // uint16 - area IDs
    2626       
    2727        for (var j = 0; j < size; j++)
     
    3636    for (var i = 0; i < mapSize; i++)
    3737    {
    38         this.height[i] = new Float32Array(Math.floor(mapSize));     // float32  // HACK: typed arrays require integer arguments
     38        this.height[i] = new Float32Array(mapSize);     // float32
    3939       
    4040        for (var j = 0; j < mapSize; j++)
     
    9898    if (g_MapSettings.CircularMap)
    9999    {   // Within map circle
    100         var halfSize = 0.5*this.size;
     100        var halfSize = Math.floor(0.5*this.size);
    101101        var dx = (x - halfSize);
    102102        var dz = (z - halfSize);
    103         return Math.sqrt(dx*dx + dz*dz) < (halfSize - 1.5);
     103        return Math.round(Math.sqrt(dx*dx + dz*dz)) < halfSize;
    104104    }
    105105    else
     
    301301    //  Flat because it's easier to handle by the engine
    302302    var mapSize = size+1;
    303     var height16 = new Uint16Array(Math.floor(mapSize*mapSize));    // uint16   // HACK: typed arrays require integer arguments
     303    var height16 = new Uint16Array(mapSize*mapSize);    // uint16
    304304    for (var x = 0; x < mapSize; x++)
    305305    {
     
    333333   
    334334    //  Convert 2D tile data to flat array
    335     var tileIndex = new Uint16Array(Math.floor(size*size));     // uint16   // HACK: typed arrays require integer arguments
    336     var tilePriority = new Uint16Array(Math.floor(size*size));  // uint16   // HACK: typed arrays require integer arguments
     335    var tileIndex = new Uint16Array(size*size);     // uint16
     336    var tilePriority = new Uint16Array(size*size);  // uint16
    337337    for (var x = 0; x < size; x++)
    338338    {
  • ps/trunk/binaries/data/mods/public/maps/random/rmgen/painter.js

    r9435 r9882  
    7070    for (var i = 0; i < size; ++i)
    7171    {
    72         saw[i] = new Uint8Array(Math.floor(size));      // bool / uint8 // HACK: typed arrays require integer arguments
    73         dist[i] = new Uint16Array(Math.floor(size));    // uint16   // HACK: typed arrays require integer arguments
     72        saw[i] = new Uint8Array(size);      // bool / uint8
     73        dist[i] = new Uint16Array(size);    // uint16
    7474    }
    7575
     
    222222    for (var i = 0; i < mapSize; ++i)
    223223    {
    224         saw[i] = new Uint8Array(Math.floor(mapSize));           // bool / uint8 // HACK: typed arrays require integer arguments
    225         dist[i] = new Uint16Array(Math.floor(mapSize));         // uint16   // HACK: typed arrays require integer arguments
    226         gotHeightPt[i] = new Uint8Array(Math.floor(mapSize));   // bool / uint8 // HACK: typed arrays require integer arguments
    227         newHeight[i] = new Float32Array(Math.floor(mapSize));   // float32  // HACK: typed arrays require integer arguments
     224        saw[i] = new Uint8Array(mapSize);           // bool / uint8
     225        dist[i] = new Uint16Array(mapSize);         // uint16
     226        gotHeightPt[i] = new Uint8Array(mapSize);   // bool / uint8
     227        newHeight[i] = new Float32Array(mapSize);   // float32
    228228    }
    229229   
  • ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer.js

    r9435 r9882  
    3636    for (var i = 0; i < size; ++i)
    3737    {
    38         gotRet[i] = new Uint8Array(Math.floor(size));           // bool / uint8 // HACK: typed arrays require integer arguments
     38        gotRet[i] = new Uint8Array(size);           // bool / uint8
    3939    }
    4040   
     
    5050    }
    5151   
    52     var noise = new Float32Array(Math.floor(intPerim));         //float32   // HACK: typed arrays require integer arguments
    53     var ctrlCoords = new Float32Array(Math.floor(ctrlPts+1));   //float32   // HACK: typed arrays require integer arguments
    54     var ctrlVals = new Float32Array(Math.floor(ctrlPts+1));     //float32   // HACK: typed arrays require integer arguments
     52    var noise = new Float32Array(intPerim);         //float32
     53    var ctrlCoords = new Float32Array(ctrlPts+1);   //float32
     54    var ctrlVals = new Float32Array(ctrlPts+1);     //float32
    5555
    5656    // Generate some interpolated noise
  • ps/trunk/binaries/data/mods/public/maps/random/rmgen/tileclass.js

    r9435 r9882  
    1414    }
    1515   
    16     this.vals = new Int16Array(Math.floor(2*this.nn));  // int16    // HACK: typed arrays require integer arguments
     16    this.vals = new Int16Array(2*this.nn);  // int16
    1717}
    1818
     
    7979    for (var i=0; i < size; ++i)
    8080    {
    81         this.inclusionCount[i] = new Int16Array(Math.floor(size)); //int16  // HACK: typed arrays require integer arguments
     81        this.inclusionCount[i] = new Int16Array(size); //int16
    8282        this.rangeCount[i] = new RangeOp(size);
    8383    }
Note: See TracChangeset for help on using the changeset viewer.