Compare commits
523 Commits
v1.3.0
...
v1.0.15-ma
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ccc1df9349 | ||
![]() |
d80c7b9fba | ||
![]() |
64c6ce289c | ||
![]() |
67de82a103 | ||
![]() |
357e0446df | ||
![]() |
f2291a57c3 | ||
![]() |
8b862df6ea | ||
![]() |
1c92f69bd4 | ||
![]() |
70833adb44 | ||
![]() |
ab61674b47 | ||
![]() |
c8ddf691ba | ||
![]() |
76afccd9db | ||
![]() |
4882dc673a | ||
![]() |
8546165e59 | ||
![]() |
4cab214635 | ||
![]() |
9a6253d0ef | ||
![]() |
55eac7ecbf | ||
![]() |
057d126658 | ||
![]() |
8efe8ae398 | ||
![]() |
e2cdd803af | ||
![]() |
b6d8cf07f8 | ||
![]() |
1b23cd564e | ||
![]() |
f6ef662344 | ||
![]() |
58b9c926ae | ||
![]() |
81d11a32fe | ||
![]() |
eb9afd5e36 | ||
![]() |
1de0b63907 | ||
![]() |
f89170c37d | ||
![]() |
73ee686a84 | ||
![]() |
e49910e121 | ||
![]() |
83805cba77 | ||
![]() |
32a61d2feb | ||
![]() |
133e20c758 | ||
![]() |
d7c5aa3fa8 | ||
![]() |
f6d59c75c6 | ||
![]() |
fd8c731713 | ||
![]() |
55a552af60 | ||
![]() |
770d18859b | ||
![]() |
22e60edc1f | ||
![]() |
c97fd07f89 | ||
![]() |
7e87cdd5a0 | ||
![]() |
b67eff406f | ||
![]() |
29a5c09ac7 | ||
![]() |
a1668abcd4 | ||
![]() |
2d8ca29935 | ||
![]() |
4f9af817a5 | ||
![]() |
7bd4beb82d | ||
![]() |
1ec57bc4c9 | ||
![]() |
63f14c984d | ||
![]() |
6c227b4a6e | ||
![]() |
b846112c43 | ||
![]() |
23f9b1507d | ||
![]() |
2a0555ea4f | ||
![]() |
0395d0bc7f | ||
![]() |
f2c03cbc34 | ||
![]() |
147c94fd93 | ||
![]() |
0e2ecf16f3 | ||
![]() |
36eb256553 | ||
![]() |
e90ca41c3c | ||
![]() |
5528231cc2 | ||
![]() |
4d01b976f1 | ||
![]() |
ff12b214cd | ||
![]() |
55c9f5296f | ||
![]() |
61e1ed7a59 | ||
![]() |
218cd30152 | ||
![]() |
bf3b819d02 | ||
![]() |
b56c8f711c | ||
![]() |
c5c6ef1cd2 | ||
![]() |
3e01cecdcc | ||
![]() |
966b2f5756 | ||
![]() |
a5743701ea | ||
![]() |
7ea1a523e1 | ||
![]() |
5445459dc7 | ||
![]() |
f2eed13473 | ||
![]() |
af894e7507 | ||
![]() |
94475f7bd1 | ||
![]() |
b5ca0bf392 | ||
![]() |
fdd8479016 | ||
![]() |
c915b385e3 | ||
![]() |
f451c552ec | ||
![]() |
0aa17a26ac | ||
![]() |
41b16a6d75 | ||
![]() |
b5f53dd6c6 | ||
![]() |
5cc2d6652d | ||
![]() |
6fb6226be5 | ||
![]() |
cee5cb3c4d | ||
![]() |
b6fb470b84 | ||
![]() |
6c74ed3869 | ||
![]() |
2c44860a70 | ||
![]() |
169b543f7d | ||
![]() |
efd15fcd62 | ||
![]() |
b372230eae | ||
![]() |
e5cb3e5ae0 | ||
![]() |
8f30b7605b | ||
![]() |
bec29c5bb4 | ||
![]() |
f84a27d705 | ||
![]() |
19f9388a43 | ||
![]() |
f25a412a47 | ||
![]() |
f7a63f17cc | ||
![]() |
aa5963b29b | ||
![]() |
15c4276a81 | ||
![]() |
04b13cbd6c | ||
![]() |
f6971c715b | ||
![]() |
c3e65a5bdd | ||
![]() |
93167f349d | ||
![]() |
b12acddab3 | ||
![]() |
fb9dbf40da | ||
![]() |
1b8bddabc8 | ||
![]() |
a4edbf3bd9 | ||
![]() |
3d13460302 | ||
![]() |
fad656e837 | ||
![]() |
fc986c87a6 | ||
![]() |
80a820ae3d | ||
![]() |
e9e446f8ab | ||
![]() |
b53194184c | ||
![]() |
bcb921cd9d | ||
![]() |
c1632b6b20 | ||
![]() |
88d10d1955 | ||
![]() |
d6fe6234d7 | ||
![]() |
29fcdc0bf8 | ||
![]() |
48ddc6389f | ||
![]() |
a3d722eb16 | ||
![]() |
b386e53ff5 | ||
![]() |
1dd444759b | ||
![]() |
76ea5fdbc1 | ||
![]() |
035325da22 | ||
![]() |
33b2fa7094 | ||
![]() |
b220243b75 | ||
![]() |
f2a077deed | ||
![]() |
d3de1426b2 | ||
![]() |
86b6b94d25 | ||
![]() |
0a19663c33 | ||
![]() |
d236fd9bd9 | ||
![]() |
bc54b79098 | ||
![]() |
5035fa39b7 | ||
![]() |
2395c33995 | ||
![]() |
92ae252210 | ||
![]() |
5d40cf373d | ||
![]() |
9cbcc3ed85 | ||
![]() |
a1f397f9bf | ||
![]() |
540b17448a | ||
![]() |
21fd997554 | ||
![]() |
23b0318591 | ||
![]() |
5727e3b1b8 | ||
![]() |
28164b491b | ||
![]() |
b02d613a28 | ||
![]() |
c18d6d4795 | ||
![]() |
5780cf7c95 | ||
![]() |
cc91fa3653 | ||
![]() |
52ef0b4d6d | ||
![]() |
ef2be78102 | ||
![]() |
9c2dc69e3c | ||
![]() |
8107bf131b | ||
![]() |
0220f46741 | ||
![]() |
e4ad517cb1 | ||
![]() |
792151a8b7 | ||
![]() |
fb67b2f3d1 | ||
![]() |
30c1f07207 | ||
![]() |
562a4554f3 | ||
![]() |
9f22b63227 | ||
![]() |
c96e7a284a | ||
![]() |
dbcd696936 | ||
![]() |
79368aa6dd | ||
![]() |
d661c893d5 | ||
![]() |
ca99404b42 | ||
![]() |
aec03840cc | ||
![]() |
5630eb14c2 | ||
![]() |
6680b0adb2 | ||
![]() |
ff0d881273 | ||
![]() |
ed5d0ea474 | ||
![]() |
997a3ca31c | ||
![]() |
ef444730b7 | ||
![]() |
7bfc6077b9 | ||
![]() |
624bd5a2a4 | ||
![]() |
1e19f9aedf | ||
![]() |
1b4c5ace61 | ||
![]() |
28037e11df | ||
![]() |
036f21de81 | ||
![]() |
43adecaf99 | ||
![]() |
c58e4dccc0 | ||
![]() |
1a1f8b2235 | ||
![]() |
f1616f6532 | ||
![]() |
a42f5ab273 | ||
![]() |
f15139e907 | ||
![]() |
f4399d441d | ||
![]() |
fd4b49e0d5 | ||
![]() |
496a276524 | ||
![]() |
c831df74d0 | ||
![]() |
e77d53fd41 | ||
![]() |
983aff2091 | ||
![]() |
570bc83a6d | ||
![]() |
8dca8bbe65 | ||
![]() |
0e91b47dba | ||
![]() |
3f7e95b502 | ||
![]() |
4f30a47c07 | ||
![]() |
ecbbd6fbf2 | ||
![]() |
13f5648963 | ||
![]() |
dfb7314207 | ||
![]() |
9293801037 | ||
![]() |
d8ac3b2353 | ||
![]() |
056f0e5614 | ||
![]() |
ada5418413 | ||
![]() |
b79e970e66 | ||
![]() |
6fc02edd1e | ||
![]() |
9a8c03106e | ||
![]() |
4a5e41b747 | ||
![]() |
649dcf4019 | ||
![]() |
ae3d1262f5 | ||
![]() |
7b2b0edbdf | ||
![]() |
353746ec04 | ||
![]() |
2fb9b4173a | ||
![]() |
fe7242f36f | ||
![]() |
8015f8486c | ||
![]() |
92d7f8f578 | ||
![]() |
fc9a9f8e09 | ||
![]() |
f94bfc2850 | ||
![]() |
db283fad15 | ||
![]() |
dd7288b787 | ||
![]() |
a6e41b2a90 | ||
![]() |
0e6ac14b74 | ||
![]() |
97f380fb7b | ||
![]() |
3e5b29c84d | ||
![]() |
5d19cc7cf1 | ||
![]() |
19995eba1a | ||
![]() |
990ed0f6bf | ||
![]() |
dc0a085d86 | ||
![]() |
0a852c49e8 | ||
![]() |
59588517d8 | ||
![]() |
3a7cbe48b8 | ||
![]() |
ed298cdfb0 | ||
![]() |
3925c34610 | ||
![]() |
a6fa112050 | ||
![]() |
d97a6a52a4 | ||
![]() |
121846eeae | ||
![]() |
ebef1edc09 | ||
![]() |
bbaf1384ba | ||
![]() |
7036a4da81 | ||
![]() |
91ceb0aa22 | ||
![]() |
de12327ac2 | ||
![]() |
6f65b54883 | ||
![]() |
c0ffd7e641 | ||
![]() |
b0c1ccf9b4 | ||
![]() |
ed3e1aa846 | ||
![]() |
7f720a1753 | ||
![]() |
6cbcbc6f3f | ||
![]() |
53ae9bc42d | ||
![]() |
9813d6946a | ||
![]() |
c7651c9949 | ||
![]() |
34211c4b3f | ||
![]() |
8bc4c247e6 | ||
![]() |
92406a051a | ||
![]() |
56f7578d13 | ||
![]() |
068b074de0 | ||
![]() |
bb0ee3b861 | ||
![]() |
93bb11c135 | ||
![]() |
2fd8c17525 | ||
![]() |
b974487fc4 | ||
![]() |
8198243425 | ||
![]() |
b4addcc125 | ||
![]() |
2d7893b9de | ||
![]() |
60c0ae1049 | ||
![]() |
aaabfa2d01 | ||
![]() |
5c8a1f3677 | ||
![]() |
b37cd74e56 | ||
![]() |
af9a31f4ad | ||
![]() |
7d8838c0ee | ||
![]() |
2c47cfd60e | ||
![]() |
6422f7c576 | ||
![]() |
369a3217f7 | ||
![]() |
f44bf935d3 | ||
![]() |
0e43eee2f3 | ||
![]() |
c6121ab590 | ||
![]() |
72ceeffdad | ||
![]() |
5eb6e9990c | ||
![]() |
3d3769cf5a | ||
![]() |
2a64151f67 | ||
![]() |
34616607a8 | ||
![]() |
796feb05e6 | ||
![]() |
14ae58ca0c | ||
![]() |
b555f46f56 | ||
![]() |
dc5e7e4cb0 | ||
![]() |
deb0b202bf | ||
![]() |
0a5a70f583 | ||
![]() |
f16e825b57 | ||
![]() |
263a8229fa | ||
![]() |
dc7a27a5e3 | ||
![]() |
651865f28a | ||
![]() |
27493d3b23 | ||
![]() |
295bbd62b8 | ||
![]() |
5cf3ae1203 | ||
![]() |
c650e190fb | ||
![]() |
5cd5873ec3 | ||
![]() |
42a66b04c5 | ||
![]() |
a237185e4c | ||
![]() |
df225a3d2f | ||
![]() |
8c59098c28 | ||
![]() |
bbd45df54d | ||
![]() |
8aa0ccd437 | ||
![]() |
74cdd9d055 | ||
![]() |
704f202ce8 | ||
![]() |
fb3082094a | ||
![]() |
7a71cbf756 | ||
![]() |
53c279fa00 | ||
![]() |
8dc542a31c | ||
![]() |
4dee127ce8 | ||
![]() |
3e341e02c8 | ||
![]() |
a673848089 | ||
![]() |
642186678e | ||
![]() |
e37357aea5 | ||
![]() |
967d8ce068 | ||
![]() |
2bb3aa84a7 | ||
![]() |
82ddd3942b | ||
![]() |
ac672092f1 | ||
![]() |
1c6eec61af | ||
![]() |
dda7864c1a | ||
![]() |
ddc13cccec | ||
![]() |
95ac2392e8 | ||
![]() |
0122f9e989 | ||
![]() |
f265f7e773 | ||
![]() |
61307ce584 | ||
![]() |
8f755a5cfc | ||
![]() |
c3addd05f7 | ||
![]() |
bbcfc9fb07 | ||
![]() |
63ac99f97a | ||
![]() |
6d29bce267 | ||
![]() |
6b039288d5 | ||
![]() |
3f803b8107 | ||
![]() |
814a9def7f | ||
![]() |
8c7891809e | ||
![]() |
30729049b3 | ||
![]() |
1a0f80dce7 | ||
![]() |
6973bc8e7d | ||
![]() |
ae3edd67da | ||
![]() |
b66db19c0a | ||
![]() |
36b931f680 | ||
![]() |
9c63054926 | ||
![]() |
276a4522d6 | ||
![]() |
4e2e58bb4c | ||
![]() |
8b7a07ffe7 | ||
![]() |
ffc6a60ee9 | ||
![]() |
f990d27851 | ||
![]() |
fa1a968b8f | ||
![]() |
3d8bf78213 | ||
![]() |
90479dfea2 | ||
![]() |
471912759a | ||
![]() |
844d4be96a | ||
![]() |
0b76ded5aa | ||
![]() |
76aa95588e | ||
![]() |
6618752b84 | ||
![]() |
af5f39af44 | ||
![]() |
03ef57daeb | ||
![]() |
a059d18195 | ||
![]() |
9f610d5ae8 | ||
![]() |
c9adb2a212 | ||
![]() |
7fd814d595 | ||
![]() |
e7065a7159 | ||
![]() |
8625db7ae4 | ||
![]() |
68e6774e26 | ||
![]() |
a7c6ae7382 | ||
![]() |
9c06049628 | ||
![]() |
34e5f4df49 | ||
![]() |
b7b58f5870 | ||
![]() |
f9d75856d1 | ||
![]() |
66b7adf485 | ||
![]() |
76637b130c | ||
![]() |
9a1a31c424 | ||
![]() |
faef000245 | ||
![]() |
c2035668cd | ||
![]() |
f1201c6259 | ||
![]() |
bdaa674662 | ||
![]() |
3b17eb4750 | ||
![]() |
9221d412ca | ||
![]() |
65bb71aabf | ||
![]() |
dcd0fa86b9 | ||
![]() |
72be1b8dbf | ||
![]() |
1d7b642c50 | ||
![]() |
f7d45ca338 | ||
![]() |
831722dd84 | ||
![]() |
ee3dd0b5bd | ||
![]() |
7480847677 | ||
![]() |
0ff715af1b | ||
a318aa87cf | |||
![]() |
74b00d3ab1 | ||
![]() |
355375e9db | ||
![]() |
016203d2bc | ||
![]() |
b65efa2968 | ||
![]() |
4fc5f10bad | ||
![]() |
f8e9d68ceb | ||
![]() |
65e8d62391 | ||
![]() |
93fa82201a | ||
![]() |
71930182dd | ||
![]() |
8764540d3b | ||
![]() |
6a6676c1cb | ||
![]() |
5bf91f1891 | ||
![]() |
14e16a959f | ||
![]() |
3b72724966 | ||
![]() |
9a0e7809cd | ||
![]() |
94c25a70b3 | ||
![]() |
4901120be4 | ||
![]() |
21e45b5e45 | ||
![]() |
b829e90edb | ||
![]() |
fbf7fa6176 | ||
![]() |
2b413ef609 | ||
![]() |
0f06ee5688 | ||
![]() |
ec065ec329 | ||
![]() |
c9a5472282 | ||
![]() |
b12199c65b | ||
![]() |
b4ac097910 | ||
![]() |
aae4ec97a9 | ||
![]() |
45d931b351 | ||
![]() |
f53c9660fe | ||
![]() |
c889854818 | ||
![]() |
b8b0a0fcce | ||
![]() |
b3f9d7e5c7 | ||
![]() |
94b457d9c0 | ||
![]() |
0c58655708 | ||
![]() |
ba98e0a15a | ||
![]() |
5496ad1198 | ||
![]() |
7bad6149b5 | ||
![]() |
378905268d | ||
![]() |
f56a700fea | ||
![]() |
736176ce27 | ||
![]() |
96d749c512 | ||
![]() |
17514c89ad | ||
![]() |
8b08f2b747 | ||
![]() |
07bb0fc4cf | ||
![]() |
dbea9d83f4 | ||
![]() |
8989ae94a7 | ||
![]() |
4db83e6f65 | ||
![]() |
9286f2e559 | ||
![]() |
045a572058 | ||
![]() |
f68be8e4c9 | ||
![]() |
ec4572c390 | ||
![]() |
b89b61496b | ||
![]() |
63f504feb7 | ||
![]() |
06eca83ff9 | ||
![]() |
ebc8b7a7fd | ||
![]() |
4c34a653bd | ||
![]() |
38d2f1b62e | ||
![]() |
d8915d1893 | ||
![]() |
873acfcb4f | ||
![]() |
030df5029b | ||
![]() |
7404b6bd2d | ||
![]() |
b9e9be227a | ||
![]() |
f2537706e7 | ||
![]() |
a8251d9385 | ||
![]() |
b1edd62c0b | ||
![]() |
c1e315fa40 | ||
![]() |
bfcf96f1ad | ||
![]() |
d257e9e1e8 | ||
![]() |
85e307f8db | ||
![]() |
03fa0a73b6 | ||
![]() |
2f157a6438 | ||
![]() |
cdde72cbe0 | ||
![]() |
b18420ad55 | ||
![]() |
d92daccdbf | ||
![]() |
6b3cc6c421 | ||
![]() |
18af85c4d7 | ||
![]() |
6c6ff18ec3 | ||
![]() |
67e663f023 | ||
![]() |
3f717b304a | ||
![]() |
300af03012 | ||
![]() |
3d8d333f10 | ||
![]() |
d87cc7f1e7 | ||
![]() |
d59ef20f72 | ||
![]() |
b2bf0229ed | ||
![]() |
f03bfd2d7a | ||
![]() |
3dd646d6e9 | ||
![]() |
58ad553b39 | ||
![]() |
83056bacf4 | ||
![]() |
2751eaf399 | ||
![]() |
869ba0d33c | ||
![]() |
aeb29d9a69 | ||
![]() |
979d5914a9 | ||
![]() |
e72f5b7c37 | ||
![]() |
42d3324fc1 | ||
![]() |
e242ed6f1f | ||
![]() |
a2acb9c11c | ||
![]() |
444da941c9 | ||
![]() |
f19fd84f1d | ||
![]() |
b5793d36a8 | ||
![]() |
a71c03124b | ||
![]() |
66c484796d | ||
![]() |
a4927030d7 | ||
![]() |
c32badb750 | ||
![]() |
356eb849f2 | ||
![]() |
04e949ed0c | ||
![]() |
13dc8622c9 | ||
![]() |
a2b9c4724d | ||
![]() |
f326e569a1 | ||
![]() |
c1961dee5f | ||
![]() |
e42a231553 | ||
![]() |
b3d9a64632 | ||
![]() |
47c7c37fa9 | ||
![]() |
17413f81ff | ||
![]() |
725e555733 | ||
![]() |
6e7456605d | ||
![]() |
b652181dda | ||
![]() |
6764d80534 | ||
![]() |
6fbc06081e | ||
![]() |
0328876d50 | ||
![]() |
c5e1dd7c3a | ||
![]() |
714824df97 | ||
![]() |
2cb921087f | ||
![]() |
1ed3144428 | ||
![]() |
ba8fa01ce5 | ||
![]() |
3f6f077833 | ||
![]() |
74d9999202 | ||
![]() |
1be1c938cc | ||
![]() |
930f1d43e0 | ||
![]() |
1e04053026 | ||
![]() |
1e6b3faff8 | ||
![]() |
e6928b6ab1 | ||
![]() |
eb97d0d479 | ||
![]() |
0a75d57cf9 | ||
![]() |
383c9b9a33 | ||
![]() |
d2adbecc44 | ||
![]() |
834395bdc3 | ||
![]() |
18dad5bedf | ||
![]() |
c188367749 | ||
![]() |
5b098c68aa | ||
![]() |
22bd56652d | ||
![]() |
d07caea0f6 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,6 +1,9 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
#Rider directory
|
||||
.idea/
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
|
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
FROM mcr.microsoft.com/windows/servercore:ltsc2022
|
||||
|
||||
USER ContainerAdministrator
|
||||
ADD https://aka.ms/highdpimfc2013x64enu vc_redist2013.exe
|
||||
ADD https://aka.ms/vs/16/release/vc_redist.x64.exe vc_redist.exe
|
||||
|
||||
RUN vc_redist2013.exe /passive /norestart
|
||||
RUN vc_redist.exe /passive /norestart
|
||||
RUN del vc_redist2013.exe && del vc_redist.exe
|
||||
|
||||
USER ContainerUser
|
||||
COPY . .
|
||||
ENV TORCH_GAME_PATH="c:\dedi"
|
||||
ENV TORCH_INSTANCE="c:\instance"
|
||||
ENV TORCH_SERVICE="true"
|
||||
ENTRYPOINT ["Torch.Server.exe"]
|
||||
CMD ["-noupdate"]
|
@@ -1,22 +0,0 @@
|
||||
pushd
|
||||
|
||||
$steamData = "C:/Steam/Data/"
|
||||
$steamCMDPath = "C:/Steam/steamcmd/"
|
||||
$steamCMDZip = "C:/Steam/steamcmd.zip"
|
||||
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
|
||||
if (!(Test-Path $steamData)) {
|
||||
mkdir "$steamData"
|
||||
}
|
||||
if (!(Test-Path $steamCMDPath)) {
|
||||
if (!(Test-Path $steamCMDZip)) {
|
||||
(New-Object System.Net.WebClient).DownloadFile("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip", "$steamCMDZip");
|
||||
}
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($steamCMDZip, $steamCMDPath)
|
||||
}
|
||||
|
||||
cd "$steamData"
|
||||
& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740" "+quit"
|
||||
|
||||
popd
|
@@ -1,52 +0,0 @@
|
||||
param([string] $ApiBase, [string]$tagName, [string]$authinfo, [string[]] $assetPaths)
|
||||
Add-Type -AssemblyName "System.Web"
|
||||
|
||||
$headers = @{
|
||||
Authorization = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($authinfo))
|
||||
Accept = "application/vnd.github.v3+json"
|
||||
}
|
||||
try
|
||||
{
|
||||
Write-Output("Checking if release with tag " + $tagName + " already exists...")
|
||||
$release = Invoke-RestMethod -Uri ($ApiBase+"releases/tags/$tagName") -Method "GET" -Headers $headers
|
||||
Write-Output(" Using existing release " + $release.id + " at " + $release.html_url)
|
||||
} catch {
|
||||
Write-Output(" Doesn't exist")
|
||||
$rel_arg = @{
|
||||
tag_name=$tagName
|
||||
name="Generated $tagName"
|
||||
body=""
|
||||
draft=$TRUE
|
||||
prerelease=$tagName.Contains("alpha") -or $tagName.Contains("beta")
|
||||
}
|
||||
Write-Output("Creating new release " + $tagName + "...")
|
||||
$release = Invoke-RestMethod -Uri ($ApiBase+"releases") -Method "POST" -Headers $headers -Body (ConvertTo-Json($rel_arg))
|
||||
Write-Output(" Created new release " + $tagName + " at " + $release.html_url)
|
||||
}
|
||||
|
||||
$assetsApiBase = $release.assets_url
|
||||
Write-Output("Checking for existing assets...")
|
||||
$existingAssets = Invoke-RestMethod -Uri ($assetsApiBase) -Method "GET" -Headers $headers
|
||||
$assetLabels = ($assetPaths | ForEach-Object {[System.IO.Path]::GetFileName($_)})
|
||||
foreach ($asset in $existingAssets) {
|
||||
if ($assetLabels -contains $asset.name) {
|
||||
$uri = $asset.url
|
||||
Write-Output(" Deleting old asset " + $asset.name + " (id " + $asset.id + "); URI=" + $uri)
|
||||
$result = Invoke-RestMethod -Uri $uri -Method "DELETE" -Headers $headers
|
||||
}
|
||||
}
|
||||
Write-Output("Uploading assets...")
|
||||
$uploadUrl = $release.upload_url.Substring(0, $release.upload_url.LastIndexOf('{'))
|
||||
foreach ($asset in $assetPaths) {
|
||||
$assetName = [System.IO.Path]::GetFileName($asset)
|
||||
$assetType = [System.Web.MimeMapping]::GetMimeMapping($asset)
|
||||
$assetData = [System.IO.File]::ReadAllBytes($asset)
|
||||
$headerExtra = $headers + @{
|
||||
"Content-Type" = $assetType
|
||||
Name = $assetName
|
||||
}
|
||||
$uri = $uploadUrl + "?name=" + $assetName
|
||||
Write-Output(" Uploading " + $asset + " as " + $assetType + "; URI=" + $uri)
|
||||
$result = Invoke-RestMethod -Uri $uri -Method "POST" -Headers $headerExtra -Body $assetData
|
||||
Write-Output(" ID=" + $result.id + ", found at=" + $result.browser_download_url)
|
||||
}
|
74
Jenkinsfile
vendored
74
Jenkinsfile
vendored
@@ -1,74 +0,0 @@
|
||||
def packageAndArchive(buildMode, packageName, exclude) {
|
||||
zipFile = "bin\\${packageName}.zip"
|
||||
packageDir = "bin\\${packageName}\\"
|
||||
|
||||
bat "IF EXIST ${zipFile} DEL ${zipFile}"
|
||||
bat "IF EXIST ${packageDir} RMDIR /S /Q ${packageDir}"
|
||||
|
||||
bat "xcopy bin\\x64\\${buildMode} ${packageDir}"
|
||||
if (exclude.length() > 0) {
|
||||
bat "del ${packageDir}${exclude}"
|
||||
}
|
||||
if (buildMode == "Release") {
|
||||
bat "del ${packageDir}*.pdb"
|
||||
}
|
||||
powershell "Add-Type -Assembly System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::CreateFromDirectory(\"\$PWD\\${packageDir}\", \"\$PWD\\${zipFile}\")"
|
||||
archiveArtifacts artifacts: zipFile, caseSensitive: false, onlyIfSuccessful: true
|
||||
}
|
||||
|
||||
node {
|
||||
stage('Checkout') {
|
||||
checkout scm
|
||||
bat 'git pull --tags'
|
||||
}
|
||||
|
||||
stage('Acquire SE') {
|
||||
bat 'powershell -File Jenkins/jenkins-grab-se.ps1'
|
||||
bat 'IF EXIST GameBinaries RMDIR GameBinaries'
|
||||
bat 'mklink /J GameBinaries "C:/Steam/Data/DedicatedServer64/"'
|
||||
}
|
||||
|
||||
stage('Acquire NuGet Packages') {
|
||||
bat 'nuget restore Torch.sln'
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
currentBuild.description = bat(returnStdout: true, script: '@powershell -File Versioning/version.ps1').trim()
|
||||
if (env.BRANCH_NAME == "master") {
|
||||
buildMode = "Release"
|
||||
} else {
|
||||
buildMode = "Debug"
|
||||
}
|
||||
bat "IF EXIST \"bin\" rmdir /Q /S \"bin\""
|
||||
bat "IF EXIST \"bin-test\" rmdir /Q /S \"bin-test\""
|
||||
bat "\"${tool 'MSBuild'}msbuild\" Torch.sln /p:Configuration=${buildMode} /p:Platform=x64 /t:Clean"
|
||||
bat "\"${tool 'MSBuild'}msbuild\" Torch.sln /p:Configuration=${buildMode} /p:Platform=x64"
|
||||
}
|
||||
|
||||
stage('Archive') {
|
||||
archiveArtifacts artifacts: "bin/x64/${buildMode}/Torch*", caseSensitive: false, fingerprint: true, onlyIfSuccessful: true
|
||||
|
||||
packageAndArchive(buildMode, "torch-server", "Torch.Client*")
|
||||
|
||||
packageAndArchive(buildMode, "torch-client", "Torch.Server*")
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
bat 'IF NOT EXIST reports MKDIR reports'
|
||||
bat "\"packages/xunit.runner.console.2.2.0/tools/xunit.console.exe\" \"bin-test/x64/${buildMode}/Torch.Tests.dll\" \"bin-test/x64/${buildMode}/Torch.Server.Tests.dll\" \"bin-test/x64/${buildMode}/Torch.Client.Tests.dll\" -parallel none -xml \"reports/Torch.Tests.xml\""
|
||||
|
||||
step([
|
||||
$class: 'XUnitBuilder',
|
||||
thresholdMode: 1,
|
||||
thresholds: [[$class: 'FailedThreshold', failureThreshold: '1']],
|
||||
tools: [[
|
||||
$class: 'XUnitDotNetTestType',
|
||||
deleteOutputFiles: true,
|
||||
failIfNotNew: true,
|
||||
pattern: 'reports/*.xml',
|
||||
skipNoTestFiles: false,
|
||||
stopProcessingIfError: true
|
||||
]]
|
||||
])
|
||||
}
|
||||
}
|
20
NLog.config
20
NLog.config
@@ -3,22 +3,28 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<variable name="logStamp" value="${time} ${pad:padding=-8:inner=[${level:uppercase=true}]}" />
|
||||
<variable name="logContent" value="${message:withException=true}"/>
|
||||
|
||||
|
||||
<targets>
|
||||
<target xsi:type="Null" name="null" formatMessage="false" />
|
||||
<target xsi:type="File" name="keen" layout="${var:logStamp} ${logger}: ${var:logContent}" fileName="Logs\Keen-${shortdate}.log" />
|
||||
<target xsi:type="File" name="main" layout="${var:logStamp} ${logger}: ${var:logContent}" fileName="Logs\Torch-${shortdate}.log" />
|
||||
<default-wrapper xsi:type="AsyncWrapper" overflowAction="Block" optimizeBufferReuse="true" />
|
||||
<target xsi:type="Null" name="null" formatMessage="false" />
|
||||
<target xsi:type="File" keepFileOpen="true" concurrentWrites="false" name="keen" layout="${var:logStamp} ${logger}: ${var:logContent}"
|
||||
fileName="Logs\Keen-${shortdate}.log" />
|
||||
<target xsi:type="File" keepFileOpen="true" concurrentWrites="false" name="main" layout="${var:logStamp} ${logger}: ${var:logContent}"
|
||||
fileName="Logs\Torch-${shortdate}.log" />
|
||||
<target xsi:type="File" name="chat" layout="${longdate} ${message}" fileName="Logs\Chat.log" />
|
||||
<target xsi:type="ColoredConsole" name="console" layout="${var:logStamp} ${logger}: ${var:logContent}" />
|
||||
<target xsi:type="ColoredConsole" name="console" layout="${var:logStamp} ${logger:shortName=true}: ${var:logContent}" />
|
||||
<target xsi:type="File" name="patch" layout="${var:logContent}" fileName="Logs\patch.log"/>
|
||||
<target xsi:type="LogViewerTarget" name="wpf" layout="[${level:uppercase=true}] ${logger:shortName=true}: ${var:logContent}" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="Keen" minlevel="Info" writeTo="console"/>
|
||||
<!-- Do not define custom rules here. Use NLog-user.config -->
|
||||
<logger name="Keen" minlevel="Warn" writeTo="main"/>
|
||||
<logger name="Keen" minlevel="Info" writeTo="console, wpf"/>
|
||||
<logger name="Keen" minlevel="Debug" writeTo="keen" final="true" />
|
||||
<logger name="Keen" writeTo="null" final="true" />
|
||||
|
||||
<logger name="*" minlevel="Info" writeTo="main, console" />
|
||||
<logger name="*" minlevel="Info" writeTo="main, console, wpf" />
|
||||
<logger name="Chat" minlevel="Info" writeTo="chat" />
|
||||
<!--<logger name="Torch.Managers.PatchManager.*" minlevel="Trace" writeTo="patch"/>-->
|
||||
</rules>
|
||||
|
20
README.md
20
README.md
@@ -1,4 +1,5 @@
|
||||
[](https://discord.gg/8uHZykr) [](http://server.torchapi.net:8080/job/Torch/job/Torch/job/master/)
|
||||
[](https://discord.gg/trK6sYdcNE)
|
||||
[](https://ci.appveyor.com/project/zznty/torch/branch/master)
|
||||
|
||||
# What is Torch?
|
||||
Torch is the successor to SE Server Extender and gives server admins the tools they need to keep their Space Engineers servers running smoothly. It features a user interface with live management tools and a plugin system so you can run your server exactly how you'd like. Torch is still in early development so there may be bugs and incomplete features.
|
||||
@@ -12,24 +13,17 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
|
||||
* Organized, easy to use configuration editor
|
||||
* Extensible using the Torch plugin system
|
||||
|
||||
### Fork Difference
|
||||
* .NET 6.0 runtime
|
||||
* Additional options & features
|
||||
|
||||
### Installation
|
||||
|
||||
* Get the latest Torch release here: https://github.com/TorchAPI/Torch/releases
|
||||
* Unzip the Torch release into its own directory and run the executable. It will automatically download the SE DS and generate the other necessary files.
|
||||
- If you already have a DS installed you can unzip the Torch files into the folder that contains the DedicatedServer64 folder.
|
||||
|
||||
## Torch.Client
|
||||
* An optional client-side version of Torch. More documentation to come.
|
||||
|
||||
# Building
|
||||
To build Torch you must first have a complete SE Dedicated installation somewhere. Before you open the solution, run the Setup batch file and enter the path of that installation's DedicatedServer64 folder. The script will make a symlink to that folder so the Torch solution can find the DLL references it needs.
|
||||
|
||||
In both cases you will need to set the InstancePath in TorchConfig.xml to an existing dedicated server instance as Torch can't fully generate it on its own yet.
|
||||
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon. (https://www.patreon.com/TorchSE)
|
||||
|
||||
# Official Plugins
|
||||
Install plugins by unzipping them into the 'Plugins' folder which should be in the same location as the Torch files. If it doesn't exist you can simply create it.
|
||||
* [Essentials](https://github.com/TorchAPI/Essentials): Adds a slew of chat commands and other tools to help manage your server.
|
||||
* [Concealment](https://github.com/TorchAPI/Concealment): Adds game logic and physics optimizations that significantly improve sim speed.
|
||||
|
||||
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon.
|
||||
[](https://www.patreon.com/bePatron?u=847269)!
|
||||
|
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using Torch.API.Managers;
|
||||
using Torch.API.Session;
|
||||
using VRage.Game.ModAPI;
|
||||
using Version = SemanticVersioning.Version;
|
||||
|
||||
namespace Torch.API
|
||||
{
|
||||
@@ -18,21 +19,25 @@ namespace Torch.API
|
||||
/// <summary>
|
||||
/// Fired when the session begins loading.
|
||||
/// </summary>
|
||||
[Obsolete("Prefer using the TorchSessionManager.SessionStateChanged event")]
|
||||
event Action SessionLoading;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the session finishes loading.
|
||||
/// </summary>
|
||||
[Obsolete("Prefer using the TorchSessionManager.SessionStateChanged event")]
|
||||
event Action SessionLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when the session begins unloading.
|
||||
/// </summary>
|
||||
[Obsolete("Prefer using the TorchSessionManager.SessionStateChanged event")]
|
||||
event Action SessionUnloading;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the session finishes unloading.
|
||||
/// </summary>
|
||||
[Obsolete("Prefer using the TorchSessionManager.SessionStateChanged event")]
|
||||
event Action SessionUnloaded;
|
||||
|
||||
/// <summary>
|
||||
@@ -70,15 +75,23 @@ namespace Torch.API
|
||||
|
||||
/// <summary>
|
||||
/// Invoke an action on the game thread and block until it has completed.
|
||||
/// If this is called on the game thread the action will execute immediately.
|
||||
/// </summary>
|
||||
void InvokeBlocking(Action action, [CallerMemberName] string caller = "");
|
||||
/// <param name="action">Action to execute</param>
|
||||
/// <param name="caller">Caller of the invoke function</param>
|
||||
/// <param name="timeoutMs">Timeout before <see cref="TimeoutException"/> is thrown, or -1 to never timeout</param>
|
||||
/// <exception cref="TimeoutException">If the action times out</exception>
|
||||
void InvokeBlocking(Action action, int timeoutMs = -1, [CallerMemberName] string caller = "");
|
||||
|
||||
/// <summary>
|
||||
/// Invoke an action on the game thread asynchronously.
|
||||
/// </summary>
|
||||
Task InvokeAsync(Action action, [CallerMemberName] string caller = "");
|
||||
|
||||
/// <summary>
|
||||
/// Invoke a function on the game thread asynchronously.
|
||||
/// </summary>
|
||||
Task<T> InvokeAsync<T>(Func<T> func, [CallerMemberName] string caller = "");
|
||||
|
||||
/// <summary>
|
||||
/// Signals the torch instance to start, then blocks until it's started.
|
||||
/// </summary>
|
||||
@@ -90,15 +103,17 @@ namespace Torch.API
|
||||
void Stop();
|
||||
|
||||
/// <summary>
|
||||
/// Restart the Torch instance.
|
||||
/// Restart the Torch instance, blocking until the restart has been performed.
|
||||
/// </summary>
|
||||
void Restart();
|
||||
void Restart(bool save = true);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a save of the game.
|
||||
/// </summary>
|
||||
/// <param name="callerId">Id of the player who initiated the save.</param>
|
||||
Task Save(long callerId);
|
||||
/// <param name="timeoutMs">timeout before the save is treated as failed, or -1 for no timeout</param>
|
||||
/// <param name="exclusive">Only start saving if we aren't already saving</param>
|
||||
/// <returns>Future result of the save, or null if one is in progress and in exclusive mode</returns>
|
||||
Task<GameSaveResult> Save(int timeoutMs = -1, bool exclusive = false);
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the Torch instance. Before this <see cref="Start"/> is invalid.
|
||||
@@ -108,7 +123,7 @@ namespace Torch.API
|
||||
/// <summary>
|
||||
/// Disposes the Torch instance. After this <see cref="Start"/> is invalid.
|
||||
/// </summary>
|
||||
void Dispose();
|
||||
void Destroy();
|
||||
|
||||
/// <summary>
|
||||
/// The current state of the game this instance of torch is controlling.
|
||||
@@ -135,6 +150,18 @@ namespace Torch.API
|
||||
/// Path of the dedicated instance folder.
|
||||
/// </summary>
|
||||
string InstancePath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the dedicated instance.
|
||||
/// </summary>
|
||||
string InstanceName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Raised when the server's Init() method has completed.
|
||||
/// </summary>
|
||||
event Action<ITorchServer> Initialized;
|
||||
|
||||
TimeSpan ElapsedPlayTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Torch.API;
|
||||
|
||||
namespace Torch
|
||||
{
|
||||
@@ -8,17 +10,28 @@ namespace Torch
|
||||
bool ForceUpdate { get; set; }
|
||||
bool GetPluginUpdates { get; set; }
|
||||
bool GetTorchUpdates { get; set; }
|
||||
[Obsolete("Use Torch.InstanceName instead")]
|
||||
string InstanceName { get; set; }
|
||||
[Obsolete("Use Torch.InstancePath instead")]
|
||||
string InstancePath { get; set; }
|
||||
bool NoGui { get; set; }
|
||||
bool NoUpdate { get; set; }
|
||||
List<string> Plugins { get; set; }
|
||||
List<Guid> Plugins { get; set; }
|
||||
bool LocalPlugins { get; set; }
|
||||
bool RestartOnCrash { get; set; }
|
||||
bool ShouldUpdatePlugins { get; }
|
||||
bool ShouldUpdateTorch { get; }
|
||||
int TickTimeout { get; set; }
|
||||
string WaitForPID { get; set; }
|
||||
|
||||
bool Save(string path = null);
|
||||
string ChatName { get; set; }
|
||||
string ChatColor { get; set; }
|
||||
string TestPlugin { get; set; }
|
||||
bool DisconnectOnRestart { get; set; }
|
||||
int WindowWidth { get; set; }
|
||||
int WindowHeight { get; set; }
|
||||
int FontSize { get; set; }
|
||||
UGCServiceType UgcServiceType { get; set; }
|
||||
bool EntityManagerEnabled { get; set; }
|
||||
void Save(string path = null);
|
||||
}
|
||||
}
|
@@ -4,31 +4,56 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Game.Gui;
|
||||
using Sandbox.Game.Multiplayer;
|
||||
using Torch.Utils;
|
||||
using VRage.Game;
|
||||
using VRage.Network;
|
||||
using VRage.Replication;
|
||||
using VRageMath;
|
||||
using VRageRender;
|
||||
|
||||
namespace Torch.API.Managers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a scripted or user chat message.
|
||||
/// </summary>
|
||||
public struct TorchChatMessage
|
||||
public readonly struct TorchChatMessage
|
||||
{
|
||||
private const string DEFAULT_FONT = MyFontEnum.Blue;
|
||||
|
||||
#region Backwards compatibility
|
||||
|
||||
[Obsolete]
|
||||
public TorchChatMessage(string author, string message, string font = DEFAULT_FONT)
|
||||
: this(author, message, default, font) { }
|
||||
|
||||
[Obsolete]
|
||||
public TorchChatMessage(string author, ulong authorSteamId, string message, ChatChannel channel, long target, string font = DEFAULT_FONT)
|
||||
: this(author, authorSteamId, message, channel, target, default, font) { }
|
||||
|
||||
[Obsolete]
|
||||
public TorchChatMessage(ulong authorSteamId, string message, ChatChannel channel, long target, string font = DEFAULT_FONT)
|
||||
: this(authorSteamId, message, channel, target, default, font) { }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new torch chat message with the given author and message.
|
||||
/// </summary>
|
||||
/// <param name="author">Author's name</param>
|
||||
/// <param name="message">Message</param>
|
||||
/// <param name="font">Font</param>
|
||||
public TorchChatMessage(string author, string message, string font = MyFontEnum.Blue)
|
||||
public TorchChatMessage(string author, string message, Color color, string font = DEFAULT_FONT)
|
||||
{
|
||||
Timestamp = DateTime.Now;
|
||||
AuthorSteamId = null;
|
||||
Author = author;
|
||||
Message = message;
|
||||
Channel = ChatChannel.Global;
|
||||
Target = 0;
|
||||
Font = font;
|
||||
Color = color == default ? ColorUtils.TranslateColor(font) : color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,13 +63,16 @@ namespace Torch.API.Managers
|
||||
/// <param name="authorSteamId">Author's steam ID</param>
|
||||
/// <param name="message">Message</param>
|
||||
/// <param name="font">Font</param>
|
||||
public TorchChatMessage(string author, ulong authorSteamId, string message, string font = MyFontEnum.Blue)
|
||||
public TorchChatMessage(string author, ulong authorSteamId, string message, ChatChannel channel, long target, Color color, string font = DEFAULT_FONT)
|
||||
{
|
||||
Timestamp = DateTime.Now;
|
||||
AuthorSteamId = authorSteamId;
|
||||
Author = author;
|
||||
Message = message;
|
||||
Channel = channel;
|
||||
Target = target;
|
||||
Font = font;
|
||||
Color = color == default ? ColorUtils.TranslateColor(font) : color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,13 +81,16 @@ namespace Torch.API.Managers
|
||||
/// <param name="authorSteamId">Author's steam ID</param>
|
||||
/// <param name="message">Message</param>
|
||||
/// <param name="font">Font</param>
|
||||
public TorchChatMessage(ulong authorSteamId, string message, string font = MyFontEnum.Blue)
|
||||
public TorchChatMessage(ulong authorSteamId, string message, ChatChannel channel, long target, Color color, string font = DEFAULT_FONT)
|
||||
{
|
||||
Timestamp = DateTime.Now;
|
||||
AuthorSteamId = authorSteamId;
|
||||
Author = MyMultiplayer.Static?.GetMemberName(authorSteamId) ?? "Player";
|
||||
Message = message;
|
||||
Channel = channel;
|
||||
Target = target;
|
||||
Font = font;
|
||||
Color = color == default ? ColorUtils.TranslateColor(font) : color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -79,9 +110,21 @@ namespace Torch.API.Managers
|
||||
/// </summary>
|
||||
public readonly string Message;
|
||||
/// <summary>
|
||||
/// The chat channel the message is part of.
|
||||
/// </summary>
|
||||
public readonly ChatChannel Channel;
|
||||
/// <summary>
|
||||
/// The intended recipient of the message.
|
||||
/// </summary>
|
||||
public readonly long Target;
|
||||
/// <summary>
|
||||
/// The font, or null if default.
|
||||
/// </summary>
|
||||
public readonly string Font;
|
||||
/// <summary>
|
||||
/// The chat message color.
|
||||
/// </summary>
|
||||
public readonly Color Color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -3,7 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VRage.Collections;
|
||||
using VRage.Game;
|
||||
using VRage.Network;
|
||||
using VRageMath;
|
||||
|
||||
namespace Torch.API.Managers
|
||||
{
|
||||
@@ -33,13 +36,36 @@ namespace Torch.API.Managers
|
||||
void SendMessageAsOther(ulong authorId, string message, ulong targetSteamId = 0);
|
||||
|
||||
|
||||
[Obsolete("Use the other overload with a Color parameter.")]
|
||||
void SendMessageAsOther(string author, string message, string font, ulong targetSteamId = 0);
|
||||
|
||||
/// <summary>
|
||||
/// Sends a scripted message with the given author and message to the given player, or all players by default.
|
||||
/// </summary>
|
||||
/// <param name="author">Author name</param>
|
||||
/// <param name="message">The message to send</param>
|
||||
/// <param name="color">Name color</param>
|
||||
/// <param name="font">Font to use</param>
|
||||
/// <param name="targetSteamId">Player to send the message to, or everyone by default</param>
|
||||
void SendMessageAsOther(string author, string message, string font, ulong targetSteamId = 0);
|
||||
void SendMessageAsOther(string author, string message, Color color = default, ulong targetSteamId = 0, string font = MyFontEnum.White);
|
||||
|
||||
/// <summary>
|
||||
/// Mute user from global chat.
|
||||
/// </summary>
|
||||
/// <param name="steamId"></param>
|
||||
/// <returns></returns>
|
||||
bool MuteUser(ulong steamId);
|
||||
|
||||
/// <summary>
|
||||
/// Unmute user from global chat.
|
||||
/// </summary>
|
||||
/// <param name="steamId"></param>
|
||||
/// <returns></returns>
|
||||
bool UnmuteUser(ulong steamId);
|
||||
|
||||
/// <summary>
|
||||
/// Users which are not allowed to chat.
|
||||
/// </summary>
|
||||
HashSetReader<ulong> MutedUsers { get; }
|
||||
}
|
||||
}
|
||||
|
21
Torch.API/Managers/IInstanceManager.cs
Normal file
21
Torch.API/Managers/IInstanceManager.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using VRage.Game;
|
||||
|
||||
namespace Torch.API.Managers;
|
||||
|
||||
public interface IInstanceManager : IManager
|
||||
{
|
||||
IWorld SelectedWorld { get; }
|
||||
void LoadInstance(string path, bool validate = true);
|
||||
void SelectCreatedWorld(string worldPath);
|
||||
void SelectWorld(string worldPath, bool modsOnly = true);
|
||||
void ImportSelectedWorldConfig();
|
||||
void SaveConfig();
|
||||
}
|
||||
|
||||
public interface IWorld
|
||||
{
|
||||
string FolderName { get; }
|
||||
string WorldPath { get; }
|
||||
MyObjectBuilder_SessionSettings KeenSessionSettings { get; }
|
||||
MyObjectBuilder_Checkpoint KeenCheckpoint { get; }
|
||||
}
|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VRage.Game.ModAPI;
|
||||
|
||||
namespace Torch.API.Managers
|
||||
{
|
||||
@@ -21,6 +22,25 @@ namespace Torch.API.Managers
|
||||
/// </summary>
|
||||
void BanPlayer(ulong steamId, bool banned = true);
|
||||
|
||||
/// <summary>
|
||||
/// Promotes user if possible.
|
||||
/// </summary>
|
||||
/// <param name="steamId"></param>
|
||||
void PromoteUser(ulong steamId);
|
||||
|
||||
/// <summary>
|
||||
/// Demotes user if possible.
|
||||
/// </summary>
|
||||
/// <param name="steamId"></param>
|
||||
void DemoteUser(ulong steamId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a user's promote level.
|
||||
/// </summary>
|
||||
/// <param name="steamId"></param>
|
||||
/// <returns></returns>
|
||||
MyPromoteLevel GetUserPromoteLevel(ulong steamId);
|
||||
|
||||
/// <summary>
|
||||
/// List of the banned SteamID's
|
||||
/// </summary>
|
||||
@@ -32,5 +52,20 @@ namespace Torch.API.Managers
|
||||
/// <param name="steamId">The SteamID of the player.</param>
|
||||
/// <returns>True if the player is banned; otherwise false.</returns>
|
||||
bool IsBanned(ulong steamId);
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a player is kicked. Passes with SteamID of kicked player.
|
||||
/// </summary>
|
||||
event Action<ulong> PlayerKicked;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a player is banned or unbanned. Passes SteamID of player, and true if banned, false if unbanned.
|
||||
/// </summary>
|
||||
event Action<ulong, bool> PlayerBanned;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a player is promoted or demoted. Passes SteamID of player, and new promote level.
|
||||
/// </summary>
|
||||
event Action<ulong, MyPromoteLevel> PlayerPromoted;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@@ -34,5 +34,22 @@ namespace Torch.API.Plugins
|
||||
/// This is called on the game thread after each tick.
|
||||
/// </summary>
|
||||
void Update();
|
||||
|
||||
/// <summary>
|
||||
/// Plugin's enabled state. Mainly for UI niceness
|
||||
/// </summary>
|
||||
PluginState State { get; }
|
||||
}
|
||||
|
||||
public enum PluginState
|
||||
{
|
||||
NotInitialized,
|
||||
DisabledError,
|
||||
DisabledUser,
|
||||
UpdateRequired,
|
||||
UninstallRequested,
|
||||
NotInstalled,
|
||||
MissingDependency,
|
||||
Enabled
|
||||
}
|
||||
}
|
||||
|
44
Torch.API/Session/GameSaveResult.cs
Normal file
44
Torch.API/Session/GameSaveResult.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Torch.API.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// The result of a save operation
|
||||
/// </summary>
|
||||
public enum GameSaveResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Successfully saved
|
||||
/// </summary>
|
||||
Success = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The game wasn't ready to be saved
|
||||
/// </summary>
|
||||
GameNotReady = -1,
|
||||
|
||||
/// <summary>
|
||||
/// Failed to take the snapshot of the current world state
|
||||
/// </summary>
|
||||
FailedToTakeSnapshot = -2,
|
||||
|
||||
/// <summary>
|
||||
/// Failed to save the snapshot to disk
|
||||
/// </summary>
|
||||
FailedToSaveToDisk = -3,
|
||||
|
||||
/// <summary>
|
||||
/// An unknown error occurred
|
||||
/// </summary>
|
||||
UnknownError = -4,
|
||||
|
||||
/// <summary>
|
||||
/// The save operation timed out
|
||||
/// </summary>
|
||||
TimedOut = -5
|
||||
}
|
||||
}
|
@@ -22,6 +22,11 @@ namespace Torch.API.Session
|
||||
/// The Space Engineers game session this session is bound to.
|
||||
/// </summary>
|
||||
MySession KeenSession { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Currently running world
|
||||
/// </summary>
|
||||
IWorld World { get; }
|
||||
|
||||
/// <inheritdoc cref="IDependencyManager"/>
|
||||
IDependencyManager Managers { get; }
|
||||
|
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Torch.API.Managers;
|
||||
using VRage.Game;
|
||||
|
||||
namespace Torch.API.Session
|
||||
{
|
||||
@@ -47,5 +49,29 @@ namespace Torch.API.Session
|
||||
/// <returns>true if removed, false if not present</returns>
|
||||
/// <exception cref="ArgumentNullException">If the factory is null</exception>
|
||||
bool RemoveFactory(SessionManagerFactoryDel factory);
|
||||
|
||||
/// <summary>
|
||||
/// Add a mod to be injected into client's world download.
|
||||
/// </summary>
|
||||
/// <param name="modId"></param>
|
||||
/// <returns></returns>
|
||||
bool AddOverrideMod(ulong modId);
|
||||
|
||||
/// <summary>
|
||||
/// Removes a mod from the injected mod list.
|
||||
/// </summary>
|
||||
/// <param name="modId"></param>
|
||||
/// <returns></returns>
|
||||
bool RemoveOverrideMod(ulong modId);
|
||||
|
||||
/// <summary>
|
||||
/// List over mods that will be injected into client world downloads.
|
||||
/// </summary>
|
||||
IReadOnlyCollection<MyObjectBuilder_Checkpoint.ModItem> OverrideMods { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when injected mod list changes.
|
||||
/// </summary>
|
||||
event Action<CollectionChangeEventArgs> OverrideModsChanged;
|
||||
}
|
||||
}
|
||||
|
@@ -1,203 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{FBA5D932-6254-4A1E-BAF4-E229FA94E3C2}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Torch.API</RootNamespace>
|
||||
<AssemblyName>Torch.API</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>$(SolutionDir)\bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<TargetFramework>net6-windows</TargetFramework>
|
||||
<AssemblyTitle>Torch API</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
<Copyright>Copyright © Torch API 2017</Copyright>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<OutputPath>..\bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<UseWpf>True</UseWpf>
|
||||
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>$(SolutionDir)\bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>$(SolutionDir)\bin\x64\Release\Torch.API.xml</DocumentationFile>
|
||||
<PropertyGroup Condition="$(Configuration) == 'Release'">
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
<!-- <Import Project="$(SolutionDir)\TransformOnBuild.targets" /> -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NLog" Version="5.0.0-rc2" />
|
||||
<PackageReference Include="SemanticVersioning" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="HavokWrapper, Version=1.0.6278.22649, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\HavokWrapper.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.4.12\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="Sandbox.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\Sandbox.Common.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Game, Version=0.1.6305.30774, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\Sandbox.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Graphics, Version=0.1.6305.30761, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\Sandbox.Graphics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.ObjectBuilders, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.ObjectBuilders.XmlSerializers, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SteamSDK, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\SteamSDK.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="VRage">
|
||||
<HintPath>..\GameBinaries\VRage.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Audio, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Audio.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Dedicated">
|
||||
<HintPath>..\GameBinaries\VRage.Dedicated.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Game.XmlSerializers, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Game.XmlSerializers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Input, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Input.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Library">
|
||||
<HintPath>..\GameBinaries\VRage.Library.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Math, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Math.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Native, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Native.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.OpenVRWrapper, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.OpenVRWrapper.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Render.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render11, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Render11.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Scripting, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Scripting.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs">
|
||||
<Link>Properties\AssemblyVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ConnectionState.cs" />
|
||||
<Compile Include="ITorchConfig.cs" />
|
||||
<Compile Include="Managers\DependencyManagerExtensions.cs" />
|
||||
<Compile Include="Managers\DependencyProviderExtensions.cs" />
|
||||
<Compile Include="Event\EventHandlerAttribute.cs" />
|
||||
<Compile Include="Event\IEvent.cs" />
|
||||
<Compile Include="Event\IEventHandler.cs" />
|
||||
<Compile Include="Managers\IChatManagerClient.cs" />
|
||||
<Compile Include="Managers\IChatManagerServer.cs" />
|
||||
<Compile Include="Managers\IDependencyManager.cs" />
|
||||
<Compile Include="Managers\IDependencyProvider.cs" />
|
||||
<Compile Include="Event\IEventManager.cs" />
|
||||
<Compile Include="Managers\IManager.cs" />
|
||||
<Compile Include="Managers\IMultiplayerManagerClient.cs" />
|
||||
<Compile Include="Managers\IMultiplayerManagerBase.cs" />
|
||||
<Compile Include="IPlayer.cs" />
|
||||
<Compile Include="Managers\IMultiplayerManagerServer.cs" />
|
||||
<Compile Include="Managers\INetworkManager.cs" />
|
||||
<Compile Include="Managers\IPluginManager.cs" />
|
||||
<Compile Include="Plugins\ITorchPlugin.cs" />
|
||||
<Compile Include="IServerControls.cs" />
|
||||
<Compile Include="ITorchBase.cs" />
|
||||
<Compile Include="Plugins\IWpfPlugin.cs" />
|
||||
<Compile Include="ModAPI\Ingame\GridExtensions.cs" />
|
||||
<Compile Include="Plugins\PluginAttribute.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServerState.cs" />
|
||||
<Compile Include="ModAPI\TorchAPI.cs" />
|
||||
<Compile Include="Session\ITorchSession.cs" />
|
||||
<Compile Include="Session\ITorchSessionManager.cs" />
|
||||
<Compile Include="Session\TorchSessionState.cs" />
|
||||
<Compile Include="TorchGameState.cs" />
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs" Link="Properties/AssemblyVersion.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
|
||||
</Project>
|
8
Torch.API/UGCServiceType.cs
Normal file
8
Torch.API/UGCServiceType.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Torch.API
|
||||
{
|
||||
public enum UGCServiceType
|
||||
{
|
||||
Steam,
|
||||
EOS
|
||||
}
|
||||
}
|
40
Torch.API/Utils/ColorUtils.cs
Normal file
40
Torch.API/Utils/ColorUtils.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Windows.Media;
|
||||
using VRage.Game;
|
||||
using Color = VRageMath.Color;
|
||||
|
||||
namespace Torch.Utils
|
||||
{
|
||||
public static class ColorUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert the old "font" or a RGB hex code to a Color.
|
||||
/// </summary>
|
||||
public static Color TranslateColor(string font)
|
||||
{
|
||||
if (StringUtils.IsFontEnum(font))
|
||||
{
|
||||
// RGB values copied from Fonts.sbc
|
||||
switch (font)
|
||||
{
|
||||
case MyFontEnum.Blue:
|
||||
return new Color(220, 244, 252);
|
||||
case MyFontEnum.Red:
|
||||
return new Color(227, 65, 65);
|
||||
case MyFontEnum.Green:
|
||||
return new Color(101, 182, 193);
|
||||
case MyFontEnum.DarkBlue:
|
||||
return new Color(94, 115, 127);
|
||||
default:
|
||||
return Color.White;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// VRage color doesn't have its own hex code parser and I don't want to write one
|
||||
var conv = (System.Windows.Media.Color)(ColorConverter.ConvertFromString(font) ??
|
||||
System.Windows.Media.Color.FromRgb(255, 255, 255));
|
||||
return new Color(conv.R, conv.G, conv.B);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
Torch.API/Utils/SemanticVersionConverter.cs
Normal file
21
Torch.API/Utils/SemanticVersionConverter.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Version = SemanticVersioning.Version;
|
||||
|
||||
namespace Torch.API.Utils;
|
||||
|
||||
public class SemanticVersionConverter : JsonConverter<Version>
|
||||
{
|
||||
public override Version? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
Version.TryParse(reader.GetString(), out var ver);
|
||||
return ver;
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Version value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -60,5 +61,13 @@ namespace Torch.Utils
|
||||
}
|
||||
return builder?.ToString() ?? "";
|
||||
}
|
||||
|
||||
private static string[] FontEnumValues => _fontEnumValues ?? (_fontEnumValues = typeof(VRage.Game.MyFontEnum).GetFields(BindingFlags.Public | BindingFlags.Static).Where(x => x.IsLiteral && !x.IsInitOnly).Select(x => (string)x.GetValue(null)).ToArray());
|
||||
|
||||
private static string[] _fontEnumValues;
|
||||
public static bool IsFontEnum(string str)
|
||||
{
|
||||
return FontEnumValues.Contains(str);
|
||||
}
|
||||
}
|
||||
}
|
84
Torch.API/WebAPI/JenkinsQuery.cs
Normal file
84
Torch.API/WebAPI/JenkinsQuery.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Torch.API.Utils;
|
||||
using Version = SemanticVersioning.Version;
|
||||
|
||||
namespace Torch.API.WebAPI
|
||||
{
|
||||
public class JenkinsQuery
|
||||
{
|
||||
private const string BRANCH_QUERY = "http://136.243.80.164:2690/job/Torch/job/{0}/" + API_PATH;
|
||||
private const string ARTIFACT_PATH = "artifact/bin/torch-server.zip";
|
||||
private const string API_PATH = "api/json";
|
||||
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static JenkinsQuery _instance;
|
||||
public static JenkinsQuery Instance => _instance ??= new JenkinsQuery();
|
||||
private HttpClient _client;
|
||||
|
||||
private JenkinsQuery()
|
||||
{
|
||||
_client = new HttpClient();
|
||||
}
|
||||
|
||||
public async Task<Job> GetLatestVersion(string branch)
|
||||
{
|
||||
var h = await _client.GetAsync(string.Format(BRANCH_QUERY, branch));
|
||||
if (!h.IsSuccessStatusCode)
|
||||
{
|
||||
Log.Error($"'{branch}' Branch query failed with code {h.StatusCode}");
|
||||
if(h.StatusCode == HttpStatusCode.NotFound)
|
||||
Log.Error("This likely means you're trying to update a branch that is not public on Jenkins. Sorry :(");
|
||||
return null;
|
||||
}
|
||||
|
||||
var branchResponse = await h.Content.ReadFromJsonAsync<BranchResponse>();
|
||||
|
||||
if (branchResponse is null)
|
||||
{
|
||||
Log.Error("Error reading branch response");
|
||||
return null;
|
||||
}
|
||||
|
||||
h = await _client.GetAsync($"{branchResponse.LastStableBuild.Url}{API_PATH}");
|
||||
if (h.IsSuccessStatusCode)
|
||||
return await h.Content.ReadFromJsonAsync<Job>();
|
||||
|
||||
Log.Error($"Job query failed with code {h.StatusCode}");
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadRelease(Job job, string path)
|
||||
{
|
||||
var h = await _client.GetAsync(job.Url + ARTIFACT_PATH);
|
||||
if (!h.IsSuccessStatusCode)
|
||||
{
|
||||
Log.Error($"Job download failed with code {h.StatusCode}");
|
||||
return false;
|
||||
}
|
||||
var s = await h.Content.ReadAsStreamAsync();
|
||||
await using var fs = new FileStream(path, FileMode.Create);
|
||||
await s.CopyToAsync(fs);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public record BranchResponse(string Name, string Url, Build LastBuild, Build LastStableBuild);
|
||||
|
||||
public record Build(int Number, string Url);
|
||||
|
||||
public record Job(int Number, bool Building, string Description, string Result, string Url,
|
||||
[property: JsonConverter(typeof(SemanticVersionConverter))] Version Version);
|
||||
}
|
104
Torch.API/WebAPI/PluginQuery.cs
Normal file
104
Torch.API/WebAPI/PluginQuery.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
|
||||
namespace Torch.API.WebAPI
|
||||
{
|
||||
public class PluginQuery
|
||||
{
|
||||
private const string ALL_QUERY = "https://torchapi.com/api/plugins/";
|
||||
private const string PLUGIN_QUERY = "https://torchapi.com/api/plugins/?guid={0}";
|
||||
private readonly HttpClient _client;
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static PluginQuery _instance;
|
||||
public static PluginQuery Instance => _instance ??= new();
|
||||
|
||||
private PluginQuery()
|
||||
{
|
||||
_client = new();
|
||||
}
|
||||
|
||||
public async Task<PluginsResponse> QueryAll()
|
||||
{
|
||||
return (PluginsResponse) await _client.GetFromJsonAsync(ALL_QUERY, typeof(PluginsResponse), CancellationToken.None);
|
||||
}
|
||||
|
||||
public Task<PluginItem> QueryOne(Guid guid)
|
||||
{
|
||||
return QueryOne(guid.ToString());
|
||||
}
|
||||
|
||||
public async Task<PluginItem> QueryOne(string guid)
|
||||
{
|
||||
using var res = await _client.GetAsync(string.Format(PLUGIN_QUERY, guid));
|
||||
if (!res.IsSuccessStatusCode)
|
||||
return null;
|
||||
return await res.Content.ReadFromJsonAsync<PluginItem>();
|
||||
}
|
||||
|
||||
public Task<bool> DownloadPlugin(Guid guid, string path = null)
|
||||
{
|
||||
return DownloadPlugin(guid.ToString(), path);
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPlugin(string guid, string path = null)
|
||||
{
|
||||
var item = await QueryOne(guid);
|
||||
if (item is null) return false;
|
||||
return await DownloadPlugin(item, path);
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPlugin(PluginItem item, string path = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
path ??= Path.Combine(Directory.GetCurrentDirectory(), "Plugins", $"{item.Name}.zip");
|
||||
|
||||
if (item.Versions.Length == 0)
|
||||
{
|
||||
Log.Error($"Selected plugin {item.Name} does not have any versions to download!");
|
||||
return false;
|
||||
}
|
||||
var version = item.Versions.FirstOrDefault(v => v.Version == item.LatestVersion);
|
||||
if (version is null)
|
||||
{
|
||||
Log.Error($"Could not find latest version for selected plugin {item.Name}");
|
||||
return false;
|
||||
}
|
||||
var s = await _client.GetStreamAsync(version.Url);
|
||||
|
||||
if(File.Exists(path))
|
||||
File.Delete(path);
|
||||
|
||||
await using var f = File.Create(path);
|
||||
await s.CopyToAsync(f);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Failed to download plugin!");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public record PluginsResponse(PluginItem[] Plugins);
|
||||
|
||||
public record PluginItem(Guid Id, string Name, string Author, string Description, string LatestVersion,
|
||||
VersionItem[] Versions)
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool Installed { get; set; }
|
||||
}
|
||||
|
||||
public record VersionItem(string Version, string Note, [property: JsonPropertyName("is_beta")] bool IsBeta,
|
||||
string Url);
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Mono.TextTransform" version="1.0.0" targetFramework="net461" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net461" />
|
||||
</packages>
|
@@ -1,96 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{632E78C0-0DAC-4B71-B411-2F1B333CC310}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Torch.Client.Tests</RootNamespace>
|
||||
<AssemblyName>Torch.Client.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<NoWarn>1591,0649</NoWarn>
|
||||
<AssemblyTitle>Torch Client Tests</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
<Copyright>Copyright © Torch API 2017</Copyright>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<OutputPath>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>$(SolutionDir)\bin-test\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>$(SolutionDir)\bin-test\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>$(SolutionDir)\bin-test\x64\Release\Torch.Client.Tests.xml</DocumentationFile>
|
||||
<DocumentationFile>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\Torch.Client.Tests.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.TextTransform" Version="1.0.0" />
|
||||
<PackageReference Include="NLog" Version="4.4.12" />
|
||||
<PackageReference Include="xunit" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.abstractions" Version="2.0.1" />
|
||||
<PackageReference Include="xunit.assert" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.core" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.extensibility.core" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.runner.console" Version="2.2.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.4.12\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs">
|
||||
<Link>Properties\AssemblyVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TorchClientReflectionTest.cs" />
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs" Link="Properties\AssemblyVersion.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj">
|
||||
<Project>{fba5d932-6254-4a1e-baf4-e229fa94e3c2}</Project>
|
||||
<Name>Torch.API</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch.Client\Torch.Client.csproj">
|
||||
<Project>{e36df745-260b-4956-a2e8-09f08b2e7161}</Project>
|
||||
<Name>Torch.Client</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch.Tests\Torch.Tests.csproj">
|
||||
<Project>{c3c8b671-6ad1-44aa-a8da-e0c0dc0fedf5}</Project>
|
||||
<Name>Torch.Tests</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch\Torch.csproj">
|
||||
<Project>{7e01635c-3b67-472e-bcd6-c5539564f214}</Project>
|
||||
<Name>Torch</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj" />
|
||||
<ProjectReference Include="..\Torch.Client\Torch.Client.csproj" />
|
||||
<ProjectReference Include="..\Torch.Tests\Torch.Tests.csproj" />
|
||||
<ProjectReference Include="..\Torch\Torch.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<Compile Remove="obj\x64\Debug\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" />
|
||||
<Compile Remove="obj\x64\Release\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
|
||||
</Project>
|
11
Torch.Client.Tests/app.config
Normal file
11
Torch.Client.Tests/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Mono.TextTransform" version="1.0.0" targetFramework="net461" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net461" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net461" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.runner.console" version="2.2.0" targetFramework="net461" developmentDependency="true" />
|
||||
</packages>
|
@@ -4,9 +4,11 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Game.World;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Managers;
|
||||
using VRage.Game.ModAPI;
|
||||
|
||||
namespace Torch.Client.Manager
|
||||
{
|
||||
@@ -24,9 +26,58 @@ namespace Torch.Client.Manager
|
||||
/// <inheritdoc />
|
||||
public void BanPlayer(ulong steamId, bool banned = true) => Torch.Invoke(() => MyMultiplayer.Static.BanClient(steamId, banned));
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PromoteUser(ulong steamId)
|
||||
{
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
var p = MySession.Static.GetUserPromoteLevel(steamId);
|
||||
if (p < MyPromoteLevel.Admin) //cannot promote to owner by design
|
||||
MySession.Static.SetUserPromoteLevel(steamId, p + 1);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void DemoteUser(ulong steamId)
|
||||
{
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
var p = MySession.Static.GetUserPromoteLevel(steamId);
|
||||
if (p > MyPromoteLevel.None && p < MyPromoteLevel.Owner) //owner cannot be demoted by design
|
||||
MySession.Static.SetUserPromoteLevel(steamId, p - 1);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public MyPromoteLevel GetUserPromoteLevel(ulong steamId)
|
||||
{
|
||||
return MySession.Static.GetUserPromoteLevel(steamId);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsBanned(ulong steamId) => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<ulong> PlayerKicked
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<ulong, bool> PlayerBanned
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<ulong, MyPromoteLevel> PlayerPromoted
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Attach()
|
||||
{
|
||||
|
@@ -18,6 +18,7 @@ namespace Torch.Client
|
||||
{
|
||||
public const string SpaceEngineersBinaries = "Bin64";
|
||||
private static string _spaceEngInstallAlias = null;
|
||||
|
||||
public static string SpaceEngineersInstallAlias
|
||||
{
|
||||
get
|
||||
@@ -26,7 +27,8 @@ namespace Torch.Client
|
||||
if (_spaceEngInstallAlias == null)
|
||||
{
|
||||
// ReSharper disable once AssignNullToNotNullAttribute
|
||||
_spaceEngInstallAlias = Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "SpaceEngineersAlias");
|
||||
_spaceEngInstallAlias = Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location),
|
||||
"SpaceEngineersAlias");
|
||||
}
|
||||
return _spaceEngInstallAlias;
|
||||
}
|
||||
@@ -52,16 +54,20 @@ namespace Torch.Client
|
||||
{
|
||||
AllocConsole();
|
||||
#endif
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
|
||||
// Early config: Resolve SE install directory.
|
||||
if (!File.Exists(Path.Combine(SpaceEngineersInstallAlias, _spaceEngineersVerifyFile)))
|
||||
SetupSpaceEngInstallAlias();
|
||||
|
||||
using (new TorchAssemblyResolver(Path.Combine(SpaceEngineersInstallAlias, SpaceEngineersBinaries)))
|
||||
if (!TorchLauncher.IsTorchWrapped())
|
||||
{
|
||||
RunClient();
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
|
||||
// Early config: Resolve SE install directory.
|
||||
if (!File.Exists(Path.Combine(SpaceEngineersInstallAlias, _spaceEngineersVerifyFile)))
|
||||
SetupSpaceEngInstallAlias();
|
||||
|
||||
TorchLauncher.Launch(Assembly.GetEntryAssembly().FullName, args,
|
||||
Path.Combine(SpaceEngineersInstallAlias, SpaceEngineersBinaries));
|
||||
return;
|
||||
}
|
||||
|
||||
RunClient();
|
||||
#if DEBUG
|
||||
}
|
||||
finally
|
||||
@@ -77,7 +83,8 @@ namespace Torch.Client
|
||||
|
||||
// TODO look at Steam/config/Config.VDF? Has alternate directories.
|
||||
var steamDir =
|
||||
Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Valve\\Steam", "SteamPath", null) as string;
|
||||
Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Valve\\Steam", "SteamPath",
|
||||
null) as string;
|
||||
if (steamDir != null)
|
||||
{
|
||||
spaceEngineersDirectory = Path.Combine(steamDir, _steamSpaceEngineersDirectory);
|
||||
@@ -85,7 +92,10 @@ namespace Torch.Client
|
||||
if (File.Exists(Path.Combine(spaceEngineersDirectory, _spaceEngineersVerifyFile)))
|
||||
_log.Debug("Found Space Engineers in {0}", spaceEngineersDirectory);
|
||||
else
|
||||
{
|
||||
_log.Debug("Couldn't find Space Engineers in {0}", spaceEngineersDirectory);
|
||||
spaceEngineersDirectory = null;
|
||||
}
|
||||
}
|
||||
if (spaceEngineersDirectory == null)
|
||||
{
|
||||
@@ -97,7 +107,8 @@ namespace Torch.Client
|
||||
{
|
||||
if (dialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
var ex = new FileNotFoundException("Unable to find the Space Engineers install directory, aborting");
|
||||
var ex = new FileNotFoundException(
|
||||
"Unable to find the Space Engineers install directory, aborting");
|
||||
_log.Fatal(ex);
|
||||
LogManager.Flush();
|
||||
throw ex;
|
||||
@@ -109,11 +120,12 @@ namespace Torch.Client
|
||||
$"Unable to find {0} in {1}. Are you sure it's the Space Engineers install directory?",
|
||||
"Invalid Space Engineers Directory", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
break;
|
||||
} while (true); // Repeat until they confirm.
|
||||
} while (true); // Repeat until they confirm.
|
||||
}
|
||||
if (!JunctionLink(SpaceEngineersInstallAlias, spaceEngineersDirectory))
|
||||
{
|
||||
var ex = new IOException($"Failed to create junction link {SpaceEngineersInstallAlias} => {spaceEngineersDirectory}. Aborting.");
|
||||
var ex = new IOException(
|
||||
$"Failed to create junction link {SpaceEngineersInstallAlias} => {spaceEngineersDirectory}. Aborting.");
|
||||
_log.Fatal(ex);
|
||||
LogManager.Flush();
|
||||
throw ex;
|
||||
@@ -121,7 +133,8 @@ namespace Torch.Client
|
||||
string junctionVerify = Path.Combine(SpaceEngineersInstallAlias, _spaceEngineersVerifyFile);
|
||||
if (!File.Exists(junctionVerify))
|
||||
{
|
||||
var ex = new FileNotFoundException($"Junction link is not working. File {junctionVerify} does not exist");
|
||||
var ex = new FileNotFoundException(
|
||||
$"Junction link is not working. File {junctionVerify} does not exist");
|
||||
_log.Fatal(ex);
|
||||
LogManager.Flush();
|
||||
throw ex;
|
||||
@@ -153,7 +166,7 @@ namespace Torch.Client
|
||||
|
||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
var ex = (Exception)e.ExceptionObject;
|
||||
var ex = (Exception) e.ExceptionObject;
|
||||
_log.Error(ex);
|
||||
LogManager.Flush();
|
||||
MessageBox.Show(ex.StackTrace, ex.Message);
|
||||
|
@@ -1,80 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{E36DF745-260B-4956-A2E8-09F08B2E7161}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Torch.Client</RootNamespace>
|
||||
<AssemblyName>Torch.Client</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<AssemblyTitle>Torch Client</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
<Copyright>Copyright © Torch API 2017</Copyright>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<OutputPath>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseWPF>true</UseWPF>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>$(SolutionDir)\bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>$(SolutionDir)\bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<DocumentationFile>$(SolutionDir)\bin\x64\Release\Torch.Client.xml</DocumentationFile>
|
||||
<DocumentationFile>$(SolutionDir)\bin\$(Platform)\$(Configuration)\Torch.Client.xml</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>torchicon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.TextTransform" Version="1.0.0" />
|
||||
<PackageReference Include="NLog" Version="4.4.12" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.4.12\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\Sandbox.Common.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Game">
|
||||
<HintPath>..\GameBinaries\Sandbox.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Graphics, Version=0.1.6108.20417, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\Sandbox.Graphics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.Game">
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="VRage">
|
||||
<HintPath>..\GameBinaries\VRage.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
@@ -88,18 +76,18 @@
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Input, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Input.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Library">
|
||||
<HintPath>..\GameBinaries\VRage.Library.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Math, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Math.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render">
|
||||
<HintPath>..\GameBinaries\VRage.Render.dll</HintPath>
|
||||
@@ -118,64 +106,17 @@
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs">
|
||||
<Link>Properties\AssemblyVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Manager\MultiplayerManagerClient.cs" />
|
||||
<Compile Include="Manager\MultiplayerManagerLobby.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TorchClient.cs" />
|
||||
<Compile Include="TorchClientConfig.cs" />
|
||||
<Compile Include="TorchConsoleScreen.cs" />
|
||||
<Compile Include="TorchSettingsScreen.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="UI\TorchMainMenuScreen.cs" />
|
||||
<Compile Include="UI\TorchNavScreen.cs" />
|
||||
<Compile Include="UI\TorchSettingsScreen.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs" Link="Properties\AssemblyVersion.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj">
|
||||
<Project>{fba5d932-6254-4a1e-baf4-e229fa94e3c2}</Project>
|
||||
<Name>Torch.API</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch\Torch.csproj">
|
||||
<Project>{7E01635C-3B67-472E-BCD6-C5539564F214}</Project>
|
||||
<Name>Torch</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj" />
|
||||
<ProjectReference Include="..\Torch\Torch.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="torchicon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
<Compile Remove="obj\x64\Debug\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" />
|
||||
<Compile Remove="obj\x64\Release\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@@ -26,22 +26,19 @@ namespace Torch.Client
|
||||
{
|
||||
public class TorchClient : TorchBase, ITorchClient
|
||||
{
|
||||
private MyCommonProgramStartup _startup;
|
||||
private IMyRender _renderer;
|
||||
|
||||
protected override uint SteamAppId => 244850;
|
||||
protected override string SteamAppName => "Space Engineers";
|
||||
protected override string SteamAppName => "SpaceEngineers";
|
||||
|
||||
public TorchClient()
|
||||
{
|
||||
Config = new TorchClientConfig();
|
||||
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
||||
sessionManager.AddFactory((x) => MyMultiplayer.Static is MyMultiplayerLobby
|
||||
? new MultiplayerManagerLobby(this)
|
||||
: null);
|
||||
? new MultiplayerManagerLobby(this)
|
||||
: null);
|
||||
sessionManager.AddFactory((x) => MyMultiplayer.Static is MyMultiplayerClientBase
|
||||
? new MultiplayerManagerClient(this)
|
||||
: null);
|
||||
? new MultiplayerManagerClient(this)
|
||||
: null);
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
@@ -49,38 +46,22 @@ namespace Torch.Client
|
||||
Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias);
|
||||
MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries);
|
||||
Log.Info("Initializing Torch Client");
|
||||
_startup = new MyCommonProgramStartup(RunArgs);
|
||||
SpaceEngineersGame.SetupBasicGameInfo();
|
||||
SpaceEngineersGame.SetupPerGameSettings();
|
||||
if (_startup.PerformReporting())
|
||||
throw new InvalidOperationException("Torch client won't launch when started in error reporting mode");
|
||||
|
||||
_startup.PerformAutoconnect();
|
||||
if (!_startup.CheckSingleInstance())
|
||||
throw new InvalidOperationException("Only one instance of Space Engineers can be running at a time.");
|
||||
|
||||
var appDataPath = _startup.GetAppDataPath();
|
||||
Config.InstancePath = appDataPath;
|
||||
Config.InstancePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
SteamAppName);
|
||||
base.Init();
|
||||
OverrideMenus();
|
||||
SetRenderWindowTitle($"Space Engineers v{GameVersion} with Torch v{TorchVersion}");
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
_startup.DetectSharpDxLeaksAfterRun();
|
||||
}
|
||||
|
||||
private void OverrideMenus()
|
||||
{
|
||||
var credits = new MyCreditsDepartment("Torch Developed By")
|
||||
{
|
||||
Persons = new List<MyCreditsPerson>
|
||||
{
|
||||
new MyCreditsPerson("THE TORCH TEAM"),
|
||||
new MyCreditsPerson("http://github.com/TorchSE"),
|
||||
}
|
||||
{
|
||||
new MyCreditsPerson("THE TORCH TEAM"),
|
||||
new MyCreditsPerson("http://github.com/TorchSE"),
|
||||
}
|
||||
};
|
||||
MyPerGameSettings.Credits.Departments.Insert(0, credits);
|
||||
|
||||
@@ -96,12 +77,11 @@ namespace Torch.Client
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (renderWindowField == null)
|
||||
return;
|
||||
var window = renderWindowField.GetValue(MySandboxGame.Static.GameRenderComponent.RenderThread) as System.Windows.Forms.Form;
|
||||
var window =
|
||||
renderWindowField.GetValue(MySandboxGame.Static.GameRenderComponent.RenderThread) as
|
||||
System.Windows.Forms.Form;
|
||||
if (window != null)
|
||||
renderThread.Invoke(() =>
|
||||
{
|
||||
window.Text = title;
|
||||
});
|
||||
renderThread.Invoke(() => { window.Text = title; });
|
||||
}
|
||||
|
||||
public override void Restart()
|
||||
@@ -109,4 +89,4 @@ namespace Torch.Client
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -23,6 +23,8 @@ namespace Torch.Client
|
||||
public bool NoGui { get; set; } = false;
|
||||
public bool RestartOnCrash { get; set; } = false;
|
||||
public string WaitForPID { get; set; } = null;
|
||||
public string ChatName { get; set; }
|
||||
public string ChatColor { get; set; }
|
||||
|
||||
public bool Save(string path = null)
|
||||
{
|
||||
|
11
Torch.Client/app.config
Normal file
11
Torch.Client/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Mono.TextTransform" version="1.0.0" targetFramework="net461" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net461" />
|
||||
</packages>
|
72
Torch.Mod/Messages/DialogMessage.cs
Normal file
72
Torch.Mod/Messages/DialogMessage.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProtoBuf;
|
||||
using Sandbox.ModAPI;
|
||||
|
||||
namespace Torch.Mod.Messages
|
||||
{
|
||||
/// Dialogs are structured as follows
|
||||
///
|
||||
/// _____________________________________
|
||||
/// | Title |
|
||||
/// --------------------------------------
|
||||
/// | Prefix Subtitle |
|
||||
/// --------------------------------------
|
||||
/// | ________________________________ |
|
||||
/// | | Content | |
|
||||
/// | --------------------------------- |
|
||||
/// | ____________ |
|
||||
/// | | ButtonText | |
|
||||
/// | -------------- |
|
||||
/// --------------------------------------
|
||||
///
|
||||
/// Button has a callback on click option,
|
||||
/// but can't serialize that, so ¯\_(ツ)_/¯
|
||||
[ProtoContract]
|
||||
public class DialogMessage : MessageBase
|
||||
{
|
||||
[ProtoMember(201)]
|
||||
public string Title;
|
||||
[ProtoMember(202)]
|
||||
public string Subtitle;
|
||||
[ProtoMember(203)]
|
||||
public string Prefix;
|
||||
[ProtoMember(204)]
|
||||
public string Content;
|
||||
[ProtoMember(205)]
|
||||
public string ButtonText;
|
||||
|
||||
public DialogMessage()
|
||||
{ }
|
||||
|
||||
public DialogMessage(string title, string subtitle, string content)
|
||||
{
|
||||
Title = title;
|
||||
Subtitle = subtitle;
|
||||
Content = content;
|
||||
Prefix = String.Empty;
|
||||
}
|
||||
|
||||
public DialogMessage(string title = null, string prefix = null, string subtitle = null, string content = null, string buttonText = null)
|
||||
{
|
||||
Title = title;
|
||||
Subtitle = subtitle;
|
||||
Prefix = prefix ?? String.Empty;
|
||||
Content = content;
|
||||
ButtonText = buttonText;
|
||||
}
|
||||
|
||||
public override void ProcessClient()
|
||||
{
|
||||
MyAPIGateway.Utilities.ShowMissionScreen(Title, Prefix, Subtitle, Content, null, ButtonText);
|
||||
}
|
||||
|
||||
public override void ProcessServer()
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
26
Torch.Mod/Messages/IncomingMessage.cs
Normal file
26
Torch.Mod/Messages/IncomingMessage.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Torch.Mod.Messages
|
||||
{
|
||||
/// <summary>
|
||||
/// shim to store incoming message data
|
||||
/// </summary>
|
||||
internal class IncomingMessage : MessageBase
|
||||
{
|
||||
public IncomingMessage()
|
||||
{
|
||||
}
|
||||
|
||||
public override void ProcessClient()
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public override void ProcessServer()
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
57
Torch.Mod/Messages/JoinServerMessage.cs
Normal file
57
Torch.Mod/Messages/JoinServerMessage.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ProtoBuf;
|
||||
using Sandbox.ModAPI;
|
||||
|
||||
namespace Torch.Mod.Messages
|
||||
{
|
||||
[ProtoContract]
|
||||
public class JoinServerMessage : MessageBase
|
||||
{
|
||||
[ProtoMember(201)]
|
||||
public int Delay;
|
||||
[ProtoMember(202)]
|
||||
public string Address;
|
||||
|
||||
private JoinServerMessage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public JoinServerMessage(string address)
|
||||
{
|
||||
Address = address;
|
||||
}
|
||||
|
||||
public JoinServerMessage(string address, int delay)
|
||||
{
|
||||
Address = address;
|
||||
Delay = delay;
|
||||
}
|
||||
|
||||
public override void ProcessClient()
|
||||
{
|
||||
if (TorchModCore.Debug)
|
||||
{
|
||||
MyAPIGateway.Utilities.ShowMessage("Torch", $"Joining server {Address} with delay {Delay}");
|
||||
}
|
||||
|
||||
if (Delay <= 0)
|
||||
{
|
||||
MyAPIGateway.Multiplayer.JoinServer(Address);
|
||||
return;
|
||||
}
|
||||
|
||||
MyAPIGateway.Parallel.StartBackground(() =>
|
||||
{
|
||||
MyAPIGateway.Parallel.Sleep(Delay);
|
||||
MyAPIGateway.Multiplayer.JoinServer(Address);
|
||||
});
|
||||
}
|
||||
|
||||
public override void ProcessServer()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
52
Torch.Mod/Messages/MessageBase.cs
Normal file
52
Torch.Mod/Messages/MessageBase.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Torch.Mod.Messages
|
||||
{
|
||||
#region Includes
|
||||
[ProtoInclude(1, typeof(DialogMessage))]
|
||||
[ProtoInclude(2, typeof(NotificationMessage))]
|
||||
[ProtoInclude(3, typeof(VoxelResetMessage))]
|
||||
[ProtoInclude(4, typeof(JoinServerMessage))]
|
||||
#endregion
|
||||
|
||||
[ProtoContract]
|
||||
public abstract class MessageBase
|
||||
{
|
||||
[ProtoMember(101)]
|
||||
public ulong SenderId;
|
||||
|
||||
public abstract void ProcessClient();
|
||||
public abstract void ProcessServer();
|
||||
|
||||
//members below not serialized, they're just metadata about the intended target(s) of this message
|
||||
internal MessageTarget TargetType;
|
||||
internal ulong Target;
|
||||
internal ulong[] Ignore;
|
||||
internal byte[] CompressedData;
|
||||
}
|
||||
|
||||
public enum MessageTarget
|
||||
{
|
||||
/// <summary>
|
||||
/// Send to Target
|
||||
/// </summary>
|
||||
Single,
|
||||
/// <summary>
|
||||
/// Send to Server
|
||||
/// </summary>
|
||||
Server,
|
||||
/// <summary>
|
||||
/// Send to all Clients (only valid from server)
|
||||
/// </summary>
|
||||
AllClients,
|
||||
/// <summary>
|
||||
/// Send to all except those steam ID listed in Ignore
|
||||
/// </summary>
|
||||
AllExcept,
|
||||
}
|
||||
}
|
39
Torch.Mod/Messages/NotificationMessage.cs
Normal file
39
Torch.Mod/Messages/NotificationMessage.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ProtoBuf;
|
||||
using Sandbox.ModAPI;
|
||||
|
||||
namespace Torch.Mod.Messages
|
||||
{
|
||||
[ProtoContract]
|
||||
public class NotificationMessage : MessageBase
|
||||
{
|
||||
[ProtoMember(201)]
|
||||
public string Message;
|
||||
[ProtoMember(202)]
|
||||
public string Font;
|
||||
[ProtoMember(203)]
|
||||
public int DisappearTimeMs;
|
||||
|
||||
public NotificationMessage()
|
||||
{ }
|
||||
|
||||
public NotificationMessage(string message, int disappearTimeMs, string font)
|
||||
{
|
||||
Message = message;
|
||||
DisappearTimeMs = disappearTimeMs;
|
||||
Font = font;
|
||||
}
|
||||
|
||||
public override void ProcessClient()
|
||||
{
|
||||
MyAPIGateway.Utilities.ShowNotification(Message, DisappearTimeMs, Font);
|
||||
}
|
||||
|
||||
public override void ProcessServer()
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
44
Torch.Mod/Messages/VoxelResetMessage.cs
Normal file
44
Torch.Mod/Messages/VoxelResetMessage.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ProtoBuf;
|
||||
using Sandbox.ModAPI;
|
||||
using VRage.ModAPI;
|
||||
using VRage.Voxels;
|
||||
|
||||
namespace Torch.Mod.Messages
|
||||
{
|
||||
[ProtoContract]
|
||||
public class VoxelResetMessage : MessageBase
|
||||
{
|
||||
[ProtoMember(201)]
|
||||
public long[] EntityId;
|
||||
|
||||
public VoxelResetMessage()
|
||||
{ }
|
||||
|
||||
public VoxelResetMessage(long[] entityId)
|
||||
{
|
||||
EntityId = entityId;
|
||||
}
|
||||
|
||||
public override void ProcessClient()
|
||||
{
|
||||
//MyAPIGateway.Parallel.ForEach(EntityId, id =>
|
||||
foreach (var id in EntityId)
|
||||
{
|
||||
IMyEntity e;
|
||||
if (!MyAPIGateway.Entities.TryGetEntityById(id, out e))
|
||||
continue;
|
||||
|
||||
var v = e as IMyVoxelBase;
|
||||
v?.Storage.Reset(MyStorageDataTypeFlags.All);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ProcessServer()
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
208
Torch.Mod/ModCommunication.cs
Normal file
208
Torch.Mod/ModCommunication.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.ModAPI;
|
||||
using Torch.Mod.Messages;
|
||||
using VRage;
|
||||
using VRage.Collections;
|
||||
using VRage.Game.ModAPI;
|
||||
using VRage.Network;
|
||||
using VRage.Utils;
|
||||
using Task = ParallelTasks.Task;
|
||||
|
||||
namespace Torch.Mod
|
||||
{
|
||||
public static class ModCommunication
|
||||
{
|
||||
public const ushort NET_ID = 4352;
|
||||
private static bool _closing = false;
|
||||
private static BlockingCollection<MessageBase> _processing;
|
||||
private static MyConcurrentPool<IncomingMessage> _messagePool;
|
||||
private static List<IMyPlayer> _playerCache;
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
MyLog.Default.WriteLineAndConsole("TORCH MOD: Registering mod communication.");
|
||||
_processing = new BlockingCollection<MessageBase>(new ConcurrentQueue<MessageBase>());
|
||||
_playerCache = new List<IMyPlayer>();
|
||||
_messagePool = new MyConcurrentPool<IncomingMessage>(8);
|
||||
|
||||
MyAPIGateway.Multiplayer.RegisterMessageHandler(NET_ID, MessageHandler);
|
||||
//background thread to handle de/compression and processing
|
||||
_closing = false;
|
||||
MyAPIGateway.Parallel.StartBackground(DoProcessing);
|
||||
MyLog.Default.WriteLineAndConsole("TORCH MOD: Mod communication registered successfully.");
|
||||
}
|
||||
|
||||
public static void Unregister()
|
||||
{
|
||||
MyLog.Default.WriteLineAndConsole("TORCH MOD: Unregistering mod communication.");
|
||||
MyAPIGateway.Multiplayer?.UnregisterMessageHandler(NET_ID, MessageHandler);
|
||||
_processing?.CompleteAdding();
|
||||
_closing = true;
|
||||
//_task.Wait();
|
||||
}
|
||||
|
||||
private static void MessageHandler(byte[] bytes)
|
||||
{
|
||||
var m = _messagePool.Get();
|
||||
m.CompressedData = bytes;
|
||||
#if TORCH
|
||||
m.SenderId = MyEventContext.Current.Sender.Value;
|
||||
#endif
|
||||
|
||||
_processing.Add(m);
|
||||
}
|
||||
|
||||
public static void DoProcessing()
|
||||
{
|
||||
while (!_closing)
|
||||
{
|
||||
try
|
||||
{
|
||||
MessageBase m;
|
||||
try
|
||||
{
|
||||
m = _processing.Take();
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
MyLog.Default.WriteLineAndConsole($"Processing message: {m.GetType().Name}");
|
||||
|
||||
if (m is IncomingMessage) //process incoming messages
|
||||
{
|
||||
MessageBase i;
|
||||
try
|
||||
{
|
||||
var o = MyCompression.Decompress(m.CompressedData);
|
||||
m.CompressedData = null;
|
||||
_messagePool.Return((IncomingMessage)m);
|
||||
i = MyAPIGateway.Utilities.SerializeFromBinary<MessageBase>(o);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MyLog.Default.WriteLineAndConsole($"TORCH MOD: Failed to deserialize message! {ex}");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (TorchModCore.Debug)
|
||||
MyAPIGateway.Utilities.ShowMessage("Torch", $"Received message of type {i.GetType().Name}");
|
||||
|
||||
if (MyAPIGateway.Multiplayer.IsServer)
|
||||
i.ProcessServer();
|
||||
else
|
||||
i.ProcessClient();
|
||||
}
|
||||
else //process outgoing messages
|
||||
{
|
||||
if (TorchModCore.Debug)
|
||||
MyAPIGateway.Utilities.ShowMessage("Torch", $"Sending message of type {m.GetType().Name}");
|
||||
|
||||
var b = MyAPIGateway.Utilities.SerializeToBinary(m);
|
||||
m.CompressedData = MyCompression.Compress(b);
|
||||
|
||||
switch (m.TargetType)
|
||||
{
|
||||
case MessageTarget.Single:
|
||||
MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, m.Target);
|
||||
break;
|
||||
case MessageTarget.Server:
|
||||
MyAPIGateway.Multiplayer.SendMessageToServer(NET_ID, m.CompressedData);
|
||||
break;
|
||||
case MessageTarget.AllClients:
|
||||
MyAPIGateway.Players.GetPlayers(_playerCache);
|
||||
foreach (var p in _playerCache)
|
||||
{
|
||||
if (p.SteamUserId == MyAPIGateway.Multiplayer.MyId)
|
||||
continue;
|
||||
MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, p.SteamUserId);
|
||||
}
|
||||
|
||||
break;
|
||||
case MessageTarget.AllExcept:
|
||||
MyAPIGateway.Players.GetPlayers(_playerCache);
|
||||
foreach (var p in _playerCache)
|
||||
{
|
||||
if (p.SteamUserId == MyAPIGateway.Multiplayer.MyId || m.Ignore.Contains(p.SteamUserId))
|
||||
continue;
|
||||
MyAPIGateway.Multiplayer.SendMessageTo(NET_ID, m.CompressedData, p.SteamUserId);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
_playerCache.Clear();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MyLog.Default.WriteLineAndConsole($"TORCH MOD: Exception occurred in communication thread! {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
MyLog.Default.WriteLineAndConsole("TORCH MOD: INFO: Communication thread shut down successfully! THIS IS NOT AN ERROR");
|
||||
//exit signal received. Clean everything and GTFO
|
||||
_processing?.Dispose();
|
||||
_processing = null;
|
||||
_messagePool?.Clean();
|
||||
_messagePool = null;
|
||||
_playerCache = null;
|
||||
}
|
||||
|
||||
public static void SendMessageTo(MessageBase message, ulong target)
|
||||
{
|
||||
if (!MyAPIGateway.Multiplayer.IsServer)
|
||||
throw new Exception("Only server can send targeted messages");
|
||||
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
message.Target = target;
|
||||
message.TargetType = MessageTarget.Single;
|
||||
_processing.Add(message);
|
||||
}
|
||||
|
||||
public static void SendMessageToClients(MessageBase message)
|
||||
{
|
||||
if (!MyAPIGateway.Multiplayer.IsServer)
|
||||
throw new Exception("Only server can send targeted messages");
|
||||
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
message.TargetType = MessageTarget.AllClients;
|
||||
_processing.Add(message);
|
||||
}
|
||||
|
||||
public static void SendMessageExcept(MessageBase message, params ulong[] ignoredUsers)
|
||||
{
|
||||
if (!MyAPIGateway.Multiplayer.IsServer)
|
||||
throw new Exception("Only server can send targeted messages");
|
||||
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
message.TargetType = MessageTarget.AllExcept;
|
||||
message.Ignore = ignoredUsers;
|
||||
_processing.Add(message);
|
||||
}
|
||||
|
||||
public static void SendMessageToServer(MessageBase message)
|
||||
{
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
message.TargetType = MessageTarget.Server;
|
||||
_processing.Add(message);
|
||||
}
|
||||
}
|
||||
}
|
21
Torch.Mod/Torch.Mod.projitems
Normal file
21
Torch.Mod/Torch.Mod.projitems
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>3ce4d2e9-b461-4f19-8233-f87e0dfddd74</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>Torch.Mod</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\IncomingMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\JoinServerMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\NotificationMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\DialogMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\MessageBase.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\VoxelResetMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ModCommunication.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)TorchModCore.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
12
Torch.Mod/Torch.Mod.shproj
Normal file
12
Torch.Mod/Torch.Mod.shproj
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>3ce4d2e9-b461-4f19-8233-f87e0dfddd74</ProjectGuid>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
<Import Project="Torch.Mod.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
51
Torch.Mod/TorchModCore.cs
Normal file
51
Torch.Mod/TorchModCore.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.ModAPI;
|
||||
using VRage.Game.Components;
|
||||
|
||||
namespace Torch.Mod
|
||||
{
|
||||
[MySessionComponentDescriptor(MyUpdateOrder.AfterSimulation)]
|
||||
public class TorchModCore : MySessionComponentBase
|
||||
{
|
||||
public const ulong MOD_ID = 2722000298;
|
||||
private static bool _init;
|
||||
public static bool Debug;
|
||||
|
||||
public override void UpdateAfterSimulation()
|
||||
{
|
||||
if (_init)
|
||||
return;
|
||||
|
||||
_init = true;
|
||||
ModCommunication.Register();
|
||||
MyAPIGateway.Utilities.MessageEntered += Utilities_MessageEntered;
|
||||
}
|
||||
|
||||
private void Utilities_MessageEntered(string messageText, ref bool sendToOthers)
|
||||
{
|
||||
if (messageText == "@!debug")
|
||||
{
|
||||
Debug = !Debug;
|
||||
MyAPIGateway.Utilities.ShowMessage("Torch", $"Debug: {Debug}");
|
||||
sendToOthers = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UnloadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
MyAPIGateway.Utilities.MessageEntered -= Utilities_MessageEntered;
|
||||
ModCommunication.Unregister();
|
||||
}
|
||||
catch
|
||||
{
|
||||
//session unloading, don't care
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,93 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{9EFD1D91-2FA2-47ED-B537-D8BC3B0E543E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Torch.Server.Tests</RootNamespace>
|
||||
<AssemblyName>Torch.Server.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<TargetFramework>net6-windows</TargetFramework>
|
||||
<NoWarn>1591,0649</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>$(SolutionDir)\bin-test\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<AssemblyTitle>Torch Server Tests</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
<Copyright>Copyright © Torch API 2017</Copyright>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>$(SolutionDir)\bin-test\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<OutputPath>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>$(SolutionDir)\bin-test\x64\Release\Torch.Server.Tests.xml</DocumentationFile>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(Configuration) == 'Release'">
|
||||
<DocumentationFile>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\Torch.Server.Tests.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<!-- <Import Project="$(SolutionDir)\TransformOnBuild.targets" /> -->
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.4.12\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.0.0-rc2" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="VRage.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\GameBinaries\VRage.Game.dll</HintPath>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs">
|
||||
<Link>Properties\AssemblyVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TorchServerReflectionTest.cs" />
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs" Link="Properties\AssemblyVersion.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj">
|
||||
<Project>{fba5d932-6254-4a1e-baf4-e229fa94e3c2}</Project>
|
||||
<Name>Torch.API</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch.Server\Torch.Server.csproj">
|
||||
<Project>{ca50886b-7b22-4cd8-93a0-c06f38d4f77d}</Project>
|
||||
<Name>Torch.Server</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch.Tests\Torch.Tests.csproj">
|
||||
<Project>{c3c8b671-6ad1-44aa-a8da-e0c0dc0fedf5}</Project>
|
||||
<Name>Torch.Tests</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch\Torch.csproj">
|
||||
<Project>{7e01635c-3b67-472e-bcd6-c5539564f214}</Project>
|
||||
<Name>Torch</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj" />
|
||||
<ProjectReference Include="..\Torch.Server\Torch.Server.csproj" />
|
||||
<ProjectReference Include="..\Torch.Tests\Torch.Tests.csproj" />
|
||||
<ProjectReference Include="..\Torch\Torch.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
|
||||
</Project>
|
@@ -6,6 +6,7 @@ using Xunit;
|
||||
|
||||
namespace Torch.Server.Tests
|
||||
{
|
||||
#warning Disabled reflection tests because of seemingly random failures
|
||||
public class TorchServerReflectionTest
|
||||
{
|
||||
static TorchServerReflectionTest()
|
||||
@@ -34,7 +35,7 @@ namespace Torch.Server.Tests
|
||||
public static IEnumerable<object[]> Events => Manager().Events;
|
||||
|
||||
#region Binding
|
||||
[Theory]
|
||||
//[Theory]
|
||||
[MemberData(nameof(Getters))]
|
||||
public void TestBindingGetter(ReflectionTestManager.FieldRef field)
|
||||
{
|
||||
@@ -45,7 +46,7 @@ namespace Torch.Server.Tests
|
||||
Assert.NotNull(field.Field.GetValue(null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
//[Theory]
|
||||
[MemberData(nameof(Setters))]
|
||||
public void TestBindingSetter(ReflectionTestManager.FieldRef field)
|
||||
{
|
||||
@@ -56,7 +57,7 @@ namespace Torch.Server.Tests
|
||||
Assert.NotNull(field.Field.GetValue(null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
//[Theory]
|
||||
[MemberData(nameof(Invokers))]
|
||||
public void TestBindingInvoker(ReflectionTestManager.FieldRef field)
|
||||
{
|
||||
@@ -67,7 +68,7 @@ namespace Torch.Server.Tests
|
||||
Assert.NotNull(field.Field.GetValue(null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
//[Theory]
|
||||
[MemberData(nameof(Events))]
|
||||
public void TestBindingEvents(ReflectionTestManager.FieldRef field)
|
||||
{
|
||||
|
34
Torch.Server.Tests/TorchServerSessionSettingsTest.cs
Normal file
34
Torch.Server.Tests/TorchServerSessionSettingsTest.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Torch.Server.ViewModels;
|
||||
using VRage.Game;
|
||||
using Xunit;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Torch.Server.Tests
|
||||
{
|
||||
public class TorchServerSessionSettingsTest
|
||||
{
|
||||
public static PropertyInfo[] ViewModelProperties = typeof(SessionSettingsViewModel).GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||
public static IEnumerable<object[]> ModelFields = typeof(MyObjectBuilder_SessionSettings).GetFields(BindingFlags.Public | BindingFlags.Instance).Select(x => new object[] { x });
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(ModelFields))]
|
||||
public void MissingPropertyTest(FieldInfo modelField)
|
||||
{
|
||||
// Ignore fields that aren't applicable to SE
|
||||
if (modelField.GetCustomAttribute<GameRelationAttribute>()?.RelatedTo == Game.MedievalEngineers)
|
||||
return;
|
||||
|
||||
if (string.IsNullOrEmpty(modelField.GetCustomAttribute<DisplayAttribute>()?.Name))
|
||||
return;
|
||||
|
||||
var match = ViewModelProperties.FirstOrDefault(p => p.Name.Equals(modelField.Name, StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.NotNull(match);
|
||||
}
|
||||
}
|
||||
}
|
11
Torch.Server.Tests/app.config
Normal file
11
Torch.Server.Tests/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Mono.TextTransform" version="1.0.0" targetFramework="net461" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net461" />
|
||||
<package id="xunit" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net461" />
|
||||
<package id="xunit.assert" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.core" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net461" />
|
||||
<package id="xunit.runner.console" version="2.2.0" targetFramework="net461" developmentDependency="true" />
|
||||
</packages>
|
66
Torch.Server/Commands/WhitelistCommands.cs
Normal file
66
Torch.Server/Commands/WhitelistCommands.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Torch.Commands;
|
||||
|
||||
namespace Torch.Server.Commands
|
||||
{
|
||||
[Category("whitelist")]
|
||||
public class WhitelistCommands : CommandModule
|
||||
{
|
||||
private TorchConfig Config => (TorchConfig)Context.Torch.Config;
|
||||
|
||||
[Command("on", "Enables the whitelist.")]
|
||||
public void On()
|
||||
{
|
||||
if (!Config.EnableWhitelist)
|
||||
{
|
||||
Config.EnableWhitelist = true;
|
||||
Context.Respond("Whitelist enabled.");
|
||||
Config.Save();
|
||||
}
|
||||
else
|
||||
Context.Respond("Whitelist is already enabled.");
|
||||
}
|
||||
|
||||
[Command("off", "Disables the whitelist")]
|
||||
public void Off()
|
||||
{
|
||||
if (Config.EnableWhitelist)
|
||||
{
|
||||
Config.EnableWhitelist = false;
|
||||
Context.Respond("Whitelist disabled.");
|
||||
Config.Save();
|
||||
}
|
||||
else
|
||||
Context.Respond("Whitelist is already disabled.");
|
||||
}
|
||||
|
||||
[Command("add", "Add a Steam ID to the whitelist.")]
|
||||
public void Add(ulong steamId)
|
||||
{
|
||||
if (!Config.Whitelist.Contains(steamId))
|
||||
{
|
||||
Config.Whitelist.Add(steamId);
|
||||
Context.Respond($"Added {steamId} to the whitelist.");
|
||||
Config.Save();
|
||||
}
|
||||
else
|
||||
Context.Respond($"{steamId} is already whitelisted.");
|
||||
}
|
||||
|
||||
[Command("remove", "Remove a Steam ID from the whitelist.")]
|
||||
public void Remove(ulong steamId)
|
||||
{
|
||||
if (Config.Whitelist.Remove(steamId))
|
||||
{
|
||||
Context.Respond($"Removed {steamId} from the whitelist.");
|
||||
Config.Save();
|
||||
}
|
||||
else
|
||||
Context.Respond($"{steamId} is not whitelisted.");
|
||||
}
|
||||
}
|
||||
}
|
3
Torch.Server/FodyWeavers.xml
Normal file
3
Torch.Server/FodyWeavers.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<PropertyChanged />
|
||||
</Weavers>
|
74
Torch.Server/FodyWeavers.xsd
Normal file
74
Torch.Server/FodyWeavers.xsd
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
|
||||
<xs:element name="Weavers">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="PropertyChanged" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="InjectOnPropertyNameChanged" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to control if the IsChanged property feature is enabled.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="EventInvokerNames" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="CheckForEquality" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="CheckForEqualityUsingBaseEquals" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="UseStaticEqualsFromBase" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="SuppressWarnings" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="GenerateXsd" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
@@ -5,62 +5,70 @@ using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
using Sandbox.Engine.Utils;
|
||||
using Torch.Utils;
|
||||
using VRage.FileSystem;
|
||||
|
||||
namespace Torch.Server
|
||||
{
|
||||
public class Initializer
|
||||
{
|
||||
internal static Initializer Instance { get; private set; }
|
||||
|
||||
private static readonly Logger Log = LogManager.GetLogger(nameof(Initializer));
|
||||
private bool _init;
|
||||
private const string STEAMCMD_DIR = "steamcmd";
|
||||
private const string STEAMCMD_ZIP = "temp.zip";
|
||||
private static readonly string STEAMCMD_PATH = $"{STEAMCMD_DIR}\\steamcmd.exe";
|
||||
private static readonly string RUNSCRIPT_PATH = $"{STEAMCMD_DIR}\\runscript.txt";
|
||||
private static readonly string STEAMCMD_EXE = "steamcmd.exe";
|
||||
private static readonly string RUNSCRIPT_FILE = "runscript.txt";
|
||||
|
||||
private const string RUNSCRIPT = @"force_install_dir ../
|
||||
login anonymous
|
||||
app_update 298740
|
||||
quit";
|
||||
|
||||
private TorchConfig _config;
|
||||
private TorchServer _server;
|
||||
private string _basePath;
|
||||
|
||||
public TorchConfig Config => _config;
|
||||
internal Persistent<TorchConfig> ConfigPersistent { get; }
|
||||
public TorchConfig Config => ConfigPersistent?.Data;
|
||||
public TorchServer Server => _server;
|
||||
|
||||
public Initializer(string basePath)
|
||||
public Initializer(string basePath, Persistent<TorchConfig> torchConfig)
|
||||
{
|
||||
_basePath = basePath;
|
||||
Instance = this;
|
||||
ConfigPersistent = torchConfig;
|
||||
}
|
||||
|
||||
public bool Initialize(string[] args)
|
||||
{
|
||||
if (_init)
|
||||
return false;
|
||||
|
||||
#if !DEBUG
|
||||
AppDomain.CurrentDomain.UnhandledException += HandleException;
|
||||
#if DEBUG
|
||||
//enables logging debug messages when built in debug mode. Amazing.
|
||||
LogManager.Configuration.AddRule(LogLevel.Debug, LogLevel.Debug, "main");
|
||||
LogManager.Configuration.AddRule(LogLevel.Debug, LogLevel.Debug, "console");
|
||||
LogManager.Configuration.AddRule(LogLevel.Debug, LogLevel.Debug, "wpf");
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
Log.Debug("Debug logging enabled.");
|
||||
#endif
|
||||
|
||||
if (!args.Contains("-noupdate"))
|
||||
// This is what happens when Keen is bad and puts extensions into the System namespace.
|
||||
if (!Enumerable.Contains(args, "-noupdate"))
|
||||
RunSteamCmd();
|
||||
|
||||
_config = InitConfig();
|
||||
if (!_config.Parse(args))
|
||||
return false;
|
||||
|
||||
if (!string.IsNullOrEmpty(_config.WaitForPID))
|
||||
if (!string.IsNullOrEmpty(Config.WaitForPID))
|
||||
{
|
||||
try
|
||||
{
|
||||
var pid = int.Parse(_config.WaitForPID);
|
||||
var pid = int.Parse(Config.WaitForPID);
|
||||
var waitProc = Process.GetProcessById(pid);
|
||||
Log.Info("Continuing in 5 seconds.");
|
||||
Log.Warn($"Waiting for process {pid} to close");
|
||||
@@ -69,11 +77,10 @@ quit";
|
||||
Console.Write(".");
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
// ignored
|
||||
Log.Warn(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,81 +88,93 @@ quit";
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
public void Run(bool isService, string instanceName, string instancePath)
|
||||
{
|
||||
_server = new TorchServer(_config);
|
||||
_server.Init();
|
||||
_server = new TorchServer(Config, instancePath, instanceName);
|
||||
|
||||
if (!_config.NoGui)
|
||||
if (isService || Config.NoGui)
|
||||
{
|
||||
_server.Init();
|
||||
_server.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !DEBUG
|
||||
if (!Config.IndependentConsole)
|
||||
{
|
||||
Console.SetOut(TextWriter.Null);
|
||||
NativeMethods.FreeConsole();
|
||||
}
|
||||
#endif
|
||||
|
||||
var gameThread = new Thread(() =>
|
||||
{
|
||||
_server.Init();
|
||||
|
||||
if (Config.Autostart || Config.TempAutostart)
|
||||
{
|
||||
Config.TempAutostart = false;
|
||||
_server.Start();
|
||||
}
|
||||
});
|
||||
|
||||
gameThread.Start();
|
||||
|
||||
var ui = new TorchUI(_server);
|
||||
if (_config.Autostart)
|
||||
_server.Start();
|
||||
|
||||
SynchronizationContext.SetSynchronizationContext(
|
||||
new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
|
||||
|
||||
ui.ShowDialog();
|
||||
}
|
||||
else
|
||||
_server.Start();
|
||||
}
|
||||
|
||||
private TorchConfig InitConfig()
|
||||
{
|
||||
var configName = "Torch.cfg";
|
||||
var configPath = Path.Combine(Directory.GetCurrentDirectory(), configName);
|
||||
if (File.Exists(configName))
|
||||
{
|
||||
Log.Info($"Loading config {configPath}");
|
||||
return TorchConfig.LoadFrom(configPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info($"Generating default config at {configPath}");
|
||||
var config = new TorchConfig { InstancePath = Path.GetFullPath("Instance") };
|
||||
config.Save(configPath);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
private static void RunSteamCmd()
|
||||
|
||||
public static void RunSteamCmd()
|
||||
{
|
||||
var log = LogManager.GetLogger("SteamCMD");
|
||||
|
||||
if (!Directory.Exists(STEAMCMD_DIR))
|
||||
var path = Environment.GetEnvironmentVariable("TORCH_STEAMCMD") ?? Path.GetFullPath(STEAMCMD_DIR);
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(STEAMCMD_DIR);
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
if (!File.Exists(RUNSCRIPT_PATH))
|
||||
File.WriteAllText(RUNSCRIPT_PATH, RUNSCRIPT);
|
||||
var runScriptPath = Path.Combine(path, RUNSCRIPT_FILE);
|
||||
if (!File.Exists(runScriptPath))
|
||||
File.WriteAllText(runScriptPath, RUNSCRIPT);
|
||||
|
||||
if (!File.Exists(STEAMCMD_PATH))
|
||||
var steamCmdExePath = Path.Combine(path, STEAMCMD_EXE);
|
||||
if (!File.Exists(steamCmdExePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
log.Info("Downloading SteamCMD.");
|
||||
using (var client = new WebClient())
|
||||
client.DownloadFile("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip", STEAMCMD_ZIP);
|
||||
using (var client = new HttpClient())
|
||||
using (var file = File.Create(STEAMCMD_ZIP))
|
||||
client.GetStreamAsync("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip").Result.CopyTo(file);
|
||||
|
||||
ZipFile.ExtractToDirectory(STEAMCMD_ZIP, STEAMCMD_DIR);
|
||||
ZipFile.ExtractToDirectory(STEAMCMD_ZIP, path);
|
||||
File.Delete(STEAMCMD_ZIP);
|
||||
log.Info("SteamCMD downloaded successfully!");
|
||||
}
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
log.Error("Failed to download SteamCMD, unable to update the DS.");
|
||||
log.Error(e, "Failed to download SteamCMD, unable to update the DS.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log.Info("Checking for DS updates.");
|
||||
var steamCmdProc = new ProcessStartInfo(STEAMCMD_PATH, "+runscript runscript.txt")
|
||||
var steamCmdProc = new ProcessStartInfo(steamCmdExePath, "+runscript runscript.txt")
|
||||
{
|
||||
WorkingDirectory = Path.Combine(Directory.GetCurrentDirectory(), STEAMCMD_DIR),
|
||||
WorkingDirectory = path,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
StandardOutputEncoding = Encoding.ASCII
|
||||
};
|
||||
var cmd = Process.Start(steamCmdProc);
|
||||
|
||||
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
while (!cmd.HasExited)
|
||||
{
|
||||
@@ -163,34 +182,5 @@ quit";
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
private void LogException(Exception ex)
|
||||
{
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
LogException(ex.InnerException);
|
||||
}
|
||||
Log.Fatal(ex);
|
||||
if (ex is ReflectionTypeLoadException exti)
|
||||
foreach (Exception exl in exti.LoaderExceptions)
|
||||
LogException(exl);
|
||||
|
||||
}
|
||||
|
||||
private void HandleException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
var ex = (Exception)e.ExceptionObject;
|
||||
LogException(ex);
|
||||
Console.WriteLine("Exiting in 5 seconds.");
|
||||
Thread.Sleep(5000);
|
||||
LogManager.Flush();
|
||||
if (_config.RestartOnCrash)
|
||||
{
|
||||
var exe = typeof(Program).Assembly.Location;
|
||||
_config.WaitForPID = Process.GetCurrentProcess().Id.ToString();
|
||||
Process.Start(exe, _config.ToString());
|
||||
}
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
51
Torch.Server/LogViewerTarget.cs
Normal file
51
Torch.Server/LogViewerTarget.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
using Torch.Server.ViewModels;
|
||||
using Torch.Server.Views;
|
||||
|
||||
namespace Torch.Server
|
||||
{
|
||||
/// <summary>
|
||||
/// NLog target that writes to a <see cref="LogViewerControl"/>.
|
||||
/// </summary>
|
||||
[Target("logViewer")]
|
||||
public sealed class LogViewerTarget : TargetWithLayout
|
||||
{
|
||||
public IList<LogEntry> LogEntries { get; set; }
|
||||
public SynchronizationContext TargetContext { get; set; }
|
||||
private readonly int _maxLines = 1000;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Write(LogEventInfo logEvent)
|
||||
{
|
||||
TargetContext?.Post(_sendOrPostCallback, logEvent);
|
||||
}
|
||||
|
||||
private void WriteCallback(object state)
|
||||
{
|
||||
var logEvent = (LogEventInfo) state;
|
||||
LogEntries?.Add(new(logEvent.TimeStamp, Layout.Render(logEvent), LogLevelColors[logEvent.Level]));
|
||||
}
|
||||
|
||||
private static readonly Dictionary<LogLevel, SolidColorBrush> LogLevelColors = new()
|
||||
{
|
||||
[LogLevel.Trace] = new SolidColorBrush(Colors.DimGray),
|
||||
[LogLevel.Debug] = new SolidColorBrush(Colors.DarkGray),
|
||||
[LogLevel.Info] = new SolidColorBrush(Colors.White),
|
||||
[LogLevel.Warn] = new SolidColorBrush(Colors.Magenta),
|
||||
[LogLevel.Error] = new SolidColorBrush(Colors.Yellow),
|
||||
[LogLevel.Fatal] = new SolidColorBrush(Colors.Red),
|
||||
};
|
||||
|
||||
private readonly SendOrPostCallback _sendOrPostCallback;
|
||||
|
||||
public LogViewerTarget()
|
||||
{
|
||||
_sendOrPostCallback = WriteCallback;
|
||||
}
|
||||
}
|
||||
}
|
@@ -40,15 +40,7 @@ namespace Torch.Server.Managers
|
||||
|
||||
protected abstract EntityControlViewModel Create(EntityViewModel evm);
|
||||
|
||||
#pragma warning disable 649
|
||||
[ReflectedGetter(Name = "Keys")]
|
||||
private static readonly Func<ConditionalWeakTable<EntityViewModel, EntityControlViewModel>, ICollection<EntityViewModel>> _weakTableKeys;
|
||||
#pragma warning restore 649
|
||||
|
||||
/// <summary>
|
||||
/// Warning: Creates a giant list, avoid if possible.
|
||||
/// </summary>
|
||||
internal ICollection<EntityViewModel> Keys => _weakTableKeys(_models);
|
||||
internal IEnumerable<EntityViewModel> Keys => _models.Select(b => b.Key);
|
||||
|
||||
internal EntityControlViewModel GetOrCreate(EntityViewModel evm)
|
||||
{
|
||||
|
@@ -1,40 +1,59 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Havok;
|
||||
using NLog;
|
||||
using Sandbox;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Sandbox.Engine.Utils;
|
||||
using Sandbox.Game;
|
||||
using Sandbox.Game.Gui;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Collections;
|
||||
using Torch.Managers;
|
||||
using Torch.Mod;
|
||||
using Torch.Server.ViewModels;
|
||||
using Torch.Utils;
|
||||
using VRage;
|
||||
using VRage.FileSystem;
|
||||
using VRage.Game;
|
||||
using VRage.Game.ObjectBuilder;
|
||||
using VRage.ObjectBuilders;
|
||||
using VRage.Plugins;
|
||||
|
||||
namespace Torch.Server.Managers
|
||||
{
|
||||
public class InstanceManager : Manager
|
||||
public class InstanceManager : Manager, IInstanceManager
|
||||
{
|
||||
private const string CONFIG_NAME = "SpaceEngineers-Dedicated.cfg";
|
||||
|
||||
public event Action<ConfigDedicatedViewModel> InstanceLoaded;
|
||||
public ConfigDedicatedViewModel DedicatedConfig { get; set; }
|
||||
private static readonly Logger Log = LogManager.GetLogger(nameof(InstanceManager));
|
||||
[Dependency]
|
||||
private FilesystemManager _filesystemManager;
|
||||
|
||||
public InstanceManager(ITorchBase torchInstance) : base(torchInstance)
|
||||
private new ITorchServer Torch { get; }
|
||||
|
||||
public InstanceManager(ITorchServer torchInstance) : base(torchInstance)
|
||||
{
|
||||
|
||||
Torch = torchInstance;
|
||||
}
|
||||
|
||||
|
||||
public IWorld SelectedWorld => DedicatedConfig.SelectedWorld;
|
||||
|
||||
public void LoadInstance(string path, bool validate = true)
|
||||
{
|
||||
Log.Info($"Loading instance {path}");
|
||||
|
||||
if (validate)
|
||||
ValidateInstance(path);
|
||||
|
||||
@@ -43,44 +62,131 @@ namespace Torch.Server.Managers
|
||||
//Initializes saves path. Why this isn't in Init() we may never know.
|
||||
MyFileSystem.InitUserSpecific(null);
|
||||
|
||||
var configPath = Path.Combine(path, CONFIG_NAME);
|
||||
if (!File.Exists(configPath))
|
||||
{
|
||||
Log.Error($"Failed to load dedicated config at {path}");
|
||||
return;
|
||||
}
|
||||
// why?....
|
||||
// var configPath = Path.Combine(path, CONFIG_NAME);
|
||||
// if (!File.Exists(configPath))
|
||||
// {
|
||||
// Log.Error($"Failed to load dedicated config at {path}");
|
||||
// return;
|
||||
// }
|
||||
|
||||
var config = new MyConfigDedicated<MyObjectBuilder_SessionSettings>(configPath);
|
||||
config.Load(configPath);
|
||||
|
||||
// var config = new MyConfigDedicated<MyObjectBuilder_SessionSettings>(configPath);
|
||||
// config.Load(configPath);
|
||||
|
||||
DedicatedConfig = new ConfigDedicatedViewModel(config);
|
||||
var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));
|
||||
DedicatedConfig = new ConfigDedicatedViewModel((MyConfigDedicated<MyObjectBuilder_SessionSettings>) MySandboxGame.ConfigDedicated);
|
||||
|
||||
var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.InstancePath, "Saves"));
|
||||
|
||||
foreach (var f in worldFolders)
|
||||
DedicatedConfig.WorldPaths.Add(f);
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(f) && File.Exists(Path.Combine(f, "Sandbox.sbc")))
|
||||
{
|
||||
var worldViewModel = new WorldViewModel(f, DedicatedConfig.LoadWorld == f);
|
||||
DedicatedConfig.Worlds.Add(worldViewModel);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Failed to load world at path: " + f);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (DedicatedConfig.WorldPaths.Count == 0)
|
||||
if (DedicatedConfig.Worlds.Count == 0)
|
||||
{
|
||||
Log.Warn($"No worlds found in the current instance {path}.");
|
||||
return;
|
||||
}
|
||||
|
||||
ImportWorldConfig();
|
||||
SelectWorld(DedicatedConfig.LoadWorld ?? DedicatedConfig.Worlds.First().WorldPath, false);
|
||||
|
||||
/*
|
||||
if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
|
||||
InstanceLoaded?.Invoke(DedicatedConfig);
|
||||
}
|
||||
|
||||
public void SelectCreatedWorld(string worldPath)
|
||||
{
|
||||
WorldViewModel worldViewModel;
|
||||
try
|
||||
{
|
||||
Log.Warn("No world specified, importing first available world.");
|
||||
SelectWorld(DedicatedConfig.WorldPaths[0], false);
|
||||
}*/
|
||||
worldViewModel = new(worldPath);
|
||||
DedicatedConfig.Worlds.Add(worldViewModel);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Failed to load world at path: " + worldPath);
|
||||
return;
|
||||
}
|
||||
SelectWorld(worldViewModel, false);
|
||||
}
|
||||
|
||||
public void SelectWorld(string worldPath, bool modsOnly = true)
|
||||
{
|
||||
DedicatedConfig.LoadWorld = worldPath;
|
||||
ImportWorldConfig(modsOnly);
|
||||
|
||||
var worldInfo = DedicatedConfig.Worlds.FirstOrDefault(x => x.WorldPath == worldPath);
|
||||
try
|
||||
{
|
||||
if (worldInfo?.Checkpoint == null)
|
||||
{
|
||||
worldInfo = new WorldViewModel(worldPath);
|
||||
DedicatedConfig.Worlds.Add(worldInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Failed to load world at path: " + worldPath);
|
||||
DedicatedConfig.LoadWorld = null;
|
||||
return;
|
||||
}
|
||||
|
||||
DedicatedConfig.SelectedWorld = worldInfo;
|
||||
if (DedicatedConfig.SelectedWorld?.Checkpoint != null)
|
||||
{
|
||||
DedicatedConfig.Mods.Clear();
|
||||
//remove the Torch mod to avoid running multiple copies of it
|
||||
DedicatedConfig.SelectedWorld.WorldConfiguration.Mods.RemoveAll(m => m.PublishedFileId == TorchModCore.MOD_ID);
|
||||
foreach (var m in DedicatedConfig.SelectedWorld.WorldConfiguration.Mods)
|
||||
DedicatedConfig.Mods.Add(new ModItemInfo(m));
|
||||
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectWorld(WorldViewModel world, bool modsOnly = true)
|
||||
{
|
||||
DedicatedConfig.LoadWorld = world.WorldPath;
|
||||
DedicatedConfig.SelectedWorld = world;
|
||||
if (DedicatedConfig.SelectedWorld?.Checkpoint != null)
|
||||
{
|
||||
DedicatedConfig.Mods.Clear();
|
||||
//remove the Torch mod to avoid running multiple copies of it
|
||||
DedicatedConfig.SelectedWorld.WorldConfiguration.Mods.RemoveAll(m => m.PublishedFileId == TorchModCore.MOD_ID);
|
||||
foreach (var m in DedicatedConfig.SelectedWorld.WorldConfiguration.Mods)
|
||||
DedicatedConfig.Mods.Add(new ModItemInfo(m));
|
||||
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
|
||||
}
|
||||
}
|
||||
|
||||
public void ImportSelectedWorldConfig()
|
||||
{
|
||||
ImportWorldConfig(DedicatedConfig.SelectedWorld, false);
|
||||
}
|
||||
|
||||
private void ImportWorldConfig(WorldViewModel world, bool modsOnly = true)
|
||||
{
|
||||
var mods = new MtObservableList<ModItemInfo>();
|
||||
foreach (var mod in world.WorldConfiguration.Mods)
|
||||
mods.Add(new ModItemInfo(mod));
|
||||
DedicatedConfig.Mods = mods;
|
||||
|
||||
|
||||
Log.Debug("Loaded mod list from world");
|
||||
|
||||
if (!modsOnly)
|
||||
DedicatedConfig.SessionSettings = world.WorldConfiguration.Settings;
|
||||
}
|
||||
|
||||
private void ImportWorldConfig(bool modsOnly = true)
|
||||
{
|
||||
@@ -97,15 +203,14 @@ namespace Torch.Server.Managers
|
||||
MyObjectBuilderSerializer.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
|
||||
if (checkpoint == null)
|
||||
{
|
||||
Log.Error($"Failed to load {DedicatedConfig.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {TorchBase.Instance.Config.InstancePath})");
|
||||
Log.Error($"Failed to load {DedicatedConfig.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {Torch.Config.InstancePath})");
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
var mods = new MtObservableList<ModItemInfo>();
|
||||
foreach (var mod in checkpoint.Mods)
|
||||
sb.AppendLine(mod.PublishedFileId.ToString());
|
||||
|
||||
DedicatedConfig.Mods = sb.ToString();
|
||||
mods.Add(new ModItemInfo(mod));
|
||||
DedicatedConfig.Mods = mods;
|
||||
|
||||
Log.Debug("Loaded mod list from world");
|
||||
|
||||
@@ -121,28 +226,38 @@ namespace Torch.Server.Managers
|
||||
|
||||
public void SaveConfig()
|
||||
{
|
||||
DedicatedConfig.Save(Path.Combine(Torch.Config.InstancePath, CONFIG_NAME));
|
||||
Log.Info("Saved dedicated config.");
|
||||
if (!((TorchServer)Torch).HasRun)
|
||||
{
|
||||
DedicatedConfig.Save(Path.Combine(Torch.InstancePath, CONFIG_NAME));
|
||||
Log.Info("Saved dedicated config.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
MyObjectBuilderSerializer.DeserializeXML(Path.Combine(DedicatedConfig.LoadWorld, "Sandbox.sbc"), out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
|
||||
if (checkpoint == null)
|
||||
{
|
||||
Log.Error($"Failed to load {DedicatedConfig.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {TorchBase.Instance.Config.InstancePath})");
|
||||
return;
|
||||
}
|
||||
checkpoint.Settings = DedicatedConfig.SessionSettings;
|
||||
checkpoint.Mods.Clear();
|
||||
foreach (var modId in DedicatedConfig.Model.Mods)
|
||||
checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId));
|
||||
var world = DedicatedConfig.Worlds.FirstOrDefault(x => x.WorldPath == DedicatedConfig.LoadWorld) ?? new WorldViewModel(DedicatedConfig.LoadWorld);
|
||||
|
||||
world.Checkpoint.SessionName = DedicatedConfig.WorldName;
|
||||
world.WorldConfiguration.Settings = DedicatedConfig.SessionSettings;
|
||||
world.WorldConfiguration.Mods.Clear();
|
||||
|
||||
foreach (var mod in DedicatedConfig.Mods)
|
||||
{
|
||||
var savedMod = ModItemUtils.Create(mod.PublishedFileId);
|
||||
savedMod.IsDependency = mod.IsDependency;
|
||||
savedMod.Name = mod.Name;
|
||||
savedMod.FriendlyName = mod.FriendlyName;
|
||||
|
||||
world.WorldConfiguration.Mods.Add(savedMod);
|
||||
}
|
||||
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
|
||||
|
||||
world.SaveSandbox();
|
||||
|
||||
MyLocalCache.SaveCheckpoint(checkpoint, DedicatedConfig.LoadWorld);
|
||||
Log.Info("Saved world config.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error("Failed to write sandbox config, changes will not appear on server");
|
||||
Log.Error("Failed to write sandbox config");
|
||||
Log.Error(e);
|
||||
}
|
||||
}
|
||||
@@ -162,4 +277,84 @@ namespace Torch.Server.Managers
|
||||
config.Save(configPath);
|
||||
}
|
||||
}
|
||||
|
||||
public class WorldViewModel : ViewModel, IWorld
|
||||
{
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public string FolderName { get; set; }
|
||||
public string WorldPath { get; }
|
||||
public MyObjectBuilder_SessionSettings KeenSessionSettings => WorldConfiguration.Settings;
|
||||
public MyObjectBuilder_Checkpoint KeenCheckpoint => Checkpoint;
|
||||
public long WorldSizeKB { get; }
|
||||
private string _checkpointPath;
|
||||
private string _worldConfigPath;
|
||||
private CheckpointViewModel _checkpoint;
|
||||
|
||||
public CheckpointViewModel Checkpoint
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_checkpoint is null) LoadSandbox();
|
||||
return _checkpoint;
|
||||
}
|
||||
private set => _checkpoint = value;
|
||||
}
|
||||
|
||||
public WorldConfigurationViewModel WorldConfiguration { get; private set; }
|
||||
|
||||
public WorldViewModel(string worldPath, bool loadFiles = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldPath = worldPath;
|
||||
WorldSizeKB = new DirectoryInfo(worldPath).GetFiles().Sum(x => x.Length) / 1024;
|
||||
_checkpointPath = Path.Combine(WorldPath, "Sandbox.sbc");
|
||||
_worldConfigPath = Path.Combine(WorldPath, "Sandbox_config.sbc");
|
||||
FolderName = Path.GetFileName(worldPath);
|
||||
if (loadFiles)
|
||||
LoadSandbox();
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
Log.Error($"World view model failed to load the path: {worldPath} Please ensure this is a valid path.");
|
||||
throw; //rethrow to be handled further up the stack
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveSandbox()
|
||||
{
|
||||
using (var f = File.Open(_checkpointPath, FileMode.Create))
|
||||
MyObjectBuilderSerializer.SerializeXML(f, Checkpoint);
|
||||
|
||||
using (var f = File.Open(_worldConfigPath, FileMode.Create))
|
||||
MyObjectBuilderSerializer.SerializeXML(f, WorldConfiguration);
|
||||
}
|
||||
|
||||
public void LoadSandbox()
|
||||
{
|
||||
if (!MyObjectBuilderSerializer.DeserializeXML(_checkpointPath, out MyObjectBuilder_Checkpoint checkpoint))
|
||||
throw new SerializationException("Error reading checkpoint, see keen log for details");
|
||||
Checkpoint = new CheckpointViewModel(checkpoint);
|
||||
|
||||
// migrate old saves
|
||||
if (File.Exists(_worldConfigPath))
|
||||
{
|
||||
if (!MyObjectBuilderSerializer.DeserializeXML(_worldConfigPath, out MyObjectBuilder_WorldConfiguration worldConfig))
|
||||
throw new SerializationException("Error reading settings, see keen log for details");
|
||||
WorldConfiguration = new WorldConfigurationViewModel(worldConfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldConfiguration = new WorldConfigurationViewModel(new MyObjectBuilder_WorldConfiguration
|
||||
{
|
||||
Mods = checkpoint.Mods,
|
||||
Settings = checkpoint.Settings
|
||||
});
|
||||
|
||||
checkpoint.Mods = null;
|
||||
checkpoint.Settings = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,11 +10,16 @@ using NLog.Fluent;
|
||||
using Sandbox;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Sandbox.Game.Gui;
|
||||
using Sandbox.Game.World;
|
||||
using Steamworks;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Managers;
|
||||
using Torch.Utils;
|
||||
using Torch.ViewModels;
|
||||
using VRage.Game;
|
||||
using VRage.Game.ModAPI;
|
||||
using VRage.GameServices;
|
||||
using VRage.Network;
|
||||
using VRage.Steam;
|
||||
@@ -25,7 +31,9 @@ namespace Torch.Server.Managers
|
||||
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#pragma warning disable 649
|
||||
[ReflectedGetter(Name = "m_members")] private static Func<MyDedicatedServerBase, List<ulong>> _members;
|
||||
[ReflectedGetter(Name = "m_members")]
|
||||
private static Func<MyDedicatedServerBase, List<ulong>> _members;
|
||||
|
||||
[ReflectedGetter(Name = "m_waitingForGroup")]
|
||||
private static Func<MyDedicatedServerBase, HashSet<ulong>> _waitingForGroup;
|
||||
#pragma warning restore 649
|
||||
@@ -35,6 +43,9 @@ namespace Torch.Server.Managers
|
||||
|
||||
private Dictionary<ulong, ulong> _gameOwnerIds = new Dictionary<ulong, ulong>();
|
||||
|
||||
[Dependency]
|
||||
private InstanceManager _instanceManager;
|
||||
|
||||
/// <inheritdoc />
|
||||
public MultiplayerManagerDedicated(ITorchBase torch) : base(torch)
|
||||
{
|
||||
@@ -49,26 +60,95 @@ namespace Torch.Server.Managers
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
MyMultiplayer.Static.BanClient(steamId, banned);
|
||||
if (_gameOwnerIds.ContainsKey(steamId))
|
||||
MyMultiplayer.Static.BanClient(_gameOwnerIds[steamId], banned);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PromoteUser(ulong steamId)
|
||||
{
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
var p = MySession.Static.GetUserPromoteLevel(steamId);
|
||||
if (p < MyPromoteLevel.Admin) //cannot promote to owner by design
|
||||
//MySession.Static.SetUserPromoteLevel(steamId, p + 1);
|
||||
MyGuiScreenPlayers.PromoteImplementation(steamId, true);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void DemoteUser(ulong steamId)
|
||||
{
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
var p = MySession.Static.GetUserPromoteLevel(steamId);
|
||||
if (p > MyPromoteLevel.None && p < MyPromoteLevel.Owner) //owner cannot be demoted by design
|
||||
//MySession.Static.SetUserPromoteLevel(steamId, p - 1);
|
||||
MyGuiScreenPlayers.PromoteImplementation(steamId, false);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public MyPromoteLevel GetUserPromoteLevel(ulong steamId)
|
||||
{
|
||||
return MySession.Static.GetUserPromoteLevel(steamId);
|
||||
}
|
||||
|
||||
internal void RaiseClientBanned(ulong user, bool banned)
|
||||
{
|
||||
PlayerBanned?.Invoke(user, banned);
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
if(_gameOwnerIds.TryGetValue(user, out ulong owner))
|
||||
MyMultiplayer.Static.BanClient(owner, banned);
|
||||
});
|
||||
}
|
||||
|
||||
internal void RaiseClientKicked(ulong user)
|
||||
{
|
||||
PlayerKicked?.Invoke(user);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsBanned(ulong steamId) => _isClientBanned.Invoke(MyMultiplayer.Static, steamId) ||
|
||||
MySandboxGame.ConfigDedicated.Banned.Contains(steamId);
|
||||
|
||||
|
||||
|
||||
public bool IsProfiling(ulong steamId) => _Profiling.Invoke((MyDedicatedServerBase)MyMultiplayer.Static, steamId);
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<ulong> PlayerKicked;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<ulong, bool> PlayerBanned;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<ulong, MyPromoteLevel> PlayerPromoted;
|
||||
|
||||
internal void RaisePromoteChanged(ulong steamId, MyPromoteLevel level)
|
||||
{
|
||||
PlayerPromoted?.Invoke(steamId, level);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Attach()
|
||||
{
|
||||
base.Attach();
|
||||
_gameServerValidateAuthTicketReplacer = _gameServerValidateAuthTicketFactory.Invoke();
|
||||
_gameServerUserGroupStatusReplacer = _gameServerUserGroupStatusFactory.Invoke();
|
||||
if (Torch.Config.UgcServiceType == UGCServiceType.Steam)
|
||||
{
|
||||
_gameServerValidateAuthTicketReplacer = _gameServerValidateAuthTicketFactory.Invoke();
|
||||
_gameServerUserGroupStatusReplacer = _gameServerUserGroupStatusFactory.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
_gameServerValidateAuthTicketReplacer = _eosServerValidateAuthTicketFactory.Invoke();
|
||||
_gameServerUserGroupStatusReplacer = _eosServerUserGroupStatusFactory.Invoke();
|
||||
}
|
||||
_gameServerValidateAuthTicketReplacer.Replace(
|
||||
new Action<ulong, JoinResult, ulong>(ValidateAuthTicketResponse), MyGameService.GameServer);
|
||||
new Action<ulong, JoinResult, ulong, string>(ValidateAuthTicketResponse), MyGameService.GameServer);
|
||||
_gameServerUserGroupStatusReplacer.Replace(new Action<ulong, ulong, bool, bool>(UserGroupStatusResponse),
|
||||
MyGameService.GameServer);
|
||||
_log.Info("Inserted steam authentication intercept");
|
||||
_log.Info("Inserted authentication intercept");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -78,19 +158,27 @@ namespace Torch.Server.Managers
|
||||
_gameServerValidateAuthTicketReplacer.Restore(MyGameService.GameServer);
|
||||
if (_gameServerUserGroupStatusReplacer != null && _gameServerUserGroupStatusReplacer.Replaced)
|
||||
_gameServerUserGroupStatusReplacer.Restore(MyGameService.GameServer);
|
||||
_log.Info("Removed steam authentication intercept");
|
||||
_log.Info("Removed authentication intercept");
|
||||
base.Detach();
|
||||
}
|
||||
|
||||
|
||||
#pragma warning disable 649
|
||||
[ReflectedEventReplace(typeof(MySteamGameServer), nameof(MySteamGameServer.ValidateAuthTicketResponse),
|
||||
[ReflectedEventReplace("VRage.Steam.MySteamGameServer, VRage.Steam", "ValidateAuthTicketResponse",
|
||||
typeof(MyDedicatedServerBase), "GameServer_ValidateAuthTicketResponse")]
|
||||
private static Func<ReflectedEventReplacer> _gameServerValidateAuthTicketFactory;
|
||||
|
||||
[ReflectedEventReplace(typeof(MySteamGameServer), nameof(MySteamGameServer.UserGroupStatusResponse),
|
||||
[ReflectedEventReplace("VRage.Steam.MySteamGameServer, VRage.Steam", "UserGroupStatusResponse",
|
||||
typeof(MyDedicatedServerBase), "GameServer_UserGroupStatus")]
|
||||
private static Func<ReflectedEventReplacer> _gameServerUserGroupStatusFactory;
|
||||
|
||||
[ReflectedEventReplace("VRage.EOS.MyEOSGameServer, VRage.EOS", "ValidateAuthTicketResponse",
|
||||
typeof(MyDedicatedServerBase), "GameServer_ValidateAuthTicketResponse")]
|
||||
private static Func<ReflectedEventReplacer> _eosServerValidateAuthTicketFactory;
|
||||
|
||||
[ReflectedEventReplace("VRage.EOS.MyEOSGameServer, VRage.EOS", "UserGroupStatusResponse",
|
||||
typeof(MyDedicatedServerBase), "GameServer_UserGroupStatus")]
|
||||
private static Func<ReflectedEventReplacer> _eosServerUserGroupStatusFactory;
|
||||
|
||||
private ReflectedEventReplacer _gameServerValidateAuthTicketReplacer;
|
||||
private ReflectedEventReplacer _gameServerUserGroupStatusReplacer;
|
||||
@@ -105,13 +193,20 @@ namespace Torch.Server.Managers
|
||||
[ReflectedStaticMethod(Type = typeof(MyGameService), Name = "GetServerAccountType")]
|
||||
private static Func<ulong, MyGameServiceAccountType> _getServerAccountType;
|
||||
|
||||
[ReflectedMethod(Name = "UserAccepted")] private static Action<MyDedicatedServerBase, ulong> _userAcceptedImpl;
|
||||
[ReflectedMethod(Name = "ClientIsProfiling")]
|
||||
private static Func<MyDedicatedServerBase, ulong, bool> _Profiling;
|
||||
|
||||
[ReflectedMethod(Name = "UserAccepted")]
|
||||
private static Action<MyDedicatedServerBase, ulong> _userAcceptedImpl;
|
||||
|
||||
[ReflectedMethod(Name = "UserRejected")]
|
||||
private static Action<MyDedicatedServerBase, ulong, JoinResult> _userRejected;
|
||||
|
||||
[ReflectedMethod(Name = "IsClientBanned")] private static Func<MyMultiplayerBase, ulong, bool> _isClientBanned;
|
||||
[ReflectedMethod(Name = "IsClientKicked")] private static Func<MyMultiplayerBase, ulong, bool> _isClientKicked;
|
||||
[ReflectedMethod(Name = "IsClientBanned")]
|
||||
private static Func<MyMultiplayerBase, ulong, bool> _isClientBanned;
|
||||
|
||||
[ReflectedMethod(Name = "IsClientKicked")]
|
||||
private static Func<MyMultiplayerBase, ulong, bool> _isClientKicked;
|
||||
|
||||
[ReflectedMethod(Name = "RaiseClientKicked")]
|
||||
private static Action<MyMultiplayerBase, ulong> _raiseClientKicked;
|
||||
@@ -135,50 +230,88 @@ namespace Torch.Server.Managers
|
||||
}
|
||||
|
||||
//Largely copied from SE
|
||||
private void ValidateAuthTicketResponse(ulong steamID, JoinResult response, ulong steamOwner)
|
||||
{
|
||||
_log.Debug($"ValidateAuthTicketResponse(user={steamID}, response={response}, owner={steamOwner}");
|
||||
if (MySandboxGame.ConfigDedicated.GroupID == 0uL)
|
||||
RunEvent(new ValidateAuthTicketEvent(steamID, steamOwner, response, 0, true, false));
|
||||
private void ValidateAuthTicketResponse(ulong steamId, JoinResult response, ulong steamOwner, string serviceName)
|
||||
{
|
||||
var state = new MyP2PSessionState();
|
||||
Sandbox.Engine.Networking.MyGameService.Peer2Peer.GetSessionState(steamId, ref state);
|
||||
var ip = new IPAddress(BitConverter.GetBytes(state.RemoteIP).Reverse().ToArray());
|
||||
|
||||
Torch.CurrentSession.KeenSession.PromotedUsers.TryGetValue(steamId, out MyPromoteLevel promoteLevel);
|
||||
|
||||
_log.Debug($"ValidateAuthTicketResponse(user={steamId}, response={response}, owner={steamOwner}, permissions={promoteLevel})");
|
||||
|
||||
_log.Info($"Connection attempt by {steamId} from {ip}");
|
||||
|
||||
if (IsProfiling(steamId))
|
||||
{
|
||||
_log.Warn($"Rejecting user {steamId} for using Profiler/ModSDK!");
|
||||
UserRejected(steamId, JoinResult.ProfilingNotAllowed);
|
||||
}
|
||||
else if (Torch.CurrentSession.KeenSession.OnlineMode == MyOnlineModeEnum.OFFLINE &&
|
||||
promoteLevel < MyPromoteLevel.Admin)
|
||||
{
|
||||
_log.Warn($"Rejecting user {steamId}, world is set to offline and user is not admin.");
|
||||
UserRejected(steamId, JoinResult.TicketCanceled);
|
||||
}
|
||||
else if (MySandboxGame.ConfigDedicated.GroupID == 0uL)
|
||||
RunEvent(new ValidateAuthTicketEvent(steamId, steamOwner, response, 0, true, false));
|
||||
else if (_getServerAccountType(MySandboxGame.ConfigDedicated.GroupID) != MyGameServiceAccountType.Clan)
|
||||
UserRejected(steamID, JoinResult.GroupIdInvalid);
|
||||
else if (MyGameService.GameServer.RequestGroupStatus(steamID, MySandboxGame.ConfigDedicated.GroupID))
|
||||
UserRejected(steamId, JoinResult.GroupIdInvalid);
|
||||
else if (MyGameService.GameServer.RequestGroupStatus(steamId, MySandboxGame.ConfigDedicated.GroupID))
|
||||
lock (_waitingForGroupLocal)
|
||||
{
|
||||
if (_waitingForGroupLocal.Count >= _waitListSize)
|
||||
_waitingForGroupLocal.RemoveAt(0);
|
||||
_waitingForGroupLocal.Add(new WaitingForGroup(steamID, response, steamOwner));
|
||||
_waitingForGroupLocal.Add(new WaitingForGroup(steamId, response, steamOwner));
|
||||
}
|
||||
else
|
||||
UserRejected(steamID, JoinResult.SteamServersOffline);
|
||||
UserRejected(steamId, JoinResult.SteamServersOffline);
|
||||
}
|
||||
|
||||
private void RunEvent(ValidateAuthTicketEvent info)
|
||||
{
|
||||
MultiplayerManagerDedicatedEventShim.RaiseValidateAuthTicket(ref info);
|
||||
JoinResult internalAuth;
|
||||
|
||||
if (info.FutureVerdict == null)
|
||||
|
||||
if (IsBanned(info.SteamOwner) || IsBanned(info.SteamID))
|
||||
internalAuth = JoinResult.BannedByAdmins;
|
||||
else if (_isClientKicked(MyMultiplayer.Static, info.SteamID) ||
|
||||
_isClientKicked(MyMultiplayer.Static, info.SteamOwner))
|
||||
internalAuth = JoinResult.KickedRecently;
|
||||
else if (info.SteamResponse == JoinResult.OK)
|
||||
{
|
||||
if (IsBanned(info.SteamOwner) || IsBanned(info.SteamID))
|
||||
CommitVerdict(info.SteamID, JoinResult.BannedByAdmins);
|
||||
else if (_isClientKicked(MyMultiplayer.Static, info.SteamID) ||
|
||||
_isClientKicked(MyMultiplayer.Static, info.SteamOwner))
|
||||
CommitVerdict(info.SteamID, JoinResult.KickedRecently);
|
||||
else if (info.SteamResponse != JoinResult.OK)
|
||||
CommitVerdict(info.SteamID, info.SteamResponse);
|
||||
else if (MyMultiplayer.Static.MemberLimit > 0 &&
|
||||
MyMultiplayer.Static.MemberCount + 1 > MyMultiplayer.Static.MemberLimit)
|
||||
CommitVerdict(info.SteamID, JoinResult.ServerFull);
|
||||
else if (MySandboxGame.ConfigDedicated.GroupID == 0uL ||
|
||||
MySandboxGame.ConfigDedicated.Administrators.Contains(info.SteamID.ToString()) ||
|
||||
var config = (TorchConfig) Torch.Config;
|
||||
if (config.EnableWhitelist && !config.Whitelist.Contains(info.SteamID))
|
||||
{
|
||||
_log.Warn($"Rejecting user {info.SteamID} because they are not whitelisted in Torch.cfg.");
|
||||
internalAuth = JoinResult.NotInGroup;
|
||||
}
|
||||
else if (MySandboxGame.ConfigDedicated.Reserved.Contains(info.SteamID))
|
||||
internalAuth = JoinResult.OK;
|
||||
//Admins can bypass member limit
|
||||
else if (MySandboxGame.ConfigDedicated.Administrators.Contains(info.SteamID.ToString()) ||
|
||||
MySandboxGame.ConfigDedicated.Administrators.Contains(_convertSteamIDFrom64(info.SteamID)))
|
||||
CommitVerdict(info.SteamID, JoinResult.OK);
|
||||
else if (MySandboxGame.ConfigDedicated.GroupID == info.Group && (info.Member || info.Officer))
|
||||
CommitVerdict(info.SteamID, JoinResult.OK);
|
||||
internalAuth = JoinResult.OK;
|
||||
//Server counts as a client, so subtract 1 from MemberCount
|
||||
else if (MyMultiplayer.Static.MemberLimit > 0 &&
|
||||
MyMultiplayer.Static.MemberCount - 1 >= MyMultiplayer.Static.MemberLimit)
|
||||
internalAuth = JoinResult.ServerFull;
|
||||
else if (MySandboxGame.ConfigDedicated.GroupID == 0uL)
|
||||
internalAuth = JoinResult.OK;
|
||||
else
|
||||
CommitVerdict(info.SteamID, JoinResult.NotInGroup);
|
||||
return;
|
||||
{
|
||||
if (MySandboxGame.ConfigDedicated.GroupID == info.Group && (info.Member || info.Officer))
|
||||
internalAuth = JoinResult.OK;
|
||||
else
|
||||
internalAuth = JoinResult.NotInGroup;
|
||||
}
|
||||
}
|
||||
else
|
||||
internalAuth = info.SteamResponse;
|
||||
|
||||
info.FutureVerdict = Task.FromResult(internalAuth);
|
||||
|
||||
MultiplayerManagerDedicatedEventShim.RaiseValidateAuthTicket(ref info);
|
||||
|
||||
info.FutureVerdict.ContinueWith((task) =>
|
||||
{
|
||||
@@ -188,8 +321,14 @@ namespace Torch.Server.Managers
|
||||
_log.Error(task.Exception, $"Future validation verdict faulted");
|
||||
verdict = JoinResult.TicketCanceled;
|
||||
}
|
||||
else if (Players.ContainsKey(info.SteamID))
|
||||
{
|
||||
_log.Warn($"Player {info.SteamID} has already joined!");
|
||||
verdict = JoinResult.AlreadyJoined;
|
||||
}
|
||||
else
|
||||
verdict = task.Result;
|
||||
|
||||
Torch.Invoke(() => { CommitVerdict(info.SteamID, verdict); });
|
||||
});
|
||||
}
|
||||
@@ -231,4 +370,4 @@ namespace Torch.Server.Managers
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Torch.Managers.PatchManager;
|
||||
using Torch.API.Managers;
|
||||
|
||||
namespace Torch.Server.Managers
|
||||
{
|
||||
[PatchShim]
|
||||
internal static class MultiplayerManagerDedicatedPatchShim
|
||||
{
|
||||
public static void Patch(PatchContext ctx)
|
||||
{
|
||||
ctx.GetPattern(typeof(MyDedicatedServerBase).GetMethod(nameof(MyDedicatedServerBase.BanClient))).Prefixes.Add(typeof(MultiplayerManagerDedicatedPatchShim).GetMethod(nameof(BanPrefix)));
|
||||
ctx.GetPattern(typeof(MyDedicatedServerBase).GetMethod(nameof(MyDedicatedServerBase.KickClient))).Prefixes.Add(typeof(MultiplayerManagerDedicatedPatchShim).GetMethod(nameof(KickPrefix)));
|
||||
}
|
||||
|
||||
public static void BanPrefix(ulong userId, bool banned)
|
||||
{
|
||||
TorchBase.Instance.CurrentSession.Managers.GetManager<MultiplayerManagerDedicated>().RaiseClientBanned(userId, banned);
|
||||
}
|
||||
|
||||
public static void KickPrefix(ulong userId)
|
||||
{
|
||||
TorchBase.Instance.CurrentSession.Managers.GetManager<MultiplayerManagerDedicated>().RaiseClientKicked(userId);
|
||||
}
|
||||
}
|
||||
}
|
40
Torch.Server/Managers/RemoteAPIManager.cs
Normal file
40
Torch.Server/Managers/RemoteAPIManager.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using NLog;
|
||||
using Sandbox;
|
||||
using Torch.API;
|
||||
using Torch.Managers;
|
||||
using VRage.Dedicated.RemoteAPI;
|
||||
|
||||
namespace Torch.Server.Managers
|
||||
{
|
||||
public class RemoteAPIManager : Manager
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public RemoteAPIManager(ITorchBase torchInstance) : base(torchInstance)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Attach()
|
||||
{
|
||||
Torch.GameStateChanged += TorchOnGameStateChanged;
|
||||
base.Attach();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Detach()
|
||||
{
|
||||
Torch.GameStateChanged -= TorchOnGameStateChanged;
|
||||
base.Detach();
|
||||
}
|
||||
|
||||
private void TorchOnGameStateChanged(MySandboxGame game, TorchGameState newstate)
|
||||
{
|
||||
if (newstate == TorchGameState.Loading && MySandboxGame.ConfigDedicated.RemoteApiEnabled && !string.IsNullOrEmpty(MySandboxGame.ConfigDedicated.RemoteSecurityKey))
|
||||
{
|
||||
var myRemoteServer = new MyRemoteServer(MySandboxGame.ConfigDedicated.RemoteApiPort, MySandboxGame.ConfigDedicated.RemoteSecurityKey);
|
||||
LogManager.GetCurrentClassLogger().Info($"Remote API started on port {myRemoteServer.Port}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
49
Torch.Server/MultiTextWriter.cs
Normal file
49
Torch.Server/MultiTextWriter.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Torch.Server
|
||||
{
|
||||
public class MultiTextWriter : TextWriter
|
||||
{
|
||||
private IEnumerable<TextWriter> writers;
|
||||
public MultiTextWriter(IEnumerable<TextWriter> writers)
|
||||
{
|
||||
this.writers = writers.ToList();
|
||||
}
|
||||
public MultiTextWriter(params TextWriter[] writers)
|
||||
{
|
||||
this.writers = writers;
|
||||
}
|
||||
|
||||
public override void Write(char value)
|
||||
{
|
||||
foreach (var writer in writers)
|
||||
writer.Write(value);
|
||||
}
|
||||
|
||||
public override void Write(string value)
|
||||
{
|
||||
foreach (var writer in writers)
|
||||
writer.Write(value);
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
foreach (var writer in writers)
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
foreach (var writer in writers)
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
public override Encoding Encoding
|
||||
{
|
||||
get { return Encoding.ASCII; }
|
||||
}
|
||||
}
|
||||
}
|
39
Torch.Server/Patches/CheckpointLoadPatch.cs
Normal file
39
Torch.Server/Patches/CheckpointLoadPatch.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Managers.PatchManager;
|
||||
using Torch.Server.Managers;
|
||||
using Torch.Utils;
|
||||
using VRage.Game;
|
||||
|
||||
namespace Torch.Patches;
|
||||
|
||||
[PatchShim]
|
||||
public static class CheckpointLoadPatch
|
||||
{
|
||||
private static readonly ILogger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[ReflectedMethodInfo(typeof(MyLocalCache), "LoadCheckpoint")]
|
||||
private static MethodInfo LoadCheckpointMethod = null!;
|
||||
|
||||
public static void Patch(PatchContext context)
|
||||
{
|
||||
context.GetPattern(LoadCheckpointMethod).AddPrefix();
|
||||
}
|
||||
|
||||
private static bool Prefix(ref MyObjectBuilder_Checkpoint __result)
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
var world = TorchBase.Instance.Managers.GetManager<InstanceManager>().DedicatedConfig.SelectedWorld;
|
||||
#pragma warning restore CS0618
|
||||
if (world is null)
|
||||
{
|
||||
Log.Error("Selected world is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
__result = world.Checkpoint;
|
||||
return false;
|
||||
}
|
||||
}
|
38
Torch.Server/Patches/PromotePatch.cs
Normal file
38
Torch.Server/Patches/PromotePatch.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Sandbox.Game.World;
|
||||
using Torch.Managers.PatchManager;
|
||||
using VRage.Game.ModAPI;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Server.Managers;
|
||||
|
||||
namespace Torch.Patches
|
||||
{
|
||||
[PatchShim]
|
||||
internal static class PromotePatch
|
||||
{
|
||||
private static Logger _log = LogManager.GetCurrentClassLogger();
|
||||
private static IMultiplayerManagerServer _backing;
|
||||
|
||||
private static IMultiplayerManagerServer ServerManager => _backing ?? (_backing = TorchBase.Instance?.CurrentSession?.Managers.GetManager<IMultiplayerManagerServer>());
|
||||
|
||||
public static void Patch(PatchContext ctx)
|
||||
{
|
||||
_log.Info("patching promote");
|
||||
ctx.GetPattern(typeof(MySession).GetMethod("OnPromoteLevelSet", BindingFlags.NonPublic | BindingFlags.Static)).Prefixes.Add(typeof(PromotePatch).GetMethod(nameof(PromotePrefix)));
|
||||
}
|
||||
|
||||
public static void PromotePrefix(ulong steamId, MyPromoteLevel level)
|
||||
{
|
||||
if (ServerManager is MultiplayerManagerDedicated d)
|
||||
d.RaisePromoteChanged(steamId, level);
|
||||
else
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
44
Torch.Server/Patches/ServerResponsePatch.cs
Normal file
44
Torch.Server/Patches/ServerResponsePatch.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Game.World;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Managers.PatchManager;
|
||||
using Torch.Managers.PatchManager.MSIL;
|
||||
using Torch.Server.Managers;
|
||||
using VRage.Game.ModAPI;
|
||||
|
||||
namespace Torch.Patches
|
||||
{
|
||||
[PatchShim]
|
||||
public static class ServerResponsePatch
|
||||
{
|
||||
private static Logger _log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static void Patch(PatchContext ctx)
|
||||
{
|
||||
var transpiler = typeof(ServerResponsePatch).GetMethod(nameof(Transpile), BindingFlags.Public | BindingFlags.Static);
|
||||
ctx.GetPattern(typeof(MyDedicatedServerBase).GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Instance))
|
||||
.Transpilers.Add(transpiler);
|
||||
_log.Info("Patching Steam response polling");
|
||||
}
|
||||
|
||||
public static IEnumerable<MsilInstruction> Transpile(IEnumerable<MsilInstruction> instructions)
|
||||
{
|
||||
// Reduce response timeout from 100 seconds to 5 seconds.
|
||||
foreach (var instruction in instructions)
|
||||
{
|
||||
if (instruction.OpCode == OpCodes.Ldc_I4 && instruction.Operand is MsilOperandInline.MsilOperandInt32 inlineI32 && inlineI32.Value == 1000)
|
||||
{
|
||||
_log.Info("Patching Steam response timeout to 5 seconds");
|
||||
inlineI32.Value = 50;
|
||||
}
|
||||
|
||||
yield return instruction;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
48
Torch.Server/Patches/WorldLoadExceptionPatch.cs
Normal file
48
Torch.Server/Patches/WorldLoadExceptionPatch.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using NLog;
|
||||
using Sandbox;
|
||||
using Torch.Managers.PatchManager;
|
||||
using Torch.Managers.PatchManager.MSIL;
|
||||
|
||||
namespace Torch.Patches
|
||||
{
|
||||
/// <summary>
|
||||
/// Patches MySandboxGame.InitQuickLaunch to rethrow exceptions caught during session load.
|
||||
/// </summary>
|
||||
[PatchShim]
|
||||
public static class WorldLoadExceptionPatch
|
||||
{
|
||||
private static readonly ILogger _log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static void Patch(PatchContext ctx)
|
||||
{
|
||||
ctx.GetPattern(typeof(MySandboxGame).GetMethod("InitQuickLaunch", BindingFlags.Instance | BindingFlags.NonPublic))
|
||||
.Transpilers.Add(typeof(WorldLoadExceptionPatch).GetMethod(nameof(Transpile), BindingFlags.Static | BindingFlags.NonPublic));
|
||||
}
|
||||
|
||||
private static IEnumerable<MsilInstruction> Transpile(IEnumerable<MsilInstruction> method)
|
||||
{
|
||||
var msil = method.ToList();
|
||||
for (var i = 0; i < msil.Count; i++)
|
||||
{
|
||||
if (msil[i].TryCatchOperations.All(x => x.Type != MsilTryCatchOperationType.BeginClauseBlock))
|
||||
continue;
|
||||
|
||||
for (; i < msil.Count; i++)
|
||||
{
|
||||
if (msil[i].OpCode != OpCodes.Leave)
|
||||
continue;
|
||||
|
||||
msil[i] = new MsilInstruction(OpCodes.Rethrow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msil;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,67 +1,105 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration.Install;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.ServiceProcess;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using NLog;
|
||||
using Sandbox.Game.World;
|
||||
using Sandbox.ModAPI;
|
||||
using Torch;
|
||||
using Torch.API;
|
||||
using Torch.Server.Views;
|
||||
using VRage.Game.ModAPI;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Security.Policy;
|
||||
using Torch.Server.Managers;
|
||||
using NLog.Targets;
|
||||
using Torch.Utils;
|
||||
using VRage.FileSystem;
|
||||
using VRageRender;
|
||||
|
||||
namespace Torch.Server
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <remarks>
|
||||
/// This method must *NOT* load any types/assemblies from the vanilla game, otherwise automatic updates will fail.
|
||||
/// </remarks>
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var isService = Environment.GetEnvironmentVariable("TORCH_SERVICE")
|
||||
?.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase) ?? false;
|
||||
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
||||
//Ensures that all the files are downloaded in the Torch directory.
|
||||
var workingDir = new FileInfo(typeof(Program).Assembly.Location).Directory.ToString();
|
||||
var binDir = Path.Combine(workingDir, "DedicatedServer64");
|
||||
Directory.SetCurrentDirectory(workingDir);
|
||||
var workingDir = AppContext.BaseDirectory;
|
||||
var binDir = Path.Combine(Environment.GetEnvironmentVariable("TORCH_GAME_PATH") ?? workingDir, "DedicatedServer64");
|
||||
Directory.SetCurrentDirectory(Environment.GetEnvironmentVariable("TORCH_GAME_PATH") ?? workingDir);
|
||||
|
||||
if (!isService && Directory.Exists(binDir))
|
||||
foreach (var file in Directory.GetFiles(binDir, "System.*.dll"))
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
if (!TorchLauncher.IsTorchWrapped())
|
||||
TorchLauncher.Launch(workingDir, binDir);
|
||||
|
||||
// Breaks on Windows Server 2019
|
||||
#if TORCH_SERVICE
|
||||
if (!new ComputerInfo().OSFullName.Contains("Server 2019") && !Environment.UserInteractive)
|
||||
{
|
||||
TorchLauncher.Launch(Assembly.GetEntryAssembly().FullName,args, binDir);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Environment.UserInteractive)
|
||||
{
|
||||
using (var service = new TorchService())
|
||||
using (var service = new TorchService(args))
|
||||
ServiceBase.Run(service);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
var initializer = new Initializer(workingDir);
|
||||
var instanceName = Environment.GetEnvironmentVariable("TORCH_INSTANCE") ?? "Instance";
|
||||
string instancePath;
|
||||
|
||||
if (Path.IsPathRooted(instanceName))
|
||||
{
|
||||
instancePath = instanceName;
|
||||
instanceName = Path.GetDirectoryName(instanceName);
|
||||
}
|
||||
else
|
||||
{
|
||||
instancePath = Path.GetFullPath(instanceName);
|
||||
}
|
||||
|
||||
var oldTorchCfg = Path.Combine(workingDir, "Torch.cfg");
|
||||
var torchCfg = Path.Combine(instancePath, "Torch.cfg");
|
||||
|
||||
if (File.Exists(oldTorchCfg))
|
||||
File.Move(oldTorchCfg, torchCfg, true);
|
||||
|
||||
var config = Persistent<TorchConfig>.Load(torchCfg);
|
||||
config.Data.InstanceName = instanceName;
|
||||
config.Data.InstancePath = instancePath;
|
||||
if (!config.Data.Parse(args))
|
||||
{
|
||||
Console.WriteLine("Invalid arguments");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
var handler = new UnhandledExceptionHandler(config.Data, isService);
|
||||
AppDomain.CurrentDomain.UnhandledException += handler.OnUnhandledException;
|
||||
|
||||
var initializer = new Initializer(workingDir, config);
|
||||
if (!initializer.Initialize(args))
|
||||
return;
|
||||
Environment.Exit(1);
|
||||
|
||||
initializer.Run();
|
||||
CopyNative(binDir);
|
||||
initializer.Run(isService, instanceName, instancePath);
|
||||
}
|
||||
|
||||
private static void CopyNative(string binPath)
|
||||
{
|
||||
var apiSource = Path.Combine(binPath, "steam_api64.dll");
|
||||
var apiTarget = Path.Combine(AppContext.BaseDirectory, "steam_api64.dll");
|
||||
if (!File.Exists(apiTarget))
|
||||
{
|
||||
File.Copy(apiSource, apiTarget);
|
||||
}
|
||||
else if (File.GetLastWriteTime(apiTarget) < File.GetLastWriteTime(binPath))
|
||||
{
|
||||
File.Delete(apiTarget);
|
||||
File.Copy(apiSource, apiTarget);
|
||||
}
|
||||
|
||||
var havokSource = Path.Combine(binPath, "Havok.dll");
|
||||
var havokTarget = Path.Combine(AppContext.BaseDirectory, "Havok.dll");
|
||||
|
||||
if (!File.Exists(havokTarget))
|
||||
{
|
||||
File.Copy(havokSource, havokTarget);
|
||||
}
|
||||
else if (File.GetLastWriteTime(havokTarget) < File.GetLastWriteTime(havokSource))
|
||||
{
|
||||
File.Delete(havokTarget);
|
||||
File.Copy(havokSource, havokTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1065
Torch.Server/Properties/Annotations.cs
Normal file
1065
Torch.Server/Properties/Annotations.cs
Normal file
File diff suppressed because it is too large
Load Diff
2
Torch.Server/Properties/Resources.Designer.cs
generated
2
Torch.Server/Properties/Resources.Designer.cs
generated
@@ -19,7 +19,7 @@ namespace Torch.Server.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
2
Torch.Server/Properties/Settings.Designer.cs
generated
2
Torch.Server/Properties/Settings.Designer.cs
generated
@@ -12,7 +12,7 @@ namespace Torch.Server.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
11
Torch.Server/Properties/launchSettings.json
Normal file
11
Torch.Server/Properties/launchSettings.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Torch.Server": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "-noupdate",
|
||||
"use64Bit": true,
|
||||
"hotReloadEnabled": false
|
||||
}
|
||||
}
|
||||
}
|
89
Torch.Server/RichTextBoxWriter.cs
Normal file
89
Torch.Server/RichTextBoxWriter.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Torch.Server
|
||||
{
|
||||
public class RichTextBoxWriter : TextWriter
|
||||
{
|
||||
private RichTextBox textbox;
|
||||
private StringBuilder _cache = new StringBuilder();
|
||||
public RichTextBoxWriter(RichTextBox textbox)
|
||||
{
|
||||
this.textbox = textbox;
|
||||
textbox.Document.Background = new SolidColorBrush(UnpackColor(Console.BackgroundColor));
|
||||
textbox.Document.Blocks.Clear();
|
||||
textbox.Document.Blocks.Add(new Paragraph {LineHeight = 12});
|
||||
}
|
||||
|
||||
public override void Write(char value)
|
||||
{
|
||||
if (value == '\r')
|
||||
return;
|
||||
|
||||
_cache.Append(value);
|
||||
if (value == '\n')
|
||||
{
|
||||
var str = _cache.ToString();
|
||||
_cache.Clear();
|
||||
|
||||
var brush = _brushes[Console.ForegroundColor];
|
||||
textbox.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
var p = (Paragraph)textbox.Document.Blocks.FirstBlock;
|
||||
p.Inlines.Add(new Run(str) { Foreground = brush });
|
||||
textbox.ScrollToEnd();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Write(string value)
|
||||
{
|
||||
var brush = _brushes[Console.ForegroundColor];
|
||||
textbox.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
var p = (Paragraph)textbox.Document.Blocks.FirstBlock;
|
||||
p.Inlines.Add(new Run(value) { Foreground = brush });
|
||||
textbox.ScrollToEnd();
|
||||
});
|
||||
}
|
||||
|
||||
public override Encoding Encoding
|
||||
{
|
||||
get { return Encoding.ASCII; }
|
||||
}
|
||||
|
||||
static RichTextBoxWriter()
|
||||
{
|
||||
foreach (var value in (ConsoleColor[])Enum.GetValues(typeof(ConsoleColor)))
|
||||
{
|
||||
_brushes.Add(value, new SolidColorBrush(UnpackColor(value)));
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<ConsoleColor, SolidColorBrush> _brushes = new Dictionary<ConsoleColor, SolidColorBrush>();
|
||||
|
||||
private static Color UnpackColor(ConsoleColor color)
|
||||
{
|
||||
var colorByte = (byte)color;
|
||||
var isBright = (colorByte & 0b1000) >> 3 > 0;
|
||||
var brightness = isBright ? (byte)255 : (byte)128;
|
||||
var red = (colorByte & 0b0100) >> 2;
|
||||
var green = (colorByte & 0b0010) >> 1;
|
||||
var blue = (colorByte & 0b0001);
|
||||
|
||||
return new Color
|
||||
{
|
||||
R = (byte)(brightness * red),
|
||||
G = (byte)(brightness * green),
|
||||
B = (byte)(brightness * blue),
|
||||
A = 255
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Torch.Collections;
|
||||
|
||||
namespace Torch.Server
|
||||
{
|
||||
public class ServerStatistics
|
||||
{
|
||||
public RollingAverage SimSpeed { get; } = new RollingAverage(30);
|
||||
}
|
||||
}
|
15
Torch.Server/Themes/Dark Theme Animated.xaml
Normal file
15
Torch.Server/Themes/Dark Theme Animated.xaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<!-- AppTheme setting -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Blue.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Tabcontrol.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="Hyperlink" x:Name="LegalshtuffLink">
|
||||
<Setter Property="NavigateUri" Value="https://github.com/MahApps/MahApps.Metro/blob/develop/LICENSE" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
84
Torch.Server/Themes/Dark Theme.xaml
Normal file
84
Torch.Server/Themes/Dark Theme.xaml
Normal file
@@ -0,0 +1,84 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<!-- AppTheme setting -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Blue.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Tabcontrol.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="TabControl">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TabControl">
|
||||
<Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="ColumnDefinition0"/>
|
||||
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
|
||||
<RowDefinition x:Name="RowDefinition1" Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel x:Name="HeaderPanel" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1" Orientation="Horizontal"/>
|
||||
<Border x:Name="ContentPanel" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
|
||||
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Border>
|
||||
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
|
||||
<TabPanel x:Name="HeaderPanel2"
|
||||
Panel.ZIndex ="1"
|
||||
KeyboardNavigation.TabIndex="1"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Margin="2,2,2,0"
|
||||
IsItemsHost="true"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="TabStripPlacement" Value="Bottom">
|
||||
<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
|
||||
<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
|
||||
<Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="TabStripPlacement" Value="Left">
|
||||
<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
|
||||
<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
|
||||
<Setter Property="Margin" TargetName="HeaderPanel" Value="2,2,0,2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="TabStripPlacement" Value="Right">
|
||||
<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
|
||||
<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
|
||||
<Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
|
||||
<Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Hyperlink" x:Name="LegalshtuffLink">
|
||||
<Setter Property="NavigateUri" Value="https://github.com/MahApps/MahApps.Metro/blob/develop/LICENSE" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
17
Torch.Server/Themes/Light Theme Animated.xaml
Normal file
17
Torch.Server/Themes/Light Theme Animated.xaml
Normal file
@@ -0,0 +1,17 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<!-- AppTheme setting -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Tabcontrol.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="Hyperlink" x:Name="LegalshtuffLink">
|
||||
<Setter Property="NavigateUri" Value="https://github.com/MahApps/MahApps.Metro/blob/develop/LICENSE" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
84
Torch.Server/Themes/Light Theme.xaml
Normal file
84
Torch.Server/Themes/Light Theme.xaml
Normal file
@@ -0,0 +1,84 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<!-- AppTheme setting -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Tabcontrol.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="TabControl">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TabControl">
|
||||
<Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="ColumnDefinition0"/>
|
||||
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
|
||||
<RowDefinition x:Name="RowDefinition1" Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel x:Name="HeaderPanel" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1" Orientation="Horizontal"/>
|
||||
<Border x:Name="ContentPanel" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
|
||||
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Border>
|
||||
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
|
||||
<TabPanel x:Name="HeaderPanel2"
|
||||
Panel.ZIndex ="1"
|
||||
KeyboardNavigation.TabIndex="1"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Margin="2,2,2,0"
|
||||
IsItemsHost="true"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="TabStripPlacement" Value="Bottom">
|
||||
<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
|
||||
<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
|
||||
<Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="TabStripPlacement" Value="Left">
|
||||
<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
|
||||
<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
|
||||
<Setter Property="Margin" TargetName="HeaderPanel" Value="2,2,0,2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="TabStripPlacement" Value="Right">
|
||||
<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
|
||||
<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
|
||||
<Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
|
||||
<Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Hyperlink" x:Name="LegalshtuffLink">
|
||||
<Setter Property="NavigateUri" Value="https://github.com/MahApps/MahApps.Metro/blob/develop/LICENSE" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
@@ -1,41 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Torch.Server</RootNamespace>
|
||||
<AssemblyName>Torch.Server</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFramework>net6-windows</TargetFramework>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>$(SolutionDir)\bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<AssemblyTitle>Torch Server</AssemblyTitle>
|
||||
<Product>Torch</Product>
|
||||
<Copyright>Copyright © Torch API 2017</Copyright>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<OutputPath>..\bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<UseWPF>true</UseWPF>
|
||||
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>$(SolutionDir)\bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<DocumentationFile>$(SolutionDir)\bin\x64\Release\Torch.Server.xml</DocumentationFile>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
<IsPackable>false</IsPackable>
|
||||
<NeutralLanguage>en</NeutralLanguage>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>Torch.Server.Program</StartupObject>
|
||||
@@ -43,348 +28,139 @@
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>torchicon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<!-- <Import Project="$(SolutionDir)\TransformOnBuild.targets" /> -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoCompleteTextBox" Version="1.3.0" />
|
||||
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
|
||||
<PackageReference Include="ControlzEx" Version="5.0.1" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
|
||||
<PackageReference Include="MdXaml" Version="1.12.0" />
|
||||
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="2.0.226801" />
|
||||
<PackageReference Include="NLog" Version="5.0.0-rc2" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" PrivateAssets="all" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="System.Management" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="HavokWrapper, Version=1.0.6051.28726, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\HavokWrapper.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\Microsoft.CodeAnalysis.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.4.12\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\Sandbox.Common.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Game, Version=0.1.6305.30774, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\Sandbox.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Graphics, Version=0.1.6305.30761, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\Sandbox.Graphics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.ObjectBuilders, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.ObjectBuilders.XmlSerializers, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SteamSDK, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\SteamSDK.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
<Reference Include="Steamworks.NET">
|
||||
<HintPath>..\GameBinaries\Steamworks.NET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="VRage, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Audio, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Audio.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Dedicated, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Dedicated.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Game.XmlSerializers, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Game.XmlSerializers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Input, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Input.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Library.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Math, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Math.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Native, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Native.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.OpenVRWrapper, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.OpenVRWrapper.dll</HintPath>
|
||||
<Reference Include="VRage.Platform.Windows, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>..\GameBinaries\VRage.Platform.Windows.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Render.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render11, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Render11.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Scripting, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\GameBinaries\VRage.Scripting.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Steam">
|
||||
<HintPath>..\GameBinaries\VRage.Steam.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs">
|
||||
<Link>Properties\AssemblyVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ListBoxExtensions.cs" />
|
||||
<Compile Include="Managers\EntityControlManager.cs" />
|
||||
<Compile Include="Managers\MultiplayerManagerDedicated.cs" />
|
||||
<Compile Include="Managers\InstanceManager.cs" />
|
||||
<Compile Include="Managers\MultiplayerManagerDedicatedEventShim.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Initializer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServerStatistics.cs" />
|
||||
<Compile Include="TorchConfig.cs" />
|
||||
<Compile Include="TorchService.cs">
|
||||
<Compile Update="TorchService.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TorchServiceInstaller.cs">
|
||||
<Compile Update="TorchServiceInstaller.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ViewModels\BlockLimitViewModel.cs" />
|
||||
<Compile Include="ViewModels\Entities\Blocks\BlockViewModel.cs" />
|
||||
<Compile Include="ViewModels\Entities\Blocks\BlockViewModelGenerator.cs" />
|
||||
<Compile Include="ViewModels\Entities\Blocks\PropertyViewModel.cs" />
|
||||
<Compile Include="ViewModels\Entities\CharacterViewModel.cs" />
|
||||
<Compile Include="ViewModels\ConfigDedicatedViewModel.cs" />
|
||||
<Compile Include="ViewModels\Entities\EntityControlViewModel.cs" />
|
||||
<Compile Include="Views\Entities\EntityControlHost.xaml.cs">
|
||||
<DependentUpon>EntityControlHost.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Entities\EntityControlsView.xaml.cs">
|
||||
<DependentUpon>EntityControlsView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ViewModels\EntityTreeViewModel.cs" />
|
||||
<Compile Include="ViewModels\Entities\EntityViewModel.cs" />
|
||||
<Compile Include="ViewModels\Entities\FloatingObjectViewModel.cs" />
|
||||
<Compile Include="ViewModels\Entities\GridViewModel.cs" />
|
||||
<Compile Include="ViewModels\ILazyLoad.cs" />
|
||||
<Compile Include="ViewModels\PluginManagerViewModel.cs" />
|
||||
<Compile Include="ViewModels\PluginViewModel.cs" />
|
||||
<Compile Include="ViewModels\SessionSettingsViewModel.cs" />
|
||||
<Compile Include="ViewModels\Entities\VoxelMapViewModel.cs" />
|
||||
<Compile Include="ViewModels\SteamUserViewModel.cs" />
|
||||
<Compile Include="Views\AddWorkshopItemsDialog.xaml.cs">
|
||||
<DependentUpon>AddWorkshopItemsDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Converters\InverseBooleanConverter.cs" />
|
||||
<Compile Include="Views\Converters\Vector3DConverter.cs" />
|
||||
<Compile Include="Views\Entities\Blocks\BlockView.xaml.cs">
|
||||
<DependentUpon>BlockView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Entities\Blocks\PropertyView.xaml.cs">
|
||||
<DependentUpon>PropertyView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ChatControl.xaml.cs">
|
||||
<DependentUpon>ChatControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ConfigControl.xaml.cs">
|
||||
<DependentUpon>ConfigControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\EntitiesControl.xaml.cs">
|
||||
<DependentUpon>EntitiesControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Converters\StringBuilderConverter.cs" />
|
||||
<Compile Include="Views\Converters\StringIdConverter.cs" />
|
||||
<Compile Include="Views\Entities\GridView.xaml.cs">
|
||||
<DependentUpon>GridView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Entities\VoxelMapView.xaml.cs">
|
||||
<DependentUpon>VoxelMapView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\FirstTimeSetup.xaml.cs">
|
||||
<DependentUpon>FirstTimeSetup.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ModsControl.xaml.cs">
|
||||
<DependentUpon>ModsControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\PluginsControl.xaml.cs">
|
||||
<DependentUpon>PluginsControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\TorchUI.xaml.cs">
|
||||
<DependentUpon>TorchUI.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\PlayerListControl.xaml.cs">
|
||||
<DependentUpon>PlayerListControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="TorchServer.cs" />
|
||||
<Compile Remove="ServerManager.cs" />
|
||||
<Compile Remove="ViewModels\SessionSettingsViewModel1.cs" />
|
||||
<Compile Remove="Views\WorldSelectControl.xaml.cs" />
|
||||
<Compile Include="..\Versioning\AssemblyVersion.cs" Link="Properties/AssemblyVersion.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj">
|
||||
<Project>{fba5d932-6254-4a1e-baf4-e229fa94e3c2}</Project>
|
||||
<Name>Torch.API</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Torch\Torch.csproj">
|
||||
<Project>{7e01635c-3b67-472e-bcd6-c5539564f214}</Project>
|
||||
<Name>Torch</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="Views\Entities\EntityControlHost.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Entities\EntityControlsView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\AddWorkshopItemsDialog.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Entities\Blocks\BlockView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Entities\Blocks\PropertyView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\ChatControl.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\ConfigControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\EntitiesControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Entities\GridView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\PluginsControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Entities\VoxelMapView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\FirstTimeSetup.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\ModsControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\TorchUI.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\PlayerListControl.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<ProjectReference Include="..\Torch.API\Torch.API.csproj" />
|
||||
<ProjectReference Include="..\Torch\Torch.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="torchicon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
<Page Remove="Views\WorldSelectControl.xaml" />
|
||||
<None Include="..\NLog.config" Visible="false" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="Always" />
|
||||
<None Include="..\Dockerfile" Visible="false" CopyToPublishDirectory="Always" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
2
Torch.Server/Torch.Server.csproj.DotSettings
Normal file
2
Torch.Server/Torch.Server.csproj.DotSettings
Normal file
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeEditing/Localization/Localizable/@EntryValue">No</s:String></wpf:ResourceDictionary>
|
@@ -1,28 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using Torch.API;
|
||||
using Torch.Views;
|
||||
|
||||
namespace Torch.Server
|
||||
{
|
||||
// TODO: redesign this gerbage
|
||||
public class TorchConfig : CommandLine, ITorchConfig
|
||||
public class TorchConfig : CommandLine, ITorchConfig, INotifyPropertyChanged
|
||||
{
|
||||
private static Logger _log = LogManager.GetLogger("Config");
|
||||
|
||||
public bool ShouldUpdatePlugins => (GetPluginUpdates && !NoUpdate) || ForceUpdate;
|
||||
public bool ShouldUpdateTorch => (GetTorchUpdates && !NoUpdate) || ForceUpdate;
|
||||
|
||||
/// <inheritdoc />
|
||||
[Arg("instancename", "The name of the Torch instance.")]
|
||||
public string InstanceName { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Arg("instancepath", "Server data folder where saves and mods are stored.")]
|
||||
public string InstancePath { get; set; }
|
||||
|
||||
private bool _autostart;
|
||||
private bool _restartOnCrash;
|
||||
private bool _noGui;
|
||||
private bool _getPluginUpdates = true;
|
||||
private bool _getTorchUpdates = true;
|
||||
private int _tickTimeout = 60;
|
||||
private bool _localPlugins;
|
||||
private bool _disconnectOnRestart;
|
||||
private string _chatName = "Server";
|
||||
private string _chatColor = "Red";
|
||||
private bool _enableWhitelist = false;
|
||||
private List<ulong> _whitelist = new List<ulong>();
|
||||
private int _windowWidth = 980;
|
||||
private int _windowHeight = 588;
|
||||
private bool _independentConsole = false;
|
||||
private bool _enableAsserts = false;
|
||||
private int _fontSize = 16;
|
||||
private UGCServiceType _ugcServiceType = UGCServiceType.Steam;
|
||||
private bool _entityManagerEnabled = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
[XmlIgnore, Arg("noupdate", "Disable automatically downloading game and plugin updates.")]
|
||||
@@ -32,85 +46,126 @@ namespace Torch.Server
|
||||
[XmlIgnore, Arg("forceupdate", "Manually check for and install updates.")]
|
||||
public bool ForceUpdate { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Permanent flag to ALWAYS automatically start the server
|
||||
/// </summary>
|
||||
[Display(Name = "Auto Start", Description = "Permanent flag to ALWAYS automatically start the server.", GroupName = "Server")]
|
||||
public bool Autostart { get => _autostart; set => Set(value, ref _autostart); }
|
||||
|
||||
/// <summary>
|
||||
/// Temporary flag to automatically start the server only on the next run
|
||||
/// </summary>
|
||||
[Arg("autostart", "Start the server immediately.")]
|
||||
public bool Autostart { get; set; }
|
||||
[XmlIgnore]
|
||||
public bool TempAutostart { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Arg("restartoncrash", "Automatically restart the server if it crashes.")]
|
||||
public bool RestartOnCrash { get; set; }
|
||||
[Display(Name = "Restart On Crash", Description = "Automatically restart the server if it crashes.", GroupName = "Server")]
|
||||
public bool RestartOnCrash { get => _restartOnCrash; set => Set(value, ref _restartOnCrash); }
|
||||
|
||||
public string InstancePath { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Arg("nogui", "Do not show the Torch UI.")]
|
||||
public bool NoGui { get; set; }
|
||||
[Display(Name = "No GUI", Description = "Do not show the Torch UI.", GroupName = "Window")]
|
||||
public bool NoGui { get => _noGui; set => Set(value, ref _noGui); }
|
||||
|
||||
/// <inheritdoc />
|
||||
[XmlIgnore, Arg("waitforpid", "Makes Torch wait for another process to exit.")]
|
||||
public string WaitForPID { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool GetTorchUpdates { get; set; } = true;
|
||||
[Display(Name = "Update Torch", Description = "Check every start for new versions of torch.", GroupName = "Server")]
|
||||
public bool GetTorchUpdates { get => _getTorchUpdates; set => Set(value, ref _getTorchUpdates); }
|
||||
|
||||
public string InstanceName { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool GetPluginUpdates { get; set; } = true;
|
||||
[Display(Name = "Update Plugins", Description = "Check every start for new versions of plugins.", GroupName = "Server")]
|
||||
public bool GetPluginUpdates { get => _getPluginUpdates; set => Set(value, ref _getPluginUpdates); }
|
||||
|
||||
/// <inheritdoc />
|
||||
public int TickTimeout { get; set; } = 60;
|
||||
[Display(Name = "Watchdog Timeout", Description = "Watchdog timeout (in seconds).", GroupName = "Server")]
|
||||
public int TickTimeout { get => _tickTimeout; set => Set(value, ref _tickTimeout); }
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<string> Plugins { get; set; } = new List<string>();
|
||||
[Arg("plugins", "Starts Torch with the given plugin GUIDs (space delimited).")]
|
||||
public List<Guid> Plugins { get; set; } = new List<Guid>();
|
||||
|
||||
[Arg("localplugins", "Loads all pluhins from disk, ignores the plugins defined in config.")]
|
||||
[Display(Name = "Local Plugins", Description = "Loads all pluhins from disk, ignores the plugins defined in config.", GroupName = "In-Game")]
|
||||
public bool LocalPlugins { get => _localPlugins; set => Set(value, ref _localPlugins); }
|
||||
|
||||
[Arg("disconnect", "When server restarts, all clients are rejected to main menu to prevent auto rejoin.")]
|
||||
[Display(Name = "Auto Disconnect", Description = "When server restarts, all clients are rejected to main menu to prevent auto rejoin.", GroupName = "In-Game")]
|
||||
public bool DisconnectOnRestart { get => _disconnectOnRestart; set => Set(value, ref _disconnectOnRestart); }
|
||||
|
||||
[Display(Name = "Chat Name", Description = "Default name for chat from gui, broadcasts etc..", GroupName = "In-Game")]
|
||||
public string ChatName { get => _chatName; set => Set(value, ref _chatName); }
|
||||
|
||||
[Display(Name = "Chat Color", Description = "Default color for chat from gui, broadcasts etc.. (Red, Blue, White, Green)", GroupName = "In-Game")]
|
||||
public string ChatColor { get => _chatColor; set => Set(value, ref _chatColor); }
|
||||
|
||||
[Display(Name = "Enable Whitelist", Description = "Enable Whitelist to prevent random players join while maintance, tests or other.", GroupName = "In-Game")]
|
||||
public bool EnableWhitelist { get => _enableWhitelist; set => Set(value, ref _enableWhitelist); }
|
||||
|
||||
[Display(Name = "Whitelist", Description = "Collection of whitelisted steam ids.", GroupName = "In-Game")]
|
||||
public List<ulong> Whitelist { get => _whitelist; set => Set(value, ref _whitelist); }
|
||||
|
||||
[Display(Name = "Width", Description = "Default window width.", GroupName = "Window")]
|
||||
public int WindowWidth { get => _windowWidth; set => Set(value, ref _windowWidth); }
|
||||
|
||||
[Display(Name = "Height", Description = "Default window height", GroupName = "Window")]
|
||||
public int WindowHeight { get => _windowHeight; set => Set(value, ref _windowHeight); }
|
||||
|
||||
[Display(Name = "Font Size", Description = "Font size for logging text box. (default is 16)", GroupName = "Window")]
|
||||
public int FontSize { get => _fontSize; set => Set(value, ref _fontSize); }
|
||||
|
||||
[Display(Name = "UGC Service Type", Description = "Service for downloading mods", GroupName = "Server")]
|
||||
public UGCServiceType UgcServiceType
|
||||
{
|
||||
get => _ugcServiceType;
|
||||
set => Set(value, ref _ugcServiceType);
|
||||
}
|
||||
|
||||
public string LastUsedTheme { get; set; } = "Torch Theme";
|
||||
|
||||
//Prevent reserved players being written to disk, but allow it to be read
|
||||
//remove this when ReservedPlayers is removed
|
||||
private bool ShouldSerializeReservedPlayers() => false;
|
||||
|
||||
[Arg("console", "Keeps a separate console window open after the main UI loads.")]
|
||||
[Display(Name = "Independent Console", Description = "Keeps a separate console window open after the main UI loads.", GroupName = "Window")]
|
||||
public bool IndependentConsole { get => _independentConsole; set => Set(value, ref _independentConsole); }
|
||||
|
||||
internal Point WindowSize { get; set; } = new Point(800, 600);
|
||||
internal Point WindowPosition { get; set; } = new Point();
|
||||
[XmlIgnore]
|
||||
private string _path;
|
||||
[Arg("testplugin", "Path to a plugin to debug. For development use only.")]
|
||||
public string TestPlugin { get; set; }
|
||||
|
||||
public TorchConfig() : this("Torch") { }
|
||||
[Arg("asserts", "Enable Keen's assert logging.")]
|
||||
[Display(Name = "Enable Asserts", Description = "Enable Keen's assert logging.", GroupName = "Server")]
|
||||
public bool EnableAsserts { get => _enableAsserts; set => Set(value, ref _enableAsserts); }
|
||||
|
||||
public TorchConfig(string instanceName = "Torch", string instancePath = null)
|
||||
[Display(Name = "Enable Entity Manager", Description = "Enable Entity Manager tab. (can affect performance)",
|
||||
GroupName = "Server")]
|
||||
public bool EntityManagerEnabled
|
||||
{
|
||||
InstanceName = instanceName;
|
||||
InstancePath = instancePath ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SpaceEngineersDedicated");
|
||||
get => _entityManagerEnabled;
|
||||
set => Set(value, ref _entityManagerEnabled);
|
||||
}
|
||||
|
||||
public static TorchConfig LoadFrom(string path)
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public TorchConfig() { }
|
||||
|
||||
protected void Set<T>(T value, ref T field, [CallerMemberName] string callerName = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ser = new XmlSerializer(typeof(TorchConfig));
|
||||
using (var f = File.OpenRead(path))
|
||||
{
|
||||
var config = (TorchConfig)ser.Deserialize(f);
|
||||
config._path = path;
|
||||
return config;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error(e);
|
||||
return null;
|
||||
}
|
||||
field = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(callerName));
|
||||
}
|
||||
|
||||
public bool Save(string path = null)
|
||||
{
|
||||
if (path == null)
|
||||
path = _path;
|
||||
else
|
||||
_path = path;
|
||||
|
||||
try
|
||||
{
|
||||
var ser = new XmlSerializer(typeof(TorchConfig));
|
||||
using (var f = File.Create(path))
|
||||
ser.Serialize(f, this);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// for backward compatibility
|
||||
public void Save(string path = null) => Initializer.Instance?.ConfigPersistent?.Save(path);
|
||||
}
|
||||
}
|
||||
|
@@ -1,40 +1,35 @@
|
||||
using Sandbox;
|
||||
using Sandbox.Engine.Utils;
|
||||
using Sandbox.Game;
|
||||
using Sandbox.Game.World;
|
||||
#region
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xml.Serialization.GeneratedAssembly;
|
||||
using Microsoft.Diagnostics.Runtime;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Analytics;
|
||||
using PropertyChanged;
|
||||
using Sandbox;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Game.Multiplayer;
|
||||
using Sandbox.ModAPI;
|
||||
using SteamSDK;
|
||||
using Sandbox.Game.World;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.API.Session;
|
||||
using Torch.Managers;
|
||||
using Torch.Commands;
|
||||
using Torch.Managers.PatchManager;
|
||||
using Torch.Mod;
|
||||
using Torch.Mod.Messages;
|
||||
using Torch.Patches;
|
||||
using Torch.Server.Commands;
|
||||
using Torch.Server.Managers;
|
||||
using Torch.Utils;
|
||||
using VRage.Dedicated;
|
||||
using VRage.FileSystem;
|
||||
using VRage.Game;
|
||||
using VRage.Game.ModAPI;
|
||||
using VRage.Game.ObjectBuilder;
|
||||
using VRage.Game.SessionComponents;
|
||||
using VRage.Library;
|
||||
using VRage.ObjectBuilders;
|
||||
using VRage.Plugins;
|
||||
using VRage.Utils;
|
||||
using VRage;
|
||||
using Timer = System.Threading.Timer;
|
||||
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
|
||||
@@ -42,107 +37,116 @@ namespace Torch.Server
|
||||
{
|
||||
public class TorchServer : TorchBase, ITorchServer
|
||||
{
|
||||
//public MyConfigDedicated<MyObjectBuilder_SessionSettings> DedicatedConfig { get; set; }
|
||||
private bool _hasRun;
|
||||
private bool _canRun;
|
||||
private TimeSpan _elapsedPlayTime;
|
||||
private bool _isRunning;
|
||||
private float _simRatio;
|
||||
private ServerState _state;
|
||||
private Stopwatch _uptime;
|
||||
private Timer _watchdog;
|
||||
private int _players;
|
||||
private MultiplayerManagerDedicated _multiplayerManagerDedicated;
|
||||
|
||||
internal bool FatalException { get; set; }
|
||||
|
||||
private System.Timers.Timer _simUpdateTimer = new System.Timers.Timer(200);
|
||||
private bool _simDirty;
|
||||
|
||||
//Here to trigger rebuild
|
||||
/// <inheritdoc />
|
||||
public TorchServer(ITorchConfig config, string instancePath, string instanceName) : base(config)
|
||||
{
|
||||
InstancePath = instancePath;
|
||||
InstanceName = instanceName;
|
||||
DedicatedInstance = new InstanceManager(this);
|
||||
AddManager(DedicatedInstance);
|
||||
if (config.EntityManagerEnabled)
|
||||
AddManager(new EntityControlManager(this));
|
||||
AddManager(new RemoteAPIManager(this));
|
||||
|
||||
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
||||
sessionManager.AddFactory(x => new MultiplayerManagerDedicated(this));
|
||||
|
||||
// Needs to be done at some point after MyVRageWindows.Init
|
||||
// where the debug listeners are registered
|
||||
if (!((TorchConfig)Config).EnableAsserts)
|
||||
MyDebug.Listeners.Clear();
|
||||
_simUpdateTimer.Elapsed += SimUpdateElapsed;
|
||||
_simUpdateTimer.Start();
|
||||
}
|
||||
|
||||
private void SimUpdateElapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if (_simDirty)
|
||||
{
|
||||
OnPropertyChanged(nameof(SimulationRatio));
|
||||
_simDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasRun { get => _hasRun; set => SetValue(ref _hasRun, value); }
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public float SimulationRatio
|
||||
{
|
||||
get => _simRatio;
|
||||
set
|
||||
{
|
||||
if (_simRatio.IsEqual(value, 0.01f))
|
||||
return;
|
||||
|
||||
_simRatio = value;
|
||||
OnPropertyChanged();
|
||||
_simDirty = true;
|
||||
//SetValue(ref _simRatio, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public TimeSpan ElapsedPlayTime
|
||||
{
|
||||
get => _elapsedPlayTime;
|
||||
set
|
||||
{
|
||||
_elapsedPlayTime = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public TimeSpan ElapsedPlayTime { get => _elapsedPlayTime; set => SetValue(ref _elapsedPlayTime, value); }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Thread GameThread { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ServerState State
|
||||
{
|
||||
get => _state;
|
||||
private set
|
||||
{
|
||||
_state = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public bool IsRunning { get => _isRunning; set => SetValue(ref _isRunning, value); }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsRunning
|
||||
{
|
||||
get => _isRunning;
|
||||
set
|
||||
{
|
||||
_isRunning = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public bool CanRun { get => _canRun; set => SetValue(ref _canRun, value); }
|
||||
|
||||
/// <inheritdoc />
|
||||
public InstanceManager DedicatedInstance { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string InstanceName => Config?.InstanceName;
|
||||
public string InstanceName { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string InstancePath => Config?.InstancePath;
|
||||
|
||||
private bool _isRunning;
|
||||
private ServerState _state;
|
||||
private TimeSpan _elapsedPlayTime;
|
||||
private float _simRatio;
|
||||
private Timer _watchdog;
|
||||
private Stopwatch _uptime;
|
||||
|
||||
/// <inheritdoc />
|
||||
public TorchServer(TorchConfig config = null)
|
||||
{
|
||||
DedicatedInstance = new InstanceManager(this);
|
||||
AddManager(DedicatedInstance);
|
||||
AddManager(new EntityControlManager(this));
|
||||
Config = config ?? new TorchConfig();
|
||||
|
||||
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
||||
sessionManager.AddFactory((x) => new MultiplayerManagerDedicated(this));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override uint SteamAppId => 244850;
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc />
|
||||
protected override string SteamAppName => "SpaceEngineersDedicated";
|
||||
|
||||
/// <inheritdoc />
|
||||
public ServerState State { get => _state; private set => SetValue(ref _state, value); }
|
||||
|
||||
public event Action<ITorchServer> Initialized;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string InstancePath { get; }
|
||||
|
||||
public int OnlinePlayers { get => _players; private set => SetValue(ref _players, value); }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Init()
|
||||
{
|
||||
Log.Info($"Init server '{Config.InstanceName}' at '{Config.InstancePath}'");
|
||||
Sandbox.Engine.Platform.Game.IsDedicated = true;
|
||||
|
||||
Log.Info("Initializing server");
|
||||
MySandboxGame.IsDedicated = true;
|
||||
base.Init();
|
||||
|
||||
Managers.GetManager<ITorchSessionManager>().SessionStateChanged += OnSessionStateChanged;
|
||||
GetManager<InstanceManager>().LoadInstance(Config.InstancePath);
|
||||
}
|
||||
|
||||
private void OnSessionStateChanged(ITorchSession session, TorchSessionState newState)
|
||||
{
|
||||
if (newState == TorchSessionState.Unloading || newState == TorchSessionState.Unloaded)
|
||||
{
|
||||
_watchdog?.Dispose();
|
||||
_watchdog = null;
|
||||
}
|
||||
GetManager<InstanceManager>().LoadInstance(InstancePath);
|
||||
CanRun = true;
|
||||
Initialized?.Invoke(this);
|
||||
Log.Info($"Initialized server '{InstanceName}' at '{InstancePath}'");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -150,12 +154,21 @@ namespace Torch.Server
|
||||
{
|
||||
if (State != ServerState.Stopped)
|
||||
return;
|
||||
|
||||
if (IsRunning || HasRun)
|
||||
{
|
||||
Restart();
|
||||
return;
|
||||
}
|
||||
|
||||
State = ServerState.Starting;
|
||||
IsRunning = true;
|
||||
HasRun = true;
|
||||
CanRun = false;
|
||||
PatchManager.CommitInternal();
|
||||
Log.Info("Starting server.");
|
||||
MySandboxGame.ConfigDedicated = DedicatedInstance.DedicatedConfig.Model;
|
||||
|
||||
DedicatedInstance.SaveConfig();
|
||||
_uptime = Stopwatch.StartNew();
|
||||
base.Start();
|
||||
}
|
||||
@@ -171,48 +184,74 @@ namespace Torch.Server
|
||||
|
||||
State = ServerState.Stopped;
|
||||
IsRunning = false;
|
||||
CanRun = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restart the program.
|
||||
/// Restart the program.
|
||||
/// </summary>
|
||||
public override void Restart()
|
||||
public override void Restart(bool save = true)
|
||||
{
|
||||
Save(0).Wait();
|
||||
if (Config.DisconnectOnRestart)
|
||||
{
|
||||
foreach (var member in MyMultiplayer.Static.Members)
|
||||
{
|
||||
MyMultiplayer.Static.DisconnectClient(member);
|
||||
}
|
||||
|
||||
Log.Info("Ejected all players from server for restart.");
|
||||
}
|
||||
|
||||
Stop();
|
||||
// TODO clone this
|
||||
var config = (TorchConfig)Config;
|
||||
LogManager.Flush();
|
||||
|
||||
var exe = Assembly.GetExecutingAssembly().Location;
|
||||
((TorchConfig)Config).WaitForPID = Process.GetCurrentProcess().Id.ToString();
|
||||
Config.Autostart = true;
|
||||
Process.Start(exe, Config.ToString());
|
||||
string exe = Assembly.GetExecutingAssembly().Location.Replace("dll", "exe");
|
||||
config.WaitForPID = Environment.ProcessId.ToString();
|
||||
config.TempAutostart = true;
|
||||
Process.Start(exe, config.ToString());
|
||||
|
||||
Process.GetCurrentProcess().Kill();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
[SuppressPropertyChangedWarnings]
|
||||
private void OnSessionStateChanged(ITorchSession session, TorchSessionState newState)
|
||||
{
|
||||
if (newState == TorchSessionState.Unloading || newState == TorchSessionState.Unloaded)
|
||||
{
|
||||
_watchdog?.Dispose();
|
||||
_watchdog = null;
|
||||
ModCommunication.Unregister();
|
||||
}
|
||||
|
||||
if (newState == TorchSessionState.Loaded)
|
||||
{
|
||||
_multiplayerManagerDedicated = CurrentSession.Managers.GetManager<MultiplayerManagerDedicated>();
|
||||
CurrentSession.Managers.GetManager<CommandManager>().RegisterCommandModule(typeof(WhitelistCommands));
|
||||
ModCommunication.Register();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Init(object gameInstance)
|
||||
{
|
||||
base.Init(gameInstance);
|
||||
var game = gameInstance as MySandboxGame;
|
||||
if (game != null && MySession.Static != null)
|
||||
{
|
||||
if (gameInstance is MySandboxGame && MySession.Static != null)
|
||||
State = ServerState.Running;
|
||||
// SteamServerAPI.Instance.GameServer.SetKeyValue("SM", "Torch");
|
||||
}
|
||||
else
|
||||
{
|
||||
State = ServerState.Stopped;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
SimulationRatio = Sync.ServerSimulationRatio;
|
||||
// Stops 1.00-1.02 flicker.
|
||||
SimulationRatio = Math.Min(Sync.ServerSimulationRatio, 1);
|
||||
var elapsed = TimeSpan.FromSeconds(Math.Floor(_uptime.Elapsed.TotalSeconds));
|
||||
ElapsedPlayTime = elapsed;
|
||||
OnlinePlayers = _multiplayerManagerDedicated?.Players.Count ?? 0;
|
||||
|
||||
if (_watchdog == null && Config.TickTimeout > 0)
|
||||
{
|
||||
@@ -226,10 +265,16 @@ namespace Torch.Server
|
||||
|
||||
private static void CheckServerResponding(object state)
|
||||
{
|
||||
var server = (TorchServer)state;
|
||||
var mre = new ManualResetEvent(false);
|
||||
((TorchServer) state).Invoke(() => mre.Set());
|
||||
server.Invoke(() => mre.Set());
|
||||
if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout)))
|
||||
{
|
||||
if (server.FatalException)
|
||||
{
|
||||
server._watchdog.Dispose();
|
||||
return;
|
||||
}
|
||||
#if DEBUG
|
||||
Log.Error(
|
||||
$"Server watchdog detected that the server was frozen for at least {((TorchServer) state).Config.TickTimeout} seconds.");
|
||||
@@ -239,10 +284,8 @@ namespace Torch.Server
|
||||
throw new TimeoutException($"Server watchdog detected that the server was frozen for at least {((TorchServer)state).Config.TickTimeout} seconds.");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Debug("Server watchdog responded");
|
||||
}
|
||||
|
||||
Log.Debug("Server watchdog responded");
|
||||
}
|
||||
|
||||
private static string DumpFrozenThread(Thread thread, int traces = 3, int pause = 5000)
|
||||
@@ -251,11 +294,12 @@ namespace Torch.Server
|
||||
var totalSize = 0;
|
||||
for (var i = 0; i < traces; i++)
|
||||
{
|
||||
string dump = DumpStack(thread).ToString();
|
||||
string dump = DumpStack(thread);
|
||||
totalSize += dump.Length;
|
||||
stacks.Add(dump);
|
||||
Thread.Sleep(pause);
|
||||
}
|
||||
|
||||
string commonPrefix = StringUtils.CommonSuffix(stacks);
|
||||
// Advance prefix to include the line terminator.
|
||||
commonPrefix = commonPrefix.Substring(commonPrefix.IndexOf('\n') + 1);
|
||||
@@ -269,73 +313,77 @@ namespace Torch.Server
|
||||
result.AppendLine($"Suffix {i}");
|
||||
result.AppendLine(stacks[i].Substring(0, stacks[i].Length - commonPrefix.Length));
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
private static StackTrace DumpStack(Thread thread)
|
||||
private static string DumpStack(Thread thread)
|
||||
{
|
||||
try
|
||||
// Deprecated in .NET Core and later
|
||||
// try
|
||||
// {
|
||||
// thread.Suspend();
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // ignored
|
||||
// }
|
||||
//
|
||||
// var stack = new StackTrace(thread, true);
|
||||
// try
|
||||
// {
|
||||
// thread.Resume();
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // ignored
|
||||
// }
|
||||
//
|
||||
// return stack.ToString();
|
||||
|
||||
// Modified from https://www.examplefiles.net/cs/579311
|
||||
using (var target = DataTarget.CreateSnapshotAndAttach(Environment.ProcessId))
|
||||
{
|
||||
thread.Suspend();
|
||||
var runtime = target.ClrVersions[0].CreateRuntime();
|
||||
|
||||
var clrThread = runtime.Threads.First(b => b.ManagedThreadId == thread.ManagedThreadId);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendFormat(
|
||||
"ManagedThreadId: {0}, Name: {1}, OSThreadId: {2}, Thread: IsAlive: {3}, IsBackground: {4}, IsThreadPool: {5}",
|
||||
thread.ManagedThreadId,
|
||||
thread.Name,
|
||||
clrThread.OSThreadId,
|
||||
thread.IsAlive,
|
||||
thread.IsBackground,
|
||||
thread.IsThreadPoolThread)
|
||||
.AppendLine();
|
||||
|
||||
sb.AppendLine("Stack trace:");
|
||||
foreach (var frame in clrThread.EnumerateStackTrace())
|
||||
{
|
||||
sb.Append('\t');
|
||||
switch (frame.Kind)
|
||||
{
|
||||
case ClrStackFrameKind.Unknown:
|
||||
sb.AppendLine("[Unknown]");
|
||||
break;
|
||||
case ClrStackFrameKind.ManagedMethod:
|
||||
sb.AppendLine(frame.Method?.Signature ?? "[Unable to get method signature]");
|
||||
break;
|
||||
case ClrStackFrameKind.Runtime:
|
||||
sb.AppendLine("[CLR Runtime]");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(frame.Kind), frame.Kind, "Incorrect value in EnumerateStackTrace");
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
var stack = new StackTrace(thread, true);
|
||||
try
|
||||
{
|
||||
thread.Resume();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Task Save(long callerId)
|
||||
{
|
||||
return SaveGameAsync(statusCode => SaveCompleted(statusCode, callerId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for when save has finished.
|
||||
/// </summary>
|
||||
/// <param name="statusCode">Return code of the save operation</param>
|
||||
/// <param name="callerId">Caller of the save operation</param>
|
||||
private void SaveCompleted(SaveGameStatus statusCode, long callerId = 0)
|
||||
{
|
||||
string response = null;
|
||||
switch (statusCode)
|
||||
{
|
||||
case SaveGameStatus.Success:
|
||||
Log.Info("Save completed.");
|
||||
response = "Saved game.";
|
||||
break;
|
||||
case SaveGameStatus.SaveInProgress:
|
||||
Log.Error("Save failed, a save is already in progress.");
|
||||
response = "Save failed, a save is already in progress.";
|
||||
break;
|
||||
case SaveGameStatus.GameNotReady:
|
||||
Log.Error("Save failed, game was not ready.");
|
||||
response = "Save failed, game was not ready.";
|
||||
break;
|
||||
case SaveGameStatus.TimedOut:
|
||||
Log.Error("Save failed, save timed out.");
|
||||
response = "Save failed, save timed out.";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (MySession.Static.Players.TryGetPlayerId(callerId, out MyPlayer.PlayerId result))
|
||||
{
|
||||
Managers.GetManager<IChatManagerServer>()?.SendMessageAsOther("Server", response,
|
||||
statusCode == SaveGameStatus.Success ? MyFontEnum.Green : MyFontEnum.Red, result.SteamId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,13 @@
|
||||
using System;
|
||||
#if TORCH_SERVICE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ServiceProcess;
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
using Torch.API;
|
||||
|
||||
@@ -12,12 +15,14 @@ namespace Torch.Server
|
||||
{
|
||||
class TorchService : ServiceBase
|
||||
{
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
public const string Name = "Torch (SEDS)";
|
||||
private TorchServer _server;
|
||||
private Initializer _initializer;
|
||||
private string[] _args;
|
||||
|
||||
public TorchService()
|
||||
public TorchService(string[] args)
|
||||
{
|
||||
_args = args;
|
||||
var workingDir = new FileInfo(typeof(TorchService).Assembly.Location).Directory.ToString();
|
||||
Directory.SetCurrentDirectory(workingDir);
|
||||
_initializer = new Initializer(workingDir);
|
||||
@@ -29,19 +34,22 @@ namespace Torch.Server
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnStart(string[] args)
|
||||
protected override void OnStart(string[] _)
|
||||
{
|
||||
base.OnStart(args);
|
||||
base.OnStart(_args);
|
||||
|
||||
_initializer.Initialize(args);
|
||||
_initializer.Initialize(_args);
|
||||
_initializer.Run();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnStop()
|
||||
{
|
||||
_server.Stop();
|
||||
base.OnStop();
|
||||
var mre = new ManualResetEvent(false);
|
||||
Task.Run(() => _initializer.Server.Stop());
|
||||
if (!mre.WaitOne(TimeSpan.FromMinutes(1)))
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if TORCH_SERVICE
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -17,21 +18,8 @@ namespace Torch.Server
|
||||
|
||||
public TorchServiceInstaller()
|
||||
{
|
||||
var serviceProcessInstaller = new ServiceProcessInstaller();
|
||||
_serviceInstaller = new ServiceInstaller();
|
||||
|
||||
serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
|
||||
serviceProcessInstaller.Username = null;
|
||||
serviceProcessInstaller.Password = null;
|
||||
|
||||
_serviceInstaller.DisplayName = "Torch (SEDS)";
|
||||
_serviceInstaller.Description = "Service for Torch (SE Dedicated Server)";
|
||||
_serviceInstaller.StartType = ServiceStartMode.Manual;
|
||||
|
||||
_serviceInstaller.ServiceName = TorchService.Name;
|
||||
|
||||
Installers.Add(serviceProcessInstaller);
|
||||
Installers.Add(_serviceInstaller);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -59,3 +47,4 @@ namespace Torch.Server
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
49
Torch.Server/UnhandledExceptionHandler.cs
Normal file
49
Torch.Server/UnhandledExceptionHandler.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
using VRage;
|
||||
|
||||
namespace Torch.Server;
|
||||
|
||||
internal class UnhandledExceptionHandler
|
||||
{
|
||||
private readonly TorchConfig _config;
|
||||
private readonly bool _isService;
|
||||
private static readonly ILogger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public UnhandledExceptionHandler(TorchConfig config, bool isService)
|
||||
{
|
||||
_config = config;
|
||||
_isService = isService;
|
||||
}
|
||||
|
||||
internal void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
return;
|
||||
var ex = (Exception)e.ExceptionObject;
|
||||
Log.Fatal(ex.ToStringDemystified());
|
||||
LogManager.Flush();
|
||||
|
||||
if (_isService)
|
||||
Environment.Exit(1);
|
||||
|
||||
if (_config.RestartOnCrash)
|
||||
{
|
||||
Console.WriteLine("Restarting in 5 seconds.");
|
||||
Thread.Sleep(5000);
|
||||
var exe = typeof(Program).Assembly.Location;
|
||||
_config.WaitForPID = Environment.ProcessId.ToString();
|
||||
Process.Start(exe, _config.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
MyVRage.Platform.Windows.MessageBox(
|
||||
"Torch encountered a fatal error and needs to close. Please check the logs for details.",
|
||||
"Fatal exception", MessageBoxOptions.OkOnly);
|
||||
}
|
||||
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
@@ -11,19 +11,17 @@ namespace Torch.Server.ViewModels
|
||||
public class BlockLimitViewModel : ViewModel
|
||||
{
|
||||
private SessionSettingsViewModel _sessionSettings;
|
||||
private string _blockType;
|
||||
private short _limit;
|
||||
|
||||
public string BlockType { get => _blockType; set { _blockType = value; OnPropertyChanged(); } }
|
||||
public short Limit { get => _limit; set { _limit = value; OnPropertyChanged(); } }
|
||||
public string BlockType { get; set; }
|
||||
public short Limit { get; set; }
|
||||
|
||||
//public CommandBinding Delete { get; } = new CommandBinding(new DeleteCommand());
|
||||
|
||||
public BlockLimitViewModel(SessionSettingsViewModel sessionSettings, string blockType, short limit)
|
||||
{
|
||||
_sessionSettings = sessionSettings;
|
||||
_blockType = blockType;
|
||||
_limit = limit;
|
||||
BlockType = blockType;
|
||||
Limit = limit;
|
||||
}
|
||||
|
||||
/* TODO: figure out how WPF commands work
|
||||
|
124
Torch.Server/ViewModels/CheckpointViewModel.cs
Normal file
124
Torch.Server/ViewModels/CheckpointViewModel.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Torch.Collections;
|
||||
using VRage;
|
||||
using VRage.Game;
|
||||
using VRage.Game.ModAPI;
|
||||
using VRage.ObjectBuilders;
|
||||
using VRage.Serialization;
|
||||
using VRageMath;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
public class CheckpointViewModel : ViewModel
|
||||
{
|
||||
private readonly MyObjectBuilder_Checkpoint _checkpoint;
|
||||
//private SessionSettingsViewModel _sessionSettings;
|
||||
|
||||
public CheckpointViewModel(MyObjectBuilder_Checkpoint checkpoint)
|
||||
{
|
||||
_checkpoint = checkpoint;
|
||||
//_sessionSettings = new SessionSettingsViewModel(_checkpoint.Settings);
|
||||
}
|
||||
|
||||
public static implicit operator MyObjectBuilder_Checkpoint(CheckpointViewModel model)
|
||||
{
|
||||
return model._checkpoint;
|
||||
}
|
||||
|
||||
public Vector3I CurrentSector { get => _checkpoint.CurrentSector; set => SetValue(ref _checkpoint.CurrentSector, value); }
|
||||
|
||||
public long ElapsedGameTime { get => _checkpoint.ElapsedGameTime; set => SetValue(ref _checkpoint.ElapsedGameTime, value); }
|
||||
|
||||
public string SessionName { get => _checkpoint.SessionName; set => SetValue(ref _checkpoint.SessionName, value); }
|
||||
|
||||
public MyPositionAndOrientation SpectatorPosition { get => _checkpoint.SpectatorPosition; set => SetValue(ref _checkpoint.SpectatorPosition, value); }
|
||||
|
||||
public bool SpectatorIsLightOn { get => _checkpoint.SpectatorIsLightOn; set => SetValue(ref _checkpoint.SpectatorIsLightOn, value); }
|
||||
|
||||
public MyCameraControllerEnum CameraController { get => _checkpoint.CameraController; set => SetValue(ref _checkpoint.CameraController, value); }
|
||||
|
||||
public long CameraEntity { get => _checkpoint.CameraEntity; set => SetValue(ref _checkpoint.CameraEntity, value); }
|
||||
|
||||
public long ControlledObject { get => _checkpoint.ControlledObject; set => SetValue(ref _checkpoint.ControlledObject, value); }
|
||||
|
||||
public string Password { get => _checkpoint.Password; set => SetValue(ref _checkpoint.Password, value); }
|
||||
|
||||
public string Description { get => _checkpoint.Description; set => SetValue(ref _checkpoint.Description, value); }
|
||||
|
||||
public DateTime LastSaveTime { get => _checkpoint.LastSaveTime; set => SetValue(ref _checkpoint.LastSaveTime, value); }
|
||||
|
||||
public float SpectatorDistance { get => _checkpoint.SpectatorDistance; set => SetValue(ref _checkpoint.SpectatorDistance, value); }
|
||||
|
||||
public ulong? WorkshopId { get => _checkpoint.WorkshopId; set => SetValue(ref _checkpoint.WorkshopId, value); }
|
||||
|
||||
public MyObjectBuilder_Toolbar CharacterToolbar { get => _checkpoint.CharacterToolbar; set => SetValue(ref _checkpoint.CharacterToolbar, value); }
|
||||
|
||||
public SerializableDictionary<long, MyObjectBuilder_Checkpoint.PlayerId> ControlledEntities { get => _checkpoint.ControlledEntities; set => SetValue(ref _checkpoint.ControlledEntities, value); }
|
||||
|
||||
//public SessionSettingsViewModel Settings
|
||||
//{
|
||||
// get => _sessionSettings;
|
||||
// set
|
||||
// {
|
||||
// SetValue(ref _sessionSettings, value);
|
||||
// _checkpoint.Settings = _sessionSettings;
|
||||
// }
|
||||
//}
|
||||
|
||||
public MyObjectBuilder_ScriptManager ScriptManagerData => throw new NotImplementedException();
|
||||
|
||||
public int AppVersion { get => _checkpoint.AppVersion; set => SetValue(ref _checkpoint.AppVersion, value); }
|
||||
|
||||
public MyObjectBuilder_FactionCollection Factions => throw new NotImplementedException();
|
||||
|
||||
//public List<MyObjectBuilder_Checkpoint.ModItem> Mods { get => _checkpoint.Mods; set => SetValue(ref _checkpoint.Mods, value); }
|
||||
|
||||
public SerializableDictionary<ulong, MyPromoteLevel> PromotedUsers { get => _checkpoint.PromotedUsers; set => SetValue(ref _checkpoint.PromotedUsers, value); }
|
||||
|
||||
public HashSet<ulong> CreativeTools { get => _checkpoint.CreativeTools; set => SetValue(ref _checkpoint.CreativeTools, value); }
|
||||
|
||||
public SerializableDefinitionId Scenario { get => _checkpoint.Scenario; set => SetValue(ref _checkpoint.Scenario, value); }
|
||||
|
||||
public List<MyObjectBuilder_Checkpoint.RespawnCooldownItem> RespawnCooldowns { get => _checkpoint.RespawnCooldowns; set => SetValue(ref _checkpoint.RespawnCooldowns, value); }
|
||||
|
||||
public List<MyObjectBuilder_Identity> Identities { get => _checkpoint.Identities; set => SetValue(ref _checkpoint.Identities, value); }
|
||||
|
||||
public List<MyObjectBuilder_Client> Clients { get => _checkpoint.Clients; set => SetValue(ref _checkpoint.Clients, value); }
|
||||
|
||||
public MyEnvironmentHostilityEnum? PreviousEnvironmentHostility { get => _checkpoint.PreviousEnvironmentHostility; set => SetValue(ref _checkpoint.PreviousEnvironmentHostility, value); }
|
||||
|
||||
public SerializableDictionary<MyObjectBuilder_Checkpoint.PlayerId, MyObjectBuilder_Player> AllPlayersData { get => _checkpoint.AllPlayersData; set => SetValue(ref _checkpoint.AllPlayersData, value); }
|
||||
|
||||
public SerializableDictionary<MyObjectBuilder_Checkpoint.PlayerId, List<Vector3>> AllPlayersColors { get => _checkpoint.AllPlayersColors; set => SetValue(ref _checkpoint.AllPlayersColors, value); }
|
||||
|
||||
public List<MyObjectBuilder_ChatHistory> ChatHistory { get => _checkpoint.ChatHistory; set => SetValue(ref _checkpoint.ChatHistory, value); }
|
||||
|
||||
public List<MyObjectBuilder_FactionChatHistory> FactionChatHistory { get => _checkpoint.FactionChatHistory; set => SetValue(ref _checkpoint.FactionChatHistory, value); }
|
||||
|
||||
public List<long> NonPlayerIdentities { get => _checkpoint.NonPlayerIdentities; set => SetValue(ref _checkpoint.NonPlayerIdentities, value); }
|
||||
|
||||
public SerializableDictionary<long, MyObjectBuilder_Gps> Gps { get => _checkpoint.Gps; set => SetValue(ref _checkpoint.Gps, value); }
|
||||
|
||||
public SerializableBoundingBoxD? WorldBoundaries { get => _checkpoint.WorldBoundaries; set => SetValue(ref _checkpoint.WorldBoundaries, value); }
|
||||
|
||||
public List<MyObjectBuilder_SessionComponent> SessionComponents { get => _checkpoint.SessionComponents; set => SetValue(ref _checkpoint.SessionComponents, value); }
|
||||
|
||||
public SerializableDefinitionId GameDefinition { get => _checkpoint.GameDefinition; set => SetValue(ref _checkpoint.GameDefinition, value); }
|
||||
|
||||
public HashSet<string> SessionComponentEnabled { get => _checkpoint.SessionComponentEnabled; set => SetValue(ref _checkpoint.SessionComponentEnabled, value); }
|
||||
|
||||
public HashSet<string> SessionComponentDisabled { get => _checkpoint.SessionComponentDisabled; set => SetValue(ref _checkpoint.SessionComponentDisabled, value); }
|
||||
|
||||
public DateTime InGameTime { get => _checkpoint.InGameTime; set => SetValue(ref _checkpoint.InGameTime, value); }
|
||||
|
||||
public string CustomLoadingScreenText { get => _checkpoint.CustomLoadingScreenText; set => SetValue(ref _checkpoint.CustomLoadingScreenText, value); }
|
||||
|
||||
public string CustomSkybox { get => _checkpoint.CustomSkybox; set => SetValue(ref _checkpoint.CustomSkybox, value); }
|
||||
|
||||
public int RequiresDX { get => _checkpoint.RequiresDX; set => SetValue(ref _checkpoint.RequiresDX, value); }
|
||||
}
|
||||
}
|
@@ -1,133 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Utils;
|
||||
using Torch.Collections;
|
||||
using Torch.Server.Managers;
|
||||
using Torch.Utils;
|
||||
using VRage.Game;
|
||||
using VRage.Game.ModAPI;
|
||||
using VRage.GameServices;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
public class ConfigDedicatedViewModel : ViewModel
|
||||
{
|
||||
private static readonly Logger Log = LogManager.GetLogger("Config");
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private MyConfigDedicated<MyObjectBuilder_SessionSettings> _config;
|
||||
public MyConfigDedicated<MyObjectBuilder_SessionSettings> Model => _config;
|
||||
|
||||
public ConfigDedicatedViewModel() : this(new MyConfigDedicated<MyObjectBuilder_SessionSettings>(""))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConfigDedicatedViewModel(MyConfigDedicated<MyObjectBuilder_SessionSettings> configDedicated)
|
||||
{
|
||||
_config = configDedicated;
|
||||
_config.IgnoreLastSession = true;
|
||||
SessionSettings = new SessionSettingsViewModel(_config.SessionSettings);
|
||||
Administrators = string.Join(Environment.NewLine, _config.Administrators);
|
||||
Banned = string.Join(Environment.NewLine, _config.Banned);
|
||||
Mods = string.Join(Environment.NewLine, _config.Mods);
|
||||
Task.Run(() => UpdateAllModInfosAsync());
|
||||
}
|
||||
|
||||
public void Save(string path = null)
|
||||
{
|
||||
var newline = new [] {Environment.NewLine};
|
||||
Validate();
|
||||
|
||||
_config.Administrators.Clear();
|
||||
foreach (var admin in Administrators.Split(newline, StringSplitOptions.RemoveEmptyEntries))
|
||||
_config.Administrators.Add(admin);
|
||||
|
||||
_config.Banned.Clear();
|
||||
foreach (var banned in Banned.Split(newline, StringSplitOptions.RemoveEmptyEntries))
|
||||
_config.Banned.Add(ulong.Parse(banned));
|
||||
|
||||
_config.Mods.Clear();
|
||||
foreach (var mod in Mods.Split(newline, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (ulong.TryParse(mod, out ulong modId))
|
||||
_config.Mods.Add(modId);
|
||||
else
|
||||
Log.Warn($"'{mod}' is not a valid mod ID.");
|
||||
}
|
||||
|
||||
// Never ever
|
||||
_config.SessionSettings = SessionSettings;
|
||||
_config.IgnoreLastSession = true;
|
||||
_config.Save(path);
|
||||
}
|
||||
|
||||
private SessionSettingsViewModel _sessionSettings;
|
||||
public SessionSettingsViewModel SessionSettings { get => _sessionSettings; set { _sessionSettings = value; OnPropertyChanged(); } }
|
||||
|
||||
public MtObservableList<string> WorldPaths { get; } = new MtObservableList<string>();
|
||||
private string _administrators;
|
||||
public string Administrators { get => _administrators; set { _administrators = value; OnPropertyChanged(); } }
|
||||
private string _banned;
|
||||
public string Banned { get => _banned; set { _banned = value; OnPropertyChanged(); } }
|
||||
private string _mods;
|
||||
public string Mods { get => _mods; set { _mods = value; OnPropertyChanged(); } }
|
||||
|
||||
public int AsteroidAmount
|
||||
public bool Validate()
|
||||
{
|
||||
get { return _config.AsteroidAmount; }
|
||||
set { _config.AsteroidAmount = value; OnPropertyChanged(); }
|
||||
if (SelectedWorld == null)
|
||||
{
|
||||
Log.Warn($"{nameof(SelectedWorld)} == null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LoadWorld == null)
|
||||
{
|
||||
Log.Warn($"{nameof(LoadWorld)} == null");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ulong GroupId
|
||||
public SessionSettingsViewModel SessionSettings { get; set; }
|
||||
|
||||
public MtObservableList<WorldViewModel> Worlds { get; } = new MtObservableList<WorldViewModel>();
|
||||
private WorldViewModel _selectedWorld;
|
||||
public WorldViewModel SelectedWorld
|
||||
{
|
||||
get { return _config.GroupID; }
|
||||
set { _config.GroupID = value; OnPropertyChanged(); }
|
||||
get => _selectedWorld;
|
||||
set
|
||||
{
|
||||
SetValue(ref _selectedWorld, value);
|
||||
SessionSettings = value.WorldConfiguration.Settings;
|
||||
LoadWorld = _selectedWorld?.WorldPath;
|
||||
}
|
||||
}
|
||||
|
||||
public string IP
|
||||
public Task UpdateAllModInfosAsync()
|
||||
{
|
||||
get { return _config.IP; }
|
||||
set { _config.IP = value; OnPropertyChanged(); }
|
||||
return Task.CompletedTask;
|
||||
/*if (!Mods.Any())
|
||||
return;
|
||||
List<MyWorkshopItem> modInfos;
|
||||
try
|
||||
{
|
||||
modInfos = await WorkshopQueryUtils.GetModsInfo(Mods.Select(b =>
|
||||
new MyObjectBuilder_Checkpoint.ModItem(b.PublishedFileId, b.UgcService, b.IsDependency)));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Info("Mods Info successfully retrieved!");
|
||||
|
||||
foreach (var modItem in Mods
|
||||
.Select(b => new MyObjectBuilder_Checkpoint.ModItem(b.PublishedFileId, b.UgcService))
|
||||
.Except(modInfos.Select(b => new MyObjectBuilder_Checkpoint.ModItem(b.Id, b.ServiceName))))
|
||||
{
|
||||
Log.Error($"Unable to retreive info about {modItem.PublishedFileId}:{modItem.PublishedServiceName}");
|
||||
}*/
|
||||
}
|
||||
|
||||
public int Port
|
||||
public List<string> Administrators { get => _config.Administrators; set => SetValue(x => _config.Administrators = x, value); }
|
||||
|
||||
public List<ulong> Banned { get => _config.Banned; set => SetValue(x => _config.Banned = x, value); }
|
||||
|
||||
private MtObservableList<ModItemInfo> _mods = new MtObservableList<ModItemInfo>();
|
||||
public MtObservableList<ModItemInfo> Mods
|
||||
{
|
||||
get { return _config.ServerPort; }
|
||||
set { _config.ServerPort = value; OnPropertyChanged(); }
|
||||
get => _mods;
|
||||
set
|
||||
{
|
||||
SetValue(x => _mods = x, value);
|
||||
Task.Run(() => UpdateAllModInfosAsync());
|
||||
}
|
||||
}
|
||||
|
||||
public string ServerName
|
||||
{
|
||||
get { return _config.ServerName; }
|
||||
set { _config.ServerName = value; OnPropertyChanged(); }
|
||||
}
|
||||
public List<ulong> Reserved { get => _config.Reserved; set => SetValue(x => _config.Reserved = x, value); }
|
||||
|
||||
public bool PauseGameWhenEmpty
|
||||
{
|
||||
get { return _config.PauseGameWhenEmpty; }
|
||||
set { _config.PauseGameWhenEmpty = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public string PremadeCheckpointPath
|
||||
{
|
||||
get { return _config.PremadeCheckpointPath; }
|
||||
set { _config.PremadeCheckpointPath = value; OnPropertyChanged(); }
|
||||
}
|
||||
public int AsteroidAmount { get => _config.AsteroidAmount; set => SetValue(x => _config.AsteroidAmount = x, value); }
|
||||
|
||||
public string LoadWorld
|
||||
{
|
||||
get { return _config.LoadWorld; }
|
||||
set { _config.LoadWorld = value; OnPropertyChanged(); }
|
||||
}
|
||||
public ulong GroupId { get => _config.GroupID; set => SetValue(x => _config.GroupID = x, value); }
|
||||
|
||||
public int SteamPort
|
||||
{
|
||||
get { return _config.SteamPort; }
|
||||
set { _config.SteamPort = value; OnPropertyChanged(); }
|
||||
}
|
||||
public string IP { get => _config.IP; set => SetValue(x => _config.IP = x, value); }
|
||||
|
||||
public string WorldName
|
||||
public int Port { get => _config.ServerPort; set => SetValue(x => _config.ServerPort = x, value); }
|
||||
|
||||
public string ServerName { get => _config.ServerName; set => SetValue(x => _config.ServerName = x, value); }
|
||||
|
||||
public string ServerDescription { get => _config.ServerDescription; set => SetValue(x => _config.ServerDescription = x, value); }
|
||||
|
||||
public bool PauseGameWhenEmpty { get => _config.PauseGameWhenEmpty; set => SetValue(x => _config.PauseGameWhenEmpty = x, value); }
|
||||
|
||||
public bool AutodetectDependencies { get => _config.AutodetectDependencies; set => SetValue(x => _config.AutodetectDependencies = x, value); }
|
||||
|
||||
public string PremadeCheckpointPath { get => _config.PremadeCheckpointPath; set => SetValue(x => _config.PremadeCheckpointPath = x, value); }
|
||||
|
||||
public string LoadWorld { get => _config.LoadWorld; set => SetValue(x => _config.LoadWorld = x, value); }
|
||||
|
||||
public int SteamPort { get => _config.SteamPort; set => SetValue(x => _config.SteamPort = x, value); }
|
||||
|
||||
public string WorldName { get => _config.WorldName; set => SetValue(x => _config.WorldName = x, value); }
|
||||
|
||||
//this is a damn server password. I don't care if this is insecure. Bite me.
|
||||
private string _password;
|
||||
public string Password
|
||||
{
|
||||
get { return _config.WorldName; }
|
||||
set { _config.WorldName = value; OnPropertyChanged(); }
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_password))
|
||||
{
|
||||
if (string.IsNullOrEmpty(_config.ServerPasswordHash))
|
||||
return string.Empty;
|
||||
return "**********";
|
||||
}
|
||||
return _password;
|
||||
}
|
||||
set
|
||||
{
|
||||
_password = value;
|
||||
if(!string.IsNullOrEmpty(value))
|
||||
_config.SetPassword(value);
|
||||
else
|
||||
{
|
||||
_config.ServerPasswordHash = null;
|
||||
_config.ServerPasswordSalt = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,17 +15,19 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
{
|
||||
public class BlockViewModel : EntityViewModel
|
||||
{
|
||||
public IMyTerminalBlock Block { get; }
|
||||
public IMyTerminalBlock Block => (IMyTerminalBlock) Entity;
|
||||
public MtObservableList<PropertyViewModel> Properties { get; } = new MtObservableList<PropertyViewModel>();
|
||||
|
||||
public string FullName => $"{Block.CubeGrid.CustomName} - {Block.CustomName}";
|
||||
public string FullName => $"{Block?.CubeGrid.CustomName} - {Block?.CustomName}";
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get => Block?.CustomName ?? "null";
|
||||
set
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.Invoke(() =>
|
||||
#pragma warning restore CS0618
|
||||
{
|
||||
Block.CustomName = value;
|
||||
OnPropertyChanged();
|
||||
@@ -38,10 +40,12 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
|
||||
public long BuiltBy
|
||||
{
|
||||
get => ((MySlimBlock)Block.SlimBlock).BuiltBy;
|
||||
get => ((MySlimBlock)Block?.SlimBlock)?.BuiltBy ?? 0;
|
||||
set
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.Invoke(() =>
|
||||
#pragma warning restore CS0618
|
||||
{
|
||||
((MySlimBlock)Block.SlimBlock).TransferAuthorship(value);
|
||||
OnPropertyChanged();
|
||||
@@ -59,7 +63,6 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
|
||||
public BlockViewModel(IMyTerminalBlock block, EntityTreeViewModel tree) : base(block, tree)
|
||||
{
|
||||
Block = block;
|
||||
if (Block == null)
|
||||
return;
|
||||
|
||||
|
@@ -3,18 +3,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using NLog;
|
||||
using Sandbox.Game.Entities.Cube;
|
||||
using Sandbox.ModAPI;
|
||||
using Sandbox.ModAPI.Interfaces;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using NLog;
|
||||
using Sandbox.ModAPI.Interfaces.Terminal;
|
||||
|
||||
namespace Torch.Server.ViewModels.Blocks
|
||||
namespace Torch.Server.ViewModels.Entities.Blocks
|
||||
{
|
||||
public static class BlockViewModelGenerator
|
||||
{
|
||||
@@ -27,8 +21,8 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
static BlockViewModelGenerator()
|
||||
{
|
||||
_asmName = new AssemblyName("Torch.Server.ViewModels.Generated");
|
||||
_ab = AppDomain.CurrentDomain.DefineDynamicAssembly(_asmName, AssemblyBuilderAccess.RunAndSave);
|
||||
_mb = _ab.DefineDynamicModule(_asmName.Name);
|
||||
_ab = AssemblyBuilder.DefineDynamicAssembly(_asmName, AssemblyBuilderAccess.RunAndCollect);
|
||||
_mb = _ab.DefineDynamicModule(_asmName.Name ?? "Torch.Server.ViewModels.Generated");
|
||||
}
|
||||
|
||||
public static void GenerateModels()
|
||||
@@ -40,7 +34,6 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
GenerateModel(type);
|
||||
}
|
||||
}
|
||||
_ab.Save("Generated.dll", PortableExecutableKinds.ILOnly, ImageFileMachine.AMD64);
|
||||
}
|
||||
|
||||
public static Type GenerateModel(Type blockType, bool force = false)
|
||||
|
@@ -19,7 +19,9 @@ namespace Torch.Server.ViewModels.Blocks
|
||||
get => _prop.GetValue(Block.Block);
|
||||
set
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.Invoke(() =>
|
||||
#pragma warning restore CS0618
|
||||
{
|
||||
_prop.SetValue(Block.Block, value);
|
||||
OnPropertyChanged();
|
||||
|
@@ -4,9 +4,24 @@ namespace Torch.Server.ViewModels.Entities
|
||||
{
|
||||
public class CharacterViewModel : EntityViewModel
|
||||
{
|
||||
private MyCharacter _character;
|
||||
public CharacterViewModel(MyCharacter character, EntityTreeViewModel tree) : base(character, tree)
|
||||
{
|
||||
|
||||
_character = character;
|
||||
character.ControllerInfo.ControlAcquired += ControllerInfo_ControlAcquired;
|
||||
character.ControllerInfo.ControlReleased += ControllerInfo_ControlAcquired;
|
||||
}
|
||||
|
||||
private void ControllerInfo_ControlAcquired(Sandbox.Game.World.MyEntityController obj)
|
||||
{
|
||||
OnPropertyChanged(nameof(Name));
|
||||
OnPropertyChanged(nameof(CanDelete));
|
||||
}
|
||||
|
||||
public CharacterViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CanDelete => _character.ControllerInfo?.Controller?.Player == null;
|
||||
}
|
||||
}
|
||||
|
@@ -18,21 +18,9 @@ namespace Torch.Server.ViewModels.Entities
|
||||
OnPropertyChanged(SignalPropertyInvalidateControl);
|
||||
}
|
||||
|
||||
private bool _hide;
|
||||
|
||||
/// <summary>
|
||||
/// Should this element be forced into the <see cref="Visibility.Collapsed"/>
|
||||
/// </summary>
|
||||
public bool Hide
|
||||
{
|
||||
get => _hide;
|
||||
protected set
|
||||
{
|
||||
if (_hide == value)
|
||||
return;
|
||||
_hide = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public bool Hide { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Controls;
|
||||
using NLog;
|
||||
using Sandbox.Game.Entities;
|
||||
using Sandbox.Game.World;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Collections;
|
||||
using Torch.Server.Managers;
|
||||
using Torch.Utils;
|
||||
using VRage.Game.Entity;
|
||||
using VRage.Game.ModAPI;
|
||||
using VRage.ModAPI;
|
||||
using VRageMath;
|
||||
@@ -12,6 +20,8 @@ namespace Torch.Server.ViewModels.Entities
|
||||
{
|
||||
protected EntityTreeViewModel Tree { get; }
|
||||
|
||||
private static Logger _log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IMyEntity _backing;
|
||||
public IMyEntity Entity
|
||||
{
|
||||
@@ -20,7 +30,9 @@ namespace Torch.Server.ViewModels.Entities
|
||||
{
|
||||
_backing = value;
|
||||
OnPropertyChanged();
|
||||
#pragma warning disable CS0618
|
||||
EntityControls = TorchBase.Instance?.Managers.GetManager<EntityControlManager>()?.BoundModels(this);
|
||||
#pragma warning restore CS0618
|
||||
// ReSharper disable once ExplicitCallerInfoArgument
|
||||
OnPropertyChanged(nameof(EntityControls));
|
||||
}
|
||||
@@ -32,30 +44,116 @@ namespace Torch.Server.ViewModels.Entities
|
||||
|
||||
public virtual string Name
|
||||
{
|
||||
get => Entity.DisplayName;
|
||||
get => Entity?.DisplayName ?? (Entity != null ? $"eid:{Entity.EntityId}" : "nil");
|
||||
set
|
||||
{
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.DisplayName = value);
|
||||
if (Entity!=null)
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.DisplayName = value);
|
||||
#pragma warning restore CS0618
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private string _descriptiveName;
|
||||
public string DescriptiveName
|
||||
{
|
||||
get => _descriptiveName ??= GetSortedName(EntityTreeViewModel.SortEnum.Name);
|
||||
set => _descriptiveName = value;
|
||||
}
|
||||
|
||||
public virtual string GetSortedName(EntityTreeViewModel.SortEnum sort)
|
||||
{
|
||||
switch (sort)
|
||||
{
|
||||
case EntityTreeViewModel.SortEnum.Name:
|
||||
return Name;
|
||||
case EntityTreeViewModel.SortEnum.Size:
|
||||
return $"{Name} ({Entity.WorldVolume.Radius * 2:N}m)";
|
||||
case EntityTreeViewModel.SortEnum.Speed:
|
||||
return $"{Name} ({Entity.Physics?.LinearVelocity.Length() ?? 0:N}m/s)";
|
||||
case EntityTreeViewModel.SortEnum.BlockCount:
|
||||
if (Entity is MyCubeGrid grid)
|
||||
return $"{Name} ({grid.BlocksCount} blocks)";
|
||||
return Name;
|
||||
case EntityTreeViewModel.SortEnum.DistFromCenter:
|
||||
return $"{Name} ({Entity.GetPosition().Length():N}m)";
|
||||
case EntityTreeViewModel.SortEnum.Owner:
|
||||
if (Entity is MyCubeGrid g)
|
||||
return $"{Name} ({g.GetGridOwnerName()})";
|
||||
return Name;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(sort), sort, null);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int CompareToSort(EntityViewModel other, EntityTreeViewModel.SortEnum sort)
|
||||
{
|
||||
if (other == null)
|
||||
return -1;
|
||||
|
||||
switch (sort)
|
||||
{
|
||||
case EntityTreeViewModel.SortEnum.Name:
|
||||
if (Name == null)
|
||||
{
|
||||
if (other.Name == null)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
if (other.Name == null)
|
||||
return -1;
|
||||
return string.Compare(Name, other.Name, StringComparison.InvariantCultureIgnoreCase);
|
||||
case EntityTreeViewModel.SortEnum.Size:
|
||||
return Entity.WorldVolume.Radius.CompareTo(other.Entity.WorldVolume.Radius);
|
||||
case EntityTreeViewModel.SortEnum.Speed:
|
||||
if (Entity.Physics == null)
|
||||
{
|
||||
if (other.Entity.Physics == null)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
if (other.Entity.Physics == null)
|
||||
return 1;
|
||||
return Entity.Physics.LinearVelocity.LengthSquared().CompareTo(other.Entity.Physics.LinearVelocity.LengthSquared());
|
||||
case EntityTreeViewModel.SortEnum.BlockCount:
|
||||
{
|
||||
if (Entity is MyCubeGrid ga && other.Entity is MyCubeGrid gb)
|
||||
return ga.BlocksCount.CompareTo(gb.BlocksCount);
|
||||
goto case EntityTreeViewModel.SortEnum.Name;
|
||||
}
|
||||
case EntityTreeViewModel.SortEnum.DistFromCenter:
|
||||
return Entity.GetPosition().LengthSquared().CompareTo(other.Entity.GetPosition().LengthSquared());
|
||||
case EntityTreeViewModel.SortEnum.Owner:
|
||||
{
|
||||
if (Entity is MyCubeGrid ga && other.Entity is MyCubeGrid gb)
|
||||
return string.Compare(ga.GetGridOwnerName(), gb.GetGridOwnerName(), StringComparison.InvariantCultureIgnoreCase);
|
||||
goto case EntityTreeViewModel.SortEnum.Name;
|
||||
}
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(sort), sort, null);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string Position
|
||||
{
|
||||
get => Entity.GetPosition().ToString();
|
||||
get => Entity?.GetPosition().ToString();
|
||||
set
|
||||
{
|
||||
if (!Vector3D.TryParse(value, out Vector3D v))
|
||||
return;
|
||||
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.SetPosition(v));
|
||||
if (Entity != null)
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.SetPosition(v));
|
||||
#pragma warning restore CS0618
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CanStop => Entity.Physics?.Enabled ?? false;
|
||||
|
||||
public virtual bool CanDelete => !(Entity is IMyCharacter);
|
||||
public virtual bool CanDelete => true;
|
||||
|
||||
public virtual void Delete()
|
||||
{
|
||||
@@ -72,5 +170,20 @@ namespace Torch.Server.ViewModels.Entities
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class Comparer : IComparer<EntityViewModel>
|
||||
{
|
||||
private EntityTreeViewModel.SortEnum _sort;
|
||||
|
||||
public Comparer(EntityTreeViewModel.SortEnum sort)
|
||||
{
|
||||
_sort = sort;
|
||||
}
|
||||
|
||||
public int Compare(EntityViewModel x, EntityViewModel y)
|
||||
{
|
||||
return x?.CompareToSort(y, _sort) ?? default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,69 +1,117 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Sandbox.Definitions;
|
||||
using Sandbox.Game.Entities;
|
||||
using Sandbox.Game.Entities.Cube;
|
||||
using Sandbox.ModAPI;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Collections;
|
||||
using Torch.Server.ViewModels.Blocks;
|
||||
using VRage.Game;
|
||||
|
||||
namespace Torch.Server.ViewModels.Entities
|
||||
{
|
||||
public class GridViewModel : EntityViewModel, ILazyLoad
|
||||
{
|
||||
private MyCubeGrid Grid => (MyCubeGrid)Entity;
|
||||
public MtObservableList<BlockViewModel> Blocks { get; } = new MtObservableList<BlockViewModel>();
|
||||
private static readonly MyCubeBlockDefinition _fillerDefinition = new MyCubeBlockDefinition()
|
||||
{
|
||||
Id = new MyDefinitionId(typeof(MyObjectBuilder_DefinitionBase), "")
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DescriptiveName { get; }
|
||||
private class CubeBlockDefinitionComparer : IComparer<MyCubeBlockDefinition>
|
||||
{
|
||||
public static readonly CubeBlockDefinitionComparer Default = new CubeBlockDefinitionComparer();
|
||||
|
||||
public GridViewModel() { }
|
||||
public int Compare(MyCubeBlockDefinition x, MyCubeBlockDefinition y)
|
||||
{
|
||||
if (x == null && y == null)
|
||||
return 0;
|
||||
if (x == null)
|
||||
return -1;
|
||||
if (y == null)
|
||||
return 1;
|
||||
if (ReferenceEquals(x, y))
|
||||
return 0;
|
||||
MyDefinitionId xi = x.Id;
|
||||
MyDefinitionId yi = y.Id;
|
||||
if (xi == yi)
|
||||
return 0;
|
||||
if (xi.TypeId != yi.TypeId)
|
||||
return string.CompareOrdinal(((Type) xi.TypeId).Name, ((Type) yi.TypeId).Name);
|
||||
return xi.SubtypeId == yi.SubtypeId ? 0 : string.CompareOrdinal(xi.SubtypeName, yi.SubtypeName);
|
||||
}
|
||||
}
|
||||
|
||||
private MyCubeGrid Grid => (MyCubeGrid) Entity;
|
||||
|
||||
public MtObservableSortedDictionary<MyCubeBlockDefinition, MtObservableSortedDictionary<long, BlockViewModel>>
|
||||
Blocks { get; } =
|
||||
new MtObservableSortedDictionary<MyCubeBlockDefinition, MtObservableSortedDictionary<long, BlockViewModel>>(
|
||||
CubeBlockDefinitionComparer.Default);
|
||||
|
||||
public GridViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public GridViewModel(MyCubeGrid grid, EntityTreeViewModel tree) : base(grid, tree)
|
||||
{
|
||||
DescriptiveName = $"{grid.DisplayName} ({grid.BlocksCount} blocks)";
|
||||
Blocks.Add(new BlockViewModel(null, Tree));
|
||||
//DescriptiveName = $"{grid.DisplayName} ({grid.BlocksCount} blocks)";
|
||||
Blocks.Add(_fillerDefinition, new MtObservableSortedDictionary<long, BlockViewModel>());
|
||||
}
|
||||
|
||||
private void Grid_OnBlockRemoved(Sandbox.Game.Entities.Cube.MySlimBlock obj)
|
||||
{
|
||||
if (obj.FatBlock != null)
|
||||
Blocks.RemoveWhere(b => b.Block.EntityId == obj.FatBlock?.EntityId);
|
||||
RemoveBlock(obj.FatBlock);
|
||||
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
|
||||
private void RemoveBlock(MyCubeBlock block)
|
||||
{
|
||||
if (!Blocks.TryGetValue(block.BlockDefinition, out var group))
|
||||
return;
|
||||
if (group.Remove(block.EntityId) && group.Count == 0 && Blocks.Count > 1)
|
||||
Blocks.Remove(block.BlockDefinition);
|
||||
}
|
||||
|
||||
private void AddBlock(MyTerminalBlock block)
|
||||
{
|
||||
if (!Blocks.TryGetValue(block.BlockDefinition, out var group))
|
||||
group = Blocks[block.BlockDefinition] = new MtObservableSortedDictionary<long, BlockViewModel>();
|
||||
group.Add(block.EntityId, new BlockViewModel(block, Tree));
|
||||
}
|
||||
|
||||
private void Grid_OnBlockAdded(Sandbox.Game.Entities.Cube.MySlimBlock obj)
|
||||
{
|
||||
var block = obj.FatBlock as IMyTerminalBlock;
|
||||
var block = obj.FatBlock as MyTerminalBlock;
|
||||
if (block != null)
|
||||
Blocks.Add(new BlockViewModel(block, Tree));
|
||||
AddBlock(block);
|
||||
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
|
||||
private bool _load;
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if (_load)
|
||||
return;
|
||||
|
||||
_load = true;
|
||||
Blocks.Clear();
|
||||
#pragma warning disable CS0618
|
||||
TorchBase.Instance.Invoke(() =>
|
||||
#pragma warning restore CS0618
|
||||
{
|
||||
foreach (var block in Grid.GetFatBlocks().Where(b => b is IMyTerminalBlock))
|
||||
{
|
||||
Blocks.Add(new BlockViewModel((IMyTerminalBlock)block, Tree));
|
||||
}
|
||||
Blocks.Clear();
|
||||
foreach (var block in Grid.GetFatBlocks().OfType<MyTerminalBlock>())
|
||||
AddBlock(block);
|
||||
|
||||
Grid.OnBlockAdded += Grid_OnBlockAdded;
|
||||
Grid.OnBlockRemoved += Grid_OnBlockRemoved;
|
||||
|
||||
Tree.ControlDispatcher.BeginInvoke(() =>
|
||||
{
|
||||
Blocks.Sort(b => b.Block.CustomName);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,26 +18,25 @@ namespace Torch.Server.ViewModels.Entities
|
||||
|
||||
public MtObservableList<GridViewModel> AttachedGrids { get; } = new MtObservableList<GridViewModel>();
|
||||
|
||||
public async Task UpdateAttachedGrids()
|
||||
public Task UpdateAttachedGrids()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
//TODO: fix
|
||||
return;
|
||||
|
||||
AttachedGrids.Clear();
|
||||
/*AttachedGrids.Clear();
|
||||
var box = Entity.WorldAABB;
|
||||
var entities = new List<MyEntity>();
|
||||
await TorchBase.Instance.InvokeAsync(() => MyEntities.GetTopMostEntitiesInBox(ref box, entities)).ConfigureAwait(false);
|
||||
foreach (var entity in entities.Where(e => e is IMyCubeGrid))
|
||||
{
|
||||
var gridModel = Tree.Grids.FirstOrDefault(g => g.Entity.EntityId == entity.EntityId);
|
||||
if (gridModel == null)
|
||||
if (Tree.Grids.TryGetValue(entity.EntityId, out var gridModel))
|
||||
{
|
||||
gridModel = new GridViewModel((MyCubeGrid)entity, Tree);
|
||||
Tree.Grids.Add(gridModel);
|
||||
Tree.Grids.Add(entity.EntityId, gridModel);
|
||||
}
|
||||
|
||||
AttachedGrids.Add(gridModel);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public VoxelMapViewModel(MyVoxelBase e, EntityTreeViewModel tree) : base(e, tree)
|
||||
|
@@ -12,32 +12,54 @@ using VRage.ModAPI;
|
||||
using System.Windows.Threading;
|
||||
using NLog;
|
||||
using Torch.Collections;
|
||||
using Torch.Server.Views.Entities;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
public class EntityTreeViewModel : ViewModel
|
||||
{
|
||||
public enum SortEnum
|
||||
{
|
||||
Name,
|
||||
Size,
|
||||
Speed,
|
||||
Owner,
|
||||
BlockCount,
|
||||
DistFromCenter,
|
||||
}
|
||||
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
//TODO: these should be sorted sets for speed
|
||||
public MtObservableList<GridViewModel> Grids { get; set; } = new MtObservableList<GridViewModel>();
|
||||
public MtObservableList<CharacterViewModel> Characters { get; set; } = new MtObservableList<CharacterViewModel>();
|
||||
public MtObservableList<EntityViewModel> FloatingObjects { get; set; } = new MtObservableList<EntityViewModel>();
|
||||
public MtObservableList<VoxelMapViewModel> VoxelMaps { get; set; } = new MtObservableList<VoxelMapViewModel>();
|
||||
public MtObservableSortedDictionary<long, GridViewModel> Grids { get; set; } = new MtObservableSortedDictionary<long, GridViewModel>();
|
||||
public MtObservableSortedDictionary<long, CharacterViewModel> Characters { get; set; } = new MtObservableSortedDictionary<long, CharacterViewModel>();
|
||||
public MtObservableSortedDictionary<long, EntityViewModel> FloatingObjects { get; set; } = new MtObservableSortedDictionary<long, EntityViewModel>();
|
||||
public MtObservableSortedDictionary<long, VoxelMapViewModel> VoxelMaps { get; set; } = new MtObservableSortedDictionary<long, VoxelMapViewModel>();
|
||||
public Dispatcher ControlDispatcher => _control.Dispatcher;
|
||||
|
||||
private EntityViewModel _currentEntity;
|
||||
public SortedView<GridViewModel> SortedGrids { get; }
|
||||
public SortedView<CharacterViewModel> SortedCharacters { get; }
|
||||
public SortedView<EntityViewModel> SortedFloatingObjects { get; }
|
||||
public SortedView<VoxelMapViewModel> SortedVoxelMaps { get; }
|
||||
|
||||
private UserControl _control;
|
||||
|
||||
public EntityViewModel CurrentEntity
|
||||
public EntityViewModel CurrentEntity { get; set; }
|
||||
|
||||
public SortEnum CurrentSort { get; set; }
|
||||
|
||||
// I hate you today WPF
|
||||
public EntityTreeViewModel() : this(null)
|
||||
{
|
||||
get => _currentEntity;
|
||||
set { _currentEntity = value; OnPropertyChanged(nameof(CurrentEntity)); }
|
||||
}
|
||||
|
||||
public EntityTreeViewModel(UserControl control)
|
||||
{
|
||||
_control = control;
|
||||
var comparer = new EntityViewModel.Comparer(CurrentSort);
|
||||
SortedGrids = new SortedView<GridViewModel>(Grids.Values, comparer);
|
||||
SortedCharacters = new SortedView<CharacterViewModel>(Characters.Values, comparer);
|
||||
SortedFloatingObjects = new SortedView<EntityViewModel>(FloatingObjects.Values, comparer);
|
||||
SortedVoxelMaps = new SortedView<VoxelMapViewModel>(VoxelMaps.Values, comparer);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
@@ -53,16 +75,19 @@ namespace Torch.Server.ViewModels
|
||||
switch (obj)
|
||||
{
|
||||
case MyCubeGrid grid:
|
||||
Grids.RemoveWhere(m => m.Id == grid.EntityId);
|
||||
Grids.Remove(grid.EntityId);
|
||||
break;
|
||||
case MyCharacter character:
|
||||
Characters.RemoveWhere(m => m.Id == character.EntityId);
|
||||
Characters.Remove(character.EntityId);
|
||||
break;
|
||||
case MyFloatingObject floating:
|
||||
FloatingObjects.RemoveWhere(m => m.Id == floating.EntityId);
|
||||
FloatingObjects.Remove(floating.EntityId);
|
||||
break;
|
||||
case MyVoxelBase voxel:
|
||||
VoxelMaps.RemoveWhere(m => m.Id == voxel.EntityId);
|
||||
if (voxel is MyPlanet || voxel is MyVoxelMap)
|
||||
{
|
||||
VoxelMaps.Remove(voxel.EntityId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -80,16 +105,19 @@ namespace Torch.Server.ViewModels
|
||||
switch (obj)
|
||||
{
|
||||
case MyCubeGrid grid:
|
||||
Grids.Add(new GridViewModel(grid, this));
|
||||
Grids.Add(grid.EntityId, new GridViewModel(grid, this));
|
||||
break;
|
||||
case MyCharacter character:
|
||||
Characters.Add(new CharacterViewModel(character, this));
|
||||
Characters.Add(character.EntityId, new CharacterViewModel(character, this));
|
||||
break;
|
||||
case MyFloatingObject floating:
|
||||
FloatingObjects.Add(new FloatingObjectViewModel(floating, this));
|
||||
FloatingObjects.Add(floating.EntityId, new FloatingObjectViewModel(floating, this));
|
||||
break;
|
||||
case MyVoxelBase voxel:
|
||||
VoxelMaps.Add(new VoxelMapViewModel(voxel, this));
|
||||
if (voxel is MyPlanet || voxel is MyVoxelMap)
|
||||
{
|
||||
VoxelMaps.Add(voxel.EntityId, new VoxelMapViewModel(voxel, this));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
13
Torch.Server/ViewModels/LogViewerViewModel.cs
Normal file
13
Torch.Server/ViewModels/LogViewerViewModel.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Torch.Server.ViewModels;
|
||||
|
||||
public class LogViewerViewModel : ViewModel
|
||||
{
|
||||
public ObservableCollection<LogEntry> LogEntries { get; set; } = new();
|
||||
}
|
||||
|
||||
|
||||
public record LogEntry(DateTime Timestamp, string Message, SolidColorBrush Color);
|
115
Torch.Server/ViewModels/ModItemInfo.cs
Normal file
115
Torch.Server/ViewModels/ModItemInfo.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using VRage.Game;
|
||||
using Torch.Utils;
|
||||
using VRage.GameServices;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper around VRage.Game.Objectbuilder_Checkpoint.ModItem
|
||||
/// that holds additional meta information
|
||||
/// (e.g. workshop description)
|
||||
/// </summary>
|
||||
public class ModItemInfo : ViewModel
|
||||
{
|
||||
MyObjectBuilder_Checkpoint.ModItem _modItem;
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// Human friendly name of the mod
|
||||
/// </summary>
|
||||
public string FriendlyName
|
||||
{
|
||||
get => _modItem.FriendlyName;
|
||||
set => SetValue(ref _modItem.FriendlyName, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Workshop ID of the mod
|
||||
/// </summary>
|
||||
public ulong PublishedFileId
|
||||
{
|
||||
get => _modItem.PublishedFileId;
|
||||
set => SetValue(ref _modItem.PublishedFileId, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Local filename of the mod
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get => _modItem.Name;
|
||||
set => SetValue(ref _modItem.FriendlyName, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the mod was added
|
||||
/// because another mod depends on it
|
||||
/// </summary>
|
||||
public bool IsDependency
|
||||
{
|
||||
get => _modItem.IsDependency;
|
||||
set => SetValue(ref _modItem.IsDependency, value);
|
||||
}
|
||||
|
||||
private string _description;
|
||||
/// <summary>
|
||||
/// Workshop description of the mod
|
||||
/// </summary>
|
||||
public string Description
|
||||
{
|
||||
get => _description;
|
||||
set => SetValue(ref _description, value);
|
||||
}
|
||||
|
||||
public string UgcService
|
||||
{
|
||||
get => _modItem.PublishedServiceName;
|
||||
set => SetValue(ref _modItem.PublishedServiceName, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, returns a new ModItemInfo instance
|
||||
/// </summary>
|
||||
/// <param name="mod">The wrapped mod</param>
|
||||
public ModItemInfo(MyObjectBuilder_Checkpoint.ModItem mod)
|
||||
{
|
||||
_modItem = mod;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve information about the
|
||||
/// wrapped mod from the workhop asynchronously
|
||||
/// via the Steam web API.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> UpdateModInfoAsync()
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
/*if (UgcService.ToLower() == "mod.io")
|
||||
return true;
|
||||
|
||||
MyWorkshopItem modInfo;
|
||||
try
|
||||
{
|
||||
modInfo = await WorkshopQueryUtils.GetModInfo(_modItem);
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
Log.Error(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.Info("Mod Info successfully retrieved!");
|
||||
FriendlyName = modInfo.Title;
|
||||
Description = modInfo.Description;*/
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{PublishedFileId}-{UgcService}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -13,19 +13,13 @@ namespace Torch.Server.ViewModels
|
||||
public class PluginManagerViewModel : ViewModel
|
||||
{
|
||||
public MtObservableList<PluginViewModel> Plugins { get; } = new MtObservableList<PluginViewModel>();
|
||||
|
||||
private PluginViewModel _selectedPlugin;
|
||||
public PluginViewModel SelectedPlugin
|
||||
{
|
||||
get => _selectedPlugin;
|
||||
set { _selectedPlugin = value; OnPropertyChanged(nameof(SelectedPlugin)); }
|
||||
}
|
||||
public PluginViewModel SelectedPlugin { get; set; }
|
||||
|
||||
public PluginManagerViewModel() { }
|
||||
|
||||
public PluginManagerViewModel(IPluginManager pluginManager)
|
||||
{
|
||||
foreach (var plugin in pluginManager)
|
||||
foreach (var plugin in pluginManager.OrderBy(x=>x.Name))
|
||||
Plugins.Add(new PluginViewModel(plugin));
|
||||
pluginManager.PluginsLoaded += PluginManager_PluginsLoaded;
|
||||
}
|
||||
|
@@ -1,34 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using NLog;
|
||||
using Torch.API;
|
||||
using Torch.API.Plugins;
|
||||
using Torch.Server.Views;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
public class PluginViewModel
|
||||
{
|
||||
public UserControl Control
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Plugin is IWpfPlugin p)
|
||||
return p.GetControl();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public UserControl Control { get; }
|
||||
public string Name { get; }
|
||||
public ITorchPlugin Plugin { get; }
|
||||
|
||||
private static Logger _log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public PluginViewModel(ITorchPlugin plugin)
|
||||
{
|
||||
Plugin = plugin;
|
||||
|
||||
if (Plugin is IWpfPlugin p)
|
||||
{
|
||||
try
|
||||
{
|
||||
Control = p.GetControl();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(ex, $"Exception loading interface for plugin {Plugin.Name}! Plugin interface will not be available!");
|
||||
Control = null;
|
||||
}
|
||||
}
|
||||
|
||||
Name = $"{plugin.Name} ({plugin.Version})";
|
||||
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
UpdateResourceDict(ThemeControl.currentTheme);
|
||||
}
|
||||
|
||||
public void UpdateResourceDict(ResourceDictionary dictionary)
|
||||
{
|
||||
if (this.Control == null)
|
||||
return;
|
||||
|
||||
this.Control.Resources.MergedDictionaries.Clear();
|
||||
this.Control.Resources.MergedDictionaries.Add(dictionary);
|
||||
}
|
||||
|
||||
public Brush Color
|
||||
{
|
||||
get {
|
||||
switch (Plugin.State)
|
||||
{
|
||||
case PluginState.NotInitialized:
|
||||
case PluginState.MissingDependency:
|
||||
case PluginState.DisabledError:
|
||||
return Brushes.Red;
|
||||
case PluginState.UpdateRequired:
|
||||
return Brushes.DodgerBlue;
|
||||
case PluginState.UninstallRequested:
|
||||
return Brushes.Gold;
|
||||
case PluginState.NotInstalled:
|
||||
case PluginState.DisabledUser:
|
||||
return Brushes.Gray;
|
||||
case PluginState.Enabled:
|
||||
return Brushes.Transparent;
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ToolTip
|
||||
{
|
||||
get { switch (Plugin.State)
|
||||
{
|
||||
case PluginState.NotInitialized:
|
||||
return "Error during load.";
|
||||
case PluginState.DisabledError:
|
||||
return "Disabled due to error on load.";
|
||||
case PluginState.DisabledUser:
|
||||
return "Disabled.";
|
||||
case PluginState.UpdateRequired:
|
||||
return "Update required.";
|
||||
case PluginState.UninstallRequested:
|
||||
return "Marked for uninstall.";
|
||||
case PluginState.NotInstalled:
|
||||
return "Not installed. Click 'Enable'";
|
||||
case PluginState.Enabled:
|
||||
return string.Empty;
|
||||
case PluginState.MissingDependency:
|
||||
return "Dependency missing. Check the log.";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user