This commit is contained in:
d07riv
2019-08-12 04:23:54 +03:00
parent 0a6c75be55
commit d7cbb4e165
8 changed files with 12 additions and 12 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "diabloweb",
"version": "1.0.22",
"version": "1.0.24",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "diabloweb",
"version": "1.0.22",
"version": "1.0.24",
"private": true,
"dependencies": {
"@babel/core": "7.4.3",

View File

@@ -5,7 +5,7 @@ import ReactGA from 'react-ga';
import create_fs from './fs';
import load_game from './api/loader';
import { SpawnSize } from './api/load_spawn';
import { SpawnSizes } from './api/load_spawn';
if (process.env.NODE_ENV === 'production') {
ReactGA.initialize('UA-43123589-6');
@@ -98,7 +98,7 @@ class App extends React.Component {
this.fs.then(fs => {
const spawn = fs.files.get('spawn.mpq');
if (spawn && spawn.byteLength === SpawnSize) {
if (spawn && SpawnSizes.includes(spawn.byteLength)) {
this.setState({has_spawn: true});
}
});
@@ -554,7 +554,7 @@ class App extends React.Component {
}
render() {
const {started, loading, error, progress, dropping, touch, has_spawn} = this.state;
const {started, loading, error, progress, dropping, has_spawn} = this.state;
return (
<div className={classNames("App", {touch: this.touchControls, started, dropping, keyboard: !!this.showKeyboard})} ref={this.setElement}>
<div className="touch-ui touch-mods">

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1,12 +1,12 @@
import axios from 'axios';
const SpawnSize = 50274091;
const SpawnSizes = [50274091, 25830791];
export { SpawnSize };
export { SpawnSizes };
export default async function load_spawn(api, fs) {
let file = fs.files.get('spawn.mpq');
if (file && file.byteLength !== SpawnSize) {
if (file && !SpawnSizes.includes(file.byteLength)) {
fs.files.delete('spawn.mpq');
await fs.delete('spawn.mpq');
file = null;
@@ -17,14 +17,14 @@ export default async function load_spawn(api, fs) {
responseType: 'arraybuffer',
onDownloadProgress: e => {
if (api.onProgress) {
api.onProgress({text: 'Downloading...', loaded: e.loaded, total: e.total || SpawnSize});
api.onProgress({text: 'Downloading...', loaded: e.loaded, total: e.total || SpawnSizes[1]});
}
},
headers: {
'Cache-Control': 'max-age=31536000'
}
});
if (spawn.data.byteLength !== SpawnSize) {
if (!SpawnSizes.includes(spawn.data.byteLength)) {
throw Error("Invalid spawn.mpq size. Try clearing cache and refreshing the page.");
}
const data = new Uint8Array(spawn.data);