diff --git a/client/src/contextmenus/coalitionareacontextmenu.ts b/client/src/contextmenus/coalitionareacontextmenu.ts index ca993f6e7..dc9ce242c 100644 --- a/client/src/contextmenus/coalitionareacontextmenu.ts +++ b/client/src/contextmenus/coalitionareacontextmenu.ts @@ -68,7 +68,8 @@ export class CoalitionAreaContextMenu extends ContextMenu { const area = this.getCoalitionArea(); if (area) getApp().getUnitsManager().createIADS(area, getCheckboxOptions(this.#iadsTypesDropdown), getCheckboxOptions(this.#iadsErasDropdown), getCheckboxOptions(this.#iadsRangesDropdown), this.#iadsDensitySlider.getValue(), this.#iadsDistributionSlider.getValue()); - }) + this.hide(); + }); this.hide(); } @@ -110,7 +111,7 @@ export class CoalitionAreaContextMenu extends ContextMenu { this.getContainer()?.querySelectorAll('[data-coalition]').forEach((element: any) => { element.setAttribute("data-coalition", this.getCoalitionArea()?.getCoalition()) }); - this.#coalitionSwitch.setValue(this.getCoalitionArea()?.getCoalition() === "red"); + this.#coalitionSwitch.setValue(this.getCoalitionArea()?.getCoalition() === "blue"); } /** Get the CoalitionArea object the contextmenu is editing diff --git a/client/src/olympusapp.ts b/client/src/olympusapp.ts index 69997534e..d2eca6807 100644 --- a/client/src/olympusapp.ts +++ b/client/src/olympusapp.ts @@ -30,7 +30,7 @@ import { ContextManager } from "./context/contextmanager"; import { Context } from "./context/context"; var VERSION = "v0.4.9-alpha-rc1"; -var DEBUG = true; +var DEBUG = false; export class OlympusApp { /* Global data */ diff --git a/client/src/server/servermanager.ts b/client/src/server/servermanager.ts index bea2c222b..10b9f59e0 100644 --- a/client/src/server/servermanager.ts +++ b/client/src/server/servermanager.ts @@ -64,7 +64,6 @@ export class ServerManager { /* On the connection */ xmlHttp.open("GET", `${this.#demoEnabled ? this.#DEMO_ADDRESS : this.#REST_ADDRESS}/${uri}${optionsString ? `?${optionsString}` : ''}`, true); - xmlHttp.timeout = 2000; /* If provided, set the credentials */ if (this.#username && this.#password) @@ -96,9 +95,11 @@ export class ServerManager { this.setConnected(false); } }; - xmlHttp.onerror = (res) => { - console.error("An error occurred during the XMLHttpRequest"); - this.setConnected(false); + xmlHttp.onreadystatechange = (res) => { + if (xmlHttp.readyState == 4 && xmlHttp.status === 0) { + console.error("An error occurred during the XMLHttpRequest"); + this.setConnected(false); + } }; xmlHttp.send(null); } @@ -600,4 +601,8 @@ export class ServerManager { getServerIsPaused() { return this.#serverIsPaused; } + + getRequests() { + return this.#requests; + } } diff --git a/client/src/unit/importexport/unitdatafileimport.ts b/client/src/unit/importexport/unitdatafileimport.ts index deeea4a1b..5a0e2221c 100644 --- a/client/src/unit/importexport/unitdatafileimport.ts +++ b/client/src/unit/importexport/unitdatafileimport.ts @@ -46,7 +46,7 @@ export class UnitDataFileImport extends UnitDataFile { return { unitType: unitData.name, location: unitData.position, liveryID: "" } }); - unitsManager.spawnUnits(category, unitsToSpawn, coalition, true); + unitsManager.spawnUnits(category, unitsToSpawn, coalition, false); } /* diff --git a/client/src/unit/unitsmanager.ts b/client/src/unit/unitsmanager.ts index 5dd0a6ee5..54624cf43 100644 --- a/client/src/unit/unitsmanager.ts +++ b/client/src/unit/unitsmanager.ts @@ -1114,7 +1114,7 @@ export class UnitsManager { /* Check if the city is inside the coalition area */ if (polyContains(new LatLng(airbase.getLatLng().lat, airbase.getLatLng().lng), coalitionArea)) { /* Arbitrary formula to obtain a number of units */ - var pointsNumber = 2 + 40 * density / 100; + var pointsNumber = 2 + 10 * density / 100; for (let i = 0; i < pointsNumber; i++) { /* Place the unit nearby the airbase, depending on the distribution parameter */ var bearing = Math.random() * 360; @@ -1127,11 +1127,8 @@ export class UnitsManager { if (Math.random() < IADSDensities[type]) { /* Get a random blueprint depending on the selected parameters and spawn the unit */ const unitBlueprint = randomUnitBlueprint(groundUnitDatabase, { type: type, eras: activeEras, ranges: activeRanges }); - if (unitBlueprint) { - this.spawnUnits("GroundUnit", [{ unitType: unitBlueprint.name, location: latlng, liveryID: "" }], coalitionArea.getCoalition(), true, "", "", (res: any) =>{ - getApp().getMap().addTemporaryMarker(latlng, unitBlueprint.name, getApp().getActiveCoalition(), res.commandHash); - }); - } + if (unitBlueprint) + this.spawnUnits("GroundUnit", [{ unitType: unitBlueprint.name, location: latlng, liveryID: "" }], coalitionArea.getCoalition(), false, "", ""); } } } @@ -1142,7 +1139,7 @@ export class UnitsManager { /* Check if the city is inside the coalition area */ if (polyContains(new LatLng(city.lat, city.lng), coalitionArea)) { /* Arbitrary formula to obtain a number of units depending on the city population */ - var pointsNumber = 2 + Math.pow(city.pop, 0.2) * density / 100; + var pointsNumber = 2 + Math.pow(city.pop, 0.15) * density / 100; for (let i = 0; i < pointsNumber; i++) { /* Place the unit nearby the city, depending on the distribution parameter */ var bearing = Math.random() * 360; @@ -1155,11 +1152,8 @@ export class UnitsManager { if (Math.random() < IADSDensities[type]) { /* Get a random blueprint depending on the selected parameters and spawn the unit */ const unitBlueprint = randomUnitBlueprint(groundUnitDatabase, { type: type, eras: activeEras, ranges: activeRanges }); - if (unitBlueprint) { - this.spawnUnits("GroundUnit", [{ unitType: unitBlueprint.name, location: latlng, liveryID: "" }], coalitionArea.getCoalition(), true, "", "", (res: any) =>{ - getApp().getMap().addTemporaryMarker(latlng, unitBlueprint.name, getApp().getActiveCoalition(), res.commandHash); - }); - } + if (unitBlueprint) + this.spawnUnits("GroundUnit", [{ unitType: unitBlueprint.name, location: latlng, liveryID: "" }], coalitionArea.getCoalition(), false, "", ""); } } } diff --git a/src/core/include/commands.h b/src/core/include/commands.h index fc86944ef..32cb71ba1 100644 --- a/src/core/include/commands.h +++ b/src/core/include/commands.h @@ -173,7 +173,7 @@ class SpawnGroundUnits : public Command priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW; }; virtual string getString(); - virtual unsigned int getLoad() { return immediate? 1: 30; } + virtual unsigned int getLoad() { return immediate? 5: 30; } private: const string coalition; @@ -196,7 +196,7 @@ class SpawnNavyUnits : public Command priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW; }; virtual string getString(); - virtual unsigned int getLoad() { return immediate ? 1 : 60; } + virtual unsigned int getLoad() { return immediate ? 5 : 60; } private: const string coalition; @@ -220,7 +220,7 @@ class SpawnAircrafts : public Command priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW; }; virtual string getString(); - virtual unsigned int getLoad() { return immediate ? 1 : 45; } + virtual unsigned int getLoad() { return immediate ? 5 : 45; } private: const string coalition; @@ -245,7 +245,7 @@ class SpawnHelicopters : public Command priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW; }; virtual string getString(); - virtual unsigned int getLoad() { return immediate ? 1 : 45; } + virtual unsigned int getLoad() { return immediate ? 5 : 45; } private: const string coalition;