mirror of
https://github.com/billsonnn/nitro-converter.git
synced 2024-11-22 15:40:52 +01:00
More updates
This commit is contained in:
parent
4def01225f
commit
39dcab0600
@ -36,10 +36,19 @@ export class EffectConverter extends SWFConverter
|
||||
{
|
||||
await this._effectDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF, className: string) =>
|
||||
{
|
||||
spinner.text = 'Parsing Effect: ' + habboAssetSwf.getDocumentClass();
|
||||
if(!habboAssetSwf)
|
||||
{
|
||||
spinner.text = 'Couldnt convert effect: ' + className;
|
||||
}
|
||||
else
|
||||
{
|
||||
spinner.text = 'Parsing Effect: ' + habboAssetSwf.getDocumentClass();
|
||||
}
|
||||
|
||||
spinner.render();
|
||||
|
||||
if(!habboAssetSwf) return;
|
||||
|
||||
const spriteBundle = await this._bundleProvider.generateSpriteSheet(habboAssetSwf);
|
||||
const assetData = await this.mapXML2JSON(habboAssetSwf, className);
|
||||
|
||||
|
@ -36,10 +36,19 @@ export class FigureConverter extends SWFConverter
|
||||
{
|
||||
await this._figureDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF, className: string) =>
|
||||
{
|
||||
spinner.text = 'Parsing Figure: ' + habboAssetSwf.getDocumentClass();
|
||||
if(!habboAssetSwf)
|
||||
{
|
||||
spinner.text = 'Couldnt convert figure: ' + className;
|
||||
}
|
||||
else
|
||||
{
|
||||
spinner.text = 'Parsing Figure: ' + habboAssetSwf.getDocumentClass();
|
||||
}
|
||||
|
||||
spinner.render();
|
||||
|
||||
if(!habboAssetSwf) return;
|
||||
|
||||
const spriteBundle = await this._bundleProvider.generateSpriteSheet(habboAssetSwf);
|
||||
const assetData = await this.mapXML2JSON(habboAssetSwf, className);
|
||||
|
||||
|
@ -36,12 +36,21 @@ export class FurnitureConverter extends SWFConverter
|
||||
|
||||
try
|
||||
{
|
||||
await this._furniDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF) =>
|
||||
await this._furniDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF, className: string) =>
|
||||
{
|
||||
spinner.text = (`Parsing Furniture: ${ habboAssetSwf.getDocumentClass() } (${ (this._furniDownloader.totalFinished + 1) } / ${ this._furniDownloader.totalItems })`);
|
||||
if(!habboAssetSwf)
|
||||
{
|
||||
spinner.text = 'Couldnt convert furni: ' + className;
|
||||
}
|
||||
else
|
||||
{
|
||||
spinner.text = (`Parsing Furniture: ${ habboAssetSwf.getDocumentClass() } (${ (this._furniDownloader.totalFinished + 1) } / ${ this._furniDownloader.totalItems })`);
|
||||
}
|
||||
|
||||
spinner.render();
|
||||
|
||||
if(!habboAssetSwf) return;
|
||||
|
||||
const spriteBundle = await this._bundleProvider.generateSpriteSheet(habboAssetSwf);
|
||||
const assetData = await this.mapXML2JSON(habboAssetSwf, 'furniture');
|
||||
|
||||
|
@ -34,12 +34,21 @@ export class PetConverter extends SWFConverter
|
||||
|
||||
try
|
||||
{
|
||||
await this._petDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF) =>
|
||||
await this._petDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF, className: string) =>
|
||||
{
|
||||
spinner.text = 'Parsing Pet: ' + habboAssetSwf.getDocumentClass();
|
||||
if(!habboAssetSwf)
|
||||
{
|
||||
spinner.text = 'Couldnt convert pet: ' + className;
|
||||
}
|
||||
else
|
||||
{
|
||||
spinner.text = 'Parsing Pet: ' + habboAssetSwf.getDocumentClass();
|
||||
}
|
||||
|
||||
spinner.render();
|
||||
|
||||
if(!habboAssetSwf) return;
|
||||
|
||||
const spriteBundle = await this._bundleProvider.generateSpriteSheet(habboAssetSwf);
|
||||
const assetData = await this.mapXML2JSON(habboAssetSwf, 'pet');
|
||||
|
||||
|
@ -13,7 +13,7 @@ export class PetDownloader
|
||||
private readonly _logger: Logger)
|
||||
{}
|
||||
|
||||
public async download(directory: File, callback: (habboAssetSwf: HabboAssetSWF) => Promise<void>): Promise<void>
|
||||
public async download(directory: File, callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise<void>): Promise<void>
|
||||
{
|
||||
const petTypes = await this.parsePetTypes();
|
||||
|
||||
@ -62,7 +62,7 @@ export class PetDownloader
|
||||
return petTypes;
|
||||
}
|
||||
|
||||
public async extractPet(className: string, callback: (habboAssetSwf: HabboAssetSWF) => Promise<void>): Promise<void>
|
||||
public async extractPet(className: string, callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise<void>): Promise<void>
|
||||
{
|
||||
let url = this._configuration.getValue('dynamic.download.pet.url');
|
||||
|
||||
@ -78,6 +78,6 @@ export class PetDownloader
|
||||
|
||||
await newHabboAssetSWF.setupAsync();
|
||||
|
||||
await callback(newHabboAssetSWF);
|
||||
await callback(newHabboAssetSWF, className);
|
||||
}
|
||||
}
|
||||
|
@ -294,6 +294,8 @@ function readSWFTags(buff, swf)
|
||||
*/
|
||||
function readSWFBuff(buff, compressed_buff, next)
|
||||
{
|
||||
if(!buff) return next(null, null);
|
||||
|
||||
buff.seek(3);// start
|
||||
|
||||
if(buff.length < 9)
|
||||
@ -359,28 +361,26 @@ function uncompress(swf, next)
|
||||
{
|
||||
uncompressed_buff = concatSWFHeader(zlib.unzipSync(compressed_buff), swf);
|
||||
|
||||
if(!Buffer.isBuffer(uncompressed_buff))
|
||||
{
|
||||
console.log('invalid_buffer');
|
||||
if(!Buffer.isBuffer(uncompressed_buff)) return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
return readSWFBuff(new SWFBuffer(uncompressed_buff), swf);
|
||||
}
|
||||
|
||||
if(!Buffer.isBuffer(compressed_buff))
|
||||
{
|
||||
console.log('invalid_buffer');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
zlib.inflate(compressed_buff, function(err, buf)
|
||||
{
|
||||
readSWFBuff(new SWFBuffer(buf), swf, next);
|
||||
if(!Buffer.isBuffer(compressed_buff))
|
||||
{
|
||||
readSWFBuff(null, swf, next);
|
||||
}
|
||||
else
|
||||
{
|
||||
readSWFBuff(new SWFBuffer(buf), swf, next);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 0x46 : // uncompressed
|
||||
if(!Buffer.isBuffer(swf)) return null;
|
||||
|
||||
return readSWFBuff(new SWFBuffer( swf ), swf, next);
|
||||
case 0x5a : // LZMA compressed
|
||||
var lzmaProperties = compressed_buff.slice(4, 9);
|
||||
@ -421,6 +421,8 @@ function uncompress(swf, next)
|
||||
lzma.decompress(lzmaProperties, input_stream, output_stream, -1);
|
||||
uncompressed_buff = Buffer.concat([swf.slice(0, 8), output_stream.getBuffer()]);
|
||||
|
||||
if(!Buffer.isBuffer(uncompressed_buff)) return null;
|
||||
|
||||
return readSWFBuff(new SWFBuffer(uncompressed_buff), swf, next);
|
||||
default :
|
||||
e = new Error('Unknown SWF compressions');
|
||||
|
@ -21,6 +21,9 @@ export class HabboAssetSWF
|
||||
async setupAsync()
|
||||
{
|
||||
const swf = await readSwfAsync(this._data);
|
||||
|
||||
if(!swf) return;
|
||||
|
||||
for(const tag of swf.tags)
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user