Skip to content

Commit

Permalink
Improved scene load check
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Jul 29, 2021
1 parent 66fcc50 commit 4fc91f5
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 31 deletions.
32 changes: 2 additions & 30 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ const {
SourceZip,
SourceDir
} = require('./util/sources');
const {
Swf,
DefineEditText
} = require('./util/swf');
const {mod} = require('./util/mod');
const {Server} = require('./util/server');
const {
version,
Expand Down Expand Up @@ -72,28 +69,6 @@ const sources = {
)
};

function fixPlayerFonts(data) {
// Set dynamic text fields to use the embedded fonts available.
// This avoids text issues where the font is not available.
// Only fix those where font was embedded just not set to use.
const swf = new Swf();
swf.decode(data);
const unchanged = new Set([97, 103, 243, 265]);
for (const tag of swf.tags) {
if (tag.code !== DefineEditText.CODE) {
continue;
}
const det = new DefineEditText();
det.decode(tag.data);
if (unchanged.has(det.fontId)) {
continue;
}
det.useOutlines = true;
tag.data = det.encode();
}
return swf.encode();
}

async function shockpkgFile(pkg) {
return (new Manager()).with(
async manager => manager.packageInstallFile(pkg)
Expand Down Expand Up @@ -186,10 +161,7 @@ async function readSources(order, each) {
let data = await propercase.dataCached(
await entry.read()
);
if (entry.path.toLowerCase() === 'player.swf') {
data = fixPlayerFonts(data);
}
return data;
return mod(entry.path, data);
}
});
});
Expand Down
8 changes: 7 additions & 1 deletion mod/Player.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ else

# Loading glitch from reloading race condition

First always check that some frames have been loaded first.

Instead of reloading the movie mark it as loaded with a variable the movie can check.

Each scene that needs to use this variable instead is updated automatically in the build script.

## `scripts` -> `DefineSprite (134)` -> `frame 13`

Original:
Expand Down Expand Up @@ -130,7 +136,7 @@ if(numBytesTotal > 100)
{
if(numBytesLoaded == numBytesTotal and numFramesLoaded == numFramesTotal and numFramesLoaded > 0)
{
_root.holder.gotoAndPlay(1);
_root.holder.__loaded = true;
}
else
{
Expand Down
Binary file modified mod/Player.swf
Binary file not shown.
17 changes: 17 additions & 0 deletions util/buffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

function bufferToHex(buffer) {
return buffer.toString('hex')
.replace(/(.{2})/g, '$1 ')
.replace(/ $/, '')
.toUpperCase();
}
exports.bufferToHex = bufferToHex;

function bufferFromHex(hex) {
return Buffer.from(
hex.replace(/\s/g, ''),
'hex'
);
}
exports.bufferFromHex = bufferFromHex;
Loading

0 comments on commit 4fc91f5

Please sign in to comment.