Skip to content

Commit

Permalink
enable gz for teambuilder-tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Rezzo64 committed Nov 24, 2023
1 parent b0b2b40 commit c831053
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
15 changes: 10 additions & 5 deletions build-tools/build-indexes
Original file line number Diff line number Diff line change
Expand Up @@ -1533,8 +1533,9 @@ function buildTeambuilderTables() {
let blockIndex = 0;

console.log("writing BattleTeambuilderTable...");
fs.writeFileSync('play.pokemonshowdown.com/data/teambuilder-tables.js', '// DO NOT EDIT - automatically built with build-tools/build-indexes\n\n');
fs.appendFileSync('play.pokemonshowdown.com/data/teambuilder-tables.js', 'exports.BattleTeambuilderTable = JSON.parse(\'{')
const tableDir = 'play.pokemonshowdown.com/data/teambuilder-tables.js';
fs.writeFileSync(tableDir, '// DO NOT EDIT - automatically built with build-tools/build-indexes\n\n');
fs.appendFileSync(tableDir, 'exports.BattleTeambuilderTable = JSON.parse(\'{')

// ChatGPT suggested to put BattleTeambuilderTable into blocks to prevent memory overload.
while (blockIndex < tableKeys.length) {
Expand All @@ -1545,11 +1546,15 @@ function buildTeambuilderTables() {
});
var jsonString = JSON.stringify(blockTable).replace(/['\\]/g, "\\$&");
jsonString = jsonString.substring(1, jsonString.length - 1);
fs.appendFileSync('play.pokemonshowdown.com/data/teambuilder-tables.js', jsonString);
fs.appendFileSync(tableDir, jsonString);
blockIndex += blockSize;
if (blockIndex < tableKeys.length) fs.appendFileSync('play.pokemonshowdown.com/data/teambuilder-tables.js', ',');
if (blockIndex < tableKeys.length) fs.appendFileSync(tableDir, ',');
}
fs.appendFileSync('play.pokemonshowdown.com/data/teambuilder-tables.js', '}\');\n\n');
fs.appendFileSync(tableDir, '}\');\n\n');
console.log("DONE");

console.log("writing compressed gz/teambuilder-tables.js.gz...");
child_process.execSync('gzip -c ' + tableDir + ' > ' + tableDir + '.gz');
console.log("DONE");

console.log("writing ModConfig...");
Expand Down
5 changes: 5 additions & 0 deletions play.pokemonshowdown.com/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ <h3><button class="closebutton" tabindex="-1" aria-label="Close"><i class="fa fa
<script src="data/abilities.js" onerror="loadRemoteData(this.src)"></script>

<script src="data/search-index.js" onerror="loadRemoteData(this.src)"></script>

<script>
document.getElementById('loading-message').innerHTML += ' DONE<br />Loading teambuilder-tables...';
</script>

<script src="data/teambuilder-tables.js" onerror="loadRemoteData(this.src)"></script>
<script src="data/mod-sprites.js" onerror="loadRemoteData(this.src)"></script>
<script src="data/mod-config.js" onerror="loadRemoteData(this.src)"></script>
Expand Down
5 changes: 5 additions & 0 deletions play.pokemonshowdown.com/testclient.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ <h3><button class="closebutton" tabindex="-1" aria-label="Close"><i class="fa fa
<script src="data/abilities.js" onerror="loadRemoteData(this.src)"></script>

<script src="data/search-index.js" onerror="loadRemoteData(this.src)"></script>

<script>
document.getElementById('loading-message').innerHTML += ' DONE<br />Loading teambuilder-tables...';
</script>

<script src="data/teambuilder-tables.js" onerror="loadRemoteData(this.src)"></script>
<script src="data/mod-sprites.js" onerror="loadRemoteData(this.src)"></script>
<script src="data/mod-config.js" onerror="loadRemoteData(this.src)"></script>
Expand Down

0 comments on commit c831053

Please sign in to comment.