mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Merge branch 'performance-optimization' into 326-add-advanced-rts-options
This commit is contained in:
@@ -14,7 +14,7 @@ const DEMO_UNIT_DATA = {
|
|||||||
TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 },
|
TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 },
|
||||||
radio: { frequency: 124000000, callsign: 1, callsignNumber: 1 },
|
radio: { frequency: 124000000, callsign: 1, callsignNumber: 1 },
|
||||||
generalSettings: { prohibitAA: false, prohibitAfterburner: false, prohibitAG: false, prohibitAirWpn: false, prohibitJettison: false },
|
generalSettings: { prohibitAA: false, prohibitAfterburner: false, prohibitAG: false, prohibitAirWpn: false, prohibitJettison: false },
|
||||||
ammo: [{ quantity: 2, name: "A cool missile", guidance: 0, category: 0, missileCategory: 0 } ],
|
ammo: [{ quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } ],
|
||||||
contacts: [{ID: 2, detectionMethod: 1}, {ID: 3, detectionMethod: 4}],
|
contacts: [{ID: 2, detectionMethod: 1}, {ID: 3, detectionMethod: 4}],
|
||||||
activePath: [{lat: 38, lng: -115, alt: 0}, {lat: 38, lng: -114, alt: 0}]
|
activePath: [{lat: 38, lng: -115, alt: 0}, {lat: 38, lng: -114, alt: 0}]
|
||||||
},
|
},
|
||||||
@@ -63,6 +63,38 @@ const DEMO_UNIT_DATA = {
|
|||||||
ammo: [{ quantity: 2, name: "A cool missile", guidance: 0, category: 0, missileCategory: 0 } ],
|
ammo: [{ quantity: 2, name: "A cool missile", guidance: 0, category: 0, missileCategory: 0 } ],
|
||||||
contacts: [{ID: 1, detectionMethod: 16}],
|
contacts: [{ID: 1, detectionMethod: 16}],
|
||||||
activePath: [ ]
|
activePath: [ ]
|
||||||
|
}, ["5"]:{ category: "GroundUnit", alive: true, human: false, controlled: true, coalition: 1, country: 0, name: "Gepard", unitName: "Cool guy 2-1", groupName: "Cool group 4", state: 1, task: "Being cool",
|
||||||
|
hasTask: false, position: { lat: 37.2, lng: -116.1, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isTanker: false, isAWACS: false, onOff: true, followRoads: false, fuel: 50,
|
||||||
|
desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0,
|
||||||
|
formationOffset: { x: 0, y: 0, z: 0 },
|
||||||
|
targetID: 0,
|
||||||
|
targetPosition: { lat: 0, lng: 0, alt: 0 },
|
||||||
|
ROE: 2,
|
||||||
|
reactionToThreat: 1,
|
||||||
|
emissionsCountermeasures: 1,
|
||||||
|
TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 },
|
||||||
|
radio: { frequency: 124000000, callsign: 1, callsignNumber: 1 },
|
||||||
|
generalSettings: { prohibitAA: false, prohibitAfterburner: false, prohibitAG: false, prohibitAirWpn: false, prohibitJettison: false },
|
||||||
|
ammo: [{ quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } ],
|
||||||
|
contacts: [{ID: 1, detectionMethod: 16}],
|
||||||
|
activePath: [ ],
|
||||||
|
isLeader: true
|
||||||
|
}, ["6"]:{ category: "GroundUnit", alive: true, human: false, controlled: true, coalition: 1, country: 0, name: "Gepard", unitName: "Cool guy 2-2", groupName: "Cool group 4", state: 1, task: "Being cool",
|
||||||
|
hasTask: false, position: { lat: 37.21, lng: -116.1, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isTanker: false, isAWACS: false, onOff: true, followRoads: false, fuel: 50,
|
||||||
|
desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0,
|
||||||
|
formationOffset: { x: 0, y: 0, z: 0 },
|
||||||
|
targetID: 0,
|
||||||
|
targetPosition: { lat: 0, lng: 0, alt: 0 },
|
||||||
|
ROE: 2,
|
||||||
|
reactionToThreat: 1,
|
||||||
|
emissionsCountermeasures: 1,
|
||||||
|
TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 },
|
||||||
|
radio: { frequency: 124000000, callsign: 1, callsignNumber: 1 },
|
||||||
|
generalSettings: { prohibitAA: false, prohibitAfterburner: false, prohibitAG: false, prohibitAirWpn: false, prohibitJettison: false },
|
||||||
|
ammo: [{ quantity: 2, name: "A cool missile", guidance: 0, category: 0, missileCategory: 0 } ],
|
||||||
|
contacts: [{ID: 1, detectionMethod: 16}],
|
||||||
|
activePath: [ ],
|
||||||
|
isLeader: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +160,7 @@ class DemoDataGenerator {
|
|||||||
array = this.appendAmmo(array, unit.ammo, 35);
|
array = this.appendAmmo(array, unit.ammo, 35);
|
||||||
array = this.appendContacts(array, unit.contacts, 36);
|
array = this.appendContacts(array, unit.contacts, 36);
|
||||||
array = this.appendActivePath(array, unit.activePath, 37);
|
array = this.appendActivePath(array, unit.activePath, 37);
|
||||||
|
array = this.appendUint8(array, unit.isLeader, 38);
|
||||||
array = this.concat(array, this.uint8ToByteArray(255));
|
array = this.concat(array, this.uint8ToByteArray(255));
|
||||||
}
|
}
|
||||||
res.end(Buffer.from(array, 'binary'));
|
res.end(Buffer.from(array, 'binary'));
|
||||||
@@ -290,8 +323,10 @@ class DemoDataGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logs(req, res){
|
logs(req, res){
|
||||||
var ret = {logs: {}};
|
var ret = {logs: {"1": "I'm a log!", "2": "I'm a different log!"}};
|
||||||
ret.time = Date.now();
|
ret.time = Date.now();
|
||||||
|
ret.frameRate = 60;
|
||||||
|
ret.load = 0;
|
||||||
res.send(JSON.stringify(ret));
|
res.send(JSON.stringify(ret));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,16 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
width: 250px;
|
width: 180px;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
#server-status-panel {
|
||||||
|
bottom: 20px;
|
||||||
|
font-size: 12px;
|
||||||
|
position: absolute;
|
||||||
|
right: 200px;
|
||||||
|
width: 300px;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
@import url("atc/unitdatatable.css");
|
@import url("atc/unitdatatable.css");
|
||||||
@import url("aic/aic.css");
|
@import url("aic/aic.css");
|
||||||
@import url("panels/connectionstatus.css");
|
@import url("panels/connectionstatus.css");
|
||||||
|
@import url("panels/serverstatus.css");
|
||||||
@import url("panels/mouseinfo.css");
|
@import url("panels/mouseinfo.css");
|
||||||
@import url("panels/unitcontrol.css");
|
@import url("panels/unitcontrol.css");
|
||||||
@import url("panels/unitinfo.css");
|
@import url("panels/unitinfo.css");
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#connection-status-panel[data-is-connected] dt::before {
|
#connection-status-panel[data-is-connected] dt::before {
|
||||||
content: "Connected FPS: " attr(data-framerate) " Load: " attr(data-load);
|
content: "Connected";
|
||||||
}
|
}
|
||||||
|
|
||||||
#connection-status-panel[data-is-connected] dd::after {
|
#connection-status-panel[data-is-connected] dd::after {
|
||||||
|
|||||||
43
client/public/stylesheets/panels/serverstatus.css
Normal file
43
client/public/stylesheets/panels/serverstatus.css
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#server-status-panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
column-gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#server-status-panel .ol-data-grid {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#server-status-panel .ol-data-grid:first-of-type {
|
||||||
|
border-right: 1px solid gray;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#server-status-panel dd {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fps-low {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fps-medium {
|
||||||
|
color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fps-high {
|
||||||
|
color: lightgreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
.load-low {
|
||||||
|
color: lightgreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
.load-medium {
|
||||||
|
color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
.load-high {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { LatLng, LatLngBounds } from "leaflet";
|
import { LatLng, LatLngBounds } from "leaflet";
|
||||||
|
|
||||||
export const HIDE_ALL = "Hide all";
|
|
||||||
export const GAME_MASTER = "Game master";
|
export const GAME_MASTER = "Game master";
|
||||||
export const BLUE_COMMANDER = "Blue commander";
|
export const BLUE_COMMANDER = "Blue commander";
|
||||||
export const RED_COMMANDER = "Red commander";
|
export const RED_COMMANDER = "Red commander";
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { Dropdown } from "./controls/dropdown";
|
|||||||
import { HotgroupPanel } from "./panels/hotgrouppanel";
|
import { HotgroupPanel } from "./panels/hotgrouppanel";
|
||||||
import { SVGInjector } from "@tanem/svg-injector";
|
import { SVGInjector } from "@tanem/svg-injector";
|
||||||
import { BLUE_COMMANDER, GAME_MASTER, RED_COMMANDER } from "./constants/constants";
|
import { BLUE_COMMANDER, GAME_MASTER, RED_COMMANDER } from "./constants/constants";
|
||||||
|
import { ServerStatusPanel } from "./panels/serverstatuspanel";
|
||||||
|
|
||||||
var map: Map;
|
var map: Map;
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ var atc: ATC;
|
|||||||
|
|
||||||
var unitInfoPanel: UnitInfoPanel;
|
var unitInfoPanel: UnitInfoPanel;
|
||||||
var connectionStatusPanel: ConnectionStatusPanel;
|
var connectionStatusPanel: ConnectionStatusPanel;
|
||||||
|
var serverStatusPanel: ServerStatusPanel;
|
||||||
var unitControlPanel: UnitControlPanel;
|
var unitControlPanel: UnitControlPanel;
|
||||||
var mouseInfoPanel: MouseInfoPanel;
|
var mouseInfoPanel: MouseInfoPanel;
|
||||||
var logPanel: LogPanel;
|
var logPanel: LogPanel;
|
||||||
@@ -53,9 +55,10 @@ function setup() {
|
|||||||
unitInfoPanel = new UnitInfoPanel("unit-info-panel");
|
unitInfoPanel = new UnitInfoPanel("unit-info-panel");
|
||||||
unitControlPanel = new UnitControlPanel("unit-control-panel");
|
unitControlPanel = new UnitControlPanel("unit-control-panel");
|
||||||
connectionStatusPanel = new ConnectionStatusPanel("connection-status-panel");
|
connectionStatusPanel = new ConnectionStatusPanel("connection-status-panel");
|
||||||
|
serverStatusPanel = new ServerStatusPanel("server-status-panel");
|
||||||
mouseInfoPanel = new MouseInfoPanel("mouse-info-panel");
|
mouseInfoPanel = new MouseInfoPanel("mouse-info-panel");
|
||||||
hotgroupPanel = new HotgroupPanel("hotgroup-panel");
|
hotgroupPanel = new HotgroupPanel("hotgroup-panel");
|
||||||
//logPanel = new LogPanel("log-panel");
|
|
||||||
|
|
||||||
/* Popups */
|
/* Popups */
|
||||||
infoPopup = new Popup("info-popup");
|
infoPopup = new Popup("info-popup");
|
||||||
@@ -243,6 +246,10 @@ export function getConnectionStatusPanel() {
|
|||||||
return connectionStatusPanel;
|
return connectionStatusPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getServerStatusPanel() {
|
||||||
|
return serverStatusPanel;
|
||||||
|
}
|
||||||
|
|
||||||
export function getHotgroupPanel() {
|
export function getHotgroupPanel() {
|
||||||
return hotgroupPanel;
|
return hotgroupPanel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export class Map extends L.Map {
|
|||||||
#miniMapLayerGroup: L.LayerGroup;
|
#miniMapLayerGroup: L.LayerGroup;
|
||||||
#temporaryMarkers: TemporaryUnitMarker[] = [];
|
#temporaryMarkers: TemporaryUnitMarker[] = [];
|
||||||
#selecting: boolean = false;
|
#selecting: boolean = false;
|
||||||
|
#isZooming: boolean = false;
|
||||||
|
|
||||||
#destinationGroupRotation: number = 0;
|
#destinationGroupRotation: number = 0;
|
||||||
#computeDestinationRotation: boolean = false;
|
#computeDestinationRotation: boolean = false;
|
||||||
@@ -67,7 +68,7 @@ export class Map extends L.Map {
|
|||||||
constructor(ID: string) {
|
constructor(ID: string) {
|
||||||
/* Init the leaflet map */
|
/* Init the leaflet map */
|
||||||
//@ts-ignore Needed because the boxSelect option is non-standard
|
//@ts-ignore Needed because the boxSelect option is non-standard
|
||||||
super(ID, { preferCanvas: true, doubleClickZoom: false, zoomControl: false, boxZoom: false, boxSelect: true, zoomAnimation: true, maxBoundsViscosity: 1.0, minZoom: 7, keyboard: true, keyboardPanDelta: 0 });
|
super(ID, { zoomSnap: 0, zoomDelta: 0.25, preferCanvas: true, doubleClickZoom: false, zoomControl: false, boxZoom: false, boxSelect: true, zoomAnimation: true, maxBoundsViscosity: 1.0, minZoom: 7, keyboard: true, keyboardPanDelta: 0 });
|
||||||
this.setView([37.23, -115.8], 10);
|
this.setView([37.23, -115.8], 10);
|
||||||
|
|
||||||
this.#ID = ID;
|
this.#ID = ID;
|
||||||
@@ -93,7 +94,8 @@ export class Map extends L.Map {
|
|||||||
/* Register event handles */
|
/* Register event handles */
|
||||||
this.on("click", (e: any) => this.#onClick(e));
|
this.on("click", (e: any) => this.#onClick(e));
|
||||||
this.on("dblclick", (e: any) => this.#onDoubleClick(e));
|
this.on("dblclick", (e: any) => this.#onDoubleClick(e));
|
||||||
this.on("zoomstart", (e: any) => this.#onZoom(e));
|
this.on("zoomstart", (e: any) => this.#onZoomStart(e));
|
||||||
|
this.on("zoomend", (e: any) => this.#onZoomEnd(e));
|
||||||
this.on("drag", (e: any) => this.centerOnUnit(null));
|
this.on("drag", (e: any) => this.centerOnUnit(null));
|
||||||
this.on("contextmenu", (e: any) => this.#onContextMenu(e));
|
this.on("contextmenu", (e: any) => this.#onContextMenu(e));
|
||||||
this.on('selectionstart', (e: any) => this.#onSelectionStart(e));
|
this.on('selectionstart', (e: any) => this.#onSelectionStart(e));
|
||||||
@@ -270,6 +272,10 @@ export class Map extends L.Map {
|
|||||||
this.#coalitionAreaContextMenu.hide();
|
this.#coalitionAreaContextMenu.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isZooming() {
|
||||||
|
return this.#isZooming;
|
||||||
|
}
|
||||||
|
|
||||||
/* Mouse coordinates */
|
/* Mouse coordinates */
|
||||||
getMousePosition() {
|
getMousePosition() {
|
||||||
return this.#lastMousePosition;
|
return this.#lastMousePosition;
|
||||||
@@ -544,11 +550,17 @@ export class Map extends L.Map {
|
|||||||
this.#updateDestinationCursors();
|
this.#updateDestinationCursors();
|
||||||
}
|
}
|
||||||
|
|
||||||
#onZoom(e: any) {
|
#onZoomStart(e: any) {
|
||||||
if (this.#centerUnit != null)
|
if (this.#centerUnit != null)
|
||||||
this.#panToUnit(this.#centerUnit);
|
this.#panToUnit(this.#centerUnit);
|
||||||
|
this.#isZooming = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#onZoomEnd(e: any) {
|
||||||
|
this.#isZooming = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#panToUnit(unit: Unit) {
|
#panToUnit(unit: Unit) {
|
||||||
var unitPosition = new L.LatLng(unit.getPosition().lat, unit.getPosition().lng);
|
var unitPosition = new L.LatLng(unit.getPosition().lat, unit.getPosition().lng);
|
||||||
this.setView(unitPosition, this.getZoom(), { animate: false });
|
this.setView(unitPosition, this.getZoom(), { animate: false });
|
||||||
|
|||||||
@@ -8,12 +8,4 @@ export class ConnectionStatusPanel extends Panel {
|
|||||||
update(connected: boolean) {
|
update(connected: boolean) {
|
||||||
this.getElement().toggleAttribute( "data-is-connected", connected );
|
this.getElement().toggleAttribute( "data-is-connected", connected );
|
||||||
}
|
}
|
||||||
|
|
||||||
setMetrics(frameRate: number, load: number) {
|
|
||||||
const dt = this.getElement().querySelector("dt");
|
|
||||||
if (dt) {
|
|
||||||
dt.dataset["framerate"] = String(frameRate);
|
|
||||||
dt.dataset["load"] = String(load);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
26
client/src/panels/serverstatuspanel.ts
Normal file
26
client/src/panels/serverstatuspanel.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { Panel } from "./panel";
|
||||||
|
|
||||||
|
export class ServerStatusPanel extends Panel {
|
||||||
|
constructor(ID: string) {
|
||||||
|
super(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(frameRate: number, load: number) {
|
||||||
|
const frameRateEl = this.getElement().querySelector("#server-frame-rate");
|
||||||
|
if (frameRateEl) {
|
||||||
|
frameRateEl.textContent = `${frameRate}`;
|
||||||
|
frameRateEl.classList.toggle("fps-high", frameRate >= 60)
|
||||||
|
frameRateEl.classList.toggle("fps-medium", frameRate >= 30 && frameRate < 60)
|
||||||
|
frameRateEl.classList.toggle("fps-low", frameRate <= 30)
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadEl = this.getElement().querySelector("#server-load");
|
||||||
|
if (loadEl) {
|
||||||
|
loadEl.textContent = `${load}`;
|
||||||
|
loadEl.classList.toggle("load-high", load >= 1000)
|
||||||
|
loadEl.classList.toggle("load-medium", load >= 100 && load < 1000)
|
||||||
|
loadEl.classList.toggle("load-low", load <= 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { LatLng } from 'leaflet';
|
import { LatLng } from 'leaflet';
|
||||||
import { getConnectionStatusPanel, getInfoPopup, getMissionHandler, getUnitDataTable, getUnitsManager, setLoginStatus } from '..';
|
import { getConnectionStatusPanel, getInfoPopup, getMissionData, getServerStatusPanel, getUnitDataTable, getUnitsManager, setLoginStatus } from '..';
|
||||||
import { GeneralSettings, Radio, TACAN } from '../@types/unit';
|
import { GeneralSettings, Radio, TACAN } from '../@types/unit';
|
||||||
import { ROEs, emissionsCountermeasures, reactionsToThreat } from '../constants/constants';
|
import { ROEs, emissionsCountermeasures, reactionsToThreat } from '../constants/constants';
|
||||||
|
|
||||||
@@ -59,8 +59,8 @@ export function GET(callback: CallableFunction, uri: string, options?: { time?:
|
|||||||
const result = JSON.parse(xmlHttp.responseText);
|
const result = JSON.parse(xmlHttp.responseText);
|
||||||
lastUpdateTimes[uri] = callback(result);
|
lastUpdateTimes[uri] = callback(result);
|
||||||
|
|
||||||
if ("frameRate" in result && "load" in result)
|
if (result.frameRate !== undefined && result.load !== undefined)
|
||||||
getConnectionStatusPanel().setMetrics(result.frameRate, result.load);
|
getServerStatusPanel().update(result.frameRate, result.load);
|
||||||
}
|
}
|
||||||
} else if (xmlHttp.status == 401) {
|
} else if (xmlHttp.status == 401) {
|
||||||
/* Bad credentials */
|
/* Bad credentials */
|
||||||
|
|||||||
@@ -64,9 +64,13 @@ export class DataExtractor {
|
|||||||
extractString(length?: number) {
|
extractString(length?: number) {
|
||||||
if (length === undefined)
|
if (length === undefined)
|
||||||
length = this.extractUInt16()
|
length = this.extractUInt16()
|
||||||
const value = this.#decoder.decode(this.#buffer.slice(this.#seekPosition, this.#seekPosition + length));
|
var stringBuffer = this.#buffer.slice(this.#seekPosition, this.#seekPosition + length);
|
||||||
|
var view = new Int8Array(stringBuffer);
|
||||||
|
var stringLength = length;
|
||||||
|
view.forEach((value: number, idx: number) => { if (value === 0) stringLength = idx; });
|
||||||
|
const value = this.#decoder.decode(stringBuffer);
|
||||||
this.#seekPosition += length;
|
this.#seekPosition += length;
|
||||||
return value;
|
return value.substring(0, stringLength).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
extractChar() {
|
extractChar() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { CustomMarker } from '../map/custommarker';
|
|||||||
import { SVGInjector } from '@tanem/svg-injector';
|
import { SVGInjector } from '@tanem/svg-injector';
|
||||||
import { UnitDatabase } from './unitdatabase';
|
import { UnitDatabase } from './unitdatabase';
|
||||||
import { TargetMarker } from '../map/targetmarker';
|
import { TargetMarker } from '../map/targetmarker';
|
||||||
import { BLUE_COMMANDER, BOMBING, CARPET_BOMBING, DLINK, DataIndexes, FIRE_AT_AREA, GAME_MASTER, HIDE_ALL, IDLE, IRST, MOVE_UNIT, OPTIC, RADAR, RED_COMMANDER, ROEs, RWR, VISUAL, emissionsCountermeasures, reactionsToThreat, states } from '../constants/constants';
|
import { BLUE_COMMANDER, BOMBING, CARPET_BOMBING, DLINK, DataIndexes, FIRE_AT_AREA, GAME_MASTER, IDLE, IRST, MOVE_UNIT, OPTIC, RADAR, RED_COMMANDER, ROEs, RWR, VISUAL, emissionsCountermeasures, reactionsToThreat, states } from '../constants/constants';
|
||||||
import { Ammo, Contact, GeneralSettings, Offset, Radio, TACAN, UnitIconOptions } from '../@types/unit';
|
import { Ammo, Contact, GeneralSettings, Offset, Radio, TACAN, UnitIconOptions } from '../@types/unit';
|
||||||
import { DataExtractor } from './dataextractor';
|
import { DataExtractor } from './dataextractor';
|
||||||
import { groundUnitDatabase } from './groundunitdatabase';
|
import { groundUnitDatabase } from './groundunitdatabase';
|
||||||
@@ -157,6 +157,7 @@ export class Unit extends CustomMarker {
|
|||||||
this.on('contextmenu', (e) => this.#onContextMenu(e));
|
this.on('contextmenu', (e) => this.#onContextMenu(e));
|
||||||
this.on('mouseover', () => { this.setHighlighted(true); })
|
this.on('mouseover', () => { this.setHighlighted(true); })
|
||||||
this.on('mouseout', () => { this.setHighlighted(false); })
|
this.on('mouseout', () => { this.setHighlighted(false); })
|
||||||
|
getMap().on("zoomend", () => {this.#onZoom();})
|
||||||
|
|
||||||
/* Deselect units if they are hidden */
|
/* Deselect units if they are hidden */
|
||||||
document.addEventListener("toggleCoalitionVisibility", (ev: CustomEventInit) => {
|
document.addEventListener("toggleCoalitionVisibility", (ev: CustomEventInit) => {
|
||||||
@@ -165,9 +166,7 @@ export class Unit extends CustomMarker {
|
|||||||
|
|
||||||
document.addEventListener("toggleUnitVisibility", (ev: CustomEventInit) => {
|
document.addEventListener("toggleUnitVisibility", (ev: CustomEventInit) => {
|
||||||
window.setTimeout(() => { this.setSelected(this.getSelected() && !this.getHidden()) }, 300);
|
window.setTimeout(() => { this.setSelected(this.getSelected() && !this.getHidden()) }, 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
getMap().on("zoomend", () => {this.#onZoom();})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCategory() {
|
getCategory() {
|
||||||
@@ -379,8 +378,6 @@ export class Unit extends CustomMarker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
belongsToCommandedCoalition() {
|
belongsToCommandedCoalition() {
|
||||||
if (getUnitsManager().getCommandMode() === HIDE_ALL)
|
|
||||||
return false;
|
|
||||||
if (getUnitsManager().getCommandedCoalition() !== this.#coalition)
|
if (getUnitsManager().getCommandedCoalition() !== this.#coalition)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -497,7 +494,6 @@ export class Unit extends CustomMarker {
|
|||||||
(this.#controlled == false && hiddenUnits.includes("dcs")) ||
|
(this.#controlled == false && hiddenUnits.includes("dcs")) ||
|
||||||
(hiddenUnits.includes(this.getMarkerCategory())) ||
|
(hiddenUnits.includes(this.getMarkerCategory())) ||
|
||||||
(hiddenUnits.includes(this.#coalition)) ||
|
(hiddenUnits.includes(this.#coalition)) ||
|
||||||
(getUnitsManager().getCommandMode() === HIDE_ALL) ||
|
|
||||||
(!this.belongsToCommandedCoalition() && this.#detectionMethods.length == 0) ||
|
(!this.belongsToCommandedCoalition() && this.#detectionMethods.length == 0) ||
|
||||||
(!this.#isLeader && this.getCategory() == "GroundUnit" && getMap().getZoom() < 13)) &&
|
(!this.#isLeader && this.getCategory() == "GroundUnit" && getMap().getZoom() < 13)) &&
|
||||||
!(this.getSelected());
|
!(this.getSelected());
|
||||||
@@ -510,7 +506,10 @@ export class Unit extends CustomMarker {
|
|||||||
|
|
||||||
/* Add the marker if not present */
|
/* Add the marker if not present */
|
||||||
if (!getMap().hasLayer(this) && !this.getHidden()) {
|
if (!getMap().hasLayer(this) && !this.getHidden()) {
|
||||||
this.addTo(getMap());
|
if (getMap().isZooming())
|
||||||
|
this.once("zoomend", () => {this.addTo(getMap())})
|
||||||
|
else
|
||||||
|
this.addTo(getMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hide the marker if necessary*/
|
/* Hide the marker if necessary*/
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { cloneUnit, deleteUnit, spawnAircrafts, spawnGroundUnits, spawnHelicopte
|
|||||||
import { bearingAndDistanceToLatLng, deg2rad, keyEventWasInInput, latLngToMercator, mToFt, mercatorToLatLng, msToKnots, polyContains, polygonArea, randomPointInPoly, randomUnitBlueprint } from "../other/utils";
|
import { bearingAndDistanceToLatLng, deg2rad, keyEventWasInInput, latLngToMercator, mToFt, mercatorToLatLng, msToKnots, polyContains, polygonArea, randomPointInPoly, randomUnitBlueprint } from "../other/utils";
|
||||||
import { CoalitionArea } from "../map/coalitionarea";
|
import { CoalitionArea } from "../map/coalitionarea";
|
||||||
import { groundUnitDatabase } from "./groundunitdatabase";
|
import { groundUnitDatabase } from "./groundunitdatabase";
|
||||||
import { BLUE_COMMANDER, DataIndexes, GAME_MASTER, HIDE_ALL, IADSDensities, IDLE, MOVE_UNIT, RED_COMMANDER } from "../constants/constants";
|
import { BLUE_COMMANDER, DataIndexes, GAME_MASTER, IADSDensities, IDLE, MOVE_UNIT, RED_COMMANDER } from "../constants/constants";
|
||||||
import { DataExtractor } from "./dataextractor";
|
import { DataExtractor } from "./dataextractor";
|
||||||
import { Contact } from "../@types/unit";
|
import { Contact } from "../@types/unit";
|
||||||
import { citiesDatabase } from "./citiesdatabase";
|
import { citiesDatabase } from "./citiesdatabase";
|
||||||
@@ -19,7 +19,7 @@ export class UnitsManager {
|
|||||||
#selectionEventDisabled: boolean = false;
|
#selectionEventDisabled: boolean = false;
|
||||||
#pasteDisabled: boolean = false;
|
#pasteDisabled: boolean = false;
|
||||||
#hiddenTypes: string[] = [];
|
#hiddenTypes: string[] = [];
|
||||||
#commandMode: string = HIDE_ALL;
|
#commandMode: string = GAME_MASTER;
|
||||||
#requestDetectionUpdate: boolean = false;
|
#requestDetectionUpdate: boolean = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -96,7 +96,7 @@ export class UnitsManager {
|
|||||||
this.#units[ID]?.setData(dataExtractor);
|
this.#units[ID]?.setData(dataExtractor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.#requestDetectionUpdate) {
|
if (this.#requestDetectionUpdate && this.getCommandMode() != GAME_MASTER) {
|
||||||
for (let ID in this.#units) {
|
for (let ID in this.#units) {
|
||||||
var unit = this.#units[ID];
|
var unit = this.#units[ID];
|
||||||
if (!unit.belongsToCommandedCoalition())
|
if (!unit.belongsToCommandedCoalition())
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<%- include('panels/unitinfo.ejs') %>
|
<%- include('panels/unitinfo.ejs') %>
|
||||||
<%- include('panels/mouseinfo.ejs') %>
|
<%- include('panels/mouseinfo.ejs') %>
|
||||||
<%- include('panels/connectionstatus.ejs') %>
|
<%- include('panels/connectionstatus.ejs') %>
|
||||||
|
<%- include('panels/serverstatus.ejs') %>
|
||||||
<%- include('panels/hotgroup.ejs') %>
|
<%- include('panels/hotgroup.ejs') %>
|
||||||
|
|
||||||
<div id="toolbar-container">
|
<div id="toolbar-container">
|
||||||
|
|||||||
10
client/views/panels/serverstatus.ejs
Normal file
10
client/views/panels/serverstatus.ejs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<div id="server-status-panel" class="ol-panel" oncontextmenu="return false;">
|
||||||
|
<dl class="ol-data-grid">
|
||||||
|
<dt>Server frame rate:</dt>
|
||||||
|
<dd id="server-frame-rate"></dd>
|
||||||
|
</dl>
|
||||||
|
<dl class="ol-data-grid">
|
||||||
|
<dt>Olympus load:</dt>
|
||||||
|
<dd id="server-load"></dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
@@ -506,7 +506,7 @@ function Olympus.generateGroundUnitsTable(units)
|
|||||||
["y"] = spawnLocation.z + value.dy,
|
["y"] = spawnLocation.z + value.dy,
|
||||||
["heading"] = 0,
|
["heading"] = 0,
|
||||||
["skill"] = "High",
|
["skill"] = "High",
|
||||||
["name"] = "GroundUnit-" .. Olympus.unitCounter .. "-" .. #unitTable + 1
|
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitTable + 1
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -517,7 +517,7 @@ function Olympus.generateGroundUnitsTable(units)
|
|||||||
["y"] = spawnLocation.z,
|
["y"] = spawnLocation.z,
|
||||||
["heading"] = 0,
|
["heading"] = 0,
|
||||||
["skill"] = "High",
|
["skill"] = "High",
|
||||||
["name"] = "GroundUnit-" .. Olympus.unitCounter .. "-" .. #unitTable + 1
|
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitTable + 1
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class Command
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unsigned int getPriority() { return priority; }
|
unsigned int getPriority() { return priority; }
|
||||||
virtual string getString(lua_State* L) = 0;
|
virtual string getString() = 0;
|
||||||
virtual unsigned int getLoad() = 0;
|
virtual unsigned int getLoad() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -118,7 +118,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = CommandPriority::HIGH;
|
priority = CommandPriority::HIGH;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return 2; }
|
virtual unsigned int getLoad() { return 2; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -142,7 +142,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = CommandPriority::LOW;
|
priority = CommandPriority::LOW;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return 2; }
|
virtual unsigned int getLoad() { return 2; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -162,7 +162,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return immediate? 1: 30; }
|
virtual unsigned int getLoad() { return immediate? 1: 30; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -184,7 +184,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return immediate ? 1 : 30; }
|
virtual unsigned int getLoad() { return immediate ? 1 : 30; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -208,7 +208,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return immediate ? 1 : 30; }
|
virtual unsigned int getLoad() { return immediate ? 1 : 30; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -235,7 +235,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return immediate ? 1 : 30; }
|
virtual unsigned int getLoad() { return immediate ? 1 : 30; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -257,7 +257,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = CommandPriority::LOW;
|
priority = CommandPriority::LOW;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return 30; }
|
virtual unsigned int getLoad() { return 30; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -277,7 +277,7 @@ public:
|
|||||||
priority = CommandPriority::HIGH;
|
priority = CommandPriority::HIGH;
|
||||||
immediate = immediate;
|
immediate = immediate;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return immediate? 1: 5; }
|
virtual unsigned int getLoad() { return immediate? 1: 5; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -296,7 +296,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = CommandPriority::MEDIUM;
|
priority = CommandPriority::MEDIUM;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return 1; }
|
virtual unsigned int getLoad() { return 1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -313,7 +313,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = CommandPriority::HIGH;
|
priority = CommandPriority::HIGH;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return 1; }
|
virtual unsigned int getLoad() { return 1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -330,7 +330,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = CommandPriority::HIGH;
|
priority = CommandPriority::HIGH;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return 1; }
|
virtual unsigned int getLoad() { return 1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -361,7 +361,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = CommandPriority::HIGH;
|
priority = CommandPriority::HIGH;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return 1; }
|
virtual unsigned int getLoad() { return 1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -382,7 +382,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = CommandPriority::HIGH;
|
priority = CommandPriority::HIGH;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return 1; }
|
virtual unsigned int getLoad() { return 1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -400,7 +400,7 @@ public:
|
|||||||
{
|
{
|
||||||
priority = CommandPriority::MEDIUM;
|
priority = CommandPriority::MEDIUM;
|
||||||
};
|
};
|
||||||
virtual string getString(lua_State* L);
|
virtual string getString();
|
||||||
virtual unsigned int getLoad() { return 4; }
|
virtual unsigned int getLoad() { return 4; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
extern UnitsManager* unitsManager;
|
extern UnitsManager* unitsManager;
|
||||||
|
|
||||||
/* Move command */
|
/* Move command */
|
||||||
string Move::getString(lua_State* L)
|
string Move::getString()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::ostringstream commandSS;
|
std::ostringstream commandSS;
|
||||||
@@ -26,7 +26,7 @@ string Move::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Smoke command */
|
/* Smoke command */
|
||||||
string Smoke::getString(lua_State* L)
|
string Smoke::getString()
|
||||||
{
|
{
|
||||||
std::ostringstream commandSS;
|
std::ostringstream commandSS;
|
||||||
commandSS.precision(10);
|
commandSS.precision(10);
|
||||||
@@ -38,7 +38,7 @@ string Smoke::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Spawn ground units command */
|
/* Spawn ground units command */
|
||||||
string SpawnGroundUnits::getString(lua_State* L)
|
string SpawnGroundUnits::getString()
|
||||||
{
|
{
|
||||||
if (unitTypes.size() != locations.size()) return "";
|
if (unitTypes.size() != locations.size()) return "";
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ string SpawnGroundUnits::getString(lua_State* L)
|
|||||||
|
|
||||||
|
|
||||||
/* Spawn ground units command */
|
/* Spawn ground units command */
|
||||||
string SpawnNavyUnits::getString(lua_State* L)
|
string SpawnNavyUnits::getString()
|
||||||
{
|
{
|
||||||
if (unitTypes.size() != locations.size()) return "";
|
if (unitTypes.size() != locations.size()) return "";
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ string SpawnNavyUnits::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Spawn aircrafts command */
|
/* Spawn aircrafts command */
|
||||||
string SpawnAircrafts::getString(lua_State* L)
|
string SpawnAircrafts::getString()
|
||||||
{
|
{
|
||||||
if (unitTypes.size() != locations.size() || unitTypes.size() != loadouts.size()) return "";
|
if (unitTypes.size() != locations.size() || unitTypes.size() != loadouts.size()) return "";
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ string SpawnAircrafts::getString(lua_State* L)
|
|||||||
|
|
||||||
|
|
||||||
/* Spawn helicopters command */
|
/* Spawn helicopters command */
|
||||||
string SpawnHelicopters::getString(lua_State* L)
|
string SpawnHelicopters::getString()
|
||||||
{
|
{
|
||||||
if (unitTypes.size() != locations.size() || unitTypes.size() != loadouts.size()) return "";
|
if (unitTypes.size() != locations.size() || unitTypes.size() != loadouts.size()) return "";
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ string SpawnHelicopters::getString(lua_State* L)
|
|||||||
|
|
||||||
|
|
||||||
/* Clone unit command */
|
/* Clone unit command */
|
||||||
string Clone::getString(lua_State* L)
|
string Clone::getString()
|
||||||
{
|
{
|
||||||
Unit* unit = unitsManager->getUnit(ID);
|
Unit* unit = unitsManager->getUnit(ID);
|
||||||
if (unit != nullptr)
|
if (unit != nullptr)
|
||||||
@@ -160,7 +160,7 @@ string Clone::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Delete unit command */
|
/* Delete unit command */
|
||||||
string Delete::getString(lua_State* L)
|
string Delete::getString()
|
||||||
{
|
{
|
||||||
std::ostringstream commandSS;
|
std::ostringstream commandSS;
|
||||||
commandSS.precision(10);
|
commandSS.precision(10);
|
||||||
@@ -171,7 +171,7 @@ string Delete::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set task command */
|
/* Set task command */
|
||||||
string SetTask::getString(lua_State* L)
|
string SetTask::getString()
|
||||||
{
|
{
|
||||||
std::ostringstream commandSS;
|
std::ostringstream commandSS;
|
||||||
commandSS.precision(10);
|
commandSS.precision(10);
|
||||||
@@ -183,7 +183,7 @@ string SetTask::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Reset task command */
|
/* Reset task command */
|
||||||
string ResetTask::getString(lua_State* L)
|
string ResetTask::getString()
|
||||||
{
|
{
|
||||||
std::ostringstream commandSS;
|
std::ostringstream commandSS;
|
||||||
commandSS.precision(10);
|
commandSS.precision(10);
|
||||||
@@ -194,7 +194,7 @@ string ResetTask::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set command command */
|
/* Set command command */
|
||||||
string SetCommand::getString(lua_State* L)
|
string SetCommand::getString()
|
||||||
{
|
{
|
||||||
std::ostringstream commandSS;
|
std::ostringstream commandSS;
|
||||||
commandSS.precision(10);
|
commandSS.precision(10);
|
||||||
@@ -206,7 +206,7 @@ string SetCommand::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set option command */
|
/* Set option command */
|
||||||
string SetOption::getString(lua_State* L)
|
string SetOption::getString()
|
||||||
{
|
{
|
||||||
std::ostringstream commandSS;
|
std::ostringstream commandSS;
|
||||||
commandSS.precision(10);
|
commandSS.precision(10);
|
||||||
@@ -226,7 +226,7 @@ string SetOption::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set onOff command */
|
/* Set onOff command */
|
||||||
string SetOnOff::getString(lua_State* L)
|
string SetOnOff::getString()
|
||||||
{
|
{
|
||||||
std::ostringstream commandSS;
|
std::ostringstream commandSS;
|
||||||
commandSS.precision(10);
|
commandSS.precision(10);
|
||||||
@@ -239,7 +239,7 @@ string SetOnOff::getString(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Explosion command */
|
/* Explosion command */
|
||||||
string Explosion::getString(lua_State* L)
|
string Explosion::getString()
|
||||||
{
|
{
|
||||||
std::ostringstream commandSS;
|
std::ostringstream commandSS;
|
||||||
commandSS.precision(10);
|
commandSS.precision(10);
|
||||||
|
|||||||
@@ -70,19 +70,18 @@ extern "C" DllExport int coreFrame(lua_State* L)
|
|||||||
frameCounter++;
|
frameCounter++;
|
||||||
|
|
||||||
const std::chrono::duration<double> executionDuration = std::chrono::system_clock::now() - lastExecution;
|
const std::chrono::duration<double> executionDuration = std::chrono::system_clock::now() - lastExecution;
|
||||||
if (executionDuration.count() > EXECUTION_TIME_INTERVAL) {
|
if (executionDuration.count() > FRAMERATE_TIME_INTERVAL) {
|
||||||
if (scheduler != nullptr) {
|
if (executionDuration.count() > 0) {
|
||||||
scheduler->execute(L);
|
scheduler->setFrameRate(frameCounter / executionDuration.count());
|
||||||
|
frameCounter = 0;
|
||||||
if (executionDuration.count() > 0) {
|
|
||||||
scheduler->setFrameRate(frameCounter / executionDuration.count());
|
|
||||||
frameCounter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastExecution = std::chrono::system_clock::now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastExecution = std::chrono::system_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scheduler != nullptr)
|
||||||
|
scheduler->execute(L);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ Scheduler::~Scheduler()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scheduler::appendCommand(Command* command)
|
void Scheduler::appendCommand(Command* newCommand)
|
||||||
{
|
{
|
||||||
commands.push_back(command);
|
for (auto command : commands) {
|
||||||
|
if (command->getString().compare(newCommand->getString()) == 0 && command->getPriority() == newCommand->getPriority())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
commands.push_back(newCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Scheduler::getLoad()
|
int Scheduler::getLoad()
|
||||||
@@ -47,13 +51,14 @@ void Scheduler::execute(lua_State* L)
|
|||||||
{
|
{
|
||||||
if (command->getPriority() == priority)
|
if (command->getPriority() == priority)
|
||||||
{
|
{
|
||||||
string commandString = "Olympus.protectedCall(" + command->getString(L) + ")";
|
string commandString = "Olympus.protectedCall(" + command->getString() + ")";
|
||||||
if (dostring_in(L, "server", (commandString)))
|
if (dostring_in(L, "server", (commandString)))
|
||||||
log("Error executing command " + commandString);
|
log("Error executing command " + commandString);
|
||||||
else
|
else
|
||||||
log("Command '" + commandString + "' executed correctly, current load " + to_string(getLoad()));
|
log("Command '" + commandString + "' executed correctly, current load " + to_string(getLoad()));
|
||||||
load = command->getLoad();
|
load = command->getLoad();
|
||||||
commands.remove(command);
|
commands.remove(command);
|
||||||
|
delete command;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ void Logger::Close()
|
|||||||
void Logger::toJSON(json::value& json, unsigned long long time)
|
void Logger::toJSON(json::value& json, unsigned long long time)
|
||||||
{
|
{
|
||||||
lock_guard<mutex> guard(mutexLock);
|
lock_guard<mutex> guard(mutexLock);
|
||||||
json[L"requestTime"] = time;
|
|
||||||
|
|
||||||
/* Loop on the logs in reverse since we are usually only interested in the very last added logs */
|
/* Loop on the logs in reverse since we are usually only interested in the very last added logs */
|
||||||
auto itr = m_logs.end();
|
auto itr = m_logs.end();
|
||||||
while (itr != m_logs.begin())
|
while (itr != m_logs.begin())
|
||||||
|
|||||||
@@ -10,4 +10,4 @@
|
|||||||
#define BULLSEYE_URI "bullseyes"
|
#define BULLSEYE_URI "bullseyes"
|
||||||
#define MISSION_URI "mission"
|
#define MISSION_URI "mission"
|
||||||
|
|
||||||
#define EXECUTION_TIME_INTERVAL 0.05
|
#define FRAMERATE_TIME_INTERVAL 0.05
|
||||||
Reference in New Issue
Block a user