Index: binaries/data/mods/public/maps/random/rmgen/RandomMap.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/RandomMap.js (revision 21929) +++ binaries/data/mods/public/maps/random/rmgen/RandomMap.js (working copy) @@ -457,21 +457,18 @@ */ RandomMap.prototype.exportTerrainTextures = function() { - let tileIndex = new Uint16Array(Math.square(this.size)); - let tilePriority = new Uint16Array(Math.square(this.size)); + // Use one u16 array. 8 bits for each + let tileData = new Uint16Array(Math.square(this.size)); for (let x = 0; x < this.size; ++x) for (let z = 0; z < this.size; ++z) { // TODO: For now just use the texture's index as priority, might want to do this another way - tileIndex[z * this.size + x] = this.texture[x][z]; - tilePriority[z * this.size + x] = this.texture[x][z]; + let val = (this.texture[x][z] << 8) | this.texture[x][z]; + tileData[z * this.size + x] = val; } - return { - "index": tileIndex, - "priority": tilePriority - }; + return tileData; }; RandomMap.prototype.ExportMap = function() Index: source/graphics/MapReader.cpp =================================================================== --- source/graphics/MapReader.cpp (revision 21929) +++ source/graphics/MapReader.cpp (working copy) @@ -1309,16 +1309,11 @@ // build tile data m_Tiles.resize(SQR(size)); - JS::RootedValue tileData(cx); - GET_TERRAIN_PROPERTY(m_MapData, tileData, &tileData) - // parse tile data object into flat arrays - std::vector tileIndex; - std::vector tilePriority; - GET_TERRAIN_PROPERTY(tileData, index, tileIndex); - GET_TERRAIN_PROPERTY(tileData, priority, tilePriority); + std::vector tileDatas; + GET_TERRAIN_PROPERTY(m_MapData, tileData, tileDatas); - ENSURE(SQR(size) == tileIndex.size() && SQR(size) == tilePriority.size()); + ENSURE(SQR(size) == tileDatas.size()); // reorder by patches and store for (size_t x = 0; x < size; ++x) @@ -1329,11 +1324,12 @@ { size_t patchY = y / PATCH_SIZE; size_t offY = y % PATCH_SIZE; + u16 tileDataValue = tileDatas[y*size + x]; STileDesc tile; - tile.m_Tex1Index = tileIndex[y*size + x]; + tile.m_Tex1Index = (tileDataValue >> 8) & 255; tile.m_Tex2Index = 0xFFFF; - tile.m_Priority = tilePriority[y*size + x]; + tile.m_Priority = tileDataValue & 255; m_Tiles[(patchY * m_PatchesPerSide + patchX) * SQR(PATCH_SIZE) + (offY * PATCH_SIZE + offX)] = tile; }