How to use readUint16 method in wpt

Best JavaScript code snippet using wpt

createMaps.js

Source:createMaps.js Github

copy

Full Screen

1var vars = require("./vars");2var fs = require("fs");3var ByteBuffer = require("bytebuffer");4var bufferRcv = new ByteBuffer(0);5var MapData = {};6var YMinMapSize = 1;7var YMaxMapSize = 100;8var XMinMapSize = 1;9var XMaxMapSize = 100;10var number = 1;11createMap(number);12function createMap(mapNumber) {13 var map = fs.createReadStream("Maps/Mapa" + mapNumber + ".map", {14 end: false15 });16 map.on("error", function(e) {17 console.log("debug -- got file read error: ", e);18 })19 .on("readable", function() {20 var buffer = map.read();21 var ByFlags;22 if (buffer) {23 bufferRcv = new ByteBuffer.wrap(buffer);24 //Versión del Mapa25 bufferRcv.readUInt16();26 //Cabeceras27 bufferRcv.readUTF8String(255);28 bufferRcv.readUint32();29 bufferRcv.readUint32();30 //Cosas al pedo31 bufferRcv.readUInt16();32 bufferRcv.readUInt16();33 bufferRcv.readUInt16();34 bufferRcv.readUInt16();35 MapData = {};36 MapData[mapNumber] = {};37 for (var y = YMinMapSize; y <= YMaxMapSize; y++) {38 MapData[mapNumber][y] = {};39 for (var x = XMinMapSize; x <= XMaxMapSize; x++) {40 MapData[mapNumber][y][x] = {};41 ByFlags = bufferRcv.readUInt8();42 if (ByFlags & 1) {43 MapData[mapNumber][y][x].blocked = 1;44 }45 MapData[mapNumber][y][x].graphics = {};46 MapData[mapNumber][y][47 x48 ].graphics[1] = bufferRcv.readUInt16();49 if (ByFlags & 2) {50 MapData[mapNumber][y][51 x52 ].graphics[2] = bufferRcv.readUInt16();53 }54 if (ByFlags & 4) {55 MapData[mapNumber][y][56 x57 ].graphics[3] = bufferRcv.readUInt16();58 }59 if (ByFlags & 8) {60 MapData[mapNumber][y][61 x62 ].graphics[4] = bufferRcv.readUInt16();63 }64 if (ByFlags & 16) {65 MapData[mapNumber][y][66 x67 ].trigger = bufferRcv.readUInt16();68 }69 }70 }71 var inf = fs.createReadStream(72 "Maps/Mapa" + mapNumber + ".inf",73 {74 end: false75 }76 );77 inf.on("error", function(e) {78 console.log("debug -- got file read error: ", e);79 })80 .on("readable", function() {81 var buffer = inf.read();82 var ByFlags;83 if (buffer) {84 bufferRcv = new ByteBuffer.wrap(buffer);85 //Cosas al pedo86 bufferRcv.readUInt16();87 bufferRcv.readUInt16();88 bufferRcv.readUInt16();89 bufferRcv.readUInt16();90 bufferRcv.readUInt16();91 //MapData[mapNumber] = {};92 //vars.infoMapData[mapNumber] = {};93 /*for (var y = YMinMapSize; y <= YMaxMapSize; y++) {94 vars.infoMapData[mapNumber][y] = {};95 for (var x = XMinMapSize; x <= XMaxMapSize; x++) {96 vars.infoMapData[mapNumber][y][x] = {};97 ByFlags = bufferRcv.readUInt8();98 if (ByFlags & 1) {99 vars.infoMapData[mapNumber][y][x].tileExit = {};100 vars.infoMapData[mapNumber][y][x].tileExit.map = bufferRcv.readUInt16();101 vars.infoMapData[mapNumber][y][x].tileExit.x = bufferRcv.readUInt16();102 vars.infoMapData[mapNumber][y][x].tileExit.y = bufferRcv.readUInt16();103 }104 if (ByFlags & 2) {105 vars.infoMapData[mapNumber][y][x].npcIndex = bufferRcv.readUInt16();106 }107 if (ByFlags & 4) {108 vars.infoMapData[mapNumber][y][x].objInfo = {};109 vars.infoMapData[mapNumber][y][x].objInfo.objIndex = bufferRcv.readUInt16();110 vars.infoMapData[mapNumber][y][x].objInfo.amount = bufferRcv.readUInt16();111 }112 }113 }*/114 for (var y = YMinMapSize; y <= YMaxMapSize; y++) {115 //MapData[mapNumber][y] = {};116 for (117 var x = XMinMapSize;118 x <= XMaxMapSize;119 x++120 ) {121 //MapData[mapNumber][y][x] = {};122 ByFlags = bufferRcv.readUInt8();123 if (ByFlags & 1) {124 MapData[mapNumber][y][x].tileExit = {};125 MapData[mapNumber][y][126 x127 ].tileExit.map = bufferRcv.readUInt16();128 MapData[mapNumber][y][129 x130 ].tileExit.x = bufferRcv.readUInt16();131 MapData[mapNumber][y][132 x133 ].tileExit.y = bufferRcv.readUInt16();134 }135 if (ByFlags & 2) {136 MapData[mapNumber][y][137 x138 ].npcIndex = bufferRcv.readUInt16();139 }140 if (ByFlags & 4) {141 MapData[mapNumber][y][x].objInfo = {};142 MapData[mapNumber][y][143 x144 ].objInfo.objIndex = bufferRcv.readUInt16();145 MapData[mapNumber][y][146 x147 ].objInfo.amount = bufferRcv.readUInt16();148 }149 }150 }151 //console.log(JSON.stringify(MapData));152 }153 })154 .on("end", function() {155 fs.writeFile(156 "mapas/mapa_" + mapNumber + ".map",157 JSON.stringify(MapData),158 function(err) {159 if (err) return console.log(err);160 console.log("Mapa" + mapNumber + " creado.");161 }162 );163 if (number < 290) {164 number++;165 createMap(number);166 }167 //process.exit(1);168 });169 //console.log(JSON.stringify(MapData));170 }171 })172 .on("end", function() {173 //process.exit(1);174 });...

Full Screen

Full Screen

zsc.js

Source:zsc.js Github

copy

Full Screen

...130 ROSELoader.load(path, function(/** BinaryReader */rh) {131 var i, j, meshes, materials, effects, models;132 var data = new ModelList();133134 meshes = rh.readUint16();135 for (i = 0; i < meshes; ++i) {136 data.meshes.push(rh.readStr());137 }138139 materials = rh.readUint16();140 for (i = 0; i < materials; ++i) {141 var material = new ModelList.Material();142 material.texturePath = rh.readStr();143 material.forSkinning = rh.readUint16() !== 0;144 material.alphaEnabled = rh.readUint16() !== 0;145 material.twoSided = rh.readUint16() !== 0;146 material.alphaTestEnabled = rh.readUint16() !== 0;147 material.alphaRef = rh.readUint16();148 material.depthTestEnabled = rh.readUint16() !== 0;149 material.depthWriteEnabled = rh.readUint16() !== 0;150 material.blendType = rh.readUint16();151 material.useSpecular = rh.readUint16() !== 0;152 material.alpha = rh.readFloat();153 material.glowType = rh.readUint16();154 material.glowColour = rh.readColour();155 data.materials.push(material);156 }157158 effects = rh.readUint16();159 for (i = 0; i < effects; ++i) {160 data.effects.push(rh.readStr());161 }162163 models = rh.readUint16();164 for (i = 0; i < models; ++i) {165 var model, parts, effects, type, size;166167 rh.skip(3*4); // Bounding cylinder168 parts = rh.readUint16();169170 if (parts > 0) {171 model = new ModelList.Model();172173 for (j = 0; j < parts; ++j) {174 var part = new ModelList.Model.Part();175 part.meshIdx = rh.readUint16();176 part.materialIdx = rh.readUint16();177178 while ((type = rh.readUint8()) != 0) {179 size = rh.readUint8();180181 switch (type) {182 case ModelList.PROPERTY_TYPE.POSITION:183 part.position = rh.readVector3().multiplyScalar(ZZ_SCALE_IN);184 break;185 case ModelList.PROPERTY_TYPE.ROTATION:186 part.rotation = rh.readQuatwxyz();187 break;188 case ModelList.PROPERTY_TYPE.SCALE:189 part.scale = rh.readVector3();190 break;191 case ModelList.PROPERTY_TYPE.PARENT:192 part.parent = rh.readUint16();193 break;194 case ModelList.PROPERTY_TYPE.AXIS_ROTATION:195 part.axisRotation = rh.readQuatwxyz();196 break;197 case ModelList.PROPERTY_TYPE.COLLISION:198 part.collisionMode = rh.readUint16();199 break;200 case ModelList.PROPERTY_TYPE.CONSTANT_ANIMATION:201 part.animPath = rh.readStrLen(size);202 break;203 case ModelList.PROPERTY_TYPE.VISIBLE_RANGE_SET:204 part.visibleRangeSet = rh.readUint16();205 break;206 case ModelList.PROPERTY_TYPE.USE_LIGHTMAP:207 part.useLightmap = !!rh.readUint16();208 break;209 case ModelList.PROPERTY_TYPE.BONE_INDEX:210 part.boneIndex = rh.readUint16();211 break;212 case ModelList.PROPERTY_TYPE.DUMMY_INDEX:213 part.dummyIndex = rh.readUint16();214 break;215 default:216 console.log('Skipping unknown ZSC model part property type ' + type);217 rh.skip(size);218 }219 }220221 model.parts.push(part);222 }223224 effects = rh.readUint16();225 for (j = 0; j < effects; ++j) {226 var effect = new ModelList.Model.Effect();227 effect.effectIdx = rh.readUint16();228 effect.type = rh.readUint16();229230 while ((type = rh.readUint8()) != 0) {231 size = rh.readUint8();232233 switch (type) {234 case ModelList.PROPERTY_TYPE.POSITION:235 effect.position = rh.readVector3().multiplyScalar(ZZ_SCALE_IN);236 break;237 case ModelList.PROPERTY_TYPE.ROTATION:238 effect.rotation = rh.readQuatwxyz();239 break;240 case ModelList.PROPERTY_TYPE.SCALE:241 effect.scale = rh.readVector3();242 break;243 case ModelList.PROPERTY_TYPE.PARENT:244 effect.parent = rh.readUint16();245 break;246 default:247 console.log('Skipping unknown ZSC model effect property type ' + type);248 rh.skip(size);249 }250 }251252 model.effects.push(effect);253 }254255 // Confirmed to be laughably invalid.256 rh.skip(2 * 3 * 4); // Bounding box257 } else {258 model = null; ...

Full Screen

Full Screen

chr.js

Source:chr.js Github

copy

Full Screen

...50 ROSELoader.load(path, function (/** BinaryReader */rh) {51 var characters, count, i, j;52 var data = new CharacterList();5354 count = rh.readUint16();55 for (i = 0; i < count; ++i) {56 data.skeletons.push(rh.readStr());57 }5859 count = rh.readUint16();60 for (i = 0; i < count; ++i) {61 data.animations.push(rh.readStr());62 }6364 count = rh.readUint16();65 for (i = 0; i < count; ++i) {66 data.effects.push(rh.readStr());67 }6869 characters = rh.readUint16();70 for (i = 0; i < characters; ++i) {71 var character = null;7273 if (!!rh.readUint8()) {74 character = new CharacterList.Character();75 character.skeletonIdx = rh.readUint16();76 character.name = rh.readStr();7778 count = rh.readUint16();79 for (j = 0; j < count; ++j) {80 character.models.push(rh.readUint16());81 }8283 count = rh.readUint16();84 for (j = 0; j < count; ++j) {85 var type = rh.readUint16();86 character.animations[type] = rh.readUint16();87 }8889 count = rh.readUint16();90 for (j = 0; j < count; ++j) {91 var effect = new CharacterList.Character.Effect();92 effect.boneIdx = rh.readUint16();93 effect.effectIdx = rh.readUint16();94 character.effects.push(effect);95 }96 }9798 data.characters.push(character);99 }100101 callback(data);102 });103};104 ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var fs = require('fs');3fs.readFile('test.wpt', function (err, data) {4 if (err) throw err;5 console.log(wpt.readUint16(data, 0));6});7exports.readUint16 = function (data, offset) {8 return data.readUInt16LE(offset);9};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var buf = new Buffer(1000);4var fd = fs.openSync('test.txt', 'r');5fs.readSync(fd, buf, 0, 1000, 0);6var val = wptools.readUint16(buf, 0);7console.log(val);8var wptools = require('wptools');9var fs = require('fs');10var buf = new Buffer(1000);11var fd = fs.openSync('test.txt', 'r');12fs.readSync(fd, buf, 0, 1000, 0);13var val = wptools.readUint16(buf, 0);14console.log(val);15var wptools = require('wptools');16var fs = require('fs');17var buf = new Buffer(1000);18var fd = fs.openSync('test.txt', 'r');19fs.readSync(fd, buf, 0, 1000, 0);20var val = wptools.readUint16(buf, 0);21console.log(val);22var wptools = require('wptools');23var fs = require('fs');24var buf = new Buffer(1000);25var fd = fs.openSync('test.txt', 'r');26fs.readSync(fd, buf, 0, 1000, 0);27var val = wptools.readUint16(buf, 0);28console.log(val);29var wptools = require('wptools');30var fs = require('fs');31var buf = new Buffer(1000);32var fd = fs.openSync('test.txt', 'r');33fs.readSync(fd, buf, 0, 1000, 0);34var val = wptools.readUint16(buf, 0);35console.log(val);36var wptools = require('wptools');37var fs = require('fs');38var buf = new Buffer(1000);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var data = fs.readFileSync('test.dat');4var buf = new Buffer(data);5var result = wptools.readUint16(buf, 0);6console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptc = require('wptc');2var wptcObj = new wptc();3var buf = new Buffer(2);4buf.writeUInt16BE(0x1234, 0);5var val = wptcObj.readUint16(buf, 0);6console.log(val);7var wptc = function() {8}9wptc.prototype.readUint16 = function(buf, offset) {10 return buf.readUInt16BE(offset);11}12module.exports = wptc;13describe('wptc', function() {14 var wptc = require('wptc');15 var wptcObj = new wptc();16 var buf = new Buffer(2);17 buf.writeUInt16BE(0x1234, 0);18 var val = wptcObj.readUint16(buf, 0);19 it('should return 4660', function() {20 expect(val).toBe(4660);21 });22});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wptObj = new wpt();3wptObj.readUint16(0, function (err, data) {4 console.log(data);5});6var wpt = function() {};7wpt.prototype.readUint16 = function (addr, callback) {8 var data = 0x1234;9 callback(null, data);10};11module.exports = wpt;12var wpt = require('wpt');13var wptObj = new wpt();14wptObj.readUint16(0, callback);15function callback(err, data) {16 console.log(data);17}18var wpt = function() {};19wpt.prototype.readUint16 = function (addr, callback) {20 var data = 0x1234;21 callback(null, data);22};23module.exports = wpt;24var wpt = require('wpt');25var wptObj = new wpt();26wptObj.readUint16(0, callback);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var data = fs.readFileSync('test.dat');4var buf = new Buffer(data);5var obj = wptools.readUint16(buf, 0);6console.log(obj);7wptools.readUint16(buf, 0);8wptools.readUint16(buf, 0, true);9wptools.readUint16(buf, 0, false);10wptools.readUint16(buf, 0, 'big');11wptools.readUint16(buf, 0, 'little');12wptools.readUint16(buf, 0, 'invalid');13wptools.readUint16(buf, 0, 1);14wptools.readUint16(buf, 0, true, 'invalid');15wptools.readUint16(buf, 0, true, 1);16wptools.readUint16(buf, 0, true, 'big');17wptools.readUint16(buf, 0, true, 'little');18wptools.readUint16(buf, 0, false, 'invalid');19wptools.readUint16(buf, 0, false, 1);20wptools.readUint16(buf, 0, false, 'big');21wptools.readUint16(buf, 0, false,

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new WebPT();2var uint16 = wpt.readUint16(0x0);3console.log(uint16);4var wpt = new WebPT();5var uint16 = wpt.readUint16(0x0);6console.log(uint16);7var wpt = new WebPT();8var uint16 = wpt.readUint16(0x0);9console.log(uint16);10var wpt = new WebPT();11var uint16 = wpt.readUint16(0x0);12console.log(uint16);13var wpt = new WebPT();14var uint16 = wpt.readUint16(0x0);15console.log(uint16);16var wpt = new WebPT();17var uint16 = wpt.readUint16(0x0);18console.log(uint16);19var wpt = new WebPT();20var uint16 = wpt.readUint16(0x0);21console.log(uint16);22var wpt = new WebPT();23var uint16 = wpt.readUint16(0x0);24console.log(uint16);25var wpt = new WebPT();26var uint16 = wpt.readUint16(0x0);27console.log(uint16);28var wpt = new WebPT();29var uint16 = wpt.readUint16(0x0);30console.log(uint16);31var wpt = new WebPT();32var uint16 = wpt.readUint16(0x0);33console.log(uint16);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful