Skip to content

Commit

Permalink
Rebase scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
njibhu committed Dec 7, 2020
1 parent 67d99c0 commit aaca99a
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 256 deletions.
64 changes: 0 additions & 64 deletions examples/src/Cntc/cntc_iterate_all.html

This file was deleted.

55 changes: 0 additions & 55 deletions examples/src/Cntc/cntc_parse.html

This file was deleted.

54 changes: 0 additions & 54 deletions examples/src/Cntc/cntc_parse_items.html

This file was deleted.

83 changes: 0 additions & 83 deletions examples/src/Cntc/cntc_tests.html

This file was deleted.

63 changes: 63 additions & 0 deletions experiments/src/cntc_iterate_all.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<html>
<head>
<title>cntc chunk analysis</title>
<meta content="" />
<style></style>
</head>

<body>
<label>
<input id="filePicker" type="file" />
</label>
<script src="./static/jquery.js"></script>
<script src="./static/DataStream.js"></script>
<script src="./static/T3D.js"></script>
<script>
var _lr;
$("#filePicker").change(function (evt) {
var file = evt.target.files[0];
T3D.getLocalReader(
file,
async function (lr) {
_lr = lr;
res = await lr.readFileList();
console.log("Sorting the files");

//Get the cntc files
let myFiles = res.filter((i) => {
return i.fileType == "PF_cntc" && i.baseIdList[0] < 1000000;
});

let cntcTypes = {};

console.log("Work:");
let fileWork = 0;
for (let elt of myFiles) {
console.log((fileWork += 1));
let r = await lr.readFile(elt.mftId);
let file = new T3D.GW2File(new DataStream(r.buffer), 0);
let mainChunk = file.getChunk("Main").data;

for (let entry of mainChunk.indexEntries) {
if (!cntcTypes[entry.type]) {
cntcTypes[entry.type] = {
amount: 0,
flagged: {},
};
}

cntcTypes[entry.type].amount += 1;
cntcTypes[entry.type].flagged[elt.baseIdList[0]]
? (cntcTypes[entry.type].flagged[elt.baseIdList[0]] += 1)
: (cntcTypes[entry.type].flagged[elt.baseIdList[0]] = 1);
}
}

console.log(cntcTypes);
},
"./static/t3dworker.js"
);
});
</script>
</body>
</html>
54 changes: 54 additions & 0 deletions experiments/src/cntc_parse.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<html>
<head>
<title>cntc chunk analysis</title>
<meta content="" />
<style></style>
</head>

<body>
<label>
<input id="filePicker" type="file" />
</label>
<script src="./static/jquery.js"></script>
<script src="./static/DataStream.js"></script>
<script src="./static/T3D.js"></script>
<script>
var lr;
$("#filePicker").change(function (evt) {
var file = evt.target.files[0];
T3D.getLocalReader(
file,
async function (lr) {
//We target a specific file:
const cntcFile = 473992;

let archiveFile = await lr.readFile(cntcFile, false, false, undefined, undefined, true);
let file = new T3D.GW2File(new DataStream(archiveFile.buffer), 0);
let mainChunk = file.getChunk("Main").data;

console.log("File loaded");

let entryArray = [];

const entriesAmount = mainChunk.indexEntries.length;
for (let i = 0; i < entriesAmount; i++) {
let begin = mainChunk.indexEntries[i].offset;
let end = mainChunk.indexEntries[i + 1] ? mainChunk.indexEntries[i + 1].offset : mainChunk.content.length;
let contentSlice = mainChunk.content.slice(begin, end);
let entry = {
type: mainChunk.indexEntries[i].type,
rootIndex: mainChunk.indexEntries[i].rootIndex,
namespaceIndex: mainChunk.indexEntries[i].namespaceIndex,
contentSlice: contentSlice,
};
entryArray.push(entry);
}

console.log(entryArray);
},
"./static/t3dworker.js"
);
});
</script>
</body>
</html>
Loading

0 comments on commit aaca99a

Please sign in to comment.