mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Compare commits
998 Commits
v0.3.0-alp
...
v1-archive
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
182fe294de | ||
|
|
95db9b5d38 | ||
|
|
a6e28e9064 | ||
|
|
116d4fa894 | ||
|
|
8b5df691ec | ||
|
|
f00fce7fe7 | ||
|
|
6bb150a41c | ||
|
|
2cadebcabd | ||
|
|
b61289d996 | ||
|
|
89051c3e85 | ||
|
|
064c24e023 | ||
|
|
e273203629 | ||
|
|
17b10bebd5 | ||
|
|
5e5ee30b8f | ||
|
|
5cd566c7ca | ||
|
|
119a6f620c | ||
|
|
3e22247f76 | ||
|
|
854bef15e0 | ||
|
|
aacf6d99bc | ||
|
|
a8595a97d8 | ||
|
|
c630fe3045 | ||
|
|
05c7d8166b | ||
|
|
1d3d8ca705 | ||
|
|
97a11d6873 | ||
|
|
15e23564c2 | ||
|
|
42782c60a4 | ||
|
|
62b2b13d75 | ||
|
|
8bf2048d4d | ||
|
|
0fee5c8e7f | ||
|
|
b5e47fdbe6 | ||
|
|
c85e923899 | ||
|
|
a897401975 | ||
|
|
2f43a84224 | ||
|
|
274c16851e | ||
|
|
e77356cb61 | ||
|
|
f4e77b1f5b | ||
|
|
95247062a3 | ||
|
|
959b083a60 | ||
|
|
395409ecae | ||
|
|
5a2b050104 | ||
|
|
732b837a46 | ||
|
|
d60d2e78ef | ||
|
|
a15d2e2ec7 | ||
|
|
df1839cee0 | ||
|
|
1b4d3dd832 | ||
|
|
0e414850bd | ||
|
|
40e984982b | ||
|
|
d7c278b034 | ||
|
|
4e679344d0 | ||
|
|
b0ab0ae8cf | ||
|
|
6edcd8a5ce | ||
|
|
aa0cca67a1 | ||
|
|
c477dcd065 | ||
|
|
6db4455d5a | ||
|
|
54bf19d410 | ||
|
|
52833cadee | ||
|
|
6a45bc9e79 | ||
|
|
88d17d1cb3 | ||
|
|
8c27fdb53c | ||
|
|
e7777a2a48 | ||
|
|
fa4a0ccecb | ||
|
|
b54aa45377 | ||
|
|
eecdcad8e7 | ||
|
|
d68ac6cf2b | ||
|
|
e39b6b5eea | ||
|
|
4eb1b3ef6d | ||
|
|
4204a4b150 | ||
|
|
b64d336922 | ||
|
|
19c1ae82a2 | ||
|
|
61dc9c8b31 | ||
|
|
d078105eb7 | ||
|
|
7ee9946f49 | ||
|
|
5507bca68d | ||
|
|
535b95242c | ||
|
|
e40b79d2c4 | ||
|
|
ecd0581942 | ||
|
|
4f7c3988a0 | ||
|
|
5b7e63b02d | ||
|
|
ef99c21380 | ||
|
|
e0ad679b57 | ||
|
|
61fb80d67f | ||
|
|
a9a0332465 | ||
|
|
4494a5ccbb | ||
|
|
f0c4b10084 | ||
|
|
0bdf362174 | ||
|
|
a53cca8dda | ||
|
|
9aad81588a | ||
|
|
5ba1498802 | ||
|
|
539b183da8 | ||
|
|
396c061a3e | ||
|
|
8c7f6abb1c | ||
|
|
5cc42dd9cf | ||
|
|
f52b5f419e | ||
|
|
3b38ca5920 | ||
|
|
86cfb4fb2f | ||
|
|
166631d618 | ||
|
|
013546a45b | ||
|
|
a2c8563adf | ||
|
|
0c8de2dcf3 | ||
|
|
4f3491062b | ||
|
|
cc8c25a283 | ||
|
|
70740233a9 | ||
|
|
f2d4f0b0ca | ||
|
|
153ca01b96 | ||
|
|
f667410a56 | ||
|
|
f13545eae9 | ||
|
|
7ee24b1c7c | ||
|
|
29784310fc | ||
|
|
3427fcea7e | ||
|
|
c99b5ed19f | ||
|
|
2118ded496 | ||
|
|
4401261446 | ||
|
|
a6ec3a8cd0 | ||
|
|
6e6da64c51 | ||
|
|
a84e190548 | ||
|
|
e0238c2680 | ||
|
|
a60f2e7b62 | ||
|
|
4782596e3c | ||
|
|
832568aa00 | ||
|
|
05e0cc393a | ||
|
|
c74258e3ad | ||
|
|
2e1c3ec4b9 | ||
|
|
9a571132c8 | ||
|
|
acb55044d1 | ||
|
|
14679bd7d8 | ||
|
|
3c9af59051 | ||
|
|
8390a25c50 | ||
|
|
97b277edda | ||
|
|
462fa53c80 | ||
|
|
945c45803b | ||
|
|
20917da437 | ||
|
|
cd25509d3d | ||
|
|
4c3f80d7d7 | ||
|
|
fac32476d4 | ||
|
|
3fa88f3cdf | ||
|
|
46135f7ae0 | ||
|
|
f6e9503045 | ||
|
|
39c28ffb04 | ||
|
|
6373fd300d | ||
|
|
04f281db56 | ||
|
|
5f2fb60e1f | ||
|
|
4efd48c4b9 | ||
|
|
fb6ac40af8 | ||
|
|
9daa683b42 | ||
|
|
baffc9af49 | ||
|
|
bc6c70928f | ||
|
|
9e1503c106 | ||
|
|
57a700d2d2 | ||
|
|
5ca6c97cbe | ||
|
|
55f3bd5adb | ||
|
|
bf7c4beccd | ||
|
|
14d44babe7 | ||
|
|
30a90a96d8 | ||
|
|
c621b5dd85 | ||
|
|
63bdf44e17 | ||
|
|
029decf969 | ||
|
|
b5c7eaf36e | ||
|
|
99de17a858 | ||
|
|
5765ade7f8 | ||
|
|
59a8fba14d | ||
|
|
965b67b8ab | ||
|
|
0ef3abbffa | ||
|
|
2124e9cd42 | ||
|
|
2f1a0ad7d3 | ||
|
|
24e6c219f5 | ||
|
|
daec6dab5b | ||
|
|
3708d4150c | ||
|
|
11518485de | ||
|
|
29118e1ea1 | ||
|
|
aa5b62c1d2 | ||
|
|
f320cb122c | ||
|
|
bb7738724f | ||
|
|
df7eebed39 | ||
|
|
21040da195 | ||
|
|
be625fdca9 | ||
|
|
7ee3fb883b | ||
|
|
c2f6edfd74 | ||
|
|
4f5023b45c | ||
|
|
f0ab43d320 | ||
|
|
d2e803ab82 | ||
|
|
ca45b8b906 | ||
|
|
ec020f7b5d | ||
|
|
f2161da162 | ||
|
|
613aed2d2b | ||
|
|
1d38bd6fea | ||
|
|
6f7b251094 | ||
|
|
a9d873a05f | ||
|
|
05f98b2738 | ||
|
|
1568c65492 | ||
|
|
4a5c4ed7d7 | ||
|
|
ff7385cf49 | ||
|
|
a0de159234 | ||
|
|
d56a95cfa3 | ||
|
|
497f718e4b | ||
|
|
9942ff476b | ||
|
|
c042d2b6f5 | ||
|
|
b9201d583c | ||
|
|
3f67125f20 | ||
|
|
4f72f10642 | ||
|
|
89fb0a9da1 | ||
|
|
0e9b249bba | ||
|
|
0f0ba4c725 | ||
|
|
5542109daf | ||
|
|
ec91b597c8 | ||
|
|
d0f85ae977 | ||
|
|
7d6930fba9 | ||
|
|
2232a114b7 | ||
|
|
33ce537993 | ||
|
|
1ab8e9a16f | ||
|
|
73b1714191 | ||
|
|
cb793e9d0f | ||
|
|
7686a60bfd | ||
|
|
38027b6ff3 | ||
|
|
a512b0e405 | ||
|
|
46fb6a98d5 | ||
|
|
1a8a19ae5c | ||
|
|
8865ded4bd | ||
|
|
7adfe9cce4 | ||
|
|
85e5a6a309 | ||
|
|
d681d3cee0 | ||
|
|
c5650ba29a | ||
|
|
ef0a2d2ddc | ||
|
|
f143e8d874 | ||
|
|
89c1660988 | ||
|
|
4e7c8ef856 | ||
|
|
8024db9579 | ||
|
|
a0634a7f99 | ||
|
|
7bf6c1bb23 | ||
|
|
a62ae4e21e | ||
|
|
6c466a8bb8 | ||
|
|
36f828acb1 | ||
|
|
046e096b9e | ||
|
|
82df3cb316 | ||
|
|
1ba16f82e7 | ||
|
|
72c6bb0086 | ||
|
|
8bb4334187 | ||
|
|
59a9069d4b | ||
|
|
ba534f1786 | ||
|
|
72bb54bde0 | ||
|
|
cb3f46303c | ||
|
|
57f021f995 | ||
|
|
bf4b2272e4 | ||
|
|
31999ec00c | ||
|
|
086b6736b0 | ||
|
|
bf93b8e90a | ||
|
|
4d6bd6c6e9 | ||
|
|
c9dc5eb2f5 | ||
|
|
5fdb704d68 | ||
|
|
6d18e25232 | ||
|
|
7391006a2f | ||
|
|
9207585f5b | ||
|
|
cb53da3a71 | ||
|
|
d2ac5aeff8 | ||
|
|
b646087026 | ||
|
|
82e60cd2cf | ||
|
|
9d46a1c73f | ||
|
|
955057183d | ||
|
|
0396d6bf9c | ||
|
|
ee1d89007c | ||
|
|
4245927a6c | ||
|
|
f585828936 | ||
|
|
7450c9e506 | ||
|
|
d957cd6655 | ||
|
|
ef91f840ae | ||
|
|
17c74fbe91 | ||
|
|
17a7a1889e | ||
|
|
24ed96b348 | ||
|
|
15e8c9e791 | ||
|
|
de14f6c738 | ||
|
|
92b1a46e8a | ||
|
|
cbaadb6fc9 | ||
|
|
44295673dc | ||
|
|
8bf0f403e2 | ||
|
|
917a0d10e5 | ||
|
|
9c65411733 | ||
|
|
6c315d89e1 | ||
|
|
b5f1a459c2 | ||
|
|
6b12000979 | ||
|
|
1aec7f8081 | ||
|
|
5f0e96e2e6 | ||
|
|
678a8585a9 | ||
|
|
e632e379b6 | ||
|
|
1a7d2b5028 | ||
|
|
ce28d49510 | ||
|
|
0ac632cc9b | ||
|
|
47e4757b6e | ||
|
|
d21ee2a7b6 | ||
|
|
0cec61afea | ||
|
|
ff04364178 | ||
|
|
0cf2733d55 | ||
|
|
f5319ed654 | ||
|
|
cfef9f4bc4 | ||
|
|
6abf7f059a | ||
|
|
c0c1ff6e17 | ||
|
|
856dba83a5 | ||
|
|
2f37916595 | ||
|
|
f36a29570b | ||
|
|
62a3719163 | ||
|
|
e9511e9233 | ||
|
|
51cf15b8cc | ||
|
|
278d0bdd3c | ||
|
|
0a07f85fcf | ||
|
|
7face05e12 | ||
|
|
22ad5d5972 | ||
|
|
2e194d557a | ||
|
|
1a76df2056 | ||
|
|
787bf13f3c | ||
|
|
10f1c6a862 | ||
|
|
0366cc38e2 | ||
|
|
603018d1ef | ||
|
|
66ae06056b | ||
|
|
17486ab40c | ||
|
|
6cae91b06f | ||
|
|
9c055e0d71 | ||
|
|
db4aeca47d | ||
|
|
c29a368e5a | ||
|
|
dbe2442bb7 | ||
|
|
2108fc4b26 | ||
|
|
48f962ca4b | ||
|
|
e80a5e8ca1 | ||
|
|
fb2ecc75eb | ||
|
|
ee95291418 | ||
|
|
46796fce13 | ||
|
|
ee08f57abe | ||
|
|
eb86d8dfca | ||
|
|
c75e20e58f | ||
|
|
2c403a9283 | ||
|
|
27c78d6a67 | ||
|
|
e0d33760e0 | ||
|
|
2d339d7161 | ||
|
|
243f58ecf3 | ||
|
|
378dbfc085 | ||
|
|
cee6839b5d | ||
|
|
f1a836c222 | ||
|
|
cbf4b56ecb | ||
|
|
e2e3da6a0f | ||
|
|
3a96808aa5 | ||
|
|
d1ccccae18 | ||
|
|
d31242124f | ||
|
|
8c4996f466 | ||
|
|
59b89dc638 | ||
|
|
f54ac5c3d8 | ||
|
|
666b3e0383 | ||
|
|
d8893e21a1 | ||
|
|
5391b567b9 | ||
|
|
ad7ea014f2 | ||
|
|
ceb00a239f | ||
|
|
81ab1aa05d | ||
|
|
7bf232f146 | ||
|
|
3f07271931 | ||
|
|
1c30bb006b | ||
|
|
34594ac836 | ||
|
|
cee58800e1 | ||
|
|
ab3b487024 | ||
|
|
91b393eb35 | ||
|
|
edb4ddc287 | ||
|
|
f9fd5caa9f | ||
|
|
d5653a9b1d | ||
|
|
ec5ff1bf0c | ||
|
|
41912d1057 | ||
|
|
228452fd17 | ||
|
|
484d3dd28f | ||
|
|
a52e7e7b1a | ||
|
|
92a08f6278 | ||
|
|
8e3da65433 | ||
|
|
3f625c03b9 | ||
|
|
4423d5f3d5 | ||
|
|
d0fc286c43 | ||
|
|
b5443ab0a8 | ||
|
|
e6c34306c9 | ||
|
|
532a83fe91 | ||
|
|
293b928764 | ||
|
|
38d62df75d | ||
|
|
fbd42ade6e | ||
|
|
9af1cffe08 | ||
|
|
b0d92906e5 | ||
|
|
0329e27713 | ||
|
|
2d39862b1b | ||
|
|
5c1782ec7f | ||
|
|
6c6117aee3 | ||
|
|
1798e62315 | ||
|
|
2b2ed76aa3 | ||
|
|
38d72a5cd0 | ||
|
|
14ec4a8610 | ||
|
|
bdc7a5bb46 | ||
|
|
131f30405c | ||
|
|
dbf21e0af9 | ||
|
|
9094f8fdc6 | ||
|
|
aa0b0a585c | ||
|
|
ad61037452 | ||
|
|
66ed1a99e0 | ||
|
|
d7dc5769a8 | ||
|
|
b0ee653bff | ||
|
|
5a950e22ce | ||
|
|
0459d5c625 | ||
|
|
43d28ebe19 | ||
|
|
187b9be57a | ||
|
|
564a650403 | ||
|
|
0e403e8b74 | ||
|
|
840cdd9049 | ||
|
|
e5e7e9be14 | ||
|
|
e677968ba7 | ||
|
|
d24b955d52 | ||
|
|
48860ff514 | ||
|
|
0e78b7559b | ||
|
|
25edfc45e5 | ||
|
|
885825e5cc | ||
|
|
344413ae74 | ||
|
|
fa0643987b | ||
|
|
dcff462b32 | ||
|
|
fa04e5f8bb | ||
|
|
c8d5f9ce0e | ||
|
|
55642a89b1 | ||
|
|
f305aa3929 | ||
|
|
47ee88c339 | ||
|
|
022e041f68 | ||
|
|
0cc53890c1 | ||
|
|
e37f7a4977 | ||
|
|
8d03c6a767 | ||
|
|
e29fdfd8c7 | ||
|
|
af619c3687 | ||
|
|
6afb6682ea | ||
|
|
9c2c7f45c6 | ||
|
|
7fbc19e90a | ||
|
|
8f2f73dc0e | ||
|
|
24a1681337 | ||
|
|
304e8ba3a0 | ||
|
|
45b840fa72 | ||
|
|
82704f042b | ||
|
|
87d71da55e | ||
|
|
71cf7c67f7 | ||
|
|
62142ed976 | ||
|
|
f56bd514dc | ||
|
|
e30f161d1d | ||
|
|
720bfb3118 | ||
|
|
4100a3cc67 | ||
|
|
942993ff6d | ||
|
|
fbf435c799 | ||
|
|
8fdb0d82e8 | ||
|
|
dcbebab61b | ||
|
|
7b10afae43 | ||
|
|
81d8a88abd | ||
|
|
cb14158a0f | ||
|
|
38fc60352a | ||
|
|
3748f0d6e3 | ||
|
|
edd626d5e5 | ||
|
|
f785e75686 | ||
|
|
9a46ed70b7 | ||
|
|
532c09a815 | ||
|
|
e430d38c63 | ||
|
|
289b36de6d | ||
|
|
7e01f40e5c | ||
|
|
cac4bb5f13 | ||
|
|
c8bb041887 | ||
|
|
9302c5c6d1 | ||
|
|
84a3313f2c | ||
|
|
1eb3beeb2e | ||
|
|
d0e6ef8c6c | ||
|
|
5da1df7e20 | ||
|
|
16fa6d9805 | ||
|
|
0ca7766689 | ||
|
|
4342575418 | ||
|
|
4cdb73a60d | ||
|
|
a23c53bcb8 | ||
|
|
19ac4f92e0 | ||
|
|
0b8f48b4fd | ||
|
|
d2fa94a6cb | ||
|
|
da1c674911 | ||
|
|
7184bc1eb2 | ||
|
|
37f30a0f1a | ||
|
|
04f4b3e78a | ||
|
|
dbdc162fae | ||
|
|
563f673fb3 | ||
|
|
423e799a82 | ||
|
|
4734b89414 | ||
|
|
6f708e7733 | ||
|
|
f0c3f95189 | ||
|
|
93ca0e3f22 | ||
|
|
d94432636f | ||
|
|
60fca35d80 | ||
|
|
db71462d1c | ||
|
|
86f522176a | ||
|
|
94ee71c48f | ||
|
|
fda0b21fb0 | ||
|
|
775148cec8 | ||
|
|
f2dc4a1a00 | ||
|
|
eda5723a3c | ||
|
|
b044d9a6c0 | ||
|
|
125d5396b9 | ||
|
|
17b8b35a43 | ||
|
|
4bd017e3c7 | ||
|
|
37447a7fd3 | ||
|
|
1ed1dec65e | ||
|
|
5e2e465813 | ||
|
|
335655406e | ||
|
|
bf12d6330c | ||
|
|
3cca3187ad | ||
|
|
f4388a2cff | ||
|
|
7cf5d324eb | ||
|
|
ec9ef2b0fb | ||
|
|
6c852d93a9 | ||
|
|
290067932e | ||
|
|
4aa3a43604 | ||
|
|
3c33696452 | ||
|
|
3ea1ab8f30 | ||
|
|
76801f773d | ||
|
|
de7eeec94a | ||
|
|
0723a3ab95 | ||
|
|
8ef48ad977 | ||
|
|
ed24d1af60 | ||
|
|
e3dffb8245 | ||
|
|
74310a5ad3 | ||
|
|
a2223165e8 | ||
|
|
a879761dc2 | ||
|
|
124b909aa4 | ||
|
|
858e9eb066 | ||
|
|
7415e0cb97 | ||
|
|
915020ddc3 | ||
|
|
95915489b2 | ||
|
|
3e39c3351a | ||
|
|
244d32e7d2 | ||
|
|
16a79827b7 | ||
|
|
bd6a36e9ea | ||
|
|
771695af59 | ||
|
|
e811c7bd46 | ||
|
|
20f99c287f | ||
|
|
f464c9ae76 | ||
|
|
15ccb3dc04 | ||
|
|
defe40d48f | ||
|
|
0f2622e821 | ||
|
|
b442d238cd | ||
|
|
00f2a3c19d | ||
|
|
dcbfdf8666 | ||
|
|
6e84423032 | ||
|
|
912ab75a96 | ||
|
|
1022fc2f0c | ||
|
|
65edce855b | ||
|
|
0ba05d5795 | ||
|
|
1b17e17290 | ||
|
|
87957df1fb | ||
|
|
d3f8d4eff7 | ||
|
|
3ffeed3b39 | ||
|
|
4197e4402c | ||
|
|
1cfe6f5583 | ||
|
|
ad5cb83abf | ||
|
|
f4a4882dbc | ||
|
|
ecb2cf182a | ||
|
|
6aea839e04 | ||
|
|
e20d2fa95a | ||
|
|
806d0cc52f | ||
|
|
2a2baaf324 | ||
|
|
74989ec015 | ||
|
|
31af3a53ce | ||
|
|
361d51b55d | ||
|
|
a12c09eba5 | ||
|
|
bcfe0653bd | ||
|
|
c43bc763f3 | ||
|
|
85325c17ac | ||
|
|
178706f8de | ||
|
|
51defbb8b2 | ||
|
|
84cf9aa27a | ||
|
|
a66098e080 | ||
|
|
283b9e682e | ||
|
|
8b5956e76b | ||
|
|
017a89b945 | ||
|
|
5bc685182b | ||
|
|
f47fc2fb19 | ||
|
|
11d6f25606 | ||
|
|
331692e3d3 | ||
|
|
7483225e0d | ||
|
|
f00df5ca3f | ||
|
|
22ae882032 | ||
|
|
fbab82e4de | ||
|
|
ca81d1c4ce | ||
|
|
a1884ab19f | ||
|
|
8905cd5e85 | ||
|
|
8d5ed33ad8 | ||
|
|
b747752b76 | ||
|
|
4e13daa270 | ||
|
|
c00096bd9a | ||
|
|
210c1fbecf | ||
|
|
4a54011aac | ||
|
|
b89c5142b6 | ||
|
|
0421f6b8fe | ||
|
|
0c50141be6 | ||
|
|
a71b8806e7 | ||
|
|
e0a27c574f | ||
|
|
8d7a49a31f | ||
|
|
25e2c50438 | ||
|
|
e3423ea9a3 | ||
|
|
812112858c | ||
|
|
8db1357904 | ||
|
|
bba0aa9f52 | ||
|
|
1cc549b24a | ||
|
|
7cafeb73ca | ||
|
|
772f082913 | ||
|
|
9f7efe3018 | ||
|
|
a28584b08b | ||
|
|
5cba46a482 | ||
|
|
a15b7620eb | ||
|
|
9ef6efa3e0 | ||
|
|
49bff88c4e | ||
|
|
80af34fa3e | ||
|
|
1d6f2644aa | ||
|
|
dc61d364d1 | ||
|
|
78de9dd538 | ||
|
|
ccaea5b9d1 | ||
|
|
e02e9de55d | ||
|
|
40da192dbb | ||
|
|
c8254238c7 | ||
|
|
9caee0c77c | ||
|
|
b9830f0190 | ||
|
|
02a0a9b783 | ||
|
|
ea1758a1a9 | ||
|
|
b43afd4e9c | ||
|
|
7700aa2030 | ||
|
|
d5d8391f63 | ||
|
|
b508d2301b | ||
|
|
01b3336709 | ||
|
|
6ba37aefd6 | ||
|
|
e68683acb7 | ||
|
|
a804904ff5 | ||
|
|
eacb89176c | ||
|
|
ec971aa822 | ||
|
|
e1f404c647 | ||
|
|
5f1e32d610 | ||
|
|
732ee2bbb9 | ||
|
|
1e461250d5 | ||
|
|
f727174044 | ||
|
|
7edc687f7b | ||
|
|
596fbf0b87 | ||
|
|
8dc48c10c3 | ||
|
|
5db90e5896 | ||
|
|
dd811def07 | ||
|
|
5273291e9a | ||
|
|
130dbda499 | ||
|
|
769aea7e4e | ||
|
|
fa3d65bde6 | ||
|
|
073281135c | ||
|
|
4c7f979e56 | ||
|
|
a5bfb4f8d2 | ||
|
|
a04780f311 | ||
|
|
aad0fd22ad | ||
|
|
bc1c3994d3 | ||
|
|
840033aa6a | ||
|
|
9cc6e9e790 | ||
|
|
b1ad2f409e | ||
|
|
7106646042 | ||
|
|
31405119f0 | ||
|
|
2e5ee93361 | ||
|
|
f981a661d5 | ||
|
|
7e05bbf5e3 | ||
|
|
4465f4a3bb | ||
|
|
ade4f183cd | ||
|
|
99dc61799f | ||
|
|
a213b94606 | ||
|
|
6600ed8cbb | ||
|
|
826bf12bd6 | ||
|
|
528e0db79c | ||
|
|
11a5fec195 | ||
|
|
c0f3f3a40a | ||
|
|
88844db23a | ||
|
|
31710b4e28 | ||
|
|
42d2f6400b | ||
|
|
2701d6adc0 | ||
|
|
5a4b203937 | ||
|
|
74cb7877cb | ||
|
|
f954338c27 | ||
|
|
cc729b1d25 | ||
|
|
4a4b1d6b00 | ||
|
|
d14741f3b1 | ||
|
|
94684fff9f | ||
|
|
44deef4a5a | ||
|
|
67079e1c0b | ||
|
|
005ffc55ce | ||
|
|
1691b0b30c | ||
|
|
e4e55430ca | ||
|
|
4d31d9d748 | ||
|
|
1413f596fb | ||
|
|
c0aee94da5 | ||
|
|
8e545346e6 | ||
|
|
2b1272c70d | ||
|
|
121f9b6ec3 | ||
|
|
6f9722143e | ||
|
|
5bf62f4b93 | ||
|
|
79319dd006 | ||
|
|
fdcff53697 | ||
|
|
24cd2729db | ||
|
|
9ca2703f16 | ||
|
|
1a579c5755 | ||
|
|
7344c761fe | ||
|
|
203a981fed | ||
|
|
d3faf65900 | ||
|
|
5efbf81090 | ||
|
|
9ffab7d531 | ||
|
|
0886ff1be1 | ||
|
|
2893182713 | ||
|
|
478bb18ab2 | ||
|
|
eae07ca6cc | ||
|
|
2264faabfc | ||
|
|
4cdf82cb14 | ||
|
|
5a7e511dac | ||
|
|
a29eb3d343 | ||
|
|
3c65aefe61 | ||
|
|
867d7697d2 | ||
|
|
ebee6610a3 | ||
|
|
c26691c2fc | ||
|
|
a038d6e999 | ||
|
|
aa1550ca01 | ||
|
|
80eaa643c9 | ||
|
|
d67d9c1afd | ||
|
|
af15fc123d | ||
|
|
0ce56e6529 | ||
|
|
258164c285 | ||
|
|
746617deb0 | ||
|
|
c51d00673d | ||
|
|
bedd21522a | ||
|
|
382013d0ca | ||
|
|
3794207d97 | ||
|
|
2805323cfa | ||
|
|
0db2e56e32 | ||
|
|
a33ad18322 | ||
|
|
885ef6b357 | ||
|
|
2435072b07 | ||
|
|
d462bd16b5 | ||
|
|
b08a3835dc | ||
|
|
ace0908d84 | ||
|
|
5186fffb5e | ||
|
|
c5160c9baa | ||
|
|
63acc94558 | ||
|
|
fc82407d9a | ||
|
|
a0ac9eb285 | ||
|
|
fc835eaba7 | ||
|
|
f7b3e5bf77 | ||
|
|
e41484186b | ||
|
|
e0bfe6a96c | ||
|
|
228f184548 | ||
|
|
892ce4c453 | ||
|
|
569d45d58a | ||
|
|
ce5f00e075 | ||
|
|
4da407008e | ||
|
|
96e79cc8ae | ||
|
|
ee93806e19 | ||
|
|
fcb02602a0 | ||
|
|
5d4fdf1e76 | ||
|
|
9af59fb51c | ||
|
|
6493d37b7c | ||
|
|
a82c033da0 | ||
|
|
91484e1c98 | ||
|
|
3db5202cdf | ||
|
|
5a28974027 | ||
|
|
4d694f1f74 | ||
|
|
5035c408e7 | ||
|
|
d209f98265 | ||
|
|
85b1404321 | ||
|
|
72c6e4e94e | ||
|
|
eb46ed2768 | ||
|
|
7f4f01c9e8 | ||
|
|
691d2746e6 | ||
|
|
d41dfc1e0d | ||
|
|
493898bd4a | ||
|
|
8ebe427269 | ||
|
|
48d4ff97a0 | ||
|
|
83769bf539 | ||
|
|
0954bf2923 | ||
|
|
a2f5f82e28 | ||
|
|
a82af04fca | ||
|
|
a1a876429c | ||
|
|
58830fa53e | ||
|
|
15c8e32fef | ||
|
|
59c915d8bc | ||
|
|
968ff61979 | ||
|
|
94901849e6 | ||
|
|
ff42126b0e | ||
|
|
39ddf10ca7 | ||
|
|
7a24e5d39d | ||
|
|
e9100504a0 | ||
|
|
099cbfdf75 | ||
|
|
28afef8847 | ||
|
|
010b1e1cce | ||
|
|
274ce76c2b | ||
|
|
f3155e618b | ||
|
|
18307caab3 | ||
|
|
2e279b8876 | ||
|
|
0da878f50f | ||
|
|
ecfb3644be | ||
|
|
c87d18fd8e | ||
|
|
5810f9232a | ||
|
|
fb8eb6f357 | ||
|
|
7eb76ff32d | ||
|
|
c3d3de9984 | ||
|
|
cc2549dbdf | ||
|
|
7efa8eab18 | ||
|
|
376ae9ec1c | ||
|
|
9882b2999f | ||
|
|
3667a75244 | ||
|
|
4089448b53 | ||
|
|
fec11869a8 | ||
|
|
e7e56d1cdb | ||
|
|
9db01d6060 | ||
|
|
ed38397631 | ||
|
|
b3dddc0570 | ||
|
|
6fa06de245 | ||
|
|
834ddde1d0 | ||
|
|
5d4348f8a7 | ||
|
|
36f2917995 | ||
|
|
eedbec175d | ||
|
|
344ec86722 | ||
|
|
952d1e5895 | ||
|
|
a371484f38 | ||
|
|
1567a6fd27 | ||
|
|
e0f96b5cca | ||
|
|
8f6e48642c | ||
|
|
0c4c10dc1a | ||
|
|
de6b78d762 | ||
|
|
6b77f32548 | ||
|
|
fd2b7a00e1 | ||
|
|
818886a65e | ||
|
|
0ca31afc91 | ||
|
|
024a73da63 | ||
|
|
744b0063d8 | ||
|
|
355923f680 | ||
|
|
44332a2004 | ||
|
|
2f125e3d0e | ||
|
|
588228c050 | ||
|
|
8977ba9b6d | ||
|
|
ad06117b78 | ||
|
|
01b30ccf12 | ||
|
|
7f75905d5d | ||
|
|
798856c649 | ||
|
|
9acd358080 | ||
|
|
31c112157a | ||
|
|
d2e162edbf | ||
|
|
6aaffe20d9 | ||
|
|
6d32b20117 | ||
|
|
bd894704b1 | ||
|
|
7af2162b50 | ||
|
|
c735d108d4 | ||
|
|
6a2ffc936e | ||
|
|
74d5480587 | ||
|
|
89c39c7038 | ||
|
|
61f955cfeb | ||
|
|
744adee94c | ||
|
|
267c0b037d | ||
|
|
860414b7b2 | ||
|
|
09bf361d44 | ||
|
|
e2f80c5788 | ||
|
|
a96a6eb57d | ||
|
|
803f9a7fd6 | ||
|
|
71a141e0b8 | ||
|
|
a99b85e646 | ||
|
|
333169d18c | ||
|
|
a08eb418a6 | ||
|
|
cbb878cf96 | ||
|
|
d684f91a5a | ||
|
|
f2de4cd34c | ||
|
|
3d076a605b | ||
|
|
3607f88e18 | ||
|
|
a0d2bb11ed | ||
|
|
ede245a37d | ||
|
|
aca1e112d2 | ||
|
|
bf5d6dac18 | ||
|
|
182ce4da42 | ||
|
|
41e2e6fa59 | ||
|
|
fe0e964a5a | ||
|
|
bee35f9ee9 | ||
|
|
e66a1bb5b4 | ||
|
|
8490997604 | ||
|
|
6898d1df6d | ||
|
|
4d863bb894 | ||
|
|
a338e5fa26 | ||
|
|
695adc8acb | ||
|
|
fab7d26191 | ||
|
|
3959139dd8 | ||
|
|
1298669f1c | ||
|
|
4fe40f5ff7 | ||
|
|
a10c113c42 | ||
|
|
d5f4b5c711 | ||
|
|
93707af56b | ||
|
|
0ae694c1a8 | ||
|
|
0b53fb19b7 | ||
|
|
cc386e86b9 | ||
|
|
a922d7de31 | ||
|
|
8e7d64f0e4 | ||
|
|
0bc406538b | ||
|
|
9547559e00 | ||
|
|
70783dc828 | ||
|
|
85bdd791b8 | ||
|
|
9d7e61556d | ||
|
|
4d954688a9 | ||
|
|
eb80c39b98 | ||
|
|
b1e4dd62b0 | ||
|
|
9db07b2ff8 | ||
|
|
df432b1635 | ||
|
|
e96cb2716d | ||
|
|
3055378b86 | ||
|
|
e4b34b1dbc | ||
|
|
f544b0afaa | ||
|
|
06e1cbeb7e | ||
|
|
6da84dd7b0 | ||
|
|
07b69fe96f | ||
|
|
94b8a9270d | ||
|
|
e0a3fd1795 | ||
|
|
14552913a3 | ||
|
|
a76ab8e037 | ||
|
|
6c496e428f | ||
|
|
46ca6ac327 | ||
|
|
27d77f97db | ||
|
|
f24d7277a0 | ||
|
|
94d2ce7fbe | ||
|
|
9391e78b16 | ||
|
|
902e4a45ac | ||
|
|
67b2ceeee7 | ||
|
|
f111e513c5 | ||
|
|
2f839624a8 | ||
|
|
187fcd3d85 | ||
|
|
66f08e8fce | ||
|
|
f97b1e5f47 | ||
|
|
c3b4c4ae36 | ||
|
|
fd7f4b9772 | ||
|
|
bac2c430ef | ||
|
|
3f1c9942c3 | ||
|
|
80ed675cbc | ||
|
|
6d434e48a1 | ||
|
|
7961870ac4 | ||
|
|
0150ae9df1 | ||
|
|
875f3ebe68 | ||
|
|
3fac8a5663 | ||
|
|
3c11e1c2a1 | ||
|
|
81871b596b | ||
|
|
8ffd5ef972 | ||
|
|
4ae72b7c0b | ||
|
|
5613394a2c | ||
|
|
2e113b468a | ||
|
|
018e37cd2a | ||
|
|
1d5f24dc1a | ||
|
|
cbb8920de7 | ||
|
|
7eb6cadc4e | ||
|
|
a4db569fbd | ||
|
|
2582dfd3c3 | ||
|
|
e9a3ecb9eb | ||
|
|
785647ad24 | ||
|
|
72cd4de55f | ||
|
|
e882123692 | ||
|
|
a949a9bf22 | ||
|
|
75c897eb5b | ||
|
|
b48f74f879 | ||
|
|
c6eeeac7c1 | ||
|
|
9c1edd2a86 | ||
|
|
133c447d5d | ||
|
|
b78cd27e4e | ||
|
|
5d29c82244 | ||
|
|
f379f6b998 | ||
|
|
439111f7a0 | ||
|
|
55372d5a5b | ||
|
|
13e3b93e93 | ||
|
|
7a6929e34b | ||
|
|
a0763a6450 | ||
|
|
2d4202979f | ||
|
|
327d5c74d9 | ||
|
|
3bad83a02f | ||
|
|
eee97294df | ||
|
|
56427d84ad | ||
|
|
fc1983d554 | ||
|
|
30568e54f7 | ||
|
|
1af98cc54f | ||
|
|
fb3a628ad0 | ||
|
|
79b0eeae9e | ||
|
|
3b2757a022 | ||
|
|
fa9f1e05ea | ||
|
|
fff0c8244e | ||
|
|
5777632114 | ||
|
|
d013337c5e | ||
|
|
ec91376da2 | ||
|
|
807cdfeb5b | ||
|
|
9f6da4845a | ||
|
|
211cf48681 | ||
|
|
4d9dd364b6 | ||
|
|
52dfcebc14 | ||
|
|
2bce51fca6 | ||
|
|
3a2048f3ec | ||
|
|
63e602afb1 | ||
|
|
7a71065b76 | ||
|
|
1989219579 | ||
|
|
dd2e858db4 | ||
|
|
916752301a | ||
|
|
1d62b4c115 | ||
|
|
258f1136e2 | ||
|
|
9d0e2239e4 | ||
|
|
5555c44c4e | ||
|
|
f80a91ca1e | ||
|
|
61d6d9f16c | ||
|
|
635c487c2b | ||
|
|
f9f02c3eb0 | ||
|
|
ad3b1cb167 | ||
|
|
880ce3919d | ||
|
|
b489659ddd | ||
|
|
f8344b1662 |
45
.github/workflows/build_package.yml
vendored
Normal file
45
.github/workflows/build_package.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Build & package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "release-candidate" ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Add MSBuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
|
||||
- name: Setup vcpkg
|
||||
run: |
|
||||
bootstrap-vcpkg
|
||||
vcpkg integrate install
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
|
||||
- name: Build
|
||||
working-directory: .
|
||||
run: "./build_package.bat"
|
||||
shell: cmd
|
||||
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v3.1.3
|
||||
with:
|
||||
name: development_build_not_a_release
|
||||
path: ./package
|
||||
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v3.1.3
|
||||
with:
|
||||
name: zip_only_package
|
||||
path: ./zip
|
||||
|
||||
|
||||
44
.gitignore
vendored
44
.gitignore
vendored
@@ -1,12 +1,42 @@
|
||||
bin
|
||||
/scripts/old
|
||||
.vs
|
||||
x64
|
||||
core.user
|
||||
core.vcxproj.user
|
||||
*.user
|
||||
Output
|
||||
node_modules
|
||||
/client/TODO.txt
|
||||
/client/public/javascripts/bundle.js
|
||||
!client/bin
|
||||
hgt
|
||||
|
||||
/backend/vcpkg_installed
|
||||
|
||||
/frontend/server/TODO.txt
|
||||
/frontend/server/public/javascripts/bundle.js
|
||||
/frontend/server/public/plugins
|
||||
/frontend/server/plugins/controltips/index.js
|
||||
/frontend/server/public/databases/units/old
|
||||
/frontend/server/plugins/databasemanager/index.js
|
||||
|
||||
/src/html
|
||||
/src/latex
|
||||
|
||||
/package
|
||||
/build
|
||||
/DCS Olympus backups
|
||||
/zip
|
||||
|
||||
*.user
|
||||
*.aps
|
||||
|
||||
L.Path.Drag.js
|
||||
leaflet-gesture-handling.css
|
||||
leaflet.nauticscale.js
|
||||
leaflet.css
|
||||
package-lock.json
|
||||
|
||||
!frontend/server/bin
|
||||
/mock-dcs
|
||||
/frontend/setup
|
||||
frontend/server/public/plugins/controltipsplugin/index.js
|
||||
frontend/website/plugins/controltips/index.js
|
||||
/frontend/server/public/maps
|
||||
*.pyc
|
||||
/scripts/**/*.jpg
|
||||
manager/manager.log
|
||||
|
||||
BIN
DCS Olympus Manager.lnk
Normal file
BIN
DCS Olympus Manager.lnk
Normal file
Binary file not shown.
59
INSTRUCTIONS.txt
Normal file
59
INSTRUCTIONS.txt
Normal file
@@ -0,0 +1,59 @@
|
||||
_____ _____ _____ ____ _
|
||||
| __ \ / ____|/ ____| / __ \| |
|
||||
| | | | | | (___ | | | | |_ _ _ __ ___ _ __ _ _ ___
|
||||
| | | | | \___ \ | | | | | | | | '_ ` _ \| '_ \| | | / __|
|
||||
| |__| | |____ ____) | | |__| | | |_| | | | | | | |_) | |_| \__ \
|
||||
|_____/ \_____|_____/ \____/|_|\__, |_| |_| |_| .__/ \__,_|___/
|
||||
__/ | | |
|
||||
|___/ |_|
|
||||
|
||||
{{OLYMPUS_VERSION_NUMBER}}
|
||||
|
||||
==========================================
|
||||
INSTALLATION INSTRUCTIONS
|
||||
|
||||
1) Close any applications which may interfere with installation, including Digital Combat Simulator (DCS) and previous versions of Olympus.
|
||||
|
||||
2) If you DO NOT have Olympus already installed, SKIP THIS STEP. If you have already installed Olympus, do the following:
|
||||
NOTE: If you made any changes to your unit databases or mods.lua file (e.g. to support a third party mod) make a backup of the edited files before proceeding or changes will be lost;
|
||||
a) If you installed DCS Olympus v1.0.3 using the installer, simply remove it using Windows's "Add or remove programs" application.
|
||||
b) If you installed DCS Olympus v1.0.3 using the archived version, remove it by deleting the "...<DCS Saved Games folder>\Mods\Services\Olympus" folder. Do this for every DCS instance you installed Olympus in.
|
||||
Remember to delete any shortcuts you created. Don't worry, they will be created automatically again by the installation script provided in this package.
|
||||
|
||||
3) Create a folder named "DCS Olympus" in your "Saved Games" directory and extract all the contents of the downloaded package into it.
|
||||
NOTE:
|
||||
a) Do not extract the contents of the package directly in your Saved Games folder or in your DCS Saved Games folder.
|
||||
b) Unlike previous version of Olympus, it is no longer necessary to copy the packaged files into each DCS instance folder.
|
||||
|
||||
4) Execute the "installer.bat" script by double-clicking on it. It is located in the folder you created in step 3. Wait for the installation script to complete. Installation may take a couple of minutes, after which the Manager will start automatically.
|
||||
NOTE: depending on your Windows configuration, the script may be called "installer" (without .bat at the end).
|
||||
|
||||
5) The Olympus Manager will open. This will allow you to add/remove Olympus to individual DCS instances.
|
||||
Use the Olympus Manager and follow the instructions to install and setup Olympus.
|
||||
|
||||
6) Start DCS and run a mission. Make sure it is UNPAUSED.
|
||||
|
||||
7) Open Olympus via the shortcut and login using any username and the Game Master password set using the Manager. (NOTE: not your DCS server password).
|
||||
Local installation: run the client from the provided desktop shortcut or start it using the "View and manage instances" page of the Manager.
|
||||
Dedicated server: users must first start the Olympus server from the provided desktop shortcut or using the "View and manage instances" page of the Manager.
|
||||
Then log in using any browser and visiting "http:\\<server IP>:<frontend port>" (frontend port is 3000 by default, but can be edited using the Manager)
|
||||
|
||||
8) You can use the manager at any time to change the ports and/or passwords. If you do, REMEMBER TO RESTART OLYMPUS AND DCS.
|
||||
|
||||
|
||||
NOTES:
|
||||
a) when launching the Manager you will be prompted to allow Electron to create a firewall rule. This is optional and can be denied without effect on the operation of the Manager;
|
||||
b) if you are using Olympus on a dedicated server with a router, you must enable port forwarding on the frontend port (3000 by default);
|
||||
c) unlike Olympus v1.0.3, running the netsh command is no longer required. It is also no longer required to create firewall rules or port forwarding for the backend port. (Optional) If you already performed this steps in the past you can delete the firewall and netsh rules.
|
||||
|
||||
|
||||
==========================================
|
||||
UPDATING INSTRUCTIONS
|
||||
|
||||
IF YOU ARE UPDATING FROM DCS OLYMPUS v1.0.3, FOLLOW THE "INSTALLATION INSTRUCTIONS".
|
||||
|
||||
To update your Olympus installation you have two options:
|
||||
a) download the new package from the GitHub releases page, delete the old unpacked package folder, then follow the INSTALLATION INSTRUCTIONS;
|
||||
b) run the Olympus Manager. If an update is available you will be given the option to automatically update Olympus from there.
|
||||
|
||||
For either options a) or b), remember to close any applications which may interfere with installation, including Digital Combat Simulator (DCS) and previous versions of Olympus.
|
||||
@@ -1,4 +1,34 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
DCS Olympus
|
||||
|
||||
A real-time AI unit control mod for DCS World
|
||||
|
||||
Copyright (C) 2023 Veltro & Gang (the "DCS Olympus Team" or the
|
||||
"Rightsholders")
|
||||
|
||||
DCS Olympus (the "MATERIAL" or "Software") is provided completely free
|
||||
to users subject to the it under both the terms of version 3 of the GNU
|
||||
General Public License ("GPLv3") as published by the Free Software Foundation,
|
||||
and the additional terms set out below (the "Additional Terms"). In the event
|
||||
that the terms of GPLv3 conflict with the Additional Terms, the
|
||||
Additional Terms shall prevail.
|
||||
|
||||
The authors and/or copyright holders of the Software have not received any
|
||||
financial benefit in connection with the Software. In any event, the
|
||||
Software is provided “as is”, without warranty of any kind, express or
|
||||
implied, including but not limited to the warranties of merchantability,
|
||||
fitness for a particular purpose and non-infringement. In no event shall
|
||||
the authors and/or copyright holders be liable for any claim, damages or
|
||||
other liability, whether in an action of contract, tort or otherwise,
|
||||
arising from, out of or in connection with the Software or the use or
|
||||
other dealings in the Software.
|
||||
|
||||
THIS MATERIAL IS NOT MADE OR SUPPORTED BY EAGLE DYNAMICS SA.
|
||||
|
||||
Any party making use of the Software in any manner agrees to be bound by
|
||||
the entirety of this document.
|
||||
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
@@ -618,57 +648,31 @@ an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
END OF GNU GENERAL PUBLIC LICENCE
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
ADDITIONAL TERMS & CONDITIONS
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
1. Governing Law
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
Save where specifically provided for otherwise, the provisions of the
|
||||
GNU General Public Licence Version 3 above shall be governed by and
|
||||
interpreted in accordance with English Law and the parties submit to the
|
||||
exclusive jurisdiction of the English Courts.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
2. Entire Agreement
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
The text of this document contains the entire understanding between
|
||||
you, the licensee, and the authors and/or copyright holders of the
|
||||
Software with respect to the subject matter to which it pertains.
|
||||
It supersedes all prior agreements and understandings (if applicable),
|
||||
oral or written, with respect to such matters.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
3. Unilateral Modification
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
The parties agree that the DCS Olympus Team shall have the right to
|
||||
unilaterally modify these terms (i.e. the agreement between you and the
|
||||
DCS Olympus Team for the use of the Software), and that parties shall
|
||||
be bound by such terms as modified from time to time. The DCS Olympus Team
|
||||
shall not have an obligation to inform you of such modification, save that
|
||||
such changes will be published on the DCS Olympus Github Repository located at
|
||||
https://github.com/Pax1601/DCSOlympus.
|
||||
103
README.md
103
README.md
@@ -1,40 +1,85 @@
|
||||
# Important note: DCS Olympus is in alpha state. No official release has been produced yet. The first public version is planned for Q2 2023.
|
||||
<img align="left" width="30" src="https://github.com/Pax1601/DCSOlympus/assets/103559271/0ecff279-a87c-4e2d-a4c7-da98c74adf38">
|
||||
|
||||
[**Join our Discord**](https://discord.gg/kNAQkhUHnQ)
|
||||
|
||||
<img align="left" width="30" src="https://github.com/Pax1601/DCSOlympus/assets/103559271/1c0dd3fd-339c-4b03-94da-3e5215b0358a">
|
||||
|
||||
[**YouTube**](https://www.youtube.com/@DCSOlympus)
|
||||
|
||||
|
||||
# DCS Olympus
|
||||
*A real-time web interface to spawn and control units in DCS World*
|
||||
|
||||

|
||||
|
||||
### What is this?
|
||||
DCS Olympus is a mod for DCS World. It allows users to spawn, control, task, group, and remove units from a DCS World server using a real-time map interface, similarly to Real Time Strategy games. The user interface also provides useful informations units, like loadouts, fuel, tasking, and so on. In the future, more features for DCS World GCI and JTAC will be available.
|
||||
DCS: Olympus is a free and open-source mod for DCS that enables dynamic real-time control through a map interface. The user is able to spawn units/groups, deploy a variety of effects such as smoke, flares, or explosions, and waypoints/tasks can be given to AI units in real-time in a way similar to a classic RTS game.
|
||||
|
||||
### Features and how to use it
|
||||
- Spawn air and ground units, with preset loadouts
|
||||
- Double click on the map to spawn a blue and red units, both in the air and in the ground, with preset loadouts for air-to-air or air-to-ground tasks;
|
||||
- Control units
|
||||
- Select one ore more units to move them around. Hold down ctrl and click to create a route for the unit to follow;
|
||||
- Attack other units
|
||||
- After selecting one ore more units, double click on another unit and select "Attack" to attack it, depending on the available weapons.
|
||||
Additionally Olympus is able to run several effects and unit behaviours beyond the core DCS offerings. This includes such things as napalm and white phosphosous explosions, or setting up AA units to fire at players and miss, and more.
|
||||
|
||||
It even includes Red and Blue modes which limit your view and powers to just seeing what your coalition sees, with a spawning budget you could play against your friends even with no-one in the game piloting, or have a Red commander working against a squadron of blue pilots, and/or a blue commander working with them.
|
||||
|
||||
Even better it requires no client mods be installed if used on a server
|
||||
|
||||
The full feature list is simply too long to enumerate in a short summary but needless to say Olympus offers up a lot of unique gameplay that has previously not existed, and enhances many other elements of DCS in exciting ways
|
||||
|
||||
### Installing DCS Olympus
|
||||
A prebuilt installer will soon be released and available here
|
||||
Check the [Wiki](https://github.com/Pax1601/DCSOlympus/wiki) for installation instructions
|
||||
|
||||
### Building DCS Olympus
|
||||
DCS Olympus is comprised of two modules:
|
||||
# Frequently Asked Questions
|
||||
|
||||
A "core" c++ .dll module, which is run by DCS and exposes all the necessary data, and provides endpoints for commands from a REST server. A Visual Studio 2017/2019/2022 solution is provided, and requires no additional configuration. The core dll solution has two dependencies, both can be installed using vcpkg (https://vcpkg.io/en/getting-started.html):
|
||||
- cpprestsdk: `vcpkg install cpprestsdk:x64-windows`
|
||||
- geographiclib: `vcpkg install geographiclib:x64-windows`
|
||||
|
||||
|
||||
A "client" node.js typescript web app, which can be hosted on the server using express.js. A Visual Studio Code configuration is provided for debugging. The client requires node.js to be installed for building (https://nodejs.org/en/). After installing node.js, move in the client folder and run the following commands:
|
||||
- `npm install`
|
||||
- `npm -g install`
|
||||
|
||||
After installing all the necessary dependencies you can start a development server executing the *client/debug.bat* batch file, and visiting http:\\localhost:3000 with any modern browser (tested with updated Chrome, Firefox and Edge). However, it is highly suggested to simply run the `Launch Chrome against localhost` debug configuration in Visual Studio Code.
|
||||
|
||||
|
||||
|
||||
|
||||
### I need troubleshooting guidance, please help? ###
|
||||
Read through the [Installation Guide](https://github.com/Pax1601/DCSOlympus/wiki) to ensure you have setup Olympus correctly.
|
||||
|
||||
Read through [Setup Troubleshooting](https://github.com/Pax1601/DCSOlympus/wiki/Setup-Troubleshooting) for common issues and solutions.
|
||||
|
||||
Read through the [Olympus User Guide](https://github.com/Pax1601/DCSOlympus/wiki/2.-User-Guide) to learn how to use Olympus.
|
||||
|
||||
If you're still having issues after trying the steps above, please post in the community-support channel with the following:
|
||||
|
||||
A detailed description of your issue
|
||||
Your Olympus log file \user home folder\AppData\Local\Temp\Olympus_log.txt for some it might be in \DCS Saved Games folder\Logs\Olympus_log.txt
|
||||
Your DCS log file \DCS Saved Games folder\Logs\dcs.log
|
||||
|
||||
Screenshots of any relevant screens or issues and any other pertinent information.
|
||||
|
||||
### Can I join up and help out with the project? ###
|
||||
Absolutely, join the discord and ping any of the developers to get briefed.
|
||||
|
||||
### Can I be a beta/alpha-tester? ###
|
||||
Same as above!
|
||||
|
||||
### Do you have a roadmap? ###
|
||||
We do not have a roadmap no, we have a laundry list of things we are hoping to do.
|
||||
|
||||
These include but are not limited to:
|
||||
1) Enhancements to helicopter play
|
||||
2) More features around use of ground units
|
||||
3) More unique effects and behaviours
|
||||
4) ATC/AIC features
|
||||
5) Usability features like unit painters etc
|
||||
|
||||
However we cannot commit to specific features, feature release order, or timelines, please remember this isn't our job and we work on it in our free time because we love DCS
|
||||
|
||||
### Does Olympus support mods? ###
|
||||
Generally OIympus will not have any issues with other mods, however you may need to tell olympus about modded units in order to be able to dynamically spawn them etc
|
||||
Keep in mind that any mods you do choose to spawn your players will need to have, some mod unit just appear as a su27 or leo2 etc. When a player is missing them, others can cause client crashes. So be smart about how you use them.
|
||||
|
||||
### Is Olympus compatible with mission scripts? ###
|
||||
We have tried hard to keep Olympus from interfering with other scripts, we have tested with a variety of new and old mission scripts and generally expect it will not be an issue.
|
||||
|
||||
However we cannot foresee everything people come up with so we suggest testing with what you have in mind once olympus releases
|
||||
|
||||
### How does it work? ###
|
||||
The quick answer is magic.
|
||||
The long answer is well all the code is there for you to read.
|
||||
The middle answer is a bit like SRS does. Olympus consists of two parts.
|
||||
|
||||
(A) Olympus back end: A dll, run by DCS, that sends data out and gets commands in via a REST API;
|
||||
(B) Webserver exe: The one you start when starting the server via the desktop shortcut.
|
||||
|
||||
A and B never communicate when you connect the client you download the web page and some other minor stuff from B, and you get the DCS data from and send commands to A.
|
||||
|
||||
### How much does Olympus impact performance? ###
|
||||
Olympus by itself should not have a noticeable impact on server performance, however the ability for the user to spawn arbitrary units and command engagements means Olympus can be used in such a way that brings the game to it's knees.
|
||||
|
||||
Be cognizant of how you play, whether it's done through Olympus or the mission editor 500 MLRS units firing at once is not going to go over well with most servers
|
||||
|
||||
|
||||
|
||||
12
backend/DCSOlympus.props
Normal file
12
backend/DCSOlympus.props
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<PropertyGroup Label="Vcpkg">
|
||||
<VcpkgEnableManifest>true</VcpkgEnableManifest>
|
||||
<VcpkgAutoLink>true</VcpkgAutoLink>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup />
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
110
backend/core/core.rc
Normal file
110
backend/core/core.rc
Normal file
@@ -0,0 +1,110 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Italian (Italy) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
|
||||
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Italian (Italy) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United Kingdom) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,4,0
|
||||
PRODUCTVERSION 1,0,3,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "DCS Olympus"
|
||||
VALUE "FileDescription", "DCS Olympus"
|
||||
VALUE "FileVersion", "1.0.4.0"
|
||||
VALUE "InternalName", "core.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023"
|
||||
VALUE "OriginalFilename", "core.dll"
|
||||
VALUE "ProductName", "DCS Olympus"
|
||||
VALUE "ProductVersion", "1.0.4.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United Kingdom) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<ClInclude Include="include\aircraft.h" />
|
||||
<ClInclude Include="include\airunit.h" />
|
||||
<ClInclude Include="include\commands.h" />
|
||||
<ClInclude Include="include\measure.h" />
|
||||
<ClInclude Include="include\datatypes.h" />
|
||||
<ClInclude Include="include\groundunit.h" />
|
||||
<ClInclude Include="include\helicopter.h" />
|
||||
<ClInclude Include="include\navyunit.h" />
|
||||
@@ -46,13 +46,15 @@
|
||||
<ClInclude Include="include\unit.h" />
|
||||
<ClInclude Include="include\unitsmanager.h" />
|
||||
<ClInclude Include="include\weapon.h" />
|
||||
<ClInclude Include="include\weaponsmanager.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\aircraft.cpp" />
|
||||
<ClCompile Include="src\airunit.cpp" />
|
||||
<ClCompile Include="src\commands.cpp" />
|
||||
<ClCompile Include="src\core.cpp" />
|
||||
<ClCompile Include="src\measure.cpp" />
|
||||
<ClCompile Include="src\datatypes.cpp" />
|
||||
<ClCompile Include="src\groundunit.cpp" />
|
||||
<ClCompile Include="src\helicopter.cpp" />
|
||||
<ClCompile Include="src\navyunit.cpp" />
|
||||
@@ -62,6 +64,10 @@
|
||||
<ClCompile Include="src\unit.cpp" />
|
||||
<ClCompile Include="src\unitsmanager.cpp" />
|
||||
<ClCompile Include="src\weapon.cpp" />
|
||||
<ClCompile Include="src\weaponsmanager.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="core.rc" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
@@ -104,22 +110,26 @@
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>.\..\..\bin\</OutDir>
|
||||
<OutDir>.\..\..\build\backend\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -172,6 +182,7 @@
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>lua.lib; GeographicLib-i.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\third-party\lua</AdditionalLibraryDirectories>
|
||||
<Version>{{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}}</Version>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -45,9 +45,13 @@
|
||||
<ClInclude Include="include\weapon.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\measure.h">
|
||||
<ClInclude Include="include\datatypes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\weaponsmanager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\aircraft.cpp">
|
||||
@@ -89,8 +93,14 @@
|
||||
<ClCompile Include="src\weapon.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\measure.cpp">
|
||||
<ClCompile Include="src\datatypes.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\weaponsmanager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="core.rc" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
20
backend/core/include/aircraft.h
Normal file
20
backend/core/include/aircraft.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "airunit.h"
|
||||
|
||||
#define AIRCRAFT_DEST_DIST_THR 2000 // Meters
|
||||
|
||||
class Aircraft : public AirUnit
|
||||
{
|
||||
public:
|
||||
Aircraft(json::value json, unsigned int ID);
|
||||
|
||||
static void loadDatabase(string path);
|
||||
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void changeAltitude(string change);
|
||||
|
||||
virtual double getDestinationReachedThreshold() { return AIRCRAFT_DEST_DIST_THR; }
|
||||
|
||||
protected:
|
||||
static json::value database;
|
||||
};
|
||||
24
backend/core/include/airunit.h
Normal file
24
backend/core/include/airunit.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "utils.h"
|
||||
#include "dcstools.h"
|
||||
#include "luatools.h"
|
||||
#include "Unit.h"
|
||||
|
||||
#define AIR_DEST_DIST_THR 2000 // Meters
|
||||
|
||||
class AirUnit : public Unit
|
||||
{
|
||||
public:
|
||||
AirUnit(json::value json, unsigned int ID);
|
||||
|
||||
virtual void setDefaults(bool force = false);
|
||||
virtual void setState(unsigned char newState);
|
||||
|
||||
virtual void changeSpeed(string change) = 0;
|
||||
virtual void changeAltitude(string change) = 0;
|
||||
virtual double getDestinationReachedThreshold() { return AIR_DEST_DIST_THR; }
|
||||
|
||||
protected:
|
||||
virtual void AIloop();
|
||||
};
|
||||
432
backend/core/include/commands.h
Normal file
432
backend/core/include/commands.h
Normal file
@@ -0,0 +1,432 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "luatools.h"
|
||||
#include "utils.h"
|
||||
#include "logger.h"
|
||||
#include "datatypes.h"
|
||||
|
||||
namespace CommandPriority {
|
||||
enum CommandPriorities { LOW, MEDIUM, HIGH, IMMEDIATE };
|
||||
};
|
||||
|
||||
namespace SetCommandType {
|
||||
enum SetCommandTypes {
|
||||
ROE = 0,
|
||||
REACTION_ON_THREAT = 1,
|
||||
RADAR_USING = 3,
|
||||
FLARE_USING = 4,
|
||||
FORMATION = 5,
|
||||
RTB_ON_BINGO = 6,
|
||||
SILENCE = 7,
|
||||
RTB_ON_OUT_OF_AMMO = 10,
|
||||
ECM_USING = 13,
|
||||
PROHIBIT_AA = 14,
|
||||
PROHIBIT_JETT = 15,
|
||||
PROHIBIT_AB = 16,
|
||||
PROHIBIT_AG = 17,
|
||||
MISSILE_ATTACK = 18,
|
||||
PROHIBIT_WP_PASS_REPORT = 19,
|
||||
ENGAGE_AIR_WEAPONS = 20,
|
||||
OPTION_RADIO_USAGE_CONTACT = 21,
|
||||
OPTION_RADIO_USAGE_ENGAGE = 22,
|
||||
OPTION_RADIO_USAGE_KILL = 23,
|
||||
JETT_TANKS_IF_EMPTY = 25,
|
||||
FORCED_ATTACK = 26
|
||||
};
|
||||
}
|
||||
|
||||
namespace ROE {
|
||||
enum ROEs {
|
||||
WEAPON_FREE = 0,
|
||||
OPEN_FIRE_WEAPON_FREE = 1,
|
||||
OPEN_FIRE = 2,
|
||||
RETURN_FIRE = 3,
|
||||
WEAPON_HOLD = 4,
|
||||
};
|
||||
}
|
||||
|
||||
namespace ReactionToThreat {
|
||||
enum ReactionsToThreat {
|
||||
NO_REACTION = 0,
|
||||
PASSIVE_DEFENCE = 1,
|
||||
EVADE_FIRE = 2,
|
||||
BYPASS_AND_ESCAPE = 3,
|
||||
ALLOW_ABORT_MISSION = 4
|
||||
};
|
||||
}
|
||||
|
||||
namespace EmissionCountermeasure {
|
||||
enum ReactionsToThreat {
|
||||
SILENT = 0,
|
||||
ATTACK = 1,
|
||||
DEFEND = 2,
|
||||
FREE = 3
|
||||
};
|
||||
}
|
||||
|
||||
namespace RadarUse {
|
||||
enum RadarUses {
|
||||
NEVER = 0,
|
||||
FOR_ATTACK_ONLY = 1,
|
||||
FOR_SEARCH_IF_REQUIRED = 2,
|
||||
FOR_CONTINUOUS_SEARCH = 3
|
||||
};
|
||||
}
|
||||
|
||||
namespace FlareUse {
|
||||
enum FlareUses {
|
||||
NEVER = 0,
|
||||
AGAINST_FIRED_MISSILE = 1,
|
||||
WHEN_FLYING_IN_SAM_WEZ = 2,
|
||||
WHEN_FLYING_NEAR_ENEMIES = 3
|
||||
};
|
||||
}
|
||||
|
||||
namespace ECMUse {
|
||||
enum ECMUses {
|
||||
NEVER_USE = 0,
|
||||
USE_IF_ONLY_LOCK_BY_RADAR = 1,
|
||||
USE_IF_DETECTED_LOCK_BY_RADAR = 2,
|
||||
ALWAYS_USE = 3
|
||||
};
|
||||
}
|
||||
|
||||
/* Base command class */
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
Command(function<void(void)> callback) : callback(callback) {};
|
||||
unsigned int getPriority() { return priority; }
|
||||
virtual string getString() = 0;
|
||||
virtual unsigned int getLoad() = 0;
|
||||
const string getHash() { return hash; }
|
||||
void executeCallback() { callback(); }
|
||||
|
||||
protected:
|
||||
unsigned int priority = CommandPriority::LOW;
|
||||
const string hash = random_string(16);
|
||||
function<void(void)> callback;
|
||||
};
|
||||
|
||||
/* Simple low priority move command (from user click) */
|
||||
class Move : public Command
|
||||
{
|
||||
public:
|
||||
Move(string groupName, Coords destination, double speed, string speedType, double altitude,
|
||||
string altitudeType, string taskOptions, string category, bool onRoad, function<void(void)> callback = []() {}) :
|
||||
Command(callback),
|
||||
groupName(groupName),
|
||||
destination(destination),
|
||||
speed(speed),
|
||||
speedType(speedType),
|
||||
altitude(altitude),
|
||||
altitudeType(altitudeType),
|
||||
taskOptions(taskOptions),
|
||||
category(category),
|
||||
onRoad(onRoad)
|
||||
{
|
||||
priority = CommandPriority::MEDIUM;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return onRoad? 45: 5; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
const Coords destination;
|
||||
const double speed;
|
||||
const string speedType;
|
||||
const double altitude;
|
||||
const string altitudeType;
|
||||
const string taskOptions;
|
||||
const string category;
|
||||
const bool onRoad;
|
||||
};
|
||||
|
||||
/* Smoke command */
|
||||
class Smoke : public Command
|
||||
{
|
||||
public:
|
||||
Smoke(string color, Coords location, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
color(color),
|
||||
location(location)
|
||||
{
|
||||
priority = CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
|
||||
private:
|
||||
const string color;
|
||||
const Coords location;
|
||||
};
|
||||
|
||||
/* Spawn ground unit command */
|
||||
class SpawnGroundUnits : public Command
|
||||
{
|
||||
public:
|
||||
SpawnGroundUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, bool immediate, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
coalition(coalition),
|
||||
spawnOptions(spawnOptions),
|
||||
country(country),
|
||||
immediate(immediate)
|
||||
{
|
||||
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return immediate? 5: 30; }
|
||||
|
||||
private:
|
||||
const string coalition;
|
||||
const vector<SpawnOptions> spawnOptions;
|
||||
const string country;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
/* Spawn navy unit command */
|
||||
class SpawnNavyUnits : public Command
|
||||
{
|
||||
public:
|
||||
SpawnNavyUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, bool immediate, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
coalition(coalition),
|
||||
spawnOptions(spawnOptions),
|
||||
country(country),
|
||||
immediate(immediate)
|
||||
{
|
||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return immediate ? 5 : 60; }
|
||||
|
||||
private:
|
||||
const string coalition;
|
||||
const vector<SpawnOptions> spawnOptions;
|
||||
const string country;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
/* Spawn aircraft command */
|
||||
class SpawnAircrafts : public Command
|
||||
{
|
||||
public:
|
||||
SpawnAircrafts(string coalition, vector<SpawnOptions> spawnOptions, string airbaseName, string country, bool immediate, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
coalition(coalition),
|
||||
spawnOptions(spawnOptions),
|
||||
airbaseName(airbaseName),
|
||||
country(country),
|
||||
immediate(immediate)
|
||||
{
|
||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return immediate ? 5 : 45; }
|
||||
|
||||
private:
|
||||
const string coalition;
|
||||
const vector<SpawnOptions> spawnOptions;
|
||||
const string airbaseName;
|
||||
const string country;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
/* Spawn helicopter command */
|
||||
class SpawnHelicopters : public Command
|
||||
{
|
||||
public:
|
||||
SpawnHelicopters(string coalition, vector<SpawnOptions> spawnOptions, string airbaseName, string country, bool immediate, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
coalition(coalition),
|
||||
spawnOptions(spawnOptions),
|
||||
airbaseName(airbaseName),
|
||||
country(country),
|
||||
immediate(immediate)
|
||||
{
|
||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return immediate ? 5 : 45; }
|
||||
|
||||
private:
|
||||
const string coalition;
|
||||
const vector<SpawnOptions> spawnOptions;
|
||||
const string airbaseName;
|
||||
const string country;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
/* Clone unit command */
|
||||
class Clone : public Command
|
||||
{
|
||||
public:
|
||||
Clone(vector<CloneOptions> cloneOptions, bool deleteOriginal, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
cloneOptions(cloneOptions),
|
||||
deleteOriginal(deleteOriginal)
|
||||
{
|
||||
priority = CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 30; }
|
||||
|
||||
private:
|
||||
const vector<CloneOptions> cloneOptions;
|
||||
const bool deleteOriginal;
|
||||
};
|
||||
|
||||
/* Delete unit command */
|
||||
class Delete : public Command
|
||||
{
|
||||
public:
|
||||
Delete(unsigned int ID, bool explosion, string explosionType, bool immediate, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
ID(ID),
|
||||
explosion(explosion),
|
||||
explosionType(explosionType),
|
||||
immediate(immediate)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
immediate = immediate;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return immediate? 1: 30; }
|
||||
|
||||
private:
|
||||
const unsigned int ID;
|
||||
const bool explosion;
|
||||
const string explosionType;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
/* SetTask command */
|
||||
class SetTask : public Command
|
||||
{
|
||||
public:
|
||||
SetTask(string groupName, string task, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
groupName(groupName),
|
||||
task(task)
|
||||
{
|
||||
priority = CommandPriority::MEDIUM;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
const string task;
|
||||
};
|
||||
|
||||
/* Reset task command */
|
||||
class ResetTask : public Command
|
||||
{
|
||||
public:
|
||||
ResetTask(string groupName, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
groupName(groupName)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
};
|
||||
|
||||
/* Set command */
|
||||
class SetCommand : public Command
|
||||
{
|
||||
public:
|
||||
SetCommand(string groupName, string command, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
groupName(groupName),
|
||||
command(command)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
const string command;
|
||||
};
|
||||
|
||||
/* Set option command */
|
||||
class SetOption : public Command
|
||||
{
|
||||
public:
|
||||
SetOption(string groupName, unsigned int optionID, unsigned int optionValue, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
groupName(groupName),
|
||||
optionID(optionID),
|
||||
optionValue(optionValue),
|
||||
optionBool(false),
|
||||
isBoolean(false)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
|
||||
SetOption(string groupName, unsigned int optionID, bool optionBool, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
groupName(groupName),
|
||||
optionID(optionID),
|
||||
optionValue(0),
|
||||
optionBool(optionBool),
|
||||
isBoolean(true)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
const unsigned int optionID;
|
||||
const unsigned int optionValue;
|
||||
const bool optionBool;
|
||||
const bool isBoolean;
|
||||
};
|
||||
|
||||
/* Set on off */
|
||||
class SetOnOff : public Command
|
||||
{
|
||||
public:
|
||||
SetOnOff(string groupName, bool onOff, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
groupName(groupName),
|
||||
onOff(onOff)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
const bool onOff;
|
||||
};
|
||||
|
||||
/* Make a ground explosion */
|
||||
class Explosion : public Command
|
||||
{
|
||||
public:
|
||||
Explosion(unsigned int intensity, string explosionType, Coords location, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
location(location),
|
||||
intensity(intensity),
|
||||
explosionType(explosionType)
|
||||
{
|
||||
priority = CommandPriority::MEDIUM;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const Coords location;
|
||||
const unsigned int intensity;
|
||||
const string explosionType;
|
||||
};
|
||||
163
backend/core/include/datatypes.h
Normal file
163
backend/core/include/datatypes.h
Normal file
@@ -0,0 +1,163 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace DataIndex {
|
||||
enum DataIndexes {
|
||||
startOfData = 0,
|
||||
category,
|
||||
alive,
|
||||
human,
|
||||
controlled,
|
||||
coalition,
|
||||
country,
|
||||
name,
|
||||
unitName,
|
||||
callsign,
|
||||
groupName,
|
||||
state,
|
||||
task,
|
||||
hasTask,
|
||||
position,
|
||||
speed,
|
||||
horizontalVelocity,
|
||||
verticalVelocity,
|
||||
heading,
|
||||
track,
|
||||
isActiveTanker,
|
||||
isActiveAWACS,
|
||||
onOff,
|
||||
followRoads,
|
||||
fuel,
|
||||
desiredSpeed,
|
||||
desiredSpeedType,
|
||||
desiredAltitude,
|
||||
desiredAltitudeType,
|
||||
leaderID,
|
||||
formationOffset,
|
||||
targetID,
|
||||
targetPosition,
|
||||
ROE,
|
||||
reactionToThreat,
|
||||
emissionsCountermeasures,
|
||||
TACAN,
|
||||
radio,
|
||||
generalSettings,
|
||||
ammo,
|
||||
contacts,
|
||||
activePath,
|
||||
isLeader,
|
||||
operateAs,
|
||||
shotsScatter,
|
||||
shotsIntensity,
|
||||
health,
|
||||
lastIndex,
|
||||
endOfData = 255
|
||||
};
|
||||
}
|
||||
|
||||
namespace State
|
||||
{
|
||||
enum States
|
||||
{
|
||||
NONE = 0,
|
||||
IDLE,
|
||||
REACH_DESTINATION,
|
||||
ATTACK,
|
||||
FOLLOW,
|
||||
LAND,
|
||||
REFUEL,
|
||||
AWACS,
|
||||
TANKER,
|
||||
BOMB_POINT,
|
||||
CARPET_BOMB,
|
||||
BOMB_BUILDING,
|
||||
FIRE_AT_AREA,
|
||||
SIMULATE_FIRE_FIGHT,
|
||||
SCENIC_AAA,
|
||||
MISS_ON_PURPOSE,
|
||||
LAND_AT_POINT
|
||||
};
|
||||
};
|
||||
|
||||
namespace ShotsScatter
|
||||
{
|
||||
enum ShotsScatters
|
||||
{
|
||||
NONE = 0,
|
||||
HIGH,
|
||||
MEDIUM,
|
||||
LOW
|
||||
};
|
||||
};
|
||||
|
||||
namespace ShotsIntensity
|
||||
{
|
||||
enum ShotsIntensities
|
||||
{
|
||||
NONE = 0,
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH
|
||||
};
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
namespace DataTypes {
|
||||
struct TACAN
|
||||
{
|
||||
bool isOn = false;
|
||||
unsigned char channel = 40;
|
||||
char XY = 'X';
|
||||
char callsign[4];
|
||||
};
|
||||
|
||||
struct Radio
|
||||
{
|
||||
unsigned int frequency = 124000000; // MHz
|
||||
unsigned char callsign = 1;
|
||||
unsigned char callsignNumber = 1;
|
||||
};
|
||||
|
||||
struct GeneralSettings
|
||||
{
|
||||
bool prohibitJettison = false;
|
||||
bool prohibitAA = false;
|
||||
bool prohibitAG = false;
|
||||
bool prohibitAfterburner = false;
|
||||
bool prohibitAirWpn = false;
|
||||
};
|
||||
|
||||
struct Ammo {
|
||||
unsigned short quantity = 0;
|
||||
char name[33];
|
||||
unsigned char guidance = 0;
|
||||
unsigned char category = 0;
|
||||
unsigned char missileCategory = 0;
|
||||
};
|
||||
|
||||
struct Contact {
|
||||
unsigned int ID = 0;
|
||||
unsigned char detectionMethod = 0;
|
||||
};
|
||||
}
|
||||
#pragma pack(pop)
|
||||
|
||||
bool operator==(const DataTypes::TACAN& lhs, const DataTypes::TACAN& rhs);
|
||||
bool operator==(const DataTypes::Radio& lhs, const DataTypes::Radio& rhs);
|
||||
bool operator==(const DataTypes::GeneralSettings& lhs, const DataTypes::GeneralSettings& rhs);
|
||||
bool operator==(const DataTypes::Ammo& lhs, const DataTypes::Ammo& rhs);
|
||||
bool operator==(const DataTypes::Contact& lhs, const DataTypes::Contact& rhs);
|
||||
|
||||
struct SpawnOptions {
|
||||
string unitType;
|
||||
Coords location;
|
||||
string loadout;
|
||||
string skill;
|
||||
string liveryID;
|
||||
};
|
||||
|
||||
struct CloneOptions {
|
||||
unsigned int ID;
|
||||
Coords location;
|
||||
};
|
||||
25
backend/core/include/groundunit.h
Normal file
25
backend/core/include/groundunit.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "unit.h"
|
||||
|
||||
#define GROUND_DEST_DIST_THR 10
|
||||
|
||||
class GroundUnit : public Unit
|
||||
{
|
||||
public:
|
||||
GroundUnit(json::value json, unsigned int ID);
|
||||
|
||||
static void loadDatabase(string path);
|
||||
|
||||
virtual void setState(unsigned char newState);
|
||||
virtual void setDefaults(bool force = false);
|
||||
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void setOnOff(bool newOnOff, bool force = false);
|
||||
virtual void setFollowRoads(bool newFollowRoads, bool force = false);
|
||||
|
||||
void aimAtPoint(Coords aimTarget);
|
||||
|
||||
protected:
|
||||
virtual void AIloop();
|
||||
static json::value database;
|
||||
};
|
||||
20
backend/core/include/helicopter.h
Normal file
20
backend/core/include/helicopter.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "airunit.h"
|
||||
|
||||
#define HELICOPTER_DEST_DIST_THR 500 // Meters
|
||||
|
||||
class Helicopter : public AirUnit
|
||||
{
|
||||
public:
|
||||
Helicopter(json::value json, unsigned int ID);
|
||||
|
||||
static void loadDatabase(string path);
|
||||
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void changeAltitude(string change);
|
||||
|
||||
virtual double getDestinationReachedThreshold() { return HELICOPTER_DEST_DIST_THR; }
|
||||
|
||||
protected:
|
||||
static json::value database;
|
||||
};
|
||||
22
backend/core/include/navyunit.h
Normal file
22
backend/core/include/navyunit.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "unit.h"
|
||||
|
||||
#define NAVY_DEST_DIST_THR 100
|
||||
|
||||
class NavyUnit : public Unit
|
||||
{
|
||||
public:
|
||||
NavyUnit(json::value json, unsigned int ID);
|
||||
|
||||
static void loadDatabase(string path);
|
||||
|
||||
virtual void setState(unsigned char newState);
|
||||
virtual void setDefaults(bool force = false);
|
||||
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void setOnOff(bool newOnOff, bool force = false);
|
||||
|
||||
protected:
|
||||
virtual void AIloop();
|
||||
static json::value database;
|
||||
};
|
||||
50
backend/core/include/scheduler.h
Normal file
50
backend/core/include/scheduler.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "luatools.h"
|
||||
#include "commands.h"
|
||||
|
||||
class Scheduler
|
||||
{
|
||||
public:
|
||||
Scheduler(lua_State* L);
|
||||
~Scheduler();
|
||||
|
||||
void appendCommand(Command* command);
|
||||
void execute(lua_State* L);
|
||||
void handleRequest(string key, json::value value, string username, json::value& answer);
|
||||
bool checkSpawnPoints(int spawnPoints, string coalition);
|
||||
bool isCommandExecuted(string commandHash) { return (find(executedCommandsHashes.begin(), executedCommandsHashes.end(), commandHash) != executedCommandsHashes.end()); }
|
||||
|
||||
void setFrameRate(double newFrameRate) { frameRate = newFrameRate; }
|
||||
void setRestrictSpawns(bool newRestrictSpawns) { restrictSpawns = newRestrictSpawns; }
|
||||
void setRestrictToCoalition(bool newRestrictToCoalition) { restrictToCoalition = newRestrictToCoalition; }
|
||||
void setSetupTime(unsigned int newSetupTime) { setupTime = newSetupTime; }
|
||||
void setBlueSpawnPoints(int newBlueSpawnPoints) { blueSpawnPoints = newBlueSpawnPoints; }
|
||||
void setRedSpawnPoints(int newRedSpawnPoints) { redSpawnPoints = newRedSpawnPoints; }
|
||||
void setEras(vector<string> newEras) { eras = newEras; }
|
||||
void setCommandModeOptions(json::value newOptions);
|
||||
|
||||
int getFrameRate() { return static_cast<int>(round(frameRate)); };
|
||||
int getLoad();
|
||||
bool getRestrictSpawns() { return restrictSpawns; }
|
||||
bool getRestrictToCoalition() { return restrictToCoalition; }
|
||||
unsigned int getSetupTime() { return setupTime; }
|
||||
int getBlueSpawnPoints() { return blueSpawnPoints; }
|
||||
int getRedSpawnPoints() { return redSpawnPoints; }
|
||||
vector<string> getEras() { return eras; }
|
||||
json::value getCommandModeOptions();
|
||||
|
||||
private:
|
||||
list<Command*> commands;
|
||||
list<string> executedCommandsHashes;
|
||||
unsigned int load = 0;
|
||||
double frameRate = 0;
|
||||
|
||||
bool restrictSpawns = false;
|
||||
bool restrictToCoalition = false;
|
||||
unsigned int setupTime = 300;
|
||||
int blueSpawnPoints = 10000;
|
||||
int redSpawnPoints = 10000;
|
||||
vector<string> eras = { "WW2", "Early Cold War", "Mid Cold War", "Late Cold War", "Modern" };
|
||||
};
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
function Olympus.protectedCall(...)\n\n \
|
||||
local status, retval = pcall(...)\n \
|
||||
if not status then\n \
|
||||
trigger.action.outText(\"ERROR: \" ..retval, 20)\n \
|
||||
if Olympus.log ~= nil then\n \
|
||||
Olympus.log:error(retval)\n \
|
||||
else\n \
|
||||
trigger.action.outText(\"Olympus critical error: \" ..retval, 20)\n \
|
||||
end\n \
|
||||
end\n \
|
||||
end\n \
|
||||
trigger.action.outText(\"Olympus.protectedCall registered successfully\", 10)\n"
|
||||
@@ -24,10 +24,17 @@ private:
|
||||
void handle_request(http_request request, function<void(json::value const&, json::value&)> action);
|
||||
void handle_put(http_request request);
|
||||
|
||||
string extractUsername(http_request& request);
|
||||
string extractPassword(http_request& request);
|
||||
|
||||
void task();
|
||||
|
||||
atomic<bool> runListener;
|
||||
|
||||
wstring password = L"";
|
||||
string gameMasterPassword = "";
|
||||
string blueCommanderPassword = "";
|
||||
string redCommanderPassword = "";
|
||||
string atcPassword = "";
|
||||
string observerPassword = "";
|
||||
};
|
||||
|
||||
268
backend/core/include/unit.h
Normal file
268
backend/core/include/unit.h
Normal file
@@ -0,0 +1,268 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "utils.h"
|
||||
#include "dcstools.h"
|
||||
#include "luatools.h"
|
||||
#include "logger.h"
|
||||
#include "commands.h"
|
||||
#include "datatypes.h"
|
||||
|
||||
#include <chrono>
|
||||
using namespace std::chrono;
|
||||
|
||||
#define TASK_CHECK_INIT_VALUE 10
|
||||
|
||||
class Unit
|
||||
{
|
||||
public:
|
||||
Unit(json::value json, unsigned int ID);
|
||||
~Unit();
|
||||
|
||||
/********** Methods **********/
|
||||
virtual void initialize(json::value json) final;
|
||||
virtual void setDefaults(bool force = false);
|
||||
|
||||
void runAILoop();
|
||||
|
||||
virtual void update(json::value json, double dt) final;
|
||||
void refreshLeaderData(unsigned long long time);
|
||||
|
||||
unsigned int getID() { return ID; }
|
||||
void getData(stringstream& ss, unsigned long long time);
|
||||
Coords getActiveDestination() { return activeDestination; }
|
||||
|
||||
virtual void changeSpeed(string change) {};
|
||||
virtual void changeAltitude(string change) {};
|
||||
bool setActiveDestination();
|
||||
void resetActiveDestination();
|
||||
void landAt(Coords loc);
|
||||
|
||||
bool updateActivePath(bool looping);
|
||||
void clearActivePath();
|
||||
void pushActivePathFront(Coords newActivePathFront);
|
||||
void pushActivePathBack(Coords newActivePathBack);
|
||||
void popActivePathFront();
|
||||
void goToDestination(string enrouteTask = "nil");
|
||||
bool isDestinationReached(double threshold);
|
||||
|
||||
string getTargetName();
|
||||
string getLeaderName();
|
||||
bool isTargetAlive();
|
||||
bool isLeaderAlive();
|
||||
|
||||
void resetTask();
|
||||
bool checkTaskFailed();
|
||||
void resetTaskFailedCounter();
|
||||
void setHasTaskAssigned(bool newHasTaskAssigned);
|
||||
void setEnableTaskCheckFailed(bool newEnableTaskCheckFailed) { enableTaskFailedCheck = newEnableTaskCheckFailed; }
|
||||
bool getEnableTaskCheckFailed() { return enableTaskFailedCheck; }
|
||||
|
||||
void triggerUpdate(unsigned char datumIndex);
|
||||
|
||||
bool hasFreshData(unsigned long long time);
|
||||
bool checkFreshness(unsigned char datumIndex, unsigned long long time);
|
||||
|
||||
/********** Setters **********/
|
||||
virtual void setCategory(string newValue) { updateValue(category, newValue, DataIndex::category); }
|
||||
virtual void setAlive(bool newValue) { updateValue(alive, newValue, DataIndex::alive); }
|
||||
virtual void setHuman(bool newValue) { updateValue(human, newValue, DataIndex::human); }
|
||||
virtual void setControlled(bool newValue) { updateValue(controlled, newValue, DataIndex::controlled); }
|
||||
virtual void setCoalition(unsigned char newValue) { updateValue(coalition, newValue, DataIndex::coalition); }
|
||||
virtual void setCountry(unsigned char newValue) { updateValue(country, newValue, DataIndex::country); }
|
||||
virtual void setName(string newValue) { updateValue(name, newValue, DataIndex::name); }
|
||||
virtual void setUnitName(string newValue) { updateValue(unitName, newValue, DataIndex::unitName); }
|
||||
virtual void setCallsign(string newValue) { updateValue(callsign, newValue, DataIndex::callsign); }
|
||||
virtual void setGroupName(string newValue) { updateValue(groupName, newValue, DataIndex::groupName); }
|
||||
virtual void setState(unsigned char newValue) { updateValue(state, newValue, DataIndex::state); };
|
||||
virtual void setTask(string newValue) { updateValue(task, newValue, DataIndex::task); }
|
||||
virtual void setHasTask(bool newValue);
|
||||
virtual void setPosition(Coords newValue) { updateValue(position, newValue, DataIndex::position); }
|
||||
virtual void setSpeed(double newValue) { updateValue(speed, newValue, DataIndex::speed); }
|
||||
virtual void setHorizontalVelocity(double newValue) { updateValue(horizontalVelocity, newValue, DataIndex::horizontalVelocity); }
|
||||
virtual void setVerticalVelocity(double newValue) { updateValue(verticalVelocity, newValue, DataIndex::verticalVelocity); }
|
||||
virtual void setHeading(double newValue) { updateValue(heading, newValue, DataIndex::heading); }
|
||||
virtual void setTrack(double newValue) { updateValue(track, newValue, DataIndex::track); }
|
||||
virtual void setIsActiveTanker(bool newValue);
|
||||
virtual void setIsActiveAWACS(bool newValue);
|
||||
virtual void setOnOff(bool newValue, bool force = false) { updateValue(onOff, newValue, DataIndex::onOff); };
|
||||
virtual void setFollowRoads(bool newValue, bool force = false) { updateValue(followRoads, newValue, DataIndex::followRoads); };
|
||||
virtual void setFuel(unsigned short newValue) { updateValue(fuel, newValue, DataIndex::fuel); }
|
||||
virtual void setDesiredSpeed(double newValue);
|
||||
virtual void setDesiredSpeedType(string newValue);
|
||||
virtual void setDesiredAltitude(double newValue);
|
||||
virtual void setDesiredAltitudeType(string newValue);
|
||||
virtual void setLeaderID(unsigned int newValue) { updateValue(leaderID, newValue, DataIndex::leaderID); }
|
||||
virtual void setFormationOffset(Offset formationOffset);
|
||||
virtual void setTargetID(unsigned int newValue) { updateValue(targetID, newValue, DataIndex::targetID); }
|
||||
virtual void setTargetPosition(Coords newValue) { updateValue(targetPosition, newValue, DataIndex::targetPosition); }
|
||||
virtual void setROE(unsigned char newValue, bool force = false);
|
||||
virtual void setReactionToThreat(unsigned char newValue, bool force = false);
|
||||
virtual void setEmissionsCountermeasures(unsigned char newValue, bool force = false);
|
||||
virtual void setTACAN(DataTypes::TACAN newValue, bool force = false);
|
||||
virtual void setRadio(DataTypes::Radio newValue, bool force = false);
|
||||
virtual void setGeneralSettings(DataTypes::GeneralSettings newValue, bool force = false);
|
||||
virtual void setAmmo(vector<DataTypes::Ammo> newValue);
|
||||
virtual void setContacts(vector<DataTypes::Contact> newValue);
|
||||
virtual void setActivePath(list<Coords> newValue);
|
||||
virtual void setIsLeader(bool newValue) { updateValue(isLeader, newValue, DataIndex::isLeader); }
|
||||
virtual void setOperateAs(unsigned char newValue) { updateValue(operateAs, newValue, DataIndex::operateAs); }
|
||||
virtual void setShotsScatter(unsigned char newValue) { updateValue(shotsScatter, newValue, DataIndex::shotsScatter); }
|
||||
virtual void setShotsIntensity(unsigned char newValue) { updateValue(shotsIntensity, newValue, DataIndex::shotsIntensity); }
|
||||
virtual void setHealth(unsigned char newValue) { updateValue(health, newValue, DataIndex::health); }
|
||||
|
||||
/********** Getters **********/
|
||||
virtual string getCategory() { return category; };
|
||||
virtual bool getAlive() { return alive; }
|
||||
virtual bool getHuman() { return human; }
|
||||
virtual bool getControlled() { return controlled; }
|
||||
virtual unsigned char getCoalition() { return coalition; }
|
||||
virtual unsigned char getCountry() { return country; }
|
||||
virtual string getName() { return name; }
|
||||
virtual string getCallsign() { return callsign; }
|
||||
virtual string getUnitName() { return unitName; }
|
||||
virtual string getGroupName() { return groupName; }
|
||||
virtual unsigned char getState() { return state; }
|
||||
virtual string getTask() { return task; }
|
||||
virtual bool getHasTask() { return hasTask; }
|
||||
virtual Coords getPosition() { return position; }
|
||||
virtual double getSpeed() { return speed; }
|
||||
virtual double getHorizontalVelocity() { return horizontalVelocity; }
|
||||
virtual double getVerticalVelocity() { return verticalVelocity; }
|
||||
virtual double getHeading() { return heading; }
|
||||
virtual double getTrack() { return track; }
|
||||
virtual bool getIsActiveTanker() { return isActiveTanker; }
|
||||
virtual bool getIsActiveAWACS() { return isActiveAWACS; }
|
||||
virtual bool getOnOff() { return onOff; };
|
||||
virtual bool getFollowRoads() { return followRoads; };
|
||||
virtual unsigned short getFuel() { return fuel; }
|
||||
virtual double getDesiredSpeed() { return desiredSpeed; };
|
||||
virtual bool getDesiredSpeedType() { return desiredSpeedType; };
|
||||
virtual double getDesiredAltitude() { return desiredAltitude; };
|
||||
virtual bool getDesiredAltitudeType() { return desiredAltitudeType; };
|
||||
virtual unsigned int getLeaderID() { return leaderID; }
|
||||
virtual Offset getFormationOffset() { return formationOffset; }
|
||||
virtual unsigned int getTargetID() { return targetID; }
|
||||
virtual Coords getTargetPosition() { return targetPosition; }
|
||||
virtual unsigned char getROE() { return ROE; }
|
||||
virtual unsigned char getReactionToThreat() { return reactionToThreat; }
|
||||
virtual unsigned char getEmissionsCountermeasures() { return emissionsCountermeasures; };
|
||||
virtual DataTypes::TACAN getTACAN() { return TACAN; }
|
||||
virtual DataTypes::Radio getRadio() { return radio; }
|
||||
virtual DataTypes::GeneralSettings getGeneralSettings() { return generalSettings; }
|
||||
virtual vector<DataTypes::Ammo> getAmmo() { return ammo; }
|
||||
virtual vector<DataTypes::Contact> getContacts() { return contacts; }
|
||||
virtual list<Coords> getActivePath() { return activePath; }
|
||||
virtual bool getIsLeader() { return isLeader; }
|
||||
virtual unsigned char getOperateAs() { return operateAs; }
|
||||
virtual unsigned char getShotsScatter() { return shotsScatter; }
|
||||
virtual unsigned char getShotsIntensity() { return shotsIntensity; }
|
||||
virtual unsigned char getHealth() { return health; }
|
||||
|
||||
protected:
|
||||
unsigned int ID;
|
||||
|
||||
string category;
|
||||
bool alive = false;
|
||||
bool human = false;
|
||||
bool controlled = false;
|
||||
unsigned char coalition = NULL;
|
||||
unsigned char country = NULL;
|
||||
string name = "";
|
||||
string unitName = "";
|
||||
string callsign = "";
|
||||
string groupName = "";
|
||||
unsigned char state = State::NONE;
|
||||
string task = "";
|
||||
bool hasTask = false;
|
||||
Coords position = Coords(NULL);
|
||||
double speed = NULL;
|
||||
double horizontalVelocity = NULL;
|
||||
double verticalVelocity = NULL;
|
||||
double heading = NULL;
|
||||
double track = NULL;
|
||||
bool isActiveTanker = false;
|
||||
bool isActiveAWACS = false;
|
||||
bool onOff = true;
|
||||
bool followRoads = false;
|
||||
unsigned short fuel = 0;
|
||||
double desiredSpeed = 0;
|
||||
bool desiredSpeedType = 0; /* CAS */
|
||||
double desiredAltitude = 1;
|
||||
bool desiredAltitudeType = 0; /* ASL */
|
||||
unsigned int leaderID = NULL;
|
||||
Offset formationOffset = Offset(NULL);
|
||||
unsigned int targetID = NULL;
|
||||
Coords targetPosition = Coords(NULL);
|
||||
unsigned char ROE = ROE::OPEN_FIRE_WEAPON_FREE;
|
||||
unsigned char reactionToThreat = ReactionToThreat::EVADE_FIRE;
|
||||
unsigned char emissionsCountermeasures = EmissionCountermeasure::DEFEND;
|
||||
DataTypes::TACAN TACAN;
|
||||
DataTypes::Radio radio;
|
||||
DataTypes::GeneralSettings generalSettings;
|
||||
vector<DataTypes::Ammo> ammo;
|
||||
vector<DataTypes::Contact> contacts;
|
||||
list<Coords> activePath;
|
||||
bool isLeader = false;
|
||||
unsigned char operateAs = 2;
|
||||
Coords activeDestination = Coords(NULL);
|
||||
unsigned char shotsScatter = 2;
|
||||
unsigned char shotsIntensity = 2;
|
||||
unsigned char health = 100;
|
||||
|
||||
/********** Other **********/
|
||||
unsigned int taskCheckCounter = 0;
|
||||
unsigned int internalCounter = 0;
|
||||
Unit* missOnPurposeTarget = nullptr;
|
||||
bool hasTaskAssigned = false;
|
||||
double initialFuel = 0;
|
||||
map<unsigned char, unsigned long long> updateTimeMap;
|
||||
unsigned long long lastLoopTime = 0;
|
||||
bool enableTaskFailedCheck = false;
|
||||
|
||||
/********** Private methods **********/
|
||||
virtual void AIloop() = 0;
|
||||
|
||||
void appendString(stringstream& ss, const unsigned char& datumIndex, const string& datumValue) {
|
||||
const unsigned short size = static_cast<unsigned short>(datumValue.size());
|
||||
ss.write((const char*)&datumIndex, sizeof(unsigned char));
|
||||
ss.write((const char*)&size, sizeof(unsigned short));
|
||||
ss << datumValue;
|
||||
}
|
||||
|
||||
/********** Template methods **********/
|
||||
template <typename T>
|
||||
void updateValue(T& value, T& newValue, unsigned char datumIndex)
|
||||
{
|
||||
if (newValue != value)
|
||||
{
|
||||
triggerUpdate(datumIndex);
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void appendNumeric(stringstream& ss, const unsigned char& datumIndex, T& datumValue) {
|
||||
ss.write((const char*)&datumIndex, sizeof(unsigned char));
|
||||
ss.write((const char*)&datumValue, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void appendVector(stringstream& ss, const unsigned char& datumIndex, vector<T>& datumValue) {
|
||||
const unsigned short size = static_cast<unsigned short>(datumValue.size());
|
||||
ss.write((const char*)&datumIndex, sizeof(unsigned char));
|
||||
ss.write((const char*)&size, sizeof(unsigned short));
|
||||
|
||||
for (auto& el : datumValue)
|
||||
ss.write((const char*)&el, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void appendList(stringstream& ss, const unsigned char& datumIndex, list<T>& datumValue) {
|
||||
const unsigned short size = static_cast<unsigned short>(datumValue.size());;
|
||||
ss.write((const char*)&datumIndex, sizeof(unsigned char));
|
||||
ss.write((const char*)&size, sizeof(unsigned short));
|
||||
|
||||
for (auto& el: datumValue)
|
||||
ss.write((const char*)&el, sizeof(T));
|
||||
}
|
||||
};
|
||||
34
backend/core/include/unitsmanager.h
Normal file
34
backend/core/include/unitsmanager.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "dcstools.h"
|
||||
|
||||
class Unit;
|
||||
|
||||
class UnitsManager
|
||||
{
|
||||
public:
|
||||
UnitsManager(lua_State* L);
|
||||
~UnitsManager();
|
||||
|
||||
map<unsigned int, Unit*>& getUnits() { return units; };
|
||||
Unit* getUnit(unsigned int ID);
|
||||
bool isUnitInGroup(Unit* unit);
|
||||
bool isUnitGroupLeader(Unit* unit, Unit*& leader);
|
||||
Unit* getGroupLeader(unsigned int ID);
|
||||
Unit* getGroupLeader(Unit* unit);
|
||||
vector<Unit*> getGroupMembers(string groupName);
|
||||
void update(json::value& missionData, double dt);
|
||||
void runAILoop();
|
||||
void getUnitData(stringstream &ss, unsigned long long time);
|
||||
void deleteUnit(unsigned int ID, bool explosion, string explosionType, bool immediate);
|
||||
void acquireControl(unsigned int ID);
|
||||
void loadDatabases();
|
||||
Unit* getClosestUnit(Unit* unit, unsigned char coalition, vector<string> categories, double &distance);
|
||||
map<Unit*, double> getUnitsInRange(Unit* unit, unsigned char coalition, vector<string> categories, double range);
|
||||
|
||||
private:
|
||||
map<unsigned int, Unit*> units;
|
||||
json::value missionDB;
|
||||
|
||||
};
|
||||
|
||||
116
backend/core/include/weapon.h
Normal file
116
backend/core/include/weapon.h
Normal file
@@ -0,0 +1,116 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "utils.h"
|
||||
#include "dcstools.h"
|
||||
#include "luatools.h"
|
||||
#include "logger.h"
|
||||
#include "commands.h"
|
||||
#include "datatypes.h"
|
||||
|
||||
#include <chrono>
|
||||
using namespace std::chrono;
|
||||
|
||||
class Weapon
|
||||
{
|
||||
public:
|
||||
Weapon(json::value json, unsigned int ID);
|
||||
~Weapon();
|
||||
|
||||
/********** Methods **********/
|
||||
void initialize(json::value json);
|
||||
void update(json::value json, double dt);
|
||||
unsigned int getID() { return ID; }
|
||||
void getData(stringstream& ss, unsigned long long time);
|
||||
void triggerUpdate(unsigned char datumIndex);
|
||||
bool hasFreshData(unsigned long long time);
|
||||
bool checkFreshness(unsigned char datumIndex, unsigned long long time);
|
||||
|
||||
/********** Setters **********/
|
||||
virtual void setCategory(string newValue) { updateValue(category, newValue, DataIndex::category); }
|
||||
virtual void setAlive(bool newValue) { updateValue(alive, newValue, DataIndex::alive); }
|
||||
virtual void setCoalition(unsigned char newValue) { updateValue(coalition, newValue, DataIndex::coalition); }
|
||||
virtual void setName(string newValue) { updateValue(name, newValue, DataIndex::name); }
|
||||
virtual void setPosition(Coords newValue) { updateValue(position, newValue, DataIndex::position); }
|
||||
virtual void setSpeed(double newValue) { updateValue(speed, newValue, DataIndex::speed); }
|
||||
virtual void setHeading(double newValue) { updateValue(heading, newValue, DataIndex::heading); }
|
||||
|
||||
/********** Getters **********/
|
||||
virtual string getCategory() { return category; };
|
||||
virtual bool getAlive() { return alive; }
|
||||
virtual unsigned char getCoalition() { return coalition; }
|
||||
virtual string getName() { return name; }
|
||||
virtual Coords getPosition() { return position; }
|
||||
virtual double getSpeed() { return speed; }
|
||||
virtual double getHeading() { return heading; }
|
||||
|
||||
protected:
|
||||
unsigned int ID;
|
||||
|
||||
string category;
|
||||
bool alive = false;
|
||||
unsigned char coalition = NULL;
|
||||
string name = "";
|
||||
Coords position = Coords(NULL);
|
||||
double speed = NULL;
|
||||
double heading = NULL;
|
||||
|
||||
/********** Other **********/
|
||||
map<unsigned char, unsigned long long> updateTimeMap;
|
||||
|
||||
/********** Private methods **********/
|
||||
void appendString(stringstream& ss, const unsigned char& datumIndex, const string& datumValue) {
|
||||
const unsigned short size = static_cast<unsigned short>(datumValue.size());
|
||||
ss.write((const char*)&datumIndex, sizeof(unsigned char));
|
||||
ss.write((const char*)&size, sizeof(unsigned short));
|
||||
ss << datumValue;
|
||||
}
|
||||
|
||||
/********** Template methods **********/
|
||||
template <typename T>
|
||||
void updateValue(T& value, T& newValue, unsigned char datumIndex)
|
||||
{
|
||||
if (newValue != value)
|
||||
{
|
||||
triggerUpdate(datumIndex);
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void appendNumeric(stringstream& ss, const unsigned char& datumIndex, T& datumValue) {
|
||||
ss.write((const char*)&datumIndex, sizeof(unsigned char));
|
||||
ss.write((const char*)&datumValue, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void appendVector(stringstream& ss, const unsigned char& datumIndex, vector<T>& datumValue) {
|
||||
const unsigned short size = datumValue.size();
|
||||
ss.write((const char*)&datumIndex, sizeof(unsigned char));
|
||||
ss.write((const char*)&size, sizeof(unsigned short));
|
||||
|
||||
for (auto& el : datumValue)
|
||||
ss.write((const char*)&el, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void appendList(stringstream& ss, const unsigned char& datumIndex, list<T>& datumValue) {
|
||||
const unsigned short size = datumValue.size();
|
||||
ss.write((const char*)&datumIndex, sizeof(unsigned char));
|
||||
ss.write((const char*)&size, sizeof(unsigned short));
|
||||
|
||||
for (auto& el : datumValue)
|
||||
ss.write((const char*)&el, sizeof(T));
|
||||
}
|
||||
};
|
||||
|
||||
class Missile : public Weapon
|
||||
{
|
||||
public:
|
||||
Missile(json::value json, unsigned int ID);
|
||||
};
|
||||
|
||||
class Bomb : public Weapon
|
||||
{
|
||||
public:
|
||||
Bomb(json::value json, unsigned int ID);
|
||||
};
|
||||
21
backend/core/include/weaponsmanager.h
Normal file
21
backend/core/include/weaponsmanager.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "dcstools.h"
|
||||
|
||||
class Weapon;
|
||||
|
||||
class WeaponsManager
|
||||
{
|
||||
public:
|
||||
WeaponsManager(lua_State* L);
|
||||
~WeaponsManager();
|
||||
|
||||
map<unsigned int, Weapon*>& getWeapons() { return weapons; };
|
||||
Weapon* getWeapon(unsigned int ID);
|
||||
void update(json::value& missionData, double dt);
|
||||
void getWeaponData(stringstream& ss, unsigned long long time);
|
||||
|
||||
private:
|
||||
map<unsigned int, Weapon*> weapons;
|
||||
};
|
||||
|
||||
14
backend/core/resource.h
Normal file
14
backend/core/resource.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by core.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -11,59 +11,61 @@ using namespace GeographicLib;
|
||||
|
||||
extern Scheduler* scheduler;
|
||||
extern UnitsManager* unitsManager;
|
||||
json::value Aircraft::database = json::value();
|
||||
extern string instancePath;
|
||||
|
||||
void Aircraft::loadDatabase(string path) {
|
||||
std::ifstream ifstream(instancePath + path);
|
||||
std::stringstream ss;
|
||||
ss << ifstream.rdbuf();
|
||||
std::error_code errorCode;
|
||||
database = json::value::parse(ss.str(), errorCode);
|
||||
if (database.is_object())
|
||||
log("Aircrafts database loaded correctly from " + instancePath + path);
|
||||
else
|
||||
log("Error reading Aircrafts database file");
|
||||
}
|
||||
|
||||
/* Aircraft */
|
||||
Aircraft::Aircraft(json::value json, int ID) : AirUnit(json, ID)
|
||||
Aircraft::Aircraft(json::value json, unsigned int ID) : AirUnit(json, ID)
|
||||
{
|
||||
log("New Aircraft created with ID: " + to_string(ID));
|
||||
addMeasure(L"category", json::value(getCategory()));
|
||||
|
||||
double desiredSpeed = knotsToMs(300);
|
||||
double desiredAltitude = ftToM(20000);
|
||||
setDesiredSpeed(desiredSpeed);
|
||||
setDesiredAltitude(desiredAltitude);
|
||||
setCategory("Aircraft");
|
||||
setDesiredSpeed(knotsToMs(300));
|
||||
setDesiredAltitude(ftToM(20000));
|
||||
};
|
||||
|
||||
void Aircraft::changeSpeed(wstring change)
|
||||
void Aircraft::changeSpeed(string change)
|
||||
{
|
||||
if (change.compare(L"stop") == 0)
|
||||
if (change.compare("stop") == 0)
|
||||
setState(State::IDLE);
|
||||
else if (change.compare(L"slow") == 0)
|
||||
else if (change.compare("slow") == 0)
|
||||
setDesiredSpeed(getDesiredSpeed() - knotsToMs(25));
|
||||
else if (change.compare(L"fast") == 0)
|
||||
else if (change.compare("fast") == 0)
|
||||
setDesiredSpeed(getDesiredSpeed() + knotsToMs(25));
|
||||
|
||||
if (getDesiredSpeed() < knotsToMs(50))
|
||||
setDesiredSpeed(knotsToMs(50));
|
||||
|
||||
if (state == State::IDLE)
|
||||
resetTask();
|
||||
else
|
||||
goToDestination(); /* Send the command to reach the destination */
|
||||
}
|
||||
|
||||
void Aircraft::changeAltitude(wstring change)
|
||||
void Aircraft::changeAltitude(string change)
|
||||
{
|
||||
if (change.compare(L"descend") == 0)
|
||||
if (change.compare("descend") == 0)
|
||||
{
|
||||
if (getDesiredAltitude() > 5000)
|
||||
setDesiredAltitude(getDesiredAltitude() - ftToM(2500));
|
||||
else if (getDesiredAltitude() > 0)
|
||||
setDesiredAltitude(getDesiredAltitude() - ftToM(500));
|
||||
}
|
||||
else if (change.compare(L"climb") == 0)
|
||||
else if (change.compare("climb") == 0)
|
||||
{
|
||||
if (getDesiredAltitude() > 5000)
|
||||
setDesiredAltitude(getDesiredAltitude() + ftToM(2500));
|
||||
else if (getDesiredAltitude() >= 0)
|
||||
setDesiredAltitude(getDesiredAltitude() + ftToM(500));
|
||||
setDesiredAltitude(getDesiredAltitude() + ftToM(500));
|
||||
}
|
||||
|
||||
if (getDesiredAltitude() < 0)
|
||||
setDesiredAltitude(0);
|
||||
|
||||
if (state == State::IDLE)
|
||||
resetTask();
|
||||
else
|
||||
goToDestination(); /* Send the command to reach the destination */
|
||||
}
|
||||
@@ -13,13 +13,35 @@ extern Scheduler* scheduler;
|
||||
extern UnitsManager* unitsManager;
|
||||
|
||||
/* Air unit */
|
||||
AirUnit::AirUnit(json::value json, int ID) : Unit(json, ID)
|
||||
AirUnit::AirUnit(json::value json, unsigned int ID) : Unit(json, ID)
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
void AirUnit::setState(int newState)
|
||||
void AirUnit::setDefaults(bool force)
|
||||
{
|
||||
if (!getAlive() || !getControlled() || getHuman() || !getIsLeader()) return;
|
||||
|
||||
/* Set the default IDLE state */
|
||||
setState(State::IDLE);
|
||||
|
||||
/* Set desired altitude to be equal to current altitude so the unit does not climb/descend after spawn */
|
||||
setDesiredAltitude(position.alt);
|
||||
|
||||
/* Set the default options */
|
||||
setROE(ROE::OPEN_FIRE_WEAPON_FREE, force);
|
||||
setReactionToThreat(ReactionToThreat::EVADE_FIRE, force);
|
||||
setEmissionsCountermeasures(EmissionCountermeasure::DEFEND, force);
|
||||
strcpy_s(TACAN.callsign, 4, "TKR");
|
||||
setTACAN(TACAN, force);
|
||||
setRadio(radio, force);
|
||||
setGeneralSettings(generalSettings, force);
|
||||
}
|
||||
|
||||
void AirUnit::setState(unsigned char newState)
|
||||
{
|
||||
Coords currentTargetPosition = getTargetPosition();
|
||||
|
||||
/************ Perform any action required when LEAVING a state ************/
|
||||
if (newState != state) {
|
||||
switch (state) {
|
||||
@@ -46,7 +68,10 @@ void AirUnit::setState(int newState)
|
||||
case State::BOMB_POINT:
|
||||
case State::CARPET_BOMB:
|
||||
case State::BOMB_BUILDING: {
|
||||
setTargetLocation(Coords(NULL));
|
||||
setTargetPosition(Coords(NULL));
|
||||
break;
|
||||
}
|
||||
case State::LAND_AT_POINT: {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -57,116 +82,130 @@ void AirUnit::setState(int newState)
|
||||
/************ Perform any action required when ENTERING a state ************/
|
||||
switch (newState) {
|
||||
case State::IDLE: {
|
||||
setEnableTaskCheckFailed(false);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
addMeasure(L"currentState", json::value(L"Idle"));
|
||||
break;
|
||||
}
|
||||
case State::REACH_DESTINATION: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
resetActiveDestination();
|
||||
addMeasure(L"currentState", json::value(L"Reach destination"));
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
if (isTargetAlive()) {
|
||||
Unit* target = unitsManager->getUnit(targetID);
|
||||
Coords targetPosition = Coords(target->getLatitude(), target->getLongitude(), 0);
|
||||
Coords targetPosition = Coords(target->getPosition().lat, target->getPosition().lng, 0);
|
||||
clearActivePath();
|
||||
pushActivePathFront(targetPosition);
|
||||
resetActiveDestination();
|
||||
addMeasure(L"currentState", json::value(L"Attack"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::FOLLOW: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
addMeasure(L"currentState", json::value(L"Follow"));
|
||||
break;
|
||||
}
|
||||
case State::LAND: {
|
||||
setEnableTaskCheckFailed(false);
|
||||
resetActiveDestination();
|
||||
addMeasure(L"currentState", json::value(L"Land"));
|
||||
break;
|
||||
}
|
||||
case State::REFUEL: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
initialFuel = fuel;
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
addMeasure(L"currentState", json::value(L"Refuel"));
|
||||
break;
|
||||
}
|
||||
case State::BOMB_POINT: {
|
||||
addMeasure(L"currentState", json::value(L"Bombing point"));
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::CARPET_BOMB: {
|
||||
addMeasure(L"currentState", json::value(L"Carpet bombing"));
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::BOMB_POINT:
|
||||
case State::CARPET_BOMB:
|
||||
case State::BOMB_BUILDING: {
|
||||
addMeasure(L"currentState", json::value(L"Bombing building"));
|
||||
setTargetPosition(currentTargetPosition);
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::LAND_AT_POINT: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
resetTask();
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
|
||||
log(unitName + L" setting state from " + to_wstring(state) + L" to " + to_wstring(newState));
|
||||
log(unitName + " setting state from " + to_string(state) + " to " + to_string(newState));
|
||||
state = newState;
|
||||
|
||||
triggerUpdate(DataIndex::state);
|
||||
|
||||
AIloop();
|
||||
}
|
||||
|
||||
void AirUnit::AIloop()
|
||||
{
|
||||
srand(static_cast<unsigned int>(time(NULL)) + ID);
|
||||
|
||||
/* State machine */
|
||||
switch (state) {
|
||||
case State::IDLE: {
|
||||
currentTask = L"Idle";
|
||||
if (isActiveTanker)
|
||||
setTask("Tanker racetrack");
|
||||
else if (isActiveAWACS)
|
||||
setTask("AWACS racetrack");
|
||||
else
|
||||
setTask("Idle");
|
||||
|
||||
if (!getHasTask())
|
||||
{
|
||||
std::wostringstream taskSS;
|
||||
if (isTanker) {
|
||||
taskSS << "{ [1] = { id = 'Tanker' }, [2] = { id = 'Orbit', pattern = 'Race-Track', altitude = " << desiredAltitude << ", speed = " << desiredSpeed << ", altitudeType = '" << desiredAltitudeType << "' } }";
|
||||
std::ostringstream taskSS;
|
||||
if (isActiveTanker) {
|
||||
taskSS << "{ [1] = { id = 'Tanker' }, [2] = { id = 'Orbit', pattern = 'Race-Track', altitude = " <<
|
||||
desiredAltitude << ", speed = " << desiredSpeed << ", altitudeType = '" <<
|
||||
(desiredAltitudeType ? "AGL" : "ASL") << "', speedType = '" << (desiredSpeedType ? "GS" : "CAS") << "' }}";
|
||||
}
|
||||
else if (isAWACS) {
|
||||
taskSS << "{ [1] = { id = 'AWACS' }, [2] = { id = 'Orbit', pattern = 'Circle', altitude = " << desiredAltitude << ", speed = " << desiredSpeed << ", altitudeType = '" << desiredAltitudeType << "' } }";
|
||||
else if (isActiveAWACS) {
|
||||
taskSS << "{ [1] = { id = 'AWACS' }, [2] = { id = 'Orbit', pattern = 'Circle', altitude = " <<
|
||||
desiredAltitude << ", speed = " << desiredSpeed << ", altitudeType = '" <<
|
||||
(desiredAltitudeType ? "AGL" : "ASL") << "', speedType = '" << (desiredSpeedType ? "GS" : "CAS") << "' }}";
|
||||
}
|
||||
else {
|
||||
taskSS << "{ id = 'Orbit', pattern = 'Circle', altitude = " << desiredAltitude << ", speed = " << desiredSpeed << ", altitudeType = '" << desiredAltitudeType << "' }";
|
||||
taskSS << "{ id = 'Orbit', pattern = 'Circle', altitude = " <<
|
||||
desiredAltitude << ", speed = " << desiredSpeed << ", altitudeType = '" <<
|
||||
(desiredAltitudeType ? "AGL" : "ASL") << "', speedType = '" << (desiredSpeedType ? "GS" : "CAS") << "'}";
|
||||
}
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str()));
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::REACH_DESTINATION: {
|
||||
wstring enrouteTask = L"";
|
||||
string enrouteTask = "";
|
||||
bool looping = false;
|
||||
|
||||
if (isTanker)
|
||||
if (isActiveTanker)
|
||||
{
|
||||
enrouteTask = L"{ id = 'Tanker' }";
|
||||
currentTask = L"Tanker";
|
||||
enrouteTask = "{ id = 'Tanker' }";
|
||||
setTask("Tanker");
|
||||
}
|
||||
else if (isAWACS)
|
||||
else if (isActiveAWACS)
|
||||
{
|
||||
enrouteTask = L"{ id = 'AWACS' }";
|
||||
currentTask = L"AWACS";
|
||||
enrouteTask = "{ id = 'AWACS' }";
|
||||
setTask("AWACS");
|
||||
}
|
||||
else
|
||||
{
|
||||
enrouteTask = L"nil";
|
||||
currentTask = L"Reaching destination";
|
||||
enrouteTask = "nil";
|
||||
setTask("Reaching destination");
|
||||
}
|
||||
|
||||
if (activeDestination == NULL || !getHasTask())
|
||||
@@ -177,7 +216,7 @@ void AirUnit::AIloop()
|
||||
goToDestination(enrouteTask);
|
||||
}
|
||||
else {
|
||||
if (isDestinationReached(AIR_DEST_DIST_THR)) {
|
||||
if (isDestinationReached(getDestinationReachedThreshold())) {
|
||||
if (updateActivePath(looping) && setActiveDestination())
|
||||
goToDestination(enrouteTask);
|
||||
else
|
||||
@@ -187,8 +226,8 @@ void AirUnit::AIloop()
|
||||
break;
|
||||
}
|
||||
case State::LAND: {
|
||||
wstring enrouteTask = L"{ id = 'Land' }";
|
||||
currentTask = L"Landing";
|
||||
string enrouteTask = "{ id = 'Land' }";
|
||||
setTask("Landing");
|
||||
|
||||
if (activeDestination == NULL)
|
||||
{
|
||||
@@ -206,13 +245,13 @@ void AirUnit::AIloop()
|
||||
|
||||
/* Attack state is an "enroute" task, meaning the unit will keep trying to attack even if a new destination is set. This is useful to
|
||||
manoeuvre the unit so that it can detect and engage the target. */
|
||||
std::wostringstream enrouteTaskSS;
|
||||
std::ostringstream enrouteTaskSS;
|
||||
enrouteTaskSS << "{"
|
||||
<< "id = 'EngageUnit'" << ","
|
||||
<< "targetID = " << targetID << ","
|
||||
<< "}";
|
||||
wstring enrouteTask = enrouteTaskSS.str();
|
||||
currentTask = L"Attacking " + getTargetName();
|
||||
string enrouteTask = enrouteTaskSS.str();
|
||||
setTask("Attacking " + getTargetName());
|
||||
|
||||
if (!getHasTask())
|
||||
{
|
||||
@@ -232,13 +271,13 @@ void AirUnit::AIloop()
|
||||
break;
|
||||
}
|
||||
|
||||
currentTask = L"Following " + getTargetName();
|
||||
setTask("Following " + getTargetName());
|
||||
|
||||
Unit* leader = unitsManager->getUnit(leaderID);
|
||||
if (!getHasTask()) {
|
||||
if (leader != nullptr && leader->getAlive() && formationOffset != NULL)
|
||||
{
|
||||
std::wostringstream taskSS;
|
||||
std::ostringstream taskSS;
|
||||
taskSS << "{"
|
||||
<< "id = 'FollowUnit'" << ", "
|
||||
<< "leaderID = " << leader->getID() << ","
|
||||
@@ -248,7 +287,7 @@ void AirUnit::AIloop()
|
||||
<< "z = " << formationOffset.z
|
||||
<< "},"
|
||||
<< "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str()));
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
@@ -256,15 +295,15 @@ void AirUnit::AIloop()
|
||||
break;
|
||||
}
|
||||
case State::REFUEL: {
|
||||
currentTask = L"Refueling";
|
||||
setTask("Refueling");
|
||||
|
||||
if (!getHasTask()) {
|
||||
if (fuel <= initialFuel) {
|
||||
std::wostringstream taskSS;
|
||||
std::ostringstream taskSS;
|
||||
taskSS << "{"
|
||||
<< "id = 'Refuel'"
|
||||
<< "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str()));
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
@@ -272,37 +311,63 @@ void AirUnit::AIloop()
|
||||
setState(State::IDLE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::BOMB_POINT: {
|
||||
currentTask = L"Bombing point";
|
||||
setTask("Bombing point");
|
||||
|
||||
if (!getHasTask()) {
|
||||
std::wostringstream taskSS;
|
||||
taskSS << "{id = 'Bombing', lat = " << targetLocation.lat << ", lng = " << targetLocation.lng << "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str()));
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
|
||||
taskSS << "{id = 'Bombing', lat = " << targetPosition.lat << ", lng = " << targetPosition.lng << "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::CARPET_BOMB: {
|
||||
currentTask = L"Carpet bombing";
|
||||
setTask("Carpet bombing");
|
||||
|
||||
if (!getHasTask()) {
|
||||
std::wostringstream taskSS;
|
||||
taskSS << "{id = 'CarpetBombing', lat = " << targetLocation.lat << ", lng = " << targetLocation.lng << "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str()));
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
|
||||
taskSS << "{id = 'CarpetBombing', lat = " << targetPosition.lat << ", lng = " << targetPosition.lng << "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::BOMB_BUILDING: {
|
||||
currentTask = L"Bombing building";
|
||||
setTask("Bombing building");
|
||||
|
||||
if (!getHasTask()) {
|
||||
std::wostringstream taskSS;
|
||||
taskSS << "{id = 'AttackMapObject', lat = " << targetLocation.lat << ", lng = " << targetLocation.lng << "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str()));
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
|
||||
taskSS << "{id = 'AttackMapObject', lat = " << targetPosition.lat << ", lng = " << targetPosition.lng << "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::LAND_AT_POINT: {
|
||||
setTask("Landing at point");
|
||||
|
||||
if (!getHasTask()) {
|
||||
setActiveDestination();
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10),
|
||||
taskSS << "{"
|
||||
<< "id = 'LandAtPoint', "
|
||||
<< "lat = " << activeDestination.lat << ", "
|
||||
<< "lng = " << activeDestination.lng
|
||||
<< "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
@@ -311,6 +376,4 @@ void AirUnit::AIloop()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
addMeasure(L"currentTask", json::value(currentTask));
|
||||
}
|
||||
256
backend/core/src/commands.cpp
Normal file
256
backend/core/src/commands.cpp
Normal file
@@ -0,0 +1,256 @@
|
||||
#include "commands.h"
|
||||
#include "logger.h"
|
||||
#include "dcstools.h"
|
||||
#include "unit.h"
|
||||
#include "unitsmanager.h"
|
||||
|
||||
extern UnitsManager* unitsManager;
|
||||
|
||||
/* Move command */
|
||||
string Move::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.move, "
|
||||
<< "\"" << groupName << "\"" << ", "
|
||||
<< destination.lat << ", "
|
||||
<< destination.lng << ", "
|
||||
<< altitude << ", "
|
||||
<< "\"" << altitudeType << "\"" << ", "
|
||||
<< speed << ", "
|
||||
<< "\"" << speedType << "\"" << ", "
|
||||
<< "\"" << category << "\"" << ", "
|
||||
<< taskOptions;
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Smoke command */
|
||||
string Smoke::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.smoke, "
|
||||
<< "\"" << color << "\"" << ", "
|
||||
<< location.lat << ", "
|
||||
<< location.lng;
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Spawn ground units command */
|
||||
string SpawnGroundUnits::getString()
|
||||
{
|
||||
std::ostringstream unitsSS;
|
||||
unitsSS.precision(10);
|
||||
for (int i = 0; i < spawnOptions.size(); i++) {
|
||||
unitsSS << "[" << i + 1 << "] = {"
|
||||
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
||||
<< "lat = " << spawnOptions[i].location.lat << ", "
|
||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
|
||||
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
|
||||
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.spawnUnits, {"
|
||||
<< "category = " << "\"" << "GroundUnit" << "\"" << ", "
|
||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||
<< "country = \"" << country << "\", "
|
||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
|
||||
/* Spawn ground units command */
|
||||
string SpawnNavyUnits::getString()
|
||||
{
|
||||
std::ostringstream unitsSS;
|
||||
unitsSS.precision(10);
|
||||
for (int i = 0; i < spawnOptions.size(); i++) {
|
||||
unitsSS << "[" << i + 1 << "] = {"
|
||||
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
||||
<< "lat = " << spawnOptions[i].location.lat << ", "
|
||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
|
||||
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.spawnUnits, {"
|
||||
<< "category = " << "\"" << "NavyUnit" << "\"" << ", "
|
||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||
<< "country = \"" << country << "\", "
|
||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Spawn aircrafts command */
|
||||
string SpawnAircrafts::getString()
|
||||
{
|
||||
std::ostringstream unitsSS;
|
||||
unitsSS.precision(10);
|
||||
for (int i = 0; i < spawnOptions.size(); i++) {
|
||||
unitsSS << "[" << i + 1 << "] = {"
|
||||
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
||||
<< "lat = " << spawnOptions[i].location.lat << ", "
|
||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||
<< "alt = " << spawnOptions[i].location.alt << ", "
|
||||
<< "loadout = \"" << spawnOptions[i].loadout << "\"" << ", "
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
|
||||
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.spawnUnits, {"
|
||||
<< "category = " << "\"" << "Aircraft" << "\"" << ", "
|
||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||
<< "airbaseName = \"" << airbaseName << "\", "
|
||||
<< "country = \"" << country << "\", "
|
||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
|
||||
/* Spawn helicopters command */
|
||||
string SpawnHelicopters::getString()
|
||||
{
|
||||
std::ostringstream unitsSS;
|
||||
unitsSS.precision(10);
|
||||
for (int i = 0; i < spawnOptions.size(); i++) {
|
||||
unitsSS << "[" << i + 1 << "] = {"
|
||||
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
||||
<< "lat = " << spawnOptions[i].location.lat << ", "
|
||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||
<< "alt = " << spawnOptions[i].location.alt << ", "
|
||||
<< "loadout = \"" << spawnOptions[i].loadout << "\"" << ", "
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
|
||||
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.spawnUnits, {"
|
||||
<< "category = " << "\"" << "Helicopter" << "\"" << ", "
|
||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||
<< "airbaseName = \"" << airbaseName << "\", "
|
||||
<< "country = \"" << country << "\", "
|
||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Clone unit command */
|
||||
string Clone::getString()
|
||||
{
|
||||
std::ostringstream unitsSS;
|
||||
unitsSS.precision(10);
|
||||
for (int i = 0; i < cloneOptions.size(); i++) {
|
||||
unitsSS << "[" << i + 1 << "] = {"
|
||||
<< "ID = " << cloneOptions[i].ID << ", "
|
||||
<< "lat = " << cloneOptions[i].location.lat << ", "
|
||||
<< "lng = " << cloneOptions[i].location.lng << " }, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.clone, "
|
||||
<< "{" << unitsSS.str() << "}" << ", "
|
||||
<< (deleteOriginal ? "true" : "false");
|
||||
return commandSS.str();
|
||||
|
||||
}
|
||||
|
||||
/* Delete unit command */
|
||||
string Delete::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.delete, "
|
||||
<< ID << ", "
|
||||
<< (explosion ? "true" : "false") << ", "
|
||||
<< "\"" << explosionType << "\"";
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Set task command */
|
||||
string SetTask::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.setTask, "
|
||||
<< "\"" << groupName << "\"" << ", "
|
||||
<< task;
|
||||
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Reset task command */
|
||||
string ResetTask::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.resetTask, "
|
||||
<< "\"" << groupName << "\"";
|
||||
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Set command command */
|
||||
string SetCommand::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.setCommand, "
|
||||
<< "\"" << groupName << "\"" << ", "
|
||||
<< command;
|
||||
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Set option command */
|
||||
string SetOption::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
|
||||
if (!isBoolean) {
|
||||
commandSS << "Olympus.setOption, "
|
||||
<< "\"" << groupName << "\"" << ", "
|
||||
<< optionID << ", "
|
||||
<< optionValue;
|
||||
} else {
|
||||
commandSS << "Olympus.setOption, "
|
||||
<< "\"" << groupName << "\"" << ", "
|
||||
<< optionID << ", "
|
||||
<< (optionBool? "true": "false");
|
||||
}
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Set onOff command */
|
||||
string SetOnOff::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
|
||||
commandSS << "Olympus.setOnOff, "
|
||||
<< "\"" << groupName << "\"" << ", "
|
||||
<< (onOff ? "true" : "false");
|
||||
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Explosion command */
|
||||
string Explosion::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.explosion, "
|
||||
<< intensity << ", "
|
||||
<< "\"" << explosionType << "\"" << ", "
|
||||
<< location.lat << ", "
|
||||
<< location.lng;
|
||||
return commandSS.str();
|
||||
}
|
||||
163
backend/core/src/core.cpp
Normal file
163
backend/core/src/core.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
#include "dcstools.h"
|
||||
#include "logger.h"
|
||||
#include "defines.h"
|
||||
#include "unitsManager.h"
|
||||
#include "weaponsManager.h"
|
||||
#include "server.h"
|
||||
#include "scheduler.h"
|
||||
#include "scriptLoader.h"
|
||||
#include "luatools.h"
|
||||
#include <chrono>
|
||||
using namespace std::chrono;
|
||||
|
||||
auto lastUnitsUpdate = std::chrono::system_clock::now();
|
||||
auto lastWeaponsUpdate = std::chrono::system_clock::now();
|
||||
auto lastExecution = std::chrono::system_clock::now();
|
||||
|
||||
/* Singleton objects */
|
||||
UnitsManager* unitsManager = nullptr;
|
||||
WeaponsManager* weaponsManager = nullptr;
|
||||
Server* server = nullptr;
|
||||
Scheduler* scheduler = nullptr;
|
||||
|
||||
/* Data jsons */
|
||||
json::value missionData = json::value::object();
|
||||
|
||||
mutex mutexLock;
|
||||
string sessionHash;
|
||||
string instancePath;
|
||||
|
||||
bool initialized = false;
|
||||
|
||||
unsigned int frameCounter = 0;
|
||||
|
||||
/* Called when DCS simulation stops. All singleton instances are deleted. */
|
||||
extern "C" DllExport int coreDeinit(lua_State* L)
|
||||
{
|
||||
if (!initialized)
|
||||
return (0);
|
||||
|
||||
log("Olympus coreDeinit called successfully");
|
||||
|
||||
server->stop(L);
|
||||
|
||||
delete unitsManager;
|
||||
delete weaponsManager;
|
||||
delete server;
|
||||
delete scheduler;
|
||||
|
||||
log("All singletons objects destroyed successfully");
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Called when DCS simulation starts. All singletons are instantiated, and the custom Lua functions are registered in the Lua state. */
|
||||
extern "C" DllExport int coreInit(lua_State* L, const char* path)
|
||||
{
|
||||
instancePath = path;
|
||||
|
||||
log("Initializing core.dll with instance path " + instancePath);
|
||||
|
||||
sessionHash = random_string(16);
|
||||
|
||||
log("Random session hash " + sessionHash);
|
||||
|
||||
unitsManager = new UnitsManager(L);
|
||||
weaponsManager = new WeaponsManager(L);
|
||||
server = new Server(L);
|
||||
scheduler = new Scheduler(L);
|
||||
|
||||
registerLuaFunctions(L);
|
||||
|
||||
server->start(L);
|
||||
|
||||
unitsManager->loadDatabases();
|
||||
|
||||
initialized = true;
|
||||
return(0);
|
||||
}
|
||||
|
||||
extern "C" DllExport int coreFrame(lua_State* L)
|
||||
{
|
||||
if (!initialized)
|
||||
return (0);
|
||||
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
frameCounter++;
|
||||
|
||||
const std::chrono::duration<double> executionDuration = std::chrono::system_clock::now() - lastExecution;
|
||||
if (executionDuration.count() > (20 * FRAMERATE_TIME_INTERVAL)) {
|
||||
if (executionDuration.count() > 0) {
|
||||
scheduler->setFrameRate(frameCounter / executionDuration.count());
|
||||
frameCounter = 0;
|
||||
}
|
||||
|
||||
lastExecution = std::chrono::system_clock::now();
|
||||
}
|
||||
|
||||
if (scheduler != nullptr)
|
||||
scheduler->execute(L);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
extern "C" DllExport int coreUnitsData(lua_State * L)
|
||||
{
|
||||
if (!initialized)
|
||||
return (0);
|
||||
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
json::value unitsData = json::value::object();
|
||||
lua_getglobal(L, "Olympus");
|
||||
lua_getfield(L, -1, "unitsData");
|
||||
luaTableToJSON(L, -1, unitsData);
|
||||
|
||||
const std::chrono::duration<double> updateDuration = std::chrono::system_clock::now() - lastUnitsUpdate;
|
||||
if (unitsData.has_object_field(L"units")) {
|
||||
unitsManager->update(unitsData[L"units"], updateDuration.count());
|
||||
}
|
||||
lastUnitsUpdate = std::chrono::system_clock::now();
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
extern "C" DllExport int coreWeaponsData(lua_State * L)
|
||||
{
|
||||
if (!initialized)
|
||||
return (0);
|
||||
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
json::value weaponsData = json::value::object();
|
||||
lua_getglobal(L, "Olympus");
|
||||
lua_getfield(L, -1, "weaponsData");
|
||||
luaTableToJSON(L, -1, weaponsData);
|
||||
|
||||
const std::chrono::duration<double> updateDuration = std::chrono::system_clock::now() - lastWeaponsUpdate;
|
||||
if (weaponsData.has_object_field(L"weapons")) {
|
||||
weaponsManager->update(weaponsData[L"weapons"], updateDuration.count());
|
||||
}
|
||||
lastWeaponsUpdate = std::chrono::system_clock::now();
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
extern "C" DllExport int coreMissionData(lua_State * L)
|
||||
{
|
||||
if (!initialized)
|
||||
return (0);
|
||||
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
lua_getglobal(L, "Olympus");
|
||||
lua_getfield(L, -1, "missionData");
|
||||
luaTableToJSON(L, -1, missionData);
|
||||
|
||||
return(0);
|
||||
}
|
||||
30
backend/core/src/datatypes.cpp
Normal file
30
backend/core/src/datatypes.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "datatypes.h"
|
||||
|
||||
bool operator==(const DataTypes::TACAN& lhs, const DataTypes::TACAN& rhs)
|
||||
{
|
||||
return lhs.isOn == rhs.isOn && lhs.channel == rhs.channel && lhs.XY == rhs.XY && strcmp(lhs.callsign, rhs.callsign) == 0;
|
||||
}
|
||||
|
||||
bool operator==(const DataTypes::Radio& lhs, const DataTypes::Radio& rhs)
|
||||
{
|
||||
return lhs.frequency == rhs.frequency && lhs.callsign == rhs.callsign && lhs.callsignNumber == rhs.callsignNumber;
|
||||
}
|
||||
|
||||
bool operator==(const DataTypes::GeneralSettings& lhs, const DataTypes::GeneralSettings& rhs)
|
||||
{
|
||||
return lhs.prohibitAA == rhs.prohibitAA && lhs.prohibitAfterburner == rhs.prohibitAfterburner && lhs.prohibitAG == rhs.prohibitAG &&
|
||||
lhs.prohibitAirWpn == rhs.prohibitAirWpn && lhs.prohibitJettison == rhs.prohibitJettison;
|
||||
}
|
||||
|
||||
bool operator==(const DataTypes::Ammo& lhs, const DataTypes::Ammo& rhs)
|
||||
{
|
||||
return lhs.category == rhs.category && lhs.guidance == rhs.guidance && lhs.missileCategory == rhs.missileCategory &&
|
||||
lhs.quantity == rhs.quantity && strcmp(lhs.name, rhs.name) == 0;
|
||||
}
|
||||
|
||||
bool operator==(const DataTypes::Contact& lhs, const DataTypes::Contact& rhs)
|
||||
{
|
||||
return lhs.detectionMethod == rhs.detectionMethod && lhs.ID == rhs.ID;
|
||||
}
|
||||
|
||||
|
||||
566
backend/core/src/groundunit.cpp
Normal file
566
backend/core/src/groundunit.cpp
Normal file
@@ -0,0 +1,566 @@
|
||||
#include "groundunit.h"
|
||||
#include "utils.h"
|
||||
#include "logger.h"
|
||||
#include "commands.h"
|
||||
#include "scheduler.h"
|
||||
#include "defines.h"
|
||||
#include "unitsmanager.h"
|
||||
|
||||
#include <GeographicLib/Geodesic.hpp>
|
||||
using namespace GeographicLib;
|
||||
|
||||
extern Scheduler* scheduler;
|
||||
extern UnitsManager* unitsManager;
|
||||
json::value GroundUnit::database = json::value();
|
||||
extern string instancePath;
|
||||
|
||||
#define RANDOM_ZERO_TO_ONE (double)(rand()) / (double)(RAND_MAX)
|
||||
#define RANDOM_MINUS_ONE_TO_ONE (((double)(rand()) / (double)(RAND_MAX) - 0.5) * 2)
|
||||
|
||||
void GroundUnit::loadDatabase(string path) {
|
||||
std::ifstream ifstream(instancePath + path);
|
||||
std::stringstream ss;
|
||||
ss << ifstream.rdbuf();
|
||||
std::error_code errorCode;
|
||||
database = json::value::parse(ss.str(), errorCode);
|
||||
if (database.is_object())
|
||||
log("GroundUnits database loaded correctly from " + instancePath + path);
|
||||
else
|
||||
log("Error reading GroundUnits database file");
|
||||
}
|
||||
|
||||
/* Ground unit */
|
||||
GroundUnit::GroundUnit(json::value json, unsigned int ID) : Unit(json, ID)
|
||||
{
|
||||
log("New Ground Unit created with ID: " + to_string(ID));
|
||||
|
||||
setCategory("GroundUnit");
|
||||
setDesiredSpeed(10);
|
||||
};
|
||||
|
||||
void GroundUnit::setDefaults(bool force)
|
||||
{
|
||||
if (!getAlive() || !getControlled() || getHuman() || !getIsLeader()) return;
|
||||
|
||||
/* Set the default IDLE state */
|
||||
setState(State::IDLE);
|
||||
|
||||
/* Set the default options */
|
||||
setROE(ROE::WEAPON_FREE, force);
|
||||
setOnOff(onOff, force);
|
||||
setFollowRoads(followRoads, force);
|
||||
}
|
||||
|
||||
void GroundUnit::setState(unsigned char newState)
|
||||
{
|
||||
Coords currentTargetPosition = getTargetPosition();
|
||||
|
||||
/************ Perform any action required when LEAVING a state ************/
|
||||
if (newState != state) {
|
||||
switch (state) {
|
||||
case State::IDLE: {
|
||||
break;
|
||||
}
|
||||
case State::REACH_DESTINATION: {
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
setTargetID(NULL);
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA:
|
||||
case State::SIMULATE_FIRE_FIGHT:
|
||||
case State::SCENIC_AAA:
|
||||
case State::MISS_ON_PURPOSE: {
|
||||
setTargetPosition(Coords(NULL));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/************ Perform any action required when ENTERING a state ************/
|
||||
switch (newState) {
|
||||
case State::IDLE: {
|
||||
setEnableTaskCheckFailed(false);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::REACH_DESTINATION: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setTargetPosition(currentTargetPosition);
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::SIMULATE_FIRE_FIGHT: {
|
||||
setTargetPosition(currentTargetPosition);
|
||||
setEnableTaskCheckFailed(false);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::SCENIC_AAA: {
|
||||
setEnableTaskCheckFailed(false);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::MISS_ON_PURPOSE: {
|
||||
setEnableTaskCheckFailed(false);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
|
||||
log(unitName + " setting state from " + to_string(state) + " to " + to_string(newState));
|
||||
state = newState;
|
||||
|
||||
triggerUpdate(DataIndex::state);
|
||||
|
||||
AIloop();
|
||||
}
|
||||
|
||||
void GroundUnit::AIloop()
|
||||
{
|
||||
srand(static_cast<unsigned int>(time(NULL)) + ID);
|
||||
|
||||
switch (state) {
|
||||
case State::IDLE: {
|
||||
setTask("Idle");
|
||||
if (getHasTask())
|
||||
resetTask();
|
||||
break;
|
||||
}
|
||||
case State::REACH_DESTINATION: {
|
||||
setTask("Reaching destination");
|
||||
|
||||
string enrouteTask = "";
|
||||
bool looping = false;
|
||||
|
||||
std::ostringstream taskSS;
|
||||
taskSS << "{ id = 'FollowRoads', value = " << (getFollowRoads() ? "true" : "false") << " }";
|
||||
enrouteTask = taskSS.str();
|
||||
|
||||
if (activeDestination == NULL || !getHasTask())
|
||||
{
|
||||
if (!setActiveDestination())
|
||||
setState(State::IDLE);
|
||||
else
|
||||
goToDestination(enrouteTask);
|
||||
}
|
||||
else {
|
||||
if (isDestinationReached(GROUND_DEST_DIST_THR)) {
|
||||
if (updateActivePath(looping) && setActiveDestination())
|
||||
goToDestination(enrouteTask);
|
||||
else
|
||||
setState(State::IDLE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
Unit* target = unitsManager->getUnit(getTargetID());
|
||||
if (target != nullptr) {
|
||||
setTask("Attacking " + target->getUnitName());
|
||||
|
||||
if (!getHasTask()) {
|
||||
/* Send the command */
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'AttackUnit', unitID = " << target->getID() << " }";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setState(State::IDLE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setTask("Firing at area");
|
||||
|
||||
if (!getHasTask()) {
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'FireAtPoint', lat = " << targetPosition.lat << ", lng = " << targetPosition.lng << ", radius = 100}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case State::SIMULATE_FIRE_FIGHT: {
|
||||
setTask("Simulating fire fight");
|
||||
|
||||
if (internalCounter == 0 && targetPosition != Coords(NULL) && scheduler->getLoad() < 30) {
|
||||
/* Get the distance and bearing to the target */
|
||||
Coords scatteredTargetPosition = targetPosition;
|
||||
double distance;
|
||||
double bearing1;
|
||||
double bearing2;
|
||||
Geodesic::WGS84().Inverse(getPosition().lat, getPosition().lng, scatteredTargetPosition.lat, scatteredTargetPosition.lng, distance, bearing1, bearing2);
|
||||
|
||||
/* Compute the scattered position applying a random scatter to the shot */
|
||||
double scatterDistance = distance * tan(10 /* degs */ * (ShotsScatter::LOW - shotsScatter) / 57.29577 + 2 / 57.29577 /* degs */) * RANDOM_MINUS_ONE_TO_ONE;
|
||||
Geodesic::WGS84().Direct(scatteredTargetPosition.lat, scatteredTargetPosition.lng, bearing1 + 90, scatterDistance, scatteredTargetPosition.lat, scatteredTargetPosition.lng);
|
||||
|
||||
/* Recover the data from the database */
|
||||
double aimTime = 2; /* s */
|
||||
bool indirectFire = false;
|
||||
double shotsBaseInterval = 15; /* s */
|
||||
if (database.has_object_field(to_wstring(name))) {
|
||||
json::value databaseEntry = database[to_wstring(name)];
|
||||
if (databaseEntry.has_number_field(L"aimTime"))
|
||||
aimTime = databaseEntry[L"aimTime"].as_number().to_double();
|
||||
if (databaseEntry.has_boolean_field(L"indirectFire"))
|
||||
indirectFire = databaseEntry[L"indirectFire"].as_bool();
|
||||
if (databaseEntry.has_number_field(L"shotsBaseInterval"))
|
||||
shotsBaseInterval = databaseEntry[L"shotsBaseInterval"].as_number().to_double();
|
||||
}
|
||||
|
||||
/* If the unit is of the indirect fire type, like a mortar, simply shoot at the target */
|
||||
if (indirectFire) {
|
||||
log(unitName + "(" + name + ")" + " simulating fire fight with indirect fire");
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'FireAtPoint', lat = " << scatteredTargetPosition.lat << ", lng = " << scatteredTargetPosition.lng << ", radius = 100}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
/* Otherwise use the aim method */
|
||||
else {
|
||||
log(unitName + "(" + name + ")" + " simulating fire fight with aim at point method");
|
||||
aimAtPoint(scatteredTargetPosition);
|
||||
}
|
||||
|
||||
/* Wait an amout of time depending on the shots intensity */
|
||||
internalCounter = static_cast<unsigned int>(((ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + aimTime) / FRAMERATE_TIME_INTERVAL);
|
||||
}
|
||||
|
||||
if (targetPosition == Coords(NULL))
|
||||
setState(State::IDLE);
|
||||
|
||||
/* Fallback if something went wrong */
|
||||
if (internalCounter == 0)
|
||||
internalCounter = static_cast<unsigned int>(3 / FRAMERATE_TIME_INTERVAL);
|
||||
internalCounter--;
|
||||
|
||||
break;
|
||||
}
|
||||
case State::SCENIC_AAA: {
|
||||
setTask("Scenic AAA");
|
||||
|
||||
/* Only perform scenic functions when the scheduler is "free" */
|
||||
if (((!getHasTask() && scheduler->getLoad() < 30) || internalCounter == 0)) {
|
||||
double distance = 0;
|
||||
unsigned char unitCoalition = coalition == 0 ? getOperateAs() : coalition;
|
||||
unsigned char targetCoalition = unitCoalition == 2 ? 1 : 2;
|
||||
Unit* target = unitsManager->getClosestUnit(this, targetCoalition, { "Aircraft", "Helicopter" }, distance);
|
||||
|
||||
/* Recover the data from the database */
|
||||
double aimTime = 2; /* s */
|
||||
double shotsBaseInterval = 15; /* s */
|
||||
if (database.has_object_field(to_wstring(name))) {
|
||||
json::value databaseEntry = database[to_wstring(name)];
|
||||
if (databaseEntry.has_number_field(L"aimTime"))
|
||||
aimTime = databaseEntry[L"aimTime"].as_number().to_double();
|
||||
if (databaseEntry.has_number_field(L"shotsBaseInterval"))
|
||||
shotsBaseInterval = databaseEntry[L"shotsBaseInterval"].as_number().to_double();
|
||||
}
|
||||
|
||||
/* Only run if an enemy air unit is closer than 20km to avoid useless load */
|
||||
if (target != nullptr && distance < 20000 /* m */) {
|
||||
double r = 15; /* m */
|
||||
double barrelElevation = r * tan(acos(((double)(rand()) / (double)(RAND_MAX))));
|
||||
|
||||
double lat = 0;
|
||||
double lng = 0;
|
||||
double randomBearing = ((double)(rand()) / (double)(RAND_MAX)) * 360;
|
||||
Geodesic::WGS84().Direct(position.lat, position.lng, randomBearing, r, lat, lng);
|
||||
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'FireAtPoint', lat = " << lat << ", lng = " << lng << ", alt = " << position.alt + barrelElevation << ", radius = 0.001}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
|
||||
/* Wait an amout of time depending on the shots intensity */
|
||||
internalCounter = static_cast<unsigned int>(((ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + aimTime) / FRAMERATE_TIME_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
if (internalCounter == 0)
|
||||
internalCounter = static_cast<unsigned int>(3 / FRAMERATE_TIME_INTERVAL);
|
||||
internalCounter--;
|
||||
|
||||
break;
|
||||
}
|
||||
case State::MISS_ON_PURPOSE: {
|
||||
setTask("Missing on purpose");
|
||||
|
||||
/* Check that the unit can perform AAA duties */
|
||||
bool canAAA = false;
|
||||
if (database.has_object_field(to_wstring(name))) {
|
||||
json::value databaseEntry = database[to_wstring(name)];
|
||||
if (databaseEntry.has_boolean_field(L"canAAA"))
|
||||
canAAA = databaseEntry[L"canAAA"].as_bool();
|
||||
}
|
||||
|
||||
if (canAAA) {
|
||||
/* Only perform scenic functions when the scheduler is "free" */
|
||||
/* Only run this when the internal counter reaches 0 to avoid excessive computations when no nearby target */
|
||||
if (scheduler->getLoad() < 30 && internalCounter == 0) {
|
||||
double distance = 0;
|
||||
unsigned char unitCoalition = coalition == 0 ? getOperateAs() : coalition;
|
||||
unsigned char targetCoalition = unitCoalition == 2 ? 1 : 2;
|
||||
|
||||
/* Default gun values */
|
||||
double barrelHeight = 1.0; /* m */
|
||||
double muzzleVelocity = 860; /* m/s */
|
||||
double aimTime = 10; /* s */
|
||||
unsigned int shotsToFire = 10;
|
||||
double shotsBaseInterval = 15; /* s */
|
||||
double shotsBaseScatter = 2; /* degs */
|
||||
double engagementRange = 10000; /* m */
|
||||
double targetingRange = 0; /* m */
|
||||
double aimMethodRange = 0; /* m */
|
||||
double acquisitionRange = 0; /* m */
|
||||
|
||||
/* Load gun values from database */
|
||||
if (database.has_object_field(to_wstring(name))) {
|
||||
json::value databaseEntry = database[to_wstring(name)];
|
||||
if (databaseEntry.has_number_field(L"barrelHeight"))
|
||||
barrelHeight = databaseEntry[L"barrelHeight"].as_number().to_double();
|
||||
if (databaseEntry.has_number_field(L"muzzleVelocity"))
|
||||
muzzleVelocity = databaseEntry[L"muzzleVelocity"].as_number().to_double();
|
||||
if (databaseEntry.has_number_field(L"aimTime"))
|
||||
aimTime = databaseEntry[L"aimTime"].as_number().to_double();
|
||||
if (databaseEntry.has_number_field(L"shotsToFire"))
|
||||
shotsToFire = databaseEntry[L"shotsToFire"].as_number().to_uint32();
|
||||
if (databaseEntry.has_number_field(L"engagementRange"))
|
||||
engagementRange = databaseEntry[L"engagementRange"].as_number().to_double();
|
||||
if (databaseEntry.has_number_field(L"shotsBaseInterval"))
|
||||
shotsBaseInterval = databaseEntry[L"shotsBaseInterval"].as_number().to_double();
|
||||
if (databaseEntry.has_number_field(L"shotsBaseScatter"))
|
||||
shotsBaseScatter = databaseEntry[L"shotsBaseScatter"].as_number().to_double();
|
||||
if (databaseEntry.has_number_field(L"targetingRange"))
|
||||
targetingRange = databaseEntry[L"targetingRange"].as_number().to_double();
|
||||
if (databaseEntry.has_number_field(L"aimMethodRange"))
|
||||
aimMethodRange = databaseEntry[L"aimMethodRange"].as_number().to_double();
|
||||
if (databaseEntry.has_number_field(L"acquisitionRange"))
|
||||
acquisitionRange = databaseEntry[L"acquisitionRange"].as_number().to_double();
|
||||
}
|
||||
|
||||
/* Get all the units in range and select one at random */
|
||||
double range = max(max(engagementRange, aimMethodRange), acquisitionRange);
|
||||
map<Unit*, double> targets = unitsManager->getUnitsInRange(this, targetCoalition, { "Aircraft", "Helicopter" }, range);
|
||||
|
||||
Unit* target = nullptr;
|
||||
unsigned int index = static_cast<unsigned int>((RANDOM_ZERO_TO_ONE * (targets.size() - 1)));
|
||||
for (auto const& p : targets) {
|
||||
if (index-- == 0) {
|
||||
target = p.first;
|
||||
distance = p.second;
|
||||
}
|
||||
}
|
||||
|
||||
/* Only do if we have a valid target close enough for AAA */
|
||||
if (target != nullptr) {
|
||||
/* Approximate the flight time */
|
||||
if (muzzleVelocity != 0)
|
||||
aimTime += distance / muzzleVelocity;
|
||||
|
||||
/* If the target is in targeting range and we are in highest precision mode, target it */
|
||||
if (distance < targetingRange && shotsScatter == ShotsScatter::LOW) {
|
||||
/* Send the command */
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'AttackUnit', unitID = " << target->getID() << " }";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
|
||||
internalCounter = static_cast<unsigned int>((aimTime + (ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL);
|
||||
}
|
||||
/* Else, do miss on purpose */
|
||||
else {
|
||||
/* Compute where the target will be in aimTime seconds, plus the effect of scatter. */
|
||||
double scatterDistance = distance * tan(shotsBaseScatter * (ShotsScatter::LOW - shotsScatter) / 57.29577) * (RANDOM_ZERO_TO_ONE - 0.1);
|
||||
double aimDistance = target->getHorizontalVelocity() * aimTime + scatterDistance;
|
||||
double aimLat = 0;
|
||||
double aimLng = 0;
|
||||
Geodesic::WGS84().Direct(target->getPosition().lat, target->getPosition().lng, target->getTrack() * 57.29577, aimDistance, aimLat, aimLng); /* TODO make util to convert degrees and radians function */
|
||||
double aimAlt = target->getPosition().alt + target->getVerticalVelocity() * aimTime + distance * tan(shotsBaseScatter * (ShotsScatter::LOW - shotsScatter) / 57.29577) * RANDOM_ZERO_TO_ONE; // Force to always miss high never low
|
||||
|
||||
/* Send the command */
|
||||
if (distance < engagementRange) {
|
||||
/* If the unit is closer than the engagement range, use the fire at point method */
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'FireAtPoint', lat = " << aimLat << ", lng = " << aimLng << ", alt = " << aimAlt << ", radius = 0.001, expendQty = " << shotsToFire << " }";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
setTargetPosition(Coords(aimLat, aimLng, target->getPosition().alt));
|
||||
internalCounter = static_cast<unsigned int>((aimTime + (ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL);
|
||||
}
|
||||
else if (distance < aimMethodRange) {
|
||||
/* If the unit is closer than the aim method range, use the aim method range */
|
||||
aimAtPoint(Coords(aimLat, aimLng, aimAlt));
|
||||
setTargetPosition(Coords(aimLat, aimLng, target->getPosition().alt));
|
||||
internalCounter = static_cast<unsigned int>((aimTime + (ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL);
|
||||
}
|
||||
else {
|
||||
/* Else just wake the unit up with an impossible command */
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'FireAtPoint', lat = " << 0 << ", lng = " << 0 << ", alt = " << 0 << ", radius = 0.001, expendQty = " << 0 << " }";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
setTargetPosition(Coords(NULL));
|
||||
|
||||
/* Don't wait too long before checking again */
|
||||
internalCounter = static_cast<unsigned int>(5 / FRAMERATE_TIME_INTERVAL);
|
||||
}
|
||||
}
|
||||
missOnPurposeTarget = target;
|
||||
}
|
||||
else {
|
||||
if (getHasTask())
|
||||
resetTask();
|
||||
}
|
||||
}
|
||||
|
||||
/* If no valid target was detected */
|
||||
if (internalCounter == 0) {
|
||||
double alertnessTimeConstant = 10; /* s */
|
||||
if (database.has_object_field(to_wstring(name))) {
|
||||
json::value databaseEntry = database[to_wstring(name)];
|
||||
if (databaseEntry.has_number_field(L"alertnessTimeConstant"))
|
||||
alertnessTimeConstant = databaseEntry[L"alertnessTimeConstant"].as_number().to_double();
|
||||
}
|
||||
internalCounter = static_cast<unsigned int>((5 + RANDOM_ZERO_TO_ONE * alertnessTimeConstant * 0 /* TODO: remove to enable alertness again */) / FRAMERATE_TIME_INTERVAL);
|
||||
missOnPurposeTarget = nullptr;
|
||||
setTargetPosition(Coords(NULL));
|
||||
}
|
||||
internalCounter--;
|
||||
}
|
||||
else {
|
||||
setState(State::IDLE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GroundUnit::aimAtPoint(Coords aimTarget) {
|
||||
double dist;
|
||||
double bearing1;
|
||||
double bearing2;
|
||||
Geodesic::WGS84().Inverse(position.lat, position.lng, aimTarget.lat, aimTarget.lng, dist, bearing1, bearing2);
|
||||
|
||||
/* Aim point distance */
|
||||
double r = 15; /* m */
|
||||
|
||||
/* Default gun values */
|
||||
double barrelHeight = 1.0; /* m */
|
||||
double muzzleVelocity = 860; /* m/s */
|
||||
double shotsBaseScatter = 5; /* degs */
|
||||
if (database.has_object_field(to_wstring(name))) {
|
||||
json::value databaseEntry = database[to_wstring(name)];
|
||||
if (databaseEntry.has_number_field(L"barrelHeight") && databaseEntry.has_number_field(L"muzzleVelocity")) {
|
||||
barrelHeight = databaseEntry[L"barrelHeight"].as_number().to_double();
|
||||
muzzleVelocity = databaseEntry[L"muzzleVelocity"].as_number().to_double();
|
||||
}
|
||||
if (databaseEntry.has_number_field(L"shotsBaseScatter"))
|
||||
shotsBaseScatter = databaseEntry[L"shotsBaseScatter"].as_number().to_double();
|
||||
}
|
||||
|
||||
/* Compute the elevation angle of the gun*/
|
||||
double deltaHeight = (aimTarget.alt - (position.alt + barrelHeight));
|
||||
double alpha = 9.81 / 2 * dist * dist / (muzzleVelocity * muzzleVelocity);
|
||||
double inner = dist * dist - 4 * alpha * (alpha + deltaHeight);
|
||||
|
||||
/* Check we can reach the target*/
|
||||
if (inner > 0) {
|
||||
/* Compute elevation and bearing */
|
||||
double barrelElevation = r * (dist - sqrt(inner)) / (2 * alpha);
|
||||
|
||||
double lat = 0;
|
||||
double lng = 0;
|
||||
Geodesic::WGS84().Direct(position.lat, position.lng, bearing1, r, lat, lng);
|
||||
|
||||
log(unitName + "(" + name + ")" + " shooting with aim at point method. Barrel elevation: " + to_string(barrelElevation * 57.29577) + "°, bearing: " + to_string(bearing1) + "°");
|
||||
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'FireAtPoint', lat = " << lat << ", lng = " << lng << ", alt = " << position.alt + barrelElevation + barrelHeight << ", radius = 0.001}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
else {
|
||||
log("Target out of range for " + unitName + "(" + name + ")");
|
||||
}
|
||||
}
|
||||
|
||||
void GroundUnit::changeSpeed(string change)
|
||||
{
|
||||
if (change.compare("stop") == 0)
|
||||
setState(State::IDLE);
|
||||
else if (change.compare("slow") == 0)
|
||||
setDesiredSpeed(getDesiredSpeed() - knotsToMs(5));
|
||||
else if (change.compare("fast") == 0)
|
||||
setDesiredSpeed(getDesiredSpeed() + knotsToMs(5));
|
||||
|
||||
if (getDesiredSpeed() < 0)
|
||||
setDesiredSpeed(0);
|
||||
}
|
||||
|
||||
void GroundUnit::setOnOff(bool newOnOff, bool force)
|
||||
{
|
||||
if (newOnOff != onOff || force) {
|
||||
Unit::setOnOff(newOnOff, force);
|
||||
Command* command = dynamic_cast<Command*>(new SetOnOff(groupName, onOff));
|
||||
scheduler->appendCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
void GroundUnit::setFollowRoads(bool newFollowRoads, bool force)
|
||||
{
|
||||
if (newFollowRoads != followRoads || force) {
|
||||
Unit::setFollowRoads(newFollowRoads, force);
|
||||
resetActiveDestination(); /* Reset active destination to apply option*/
|
||||
}
|
||||
}
|
||||
71
backend/core/src/helicopter.cpp
Normal file
71
backend/core/src/helicopter.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#include "helicopter.h"
|
||||
#include "utils.h"
|
||||
#include "logger.h"
|
||||
#include "commands.h"
|
||||
#include "scheduler.h"
|
||||
#include "defines.h"
|
||||
#include "unitsManager.h"
|
||||
|
||||
#include <GeographicLib/Geodesic.hpp>
|
||||
using namespace GeographicLib;
|
||||
|
||||
extern Scheduler* scheduler;
|
||||
extern UnitsManager* unitsManager;
|
||||
json::value Helicopter::database = json::value();
|
||||
extern string instancePath;
|
||||
|
||||
void Helicopter::loadDatabase(string path) {
|
||||
std::ifstream ifstream(instancePath + path);
|
||||
std::stringstream ss;
|
||||
ss << ifstream.rdbuf();
|
||||
std::error_code errorCode;
|
||||
database = json::value::parse(ss.str(), errorCode);
|
||||
if (database.is_object())
|
||||
log("Helicopters database loaded correctly from " + instancePath + path);
|
||||
else
|
||||
log("Error reading Helicopters database file");
|
||||
}
|
||||
|
||||
/* Helicopter */
|
||||
Helicopter::Helicopter(json::value json, unsigned int ID) : AirUnit(json, ID)
|
||||
{
|
||||
log("New Helicopter created with ID: " + to_string(ID));
|
||||
|
||||
setCategory("Helicopter");
|
||||
setDesiredSpeed(knotsToMs(100));
|
||||
setDesiredAltitude(ftToM(5000));
|
||||
};
|
||||
|
||||
void Helicopter::changeSpeed(string change)
|
||||
{
|
||||
if (change.compare("stop") == 0)
|
||||
setState(State::IDLE);
|
||||
else if (change.compare("slow") == 0)
|
||||
setDesiredSpeed(getDesiredSpeed() - knotsToMs(10));
|
||||
else if (change.compare("fast") == 0)
|
||||
setDesiredSpeed(getDesiredSpeed() + knotsToMs(10));
|
||||
|
||||
if (getDesiredSpeed() < knotsToMs(0))
|
||||
setDesiredSpeed(knotsToMs(0));
|
||||
}
|
||||
|
||||
void Helicopter::changeAltitude(string change)
|
||||
{
|
||||
if (change.compare("descend") == 0)
|
||||
{
|
||||
if (getDesiredAltitude() > 100)
|
||||
setDesiredAltitude(getDesiredAltitude() - ftToM(100));
|
||||
else if (getDesiredAltitude() > 0)
|
||||
setDesiredAltitude(getDesiredAltitude() - ftToM(10));
|
||||
}
|
||||
else if (change.compare("climb") == 0)
|
||||
{
|
||||
if (getDesiredAltitude() > 100)
|
||||
setDesiredAltitude(getDesiredAltitude() + ftToM(100));
|
||||
else if (getDesiredAltitude() >= 0)
|
||||
setDesiredAltitude(getDesiredAltitude() + ftToM(10));
|
||||
}
|
||||
|
||||
if (getDesiredAltitude() < 0)
|
||||
setDesiredAltitude(0);
|
||||
}
|
||||
242
backend/core/src/navyunit.cpp
Normal file
242
backend/core/src/navyunit.cpp
Normal file
@@ -0,0 +1,242 @@
|
||||
#include "navyunit.h"
|
||||
#include "utils.h"
|
||||
#include "logger.h"
|
||||
#include "commands.h"
|
||||
#include "scheduler.h"
|
||||
#include "defines.h"
|
||||
#include "unitsManager.h"
|
||||
|
||||
#include <GeographicLib/Geodesic.hpp>
|
||||
using namespace GeographicLib;
|
||||
|
||||
extern Scheduler* scheduler;
|
||||
extern UnitsManager* unitsManager;
|
||||
json::value NavyUnit::database = json::value();
|
||||
extern string instancePath;
|
||||
|
||||
void NavyUnit::loadDatabase(string path) {
|
||||
std::ifstream ifstream(instancePath + path);
|
||||
std::stringstream ss;
|
||||
ss << ifstream.rdbuf();
|
||||
std::error_code errorCode;
|
||||
database = json::value::parse(ss.str(), errorCode);
|
||||
if (database.is_object())
|
||||
log("NavyUnits database loaded correctly from " + instancePath + path);
|
||||
else
|
||||
log("Error reading NavyUnits database file");
|
||||
}
|
||||
|
||||
/* Navy Unit */
|
||||
NavyUnit::NavyUnit(json::value json, unsigned int ID) : Unit(json, ID)
|
||||
{
|
||||
log("New Navy Unit created with ID: " + to_string(ID));
|
||||
|
||||
setCategory("NavyUnit");
|
||||
setDesiredSpeed(10);
|
||||
};
|
||||
|
||||
void NavyUnit::setDefaults(bool force)
|
||||
{
|
||||
if (!getAlive() || !getControlled() || getHuman() || !getIsLeader()) return;
|
||||
|
||||
/* Set the default IDLE state */
|
||||
setState(State::IDLE);
|
||||
|
||||
/* Set the default options */
|
||||
setROE(ROE::WEAPON_FREE, force);
|
||||
setOnOff(onOff, force);
|
||||
setFollowRoads(followRoads, force);
|
||||
}
|
||||
|
||||
void NavyUnit::setState(unsigned char newState)
|
||||
{
|
||||
Coords currentTargetPosition = getTargetPosition();
|
||||
|
||||
/************ Perform any action required when LEAVING a state ************/
|
||||
if (newState != state) {
|
||||
switch (state) {
|
||||
case State::IDLE: {
|
||||
break;
|
||||
}
|
||||
case State::REACH_DESTINATION: {
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
setTargetID(NULL);
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA:
|
||||
case State::SIMULATE_FIRE_FIGHT:
|
||||
case State::SCENIC_AAA:
|
||||
case State::MISS_ON_PURPOSE: {
|
||||
setTargetPosition(Coords(NULL));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/************ Perform any action required when ENTERING a state ************/
|
||||
switch (newState) {
|
||||
case State::IDLE: {
|
||||
setEnableTaskCheckFailed(false);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::REACH_DESTINATION: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setTargetPosition(currentTargetPosition);
|
||||
setEnableTaskCheckFailed(true);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::SIMULATE_FIRE_FIGHT: {
|
||||
setTargetPosition(currentTargetPosition);
|
||||
setEnableTaskCheckFailed(false);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::SCENIC_AAA: {
|
||||
setEnableTaskCheckFailed(false);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::MISS_ON_PURPOSE: {
|
||||
setEnableTaskCheckFailed(false);
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
|
||||
log(unitName + " setting state from " + to_string(state) + " to " + to_string(newState));
|
||||
state = newState;
|
||||
|
||||
triggerUpdate(DataIndex::state);
|
||||
|
||||
AIloop();
|
||||
}
|
||||
|
||||
void NavyUnit::AIloop()
|
||||
{
|
||||
srand(static_cast<unsigned int>(time(NULL)) + ID);
|
||||
|
||||
switch (state) {
|
||||
case State::IDLE: {
|
||||
setTask("Idle");
|
||||
if (getHasTask())
|
||||
resetTask();
|
||||
break;
|
||||
}
|
||||
case State::REACH_DESTINATION: {
|
||||
string enrouteTask = "{}";
|
||||
bool looping = false;
|
||||
|
||||
if (activeDestination == NULL || !getHasTask())
|
||||
{
|
||||
if (!setActiveDestination())
|
||||
setState(State::IDLE);
|
||||
else
|
||||
goToDestination(enrouteTask);
|
||||
}
|
||||
else {
|
||||
if (isDestinationReached(NAVY_DEST_DIST_THR)) {
|
||||
if (updateActivePath(looping) && setActiveDestination())
|
||||
goToDestination(enrouteTask);
|
||||
else
|
||||
setState(State::IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case State::ATTACK: {
|
||||
Unit* target = unitsManager->getUnit(getTargetID());
|
||||
if (target != nullptr) {
|
||||
setTask("Attacking " + target->getUnitName());
|
||||
|
||||
if (!getHasTask()) {
|
||||
/* Send the command */
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
taskSS << "{id = 'AttackUnit', unitID = " << target->getID() << " }";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setState(State::IDLE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case State::FIRE_AT_AREA: {
|
||||
setTask("Firing at area");
|
||||
|
||||
if (!getHasTask()) {
|
||||
std::ostringstream taskSS;
|
||||
taskSS.precision(10);
|
||||
|
||||
taskSS << "{id = 'FireAtPoint', lat = " << targetPosition.lat << ", lng = " << targetPosition.lng << ", radius = 1000}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(groupName, taskSS.str(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case State::SIMULATE_FIRE_FIGHT: {
|
||||
setTask("Simulating fire fight");
|
||||
|
||||
// TODO
|
||||
|
||||
setState(State::IDLE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NavyUnit::changeSpeed(string change)
|
||||
{
|
||||
if (change.compare("stop") == 0)
|
||||
setState(State::IDLE);
|
||||
else if (change.compare("slow") == 0)
|
||||
setDesiredSpeed(getDesiredSpeed() - knotsToMs(5));
|
||||
else if (change.compare("fast") == 0)
|
||||
setDesiredSpeed(getDesiredSpeed() + knotsToMs(5));
|
||||
|
||||
if (getDesiredSpeed() < 0)
|
||||
setDesiredSpeed(0);
|
||||
}
|
||||
|
||||
void NavyUnit::setOnOff(bool newOnOff, bool force)
|
||||
{
|
||||
if (newOnOff != onOff || force) {
|
||||
Unit::setOnOff(newOnOff, force);
|
||||
Command* command = dynamic_cast<Command*>(new SetOnOff(groupName, onOff));
|
||||
scheduler->appendCommand(command);
|
||||
}
|
||||
}
|
||||
694
backend/core/src/scheduler.cpp
Normal file
694
backend/core/src/scheduler.cpp
Normal file
@@ -0,0 +1,694 @@
|
||||
#include "scheduler.h"
|
||||
#include "logger.h"
|
||||
#include "dcstools.h"
|
||||
#include "unitsManager.h"
|
||||
#include "utils.h"
|
||||
#include "unit.h"
|
||||
|
||||
extern UnitsManager* unitsManager;
|
||||
|
||||
Scheduler::Scheduler(lua_State* L)
|
||||
{
|
||||
LogInfo(L, "Scheduler constructor called successfully");
|
||||
}
|
||||
|
||||
Scheduler::~Scheduler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Appends a */
|
||||
void Scheduler::appendCommand(Command* newCommand)
|
||||
{
|
||||
for (auto command : commands) {
|
||||
if (command->getString().compare(newCommand->getString()) == 0 && command->getPriority() == newCommand->getPriority())
|
||||
return;
|
||||
}
|
||||
commands.push_back(newCommand);
|
||||
}
|
||||
|
||||
int Scheduler::getLoad()
|
||||
{
|
||||
int currentLoad = 0;
|
||||
for (auto command : commands) {
|
||||
currentLoad += command->getLoad();
|
||||
}
|
||||
return currentLoad;
|
||||
}
|
||||
|
||||
void Scheduler::execute(lua_State* L)
|
||||
{
|
||||
/* Decrease the active computation load. New commands can be sent only if the load has reached 0.
|
||||
This is needed to avoid server lag. */
|
||||
if (load > 0) {
|
||||
load--;
|
||||
return;
|
||||
}
|
||||
|
||||
int priority = CommandPriority::IMMEDIATE;
|
||||
while (priority >= CommandPriority::LOW) {
|
||||
for (auto command : commands)
|
||||
{
|
||||
if (command->getPriority() == priority)
|
||||
{
|
||||
string commandString = "Olympus.protectedCall(" + command->getString() + ")";
|
||||
if (dostring_in(L, "server", (commandString)))
|
||||
log("Error executing command " + commandString);
|
||||
else
|
||||
log("Command '" + commandString + "' executed correctly, current load " + to_string(getLoad()));
|
||||
|
||||
/* Adjust the load depending on the fps */
|
||||
double fpsMultiplier = 20;
|
||||
if (getFrameRate() + 3 > 0)
|
||||
fpsMultiplier = static_cast<unsigned int>(max(1, 60 / (getFrameRate() + 3))); /* Multiplier between 1 and 20 */
|
||||
|
||||
load = static_cast<unsigned int>(command->getLoad() * fpsMultiplier);
|
||||
commands.remove(command);
|
||||
executedCommandsHashes.push_back(command->getHash());
|
||||
command->executeCallback(); /* Execute the command callback (this is a lambda function that can be used to execute a function when the command is run) */
|
||||
delete command;
|
||||
return;
|
||||
}
|
||||
}
|
||||
priority--;
|
||||
};
|
||||
}
|
||||
|
||||
void Scheduler::setCommandModeOptions(json::value value) {
|
||||
if (value.has_boolean_field(L"restrictSpawns"))
|
||||
setRestrictSpawns(value[L"restrictSpawns"].as_bool());
|
||||
if (value.has_boolean_field(L"restrictToCoalition"))
|
||||
setRestrictToCoalition(value[L"restrictToCoalition"].as_bool());
|
||||
if (value.has_number_field(L"setupTime"))
|
||||
setSetupTime(value[L"setupTime"].as_number().to_int32());
|
||||
if (value.has_object_field(L"spawnPoints")) {
|
||||
if (value[L"spawnPoints"].has_number_field(L"blue"))
|
||||
setBlueSpawnPoints(value[L"spawnPoints"][L"blue"].as_number().to_int32());
|
||||
if (value[L"spawnPoints"].has_number_field(L"red"))
|
||||
setRedSpawnPoints(value[L"spawnPoints"][L"red"].as_number().to_int32());
|
||||
}
|
||||
if (value.has_array_field(L"eras")) {
|
||||
int length = static_cast<int>(value[L"eras"].as_array().size());
|
||||
vector<string> newEras;
|
||||
for (int idx = 0; idx < length; idx++)
|
||||
newEras.push_back(to_string(value[L"eras"].as_array().at(idx)));
|
||||
setEras(newEras);
|
||||
}
|
||||
}
|
||||
|
||||
json::value Scheduler::getCommandModeOptions() {
|
||||
json::value json = json::value::object();
|
||||
|
||||
json[L"restrictSpawns"] = json::value(getRestrictSpawns());
|
||||
json[L"restrictToCoalition"] = json::value(getRestrictToCoalition());
|
||||
json[L"setupTime"] = json::value(getSetupTime());
|
||||
json[L"spawnPoints"] = json::value::object();
|
||||
json[L"spawnPoints"][L"blue"] = json::value(getBlueSpawnPoints());
|
||||
json[L"spawnPoints"][L"red"] = json::value(getRedSpawnPoints());
|
||||
|
||||
int idx = 0;
|
||||
json[L"eras"] = json::value::array();
|
||||
for (string era : getEras())
|
||||
json[L"eras"][idx++] = json::value(to_wstring(era));
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
bool Scheduler::checkSpawnPoints(int spawnPoints, string coalition)
|
||||
{
|
||||
if (!getRestrictSpawns()) return true;
|
||||
|
||||
if (coalition.compare("blue") == 0) {
|
||||
if (getBlueSpawnPoints() - spawnPoints >= 0) {
|
||||
setBlueSpawnPoints(getBlueSpawnPoints() - spawnPoints);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
log("Not enough blue coalition spawn points available. Available: " + to_string(getBlueSpawnPoints()) + ", required: " + to_string(spawnPoints));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (coalition.compare("red") == 0) {
|
||||
if (getRedSpawnPoints() - spawnPoints >= 0) {
|
||||
setRedSpawnPoints(getRedSpawnPoints() - spawnPoints);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
log("Not enough red coalition spawn points available. Available: " + to_string(getRedSpawnPoints()) + ", required: " + to_string(spawnPoints));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Scheduler::handleRequest(string key, json::value value, string username, json::value& answer)
|
||||
{
|
||||
Command* command = nullptr;
|
||||
|
||||
log("Received request with ID: " + key);
|
||||
log(L"Incoming command raw value: " + value.serialize());
|
||||
|
||||
/************************/
|
||||
if (key.compare("setPath") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr)
|
||||
{
|
||||
json::value path = value[L"path"];
|
||||
list<Coords> newPath;
|
||||
for (unsigned int i = 0; i < path.as_array().size(); i++)
|
||||
{
|
||||
string WP = to_string(i);
|
||||
double lat = path[i][L"lat"].as_double();
|
||||
double lng = path[i][L"lng"].as_double();
|
||||
Coords dest; dest.lat = lat; dest.lng = lng;
|
||||
newPath.push_back(dest);
|
||||
}
|
||||
|
||||
unit->setActivePath(newPath);
|
||||
unit->setState(State::REACH_DESTINATION);
|
||||
log(username + " updated destination path for unit " + unit->getUnitName() + "(" + unit->getName() + ")", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("smoke") == 0)
|
||||
{
|
||||
string color = to_string(value[L"color"]);
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
command = dynamic_cast<Command*>(new Smoke(color, loc));
|
||||
log(username + " added a " + color + " smoke at (" + to_string(lat) + ", " + to_string(lng) + ")", true);
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("spawnAircrafts") == 0 || key.compare("spawnHelicopters") == 0)
|
||||
{
|
||||
bool immediate = value[L"immediate"].as_bool();
|
||||
string coalition = to_string(value[L"coalition"]);
|
||||
string airbaseName = to_string(value[L"airbaseName"]);
|
||||
string country = to_string(value[L"country"]);
|
||||
|
||||
|
||||
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
|
||||
if (!checkSpawnPoints(spawnPoints, coalition)) return;
|
||||
|
||||
vector<SpawnOptions> spawnOptions;
|
||||
for (auto unit : value[L"units"].as_array()) {
|
||||
string unitType = to_string(unit[L"unitType"]);
|
||||
double lat = unit[L"location"][L"lat"].as_double();
|
||||
double lng = unit[L"location"][L"lng"].as_double();
|
||||
double alt = unit[L"altitude"].as_double();
|
||||
Coords location; location.lat = lat; location.lng = lng; location.alt = alt;
|
||||
string loadout = to_string(unit[L"loadout"]);
|
||||
string liveryID = to_string(unit[L"liveryID"]);
|
||||
string skill = to_string(unit[L"skill"]);
|
||||
|
||||
spawnOptions.push_back({unitType, location, loadout, skill, liveryID});
|
||||
log(username + " spawned a " + coalition + " " + unitType , true);
|
||||
}
|
||||
|
||||
if (key.compare("spawnAircrafts") == 0)
|
||||
command = dynamic_cast<Command*>(new SpawnAircrafts(coalition, spawnOptions, airbaseName, country, immediate));
|
||||
else
|
||||
command = dynamic_cast<Command*>(new SpawnHelicopters(coalition, spawnOptions, airbaseName, country, immediate));
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("spawnGroundUnits") == 0 || key.compare("spawnNavyUnits") == 0)
|
||||
{
|
||||
bool immediate = value[L"immediate"].as_bool();
|
||||
string coalition = to_string(value[L"coalition"]);
|
||||
string country = to_string(value[L"country"]);
|
||||
|
||||
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
|
||||
if (!checkSpawnPoints(spawnPoints, coalition)) return;
|
||||
|
||||
vector<SpawnOptions> spawnOptions;
|
||||
for (auto unit : value[L"units"].as_array()) {
|
||||
string unitType = to_string(unit[L"unitType"]);
|
||||
double lat = unit[L"location"][L"lat"].as_double();
|
||||
double lng = unit[L"location"][L"lng"].as_double();
|
||||
Coords location; location.lat = lat; location.lng = lng;
|
||||
string liveryID = to_string(unit[L"liveryID"]);
|
||||
string skill = to_string(unit[L"skill"]);
|
||||
|
||||
spawnOptions.push_back({ unitType, location, "", skill, liveryID});
|
||||
log(username + " spawned a " + coalition + " " + unitType, true);
|
||||
}
|
||||
|
||||
if (key.compare("spawnGroundUnits") == 0)
|
||||
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, spawnOptions, country, immediate));
|
||||
else
|
||||
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, spawnOptions, country, immediate));
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("attackUnit") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
unsigned int targetID = value[L"targetID"].as_integer();
|
||||
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
Unit* target = unitsManager->getUnit(targetID);
|
||||
|
||||
if (unit != nullptr && target != nullptr) {
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to attack unit " + target->getUnitName() + "(" + target->getName() + ")", true);
|
||||
unit->setTargetID(targetID);
|
||||
unit->setState(State::ATTACK);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("followUnit") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
unsigned int leaderID = value[L"targetID"].as_integer();
|
||||
double offsetX = value[L"offsetX"].as_double();
|
||||
double offsetY = value[L"offsetY"].as_double();
|
||||
double offsetZ = value[L"offsetZ"].as_double();
|
||||
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
Unit* leader = unitsManager->getUnit(leaderID);
|
||||
|
||||
if (unit != nullptr && leader != nullptr) {
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to follow unit " + leader->getUnitName() + "(" + leader->getName() + ")", true);
|
||||
unit->setFormationOffset(Offset(offsetX, offsetY, offsetZ));
|
||||
unit->setLeaderID(leaderID);
|
||||
unit->setState(State::FOLLOW);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("changeSpeed") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->changeSpeed(to_string(value[L"change"]));
|
||||
log(username + " changed " + unit->getUnitName() + "(" + unit->getName() + ") speed: " + to_string(value[L"change"]), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("changeAltitude") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->changeAltitude(to_string(value[L"change"]));
|
||||
log(username + " changed " + unit->getUnitName() + "(" + unit->getName() + ") altitude: " + to_string(value[L"change"]), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setSpeed") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setDesiredSpeed(value[L"speed"].as_double());
|
||||
log(username + " set " + unit->getUnitName() + "(" + unit->getName() + ") speed: " + to_string(value[L"speed"].as_double()), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setSpeedType") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setDesiredSpeedType(to_string(value[L"speedType"]));
|
||||
log(username + " set " + unit->getUnitName() + "(" + unit->getName() + ") speed type: " + to_string(value[L"speedType"]), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setAltitude") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setDesiredAltitude(value[L"altitude"].as_double());
|
||||
log(username + " set " + unit->getUnitName() + "(" + unit->getName() + ") altitude: " + to_string(value[L"altitude"].as_double()), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setAltitudeType") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setDesiredAltitudeType(to_string(value[L"altitudeType"]));
|
||||
log(username + " set " + unit->getUnitName() + "(" + unit->getName() + ") altitude type: " + to_string(value[L"altitudeType"]), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("cloneUnits") == 0)
|
||||
{
|
||||
vector<CloneOptions> cloneOptions;
|
||||
bool deleteOriginal = value[L"deleteOriginal"].as_bool();
|
||||
|
||||
for (auto unit : value[L"units"].as_array()) {
|
||||
unsigned int ID = unit[L"ID"].as_integer();
|
||||
double lat = unit[L"location"][L"lat"].as_double();
|
||||
double lng = unit[L"location"][L"lng"].as_double();
|
||||
|
||||
Coords location; location.lat = lat; location.lng = lng;
|
||||
cloneOptions.push_back({ ID, location });
|
||||
log(username + " cloning unit with ID " + to_string(ID), true);
|
||||
}
|
||||
|
||||
command = dynamic_cast<Command*>(new Clone(cloneOptions, deleteOriginal));
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setROE") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unsigned char ROE = value[L"ROE"].as_number().to_uint32();
|
||||
unit->setROE(ROE);
|
||||
log(username + " set unit " + unit->getUnitName() + "(" + unit->getName() + ") ROE to " + to_string(ROE), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setReactionToThreat") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unsigned char reactionToThreat = value[L"reactionToThreat"].as_number().to_uint32();
|
||||
unit->setReactionToThreat(reactionToThreat);
|
||||
log(username + " set unit " + unit->getUnitName() + "(" + unit->getName() + ") reaction to threat to " + to_string(reactionToThreat), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setEmissionsCountermeasures") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unsigned char emissionsCountermeasures = value[L"emissionsCountermeasures"].as_number().to_uint32();
|
||||
unit->setEmissionsCountermeasures(emissionsCountermeasures);
|
||||
log(username + " set unit " + unit->getUnitName() + "(" + unit->getName() + ") emissions and countermeasures to " + to_string(emissionsCountermeasures), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("landAt") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
unit->landAt(loc);
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to land", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("deleteUnit") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
bool explosion = value[L"explosion"].as_bool();
|
||||
string explosionType = to_string(value[L"explosionType"]);
|
||||
bool immediate = value[L"immediate"].as_bool();
|
||||
Unit* unit = unitsManager->getUnit(ID);
|
||||
if (unit != nullptr) {
|
||||
unitsManager->deleteUnit(ID, explosion, explosionType, immediate);
|
||||
log(username + " deleted unit " + unit->getUnitName() + "(" + unit->getName() + ")", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("refuel") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setState(State::REFUEL);
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to refuel", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setAdvancedOptions") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr)
|
||||
{
|
||||
/* Advanced tasking */
|
||||
unit->setIsActiveTanker(value[L"isActiveTanker"].as_bool());
|
||||
unit->setIsActiveAWACS(value[L"isActiveAWACS"].as_bool());
|
||||
|
||||
/* TACAN Options */
|
||||
DataTypes::TACAN TACAN;
|
||||
TACAN.isOn = value[L"TACAN"][L"isOn"].as_bool();
|
||||
TACAN.channel = static_cast<unsigned char>(value[L"TACAN"][L"channel"].as_number().to_uint32());
|
||||
TACAN.XY = to_string(value[L"TACAN"][L"XY"]).at(0);
|
||||
string callsign = to_string(value[L"TACAN"][L"callsign"]);
|
||||
if (callsign.length() > 3)
|
||||
callsign = callsign.substr(0, 3);
|
||||
strcpy_s(TACAN.callsign, 4, callsign.c_str());
|
||||
unit->setTACAN(TACAN);
|
||||
|
||||
/* Radio Options */
|
||||
auto radio = value[L"radio"];
|
||||
unit->setRadio({ radio[L"frequency"].as_number().to_uint32(),
|
||||
static_cast<unsigned char>(radio[L"callsign"].as_number().to_uint32()),
|
||||
static_cast<unsigned char>(radio[L"callsignNumber"].as_number().to_uint32())
|
||||
});
|
||||
|
||||
/* General Settings */
|
||||
auto generalSettings = value[L"generalSettings"];
|
||||
unit->setGeneralSettings({ generalSettings[L"prohibitJettison"].as_bool(),
|
||||
generalSettings[L"prohibitAA"].as_bool(),
|
||||
generalSettings[L"prohibitAG"].as_bool(),
|
||||
generalSettings[L"prohibitAfterburner"].as_bool(),
|
||||
generalSettings[L"prohibitAirWpn"].as_bool(),
|
||||
});
|
||||
|
||||
unit->resetActiveDestination();
|
||||
|
||||
log(username + " updated unit " + unit->getUnitName() + "(" + unit->getName() + ") advancedOptions", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setFollowRoads") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
bool followRoads = value[L"followRoads"].as_bool();
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setFollowRoads(followRoads);
|
||||
log(username + " set unit " + unit->getUnitName() + "(" + unit->getName() + ") followRoads to: " + (followRoads ? "true" : "false"), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setOnOff") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
bool onOff = value[L"onOff"].as_bool();
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setOnOff(onOff);
|
||||
log(username + " set unit " + unit->getUnitName() + "(" + unit->getName() + ") onOff to: " + (onOff? "true": "false"), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("explosion") == 0)
|
||||
{
|
||||
unsigned int intensity = value[L"intensity"].as_integer();
|
||||
string explosionType = to_string(value[L"explosionType"]);
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
log("Adding explosion of type " + explosionType + " at (" + to_string(lat) + ", " + to_string(lng) + ")");
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
command = dynamic_cast<Command*>(new Explosion(intensity, explosionType, loc));
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("bombPoint") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setTargetPosition(loc);
|
||||
unit->setState(State::BOMB_POINT);
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to bomb a point", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("carpetBomb") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setTargetPosition(loc);
|
||||
unit->setState(State::CARPET_BOMB);
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to perform carpet bombing", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
/* TODO: this command does not appear to be working in DCS and has been disabled */
|
||||
else if (key.compare("bombBuilding") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setTargetPosition(loc);
|
||||
unit->setState(State::BOMB_BUILDING);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("fireAtArea") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setTargetPosition(loc);
|
||||
unit->setState(State::FIRE_AT_AREA);
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to fire at area", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("simulateFireFight") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
double alt = value[L"altitude"].as_double();
|
||||
Coords loc; loc.lat = lat; loc.lng = lng; loc.alt = alt;
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setTargetPosition(loc);
|
||||
unit->setState(State::SIMULATE_FIRE_FIGHT);
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to simulate a fire fight", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("scenicAAA") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setState(State::SCENIC_AAA);
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to enter scenic AAA state", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("missOnPurpose") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unit->setState(State::MISS_ON_PURPOSE);
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to enter Miss On Purpose state", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setOperateAs") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
unsigned char operateAs = value[L"operateAs"].as_number().to_uint32();
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr)
|
||||
unit->setOperateAs(operateAs);
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("landAtPoint") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
|
||||
if (unit != nullptr) {
|
||||
list<Coords> newPath;
|
||||
newPath.push_back(loc);
|
||||
unit->setActivePath(newPath);
|
||||
unit->setState(State::LAND_AT_POINT);
|
||||
|
||||
log(username + " tasked unit " + unit->getUnitName() + "(" + unit->getName() + ") to land at point", true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setShotsScatter") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unsigned char shotsScatter = value[L"shotsScatter"].as_number().to_uint32();
|
||||
unit->setShotsScatter(shotsScatter);
|
||||
log(username + " set unit " + unit->getUnitName() + "(" + unit->getName() + ") shots scatter to " + to_string(shotsScatter), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setShotsIntensity") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
if (unit != nullptr) {
|
||||
unsigned char shotsIntensity = value[L"shotsIntensity"].as_number().to_uint32();
|
||||
unit->setShotsIntensity(shotsIntensity);
|
||||
log(username + " set unit " + unit->getUnitName() + "(" + unit->getName() + ") shots intensity to " + to_string(shotsIntensity), true);
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setCommandModeOptions") == 0)
|
||||
{
|
||||
setCommandModeOptions(value);
|
||||
log(username + " updated the Command Mode Options", true);
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("reloadDatabases") == 0) {
|
||||
unitsManager->loadDatabases();
|
||||
}
|
||||
/************************/
|
||||
else
|
||||
{
|
||||
log("Unknown command: " + key);
|
||||
}
|
||||
|
||||
if (command != nullptr)
|
||||
{
|
||||
appendCommand(command);
|
||||
log("New command appended correctly to stack. Current server load: " + to_string(getLoad()));
|
||||
answer[L"commandHash"] = json::value(to_wstring(command->getHash()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
#include "logger.h"
|
||||
#include "luatools.h"
|
||||
#include "dcstools.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
extern string instancePath;
|
||||
|
||||
bool executeLuaScript(lua_State* L, string path)
|
||||
{
|
||||
replace(path.begin(), path.end(), '\\', '/');
|
||||
@@ -13,10 +16,12 @@ bool executeLuaScript(lua_State* L, string path)
|
||||
if (dostring_in(L, "server", str.c_str()) != 0)
|
||||
{
|
||||
log("Error registering " + path);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
log(path + " registered successfully");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,21 +39,9 @@ void registerLuaFunctions(lua_State* L)
|
||||
log("protectedCall registered successfully");
|
||||
}
|
||||
|
||||
char* buf = nullptr;
|
||||
size_t sz = 0;
|
||||
if (_dupenv_s(&buf, &sz, "DCSOLYMPUS_PATH") == 0 && buf != nullptr)
|
||||
{
|
||||
modLocation = buf;
|
||||
free(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
log("DCSOLYMPUS_PATH environment variable is missing");
|
||||
return;
|
||||
}
|
||||
|
||||
executeLuaScript(L, modLocation + "\\Scripts\\mist.lua");
|
||||
executeLuaScript(L, modLocation + "\\Scripts\\OlympusCommand.lua");
|
||||
executeLuaScript(L, modLocation + "\\Scripts\\unitPayloads.lua");
|
||||
executeLuaScript(L, modLocation + "\\Scripts\\templates.lua");
|
||||
executeLuaScript(L, instancePath + MIST_SCRIPT);
|
||||
executeLuaScript(L, instancePath + OLYMPUS_COMMAND_SCRIPT);
|
||||
executeLuaScript(L, instancePath + UNIT_PAYLOADS_SCRIPT);
|
||||
executeLuaScript(L, instancePath + TEMPLATES_SCRIPT);
|
||||
executeLuaScript(L, instancePath + MODS_SCRIPT);
|
||||
}
|
||||
345
backend/core/src/server.cpp
Normal file
345
backend/core/src/server.cpp
Normal file
@@ -0,0 +1,345 @@
|
||||
#include "server.h"
|
||||
#include "logger.h"
|
||||
#include "defines.h"
|
||||
#include "unitsManager.h"
|
||||
#include "weaponsManager.h"
|
||||
#include "scheduler.h"
|
||||
#include "luatools.h"
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include "base64.hpp"
|
||||
|
||||
#include <chrono>
|
||||
using namespace std::chrono;
|
||||
using namespace base64;
|
||||
|
||||
extern UnitsManager* unitsManager;
|
||||
extern WeaponsManager* weaponsManager;
|
||||
extern Scheduler* scheduler;
|
||||
extern json::value missionData;
|
||||
extern mutex mutexLock;
|
||||
extern string sessionHash;
|
||||
extern string instancePath;
|
||||
|
||||
void handle_eptr(std::exception_ptr eptr)
|
||||
{
|
||||
try {
|
||||
if (eptr) {
|
||||
std::rethrow_exception(eptr);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
log(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
Server::Server(lua_State* L):
|
||||
serverThread(nullptr),
|
||||
runListener(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Server::start(lua_State* L)
|
||||
{
|
||||
log("Starting RESTServer");
|
||||
serverThread = new thread(&Server::task, this);
|
||||
}
|
||||
|
||||
void Server::stop(lua_State* L)
|
||||
{
|
||||
log("Stopping RESTServer");
|
||||
runListener = false;
|
||||
if (serverThread != nullptr)
|
||||
serverThread->join();
|
||||
}
|
||||
|
||||
void Server::handle_options(http_request request)
|
||||
{
|
||||
http_response response(status_codes::OK);
|
||||
response.headers().add(U("Allow"), U("GET, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Origin"), U("*"));
|
||||
response.headers().add(U("Access-Control-Allow-Methods"), U("GET, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Headers"), U("Content-Type, Authorization"));
|
||||
|
||||
request.reply(response);
|
||||
}
|
||||
|
||||
void Server::handle_get(http_request request)
|
||||
{
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
milliseconds ms = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
http_response response(status_codes::OK);
|
||||
|
||||
string password = extractPassword(request);
|
||||
if (password.compare(gameMasterPassword) == 0 || password.compare(blueCommanderPassword) == 0 || password.compare(redCommanderPassword) == 0)
|
||||
{
|
||||
std::exception_ptr eptr;
|
||||
try {
|
||||
auto answer = json::value::object();
|
||||
auto path = uri::split_path(uri::decode(request.relative_uri().path()));
|
||||
|
||||
/* If present, extract the request reference time. This is used for updates, and it specifies the last time that request has been performed */
|
||||
map<utility::string_t, utility::string_t> query = request.relative_uri().split_query(request.relative_uri().query());
|
||||
unsigned long long time = 0;
|
||||
if (query.find(L"time") != query.end())
|
||||
{
|
||||
try {
|
||||
time = stoull((*(query.find(L"time"))).second);
|
||||
}
|
||||
catch (...) {
|
||||
time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (path.size() > 0)
|
||||
{
|
||||
string URI = to_string(path[0]);
|
||||
/* Units data */
|
||||
if (URI.compare(UNITS_URI) == 0)
|
||||
{
|
||||
unsigned long long updateTime = ms.count();
|
||||
stringstream ss;
|
||||
ss.write((char*)&updateTime, sizeof(updateTime));
|
||||
unitsManager->getUnitData(ss, time);
|
||||
response.set_body(concurrency::streams::bytestream::open_istream(ss.str()));
|
||||
}
|
||||
else if (URI.compare(WEAPONS_URI) == 0)
|
||||
{
|
||||
unsigned long long updateTime = ms.count();
|
||||
stringstream ss;
|
||||
ss.write((char*)&updateTime, sizeof(updateTime));
|
||||
weaponsManager->getWeaponData(ss, time);
|
||||
response.set_body(concurrency::streams::bytestream::open_istream(ss.str()));
|
||||
}
|
||||
else {
|
||||
/* Logs data */
|
||||
if (URI.compare(LOGS_URI) == 0)
|
||||
{
|
||||
auto logs = json::value::object();
|
||||
getLogsJSON(logs, time);
|
||||
answer[L"logs"] = logs;
|
||||
}
|
||||
/* Airbases data */
|
||||
else if (URI.compare(AIRBASES_URI) == 0 && missionData.has_object_field(L"airbases"))
|
||||
answer[L"airbases"] = missionData[L"airbases"];
|
||||
/* Bullseyes data */
|
||||
else if (URI.compare(BULLSEYE_URI) == 0 && missionData.has_object_field(L"bullseyes"))
|
||||
answer[L"bullseyes"] = missionData[L"bullseyes"];
|
||||
/* Mission data */
|
||||
else if (URI.compare(MISSION_URI) == 0 && missionData.has_object_field(L"mission")) {
|
||||
answer[L"mission"] = missionData[L"mission"];
|
||||
answer[L"mission"][L"commandModeOptions"] = scheduler->getCommandModeOptions();
|
||||
|
||||
/* The active mode is determined by the inserted password*/
|
||||
if (password.compare(gameMasterPassword) == 0)
|
||||
answer[L"mission"][L"commandModeOptions"][L"commandMode"] = json::value(L"Game master");
|
||||
else if (password.compare(blueCommanderPassword) == 0)
|
||||
answer[L"mission"][L"commandModeOptions"][L"commandMode"] = json::value(L"Blue commander");
|
||||
else if (password.compare(redCommanderPassword) == 0)
|
||||
answer[L"mission"][L"commandModeOptions"][L"commandMode"] = json::value(L"Red commander");
|
||||
else
|
||||
answer[L"mission"][L"commandModeOptions"][L"commandMode"] = json::value(L"Observer");
|
||||
}
|
||||
else if (URI.compare(COMMANDS_URI) == 0 && query.find(L"commandHash") != query.end()) {
|
||||
answer[L"commandExecuted"] = json::value(scheduler->isCommandExecuted(to_string(query[L"commandHash"])));
|
||||
}
|
||||
|
||||
/* Common data */
|
||||
answer[L"time"] = json::value::string(to_wstring(ms.count()));
|
||||
answer[L"sessionHash"] = json::value::string(to_wstring(sessionHash));
|
||||
answer[L"load"] = scheduler->getLoad();
|
||||
answer[L"frameRate"] = scheduler->getFrameRate();
|
||||
response.set_body(answer);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
eptr = std::current_exception(); // capture
|
||||
}
|
||||
handle_eptr(eptr);
|
||||
}
|
||||
else {
|
||||
response = status_codes::Unauthorized;
|
||||
}
|
||||
|
||||
response.headers().add(U("Allow"), U("GET, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Origin"), U("*"));
|
||||
response.headers().add(U("Access-Control-Allow-Methods"), U("GET, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Headers"), U("Content-Type, Authorization"));
|
||||
|
||||
request.reply(response);
|
||||
}
|
||||
|
||||
void Server::handle_request(http_request request, function<void(json::value const&, json::value&)> action)
|
||||
{
|
||||
http_response response(status_codes::OK);
|
||||
|
||||
//TODO: limit what a user can do depending on the password
|
||||
string password = extractPassword(request);
|
||||
if (password.compare(gameMasterPassword) == 0 || password.compare(blueCommanderPassword) == 0 || password.compare(redCommanderPassword) == 0)
|
||||
{
|
||||
auto answer = json::value::object();
|
||||
request.extract_json().then([&answer, &action](pplx::task<json::value> task)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto const& jvalue = task.get();
|
||||
if (!jvalue.is_null())
|
||||
action(jvalue, answer);
|
||||
}
|
||||
catch (http_exception const& e)
|
||||
{
|
||||
log(e.what());
|
||||
}
|
||||
}).wait();
|
||||
response.set_body(answer);
|
||||
}
|
||||
else {
|
||||
response = status_codes::Unauthorized;
|
||||
}
|
||||
|
||||
response.headers().add(U("Allow"), U("GET, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Origin"), U("*"));
|
||||
response.headers().add(U("Access-Control-Allow-Methods"), U("GET, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Headers"), U("Content-Type, Authorization"));
|
||||
|
||||
request.reply(response);
|
||||
}
|
||||
|
||||
void Server::handle_put(http_request request)
|
||||
{
|
||||
string username = extractUsername(request);
|
||||
handle_request(
|
||||
request,
|
||||
[username](json::value const& jvalue, json::value& answer)
|
||||
{
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
for (auto const& e : jvalue.as_object())
|
||||
{
|
||||
auto key = e.first;
|
||||
auto value = e.second;
|
||||
|
||||
std::exception_ptr eptr;
|
||||
try {
|
||||
scheduler->handleRequest(to_string(key), value, username, answer);
|
||||
}
|
||||
catch (...) {
|
||||
eptr = std::current_exception(); // capture
|
||||
}
|
||||
handle_eptr(eptr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
string Server::extractUsername(http_request& request) {
|
||||
if (request.headers().has(L"Authorization")) {
|
||||
string authorization = to_string(request.headers().find(L"Authorization")->second);
|
||||
string s = "Basic ";
|
||||
string::size_type i = authorization.find(s);
|
||||
|
||||
if (i != std::string::npos)
|
||||
authorization.erase(i, s.length());
|
||||
else
|
||||
return "";
|
||||
|
||||
string decoded = from_base64(authorization);
|
||||
i = decoded.find(":");
|
||||
if (i != string::npos && i <= decoded.length())
|
||||
decoded.erase(i, decoded.length() - i);
|
||||
else
|
||||
return "";
|
||||
|
||||
return decoded;
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
string Server::extractPassword(http_request& request) {
|
||||
if (request.headers().has(L"Authorization")) {
|
||||
string authorization = to_string(request.headers().find(L"Authorization")->second);
|
||||
string s = "Basic ";
|
||||
string::size_type i = authorization.find(s);
|
||||
|
||||
if (i != std::string::npos)
|
||||
authorization.erase(i, s.length());
|
||||
else
|
||||
return "";
|
||||
|
||||
string decoded = from_base64(authorization);
|
||||
i = decoded.find(":");
|
||||
if (i != string::npos && i+1 < decoded.length())
|
||||
decoded.erase(0, i+1);
|
||||
else
|
||||
return "";
|
||||
|
||||
return decoded;
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
void Server::task()
|
||||
{
|
||||
string address = REST_ADDRESS;
|
||||
string jsonLocation = instancePath + OLYMPUS_JSON_PATH;
|
||||
|
||||
log("Reading configuration from " + jsonLocation);
|
||||
|
||||
std::ifstream ifstream(jsonLocation);
|
||||
std::stringstream ss;
|
||||
ss << ifstream.rdbuf();
|
||||
std::error_code errorCode;
|
||||
json::value config = json::value::parse(ss.str(), errorCode);
|
||||
if (config.is_object() && config.has_object_field(L"backend") &&
|
||||
config[L"backend"].has_string_field(L"address") && config[L"backend"].has_number_field(L"port"))
|
||||
{
|
||||
address = "http://" + to_string(config[L"backend"][L"address"]) + ":" + to_string(config[L"backend"][L"port"].as_number().to_int32());
|
||||
log("Starting backend on " + address);
|
||||
}
|
||||
else
|
||||
log("Error reading configuration file. Starting backend on " + address);
|
||||
|
||||
if (config.is_object() && config.has_object_field(L"authentication"))
|
||||
{
|
||||
if (config[L"authentication"].has_string_field(L"gameMasterPassword")) gameMasterPassword = to_string(config[L"authentication"][L"gameMasterPassword"]);
|
||||
if (config[L"authentication"].has_string_field(L"blueCommanderPassword")) blueCommanderPassword = to_string(config[L"authentication"][L"blueCommanderPassword"]);
|
||||
if (config[L"authentication"].has_string_field(L"redCommanderPassword")) redCommanderPassword = to_string(config[L"authentication"][L"redCommanderPassword"]);
|
||||
}
|
||||
else
|
||||
log("Error reading configuration file. No password set.");
|
||||
|
||||
http_listener listener(to_wstring(address + "/" + REST_URI));
|
||||
|
||||
std::function<void(http_request)> handle_options = std::bind(&Server::handle_options, this, std::placeholders::_1);
|
||||
std::function<void(http_request)> handle_get = std::bind(&Server::handle_get, this, std::placeholders::_1);
|
||||
std::function<void(http_request)> handle_put = std::bind(&Server::handle_put, this, std::placeholders::_1);
|
||||
|
||||
listener.support(methods::OPTIONS, handle_options);
|
||||
listener.support(methods::GET, handle_get);
|
||||
listener.support(methods::PUT, handle_put);
|
||||
|
||||
try
|
||||
{
|
||||
listener.open()
|
||||
.then([&listener]() {log("RESTServer starting to listen"); })
|
||||
.wait();
|
||||
|
||||
while (runListener) { Sleep(1000); };
|
||||
|
||||
listener.close()
|
||||
.then([&listener]() {log("RESTServer stopping connections"); })
|
||||
.wait();
|
||||
|
||||
log("RESTServer stopped listening");
|
||||
}
|
||||
catch (exception const& e)
|
||||
{
|
||||
log(e.what());
|
||||
}
|
||||
}
|
||||
813
backend/core/src/unit.cpp
Normal file
813
backend/core/src/unit.cpp
Normal file
@@ -0,0 +1,813 @@
|
||||
#include "unit.h"
|
||||
#include "utils.h"
|
||||
#include "logger.h"
|
||||
#include "commands.h"
|
||||
#include "scheduler.h"
|
||||
#include "defines.h"
|
||||
#include "unitsmanager.h"
|
||||
|
||||
#include <chrono>
|
||||
using namespace std::chrono;
|
||||
|
||||
#include <GeographicLib/Geodesic.hpp>
|
||||
using namespace GeographicLib;
|
||||
|
||||
extern Scheduler* scheduler;
|
||||
extern UnitsManager* unitsManager;
|
||||
|
||||
Unit::Unit(json::value json, unsigned int ID) :
|
||||
ID(ID)
|
||||
{
|
||||
log("Creating unit with ID: " + to_string(ID));
|
||||
}
|
||||
|
||||
Unit::~Unit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Unit::initialize(json::value json)
|
||||
{
|
||||
update(json, 0);
|
||||
setDefaults();
|
||||
}
|
||||
|
||||
|
||||
void Unit::update(json::value json, double dt)
|
||||
{
|
||||
if (json.has_string_field(L"name"))
|
||||
setName(to_string(json[L"name"]));
|
||||
|
||||
if (json.has_string_field(L"unitName"))
|
||||
setUnitName(to_string(json[L"unitName"]));
|
||||
|
||||
if (json.has_string_field(L"groupName"))
|
||||
setGroupName(to_string(json[L"groupName"]));
|
||||
|
||||
if (json.has_string_field(L"callsign"))
|
||||
setCallsign(to_string(json[L"callsign"]));
|
||||
|
||||
if (json.has_number_field(L"coalitionID"))
|
||||
setCoalition(json[L"coalitionID"].as_number().to_int32());
|
||||
//if (json.has_number_field(L"Country"))
|
||||
// setCountry(json[L"Country"].as_number().to_int32());
|
||||
|
||||
/* All units which contain the name "Olympus" are automatically under AI control */
|
||||
if (getUnitName().find("Olympus") != string::npos)
|
||||
setControlled(true);
|
||||
|
||||
if (json.has_object_field(L"position"))
|
||||
{
|
||||
setPosition({
|
||||
json[L"position"][L"lat"].as_number().to_double(),
|
||||
json[L"position"][L"lng"].as_number().to_double(),
|
||||
json[L"position"][L"alt"].as_number().to_double()
|
||||
});
|
||||
}
|
||||
|
||||
if (json.has_number_field(L"heading"))
|
||||
setHeading(json[L"heading"].as_number().to_double());
|
||||
|
||||
if (json.has_number_field(L"track"))
|
||||
setTrack(json[L"track"].as_number().to_double());
|
||||
|
||||
if (json.has_number_field(L"speed"))
|
||||
setSpeed(json[L"speed"].as_number().to_double());
|
||||
|
||||
if (json.has_number_field(L"horizontalVelocity"))
|
||||
setHorizontalVelocity(json[L"horizontalVelocity"].as_number().to_double());
|
||||
|
||||
if (json.has_number_field(L"verticalVelocity"))
|
||||
setVerticalVelocity(json[L"verticalVelocity"].as_number().to_double());
|
||||
|
||||
if (json.has_boolean_field(L"isAlive"))
|
||||
setAlive(json[L"isAlive"].as_bool());
|
||||
|
||||
if (json.has_boolean_field(L"isHuman"))
|
||||
setHuman(json[L"isHuman"].as_bool());
|
||||
|
||||
if (json.has_number_field(L"fuel")) {
|
||||
setFuel(short(json[L"fuel"].as_number().to_double() * 100));
|
||||
}
|
||||
|
||||
if (json.has_object_field(L"ammo")) {
|
||||
vector<DataTypes::Ammo> ammo;
|
||||
for (auto const& el : json[L"ammo"].as_object()) {
|
||||
DataTypes::Ammo ammoItem;
|
||||
auto ammoJson = el.second;
|
||||
|
||||
if (ammoJson.has_number_field(L"count"))
|
||||
ammoItem.quantity = ammoJson[L"count"].as_number().to_uint32();
|
||||
|
||||
if (ammoJson.has_object_field(L"desc")) {
|
||||
if (ammoJson[L"desc"].has_string_field(L"displayName")) {
|
||||
string name = to_string(ammoJson[L"desc"][L"displayName"].as_string());
|
||||
name = name.substr(0, min(name.size(), sizeof(ammoItem.name) - 1));
|
||||
strcpy_s(ammoItem.name, sizeof(ammoItem.name), name.c_str());
|
||||
}
|
||||
|
||||
if (ammoJson[L"desc"].has_number_field(L"guidance"))
|
||||
ammoItem.guidance = ammoJson[L"desc"][L"guidance"].as_number().to_uint32();
|
||||
|
||||
if (ammoJson[L"desc"].has_number_field(L"category"))
|
||||
ammoItem.category = ammoJson[L"desc"][L"category"].as_number().to_uint32();
|
||||
|
||||
if (ammoJson[L"desc"].has_number_field(L"missileCategory"))
|
||||
ammoItem.missileCategory = ammoJson[L"desc"][L"missileCategory"].as_number().to_uint32();
|
||||
}
|
||||
ammo.push_back(ammoItem);
|
||||
}
|
||||
setAmmo(ammo);
|
||||
}
|
||||
|
||||
if (json.has_object_field(L"contacts")) {
|
||||
vector<DataTypes::Contact> contacts;
|
||||
for (auto const& el : json[L"contacts"].as_object()) {
|
||||
DataTypes::Contact contactItem;
|
||||
auto contactJson = el.second;
|
||||
contactItem.ID = contactJson[L"object"][L"id_"].as_number().to_uint32();
|
||||
|
||||
string detectionMethod = to_string(contactJson[L"detectionMethod"]);
|
||||
if (detectionMethod.compare("VISUAL") == 0) contactItem.detectionMethod = 1;
|
||||
else if (detectionMethod.compare("OPTIC") == 0) contactItem.detectionMethod = 2;
|
||||
else if (detectionMethod.compare("RADAR") == 0) contactItem.detectionMethod = 4;
|
||||
else if (detectionMethod.compare("IRST") == 0) contactItem.detectionMethod = 8;
|
||||
else if (detectionMethod.compare("RWR") == 0) contactItem.detectionMethod = 16;
|
||||
else if (detectionMethod.compare("DLINK") == 0) contactItem.detectionMethod = 32;
|
||||
contacts.push_back(contactItem);
|
||||
}
|
||||
setContacts(contacts);
|
||||
}
|
||||
|
||||
if (json.has_boolean_field(L"hasTask"))
|
||||
setHasTask(json[L"hasTask"].as_bool());
|
||||
|
||||
if (json.has_number_field(L"health"))
|
||||
setHealth(static_cast<unsigned char>(json[L"health"].as_number().to_uint32()));
|
||||
|
||||
runAILoop();
|
||||
}
|
||||
|
||||
void Unit::setDefaults(bool force)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Unit::runAILoop() {
|
||||
/* Set isLeader */
|
||||
Unit* leader = nullptr;
|
||||
setIsLeader(unitsManager->isUnitGroupLeader(this, leader));
|
||||
|
||||
/* If the unit is alive, controlled, is the leader of the group and it is not a human, run the AI Loop that performs the requested commands and instructions (moving, attacking, etc) */
|
||||
if (getAlive() && getControlled() && !getHuman() && getIsLeader()) {
|
||||
if (getEnableTaskCheckFailed() && checkTaskFailed()) {
|
||||
log(unitName + " has no task, switching to IDLE state");
|
||||
setState(State::IDLE);
|
||||
}
|
||||
AIloop();
|
||||
}
|
||||
|
||||
refreshLeaderData(lastLoopTime);
|
||||
|
||||
milliseconds ms = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
lastLoopTime = ms.count();
|
||||
}
|
||||
|
||||
void Unit::refreshLeaderData(unsigned long long time) {
|
||||
/* When units are in a group, most data comes from the group leader. If new data is available, align it from the leader */
|
||||
if (!getIsLeader()) {
|
||||
Unit* leader = unitsManager->getGroupLeader(this);
|
||||
if (leader != nullptr) {
|
||||
for (unsigned char datumIndex = DataIndex::startOfData + 1; datumIndex < DataIndex::lastIndex; datumIndex++)
|
||||
{
|
||||
if (leader->checkFreshness(datumIndex, time)) {
|
||||
switch (datumIndex) {
|
||||
case DataIndex::controlled: updateValue(controlled, leader->controlled, datumIndex); break;
|
||||
case DataIndex::state: updateValue(state, leader->state, datumIndex); break;
|
||||
case DataIndex::task: updateValue(task, leader->task, datumIndex); break;
|
||||
case DataIndex::hasTask: updateValue(hasTask, leader->hasTask, datumIndex); break;
|
||||
case DataIndex::isActiveTanker: updateValue(isActiveTanker, leader->isActiveTanker, datumIndex); break;
|
||||
case DataIndex::isActiveAWACS: updateValue(isActiveAWACS, leader->isActiveAWACS, datumIndex); break;
|
||||
case DataIndex::onOff: updateValue(onOff, leader->onOff, datumIndex); break;
|
||||
case DataIndex::followRoads: updateValue(followRoads, leader->followRoads, datumIndex); break;
|
||||
case DataIndex::desiredSpeed: updateValue(desiredSpeed, leader->desiredSpeed, datumIndex); break;
|
||||
case DataIndex::desiredSpeedType: updateValue(desiredSpeedType, leader->desiredSpeedType, datumIndex); break;
|
||||
case DataIndex::desiredAltitude: updateValue(desiredAltitude, leader->desiredAltitude, datumIndex); break;
|
||||
case DataIndex::desiredAltitudeType: updateValue(desiredAltitudeType, leader->desiredAltitudeType, datumIndex); break;
|
||||
case DataIndex::leaderID: updateValue(leaderID, leader->leaderID, datumIndex); break;
|
||||
case DataIndex::formationOffset: updateValue(formationOffset, leader->formationOffset, datumIndex); break;
|
||||
case DataIndex::targetID: updateValue(targetID, leader->targetID, datumIndex); break;
|
||||
case DataIndex::targetPosition: updateValue(targetPosition, leader->targetPosition, datumIndex); break;
|
||||
case DataIndex::ROE: updateValue(ROE, leader->ROE, datumIndex); break;
|
||||
case DataIndex::reactionToThreat: updateValue(reactionToThreat, leader->reactionToThreat, datumIndex); break;
|
||||
case DataIndex::emissionsCountermeasures: updateValue(emissionsCountermeasures, leader->emissionsCountermeasures, datumIndex); break;
|
||||
case DataIndex::TACAN: updateValue(TACAN, leader->TACAN, datumIndex); break;
|
||||
case DataIndex::radio: updateValue(radio, leader->radio, datumIndex); break;
|
||||
case DataIndex::generalSettings: updateValue(generalSettings, leader->generalSettings, datumIndex); break;
|
||||
case DataIndex::activePath: updateValue(activePath, leader->activePath, datumIndex); break;
|
||||
case DataIndex::operateAs: updateValue(operateAs, leader->operateAs, datumIndex); break;
|
||||
case DataIndex::shotsScatter: updateValue(shotsScatter, leader->shotsScatter, datumIndex); break;
|
||||
case DataIndex::shotsIntensity: updateValue(shotsIntensity, leader->shotsIntensity, datumIndex); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::checkFreshness(unsigned char datumIndex, unsigned long long time) {
|
||||
auto it = updateTimeMap.find(datumIndex);
|
||||
if (it == updateTimeMap.end())
|
||||
return false;
|
||||
else
|
||||
return it->second > time;
|
||||
}
|
||||
|
||||
bool Unit::hasFreshData(unsigned long long time) {
|
||||
for (auto it : updateTimeMap)
|
||||
if (it.second > time)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Unit::getData(stringstream& ss, unsigned long long time)
|
||||
{
|
||||
/* When an update is requested, make sure data is refreshed */
|
||||
if (time == 0)
|
||||
refreshLeaderData(0);
|
||||
|
||||
const unsigned char endOfData = DataIndex::endOfData;
|
||||
ss.write((const char*)&ID, sizeof(ID));
|
||||
if (!alive && time == 0) {
|
||||
unsigned char datumIndex = DataIndex::category;
|
||||
appendString(ss, datumIndex, category);
|
||||
datumIndex = DataIndex::alive;
|
||||
appendNumeric(ss, datumIndex, alive);
|
||||
}
|
||||
else {
|
||||
for (unsigned char datumIndex = DataIndex::startOfData + 1; datumIndex < DataIndex::lastIndex; datumIndex++)
|
||||
{
|
||||
if (checkFreshness(datumIndex, time)) {
|
||||
switch (datumIndex) {
|
||||
case DataIndex::category: appendString(ss, datumIndex, category); break;
|
||||
case DataIndex::alive: appendNumeric(ss, datumIndex, alive); break;
|
||||
case DataIndex::human: appendNumeric(ss, datumIndex, human); break;
|
||||
case DataIndex::controlled: appendNumeric(ss, datumIndex, controlled); break;
|
||||
case DataIndex::coalition: appendNumeric(ss, datumIndex, coalition); break;
|
||||
case DataIndex::country: appendNumeric(ss, datumIndex, country); break;
|
||||
case DataIndex::name: appendString(ss, datumIndex, name); break;
|
||||
case DataIndex::unitName: appendString(ss, datumIndex, unitName); break;
|
||||
case DataIndex::callsign: appendString(ss, datumIndex, callsign); break;
|
||||
case DataIndex::groupName: appendString(ss, datumIndex, groupName); break;
|
||||
case DataIndex::state: appendNumeric(ss, datumIndex, state); break;
|
||||
case DataIndex::task: appendString(ss, datumIndex, task); break;
|
||||
case DataIndex::hasTask: appendNumeric(ss, datumIndex, hasTask); break;
|
||||
case DataIndex::position: appendNumeric(ss, datumIndex, position); break;
|
||||
case DataIndex::speed: appendNumeric(ss, datumIndex, speed); break;
|
||||
case DataIndex::horizontalVelocity: appendNumeric(ss, datumIndex, horizontalVelocity); break;
|
||||
case DataIndex::verticalVelocity: appendNumeric(ss, datumIndex, verticalVelocity); break;
|
||||
case DataIndex::heading: appendNumeric(ss, datumIndex, heading); break;
|
||||
case DataIndex::track: appendNumeric(ss, datumIndex, track); break;
|
||||
case DataIndex::isActiveTanker: appendNumeric(ss, datumIndex, isActiveTanker); break;
|
||||
case DataIndex::isActiveAWACS: appendNumeric(ss, datumIndex, isActiveAWACS); break;
|
||||
case DataIndex::onOff: appendNumeric(ss, datumIndex, onOff); break;
|
||||
case DataIndex::followRoads: appendNumeric(ss, datumIndex, followRoads); break;
|
||||
case DataIndex::fuel: appendNumeric(ss, datumIndex, fuel); break;
|
||||
case DataIndex::desiredSpeed: appendNumeric(ss, datumIndex, desiredSpeed); break;
|
||||
case DataIndex::desiredSpeedType: appendNumeric(ss, datumIndex, desiredSpeedType); break;
|
||||
case DataIndex::desiredAltitude: appendNumeric(ss, datumIndex, desiredAltitude); break;
|
||||
case DataIndex::desiredAltitudeType: appendNumeric(ss, datumIndex, desiredAltitudeType); break;
|
||||
case DataIndex::leaderID: appendNumeric(ss, datumIndex, leaderID); break;
|
||||
case DataIndex::formationOffset: appendNumeric(ss, datumIndex, formationOffset); break;
|
||||
case DataIndex::targetID: appendNumeric(ss, datumIndex, targetID); break;
|
||||
case DataIndex::targetPosition: appendNumeric(ss, datumIndex, targetPosition); break;
|
||||
case DataIndex::ROE: appendNumeric(ss, datumIndex, ROE); break;
|
||||
case DataIndex::reactionToThreat: appendNumeric(ss, datumIndex, reactionToThreat); break;
|
||||
case DataIndex::emissionsCountermeasures: appendNumeric(ss, datumIndex, emissionsCountermeasures); break;
|
||||
case DataIndex::TACAN: appendNumeric(ss, datumIndex, TACAN); break;
|
||||
case DataIndex::radio: appendNumeric(ss, datumIndex, radio); break;
|
||||
case DataIndex::generalSettings: appendNumeric(ss, datumIndex, generalSettings); break;
|
||||
case DataIndex::ammo: appendVector(ss, datumIndex, ammo); break;
|
||||
case DataIndex::contacts: appendVector(ss, datumIndex, contacts); break;
|
||||
case DataIndex::activePath: appendList(ss, datumIndex, activePath); break;
|
||||
case DataIndex::isLeader: appendNumeric(ss, datumIndex, isLeader); break;
|
||||
case DataIndex::operateAs: appendNumeric(ss, datumIndex, operateAs); break;
|
||||
case DataIndex::shotsScatter: appendNumeric(ss, datumIndex, shotsScatter); break;
|
||||
case DataIndex::shotsIntensity: appendNumeric(ss, datumIndex, shotsIntensity); break;
|
||||
case DataIndex::health: appendNumeric(ss, datumIndex, health); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ss.write((const char*)&endOfData, sizeof(endOfData));
|
||||
}
|
||||
|
||||
void Unit::setAmmo(vector<DataTypes::Ammo> newValue)
|
||||
{
|
||||
if (ammo.size() == newValue.size()) {
|
||||
bool equal = true;
|
||||
for (int i = 0; i < ammo.size(); i++) {
|
||||
if (ammo.at(i) != newValue.at(i))
|
||||
{
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (equal)
|
||||
return;
|
||||
}
|
||||
ammo = newValue;
|
||||
triggerUpdate(DataIndex::ammo);
|
||||
}
|
||||
|
||||
void Unit::setContacts(vector<DataTypes::Contact> newValue)
|
||||
{
|
||||
if (contacts.size() == newValue.size()) {
|
||||
bool equal = true;
|
||||
for (int i = 0; i < contacts.size(); i++) {
|
||||
if (contacts.at(i) != newValue.at(i))
|
||||
{
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (equal)
|
||||
return;
|
||||
}
|
||||
contacts = newValue;
|
||||
triggerUpdate(DataIndex::contacts);
|
||||
}
|
||||
|
||||
void Unit::setActivePath(list<Coords> newPath)
|
||||
{
|
||||
activePath = newPath;
|
||||
resetActiveDestination();
|
||||
}
|
||||
|
||||
void Unit::clearActivePath()
|
||||
{
|
||||
list<Coords> newPath;
|
||||
setActivePath(newPath);
|
||||
}
|
||||
|
||||
void Unit::pushActivePathFront(Coords newActivePathFront)
|
||||
{
|
||||
list<Coords> path = activePath;
|
||||
path.push_front(newActivePathFront);
|
||||
setActivePath(path);
|
||||
}
|
||||
|
||||
void Unit::pushActivePathBack(Coords newActivePathBack)
|
||||
{
|
||||
list<Coords> path = activePath;
|
||||
path.push_back(newActivePathBack);
|
||||
setActivePath(path);
|
||||
}
|
||||
|
||||
void Unit::popActivePathFront()
|
||||
{
|
||||
list<Coords> path = activePath;
|
||||
path.pop_front();
|
||||
setActivePath(path);
|
||||
}
|
||||
|
||||
string Unit::getTargetName()
|
||||
{
|
||||
if (isTargetAlive())
|
||||
{
|
||||
Unit* target = unitsManager->getUnit(targetID);
|
||||
if (target != nullptr)
|
||||
return target->getUnitName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
bool Unit::isTargetAlive()
|
||||
{
|
||||
if (targetID == NULL)
|
||||
return false;
|
||||
|
||||
Unit* target = unitsManager->getUnit(targetID);
|
||||
if (target != nullptr)
|
||||
return target->alive;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
string Unit::getLeaderName()
|
||||
{
|
||||
if (isLeaderAlive())
|
||||
{
|
||||
Unit* leader = unitsManager->getUnit(leaderID);
|
||||
if (leader != nullptr)
|
||||
return leader->getUnitName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
bool Unit::isLeaderAlive()
|
||||
{
|
||||
if (leaderID == NULL)
|
||||
return false;
|
||||
|
||||
Unit* leader = unitsManager->getUnit(leaderID);
|
||||
if (leader != nullptr)
|
||||
return leader->alive;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void Unit::resetActiveDestination()
|
||||
{
|
||||
activeDestination = Coords(NULL);
|
||||
}
|
||||
|
||||
void Unit::resetTask()
|
||||
{
|
||||
Command* command = dynamic_cast<Command*>(new ResetTask(groupName, [this]() { this->setHasTaskAssigned(false); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
}
|
||||
|
||||
void Unit::setFormationOffset(Offset newFormationOffset)
|
||||
{
|
||||
formationOffset = newFormationOffset;
|
||||
|
||||
/* Apply the change */
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
AIloop();
|
||||
|
||||
triggerUpdate(DataIndex::formationOffset);
|
||||
}
|
||||
|
||||
void Unit::setROE(unsigned char newROE, bool force)
|
||||
{
|
||||
if (ROE != newROE || force) {
|
||||
ROE = newROE;
|
||||
Command* command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::ROE, static_cast<unsigned int>(ROE)));
|
||||
scheduler->appendCommand(command);
|
||||
|
||||
triggerUpdate(DataIndex::ROE);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setReactionToThreat(unsigned char newReactionToThreat, bool force)
|
||||
{
|
||||
if (reactionToThreat != newReactionToThreat || force) {
|
||||
reactionToThreat = newReactionToThreat;
|
||||
|
||||
Command* command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::REACTION_ON_THREAT, static_cast<unsigned int>(reactionToThreat)));
|
||||
scheduler->appendCommand(command);
|
||||
|
||||
triggerUpdate(DataIndex::reactionToThreat);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setEmissionsCountermeasures(unsigned char newEmissionsCountermeasures, bool force)
|
||||
{
|
||||
if (emissionsCountermeasures != newEmissionsCountermeasures || force) {
|
||||
emissionsCountermeasures = newEmissionsCountermeasures;
|
||||
|
||||
unsigned int radarEnum;
|
||||
unsigned int flareEnum;
|
||||
unsigned int ECMEnum;
|
||||
if (emissionsCountermeasures == EmissionCountermeasure::SILENT)
|
||||
{
|
||||
radarEnum = RadarUse::NEVER;
|
||||
flareEnum = FlareUse::NEVER;
|
||||
ECMEnum = ECMUse::NEVER_USE;
|
||||
}
|
||||
else if (emissionsCountermeasures == EmissionCountermeasure::ATTACK)
|
||||
{
|
||||
radarEnum = RadarUse::FOR_ATTACK_ONLY;
|
||||
flareEnum = FlareUse::AGAINST_FIRED_MISSILE;
|
||||
ECMEnum = ECMUse::USE_IF_ONLY_LOCK_BY_RADAR;
|
||||
}
|
||||
else if (emissionsCountermeasures == EmissionCountermeasure::DEFEND)
|
||||
{
|
||||
radarEnum = RadarUse::FOR_SEARCH_IF_REQUIRED;
|
||||
flareEnum = FlareUse::WHEN_FLYING_IN_SAM_WEZ;
|
||||
ECMEnum = ECMUse::USE_IF_DETECTED_LOCK_BY_RADAR;
|
||||
}
|
||||
else if (emissionsCountermeasures == EmissionCountermeasure::FREE)
|
||||
{
|
||||
radarEnum = RadarUse::FOR_CONTINUOUS_SEARCH;
|
||||
flareEnum = FlareUse::WHEN_FLYING_NEAR_ENEMIES;
|
||||
ECMEnum = ECMUse::ALWAYS_USE;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
Command* command;
|
||||
|
||||
command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::RADAR_USING, radarEnum));
|
||||
scheduler->appendCommand(command);
|
||||
|
||||
command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::FLARE_USING, flareEnum));
|
||||
scheduler->appendCommand(command);
|
||||
|
||||
command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::ECM_USING, ECMEnum));
|
||||
scheduler->appendCommand(command);
|
||||
|
||||
triggerUpdate(DataIndex::emissionsCountermeasures);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::landAt(Coords loc)
|
||||
{
|
||||
clearActivePath();
|
||||
pushActivePathBack(loc);
|
||||
setState(State::LAND);
|
||||
}
|
||||
|
||||
void Unit::setIsActiveTanker(bool newIsActiveTanker)
|
||||
{
|
||||
if (isActiveTanker != newIsActiveTanker) {
|
||||
isActiveTanker = newIsActiveTanker;
|
||||
|
||||
/* Apply the change */
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
AIloop();
|
||||
|
||||
triggerUpdate(DataIndex::isActiveTanker);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setIsActiveAWACS(bool newIsActiveAWACS)
|
||||
{
|
||||
if (isActiveAWACS != newIsActiveAWACS) {
|
||||
isActiveAWACS = newIsActiveAWACS;
|
||||
|
||||
/* Apply the change */
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
AIloop();
|
||||
|
||||
triggerUpdate(DataIndex::isActiveAWACS);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setTACAN(DataTypes::TACAN newTACAN, bool force)
|
||||
{
|
||||
if (TACAN != newTACAN || force)
|
||||
{
|
||||
TACAN = newTACAN;
|
||||
if (TACAN.isOn) {
|
||||
std::ostringstream commandSS;
|
||||
|
||||
if (TACAN.channel < 0)
|
||||
TACAN.channel = 0;
|
||||
if (TACAN.channel > 126)
|
||||
TACAN.channel = 126;
|
||||
|
||||
commandSS << "{"
|
||||
<< "id = 'ActivateBeacon',"
|
||||
<< "params = {"
|
||||
<< "type = " << ((TACAN.XY == 'X' == 0) ? 4 : 5) << ","
|
||||
<< "system = 3,"
|
||||
<< "name = \"Olympus_TACAN\","
|
||||
<< "callsign = \"" << TACAN.callsign << "\", "
|
||||
<< "frequency = " << TACANChannelToFrequency(TACAN.channel, TACAN.XY) << ","
|
||||
<< "}"
|
||||
<< "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetCommand(groupName, commandSS.str()));
|
||||
scheduler->appendCommand(command);
|
||||
}
|
||||
else {
|
||||
std::ostringstream commandSS;
|
||||
commandSS << "{"
|
||||
<< "id = 'DeactivateBeacon',"
|
||||
<< "params = {"
|
||||
<< "}"
|
||||
<< "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetCommand(groupName, commandSS.str()));
|
||||
scheduler->appendCommand(command);
|
||||
}
|
||||
|
||||
triggerUpdate(DataIndex::TACAN);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setRadio(DataTypes::Radio newRadio, bool force)
|
||||
{
|
||||
if (radio != newRadio || force)
|
||||
{
|
||||
radio = newRadio;
|
||||
|
||||
std::ostringstream commandSS;
|
||||
Command* command;
|
||||
|
||||
if (radio.frequency < 0)
|
||||
radio.frequency = 0;
|
||||
|
||||
if (radio.frequency > 999000000)
|
||||
radio.frequency = 999000000;
|
||||
|
||||
commandSS << "{"
|
||||
<< "id = 'SetFrequency',"
|
||||
<< "params = {"
|
||||
<< "modulation = 0," // TODO Allow selection
|
||||
<< "frequency = " << radio.frequency << ","
|
||||
<< "}"
|
||||
<< "}";
|
||||
command = dynamic_cast<Command*>(new SetCommand(groupName, commandSS.str()));
|
||||
scheduler->appendCommand(command);
|
||||
|
||||
// Clear the stringstream
|
||||
commandSS.str(string(""));
|
||||
|
||||
commandSS << "{"
|
||||
<< "id = 'SetCallsign',"
|
||||
<< "params = {"
|
||||
<< "callname = " << to_string(radio.callsign) << ","
|
||||
<< "number = " << to_string(radio.callsignNumber) << ","
|
||||
<< "}"
|
||||
<< "}";
|
||||
command = dynamic_cast<Command*>(new SetCommand(groupName, commandSS.str()));
|
||||
scheduler->appendCommand(command);
|
||||
|
||||
triggerUpdate(DataIndex::radio);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setGeneralSettings(DataTypes::GeneralSettings newGeneralSettings, bool force)
|
||||
{
|
||||
if (generalSettings != newGeneralSettings)
|
||||
{
|
||||
generalSettings = newGeneralSettings;
|
||||
|
||||
Command* command;
|
||||
command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::PROHIBIT_AA, generalSettings.prohibitAA));
|
||||
scheduler->appendCommand(command);
|
||||
command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::PROHIBIT_AG, generalSettings.prohibitAG));
|
||||
scheduler->appendCommand(command);
|
||||
command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::PROHIBIT_JETT, generalSettings.prohibitJettison));
|
||||
scheduler->appendCommand(command);
|
||||
command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::PROHIBIT_AB, generalSettings.prohibitAfterburner));
|
||||
scheduler->appendCommand(command);
|
||||
command = dynamic_cast<Command*>(new SetOption(groupName, SetCommandType::ENGAGE_AIR_WEAPONS, !generalSettings.prohibitAirWpn));
|
||||
scheduler->appendCommand(command);
|
||||
|
||||
triggerUpdate(DataIndex::generalSettings);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setDesiredSpeed(double newDesiredSpeed)
|
||||
{
|
||||
if (desiredSpeed != newDesiredSpeed) {
|
||||
desiredSpeed = newDesiredSpeed;
|
||||
|
||||
/* Apply the change */
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
AIloop();
|
||||
|
||||
triggerUpdate(DataIndex::desiredSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setDesiredAltitude(double newDesiredAltitude)
|
||||
{
|
||||
if (desiredAltitude != newDesiredAltitude) {
|
||||
desiredAltitude = newDesiredAltitude;
|
||||
|
||||
/* Apply the change */
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
AIloop();
|
||||
|
||||
triggerUpdate(DataIndex::desiredAltitude);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setDesiredSpeedType(string newDesiredSpeedType)
|
||||
{
|
||||
if (desiredSpeedType != (newDesiredSpeedType.compare("GS") == 0)) {
|
||||
desiredSpeedType = newDesiredSpeedType.compare("GS") == 0;
|
||||
|
||||
/* Apply the change */
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
AIloop();
|
||||
|
||||
triggerUpdate(DataIndex::desiredSpeedType);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setDesiredAltitudeType(string newDesiredAltitudeType)
|
||||
{
|
||||
if (desiredAltitudeType != (newDesiredAltitudeType.compare("AGL") == 0)) {
|
||||
desiredAltitudeType = newDesiredAltitudeType.compare("AGL") == 0;
|
||||
|
||||
/* Apply the change */
|
||||
setHasTask(false);
|
||||
resetTaskFailedCounter();
|
||||
AIloop();
|
||||
|
||||
triggerUpdate(DataIndex::desiredAltitudeType);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::goToDestination(string enrouteTask)
|
||||
{
|
||||
if (activeDestination != NULL)
|
||||
{
|
||||
Command* command = dynamic_cast<Command*>(new Move(groupName, activeDestination, getDesiredSpeed(), getDesiredSpeedType() ? "GS" : "CAS", getDesiredAltitude(), getDesiredAltitudeType() ? "AGL" : "ASL", enrouteTask, getCategory(), getFollowRoads(), [this]() { this->setHasTaskAssigned(true); }));
|
||||
scheduler->appendCommand(command);
|
||||
setHasTask(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::isDestinationReached(double threshold)
|
||||
{
|
||||
if (activeDestination != NULL)
|
||||
{
|
||||
/* Check if any unit in the group has reached the point */
|
||||
for (auto const& p : unitsManager->getGroupMembers(groupName))
|
||||
{
|
||||
double dist = 0;
|
||||
Geodesic::WGS84().Inverse(p->getPosition().lat, p->getPosition().lng, activeDestination.lat, activeDestination.lng, dist);
|
||||
if (dist < threshold)
|
||||
{
|
||||
log(unitName + " destination reached");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Unit::setActiveDestination()
|
||||
{
|
||||
if (activePath.size() > 0)
|
||||
{
|
||||
activeDestination = activePath.front();
|
||||
log(unitName + " active destination set to queue front");
|
||||
|
||||
triggerUpdate(DataIndex::activePath);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeDestination = Coords(0);
|
||||
log(unitName + " active destination set to NULL");
|
||||
|
||||
triggerUpdate(DataIndex::activePath);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::updateActivePath(bool looping)
|
||||
{
|
||||
if (activePath.size() > 0)
|
||||
{
|
||||
/* Push the next destination in the queue to the front */
|
||||
if (looping)
|
||||
pushActivePathBack(activePath.front());
|
||||
popActivePathFront();
|
||||
log(unitName + " active path front popped");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::setHasTask(bool newValue) {
|
||||
updateValue(hasTask, newValue, DataIndex::hasTask);
|
||||
}
|
||||
|
||||
bool Unit::checkTaskFailed()
|
||||
{
|
||||
if (getHasTask())
|
||||
return false;
|
||||
else {
|
||||
if (taskCheckCounter > 0)
|
||||
taskCheckCounter -= hasTaskAssigned;
|
||||
return taskCheckCounter == 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::resetTaskFailedCounter() {
|
||||
taskCheckCounter = TASK_CHECK_INIT_VALUE;
|
||||
}
|
||||
|
||||
void Unit::setHasTaskAssigned(bool newHasTaskAssigned) {
|
||||
hasTaskAssigned = newHasTaskAssigned;
|
||||
if (hasTaskAssigned)
|
||||
log(unitName + " was assigned a new task");
|
||||
else
|
||||
log(unitName + " no task assigned");
|
||||
}
|
||||
|
||||
void Unit::triggerUpdate(unsigned char datumIndex) {
|
||||
updateTimeMap[datumIndex] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
241
backend/core/src/unitsmanager.cpp
Normal file
241
backend/core/src/unitsmanager.cpp
Normal file
@@ -0,0 +1,241 @@
|
||||
#include "framework.h"
|
||||
#include "unitsManager.h"
|
||||
#include "logger.h"
|
||||
#include "unit.h"
|
||||
#include "aircraft.h"
|
||||
#include "helicopter.h"
|
||||
#include "groundunit.h"
|
||||
#include "navyunit.h"
|
||||
#include "weapon.h"
|
||||
#include "commands.h"
|
||||
#include "scheduler.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include <GeographicLib/Geodesic.hpp>
|
||||
using namespace GeographicLib;
|
||||
|
||||
#include "base64.hpp"
|
||||
using namespace base64;
|
||||
|
||||
extern Scheduler* scheduler;
|
||||
|
||||
UnitsManager::UnitsManager(lua_State* L)
|
||||
{
|
||||
LogInfo(L, "Units Manager constructor called successfully");
|
||||
}
|
||||
|
||||
UnitsManager::~UnitsManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Unit* UnitsManager::getUnit(unsigned int ID)
|
||||
{
|
||||
if (units.find(ID) == units.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
return units[ID];
|
||||
}
|
||||
}
|
||||
|
||||
bool UnitsManager::isUnitInGroup(Unit* unit)
|
||||
{
|
||||
if (unit != nullptr) {
|
||||
string groupName = unit->getGroupName();
|
||||
if (groupName.length() == 0) return false;
|
||||
for (auto const& p : units)
|
||||
{
|
||||
if (p.second->getGroupName().compare(groupName) == 0 && p.second != unit && p.second->getAlive())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Returns true if unit is group leader. Else, returns false, and leader will be equal to the group leader */
|
||||
bool UnitsManager::isUnitGroupLeader(Unit* unit, Unit*& leader)
|
||||
{
|
||||
if (unit != nullptr) {
|
||||
leader = getGroupLeader(unit);
|
||||
return leader == nullptr? false: unit == leader;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
Unit* UnitsManager::getGroupLeader(Unit* unit)
|
||||
{
|
||||
if (unit != nullptr) {
|
||||
string groupName = unit->getGroupName();
|
||||
if (groupName.length() == 0) return nullptr;
|
||||
/* Find the first alive unit that has the same groupName */
|
||||
for (auto const& p : units)
|
||||
{
|
||||
if (p.second->getAlive() && p.second->getGroupName().compare(groupName) == 0)
|
||||
return p.second;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
vector<Unit*> UnitsManager::getGroupMembers(string groupName)
|
||||
{
|
||||
vector<Unit*> members;
|
||||
for (auto const& p : units)
|
||||
{
|
||||
if (p.second->getGroupName().compare(groupName) == 0)
|
||||
members.push_back(p.second);
|
||||
}
|
||||
return members;
|
||||
}
|
||||
|
||||
Unit* UnitsManager::getGroupLeader(unsigned int ID)
|
||||
{
|
||||
Unit* unit = getUnit(ID);
|
||||
return getGroupLeader(unit);
|
||||
}
|
||||
|
||||
void UnitsManager::update(json::value& json, double dt)
|
||||
{
|
||||
for (auto const& p : json.as_object())
|
||||
{
|
||||
unsigned int ID = std::stoi(p.first);
|
||||
if (units.count(ID) == 0)
|
||||
{
|
||||
json::value value = p.second;
|
||||
if (value.has_string_field(L"category")) {
|
||||
string category = to_string(value[L"category"].as_string());
|
||||
if (category.compare("Aircraft") == 0)
|
||||
units[ID] = dynamic_cast<Unit*>(new Aircraft(p.second, ID));
|
||||
else if (category.compare("Helicopter") == 0)
|
||||
units[ID] = dynamic_cast<Unit*>(new Helicopter(p.second, ID));
|
||||
else if (category.compare("GroundUnit") == 0)
|
||||
units[ID] = dynamic_cast<Unit*>(new GroundUnit(p.second, ID));
|
||||
else if (category.compare("NavyUnit") == 0)
|
||||
units[ID] = dynamic_cast<Unit*>(new NavyUnit(p.second, ID));
|
||||
|
||||
/* Initialize the unit if creation was successfull */
|
||||
if (units.count(ID) != 0) {
|
||||
units[ID]->update(p.second, dt);
|
||||
units[ID]->initialize(p.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Update the unit if present*/
|
||||
if (units.count(ID) != 0)
|
||||
units[ID]->update(p.second, dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UnitsManager::runAILoop() {
|
||||
/* Run the AI Loop on all units */
|
||||
for (auto const& unit : units)
|
||||
unit.second->runAILoop();
|
||||
}
|
||||
|
||||
void UnitsManager::getUnitData(stringstream &ss, unsigned long long time)
|
||||
{
|
||||
for (auto const& p : units)
|
||||
p.second->getData(ss, time);
|
||||
}
|
||||
|
||||
void UnitsManager::deleteUnit(unsigned int ID, bool explosion, string explosionType, bool immediate)
|
||||
{
|
||||
if (getUnit(ID) != nullptr)
|
||||
{
|
||||
Command* command = dynamic_cast<Command*>(new Delete(ID, explosion, explosionType, immediate));
|
||||
scheduler->appendCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
Unit* UnitsManager::getClosestUnit(Unit* unit, unsigned char coalition, vector<string> categories, double &distance) {
|
||||
Unit* closestUnit = nullptr;
|
||||
distance = 0;
|
||||
|
||||
for (auto const& p : units) {
|
||||
/* Check if the units category is of the correct type */
|
||||
bool requestedCategory = false;
|
||||
for (auto const& category : categories) {
|
||||
if (p.second->getCategory().compare(category) == 0) {
|
||||
requestedCategory = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the unit belongs to the desired coalition, is alive, and is of the category requested */
|
||||
if (requestedCategory && p.second->getCoalition() == coalition && p.second->getAlive()) {
|
||||
/* Compute the distance from the unit to the tested unit */
|
||||
double dist;
|
||||
double bearing1;
|
||||
double bearing2;
|
||||
Geodesic::WGS84().Inverse(unit->getPosition().lat, unit->getPosition().lng, p.second->getPosition().lat, p.second->getPosition().lng, dist, bearing1, bearing2);
|
||||
double altDelta = unit->getPosition().alt - p.second->getPosition().alt;
|
||||
|
||||
/* If the closest unit has not been assigned yet, assign it to this unit */
|
||||
if (closestUnit == nullptr)
|
||||
{
|
||||
closestUnit = p.second;
|
||||
distance = sqrt(dist * dist + altDelta * altDelta);
|
||||
|
||||
}
|
||||
else {
|
||||
/* Check if the unit is closer than the one already selected */
|
||||
if (dist < distance) {
|
||||
closestUnit = p.second;
|
||||
distance = sqrt(dist * dist + altDelta * altDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return closestUnit;
|
||||
}
|
||||
|
||||
map<Unit*, double> UnitsManager::getUnitsInRange(Unit* unit, unsigned char coalition, vector<string> categories, double range) {
|
||||
map<Unit*, double> unitsInRange;
|
||||
|
||||
for (auto const& p : units) {
|
||||
/* Check if the units category is of the correct type */
|
||||
bool requestedCategory = false;
|
||||
for (auto const& category : categories) {
|
||||
if (p.second->getCategory().compare(category) == 0) {
|
||||
requestedCategory = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the unit belongs to the desired coalition, is alive, and is of the category requested */
|
||||
if (requestedCategory && p.second->getCoalition() == coalition && p.second->getAlive()) {
|
||||
/* Compute the distance from the unit to the tested unit */
|
||||
double dist;
|
||||
double bearing1;
|
||||
double bearing2;
|
||||
Geodesic::WGS84().Inverse(unit->getPosition().lat, unit->getPosition().lng, p.second->getPosition().lat, p.second->getPosition().lng, dist, bearing1, bearing2);
|
||||
|
||||
if (dist <= range)
|
||||
unitsInRange[p.second] = dist;
|
||||
}
|
||||
}
|
||||
|
||||
return unitsInRange;
|
||||
}
|
||||
|
||||
void UnitsManager::acquireControl(unsigned int ID) {
|
||||
Unit* leader = getGroupLeader(ID);
|
||||
if (leader != nullptr) {
|
||||
if (!leader->getControlled()) {
|
||||
leader->setControlled(true);
|
||||
leader->setDefaults(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UnitsManager::loadDatabases() {
|
||||
Aircraft::loadDatabase(AIRCRAFT_DATABASE_PATH);
|
||||
Helicopter::loadDatabase(HELICOPTER_DATABASE_PATH);
|
||||
GroundUnit::loadDatabase(GROUNDUNIT_DATABASE_PATH);
|
||||
NavyUnit::loadDatabase(NAVYUNIT_DATABASE_PATH);
|
||||
}
|
||||
116
backend/core/src/weapon.cpp
Normal file
116
backend/core/src/weapon.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
#include "weapon.h"
|
||||
#include "utils.h"
|
||||
#include "logger.h"
|
||||
#include "commands.h"
|
||||
#include "scheduler.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include <chrono>
|
||||
using namespace std::chrono;
|
||||
|
||||
Weapon::Weapon(json::value json, unsigned int ID) :
|
||||
ID(ID)
|
||||
{
|
||||
log("Creating weapon with ID: " + to_string(ID));
|
||||
}
|
||||
|
||||
Weapon::~Weapon()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Weapon::initialize(json::value json)
|
||||
{
|
||||
if (json.has_string_field(L"name"))
|
||||
setName(to_string(json[L"name"]));
|
||||
|
||||
|
||||
if (json.has_number_field(L"coalitionID"))
|
||||
setCoalition(json[L"coalitionID"].as_number().to_int32());
|
||||
|
||||
update(json, 0);
|
||||
}
|
||||
|
||||
|
||||
void Weapon::update(json::value json, double dt)
|
||||
{
|
||||
if (json.has_object_field(L"position"))
|
||||
{
|
||||
setPosition({
|
||||
json[L"position"][L"lat"].as_number().to_double(),
|
||||
json[L"position"][L"lng"].as_number().to_double(),
|
||||
json[L"position"][L"alt"].as_number().to_double()
|
||||
});
|
||||
}
|
||||
|
||||
if (json.has_number_field(L"heading"))
|
||||
setHeading(json[L"heading"].as_number().to_double());
|
||||
|
||||
if (json.has_number_field(L"speed"))
|
||||
setSpeed(json[L"speed"].as_number().to_double());
|
||||
|
||||
if (json.has_boolean_field(L"isAlive"))
|
||||
setAlive(json[L"isAlive"].as_bool());
|
||||
}
|
||||
|
||||
bool Weapon::checkFreshness(unsigned char datumIndex, unsigned long long time) {
|
||||
auto it = updateTimeMap.find(datumIndex);
|
||||
if (it == updateTimeMap.end())
|
||||
return false;
|
||||
else
|
||||
return it->second > time;
|
||||
}
|
||||
|
||||
bool Weapon::hasFreshData(unsigned long long time) {
|
||||
for (auto it : updateTimeMap)
|
||||
if (it.second > time)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Weapon::getData(stringstream& ss, unsigned long long time)
|
||||
{
|
||||
const unsigned char endOfData = DataIndex::endOfData;
|
||||
ss.write((const char*)&ID, sizeof(ID));
|
||||
if (!alive && time == 0) {
|
||||
unsigned char datumIndex = DataIndex::category;
|
||||
appendString(ss, datumIndex, category);
|
||||
datumIndex = DataIndex::alive;
|
||||
appendNumeric(ss, datumIndex, alive);
|
||||
}
|
||||
else {
|
||||
for (unsigned char datumIndex = DataIndex::startOfData + 1; datumIndex < DataIndex::lastIndex; datumIndex++)
|
||||
{
|
||||
if (checkFreshness(datumIndex, time)) {
|
||||
switch (datumIndex) {
|
||||
case DataIndex::category: appendString(ss, datumIndex, category); break;
|
||||
case DataIndex::alive: appendNumeric(ss, datumIndex, alive); break;
|
||||
case DataIndex::coalition: appendNumeric(ss, datumIndex, coalition); break;
|
||||
case DataIndex::name: appendString(ss, datumIndex, name); break;
|
||||
case DataIndex::position: appendNumeric(ss, datumIndex, position); break;
|
||||
case DataIndex::speed: appendNumeric(ss, datumIndex, speed); break;
|
||||
case DataIndex::heading: appendNumeric(ss, datumIndex, heading); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ss.write((const char*)&endOfData, sizeof(endOfData));
|
||||
}
|
||||
|
||||
void Weapon::triggerUpdate(unsigned char datumIndex) {
|
||||
updateTimeMap[datumIndex] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
|
||||
/* Missile */
|
||||
Missile::Missile(json::value json, unsigned int ID) : Weapon(json, ID)
|
||||
{
|
||||
log("New Missile created with ID: " + to_string(ID));
|
||||
setCategory("Missile");
|
||||
};
|
||||
|
||||
/* Bomb */
|
||||
Bomb::Bomb(json::value json, unsigned int ID) : Weapon(json, ID)
|
||||
{
|
||||
log("New Bomb created with ID: " + to_string(ID));
|
||||
setCategory("Bomb");
|
||||
};
|
||||
65
backend/core/src/weaponsmanager.cpp
Normal file
65
backend/core/src/weaponsmanager.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "framework.h"
|
||||
#include "weaponsManager.h"
|
||||
#include "logger.h"
|
||||
#include "weapon.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
#include "base64.hpp"
|
||||
using namespace base64;
|
||||
|
||||
WeaponsManager::WeaponsManager(lua_State* L)
|
||||
{
|
||||
LogInfo(L, "Weapons Manager constructor called successfully");
|
||||
}
|
||||
|
||||
WeaponsManager::~WeaponsManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Weapon* WeaponsManager::getWeapon(unsigned int ID)
|
||||
{
|
||||
if (weapons.find(ID) == weapons.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
return weapons[ID];
|
||||
}
|
||||
}
|
||||
|
||||
void WeaponsManager::update(json::value& json, double dt)
|
||||
{
|
||||
for (auto const& p : json.as_object())
|
||||
{
|
||||
unsigned int ID = std::stoi(p.first);
|
||||
if (weapons.count(ID) == 0)
|
||||
{
|
||||
json::value value = p.second;
|
||||
if (value.has_string_field(L"category")) {
|
||||
string category = to_string(value[L"category"].as_string());
|
||||
if (category.compare("Missile") == 0)
|
||||
weapons[ID] = dynamic_cast<Weapon*>(new Missile(p.second, ID));
|
||||
else if (category.compare("Bomb") == 0)
|
||||
weapons[ID] = dynamic_cast<Weapon*>(new Bomb(p.second, ID));
|
||||
|
||||
/* Initialize the weapon if creation was successfull */
|
||||
if (weapons.count(ID) != 0) {
|
||||
weapons[ID]->update(p.second, dt);
|
||||
weapons[ID]->initialize(p.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Update the weapon if present*/
|
||||
if (weapons.count(ID) != 0)
|
||||
weapons[ID]->update(p.second, dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WeaponsManager::getWeaponData(stringstream& ss, unsigned long long time)
|
||||
{
|
||||
for (auto const& p : weapons)
|
||||
p.second->getData(ss, time);
|
||||
}
|
||||
|
||||
110
backend/dcstools/dcstools.rc
Normal file
110
backend/dcstools/dcstools.rc
Normal file
@@ -0,0 +1,110 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Italian (Italy) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
|
||||
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Italian (Italy) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United Kingdom) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,4,0
|
||||
PRODUCTVERSION 1,0,3,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "DCS Olympus"
|
||||
VALUE "FileDescription", "DCS Olympus"
|
||||
VALUE "FileVersion", "1.0.4.0"
|
||||
VALUE "InternalName", "dcstools.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023"
|
||||
VALUE "OriginalFilename", "dcstools.dll"
|
||||
VALUE "ProductName", "DCS Olympus"
|
||||
VALUE "ProductVersion", "1.0.4.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United Kingdom) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\dcstools.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\luatools\luatools.vcxproj">
|
||||
@@ -32,6 +33,9 @@
|
||||
<Project>{b85009ce-4a5c-4a5a-b85d-001b3a2651b2}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="dcstools.rc" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
@@ -73,19 +77,23 @@
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>.\..\..\bin\</OutDir>
|
||||
<OutDir>.\..\..\build\backend\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -134,6 +142,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<Version>{{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}}</Version>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -23,5 +23,13 @@
|
||||
<ClInclude Include="include\dcstools.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="dcstools.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -5,8 +5,8 @@
|
||||
void DllExport LogInfo(lua_State* L, string message);
|
||||
void DllExport LogWarning(lua_State* L, string message);
|
||||
void DllExport LogError(lua_State* L, string message);
|
||||
void DllExport Log(lua_State* L, string message, int level);
|
||||
void DllExport Log(lua_State* L, string message, unsigned int level);
|
||||
int DllExport dostring_in(lua_State* L, string target, string command);
|
||||
map<int, json::value> DllExport getAllUnits(lua_State* L);
|
||||
int DllExport TACANChannelToFrequency(int channel, wstring XY);
|
||||
void DllExport getAllUnits(lua_State* L, map<unsigned int, json::value>& unitJSONs);
|
||||
unsigned int DllExport TACANChannelToFrequency(unsigned int channel, char XY);
|
||||
|
||||
14
backend/dcstools/resource.h
Normal file
14
backend/dcstools/resource.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by dcstools.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -42,7 +42,7 @@ void LogError(lua_State* L, string message)
|
||||
Log(L, message, errorLevel);
|
||||
}
|
||||
|
||||
void Log(lua_State* L, string message, int level)
|
||||
void Log(lua_State* L, string message, unsigned int level)
|
||||
{
|
||||
STACK_INIT;
|
||||
|
||||
@@ -56,10 +56,9 @@ void Log(lua_State* L, string message, int level)
|
||||
STACK_CLEAN;
|
||||
}
|
||||
|
||||
map<int, json::value> getAllUnits(lua_State* L)
|
||||
void getAllUnits(lua_State* L, map<unsigned int, json::value>& unitJSONs)
|
||||
{
|
||||
int res = 0;
|
||||
map<int, json::value> units;
|
||||
unsigned int res = 0;
|
||||
|
||||
STACK_INIT;
|
||||
|
||||
@@ -83,15 +82,17 @@ map<int, json::value> getAllUnits(lua_State* L)
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 2) != 0)
|
||||
{
|
||||
int ID = lua_tonumber(L, -2);
|
||||
units[ID] = luaTableToJSON(L, -1);
|
||||
unsigned int ID = static_cast<unsigned int>(lua_tonumber(L, -2));
|
||||
if (unitJSONs.find(ID) == unitJSONs.end())
|
||||
unitJSONs[ID] = json::value::object();
|
||||
luaTableToJSON(L, -1, unitJSONs[ID]);
|
||||
STACK_POP(1)
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
STACK_CLEAN;
|
||||
return units;
|
||||
return;
|
||||
}
|
||||
|
||||
int dostring_in(lua_State* L, string target, string command)
|
||||
@@ -103,8 +104,8 @@ int dostring_in(lua_State* L, string target, string command)
|
||||
return lua_pcall(L, 2, 0, 0);
|
||||
}
|
||||
|
||||
int TACANChannelToFrequency(int channel, wstring XY)
|
||||
unsigned int TACANChannelToFrequency(unsigned int channel, char XY)
|
||||
{
|
||||
int basef = (XY == L"X" && channel > 63) || (XY == L"Y" && channel < 64) ? 1087: 961;
|
||||
unsigned int basef = (XY == 'X' && channel > 63) || (XY == 'Y' && channel < 64) ? 1087 : 961;
|
||||
return (basef + channel) * 1000000;
|
||||
}
|
||||
2579
backend/docs
Normal file
2579
backend/docs
Normal file
File diff suppressed because it is too large
Load Diff
7
backend/logger/include/interface.h
Normal file
7
backend/logger/include/interface.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
void DllExport setLogDirectory(std::string m_dirPath);
|
||||
void DllExport log(const std::string& sMessage, bool addToJSON = false);
|
||||
void DllExport log(const std::wstring& sMessage, bool addToJSON = false);
|
||||
void DllExport getLogsJSON(json::value& json, unsigned long long time);
|
||||
@@ -5,9 +5,10 @@
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
void log(const string& sMessage);
|
||||
void log(const wstring& sMessage);
|
||||
void toJSON(json::value& json, int logsNumber = NULL);
|
||||
void log(const string& sMessage, bool addToJSON);
|
||||
void log(const wstring& sMessage, bool addToJSON);
|
||||
void toJSON(json::value& json, unsigned long long time);
|
||||
void setDirectory(string newDirPath);
|
||||
|
||||
static Logger* GetLogger();
|
||||
|
||||
@@ -19,10 +20,12 @@ private:
|
||||
static const string m_sFileName;
|
||||
static Logger* m_pThis;
|
||||
static ofstream m_Logfile;
|
||||
static std::list<std::string> m_logs;
|
||||
static std::map<unsigned long long, std::string> m_logs;
|
||||
static string m_dirPath;
|
||||
|
||||
mutex mutexLock;
|
||||
|
||||
void Clear();
|
||||
void Open();
|
||||
void Close();
|
||||
};
|
||||
110
backend/logger/logger.rc
Normal file
110
backend/logger/logger.rc
Normal file
@@ -0,0 +1,110 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Italian (Italy) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
|
||||
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Italian (Italy) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United Kingdom) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,4,0
|
||||
PRODUCTVERSION 1,0,3,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "DCS Olympus"
|
||||
VALUE "FileDescription", "DCS Olympus"
|
||||
VALUE "FileVersion", "1.0.4.0"
|
||||
VALUE "InternalName", "logger.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023"
|
||||
VALUE "OriginalFilename", "logger.dll"
|
||||
VALUE "ProductName", "DCS Olympus"
|
||||
VALUE "ProductVersion", "1.0.4.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United Kingdom) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -25,12 +25,16 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\interface.h" />
|
||||
<ClInclude Include="include\logger.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\utils\utils.vcxproj">
|
||||
<Project>{b85009ce-4a5c-4a5a-b85d-001b3a2651b2}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="logger.rc" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
@@ -72,19 +76,23 @@
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>.\..\..\bin\</OutDir>
|
||||
<OutDir>.\..\..\build\backend\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -133,6 +141,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<Version>{{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}}</Version>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -29,5 +29,13 @@
|
||||
<ClInclude Include="include\interface.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="logger.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
14
backend/logger/resource.h
Normal file
14
backend/logger/resource.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by logger.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
25
backend/logger/src/interface.cpp
Normal file
25
backend/logger/src/interface.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "framework.h"
|
||||
#include "logger.h"
|
||||
#include "interface.h"
|
||||
|
||||
#define LOGGER Logger::GetLogger()
|
||||
|
||||
void setLogDirectory(string m_dirPath)
|
||||
{
|
||||
LOGGER->setDirectory(m_dirPath);
|
||||
}
|
||||
|
||||
void log(const string& message, bool addToJSON)
|
||||
{
|
||||
LOGGER->log(message, addToJSON);
|
||||
}
|
||||
|
||||
void log(const wstring& message, bool addToJSON)
|
||||
{
|
||||
LOGGER->log(message, addToJSON);
|
||||
}
|
||||
|
||||
void getLogsJSON(json::value& json, unsigned long long time)
|
||||
{
|
||||
LOGGER->toJSON(json, time);
|
||||
}
|
||||
98
backend/logger/src/logger.cpp
Normal file
98
backend/logger/src/logger.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
#include "logger.h"
|
||||
#include "utils.h"
|
||||
#include "defines.h"
|
||||
#include <chrono>
|
||||
using namespace std::chrono;
|
||||
|
||||
const string Logger::m_sFileName = LOG_NAME;
|
||||
Logger* Logger::m_pThis = NULL;
|
||||
ofstream Logger::m_Logfile;
|
||||
std::map<unsigned long long, std::string> Logger::m_logs;
|
||||
std::string Logger::m_dirPath;
|
||||
|
||||
Logger::Logger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Logger* Logger::GetLogger()
|
||||
{
|
||||
if (m_pThis == NULL) {
|
||||
m_pThis = new Logger();
|
||||
m_pThis->Clear();
|
||||
}
|
||||
return m_pThis;
|
||||
}
|
||||
|
||||
void Logger::setDirectory(string newDirPath)
|
||||
{
|
||||
m_dirPath = newDirPath;
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Logger::Clear()
|
||||
{
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
try {
|
||||
m_Logfile.open((m_dirPath + m_sFileName).c_str(), ios::out | ios::trunc);
|
||||
}
|
||||
catch (...) {
|
||||
std::filesystem::path m_dirPath = std::filesystem::temp_directory_path();
|
||||
m_Logfile.open((m_dirPath.string() + m_sFileName).c_str(), ios::out | ios::trunc);
|
||||
}
|
||||
m_Logfile << "Creating a new log instance\n";
|
||||
m_pThis->Close();
|
||||
}
|
||||
|
||||
void Logger::Open()
|
||||
{
|
||||
try {
|
||||
m_Logfile.open((m_dirPath + m_sFileName).c_str(), ios::out | std::ios::app);
|
||||
}
|
||||
catch (...) {
|
||||
std::filesystem::path m_dirPath = std::filesystem::temp_directory_path();
|
||||
m_Logfile.open((m_dirPath.string() + m_sFileName).c_str(), ios::out | std::ios::app);
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Close()
|
||||
{
|
||||
m_Logfile.close();
|
||||
}
|
||||
|
||||
void Logger::toJSON(json::value& json, unsigned long long time)
|
||||
{
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
/* Loop on the logs in reverse since we are usually only interested in the very last added logs */
|
||||
auto itr = m_logs.end();
|
||||
while (itr != m_logs.begin())
|
||||
{
|
||||
--itr;
|
||||
if (itr->first < time) return;
|
||||
json[to_wstring(itr->first)] = json::value::string(to_wstring(itr->second));
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::log(const string& message, bool addToJSON)
|
||||
{
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
Open();
|
||||
milliseconds ms = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
m_Logfile << CurrentDateTime() << ":\t";
|
||||
m_Logfile << message << "\n";
|
||||
if (addToJSON)
|
||||
m_logs[static_cast<unsigned long long>(ms.count())] = message;
|
||||
Close();
|
||||
}
|
||||
|
||||
void Logger::log(const wstring& message, bool addToJSON)
|
||||
{
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
Open();
|
||||
milliseconds ms = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
m_Logfile << CurrentDateTime() << ":\t";
|
||||
m_Logfile << to_string(message) << "\n";
|
||||
if (addToJSON)
|
||||
m_logs[static_cast<unsigned long long>(ms.count())] = to_string(message);
|
||||
Close();
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
void DllExport stackUpdate(lua_State* L, int& stackDepth, int initialStack = 0);
|
||||
void DllExport stackPop(lua_State* L, int popDepth = 1);
|
||||
void DllExport stackClean(lua_State* L, int stackDepth);
|
||||
json::value DllExport luaTableToJSON(lua_State* L, int index, bool logKeys = false);
|
||||
void DllExport luaTableToJSON(lua_State* L, int index, json::value& json, bool logKeys = false);
|
||||
void DllExport luaLogTableKeys(lua_State* L, int index);
|
||||
|
||||
#define STACK_UPDATE stackUpdate(L, stackDepth, initialStack);
|
||||
#define STACK_INIT int stackDepth = 0; int initialStack = 0; stackUpdate(L, initialStack);
|
||||
110
backend/luatools/luatools.rc
Normal file
110
backend/luatools/luatools.rc
Normal file
@@ -0,0 +1,110 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Italian (Italy) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
|
||||
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Italian (Italy) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United Kingdom) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,4,0
|
||||
PRODUCTVERSION 1,0,3,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "DCS Olympus"
|
||||
VALUE "FileDescription", "DCS Olympus"
|
||||
VALUE "FileVersion", "1.0.4.0"
|
||||
VALUE "InternalName", "luatools.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023"
|
||||
VALUE "OriginalFilename", "luatools.dll"
|
||||
VALUE "ProductName", "DCS Olympus"
|
||||
VALUE "ProductVersion", "1.0.4.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United Kingdom) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -60,19 +60,23 @@
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>.\..\..\bin\</OutDir>
|
||||
<OutDir>.\..\..\build\backend\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -121,6 +125,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<Version>{{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}}</Version>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -160,6 +165,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\luatools.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="luatools.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
@@ -23,5 +23,13 @@
|
||||
<ClInclude Include="include\luatools.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="luatools.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
14
backend/luatools/resource.h
Normal file
14
backend/luatools/resource.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by luatools.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -18,10 +18,31 @@ void stackClean(lua_State* L, int stackDepth)
|
||||
lua_pop(L, stackDepth);
|
||||
}
|
||||
|
||||
json::value luaTableToJSON(lua_State* L, int index, bool logKeys)
|
||||
{
|
||||
auto json = json::value::object();
|
||||
|
||||
void luaLogTableKeys(lua_State* L, int index)
|
||||
{
|
||||
if (lua_istable(L, index))
|
||||
{
|
||||
STACK_INIT;
|
||||
|
||||
lua_pushvalue(L, index);
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, -2))
|
||||
{
|
||||
lua_pushvalue(L, -2);
|
||||
const char* key = lua_tostring(L, -1);
|
||||
log(key);
|
||||
lua_pop(L, 2);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
STACK_CLEAN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void luaTableToJSON(lua_State* L, int index, json::value& json, bool logKeys)
|
||||
{
|
||||
if (lua_istable(L, index))
|
||||
{
|
||||
STACK_INIT;
|
||||
@@ -38,7 +59,9 @@ json::value luaTableToJSON(lua_State* L, int index, bool logKeys)
|
||||
}
|
||||
if (lua_istable(L, -2))
|
||||
{
|
||||
json[to_wstring(key)] = luaTableToJSON(L, -2, logKeys);
|
||||
if (!json.has_object_field(to_wstring(key)))
|
||||
json[to_wstring(key)] = json::value::object();
|
||||
luaTableToJSON(L, -2, json[to_wstring(key)], logKeys);
|
||||
}
|
||||
else if (lua_isnumber(L, -2))
|
||||
{
|
||||
@@ -58,6 +81,5 @@ json::value luaTableToJSON(lua_State* L, int index, bool logKeys)
|
||||
|
||||
STACK_CLEAN;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
110
backend/olympus/olympus.rc
Normal file
110
backend/olympus/olympus.rc
Normal file
@@ -0,0 +1,110 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Italian (Italy) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
|
||||
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Italian (Italy) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United Kingdom) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,4,0
|
||||
PRODUCTVERSION 1,0,3,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "DCS Olympus"
|
||||
VALUE "FileDescription", "DCS Olympus"
|
||||
VALUE "FileVersion", "1.0.4.0"
|
||||
VALUE "InternalName", "olympus.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023"
|
||||
VALUE "OriginalFilename", "olympus.dll"
|
||||
VALUE "ProductName", "DCS Olympus"
|
||||
VALUE "ProductVersion", "1.0.4.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United Kingdom) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -20,10 +20,19 @@
|
||||
<ProjectReference Include="..\logger\logger.vcxproj">
|
||||
<Project>{873ecabe-fcfe-4217-ac15-91959c3cf1c6}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\luatools\luatools.vcxproj">
|
||||
<Project>{de139ec1-4f88-47d5-be73-f41915fe14a3}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\utils\utils.vcxproj">
|
||||
<Project>{b85009ce-4a5c-4a5a-b85d-001b3a2651b2}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="olympus.rc" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
@@ -53,9 +62,11 @@
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -64,10 +75,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>.\..\..\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg">
|
||||
<VcpkgAutoLink>true</VcpkgAutoLink>
|
||||
<OutDir>.\..\..\build\backend\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
@@ -87,6 +95,7 @@
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>lua.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\third-party\lua</AdditionalLibraryDirectories>
|
||||
<Version>{{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}}</Version>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -112,6 +121,7 @@
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>lua.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\third-party\lua</AdditionalLibraryDirectories>
|
||||
<DelayLoadDLLs>dcstools.dll;logger.dll;utils.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
@@ -13,4 +13,10 @@
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="olympus.rc" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
14
backend/olympus/resource.h
Normal file
14
backend/olympus/resource.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by olympus.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
238
backend/olympus/src/olympus.cpp
Normal file
238
backend/olympus/src/olympus.cpp
Normal file
@@ -0,0 +1,238 @@
|
||||
#include "framework.h"
|
||||
#include "dcstools.h"
|
||||
#include "logger.h"
|
||||
#include "utils.h"
|
||||
|
||||
/* Run-time linking to core dll allows for "hot swap". This is useful for development but could be removed when stable.*/
|
||||
HINSTANCE hGetProcIDDLL = NULL;
|
||||
typedef int(__stdcall* f_coreInit)(lua_State* L, const char* path);
|
||||
typedef int(__stdcall* f_coreDeinit)(lua_State* L);
|
||||
typedef int(__stdcall* f_coreFrame)(lua_State* L);
|
||||
typedef int(__stdcall* f_coreUnitsData)(lua_State* L);
|
||||
typedef int(__stdcall* f_coreWeaponsData)(lua_State* L);
|
||||
typedef int(__stdcall* f_coreMissionData)(lua_State* L);
|
||||
f_coreInit coreInit = nullptr;
|
||||
f_coreDeinit coreDeinit = nullptr;
|
||||
f_coreFrame coreFrame = nullptr;
|
||||
f_coreUnitsData coreUnitsData = nullptr;
|
||||
f_coreWeaponsData coreWeaponsData = nullptr;
|
||||
f_coreMissionData coreMissionData = nullptr;
|
||||
|
||||
string modPath;
|
||||
|
||||
//Returns the last Win32 error, in string format. Returns an empty string if there is no error.
|
||||
std::string GetLastErrorAsString()
|
||||
{
|
||||
//Get the error message ID, if any.
|
||||
DWORD errorMessageID = ::GetLastError();
|
||||
if (errorMessageID == 0) {
|
||||
return std::string(); //No error message has been recorded
|
||||
}
|
||||
|
||||
LPSTR messageBuffer = nullptr;
|
||||
|
||||
//Ask Win32 to give us the string version of that message ID.
|
||||
//The parameters we pass in, tell Win32 to create the buffer that holds the message for us (because we don't yet know how long the message string will be).
|
||||
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);
|
||||
|
||||
//Copy the error message into a std::string.
|
||||
std::string message(messageBuffer, size);
|
||||
|
||||
//Free the Win32's string's buffer.
|
||||
LocalFree(messageBuffer);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
static int onSimulationStart(lua_State* L)
|
||||
{
|
||||
LogInfo(L, "Trying to load core.dll from " + modPath);
|
||||
SetDllDirectoryA(modPath.c_str());
|
||||
|
||||
setLogDirectory(modPath);
|
||||
|
||||
log("onSimulationStart callback called successfully");
|
||||
|
||||
string dllLocation = modPath + "\\core.dll";
|
||||
|
||||
log("Loading core.dll");
|
||||
hGetProcIDDLL = LoadLibrary(to_wstring(dllLocation).c_str());
|
||||
|
||||
if (!hGetProcIDDLL) {
|
||||
LogError(L, "Error loading core DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
log("Core DLL loaded successfully");
|
||||
|
||||
coreInit = (f_coreInit)GetProcAddress(hGetProcIDDLL, "coreInit");
|
||||
if (!coreInit)
|
||||
{
|
||||
LogError(L, "Error getting coreInit ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreDeinit = (f_coreDeinit)GetProcAddress(hGetProcIDDLL, "coreDeinit");
|
||||
if (!coreDeinit)
|
||||
{
|
||||
LogError(L, "Error getting coreDeinit ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreFrame = (f_coreFrame)GetProcAddress(hGetProcIDDLL, "coreFrame");
|
||||
if (!coreFrame)
|
||||
{
|
||||
LogError(L, "Error getting coreFrame ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreUnitsData = (f_coreUnitsData)GetProcAddress(hGetProcIDDLL, "coreUnitsData");
|
||||
if (!coreUnitsData)
|
||||
{
|
||||
LogError(L, "Error getting coreUnitsData ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreWeaponsData = (f_coreWeaponsData)GetProcAddress(hGetProcIDDLL, "coreWeaponsData");
|
||||
if (!coreWeaponsData)
|
||||
{
|
||||
LogError(L, "Error getting coreWeaponsData ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreMissionData = (f_coreMissionData)GetProcAddress(hGetProcIDDLL, "coreMissionData");
|
||||
if (!coreMissionData)
|
||||
{
|
||||
LogError(L, "Error getting coreMissionData ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreInit(L, modPath.c_str());
|
||||
|
||||
LogInfo(L, "Module loaded and started successfully.");
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
LogError(L, "Error while loading module: " + GetLastErrorAsString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int onSimulationFrame(lua_State* L)
|
||||
{
|
||||
if (coreFrame)
|
||||
{
|
||||
coreFrame(L);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int onSimulationStop(lua_State* L)
|
||||
{
|
||||
log("onSimulationStop callback called successfully");
|
||||
if (hGetProcIDDLL)
|
||||
{
|
||||
log("Trying to unload core DLL");
|
||||
if (coreDeinit)
|
||||
{
|
||||
coreDeinit(L);
|
||||
}
|
||||
|
||||
if (FreeLibrary(hGetProcIDDLL))
|
||||
{
|
||||
log("Core DLL unloaded successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogError(L, "Error unloading DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreInit = nullptr;
|
||||
coreDeinit = nullptr;
|
||||
coreFrame = nullptr;
|
||||
coreUnitsData = nullptr;
|
||||
coreWeaponsData = nullptr;
|
||||
coreMissionData = nullptr;
|
||||
}
|
||||
|
||||
hGetProcIDDLL = NULL;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
LogError(L, "Error while unloading module: " + GetLastErrorAsString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setUnitsData(lua_State* L)
|
||||
{
|
||||
if (coreUnitsData)
|
||||
{
|
||||
coreUnitsData(L);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setWeaponsData(lua_State* L)
|
||||
{
|
||||
if (coreWeaponsData)
|
||||
{
|
||||
coreWeaponsData(L);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setMissionData(lua_State* L)
|
||||
{
|
||||
if (coreMissionData)
|
||||
{
|
||||
coreMissionData(L);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg Map[] = {
|
||||
{"onSimulationStart", onSimulationStart},
|
||||
{"onSimulationFrame", onSimulationFrame},
|
||||
{"onSimulationStop", onSimulationStop},
|
||||
{"setUnitsData", setUnitsData },
|
||||
{"setWeaponsData", setWeaponsData },
|
||||
{"setMissionData", setMissionData },
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
extern "C" DllExport int luaopen_olympus(lua_State * L)
|
||||
{
|
||||
lua_getglobal(L, "require");
|
||||
lua_pushstring(L, "lfs");
|
||||
lua_pcall(L, 1, 1, 0);
|
||||
lua_getfield(L, -1, "writedir");
|
||||
lua_pcall(L, 0, 1, 0);
|
||||
if (lua_isstring(L, -1)) {
|
||||
modPath = string(lua_tostring(L, -1)) + "Mods\\Services\\Olympus\\bin\\";
|
||||
SetDllDirectoryA(modPath.c_str());
|
||||
LogInfo(L, "Instance location retrieved successfully");
|
||||
}
|
||||
else {
|
||||
/* Log without using the helper dlls because we have not loaded them yet here */
|
||||
lua_getglobal(L, "log");
|
||||
lua_getfield(L, -1, "ERROR");
|
||||
int errorLevel = (int)lua_tointeger(L, -1);
|
||||
|
||||
lua_getglobal(L, "log");
|
||||
lua_getfield(L, -1, "write");
|
||||
lua_pushstring(L, "Olympus.dll");
|
||||
lua_pushnumber(L, errorLevel);
|
||||
lua_pushstring(L, "An error has occurred while trying to retrieve Olympus's instance location");
|
||||
lua_pcall(L, 3, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LogInfo(L, "Loading .dlls from " + modPath);
|
||||
|
||||
luaL_register(L, "olympus", Map);
|
||||
return 1;
|
||||
}
|
||||
28
backend/shared/include/defines.h
Normal file
28
backend/shared/include/defines.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION "{{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}}"
|
||||
#define LOG_NAME "..\\..\\..\\..\\Logs\\Olympus_log.txt"
|
||||
|
||||
#define REST_ADDRESS "http://localhost:3001"
|
||||
#define REST_URI "olympus"
|
||||
#define UNITS_URI "units"
|
||||
#define WEAPONS_URI "weapons"
|
||||
#define LOGS_URI "logs"
|
||||
#define AIRBASES_URI "airbases"
|
||||
#define BULLSEYE_URI "bullseyes"
|
||||
#define MISSION_URI "mission"
|
||||
#define COMMANDS_URI "commands"
|
||||
|
||||
#define FRAMERATE_TIME_INTERVAL 0.05
|
||||
|
||||
#define OLYMPUS_JSON_PATH "..\\..\\..\\..\\Config\\olympus.json"
|
||||
#define AIRCRAFT_DATABASE_PATH "..\\databases\\units\\aircraftdatabase.json"
|
||||
#define HELICOPTER_DATABASE_PATH "..\\databases\\units\\helicopterdatabase.json"
|
||||
#define GROUNDUNIT_DATABASE_PATH "..\\databases\\units\\groundunitdatabase.json"
|
||||
#define NAVYUNIT_DATABASE_PATH "..\\databases\\units\\navyunitdatabase.json"
|
||||
|
||||
#define MIST_SCRIPT "..\\Scripts\\mist.lua"
|
||||
#define OLYMPUS_COMMAND_SCRIPT "..\\Scripts\\OlympusCommand.lua"
|
||||
#define UNIT_PAYLOADS_SCRIPT "..\\Scripts\\unitPayloads.lua"
|
||||
#define TEMPLATES_SCRIPT "..\\Scripts\\templates.lua"
|
||||
#define MODS_SCRIPT "..\\Scripts\\mods.lua"
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <codecvt>
|
||||
#include <cpprest/http_listener.h>
|
||||
#include <cpprest/json.h>
|
||||
#include <cpprest/streams.h>
|
||||
#include <set>
|
||||
|
||||
using namespace std;
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct Coords {
|
||||
double lat = 0;
|
||||
double lng = 0;
|
||||
@@ -12,22 +13,24 @@ struct Offset {
|
||||
double y = 0;
|
||||
double z = 0;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
// Get current date/time, format is YYYY-MM-DD.HH:mm:ss
|
||||
const DllExport std::string CurrentDateTime();
|
||||
std::wstring DllExport to_wstring(const std::string& str);
|
||||
std::string DllExport to_string(json::value& value);
|
||||
std::string DllExport to_string(const std::wstring& wstr);
|
||||
std::string DllExport random_string(size_t length);
|
||||
|
||||
bool DllExport operator== (const Coords& a, const Coords& b);
|
||||
bool DllExport operator!= (const Coords& a, const Coords& b);
|
||||
bool DllExport operator== (const Coords& a, const int& b);
|
||||
bool DllExport operator!= (const Coords& a, const int& b);
|
||||
bool DllExport operator== (const Coords& a, const double& b);
|
||||
bool DllExport operator!= (const Coords& a, const double& b);
|
||||
|
||||
bool DllExport operator== (const Offset& a, const Offset& b);
|
||||
bool DllExport operator!= (const Offset& a, const Offset& b);
|
||||
bool DllExport operator== (const Offset& a, const int& b);
|
||||
bool DllExport operator!= (const Offset& a, const int& b);
|
||||
bool DllExport operator== (const Offset& a, const double& b);
|
||||
bool DllExport operator!= (const Offset& a, const double& b);
|
||||
|
||||
double DllExport knotsToMs(const double knots);
|
||||
double DllExport msToKnots(const double ms);
|
||||
14
backend/utils/resource.h
Normal file
14
backend/utils/resource.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by utils.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -14,12 +14,16 @@ const std::string CurrentDateTime()
|
||||
|
||||
std::wstring to_wstring(const std::string& str)
|
||||
{
|
||||
int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
|
||||
unsigned int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (unsigned int)str.size(), NULL, 0);
|
||||
std::wstring wstrTo(size_needed, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
|
||||
MultiByteToWideChar(CP_UTF8, 0, &str[0], (unsigned int)str.size(), &wstrTo[0], size_needed);
|
||||
return wstrTo;
|
||||
}
|
||||
|
||||
std::string to_string(json::value& value) {
|
||||
return to_string(value.as_string());
|
||||
}
|
||||
|
||||
std::string to_string(const std::wstring& wstr)
|
||||
{
|
||||
if (wstr.empty())
|
||||
@@ -27,19 +31,20 @@ std::string to_string(const std::wstring& wstr)
|
||||
return "";
|
||||
}
|
||||
|
||||
const auto size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr.at(0), (int)wstr.size(), nullptr, 0, nullptr, nullptr);
|
||||
const auto size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr.at(0), (unsigned int)wstr.size(), nullptr, 0, nullptr, nullptr);
|
||||
if (size_needed <= 0)
|
||||
{
|
||||
throw std::runtime_error("WideCharToMultiByte() failed: " + std::to_string(size_needed));
|
||||
}
|
||||
|
||||
std::string result(size_needed, 0);
|
||||
WideCharToMultiByte(CP_UTF8, 0, &wstr.at(0), (int)wstr.size(), &result.at(0), size_needed, nullptr, nullptr);
|
||||
WideCharToMultiByte(CP_UTF8, 0, &wstr.at(0), (unsigned int)wstr.size(), &result.at(0), size_needed, nullptr, nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string random_string(size_t length)
|
||||
{
|
||||
srand(static_cast<unsigned int>(time(NULL)));
|
||||
auto randchar = []() -> char
|
||||
{
|
||||
const char charset[] =
|
||||
@@ -56,13 +61,13 @@ std::string random_string(size_t length)
|
||||
|
||||
bool operator== (const Coords& a, const Coords& b) { return a.lat == b.lat && a.lng == b.lng && a.alt == b.alt; }
|
||||
bool operator!= (const Coords& a, const Coords& b) { return !(a == b); }
|
||||
bool operator== (const Coords& a, const int& b) { return a.lat == b && a.lng == b && a.alt == b; }
|
||||
bool operator!= (const Coords& a, const int& b) { return !(a == b); }
|
||||
bool operator== (const Coords& a, const double& b) { return a.lat == b && a.lng == b && a.alt == b; }
|
||||
bool operator!= (const Coords& a, const double& b) { return !(a == b); }
|
||||
|
||||
bool operator== (const Offset& a, const Offset& b) { return a.x == b.x && a.y == b.y && a.z == b.z; }
|
||||
bool operator!= (const Offset& a, const Offset& b) { return !(a == b); }
|
||||
bool operator== (const Offset& a, const int& b) { return a.x == b && a.y == b && a.z == b; }
|
||||
bool operator!= (const Offset& a, const int& b) { return !(a == b); }
|
||||
bool operator== (const Offset& a, const double& b) { return a.x == b && a.y == b && a.z == b; }
|
||||
bool operator!= (const Offset& a, const double& b) { return !(a == b); }
|
||||
|
||||
|
||||
double knotsToMs(const double knots) {
|
||||
@@ -79,4 +84,4 @@ double ftToM(const double ft) {
|
||||
|
||||
double mToFt(const double m) {
|
||||
return m / 0.3048;
|
||||
}
|
||||
}
|
||||
110
backend/utils/utils.rc
Normal file
110
backend/utils/utils.rc
Normal file
@@ -0,0 +1,110 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Italian (Italy) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
|
||||
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Italian (Italy) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United Kingdom) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,4,0
|
||||
PRODUCTVERSION 1,0,3,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "DCS Olympus"
|
||||
VALUE "FileDescription", "DCS Olympus"
|
||||
VALUE "FileVersion", "1.0.4.0"
|
||||
VALUE "InternalName", "utils.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023"
|
||||
VALUE "OriginalFilename", "utils.dll"
|
||||
VALUE "ProductName", "TODO: <Product name>"
|
||||
VALUE "ProductVersion", "1.0.4.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United Kingdom) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -20,10 +20,14 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\utils.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\utils.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="utils.rc" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
@@ -65,19 +69,23 @@
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\DCSOlympus.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>.\..\..\bin\</OutDir>
|
||||
<OutDir>.\..\..\build\backend\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
@@ -14,10 +14,16 @@
|
||||
<ClInclude Include="include\utils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\utils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="utils.rc" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
14
backend/vcpkg-configuration.json
Normal file
14
backend/vcpkg-configuration.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"default-registry": {
|
||||
"kind": "git",
|
||||
"baseline": "7f9f0e44db287e8e67c0e888141bfa200ab45121",
|
||||
"repository": "https://github.com/microsoft/vcpkg"
|
||||
},
|
||||
"registries": [
|
||||
{
|
||||
"kind": "artifact",
|
||||
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
|
||||
"name": "microsoft"
|
||||
}
|
||||
]
|
||||
}
|
||||
6
backend/vcpkg.json
Normal file
6
backend/vcpkg.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"dependencies": [
|
||||
"cpprestsdk",
|
||||
"geographiclib"
|
||||
]
|
||||
}
|
||||
2
build_package.bat
Normal file
2
build_package.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
call .\scripts\batch\build.bat
|
||||
call .\scripts\batch\package.bat
|
||||
2
client/.vscode/settings.json
vendored
2
client/.vscode/settings.json
vendored
@@ -1,2 +0,0 @@
|
||||
{
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
var express = require('express');
|
||||
var path = require('path');
|
||||
var cookieParser = require('cookie-parser');
|
||||
var logger = require('morgan');
|
||||
var fs = require('fs');
|
||||
var basicAuth = require('express-basic-auth')
|
||||
|
||||
var atcRouter = require('./routes/api/atc');
|
||||
var airbasesRouter = require('./routes/api/airbases');
|
||||
var indexRouter = require('./routes/index');
|
||||
var uikitRouter = require('./routes/uikit');
|
||||
var usersRouter = require('./routes/users');
|
||||
var resourcesRouter = require('./routes/resources');
|
||||
|
||||
var app = express();
|
||||
|
||||
app.use(logger('dev'));
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(cookieParser());
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.use('/', indexRouter);
|
||||
app.use('/api/atc', atcRouter);
|
||||
app.use('/api/airbases', airbasesRouter);
|
||||
app.use('/users', usersRouter);
|
||||
app.use('/uikit', uikitRouter);
|
||||
app.use('/resources', resourcesRouter);
|
||||
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
let rawdata = fs.readFileSync('../olympus.json');
|
||||
let config = JSON.parse(rawdata);
|
||||
if (config["server"] != undefined)
|
||||
app.get('/config', (req, res) => res.send(config["server"]));
|
||||
|
||||
module.exports = app;
|
||||
|
||||
const DemoDataGenerator = require('./demo.js');
|
||||
var demoDataGenerator = new DemoDataGenerator(10);
|
||||
app.get('/demo/units', (req, res) => demoDataGenerator.units(req, res));
|
||||
app.get('/demo/logs', (req, res) => demoDataGenerator.logs(req, res));
|
||||
app.get('/demo/bullseyes', (req, res) => demoDataGenerator.bullseyes(req, res));
|
||||
app.get('/demo/airbases', (req, res) => demoDataGenerator.airbases(req, res));
|
||||
app.get('/demo/mission', (req, res) => demoDataGenerator.mission(req, res));
|
||||
|
||||
app.use('/demo', basicAuth({
|
||||
users: { 'admin': 'socks' }
|
||||
}))
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var app = require('../app');
|
||||
var debug = require('debug')('client:server');
|
||||
var http = require('http');
|
||||
|
||||
/**
|
||||
* Get port from environment and store in Express.
|
||||
*/
|
||||
|
||||
var port = normalizePort(process.env.PORT || '3000');
|
||||
app.set('port', port);
|
||||
|
||||
/**
|
||||
* Create HTTP server.
|
||||
*/
|
||||
|
||||
var server = http.createServer(app);
|
||||
|
||||
/**
|
||||
* Listen on provided port, on all network interfaces.
|
||||
*/
|
||||
|
||||
server.listen(port);
|
||||
server.on('error', onError);
|
||||
server.on('listening', onListening);
|
||||
|
||||
/**
|
||||
* Normalize a port into a number, string, or false.
|
||||
*/
|
||||
|
||||
function normalizePort(val) {
|
||||
var port = parseInt(val, 10);
|
||||
|
||||
if (isNaN(port)) {
|
||||
// named pipe
|
||||
return val;
|
||||
}
|
||||
|
||||
if (port >= 0) {
|
||||
// port number
|
||||
return port;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "error" event.
|
||||
*/
|
||||
|
||||
function onError(error) {
|
||||
if (error.syscall !== 'listen') {
|
||||
throw error;
|
||||
}
|
||||
|
||||
var bind = typeof port === 'string'
|
||||
? 'Pipe ' + port
|
||||
: 'Port ' + port;
|
||||
|
||||
// handle specific listen errors with friendly messages
|
||||
switch (error.code) {
|
||||
case 'EACCES':
|
||||
console.error(bind + ' requires elevated privileges');
|
||||
process.exit(1);
|
||||
break;
|
||||
case 'EADDRINUSE':
|
||||
console.error(bind + ' is already in use');
|
||||
process.exit(1);
|
||||
break;
|
||||
default:
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "listening" event.
|
||||
*/
|
||||
|
||||
function onListening() {
|
||||
var addr = server.address();
|
||||
var bind = typeof addr === 'string'
|
||||
? 'pipe ' + addr
|
||||
: 'port ' + addr.port;
|
||||
debug('Listening on ' + bind);
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
copy .\\node_modules\\leaflet\\dist\\leaflet.css .\\public\\stylesheets\\leaflet\\leaflet.css
|
||||
copy .\\node_modules\\leaflet.nauticscale\\dist\\leaflet.nauticscale.js .\\public\\javascripts\\leaflet.nauticscale.js
|
||||
@@ -1,2 +0,0 @@
|
||||
start cmd /k "npm run start"
|
||||
start cmd /k "watchify .\src\index.ts --debug -o .\public\javascripts\bundle.js -t [ babelify --global true --presets [ @babel/preset-env ] --extensions '.js'] -p [ tsify --noImplicitAny ]
|
||||
705
client/demo.js
705
client/demo.js
@@ -1,705 +0,0 @@
|
||||
|
||||
const DEMO_UNIT_DATA = {
|
||||
["1"]:{
|
||||
baseData: {
|
||||
AI: false,
|
||||
name: "KC-135",
|
||||
unitName: "Olympus 1-1 aka Mr. Very long name",
|
||||
groupName: "Group 2",
|
||||
alive: true,
|
||||
category: "Aircraft",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.20,
|
||||
longitude: -115.80,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 50,
|
||||
flags: {Human: false},
|
||||
ammo: [
|
||||
{
|
||||
count: 4,
|
||||
desc: {
|
||||
displayName: "AIM-120"
|
||||
}
|
||||
},
|
||||
{
|
||||
count: 2,
|
||||
desc: {
|
||||
displayName: "AIM-7"
|
||||
}
|
||||
}
|
||||
],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "blue"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Holding",
|
||||
currentState: "Idle",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredSpeedType: "CAS",
|
||||
desiredAltitude: 3000,
|
||||
desiredAltitudeType: "ASL",
|
||||
isTanker: false,
|
||||
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "Designated",
|
||||
reactionToThreat: "Abort",
|
||||
}
|
||||
},
|
||||
["2"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "KC-135",
|
||||
unitName: "Olympus 1-2",
|
||||
groupName: "Group 3",
|
||||
alive: true,
|
||||
category: "Aircraft",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.2,
|
||||
longitude: -115.75,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "red"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 300,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "Designated",
|
||||
reactionToThreat: "Abort",
|
||||
}
|
||||
},
|
||||
["3"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "M-60",
|
||||
unitName: "Olympus 1-3",
|
||||
groupName: "Group 4",
|
||||
alive: true,
|
||||
category: "GroundUnit",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.175,
|
||||
longitude: -115.8,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "blue"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000,
|
||||
onOff: false
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["4"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "2S6 Tunguska",
|
||||
unitName: "Olympus 1-4",
|
||||
alive: true,
|
||||
category: "GroundUnit",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.175,
|
||||
longitude: -115.75,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "red"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["5"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "M-60",
|
||||
unitName: "Olympus 1-3",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "GroundUnit",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.15,
|
||||
longitude: -115.8,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "blue"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["6"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "M-60",
|
||||
unitName: "Olympus 1-4",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "GroundUnit",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.15,
|
||||
longitude: -115.75,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "red"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["7"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "CVN-75 Very long name",
|
||||
unitName: "Olympus 1-7",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "NavyUnit",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.125,
|
||||
longitude: -115.8,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "blue"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["8"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "CVN-75",
|
||||
unitName: "Olympus 1-8",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "NavyUnit",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.125,
|
||||
longitude: -115.75,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "red"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["9"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "CVN-75",
|
||||
unitName: "Olympus 1-9",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "Aircraft",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.10,
|
||||
longitude: -115.75,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "red"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["10"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "CVN-75",
|
||||
unitName: "Olympus 1-10",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "Aircraft",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.10,
|
||||
longitude: -115.8,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "blue"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["11"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "CVN-75",
|
||||
unitName: "Olympus 1-11",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "Missile",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.075,
|
||||
longitude: -115.80,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "blue"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["12"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "CVN-75",
|
||||
unitName: "Olympus 1-12",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "Missile",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.075,
|
||||
longitude: -115.75,
|
||||
altitude: 2000,
|
||||
heading: 0.6,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "red"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["13"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "CVN-75",
|
||||
unitName: "Olympus 1-11",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "Bomb",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.05,
|
||||
longitude: -115.8,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "blue"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
},
|
||||
["14"]:{
|
||||
baseData: {
|
||||
AI: true,
|
||||
name: "CVN-75",
|
||||
unitName: "Olympus 1-12",
|
||||
groupName: "Group 1",
|
||||
alive: true,
|
||||
category: "Bomb",
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.05,
|
||||
longitude: -115.75,
|
||||
altitude: 2000,
|
||||
heading: 0.6,
|
||||
speed: 300
|
||||
},
|
||||
missionData: {
|
||||
fuel: 0.5,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "red"
|
||||
},
|
||||
formationData: {
|
||||
formation: "Echelon",
|
||||
isLeader: false,
|
||||
isWingman: false,
|
||||
leaderID: null,
|
||||
wingmen: [],
|
||||
wingmenIDs: []
|
||||
},
|
||||
taskData: {
|
||||
currentTask: "Example task",
|
||||
activePath: undefined,
|
||||
desiredSpeed: 400,
|
||||
desiredAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DemoDataGenerator {
|
||||
constructor(unitsNumber)
|
||||
{
|
||||
this.demoUnits = this.generateRandomUnitsDemoData(unitsNumber);
|
||||
}
|
||||
|
||||
units(req, res){
|
||||
var ret = this.demoUnits;
|
||||
for (let ID in this.demoUnits["units"]){
|
||||
this.demoUnits["units"][ID].flightData.latitude += 0.00001;
|
||||
}
|
||||
ret.time = Date.now();
|
||||
res.send(JSON.stringify(ret));
|
||||
};
|
||||
|
||||
logs(req, res){
|
||||
var ret = {logs: {}};
|
||||
ret.time = Date.now();
|
||||
res.send(JSON.stringify(ret));
|
||||
};
|
||||
|
||||
airbases(req, res){
|
||||
var ret = {airbases: {
|
||||
["0"]: {
|
||||
callsign: "Neutral",
|
||||
latitude: 37.3,
|
||||
longitude: -115.8,
|
||||
coalition: "neutral"
|
||||
},
|
||||
["1"]: {
|
||||
callsign: "Red",
|
||||
latitude: 37.3,
|
||||
longitude: -115.75,
|
||||
coalition: "red"
|
||||
},
|
||||
["2"]: {
|
||||
callsign: "Blue",
|
||||
latitude: 37.3,
|
||||
longitude: -115.7,
|
||||
coalition: "blue"
|
||||
}
|
||||
}};
|
||||
ret.time = Date.now();
|
||||
res.send(JSON.stringify(ret));
|
||||
};
|
||||
|
||||
bullseyes(req, res){
|
||||
var ret = {bullseyes: {
|
||||
"0": {
|
||||
latitude: 37.25,
|
||||
longitude: -115.8,
|
||||
coalition: "neutral"
|
||||
},
|
||||
"1": {
|
||||
latitude: 37.25,
|
||||
longitude: -115.75,
|
||||
coalition: "red"
|
||||
},
|
||||
"2": {
|
||||
latitude: 37.25,
|
||||
longitude: -115.7,
|
||||
coalition: "blue"
|
||||
}
|
||||
}};
|
||||
ret.time = Date.now();
|
||||
res.send(JSON.stringify(ret));
|
||||
};
|
||||
|
||||
mission(req, res){
|
||||
var ret = {mission: {theatre: "Nevada"}};
|
||||
ret.time = Date.now();
|
||||
res.send(JSON.stringify(ret));
|
||||
}
|
||||
|
||||
generateRandomUnitsDemoData(unitsNumber)
|
||||
{
|
||||
return {"units": DEMO_UNIT_DATA};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DemoDataGenerator;
|
||||
10091
client/package-lock.json
generated
10091
client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"name": "DCSOlympus",
|
||||
"node-main": "./bin/www",
|
||||
"main": "http://localhost:3000",
|
||||
"version": "v0.3.0-alpha",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"copy": "copy.bat",
|
||||
"start": "npm run copy & concurrently --kill-others \"npm run watch\" \"nodemon ./bin/www\"",
|
||||
"watch": "watchify .\\src\\index.ts --debug -o .\\public\\javascripts\\bundle.js -t [ babelify --global true --presets [ @babel/preset-env ] --extensions '.js'] -p [ tsify --noImplicitAny ]"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/formatcoords": "^1.1.0",
|
||||
"@types/geojson": "^7946.0.10",
|
||||
"@types/leaflet": "^1.9.0",
|
||||
"@types/svg-injector": "^0.0.29",
|
||||
"cookie-parser": "~1.4.4",
|
||||
"debug": "~2.6.9",
|
||||
"ejs": "^3.1.8",
|
||||
"express": "~4.16.1",
|
||||
"formatcoords": "^1.1.3",
|
||||
"leaflet": "^1.9.3",
|
||||
"leaflet-control-mini-map": "^0.4.0",
|
||||
"leaflet.nauticscale": "^1.1.0",
|
||||
"morgan": "~1.9.1",
|
||||
"save": "^2.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.21.4",
|
||||
"@tanem/svg-injector": "^10.1.55",
|
||||
"@types/gtag.js": "^0.0.12",
|
||||
"@types/node": "^18.16.1",
|
||||
"@types/sortablejs": "^1.15.0",
|
||||
"babelify": "^10.0.0",
|
||||
"browserify": "^17.0.0",
|
||||
"concurrently": "^7.6.0",
|
||||
"cp": "^0.2.0",
|
||||
"esmify": "^2.1.1",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"nodemon": "^2.0.20",
|
||||
"sortablejs": "^1.15.0",
|
||||
"tsify": "^5.0.4",
|
||||
"typescript": "^4.9.4",
|
||||
"watchify": "^4.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
copy .\\node_modules\\leaflet\\dist\\leaflet.css .\\public\\stylesheets\\leaflet\\leaflet.css
|
||||
copy .\\node_modules\\leaflet.nauticscale\\dist\\leaflet.nauticscale.js .\\public\\javascripts\\leaflet.nauticscale.js
|
||||
@@ -1,38 +0,0 @@
|
||||
L.Control.ScaleNautic = L.Control.Scale.extend({
|
||||
options: {
|
||||
nautic: false
|
||||
},
|
||||
|
||||
_addScales: function(options, className, container) {
|
||||
L.Control.Scale.prototype._addScales.call(this, options, className, container);
|
||||
L.setOptions(options);
|
||||
if (this.options.nautic) {
|
||||
this._nScale = L.DomUtil.create('div', className, container);
|
||||
}
|
||||
},
|
||||
|
||||
_updateScales: function (maxMeters) {
|
||||
L.Control.Scale.prototype._updateScales.call(this, maxMeters);
|
||||
if (this.options.nautic && maxMeters) {
|
||||
this._updateNautic(maxMeters);
|
||||
}
|
||||
},
|
||||
|
||||
_updateNautic: function (maxMeters) {
|
||||
var scale = this._nScale,
|
||||
maxNauticalMiles = maxMeters / 1852, nauticalMiles;
|
||||
|
||||
if(maxMeters >= 1852) {
|
||||
nauticalMiles = L.Control.Scale.prototype._getRoundNum.call(this, maxNauticalMiles);
|
||||
} else {
|
||||
nauticalMiles = maxNauticalMiles > 0.1 ? Math.round(maxNauticalMiles * 10) / 10 : Math.round(maxNauticalMiles * 100) / 100;
|
||||
}
|
||||
|
||||
scale.style.width = Math.round(this.options.maxWidth * (nauticalMiles / maxNauticalMiles)) - 10 + 'px';
|
||||
scale.innerHTML = nauticalMiles + ' nm';
|
||||
}
|
||||
});
|
||||
|
||||
L.control.scalenautic = function (options) {
|
||||
return new L.Control.ScaleNautic(options);
|
||||
};
|
||||
@@ -1,194 +0,0 @@
|
||||
/**************************************/
|
||||
|
||||
.olympus-dialog {
|
||||
align-self: center;
|
||||
background:white;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-self: center;
|
||||
padding:10px;
|
||||
position:absolute;
|
||||
width:fit-content;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.olympus-dialog-close {
|
||||
cursor:pointer;
|
||||
position:absolute;
|
||||
right:10px;
|
||||
top:5px;
|
||||
}
|
||||
|
||||
.olympus-dialog-header {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
|
||||
/**************************************/
|
||||
|
||||
|
||||
/***** AIC *****/
|
||||
|
||||
.aic-panel {
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#aic-control-panel {
|
||||
bottom:30px;
|
||||
position: absolute;
|
||||
left:30px;
|
||||
}
|
||||
|
||||
|
||||
#aic-control-panel .olympus-button img {
|
||||
max-width: 32px;
|
||||
}
|
||||
|
||||
|
||||
#aic-toolbox, #aic-callsign-panel {
|
||||
align-items: flex-start;
|
||||
align-self: center;
|
||||
flex-direction: column;
|
||||
row-gap: 10px;
|
||||
display:none;
|
||||
position:absolute;
|
||||
}
|
||||
|
||||
.aic-panel {
|
||||
background:#eaeaea;
|
||||
border-bottom-right-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
justify-self: left;
|
||||
padding:5px 10px;
|
||||
}
|
||||
|
||||
.aic-enabled #aic-toolbox, .aic-enabled #aic-callsign-panel {
|
||||
display:flex;
|
||||
}
|
||||
|
||||
.aic-enabled #aic-callsign-panel {
|
||||
align-self: auto;
|
||||
top: 100px;
|
||||
}
|
||||
|
||||
.aic-panel h2 {
|
||||
font-size:90%;
|
||||
margin:0;
|
||||
padding:0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#aic-callsign-display {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#aic-formation-list {
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#aic-formation-list > div {
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
margin-top:10px;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
#aic-formation-list .aic-formation-image img {
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 10px;
|
||||
max-width: 50px;
|
||||
}
|
||||
|
||||
#aic-formation-list .aic-formation-name {
|
||||
font-size:90%;
|
||||
}
|
||||
|
||||
#aic-formation-list .aic-formation-descriptor {
|
||||
background:white;
|
||||
border-radius: 10px;
|
||||
left:100px;
|
||||
padding:5px;
|
||||
position:absolute;
|
||||
width: max-content;
|
||||
}
|
||||
|
||||
#aic-teleprompt {
|
||||
background-color: white;
|
||||
border:2px solid black;
|
||||
border-radius: 10px;
|
||||
bottom: 50px;
|
||||
color: black;
|
||||
display: none;
|
||||
justify-content: center;
|
||||
justify-self: center;
|
||||
padding: 10px;
|
||||
position: absolute;
|
||||
width: fit-content;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.aic-enabled #aic-teleprompt {
|
||||
display:flex;
|
||||
}
|
||||
|
||||
#aic-descriptor {
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
#aic-descriptor .aic-descriptor-section {
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
margin:0 10px;
|
||||
}
|
||||
|
||||
#aic-descriptor .aic-descriptor-section-label {
|
||||
background-color:#eaeaea;
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
padding:.25em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#aic-descriptor .aic-descriptor-phrase {
|
||||
border-bottom: 1px solid #ccc;
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
margin-bottom:5px;
|
||||
padding-bottom:2px;
|
||||
}
|
||||
|
||||
#aic-descriptor .aic-descriptor-phrase:last-of-type {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#aic-descriptor .aic-descriptor-components .aic-descriptor-component {
|
||||
margin:0 5px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#aic-descriptor .aic-descriptor-component-label {
|
||||
display:none;
|
||||
}
|
||||
|
||||
#aic-descriptor .aic-descriptor-component-value:after {
|
||||
content:",";
|
||||
margin-right:5px;
|
||||
}
|
||||
|
||||
#aic-descriptor .aic-descriptor-component:last-of-type .aic-descriptor-component-value:after {
|
||||
content:"; ";
|
||||
}
|
||||
|
||||
#aic-descriptor .aic-descriptor-section:last-of-type .aic-descriptor-component:last-of-type .aic-descriptor-component-value:after {
|
||||
content:".";
|
||||
}
|
||||
|
||||
|
||||
/**************************************/
|
||||
@@ -1,205 +0,0 @@
|
||||
.ol-strip-board .ol-dialog-header {
|
||||
align-items: center;
|
||||
display:flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.ol-strip-board-strips {
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
row-gap: 4px;
|
||||
}
|
||||
|
||||
.ol-strip-board-strip {
|
||||
align-items: center;
|
||||
border-radius: var( --border-radius-sm );
|
||||
column-gap: 4px;
|
||||
display:flex;
|
||||
flex-flow: row nowrap;
|
||||
row-gap:4px;
|
||||
}
|
||||
|
||||
.ol-strip-board-strip[data-flight-status="checkedin"] {
|
||||
background-color: #ffffff2A;
|
||||
}
|
||||
|
||||
.ol-strip-board-strip[data-flight-status="readytotaxi"] {
|
||||
background-color: #ffff0063;
|
||||
}
|
||||
|
||||
.ol-strip-board-strip[data-flight-status="clearedtotaxi"] {
|
||||
background-color: #00ff0030;
|
||||
}
|
||||
|
||||
.ol-strip-board-strip[data-flight-status="halted"] {
|
||||
background-color: #FF000040;
|
||||
}
|
||||
|
||||
.ol-strip-board-strip[data-flight-status="terminated"] {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.ol-strip-board-headers {
|
||||
column-gap: 4px;
|
||||
display:flex;
|
||||
flex-flow:row nowrap;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ol-strip-board-headers > *, .ol-strip-board-strip > [data-point] {
|
||||
padding: 4px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
width:80px;
|
||||
}
|
||||
|
||||
.ol-strip-board-strip input[type="text"] {
|
||||
appearance: none;
|
||||
background-color: transparent;
|
||||
border:1px solid #ffffff30;
|
||||
border-radius: var( --border-radius-sm );
|
||||
color:white;
|
||||
font-size:12px;
|
||||
font-weight:normal;
|
||||
outline:none;
|
||||
padding: 4px 0;
|
||||
text-align: center;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.ol-strip-board-strip[data-time-warning="level-1"] [data-point="timeToGo"] {
|
||||
border:1px solid #cc0000;
|
||||
}
|
||||
|
||||
.ol-strip-board-headers :nth-child(1) {
|
||||
width:12px;
|
||||
}
|
||||
|
||||
.ol-strip-board-headers :nth-child(2),
|
||||
.ol-strip-board-strip :nth-child(2),
|
||||
[data-board-type="ground"] .ol-strip-board-headers :nth-child(3),
|
||||
[data-board-type="ground"] .ol-strip-board-strip :nth-child(3) {
|
||||
width:130px;
|
||||
}
|
||||
|
||||
[data-board-type="ground"] .ol-strip-board-strip :nth-child(5) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.ol-strip-board-headers :last-child,
|
||||
.ol-strip-board-strip :last-child {
|
||||
width:20px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[data-board-type="tower"] .ol-strip-board-strip > * {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-board-type="tower"] .ol-strip-board-strip a {
|
||||
color:white;
|
||||
}
|
||||
|
||||
[data-board-type="tower"] .ol-strip-board-strip > :nth-child(2) {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
[data-board-type="tower"] .ol-strip-board-strip :nth-child(3) input,
|
||||
[data-board-type="tower"] .ol-strip-board-strip :nth-child(5) input {
|
||||
width:30px;
|
||||
}
|
||||
|
||||
[data-board-type="tower"] .ol-strip-board-strip :nth-child(3) {
|
||||
font-size:10px;
|
||||
}
|
||||
|
||||
|
||||
[data-altitude-assigned] [data-point="assignedAltitude"] input,
|
||||
[data-speed-assigned] [data-point="assignedSpeed"] input {
|
||||
background-color:#ffffffbb;
|
||||
color: black;
|
||||
font-weight: var( --font-weight-bolder );
|
||||
}
|
||||
|
||||
[data-warning-altitude] [data-point="altitude"],
|
||||
[data-warning-speed] [data-point="speed"] {
|
||||
background:#cc0000;
|
||||
border-radius: var( --border-radius-sm );
|
||||
}
|
||||
|
||||
|
||||
|
||||
.ol-strip-board-strip > [data-point="name"] {
|
||||
text-overflow: ellipsis;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
.ol-strip-board-strip .ol-select-value {
|
||||
opacity: .85;
|
||||
}
|
||||
|
||||
|
||||
.ol-strip-board-add-flight {
|
||||
display:flex;
|
||||
flex-flow: row nowrap;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
|
||||
.ol-strip-board-add-flight > * {
|
||||
border:none;
|
||||
outline: none;
|
||||
padding:4px 8px;
|
||||
}
|
||||
|
||||
.add-flight-by-click img {
|
||||
filter:invert();
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.ol-strip-board-add-flight input {
|
||||
border-radius: var( --border-radius-sm );
|
||||
}
|
||||
|
||||
.ol-strip-board-add-flight .ol-auto-suggest {
|
||||
background:white;
|
||||
border-radius: var(--border-radius-sm );
|
||||
color:black;
|
||||
display:none;
|
||||
flex-direction: column;
|
||||
left:0;
|
||||
margin:0;
|
||||
position:absolute;
|
||||
translate:0 -100%;
|
||||
top:0;
|
||||
}
|
||||
|
||||
.ol-strip-board-add-flight .ol-auto-suggest[data-has-suggestions] {
|
||||
display:flex;
|
||||
row-gap: 4px;
|
||||
}
|
||||
|
||||
.ol-strip-board-add-flight .ol-auto-suggest[data-has-suggestions] a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
[data-board-type="ground"] {
|
||||
bottom:20px;
|
||||
}
|
||||
|
||||
[data-board-type="tower"] {
|
||||
right:10px;
|
||||
top:10px;
|
||||
}
|
||||
|
||||
[data-board-type="tower"] .ol-auto-suggest {
|
||||
top:30px;
|
||||
translate:0;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#unit-list {
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
font-size:13px;
|
||||
height: 250px;
|
||||
width:fit-content;
|
||||
}
|
||||
|
||||
#unit-list > div {
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
#unit-list > div > div {
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
width:100px;
|
||||
}
|
||||
|
||||
#unit-list > div:first-of-type {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#unit-list > div > div:nth-of-type( 4 ) {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -1,656 +0,0 @@
|
||||
/* required styles */
|
||||
|
||||
.leaflet-pane,
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-tile-container,
|
||||
.leaflet-pane > svg,
|
||||
.leaflet-pane > canvas,
|
||||
.leaflet-zoom-box,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-layer {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-container {
|
||||
overflow: hidden;
|
||||
}
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
/* Prevents IE11 from highlighting tiles in blue */
|
||||
.leaflet-tile::selection {
|
||||
background: transparent;
|
||||
}
|
||||
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
|
||||
.leaflet-safari .leaflet-tile {
|
||||
image-rendering: -webkit-optimize-contrast;
|
||||
}
|
||||
/* hack that prevents hw layers "stretching" when loading new tiles */
|
||||
.leaflet-safari .leaflet-tile-container {
|
||||
width: 1600px;
|
||||
height: 1600px;
|
||||
-webkit-transform-origin: 0 0;
|
||||
}
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
display: block;
|
||||
}
|
||||
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
|
||||
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
|
||||
.leaflet-container .leaflet-overlay-pane svg {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
}
|
||||
.leaflet-container .leaflet-marker-pane img,
|
||||
.leaflet-container .leaflet-shadow-pane img,
|
||||
.leaflet-container .leaflet-tile-pane img,
|
||||
.leaflet-container img.leaflet-image-layer,
|
||||
.leaflet-container .leaflet-tile {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
width: auto;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.leaflet-container.leaflet-touch-zoom {
|
||||
-ms-touch-action: pan-x pan-y;
|
||||
touch-action: pan-x pan-y;
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag {
|
||||
-ms-touch-action: pinch-zoom;
|
||||
/* Fallback for FF which doesn't support pinch-zoom */
|
||||
touch-action: none;
|
||||
touch-action: pinch-zoom;
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
|
||||
-ms-touch-action: none;
|
||||
touch-action: none;
|
||||
}
|
||||
.leaflet-container {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.leaflet-container a {
|
||||
-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
|
||||
}
|
||||
.leaflet-tile {
|
||||
filter: inherit;
|
||||
visibility: hidden;
|
||||
}
|
||||
.leaflet-tile-loaded {
|
||||
visibility: inherit;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
width: 0;
|
||||
height: 0;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
z-index: 800;
|
||||
}
|
||||
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
|
||||
.leaflet-overlay-pane svg {
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.leaflet-pane { z-index: 400; }
|
||||
|
||||
.leaflet-tile-pane { z-index: 200; }
|
||||
.leaflet-overlay-pane { z-index: 400; }
|
||||
.leaflet-shadow-pane { z-index: 500; }
|
||||
.leaflet-marker-pane { z-index: 600; }
|
||||
.leaflet-tooltip-pane { z-index: 650; }
|
||||
.leaflet-popup-pane { z-index: 700; }
|
||||
|
||||
.leaflet-map-pane canvas { z-index: 100; }
|
||||
.leaflet-map-pane svg { z-index: 200; }
|
||||
|
||||
.leaflet-vml-shape {
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
.lvml {
|
||||
behavior: url(#default#VML);
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
/* control positioning */
|
||||
|
||||
.leaflet-control {
|
||||
position: relative;
|
||||
z-index: 800;
|
||||
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
||||
pointer-events: auto;
|
||||
}
|
||||
.leaflet-top,
|
||||
.leaflet-bottom {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
pointer-events: none;
|
||||
}
|
||||
.leaflet-top {
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-right {
|
||||
right: 0;
|
||||
}
|
||||
.leaflet-bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
.leaflet-left {
|
||||
left: 0;
|
||||
}
|
||||
.leaflet-control {
|
||||
float: left;
|
||||
clear: both;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
float: right;
|
||||
}
|
||||
.leaflet-top .leaflet-control {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.leaflet-left .leaflet-control {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
|
||||
/* zoom and fade animations */
|
||||
|
||||
.leaflet-fade-anim .leaflet-popup {
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
-moz-transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
opacity: 1;
|
||||
}
|
||||
.leaflet-zoom-animated {
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
}
|
||||
svg.leaflet-zoom-animated {
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-hide {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* cursors */
|
||||
|
||||
.leaflet-interactive {
|
||||
cursor: pointer;
|
||||
}
|
||||
.leaflet-grab {
|
||||
cursor: -webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
cursor: grab;
|
||||
}
|
||||
.leaflet-crosshair,
|
||||
.leaflet-crosshair .leaflet-interactive {
|
||||
cursor: crosshair;
|
||||
}
|
||||
.leaflet-popup-pane,
|
||||
.leaflet-control {
|
||||
cursor: auto;
|
||||
}
|
||||
.leaflet-dragging .leaflet-grab,
|
||||
.leaflet-dragging .leaflet-grab .leaflet-interactive,
|
||||
.leaflet-dragging .leaflet-marker-draggable {
|
||||
cursor: move;
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* marker & overlays interactivity */
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-pane > svg path,
|
||||
.leaflet-tile-container {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.leaflet-marker-icon.leaflet-interactive,
|
||||
.leaflet-image-layer.leaflet-interactive,
|
||||
.leaflet-pane > svg path.leaflet-interactive,
|
||||
svg.leaflet-image-layer.leaflet-interactive path {
|
||||
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* visual tweaks */
|
||||
|
||||
.leaflet-container {
|
||||
background: #ddd;
|
||||
outline-offset: 1px;
|
||||
}
|
||||
.leaflet-container a {
|
||||
color: #0078A8;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
border: 2px dotted #38f;
|
||||
background: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
|
||||
/* general typography */
|
||||
.leaflet-container {
|
||||
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
|
||||
/* general toolbar styles */
|
||||
|
||||
.leaflet-bar {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a {
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #ccc;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
display: block;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
.leaflet-bar a,
|
||||
.leaflet-control-layers-toggle {
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
display: block;
|
||||
}
|
||||
.leaflet-bar a:hover,
|
||||
.leaflet-bar a:focus {
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
.leaflet-bar a:first-child {
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a:last-child {
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-bottom: none;
|
||||
}
|
||||
.leaflet-bar a.leaflet-disabled {
|
||||
cursor: default;
|
||||
background-color: #f4f4f4;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-bar a {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar a:first-child {
|
||||
border-top-left-radius: 2px;
|
||||
border-top-right-radius: 2px;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar a:last-child {
|
||||
border-bottom-left-radius: 2px;
|
||||
border-bottom-right-radius: 2px;
|
||||
}
|
||||
|
||||
/* zoom control */
|
||||
|
||||
.leaflet-control-zoom-in,
|
||||
.leaflet-control-zoom-out {
|
||||
font: bold 18px 'Lucida Console', Monaco, monospace;
|
||||
text-indent: 1px;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
|
||||
/* layers control */
|
||||
|
||||
.leaflet-control-layers {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
|
||||
background: #fff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers.png);
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
.leaflet-retina .leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers-2x.png);
|
||||
background-size: 26px 26px;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers-toggle {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
.leaflet-control-layers .leaflet-control-layers-list,
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
|
||||
display: none;
|
||||
}
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-list {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
.leaflet-control-layers-expanded {
|
||||
padding: 6px 10px 6px 6px;
|
||||
color: #333;
|
||||
background: #fff;
|
||||
}
|
||||
.leaflet-control-layers-scrollbar {
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.leaflet-control-layers-selector {
|
||||
margin-top: 2px;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
.leaflet-control-layers label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-size: 1.08333em;
|
||||
}
|
||||
.leaflet-control-layers-separator {
|
||||
height: 0;
|
||||
border-top: 1px solid #ddd;
|
||||
margin: 5px -10px 5px -6px;
|
||||
}
|
||||
|
||||
/* Default icon URLs */
|
||||
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
|
||||
background-image: url(images/marker-icon.png);
|
||||
}
|
||||
|
||||
|
||||
/* attribution and scale controls */
|
||||
|
||||
.leaflet-container .leaflet-control-attribution {
|
||||
background: #fff;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
margin: 0;
|
||||
}
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-scale-line {
|
||||
padding: 0 5px;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.leaflet-control-attribution a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.leaflet-control-attribution a:hover,
|
||||
.leaflet-control-attribution a:focus {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.leaflet-attribution-flag {
|
||||
display: inline !important;
|
||||
vertical-align: baseline !important;
|
||||
width: 1em;
|
||||
height: 0.6669em;
|
||||
}
|
||||
.leaflet-left .leaflet-control-scale {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control-scale {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.leaflet-control-scale-line {
|
||||
border: 2px solid #777;
|
||||
border-top: none;
|
||||
line-height: 1.1;
|
||||
padding: 2px 5px 1px;
|
||||
white-space: nowrap;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
text-shadow: 1px 1px #fff;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child) {
|
||||
border-top: 2px solid #777;
|
||||
border-bottom: none;
|
||||
margin-top: -2px;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
|
||||
border-bottom: 2px solid #777;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-attribution,
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
box-shadow: none;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
border: 2px solid rgba(0,0,0,0.2);
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
|
||||
/* popup */
|
||||
|
||||
.leaflet-popup {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.leaflet-popup-content-wrapper {
|
||||
padding: 1px;
|
||||
text-align: left;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.leaflet-popup-content {
|
||||
margin: 13px 24px 13px 20px;
|
||||
line-height: 1.3;
|
||||
font-size: 13px;
|
||||
font-size: 1.08333em;
|
||||
min-height: 1px;
|
||||
}
|
||||
.leaflet-popup-content p {
|
||||
margin: 17px 0;
|
||||
margin: 1.3em 0;
|
||||
}
|
||||
.leaflet-popup-tip-container {
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
margin-top: -1px;
|
||||
margin-left: -20px;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
.leaflet-popup-tip {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
padding: 1px;
|
||||
|
||||
margin: -10px auto 0;
|
||||
pointer-events: auto;
|
||||
|
||||
-webkit-transform: rotate(45deg);
|
||||
-moz-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.leaflet-popup-content-wrapper,
|
||||
.leaflet-popup-tip {
|
||||
background: white;
|
||||
color: #333;
|
||||
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
border: none;
|
||||
text-align: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font: 16px/24px Tahoma, Verdana, sans-serif;
|
||||
color: #757575;
|
||||
text-decoration: none;
|
||||
background: transparent;
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button:hover,
|
||||
.leaflet-container a.leaflet-popup-close-button:focus {
|
||||
color: #585858;
|
||||
}
|
||||
.leaflet-popup-scrolled {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper {
|
||||
-ms-zoom: 1;
|
||||
}
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
width: 24px;
|
||||
margin: 0 auto;
|
||||
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
|
||||
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-control-zoom,
|
||||
.leaflet-oldie .leaflet-control-layers,
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper,
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
|
||||
/* div icon */
|
||||
|
||||
.leaflet-div-icon {
|
||||
background: #fff;
|
||||
border: 1px solid #666;
|
||||
}
|
||||
|
||||
|
||||
/* Tooltip */
|
||||
/* Base styles for the element that has a tooltip */
|
||||
.leaflet-tooltip {
|
||||
position: absolute;
|
||||
padding: 6px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #fff;
|
||||
border-radius: 3px;
|
||||
color: #222;
|
||||
white-space: nowrap;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-tooltip.leaflet-interactive {
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.leaflet-tooltip-top:before,
|
||||
.leaflet-tooltip-bottom:before,
|
||||
.leaflet-tooltip-left:before,
|
||||
.leaflet-tooltip-right:before {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
border: 6px solid transparent;
|
||||
background: transparent;
|
||||
content: "";
|
||||
}
|
||||
|
||||
/* Directions */
|
||||
|
||||
.leaflet-tooltip-bottom {
|
||||
margin-top: 6px;
|
||||
}
|
||||
.leaflet-tooltip-top {
|
||||
margin-top: -6px;
|
||||
}
|
||||
.leaflet-tooltip-bottom:before,
|
||||
.leaflet-tooltip-top:before {
|
||||
left: 50%;
|
||||
margin-left: -6px;
|
||||
}
|
||||
.leaflet-tooltip-top:before {
|
||||
bottom: 0;
|
||||
margin-bottom: -12px;
|
||||
border-top-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-bottom:before {
|
||||
top: 0;
|
||||
margin-top: -12px;
|
||||
margin-left: -6px;
|
||||
border-bottom-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-left {
|
||||
margin-left: -6px;
|
||||
}
|
||||
.leaflet-tooltip-right {
|
||||
margin-left: 6px;
|
||||
}
|
||||
.leaflet-tooltip-left:before,
|
||||
.leaflet-tooltip-right:before {
|
||||
top: 50%;
|
||||
margin-top: -6px;
|
||||
}
|
||||
.leaflet-tooltip-left:before {
|
||||
right: 0;
|
||||
margin-right: -12px;
|
||||
border-left-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-right:before {
|
||||
left: 0;
|
||||
margin-left: -12px;
|
||||
border-right-color: #fff;
|
||||
}
|
||||
|
||||
/* Printing */
|
||||
|
||||
@media print {
|
||||
/* Prevent printers from removing background-images of controls. */
|
||||
.leaflet-control {
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
}
|
||||
@@ -1,409 +0,0 @@
|
||||
#map-contextmenu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: fit-content;
|
||||
position: absolute;
|
||||
row-gap: 5px;
|
||||
width: 280px;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#aircraft-spawn-menu {
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
#ground-unit-spawn-menu {
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
#active-coalition-label {
|
||||
border-radius: 999px;
|
||||
color: var(--nav-text);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
height: fit-content;
|
||||
padding: 3px 10px;
|
||||
padding-bottom: 3px;
|
||||
position: absolute;
|
||||
top: -28px;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
#coalition-switch {
|
||||
margin-right: 10px;
|
||||
height: 25px;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
#coalition-switch[data-value="false"]>.ol-switch-fill {
|
||||
background-color: var(--primary-blue);
|
||||
}
|
||||
|
||||
#coalition-switch[data-value="true"]>.ol-switch-fill {
|
||||
background-color: var(--primary-red);
|
||||
}
|
||||
|
||||
#coalition-switch[data-value="undefined"]>.ol-switch-fill {
|
||||
background-color: var(--primary-neutral);
|
||||
}
|
||||
|
||||
#map-contextmenu>div:nth-child(2) {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
#map-contextmenu>ul {
|
||||
max-height: 200px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#map-contextmenu .ol-panel {
|
||||
border-radius: var(--border-radius-sm);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#map-contextmenu ul {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#map-contextmenu>div:nth-child(n+3) {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
row-gap: 5px;
|
||||
}
|
||||
|
||||
#map-contextmenu .ol-select-container {
|
||||
align-self: stretch;
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#aircraft-spawn-menu .ol-select.is-open .ol-select-options {
|
||||
max-height: 300px;
|
||||
}
|
||||
|
||||
#aircraft-spawn-menu>button,
|
||||
#ground-unit-spawn-menu>button {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#aircraft-spawn-button {
|
||||
background-image: url("/resources/theme/images/buttons/spawn/aircraft.svg");
|
||||
background-size: 48px;
|
||||
}
|
||||
|
||||
#ground-unit-spawn-button {
|
||||
background-image: url("/resources/theme/images/buttons/spawn/ground.svg");
|
||||
background-size: 48px;
|
||||
}
|
||||
|
||||
#smoke-spawn-button {
|
||||
background-image: url("/resources/theme/images/buttons/spawn/smoke.svg");
|
||||
background-size: 48px;
|
||||
}
|
||||
|
||||
#explosion-spawn-button {
|
||||
background-image: url("/resources/theme/images/buttons/spawn/explosion.svg");
|
||||
background-size: 48px;
|
||||
}
|
||||
|
||||
.unit-spawn-button {
|
||||
border: none;
|
||||
border-radius: 0px;
|
||||
height: 48px;
|
||||
margin-bottom: -10px;
|
||||
margin-top: -10px;
|
||||
width: 48px;
|
||||
}
|
||||
|
||||
.unit-spawn-button:last-of-type {
|
||||
border-bottom-right-radius: var(--border-radius-sm);
|
||||
border-top-right-radius: var(--border-radius-sm);
|
||||
}
|
||||
|
||||
[data-active-coalition="blue"].unit-spawn-button:hover,
|
||||
[data-active-coalition="blue"].unit-spawn-button.is-open,
|
||||
[data-active-coalition="blue"]#active-coalition-label,
|
||||
[data-active-coalition="blue"].deploy-unit-button,
|
||||
[data-active-coalition="blue"]#spawn-airbase-aircraft-button {
|
||||
background-color: var(--primary-blue)
|
||||
}
|
||||
|
||||
[data-active-coalition="red"].unit-spawn-button:hover,
|
||||
[data-active-coalition="red"].unit-spawn-button.is-open,
|
||||
[data-active-coalition="red"]#active-coalition-label,
|
||||
[data-active-coalition="red"].deploy-unit-button,
|
||||
[data-active-coalition="red"]#spawn-airbase-aircraft-button {
|
||||
background-color: var(--primary-red)
|
||||
}
|
||||
|
||||
[data-active-coalition="neutral"].unit-spawn-button:hover,
|
||||
[data-active-coalition="neutral"].unit-spawn-button.is-open,
|
||||
[data-active-coalition="neutral"]#active-coalition-label,
|
||||
[data-active-coalition="neutral"].deploy-unit-button,
|
||||
[data-active-coalition="neutral"]#spawn-airbase-aircraft-button {
|
||||
background-color: var(--primary-neutral)
|
||||
}
|
||||
|
||||
[data-active-coalition="blue"].deploy-unit-button:disabled {
|
||||
background-color: transparent;
|
||||
border: 1px solid var(--primary-blue);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
[data-active-coalition="red"].deploy-unit-button:disabled {
|
||||
background-color: transparent;
|
||||
border: 1px solid var(--primary-red);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
[data-active-coalition="neutral"].deploy-unit-button:disabled {
|
||||
background-color: transparent;
|
||||
border: 1px solid var(--primary-neutral);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
[data-active-coalition="blue"]#active-coalition-label::after {
|
||||
content: "Create blue unit";
|
||||
}
|
||||
|
||||
[data-active-coalition="red"]#active-coalition-label::after {
|
||||
content: "Create red unit";
|
||||
}
|
||||
|
||||
[data-active-coalition="neutral"]#active-coalition-label::after {
|
||||
content: "Create neutral unit";
|
||||
}
|
||||
|
||||
#loadout-preview {
|
||||
align-content: space-between;
|
||||
align-items: center;
|
||||
column-gap: 20px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#loadout-list {
|
||||
align-content: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#unit-image {
|
||||
filter: invert(100%);
|
||||
height: 100px;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#smoke-spawn-menu {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#explosion-menu>button,
|
||||
#smoke-spawn-menu>button {
|
||||
align-items: center;
|
||||
column-gap: 10px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#smoke-spawn-menu>button::before {
|
||||
border-radius: 999px;
|
||||
content: "";
|
||||
display: block;
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
[data-smoke-color="red"]::before {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
[data-smoke-color="white"]::before {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
[data-smoke-color="blue"]::before {
|
||||
background-color: blue;
|
||||
}
|
||||
|
||||
[data-smoke-color="green"]::before {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
[data-smoke-color="orange"]::before {
|
||||
background-color: orange;
|
||||
}
|
||||
|
||||
#aircraft-spawn-menu .ol-slider-value {
|
||||
color: var(--accent-light-blue);
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#aircraft-spawn-altitude-slider {
|
||||
padding: 0px 10px;
|
||||
}
|
||||
|
||||
/* Unit context menu */
|
||||
#unit-contextmenu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: fit-content;
|
||||
padding: 15px;
|
||||
position: absolute;
|
||||
row-gap: 5px;
|
||||
width: fit-content;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#unit-contextmenu button {
|
||||
border: 1px solid var(--background-offwhite);
|
||||
border-radius: var(--border-radius-sm);
|
||||
font-weight: normal;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
#unit-contextmenu div {
|
||||
align-content: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
#unit-contextmenu div:before {
|
||||
display: inline-block;
|
||||
filter: invert(100%);
|
||||
height: 16px;
|
||||
margin-right: 15px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
#center-map::before {
|
||||
content: url("/resources/theme/images/icons/arrows-to-eye-solid.svg");
|
||||
}
|
||||
|
||||
#refuel::before {
|
||||
content: url("/resources/theme/images/icons/fuel.svg");
|
||||
}
|
||||
|
||||
#attack::before {
|
||||
content: url("/resources/theme/images/icons/sword.svg");
|
||||
}
|
||||
|
||||
#bomb::before {
|
||||
content: url("/resources/theme/images/icons/crosshairs-solid.svg");
|
||||
}
|
||||
|
||||
#carpet-bomb::before {
|
||||
content: url("/resources/theme/images/icons/explosion-solid.svg");
|
||||
}
|
||||
|
||||
#fire-at-area::before {
|
||||
content: url("/resources/theme/images/icons/crosshairs-solid.svg");
|
||||
}
|
||||
|
||||
#follow::before {
|
||||
content: url("/resources/theme/images/icons/follow.svg");
|
||||
}
|
||||
|
||||
#trail::before {
|
||||
content: url("/resources/theme/images/icons/trail.svg");
|
||||
}
|
||||
|
||||
#echelon-lh::before {
|
||||
content: url("/resources/theme/images/icons/echelon-lh.svg");
|
||||
}
|
||||
|
||||
#echelon-rh::before {
|
||||
content: url("/resources/theme/images/icons/echelon-rh.svg");
|
||||
}
|
||||
|
||||
#line-abreast-rh::before,
|
||||
#line-abreast-lh::before {
|
||||
content: url("/resources/theme/images/icons/line-abreast.svg");
|
||||
}
|
||||
|
||||
#front::before {
|
||||
content: url("/resources/theme/images/icons/front.svg");
|
||||
}
|
||||
|
||||
#diamond::before {
|
||||
content: url("/resources/theme/images/icons/diamond.svg");
|
||||
}
|
||||
|
||||
#custom::before {
|
||||
content: url("/resources/theme/images/icons/custom.svg");
|
||||
}
|
||||
|
||||
#custom-formation-dialog {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
#custom-formation-dialog>.ol-dialog-content {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
row-gap: 10px;
|
||||
}
|
||||
|
||||
#custom-formation-dialog>.ol-dialog-content>.ol-group {
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#reference-system {
|
||||
content: url("/images/reference-system.svg");
|
||||
display: inline-block;
|
||||
filter: invert(100%);
|
||||
position: absolute;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.formation-position-clock {
|
||||
height: 100px;
|
||||
margin: 15px;
|
||||
position: relative;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.formation-position-clock>.clock-hand {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
height: 20px;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
/* Airbase context menu */
|
||||
#airbase-contextmenu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: fit-content;
|
||||
position: absolute;
|
||||
row-gap: 5px;
|
||||
width: 180px;
|
||||
z-index: 9999;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
.ol-popup > div {
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.visible {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.invisible {
|
||||
opacity: 0;
|
||||
transition: opacity 2s linear;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#connection-status-panel dt::before {
|
||||
content: "No connection";
|
||||
}
|
||||
|
||||
#connection-status-panel dd::after {
|
||||
border-radius: 50%;
|
||||
background: red;
|
||||
content: " ";
|
||||
height: 12px;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
#connection-status-panel[data-is-connected] dt::before {
|
||||
content: "Connected";
|
||||
}
|
||||
|
||||
#connection-status-panel[data-is-connected] dd::after {
|
||||
background: var(--accent-green);
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
#mouse-info-panel>* {
|
||||
background-color: var(--background-grey);
|
||||
border-radius: var(--border-radius-sm);
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
#mouse-info-panel dl {
|
||||
margin-bottom: 4px;
|
||||
row-gap: 5px;
|
||||
}
|
||||
|
||||
#mouse-info-panel dt {
|
||||
height: fit-content;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
#mouse-info-panel dt::after {
|
||||
align-items: center;
|
||||
background-color: white;
|
||||
border-radius: var(--border-radius-sm);
|
||||
color: var(--background-steel);
|
||||
display: flex;
|
||||
font-size: 15.6px;
|
||||
font-weight: bolder;
|
||||
height: 16px;
|
||||
justify-content: center;
|
||||
line-height: 16px;
|
||||
padding: 4px;
|
||||
text-transform: uppercase;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
#mouse-info-panel #measuring-tool dt {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
background-color: var(--background-offwhite);
|
||||
border-radius: var(--border-radius-sm);
|
||||
}
|
||||
|
||||
#mouse-info-panel #measuring-tool svg {
|
||||
padding: 3px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#mouse-info-panel #measuring-tool dt svg>* {
|
||||
fill: black;
|
||||
stroke: black;
|
||||
}
|
||||
|
||||
#mouse-info-panel dt[data-label]::after {
|
||||
content: attr(data-label);
|
||||
}
|
||||
|
||||
#mouse-info-panel dt[data-coalition="blue"]::after {
|
||||
background-color: var(--primary-blue);
|
||||
}
|
||||
|
||||
#mouse-info-panel dt[data-coalition="red"]::after {
|
||||
background-color: var(--primary-red);
|
||||
}
|
||||
|
||||
#mouse-info-panel dt[data-tooltip]:hover::before {
|
||||
background-color: var(--background-grey);
|
||||
border-radius: 5px;
|
||||
content: attr(data-tooltip);
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
padding: 5px;
|
||||
position: absolute;
|
||||
translate: calc(-100% - 15px) 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#mouse-info-panel dd {
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.br-info::after {
|
||||
content: attr(data-bearing) '\00B0 / ' attr(data-distance) " " attr(data-distance-units);
|
||||
font-weight: bold;
|
||||
font-size: 13px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--background-offwhite);
|
||||
}
|
||||
|
||||
.br-info[data-coalition="blue"]::after {
|
||||
color: var(--primary-blue)
|
||||
}
|
||||
|
||||
.br-info[data-coalition="red"]::after {
|
||||
color: var(--primary-red)
|
||||
}
|
||||
|
||||
.br-info[data-message]::after {
|
||||
content: attr(data-message);
|
||||
}
|
||||
|
||||
.coordinates::after {
|
||||
content: attr(data-value);
|
||||
font-weight: bold;
|
||||
font-size: 13px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--background-offwhite);
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
body.feature-forceShowUnitControlPanel #unit-control-panel {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
#unit-control-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 10px;
|
||||
}
|
||||
|
||||
#unit-control-panel h3 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
#unit-control-panel #selected-units-container {
|
||||
align-items: left;
|
||||
border-radius: var(--border-radius-md);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 215px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
row-gap: 4px;
|
||||
}
|
||||
|
||||
#unit-control-panel #selected-units-container button {
|
||||
align-items: center;
|
||||
border-radius: var(--border-radius-lg);
|
||||
display: flex;
|
||||
font-size: 11px;
|
||||
height: 32px;
|
||||
justify-content: space-between;
|
||||
margin-right: 5px;
|
||||
position: relative;
|
||||
width: calc(100% - 5px);
|
||||
}
|
||||
|
||||
#unit-control-panel #selected-units-container button::after {
|
||||
border-radius: 999px;
|
||||
color: var(--secondary-semitransparent-white);
|
||||
content: attr(data-label);
|
||||
font-size: 10px;
|
||||
padding: 4px 6px;
|
||||
white-space: nowrap;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
#unit-control-panel #selected-units-container button:hover::after {
|
||||
max-width: 100%;
|
||||
text-overflow: unset;
|
||||
}
|
||||
|
||||
#unit-control-panel #selected-units-container button::before {
|
||||
border-radius: var(--border-radius-sm);
|
||||
content: attr(data-callsign);
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
padding: 4px;
|
||||
padding-left: 0;
|
||||
text-align: left;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
#unit-control-panel h4 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
#advanced-settings-dialog {
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
#advanced-settings-dialog>.ol-dialog-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
row-gap: 10px;
|
||||
}
|
||||
|
||||
#advanced-settings-dialog>.ol-dialog-content>div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
row-gap: 10px;
|
||||
}
|
||||
|
||||
#advanced-settings-dialog>.ol-dialog-content>div>.ol-group {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#advanced-settings-dialog h4 {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#advanced-settings-dialog hr {
|
||||
margin-bottom: 10px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
#general-settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
row-gap: 10px;
|
||||
}
|
||||
|
||||
#general-settings-grid>div {
|
||||
width: 49%;
|
||||
}
|
||||
|
||||
#flight-data .ol-slider {
|
||||
margin: 20px 0px;
|
||||
}
|
||||
|
||||
.ol-slider-container dd {
|
||||
column-gap: 5px;
|
||||
}
|
||||
|
||||
#flight-data .ol-switch {
|
||||
height: 20px;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
#flight-data .ol-switch-fill {
|
||||
background-color: var(--accent-light-blue);
|
||||
}
|
||||
|
||||
#flight-data .ol-switch-fill::after {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#altitude-type-switch[data-value="true"]>.ol-switch-fill::before {
|
||||
content: "AGL";
|
||||
}
|
||||
|
||||
#altitude-type-switch[data-value="false"]>.ol-switch-fill::before {
|
||||
content: "ASL";
|
||||
}
|
||||
|
||||
#speed-type-switch[data-value="true"]>.ol-switch-fill::before {
|
||||
content: "GS";
|
||||
}
|
||||
|
||||
#speed-type-switch[data-value="false"]>.ol-switch-fill::before {
|
||||
content: "CAS";
|
||||
}
|
||||
|
||||
#unit-control-panel .ol-slider-value {
|
||||
color: var(--accent-light-blue);
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#unit-control-panel .switch-control {
|
||||
align-items: center;
|
||||
display: grid;
|
||||
grid-template-columns: 1.35fr 0.65fr;
|
||||
}
|
||||
|
||||
#unit-control-panel .switch-control>*:nth-child(2) {
|
||||
justify-self: end;
|
||||
}
|
||||
|
||||
#unit-control-panel .switch-control>*:nth-child(3) {
|
||||
color: var(--secondary-semitransparent-white);
|
||||
}
|
||||
|
||||
#unit-control-panel .switch-control h4 {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#unit-control-panel .switch-control .ol-switch {
|
||||
height: 25px;
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
#unit-control-panel .switch-control .ol-switch-fill {
|
||||
background-color: var(--accent-light-blue);
|
||||
}
|
||||
|
||||
#unit-control-panel .switch-control .ol-switch-fill::after {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#unit-control-panel .switch-control .ol-switch[data-value="true"]>.ol-switch-fill::before {
|
||||
content: "YES";
|
||||
}
|
||||
|
||||
#unit-control-panel .switch-control .ol-switch[data-value="false"]>.ol-switch-fill::before {
|
||||
content: "NO";
|
||||
}
|
||||
|
||||
#advanced-settings-div {
|
||||
column-gap: 5px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#advanced-settings-div>*:nth-child(2) {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
#advanced-settings-div button {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
/* Element visibility control */
|
||||
#unit-control-panel:not([data-show-categories-tooltip]) #categories-tooltip,
|
||||
#unit-control-panel:not([data-show-speed-slider]) #speed-slider,
|
||||
#unit-control-panel:not([data-show-altitude-slider]) #altitude-slider,
|
||||
#unit-control-panel:not([data-show-roe]) #roe,
|
||||
#unit-control-panel:not([data-show-threat]) #threat,
|
||||
#unit-control-panel:not([data-show-emissions-countermeasures]) #emissions-countermeasures,
|
||||
#unit-control-panel:not([data-show-on-off]) #ai-on-off,
|
||||
#unit-control-panel:not([data-show-follow-roads]) #follow-roads,
|
||||
#unit-control-panel:not([data-show-advanced-settings-button]) #advanced-settings-button,
|
||||
#advanced-settings-dialog:not([data-show-settings]) #general-settings,
|
||||
#advanced-settings-dialog:not([data-show-tasking]) #tasking,
|
||||
#advanced-settings-dialog:not([data-show-tanker]) #tanker-checkbox,
|
||||
#advanced-settings-dialog:not([data-show-AWACS]) #AWACS-checkbox,
|
||||
#advanced-settings-dialog:not([data-show-TACAN]) #TACAN-options,
|
||||
#advanced-settings-dialog:not([data-show-radio]) #radio-options {
|
||||
display: none;
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
fill="none"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
sodipodi:docname="spawn_aircraft.svg"
|
||||
inkscape:version="1.0 (4035a4fb49, 2020-05-01)">
|
||||
<metadata
|
||||
id="metadata14">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs12" />
|
||||
<sodipodi:namedview
|
||||
inkscape:document-rotation="0"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1017"
|
||||
id="namedview10"
|
||||
showgrid="false"
|
||||
inkscape:zoom="18.782524"
|
||||
inkscape:cx="26.073424"
|
||||
inkscape:cy="15.446316"
|
||||
inkscape:window-x="1912"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg8" />
|
||||
<rect
|
||||
x="0.5"
|
||||
y="0.5"
|
||||
width="31"
|
||||
height="31"
|
||||
rx="7.5"
|
||||
fill="white"
|
||||
id="rect2"
|
||||
style="fill:none" />
|
||||
<path
|
||||
d="m 22.011184,13.780381 c 1.003947,0 2.775568,0.85633 2.775568,1.889757 0,1.063016 -1.771621,1.889759 -2.775568,1.889759 h -3.454693 l -2.952773,5.196833 c -0.177205,0.295233 -0.502027,0.472439 -0.826742,0.472439 h -1.653592 c -0.324822,0 -0.560988,-0.295235 -0.472439,-0.590577 l 1.446906,-5.078695 H 11.086009 L 9.786807,19.272448 C 9.698217,19.390585 9.58011,19.449654 9.432472,19.449654 H 8.192315 c -0.236219,0 -0.413381,-0.177206 -0.413381,-0.413371 0,-0.02959 0,-0.05907 0,-0.08855 L 8.723813,15.670138 7.778934,12.422131 c 0,-0.02959 0,-0.05907 0,-0.118137 0,-0.206685 0.177162,-0.413371 0.413381,-0.413371 h 1.240157 c 0.147638,0 0.265743,0.08855 0.354335,0.206686 l 1.299202,1.683072 h 3.011842 L 12.650945,8.7311863 C 12.562399,8.435909 12.798562,8.1111082 13.123384,8.1111082 h 1.653592 c 0.324715,0 0.649537,0.2066963 0.826742,0.5019629 l 2.952773,5.1673099 z"
|
||||
fill="#202831"
|
||||
id="path4"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke-width:1.07987" />
|
||||
<rect
|
||||
x="0.5"
|
||||
y="0.5"
|
||||
width="31"
|
||||
height="31"
|
||||
rx="7.5"
|
||||
stroke="white"
|
||||
id="rect6"
|
||||
style="fill:none;stroke:none" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.8 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user