mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Fixed missing category error
This commit is contained in:
@@ -8,7 +8,7 @@ export class UnitDatabase {
|
|||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
load(url: string) {
|
load(url: string, category?: string) {
|
||||||
if (url !== "") {
|
if (url !== "") {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", url, true);
|
xhr.open("GET", url, true);
|
||||||
@@ -18,6 +18,12 @@ export class UnitDatabase {
|
|||||||
var status = xhr.status;
|
var status = xhr.status;
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
const newBlueprints = xhr.response as { [key: string]: UnitBlueprint };
|
const newBlueprints = xhr.response as { [key: string]: UnitBlueprint };
|
||||||
|
for (let unit in newBlueprints) {
|
||||||
|
if (!newBlueprints[unit].category) {
|
||||||
|
if (category) newBlueprints[unit].category = category
|
||||||
|
else console.warn(`No category provided for ${unit}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
this.blueprints = { ...this.blueprints, ...newBlueprints };
|
this.blueprints = { ...this.blueprints, ...newBlueprints };
|
||||||
UnitDatabaseLoadedEvent.dispatch();
|
UnitDatabaseLoadedEvent.dispatch();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user