Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Pax1601/DCSOlympus
Browse files Browse the repository at this point in the history
  • Loading branch information
Pax1601 committed Dec 5, 2023
2 parents e29fdfd + af619c3 commit 8d03c6a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
5 changes: 3 additions & 2 deletions client/src/contextmenus/coalitionareacontextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/src/olympusapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
13 changes: 9 additions & 4 deletions client/src/server/servermanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -600,4 +601,8 @@ export class ServerManager {
getServerIsPaused() {
return this.#serverIsPaused;
}

getRequests() {
return this.#requests;
}
}
2 changes: 1 addition & 1 deletion client/src/unit/importexport/unitdatafileimport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down
18 changes: 6 additions & 12 deletions client/src/unit/unitsmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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, "", "");
}
}
}
Expand All @@ -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;
Expand All @@ -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, "", "");
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/include/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 8d03c6a

Please sign in to comment.