Welcome! Share code as fast as possible.
- Use the language picker to change the language manually.
- The previous link will get modified. You can then share this new link with others.
- Visit
https://code-dump.vercel.app/<extension>
- For example, to create a link which for a JavaScript code you will visit
https://code-dump.vercel.app/js
Any link generated does not have an expiry.
GitHub
// @ts-nocheck
// This script parses EU.rws, finds tileTemperatureDeflate, inflates its content, and prints it.
import * as fs from 'fs';
import * as xml2js from 'xml2js';
import * as zlib from 'zlib';
// Path to the XML file
const xmlFile = __dirname + '/EU.rws';
// Read the entire file
fs.readFile(xmlFile, 'utf8', (err, data) => {
if (err) {
console.error('Error reading file:', err);
return;
}
// Parse the XML
xml2js.parseString(data, (err, result) => {
if (err) {
console.error('Error parsing XML:', err);
return;
}
// Find the tileTemperatureDeflate element
fs.writeFileSync('result.json', JSON.stringify(result, null, 2));
const tileTempDeflate = result.savegame.world[0].grid[0].tileTemperatureDeflate[0];
fs.writeFileSync('tileTempDeflate.json', tileTempDeflate);
if (!tileTempDeflate) {
console.error('tileTemperatureDeflate element not found');
return;
}
// Extract the deflated data (assuming it's the first element's text)
const deflatedData = tileTempDeflate as string;
// Try to decode and inflate the data
try {
// If the data is base64-encoded zlib, decode and inflate
const buffer = Buffer.from(deflatedData, 'base64');
// Try multiple decompression methods
const methods = [
{ name: 'inflate', fn: zlib.inflate },
{ name: 'inflateRaw', fn: zlib.inflateRaw },
{ name: 'gunzip', fn: zlib.gunzip },
{ name: 'unzip', fn: zlib.unzip }
];
methods.forEach(method => {
method.fn(buffer, (err, result) => {
if (err) {
console.error(`Failed to ${method.name}:`, err);
} else {
fs.writeFileSync(`${method.name}Result.json`, result.toString('utf8'));
}
});
});
} catch (e) {
console.error('Error decoding or inflating:', e);
}
});
});