Compare commits

...

528 Commits

Author SHA1 Message Date
ab092125b0 fix sleet version
All checks were successful
Release / Get Version (push) Successful in 2m58s
Release / Build and Publish Package (push) Successful in 4m36s
Release / Build and Publish Nuget (push) Successful in 5m1s
2024-05-11 18:31:38 +00:00
e320d8fbd5 fucking m*crosoft
Some checks failed
Release / Get Version (push) Successful in 14s
Release / Build and Publish Package (push) Successful in 5m45s
Release / Build and Publish Nuget (push) Failing after 8m5s
2024-01-28 12:54:48 +00:00
2d28ce7415 Update .github/workflows/release.yaml
Some checks failed
Release / Get Version (push) Successful in 18s
Release / Build and Publish Package (push) Successful in 6m35s
Release / Build and Publish Nuget (push) Failing after 11m48s
2024-01-28 12:38:34 +00:00
fd64c77aed Update .github/workflows/release.yaml
Some checks failed
Release / Get Version (push) Successful in 12s
Release / Build and Publish Nuget (push) Failing after 2m40s
Release / Build and Publish Package (push) Successful in 3m41s
2024-01-17 10:16:24 +00:00
aeaf755d08 Update .github/workflows/release.yaml
Some checks failed
Release / Get Version (push) Successful in 12s
Release / Build and Publish Nuget (push) Failing after 5m20s
Release / Build and Publish Package (push) Successful in 6m2s
2024-01-17 09:53:00 +00:00
667f52f33b Update .github/workflows/release.yaml
Some checks failed
Release / Get Version (push) Successful in 27s
Release / Build and Publish Nuget (push) Failing after 2m1s
Release / Build and Publish Package (push) Failing after 2m56s
2024-01-16 17:49:07 +00:00
zznty
4c5751fccf . 2024-01-08 20:00:41 +07:00
zznty
bd11bc223d fucking dotnet breaking cringe 2024-01-08 19:51:06 +07:00
zznty
ccd04585c4 maybe 2024-01-08 19:48:16 +07:00
zznty
88ad741f3b dotnettt 2024-01-08 19:43:53 +07:00
zznty
29bfcced62 fix this cringe with rids 2024-01-08 19:40:44 +07:00
zznty
5fac281f37 update deps 2024-01-08 19:35:46 +07:00
zznty
6698359c08 Update Directory.Build.props 2023-12-18 18:40:47 +03:00
zznty
7bbdb79257 actually hardcode runtime version 2023-12-17 22:01:28 +07:00
zznty
afa40d3532 build selfcontained on windows because microsoft broke windows targeting in net8 2023-12-17 21:46:35 +07:00
zznty
4afae0fe56 net 8 target 2023-12-17 21:35:51 +07:00
zznty
f43e61c7bb fix dotnet version 2023-12-15 18:00:30 +07:00
zznty
646916dc7b force update dependencies 2023-12-14 00:56:46 +07:00
zznty
563c611e3e revert to net7 2023-12-06 17:23:15 +07:00
zznty
579b090c85 resolve rid ci issues 2023-12-06 16:21:42 +07:00
zznty
f49748da9f fix package warnings 2023-12-06 15:47:36 +07:00
zznty
534fdd0e49 fix build 2023-12-05 18:04:10 +07:00
zznty
6070bddd7d change nuget feed 2023-12-05 13:58:41 +03:00
zznty
d8e2d9fcec net8 update 2023-12-04 21:22:43 +07:00
zznty
615defabb6 update dependencies 2023-09-07 14:49:27 +07:00
zznty
0d719ee01f fix startup crash after update 2023-09-07 14:46:12 +07:00
22c4cfb039 Update for latest version 2023-09-04 13:47:48 -04:00
5f0ffb6f9a Merge remote-tracking branch 'origin/master' 2023-08-31 23:54:00 -04:00
1b2a989441 Update for 1.203.22 2023-08-31 23:53:46 -04:00
zznty
83dfc7152f properly handle sigterm and dont freeze forever on unload 2023-07-13 13:18:20 +07:00
d7e5f53e4f Fix SteamCMD args order + add quit arg 2023-07-10 01:46:28 -04:00
9b08b39a1f Switch from depot tool to SteamCMD 2023-07-10 01:25:31 -04:00
zznty
8011f9eed7 update harmony 2023-07-09 03:46:23 +07:00
1df791e7a8 Update for latest version, and have script compiler use Release x64 compilation 2023-07-07 22:37:52 -04:00
zznty
bbc2f9046f update packages 2023-07-06 03:00:08 +07:00
117ea7df91 Use config stuff for mod service to avoid calling MyGameService static constructor 2023-07-03 22:45:08 -04:00
6ec355f931 Call new action if action is being added to initialized event when already initialized 2023-07-02 13:37:51 -04:00
zznty
343420f1d8 fix initialization issues 2023-07-01 19:57:18 +07:00
zznty
1396c8b1da upgrade packages 2023-06-29 14:35:37 +07:00
zznty
9900f92133 init server before starting ui due to static ctors 2023-06-29 14:20:23 +07:00
zznty
3be524d169 expose custom config to plugins
add support for some basic game parameters to be set via custom config
2023-06-29 14:08:45 +07:00
ed694ae95b Move SetupBasicGameInfo to initializer so it can be called before ui thread init 2023-06-27 15:51:12 -04:00
e9a9e180a8 Move Init back to where it was to prevent UI init issues 2023-06-27 15:02:13 -04:00
a8dfaf6239 Fix MyEntities init 2023-06-27 13:04:52 -04:00
bbdd1c7e01 Update package dependency version 2023-06-21 22:41:31 -04:00
e70e1ca4e6 Fix NRE in MyGameService static constructor 2023-06-18 01:06:22 -04:00
zznty
d65c20a05d update se to 1.202.120 2023-06-13 22:42:35 +07:00
f21976cf2d Depot tool is still broken 2023-06-12 22:50:44 -04:00
0c918106bc Update package dependency 2023-05-29 12:46:40 -04:00
6c9ec57d87 Update for latest SE version 2023-05-29 12:32:49 -04:00
zznty
b0f491ac88 do not exit without autostart 2023-04-25 16:32:52 +07:00
zznty
a426ad9e02 fix steam redist missing on automatic download 2023-04-22 21:22:46 +07:00
zznty
ba75b1583a do not copy dlls in service mode as it can mess up with runtimes 2023-04-22 18:30:02 +07:00
zznty
45068ea932 remove requirement o sta thread in no gui scenarios 2023-04-22 02:51:29 +07:00
zznty
181e9297a1 fix packaging 2023-04-14 11:36:04 +07:00
zznty
e0417d3235 breaking: bump to v2 lmao 2023-04-14 11:15:57 +07:00
zznty
17a244a536 update nuget package and use autoversioning 2023-04-14 11:13:34 +07:00
zznty
bd27360655 update to new se 2023-04-14 11:05:36 +07:00
zznty
b24eee3ecf remove beta from depot tool install 2023-03-27 16:03:15 +07:00
zznty
9068558a53 fix patcher compat with __local thing 2023-03-24 14:49:42 +07:00
zznty
9c22948ce9 fix keen compiler assemblies fuckery 2023-02-21 22:43:30 +07:00
zznty
2b1a5d4c6e fix script compiler compat with event block mods 2023-02-19 19:44:00 +07:00
zznty
2860dda41b windows moment 2023-02-17 16:32:48 +07:00
zznty
5483728a4e use depot downloader instead of steamcmd because its having some troubles with branching 2023-02-17 16:11:35 +07:00
zznty
32d318be5e fix auto-updates and crash handler restart 2023-02-17 15:47:44 +07:00
zznty
f349366b58 add a bit more configuration for steam cmd updates 2023-02-17 12:47:39 +07:00
zznty
73ce979b54 update packages to new se version
keen has thrown a bunch of new static ctors so factory patch cannot be revied :(
2023-02-17 12:43:45 +07:00
zznty
73b95472bc remove harmony compat warning 2023-02-17 12:26:16 +07:00
zznty
9b832a998d use beta for steamcmd 2023-02-17 12:25:05 +07:00
zznty
b1087822c9 gitignore moment 2023-02-08 21:50:23 +07:00
zznty
ef2d35879c bump harmony version 2023-02-08 21:10:17 +07:00
zznty
83d8eea9ef use harmony instead of torch patcher 2023-02-08 21:00:21 +07:00
zznty
8cdd992350 build torch reference assemblies package so it will reference both torch.server and se assemblies packages 2023-02-08 16:10:07 +07:00
zznty
b9cb71e11f introduction of nuget packages as plugins support 2023-02-08 15:56:50 +07:00
zznty
1a1a7e779a versions for all packages 2023-01-30 18:00:38 +07:00
zznty
6bcd2ea58e windows moment 2023-01-24 16:27:31 +07:00
zznty
b8a06f7bd7 publish nuget package on release 2023-01-24 16:25:10 +07:00
zznty
d44b1a592c rewrite torch mod because casitard broke original 2023-01-24 16:09:19 +07:00
zznty
d7d556d2f2 fix for restart on crash too 2023-01-12 23:37:43 +07:00
zznty
850b313269 fix updates again 2023-01-12 23:29:37 +07:00
zznty
fe985e1a9c fix restart again 2023-01-12 23:20:44 +07:00
zznty
aeea192860 exit on restart 2023-01-09 22:02:54 +07:00
zznty
b8be5b2dce fix auto-updates 2023-01-05 00:48:11 +07:00
zznty
ea08d60d58 update protobuf 2023-01-05 00:41:49 +07:00
zznty
6493a305f7 remove retarded assembly version checks 2023-01-04 23:59:33 +07:00
zznty
bc0a2b89b8 fix entity updates and steam errors on game exit 2022-12-14 19:57:14 +07:00
zznty
846c2aa42e remove cache from ci 2022-12-12 13:29:40 +03:00
zznty
ac1ec431fd use lock files 2022-12-12 17:27:21 +07:00
zznty
3acaf25376 fix plugins ui crashes 2022-12-12 17:25:03 +07:00
zznty
e8928b6b3b fix PropertyGrid readonly is not copyable (#516)
(cherry picked from commit 09ddad495988beed896077f879998bf62cd0c8a8)
2022-12-02 15:45:59 +07:00
zznty
8478ee3752 cleanup for webapi things 2022-12-02 15:44:38 +07:00
zznty
ead8e3a4fc update 2022-12-02 15:23:11 +07:00
zznty
f73b9df924 net7 things 2022-11-20 23:13:16 +07:00
zznty
d524651da9 im a true retard 2022-11-06 21:07:18 +06:00
zznty
2743e5b42d okay 2022-11-06 21:02:41 +06:00
zznty
02bd9df059 fix because retarded exmaples 2022-11-06 21:00:24 +06:00
zznty
a5cc132151 add version string normalization 2022-11-06 20:57:56 +06:00
zznty
92dea1986c linux ci v5 2022-11-06 20:49:18 +06:00
zznty
c03eb79f81 linux ci v4 2022-11-06 20:46:54 +06:00
zznty
0ee9c5f97c test linux ci v3 2022-11-06 20:44:17 +06:00
zznty
c283059106 test linux ci v2 2022-11-06 20:41:26 +06:00
zznty
422963517f test building linux 2022-11-06 17:36:29 +03:00
zznty
d2ac0e44be correct whitelist for compiler 2022-10-16 02:09:44 +07:00
zznty
c5acf61f7c add auto-updates from github 2022-10-15 15:33:57 +07:00
zznty
197d04a661 fix steamcmd default directory 2022-10-15 15:33:09 +07:00
zznty
99ab7d0eea Merge remote-tracking branch 'pve/master' 2022-10-15 02:19:05 +07:00
zznty
17f97af52f add gslt login option (#515)
(cherry picked from commit c81f139fe6b5de0c9f7a005dc2cbe576f4ca8f67)
2022-10-15 02:09:09 +07:00
zznty
ed7c897bd2 Update README.md 2022-10-14 21:59:18 +03:00
zznty
e4d3c3987f fix ci changelog building 2022-10-14 21:48:43 +03:00
zznty
067d8802b6 change instance path resolving back to bin folder
i dont think we need to place our instance at game dir by default
2022-10-15 00:55:44 +07:00
zznty
8f32f64ede change script compilation manager lifetime
seems game loads faster than torch internals
2022-10-15 00:50:10 +07:00
zznty
90ff3f93f0 disable gc patch because conflicting with the same from plugin 2022-10-15 00:44:49 +07:00
zznty
ad28b302f9 add harmony logging 2022-10-15 00:42:23 +07:00
zznty
a0d0976a6a c# 10 and assembly unloading for in-game scripts 2022-10-15 00:16:00 +07:00
zznty
a9c9a0de68 refactor restart and config handling 2022-10-12 16:36:25 +07:00
zznty
9a967345b9 skip obfuscated assemblies from compatibility fixes 2022-10-10 20:31:59 +07:00
zznty
98a4be655f fix plugins download 2022-10-10 20:31:10 +07:00
zznty
76de8f3d0b fix ci zipping 2022-10-09 20:34:22 +07:00
zznty
6f886d4f7d fix for releases 2022-10-09 20:28:58 +07:00
zznty
a753abb8fd i love github and windows 2022-10-09 20:25:00 +07:00
zznty
452970d2fd add nuget source to ci 2022-10-09 20:14:25 +07:00
zznty
e28c38e04f update ci 2022-10-09 20:07:08 +07:00
zznty
5d9fe01c69 Update README.md 2022-10-09 15:58:28 +03:00
zznty
04227912b0 github ci 2022-10-09 19:55:22 +07:00
zznty
44dd0805e2 get rid of old ci files 2022-10-09 17:54:36 +07:00
zznty
c5c8e527da projects cleanup 2022-10-09 17:52:30 +07:00
zznty
49f68a8fcc allow selection for log lines 2022-10-09 17:51:45 +07:00
zznty
f8a3647308 seems to be configuration rework 2022-09-09 16:48:14 +07:00
zznty
0a40b1fe0f move some parts of main class to other
fix poorly implemented features
2022-06-05 15:50:03 +07:00
zznty
a1e9434444 remove compat for netframework 2022-06-05 15:43:15 +07:00
zznty
d2d96df8be fix csproj 2022-05-08 12:39:09 +07:00
zznty
b40f288827 Merge remote-tracking branch 'zznty/master'
# Conflicts:
#	Torch.API/Torch.API.csproj
#	Torch/Patches/ScriptCompilerPatch.cs
2022-05-08 12:36:22 +07:00
zznty
6267cffebe update packages 2022-05-08 12:30:05 +07:00
zznty
5fe25fb781 ship harmony with torch to prevent crashes due to runtime version mismatch
add warning if plugin is using harmony
update monomod package
2022-05-08 12:26:31 +07:00
zznty
d05e979ede remove unnecessary async lambda 2022-05-08 12:25:06 +07:00
zznty
1afb126cb5 fix plugin downloading on separated runtime directory 2022-05-08 12:24:38 +07:00
zznty
d52348149a fix scripts compilation 2022-05-08 11:44:12 +07:00
zznty
20eac508d3 clean up project files 2022-05-08 11:22:39 +07:00
zznty
8ba02a84d3 correct logging indent 2022-05-08 11:22:14 +07:00
zznty
15be85b4f5 forced lang version to 10 (as ryo requested)
all libs are now packed into directory
jenkins file is back
some directives to get net48 supported too
2022-03-16 20:34:01 +07:00
zznty
cf5c00ce0e fixed steamcmd path does not follow TORCH_GAME_PATH env variable 2022-03-07 13:25:38 +07:00
zznty
9c185d5577 fixed mods not being properly cleared from bulk edit
fixed bulk edit crash if input format is invalid
2022-03-05 20:19:01 +07:00
LTP
8b6c401531 fixed plugin dependencies resolution 2022-03-03 22:30:55 +07:00
z__
92db8994ef fixed ScriptCompilerPatch 2022-02-28 17:16:23 +07:00
z__
aee36661fd fixed keen log indent 2022-02-28 17:15:33 +07:00
z__
feda84fac8 Merge remote-tracking branch 'zznty/master' 2022-02-18 17:27:52 +07:00
z__
2503cd6372 fixed NRE in edit roles button 2022-02-18 17:27:40 +07:00
zznty
f321034eeb Update README.md 2022-02-16 10:08:20 +07:00
z__
7573684520 remove unnecessary information that breaks common suffixes 2022-02-12 02:02:09 +07:00
z__
223eaa9fd0 rebase online players counter to events 2022-02-12 01:58:00 +07:00
z__
d138a46f25 forced stop & restart in separate thread 2022-02-12 01:42:46 +07:00
z__
ce2bbd4a61 fix not implemented property 2022-02-12 01:40:38 +07:00
z__
85dd4b46b8 mods loading fixes 2022-02-12 00:40:10 +07:00
z__
166a9d1dbe logs limit 2022-02-12 00:37:00 +07:00
z__
dfc15354ca replace log config if it's from previous versions 2022-02-11 23:04:03 +07:00
z__
57c977deb4 remove load order display 2022-02-11 21:26:47 +07:00
z__
f6cdc2fe79 removed missing dockerfile in solution files 2022-02-11 15:35:53 +07:00
z__
f42b9c6674 dont forget to call 2022-02-09 20:26:37 +07:00
zznty
227557f421 Merge branch 'fixes' 2022-02-09 20:25:46 +07:00
z__
0632f68aaf it was needed, but with some checks 2022-02-09 20:25:09 +07:00
z__
0a9f299527 we dont need it anymore 2022-02-09 15:34:13 +07:00
z__
67f25ab20b transform ctor to extension method 2022-02-08 23:36:39 +07:00
z__
ad19a7dc9e better exception for invalid operand type 2022-02-08 23:26:25 +07:00
z__
dd854a159a ok high iq solutions is bad for compatibility 2022-02-04 15:11:49 +07:00
z__
879a373e6a added possibility to call SetConfiguration again if needed 2022-02-04 14:42:37 +07:00
z__
ec1b017946 added nlog custom targets assemblies loading 2022-02-04 14:33:32 +07:00
z__
cf75210304 fixed game analytics logger crash 2022-02-04 13:44:04 +07:00
z__
3696f18714 move nlog config to instance and move default to resources 2022-02-04 13:25:56 +07:00
z__
1f7e4e869d final fixes for warfare 2 2022-02-04 12:09:17 +07:00
z__
ba5b611994 add STA thread back, not being added automatically on local build 2022-02-04 10:38:47 +07:00
z__
2bcf79efdd to trigger autobuild to fix warfare 2 update 2022-02-04 09:47:22 +07:00
z__
d5c101bf19 i believe we're done 2022-02-03 19:49:16 +07:00
z__
e9841b4de1 now should work 2022-02-03 19:43:54 +07:00
z__
aea0011683 maybe 2022-02-03 19:41:13 +07:00
z__
d10528f9fe fixed RID 2022-02-03 19:39:07 +07:00
z__
66ea4d7307 build script update 2022-02-03 19:34:06 +07:00
z__
f6ce40a854 again updated ci buildfile 2022-02-03 19:04:42 +07:00
zznty
bd62d31298 trash dockerfile, it will be on separate repo 2022-02-03 18:50:15 +07:00
z__
b1cf5fb638 i wanna believe this is the last for appveyor.yml 2022-02-03 18:44:02 +07:00
z__
1d6a2a9a60 fix fucking github's new lines 2022-02-03 18:41:55 +07:00
zznty
455be2393e fix build error 2022-02-03 18:38:49 +07:00
zznty
6131a9003b corrently assign version on publish 2022-02-03 18:35:50 +07:00
zznty
2a17c4bc09 Update appveyor.yml
it cannot cache if size larger than 1gb 
so delete unnecessary files
2022-02-03 18:29:25 +07:00
zznty
ccc1df9349 Update appveyor.yml 2022-02-03 18:17:26 +07:00
z__
d80c7b9fba Merge remote-tracking branch 'zznty/master'
# Conflicts:
#	README.md
2022-02-03 18:03:57 +07:00
z__
64c6ce289c appveyor badge in README.md 2022-02-03 18:02:12 +07:00
z__
67de82a103 added appveyor as CI/CD 2022-02-03 18:00:47 +07:00
z__
357e0446df got it working on docker
fixed log closing exception
2022-02-03 17:03:49 +07:00
zznty
f2291a57c3 update discord link 2022-02-02 14:31:52 +07:00
z__
8b862df6ea Merge remote-tracking branch 'zznty/master' 2022-02-02 14:29:10 +07:00
z__
1c92f69bd4 updated NLog to v5
fixed most of issues with world creating/loading
fixed log window lags
fixed some compiler warnings
fixed empty log files creating
fixed logging performance
added better logging of load process
commands autocomplete in torch GUI
chat in torch GUI now has entered history (like console, use up/down arrows)
abstraction of instance manager
session name now correctly displaying in torchSessionManager messages
TorchSession now has loaded world property (as torch now has more control about world load process)
now only dedicated config locks after session start
2022-02-02 14:28:53 +07:00
z__
70833adb44 updated NLog to v5
fixed most of issues with world creating/loading
fixed log window lags
fixed some compiler warnings
fixed empty log files creating
fixed logging performance
added better logging of load process
2022-02-02 14:09:08 +07:00
z__
ab61674b47 integrity analysis for invalid IL 2022-02-02 00:39:43 +07:00
z__
c8ddf691ba fixed world configuration updating 2022-02-02 00:11:15 +07:00
zznty
76afccd9db shitty gc calls removal 2022-02-01 15:11:04 +07:00
zznty
4882dc673a xml config formatting fix 2022-02-01 15:10:51 +07:00
zznty
8546165e59 Merge branch 'tests/try-finally' 2022-02-01 12:04:01 +07:00
z__
4cab214635 fixed planet heightmap loading 2022-02-01 12:01:29 +07:00
z__
9a6253d0ef NRE fixes 2022-02-01 11:39:00 +07:00
zznty
55eac7ecbf test for try/finally transpiler 2022-01-31 20:28:43 +07:00
zznty
057d126658 exception fixes 2022-01-30 19:23:43 +07:00
z__
8efe8ae398 removed useless thing 2022-01-26 11:00:44 +07:00
z__
e2cdd803af remove redundant saving on stop/restart
saving in unload controlled by setting in dedicated config
2022-01-26 10:57:20 +07:00
zznty
b6d8cf07f8 we dont need link to build server anymore 2022-01-23 21:28:52 +07:00
zznty
1b23cd564e Update README.md 2022-01-23 21:28:04 +07:00
z__
f6ef662344 queries and restart fixes 2022-01-23 21:03:32 +07:00
z__
58b9c926ae net6 things 2022-01-22 21:13:38 +07:00
Bishbash777
81d11a32fe Update Jenkinsfile 2022-01-17 00:08:01 +00:00
Bishbash777
eb9afd5e36 Update Jenkinsfile 2022-01-16 23:29:09 +00:00
Bishbash777
1de0b63907 Merge pull request #459 from Bishbash777/master
Net 4.8 upgrade
2022-01-16 23:15:35 +00:00
Bishbash777
f89170c37d Net 4.8 upgrade (#27)
* Framework 4.8 Upgrade and small memory access change

* update tests to 4.8

* update mod_id for torch mod
2022-01-16 23:12:55 +00:00
Bishbash777
73ee686a84 Update Jenkinsfile 2022-01-16 22:51:02 +00:00
Bishbash777
e49910e121 Merge pull request #458 from Bishbash777/torch-migration-p2
point to new (temporary?) build server
2022-01-16 14:09:55 +00:00
Jack Bishop
83805cba77 point to new (temporary?) build server 2022-01-16 14:09:18 +00:00
Bishbash777
32a61d2feb Update Torch.Server.Tests.csproj 2022-01-16 03:38:14 +00:00
Bishbash777
133e20c758 Update Torch.Tests.csproj 2022-01-16 03:30:31 +00:00
Bishbash777
d7c5aa3fa8 Update Torch.API.csproj 2022-01-16 03:24:38 +00:00
Bishbash777
f6d59c75c6 Update Torch.csproj 2022-01-16 03:19:18 +00:00
Bishbash777
fd8c731713 Update Jenkinsfile 2022-01-16 02:53:31 +00:00
Bishbash777
55a552af60 Update Torch.csproj 2022-01-16 02:52:29 +00:00
Bishbash777
770d18859b Update Torch.csproj 2022-01-16 02:48:27 +00:00
Bishbash777
22e60edc1f Update Jenkinsfile 2022-01-16 02:12:33 +00:00
Bishbash777
c97fd07f89 Update README.md 2022-01-15 23:47:00 +00:00
Bishbash777
7e87cdd5a0 Update README.md 2022-01-15 23:44:01 +00:00
Bishbash777
b67eff406f Update README.md 2022-01-15 21:33:10 +00:00
Bishbash777
29a5c09ac7 Update README.md 2022-01-15 21:28:53 +00:00
Bishbash777
a1668abcd4 Merge pull request #457 from Bishbash777/master
Phase 1 migration
2022-01-14 03:03:37 +00:00
Bishbash777
2d8ca29935 Merge pull request #19 from Bishbash777/torch-migration
Torch migration
2022-01-14 03:03:05 +00:00
Jack Bishop
4f9af817a5 phase-1 changes 2022-01-14 02:31:51 +00:00
Jack Bishop
7bd4beb82d update plugin query to new endpoint 2022-01-10 17:02:42 +00:00
Jack Bishop
1ec57bc4c9 QOL - Order plugin controls by name 2021-09-27 01:12:15 +01:00
Bishbash777
63f14c984d Merge pull request #455 from N1Ran/master
Some fixes.
2021-09-03 16:54:54 +01:00
Olatide F
6c227b4a6e merge Friendly 2021-09-03 08:27:25 -04:00
Olatide F
b846112c43 fix for the plugin browser crash 2021-09-03 08:20:46 -04:00
N1Ran
23f9b1507d Merge branch 'master' of https://github.com/TorchAPI/Torch 2021-09-03 02:13:30 -04:00
Bishbash777
2a0555ea4f Update TorchServer.cs 2021-07-28 18:37:45 +01:00
Bishbash777
0395d0bc7f Merge pull request #452 from Bishbash777/199-update
199 update changes and UI updates + various
2021-07-28 18:07:04 +01:00
Bishbash777
f2c03cbc34 fix log in release mode 2021-07-28 18:53:58 +02:00
Bishbash777
147c94fd93 Merge pull request #15 from zznty/fix/xbox
Fixes for EOS & consoles
2021-07-28 09:46:13 +01:00
Bishbash777
0e2ecf16f3 Merge pull request #14 from zznty/fix/duplicate-clientId
fixed crash due to clientId duplicate
2021-07-28 09:43:34 +01:00
Bishbash777
36eb256553 Update ChatManagerClient.cs 2021-07-28 09:06:04 +01:00
Bishbash777
e90ca41c3c properly init new updated PluginBrowser 2021-07-28 09:05:13 +01:00
Bishbash777
5528231cc2 Create PluginDownloader.xaml.cs 2021-07-28 09:04:08 +01:00
Bishbash777
4d01b976f1 Create PluginDownloader.xaml 2021-07-28 09:03:36 +01:00
Bishbash777
ff12b214cd new plugin loader init 2021-07-28 09:03:09 +01:00
Bishbash777
55c9f5296f Added new data into PluginBrowser 2021-07-28 08:58:10 +01:00
Bishbash777
61e1ed7a59 fix for role editor crash when roles are null 2021-07-28 08:55:27 +01:00
Bishbash777
218cd30152 New window views 2021-07-28 08:54:23 +01:00
Bishbash777
bf3b819d02 get setter for Name and a new Installed tag 2021-07-28 08:52:34 +01:00
zznty
b56c8f711c fixed crash due to clientId duplicate
fixes for System.ArgumentException: Key <clientId> already exists
Parameter name: key
2021-07-17 17:36:36 +07:00
zznty
c5c6ef1cd2 xbox compat support 2021-07-09 01:26:39 +07:00
zznty
3e01cecdcc mod.io support and eos fix 2021-05-07 19:02:28 +07:00
N1Ran
966b2f5756 Merge branch 'master' of https://github.com/TorchAPI/Torch 2021-04-25 21:30:51 -04:00
Jimmacle
a5743701ea Merge pull request #442 from Bishbash777/master
Fix server discovery issue on main "Join Game" Screen
2021-04-25 09:09:23 -07:00
Bishbash777
7ea1a523e1 Fix server discovery issue on main "Join Game" Screen 2021-04-25 12:36:46 +01:00
Jimmacle
5445459dc7 Merge pull request #441 from Bishbash777/update-198
fix for 198
2021-04-22 10:29:02 -07:00
Bishbash777
f2eed13473 fix for 198 2021-04-22 18:28:03 +01:00
Olatide F
af894e7507 update 2021-03-21 09:19:01 -04:00
Olatide F
94475f7bd1 update 2021-03-21 09:17:41 -04:00
Jimmacle
b5ca0bf392 Merge pull request #438 from Bishbash777/hotfix-197.181-changes
Add missing parameter into initNetworking if service type is EOS
2021-03-18 07:23:57 -07:00
Bishbash777
fdd8479016 Add missing parameter into initNetworking if service type is EOS 2021-03-18 12:28:49 +00:00
N1Ran
c915b385e3 update 2021-03-18 06:29:00 -04:00
Jimmacle
f451c552ec Merge pull request #431 from theltp/fix/cross-play
final fix for cross-play update
2021-03-18 06:27:55 -04:00
John Gross
0aa17a26ac Update for hotfix 2021-03-11 10:08:27 -08:00
Jimmacle
41b16a6d75 Merge pull request #433 from Bishbash777/stop-cancel-fix
Fix the stop cancel command
2021-02-14 14:16:01 -08:00
Bishbash777
b5f53dd6c6 Fix the stop cancel command 2021-02-14 14:24:43 +01:00
Jimmacle
5cc2d6652d Merge pull request #432 from theltp/fix/cross-play
totally fix for cross play
2021-02-12 14:21:24 -08:00
LTP
6fb6226be5 Merge remote-tracking branch 'theltp/fix/cross-play' into fix/cross-play 2021-02-12 19:36:37 +07:00
LTP
cee5cb3c4d totally fixed 2021-02-12 19:36:28 +07:00
Jimmacle
b6fb470b84 Merge pull request #431 from theltp/fix/cross-play
final fix for cross-play update
2021-02-11 21:27:13 -08:00
Jimmacle
6c74ed3869 Merge branch 'master' into fix/cross-play 2021-02-11 21:26:31 -08:00
LTP
2c44860a70 fixed mistake 2021-02-12 12:08:43 +07:00
LTP
169b543f7d final fix + new config option to change service between Steam and EOS 2021-02-12 12:05:16 +07:00
Jimmacle
efd15fcd62 Merge pull request #428 from theltp/fix/cross-play
fix for cross-play update
2021-02-11 13:34:28 -08:00
LTP
b372230eae idk why it's not working 2021-02-12 00:45:51 +07:00
LTP
e5cb3e5ae0 fix for cross-play update 2021-02-11 23:15:46 +07:00
John Gross
8f30b7605b Update Jenkinsfile 2020-12-03 22:11:23 -08:00
John Gross
bec29c5bb4 Fix world generator - inconsistent paths 2020-12-03 22:01:18 -08:00
John Gross
f84a27d705 Fix more world generator path weirdness 2020-11-25 23:45:04 -08:00
Jimmacle
19f9388a43 Merge pull request #415 from foogs/master
YOUR PRIVACY HAS BEEN DELETED
2020-11-25 21:59:43 -08:00
foogs
f25a412a47 YOUR PRIVACY HAS BEEN DELETED 2020-11-26 08:43:56 +03:00
John Gross
f7a63f17cc Patch steam timeout to 5 seconds to work around callback issues 2020-11-25 16:44:01 -08:00
John Gross
aa5963b29b Merge branch 'master' of https://github.com/TorchAPI/Torch into master 2020-11-25 12:26:26 -08:00
John Gross
15c4276a81 More fixes for 25th 2020-11-25 12:26:18 -08:00
Jimmacle
04b13cbd6c Merge pull request #413 from TorchAPI/command-perms
Command perms
2020-11-25 11:35:51 -08:00
Jimmacle
f6971c715b Merge branch 'master' into command-perms 2020-11-25 11:35:18 -08:00
John Gross
c3e65a5bdd Tentative fix for 2020-11-25 update 2020-11-25 11:32:05 -08:00
Bishbash777
93167f349d new chat event to allow access to msg properties (#411)
* new chat event to allow access to msg properties

* Naming conventions reee

Co-authored-by: Jimmacle <mindstorms11@cox.net>
2020-11-03 14:04:17 -08:00
Jimmacle
b12acddab3 Command perms (#408)
* Add event to override Torch command permission checker

* Correct permission override condition
2020-10-29 14:04:30 -07:00
John Gross
fb9dbf40da Correct permission override condition 2020-10-29 13:27:35 -07:00
John Gross
1b8bddabc8 Add event to override Torch command permission checker 2020-10-29 13:25:23 -07:00
Foogs
a4edbf3bd9 Not count voxel physics pls (#405) 2020-09-18 11:28:08 -07:00
Yuri.Sh
3d13460302 Added ModSDK Logging (#404)
This change was made by @BobDaRoss
I like to help with correct pull request.
2020-08-23 12:40:50 -07:00
N1Ran
fad656e837 Added new features from SE to UI config page (#398)
Co-authored-by: Olatide F <tide1988@live.com>
Co-authored-by: Jimmacle <mindstorms11@cox.net>
2020-08-11 14:07:32 -07:00
Jimmacle
fc986c87a6 Copy and paste bad 2020-08-10 14:40:41 -07:00
Bob Da Ross
80a820ae3d Fixed ModSDK players from joining and getting sandbox file. (#399) 2020-08-10 14:21:13 -07:00
Equinox
e9e446f8ab Fix async command responses (#393)
Fix logs not being written for invalid IL
2020-07-09 18:06:35 -07:00
John Gross
b53194184c Fix world generator dialog 2020-06-25 14:48:46 -07:00
John Gross
bcb921cd9d Add code to automatically delete the bad DLL 2020-04-24 19:27:20 -07:00
John Gross
c1632b6b20 Don't serialize temporary autostart flag 2020-04-23 13:03:29 -07:00
John Gross
88d10d1955 Change KeenLogPatch to handle errors better 2020-04-23 12:59:46 -07:00
Jimmacle
d6fe6234d7 Forced MSBuild too much 2020-04-22 21:22:56 -07:00
Brant Martin
29fcdc0bf8 Add temporary autostart flag for restart commands and autostart commandline switch (#382)
Co-authored-by: Jimmacle <mindstorms11@cox.net>
2020-04-22 12:31:55 -07:00
Brant Martin
48ddc6389f Fix property grid stretching rows with low item count (#381) / Fix Jenkins packaging unnecessary binaries (#383)
* Fix property grid stretching rows with low item count

* Fix Jenkins packaging unnecessary binaries (#383)

* Fix Jenkins packaging DLLs it shouldn't

* Zap more sneaky copy locals

* MSBuild won't cooperate so it will be forced to comply

Co-authored-by: Jimmacle <mindstorms11@cox.net>
2020-04-22 12:29:28 -07:00
John Gross
a3d722eb16 Fix missing sender argument 2020-04-13 06:44:11 -07:00
John Gross
b386e53ff5 Force language version so Jenkins is happy 2020-04-13 05:08:52 -07:00
Jimmacle
1dd444759b Add support for new chat colors (#379)
* Add backwards-compatible support for new chat color system

* Use default

* Set LangVersion properly

* Add backwards compatible ctors in TorchChatMessage

* Fix not setting Font if it's not MyFontEnum

* Use correct color mappings
2020-04-13 04:44:12 -07:00
Brant Martin
76ea5fdbc1 Quick hack to reduce sim slowdown during save (#375) 2020-04-09 08:32:23 -07:00
Jimmacle
035325da22 Assert option and other fixes (#370)
* Add option to control assert logging

* Fix logging errors from calling InitMultithreading before InvokeBeforeRun
2020-03-20 09:44:54 -07:00
Equinox
33b2fa7094 Fix init (#369) 2020-03-19 12:34:47 -07:00
Equinox
b220243b75 Fix frostbite (#368)
Stop using playtest dir
2020-03-19 12:15:32 -07:00
John Gross
f2a077deed Whomst removed the plugin update option check 2020-02-23 09:18:11 -08:00
Brant Martin
d3de1426b2 Fix plugin update race condition 2020-02-23 00:27:09 -05:00
Equinox
86b6b94d25 Merge pull request #360 from sirhamsteralot/master
Add injecting of private class fields into patching methods
2020-02-15 15:19:12 -08:00
Equinox
0a19663c33 Merge branch 'master' into master 2020-02-15 15:15:28 -08:00
sirhamsteralot
d236fd9bd9 Bind to anything 2020-02-15 22:52:38 +01:00
Neko Boi Nick
bc54b79098 Fixed #364 (#365)
* Added Move Function

* Fixed #364

* Quick fix as the issue still sort of persisted.

* Update ModToIdConverter.cs

* Fixed the logic inverse.
2020-02-15 15:56:51 -05:00
Jimmacle
5035fa39b7 Fix inaccurate error tooltip
This enum isn't used for any actual features yet
2020-02-03 16:37:45 -08:00
sirhamsteralot
2395c33995 Formatting Part deux 2019-12-26 14:45:12 +01:00
sirhamsteralot
92ae252210 formatting 2019-12-26 00:07:18 +01:00
sirhamsteralot
5d40cf373d injecting of fields -- equinox 2019-12-25 23:22:22 +01:00
sirhamsteralot
9cbcc3ed85 Merge branch 'master' of git://github.com/TorchAPI/Torch 2019-12-25 23:13:24 +01:00
John Gross
a1f397f9bf Keep config disabled after stopping server 2019-12-21 12:22:29 -08:00
John Gross
540b17448a Fix overwriting Sandbox with stale cached version 2019-12-07 18:15:48 -08:00
John Gross
21fd997554 Support NPC identities in GetGridOwnerName 2019-12-07 14:11:27 -08:00
John Gross
23b0318591 Disable forcing IgnoreLastSession true 2019-11-29 15:58:44 -08:00
John Gross
5727e3b1b8 Rewrite Initializer.Run so it doesn't look like a toddler made it 2019-11-10 15:59:30 -08:00
John Gross
28164b491b Merge branch 'master' of https://github.com/TorchAPI/Torch 2019-11-05 10:19:46 -08:00
John Gross
b02d613a28 Fix crash when logging pre-formatted messages 2019-11-05 10:19:16 -08:00
Brant Martin
c18d6d4795 Unhack the hack 2019-11-01 12:18:21 -04:00
Brant Martin
5780cf7c95 Quick and dirty hack to resolve dll conflicts 2019-10-31 18:18:19 -04:00
John Gross
cc91fa3653 Fix mod downloading, more descriptive sandbox error message 2019-10-26 11:38:38 -07:00
John Gross
52ef0b4d6d Add MySteamService wrapper, add UGC service to init, fix chat intercept 2019-10-24 14:35:06 -07:00
John Gross
ef2be78102 Merge branch 'Patron' 2019-10-24 12:59:37 -07:00
Brant Martin
9c2dc69e3c patch prep 2019-10-23 20:36:15 -04:00
Brant Martin
8107bf131b Revert "Set default tab to chat because of spookyness"
This reverts commit 792151a8b7.
2019-09-29 18:16:26 -04:00
Brant Martin
0220f46741 Save changes to config when using plugin browser 2019-09-25 17:44:11 -04:00
Brant Martin
e4ad517cb1 Handle exceptions when clearing temp files BECAUSE NO ONE REPORTED IT 2019-09-25 17:36:16 -04:00
Brant Martin
792151a8b7 Set default tab to chat because of spookyness 2019-09-25 17:22:53 -04:00
John Gross
fb67b2f3d1 Merge branch 'master' of https://github.com/TorchAPI/Torch 2019-09-21 12:28:50 -07:00
John Gross
30c1f07207 Add file to project 2019-09-21 12:28:15 -07:00
John Gross
562a4554f3 Update instance manager for new config format 2019-09-21 12:19:14 -07:00
N1Ran
9f22b63227 This fixed it (#346)
Let's get this help back online
2019-09-21 10:24:30 -04:00
John Gross
c96e7a284a Merge branch 'master' into Patron 2019-09-19 11:34:09 -07:00
Jimmacle
dbcd696936 How did this get here 2019-09-19 11:10:52 -07:00
John Gross
79368aa6dd Fix MessageBox spam if Torch crashes with UI enabled and autorestart disabled 2019-09-13 11:46:35 -07:00
Brant Martin
d661c893d5 Fix a dumb 2019-09-10 18:17:45 -04:00
N1Ran
ca99404b42 Stop command countdown (#343)
Hopefully this works
2019-09-10 17:58:50 -04:00
Brant Martin
aec03840cc Nothing to see here, move along 2019-09-07 12:10:08 -04:00
John Gross
5630eb14c2 Stop service "properly" 2019-09-01 10:22:42 -07:00
John Gross
6680b0adb2 Fix services? 2019-08-31 23:25:05 -07:00
Brant Martin
ff0d881273 Gracefully handle corrupt plugin zips 2019-08-27 16:43:31 -04:00
Brant Martin
ed5d0ea474 Merge branch 'master' into Patron 2019-08-27 16:34:46 -04:00
Brant Martin
997a3ca31c Adjust behavior of restarts. Closes #337 2019-08-25 11:55:14 -04:00
Brant Martin
ef444730b7 Fix dumb arithmetic error breaking saves. Closes #336 2019-08-25 11:20:35 -04:00
Brant Martin
7bfc6077b9 Set game thread locale to English. Should give English exceptions now. 2019-08-25 11:04:08 -04:00
Brant Martin
624bd5a2a4 Fix references 2019-08-25 11:03:24 -04:00
John Gross
1e19f9aedf Fix save tracking desync 2019-08-22 20:38:35 -07:00
John Gross
1b4c5ace61 Fix saving 2019-08-22 15:46:40 -07:00
John Gross
28037e11df Fix more chat, add missing config UI 2019-08-22 12:36:35 -07:00
John Gross
036f21de81 Fixy fix time, Keen touched the chat system 2019-08-22 11:24:19 -07:00
Brant Martin
43adecaf99 Publictest (#335)
* Fix compiler errors

* Fix Jenkins

* Build public test as Release

* Fix more things

* Oops

* Remove obsolete code

* Fix GameStatePatchShim
2019-08-22 13:25:53 -04:00
Brant Martin
c58e4dccc0 Merge branch 'master' into Patron 2019-08-19 14:40:25 -04:00
Brant Martin
1a1f8b2235 Fix dumb in torch mod 2019-08-16 12:51:51 -04:00
Brant Martin
f1616f6532 Implement kick on restart 2019-08-16 12:48:16 -04:00
Brant Martin
a42f5ab273 Fix editing admins with role editor 2019-08-08 21:58:12 -04:00
Brant Martin
f15139e907 Add -testplugin commandline switch 2019-07-15 11:10:10 -04:00
John Gross
f4399d441d Only disable service mode on Windows Server 2019 2019-07-11 23:35:24 -07:00
John Gross
fd4b49e0d5 Fix remote API load order 2019-07-11 13:26:43 -07:00
John Gross
496a276524 Disable starting as service to fix compatibility with Windows Server 2019 2019-07-10 18:43:32 -07:00
Brant Martin
c831df74d0 Fix regression in PluginManager.
Closes #321
2019-07-10 14:12:04 -04:00
John Gross
e77d53fd41 Better SortedView fix 2019-07-06 17:18:15 -07:00
John Gross
983aff2091 Merge branch 'master' into Patron 2019-07-06 17:00:22 -07:00
John Gross
570bc83a6d Fix remote API, file copying, entity manager sorting 2019-07-06 16:58:36 -07:00
Brant Martin
8dca8bbe65 Fix build issues 2019-06-26 11:18:48 -04:00
Brant Martin
0e91b47dba Merge branch 'Patron' of https://github.com/TorchAPI/Torch into Patron 2019-06-25 16:48:24 -04:00
Brant Martin
3f7e95b502 Log errors when a plugin's control throws exceptions instead of just letting WPF die.
Also add some new types for Essentials
2019-06-25 16:47:54 -04:00
Brant Martin
4f30a47c07 Handle conflicting connection attempts gracefully 2019-06-25 16:11:13 -04:00
John Gross
ecbbd6fbf2 Copy native DLLs if newer 2019-06-24 19:47:08 -07:00
Brant Martin
13f5648963 Remove false positive in debug code 2019-06-23 21:34:20 -04:00
Brant Martin
dfb7314207 Automatically delete and replace steam_api.dll to fix weirdness 2019-06-23 19:33:22 -04:00
Brant Martin
9293801037 Tweak debug output 2019-06-23 08:42:53 -04:00
Brant Martin
d8ac3b2353 Add debug info to InstancePath setter to track down a stupid bug 2019-06-22 23:36:57 -04:00
Jimmacle
056f0e5614 Merge pull request #322 from biscuitWizard/Patron
autoscroll disabler for log
2019-06-21 03:01:32 -07:00
J Iaccarino
ada5418413 Merge pull request #1 from TorchAPI/Patron
Patron
2019-06-21 01:35:51 -07:00
bitMuse
b79e970e66 Added autoscroll disable for log window.. fuck wpf. 2019-06-21 01:34:01 -07:00
John Gross
6fc02edd1e Add save plugin list on first load 2019-06-20 19:06:05 -07:00
Jimmacle
9a8c03106e Merge pull request #320 from biscuitWizard/Patron
Patron
2019-06-20 16:30:22 -07:00
asdfasdfa
4a5e41b747 Added code to finish registering the plugins. 2019-06-17 21:19:51 -07:00
asdfasdfa
649dcf4019 Refactored PluginManager to accept load hints. 2019-06-17 21:17:00 -07:00
Brant Martin
ae3d1262f5 Merge branch 'master' into Patron 2019-06-16 08:31:35 -04:00
John Gross
7b2b0edbdf Merge remote-tracking branch 'origin/PreRelease' 2019-06-16 02:20:43 -07:00
Brant Martin
353746ec04 Exclude abstract types from plugin scan 2019-06-13 09:53:09 -04:00
Brant Martin
2fb9b4173a Revert back to local temp folder 2019-06-13 08:05:03 -04:00
Brant Martin
fe7242f36f more error handling 2019-06-11 06:27:37 -04:00
Brant Martin
8015f8486c Add error handling to world view loading 2019-06-10 21:04:40 -04:00
Brant Martin
92d7f8f578 Merge branch 'Patron' of https://github.com/TorchAPI/Torch into Patron 2019-06-09 17:45:56 -04:00
Brant Martin
fc9a9f8e09 Merge branch 'master' into PreRelease 2019-06-09 17:45:48 -04:00
Brant Martin
f94bfc2850 Merge branch 'master' into Patron 2019-06-09 17:45:37 -04:00
Brant Martin
db283fad15 Fix admin permission/logger errors. Probably. 2019-06-08 09:33:35 -04:00
John Gross
dd7288b787 Merge branch 'master' into Patron 2019-06-06 19:36:40 -07:00
John Gross
a6e41b2a90 Fix native Havok.dll loading 2019-06-06 18:23:39 -07:00
John Gross
0e6ac14b74 Error handling 2019-06-06 18:06:28 -07:00
John Gross
97f380fb7b Fix moar 2019-06-06 18:03:58 -07:00
John Gross
3e5b29c84d I think I actually fixed it 2019-06-06 17:07:25 -07:00
John Gross
5d19cc7cf1 I think I fixed it 2019-06-06 15:48:29 -07:00
Brant Martin
19995eba1a Update protobuf to 2.4 2019-06-06 15:54:05 -04:00
Brant Martin
990ed0f6bf Merge branch 'master' into PreRelease 2019-06-06 15:36:39 -04:00
Brant Martin
dc0a085d86 Merge branch 'master' into Patron 2019-06-06 15:36:32 -04:00
Brant Martin
0a852c49e8 Copy missing dll 2019-06-06 15:35:54 -04:00
Brant Martin
59588517d8 Merge branch 'master' into PreRelease 2019-06-06 15:15:44 -04:00
Brant Martin
3a7cbe48b8 Merge branch 'master' into Patron 2019-06-06 15:15:31 -04:00
Brant Martin
ed298cdfb0 Fix for update 2019-06-06 15:11:39 -04:00
Brant Martin
3925c34610 Remove return statement in plugin loader because I'm stupid 2019-06-06 08:28:23 -04:00
Brant Martin
a6fa112050 Fix random MT error in SortedView 2019-06-05 13:56:28 -04:00
Brant Martin
d97a6a52a4 Handle xml errors in Persistent.Load gracefully 2019-06-05 13:56:08 -04:00
Brant Martin
121846eeae Fix rare crash in entity view sorting 2019-06-03 19:56:29 -04:00
Brant Martin
ebef1edc09 Plugin loading, init, and update now actually catch and report errors. 2019-06-03 16:16:25 -04:00
Brant Martin
bbaf1384ba Allow property grid description field to resize 2019-06-03 00:07:59 -04:00
Brant Martin
7036a4da81 Enable deleting characters when there is no controller attached.
Increase !save timeout to 5 mintues
2019-06-02 11:15:16 -04:00
Brant Martin
91ceb0aa22 Implement ScrollContainerProperty to allow plugins to disable the default scrollviewer wrapper on their controls 2019-05-08 18:34:09 -04:00
John Gross
de12327ac2 Merge branch 'master' into Patron 2019-05-06 23:54:52 -07:00
John Gross
6f65b54883 stop 2019-05-06 23:54:02 -07:00
John Gross
c0ffd7e641 Merge branch 'master' into Patron 2019-05-06 18:59:12 -07:00
John Gross
b0c1ccf9b4 Add NLog-user.cfg to build output 2019-05-06 18:01:40 -07:00
Brant Martin
ed3e1aa846 Merge branch 'master' into Patron 2019-05-06 19:35:11 -04:00
Brant Martin
7f720a1753 Implement user nlog configs, update updater to ignore user config. Resolves #309
Also changes FilesystemManager to use system temp directory when appropriate. (reduces clutter on disk)
2019-05-06 19:34:12 -04:00
Brant Martin
6cbcbc6f3f Save config on backwards-compatible load 2019-05-04 18:42:27 -04:00
Brant Martin
53ae9bc42d Remove debug code 2019-05-04 18:40:17 -04:00
Brant Martin
9813d6946a Refactor plugin loading. All active plugins must now be listed in torch.cfg 2019-05-03 21:39:56 -04:00
John Gross
c7651c9949 Fix NRE if help command is used from server 2019-04-29 11:43:19 -07:00
Brant Martin
34211c4b3f Filter help commands by promote level of requesting user. Closes #306 2019-04-28 18:25:53 -04:00
Brant Martin
8bc4c247e6 Enable the scrollbar on the config page 2019-04-22 15:55:02 -04:00
Brant Martin
92406a051a Add bulk editing of roles 2019-04-22 15:44:34 -04:00
Brant Martin
56f7578d13 Implement chat muting TorchAPI/Essentials#81 2019-04-20 11:43:55 -04:00
Brant Martin
068b074de0 Add player display to main UI window. Ref TorchAPI/Essentials#106 2019-04-20 09:02:21 -04:00
Brant Martin
bb0ee3b861 Add editor for player promotion levels. Resolves #280 2019-04-19 21:30:10 -04:00
John Gross
93bb11c135 Fix crash on invalid command from UI 2019-04-19 11:23:04 -07:00
John Gross
2fd8c17525 Merge branch 'master' into Patron 2019-04-19 08:26:04 -07:00
John Gross
b974487fc4 Fix for command response in UI. How did this ever work? 2019-04-16 11:57:13 -07:00
John Gross
8198243425 Add backwards compatibility to CommandContext.Respond for plugins compiled against older Torch 2019-04-16 10:20:13 -07:00
John Gross
b4addcc125 Add nullchecks to player action buttons 2019-04-15 15:41:13 -07:00
John Gross
2d7893b9de Merge branch 'master' of https://github.com/TorchAPI/Torch 2019-04-15 15:39:09 -07:00
John Gross
60c0ae1049 Fix message target bug 2019-04-15 15:38:34 -07:00
Brant Martin
aaabfa2d01 Merge branch 'master' into Patron 2019-04-10 16:31:19 -04:00
Brant Martin
5c8a1f3677 Don't throw exceptions when saving is abnormal 2019-04-10 16:29:41 -04:00
Brant Martin
b37cd74e56 Fix gross initializer error on first time installations 2019-04-10 14:28:13 -04:00
Brant Martin
af9a31f4ad Keen broke network intercept. Disable it until we decide what to do. 2019-04-09 21:20:56 -04:00
John Gross
7d8838c0ee Add customizable server chat name and color 2019-04-08 19:46:58 -07:00
Brant Martin
2c47cfd60e Enable PatchShim for plugins 2019-03-13 14:41:25 -04:00
Brant Martin
6422f7c576 Fail *gracefully* when Havok runs out of memory. 2019-03-12 20:49:45 -04:00
Brant Martin
369a3217f7 Change plugin update IO logic 2019-03-10 16:45:18 -04:00
Jimmacle
f44bf935d3 Merge pull request #299 from N1Ran/Patron
Fix for the GUI entity count.  Revert just the count from Sorted
2019-03-09 10:25:25 -08:00
N1Ran
0e43eee2f3 Fix for the GUI entity count. Revert just the count from Sorted 2019-03-09 09:51:03 -05:00
Jimmacle
c6121ab590 Merge pull request #298 from TorchAPI/master
Update events/UI to reflect new chat
2019-03-08 12:58:45 -08:00
John Gross
72ceeffdad Update events/UI to reflect new chat 2019-03-05 11:31:00 -08:00
Brant Martin
5eb6e9990c Don't die when updating plugins with no releases 2019-03-03 19:02:20 -05:00
Brant Martin
3d3769cf5a Enable plugin updating from website 2019-03-03 18:46:11 -05:00
Brant Martin
2a64151f67 There's a damn typo in the jenkins file 2019-03-03 17:44:26 -05:00
Brant Martin
34616607a8 Implement Torch auto-update. Sadly does not work for Patron branch. 2019-03-03 17:42:02 -05:00
Brant Martin
796feb05e6 I shouldn't be allowed to have a computer 2019-03-03 15:23:43 -05:00
Brant Martin
14ae58ca0c Versioning should work now 2019-03-03 15:21:57 -05:00
Brant Martin
b555f46f56 Try versioning again 2019-03-03 15:17:00 -05:00
Brant Martin
dc5e7e4cb0 Try new version scheme 2019-03-03 15:01:51 -05:00
Brant Martin
deb0b202bf Merge remote-tracking branch 'origin/master' into Patron 2019-03-03 13:01:46 -05:00
Brant Martin
0a5a70f583 csproj didn't update for some reason 2019-03-02 14:38:52 -05:00
John Gross
f16e825b57 Fix command hiding, remove duplicate event invoke 2019-03-02 11:14:23 -08:00
Brant Martin
263a8229fa Enable hyperlinks.
Sanitize hyperlinks.
2019-03-02 12:14:32 -05:00
Brant Martin
dc7a27a5e3 Merge branch 'master' of https://github.com/TorchAPI/Torch into Patron 2019-03-02 11:42:24 -05:00
Brant Martin
651865f28a Implement plugin browser and downloader 2019-03-02 11:42:08 -05:00
John Gross
27493d3b23 Revert "Replace the stupid MyMultiplayer.GetMemberName with something that actually works."
This reverts commit 8c59098c28.
2019-03-01 20:28:38 -08:00
John Gross
295bbd62b8 Fix window size shenanigans breaking the config 2019-02-28 13:44:14 -08:00
John Gross
5cf3ae1203 Fix command hiding, add new chat properties to TorchChatMessage 2019-02-28 12:33:26 -08:00
John Gross
c650e190fb Clean up mess from last commit 2019-02-28 12:03:26 -08:00
John Gross
5cd5873ec3 Replace chat intercept with patch 2019-02-28 11:57:36 -08:00
John Gross
42a66b04c5 Revert build scripts for merge 2019-02-28 08:28:33 -08:00
Brant Martin
a237185e4c Move all deprecated junk to the deprecated file 2019-02-27 19:11:47 -05:00
Brant Martin
df225a3d2f Add new config options 2019-02-27 17:05:15 -05:00
Brant Martin
8c59098c28 Replace the stupid MyMultiplayer.GetMemberName with something that actually works. 2019-02-27 16:31:28 -05:00
Brant Martin
bbd45df54d fix jenkins for real 2019-02-25 17:03:36 -05:00
Brant Martin
8aa0ccd437 . 2019-02-25 16:58:22 -05:00
Brant Martin
74cdd9d055 fix the thing 2019-02-25 16:56:57 -05:00
Brant Martin
704f202ce8 asdg 2019-02-25 16:24:15 -05:00
John Gross
fb3082094a Revert unnecessary playtest things 2019-02-25 12:47:25 -08:00
Brant Martin
7a71cbf756 branch name 2019-02-25 15:39:27 -05:00
Brant Martin
53c279fa00 Reconfigure jenkins data 2019-02-25 15:38:02 -05:00
Brant Martin
8dc542a31c Merge branch 'Patron' of https://github.com/TorchAPI/Torch into survival 2019-02-25 15:27:34 -05:00
Brant Martin
4dee127ce8 Merge branch 'playtest' of https://github.com/TorchAPI/Torch into survival 2019-02-25 15:27:14 -05:00
Brant Martin
3e341e02c8 Make Torch UI remember its last screen size/position. Fixes #260
(this is Jim's fault)
2019-02-25 14:06:38 -05:00
Brant Martin
a673848089 Implement a truly terrible bulk mod editing mode. 2019-02-25 13:59:13 -05:00
Brant Martin
642186678e Fix new world generator breaking with non-default instance paths #286 2019-02-25 12:55:04 -05:00
Brant Martin
e37357aea5 Don't build in debug please 2019-02-20 21:17:37 -05:00
Brant Martin
967d8ce068 Add independent console option. Various random fixes 2019-02-20 20:20:09 -05:00
Brant Martin
2bb3aa84a7 Fix entity sorting 2019-02-20 20:19:46 -05:00
Brant Martin
82ddd3942b Remove mod textbox 2019-02-20 16:04:59 -05:00
Brant Martin
ac672092f1 Implement delegate caching 2019-02-10 19:14:15 -05:00
Brant Martin
1c6eec61af Add basic, experimental entity sorting 2019-02-10 16:29:08 -05:00
Brant Martin
dda7864c1a Add !uptime command 2019-02-10 14:58:31 -05:00
Brant Martin
ddc13cccec Overhaul NetworkManager.
Old systems of network injection and intercept are deprecated and will be removed in the future!
2019-02-09 12:17:36 -05:00
Brant Martin
95ac2392e8 Fix mod injection 2019-02-09 08:56:46 -05:00
Brant Martin
0122f9e989 Add API for injecting client mods 2019-02-08 13:53:37 -05:00
Tobias K
f265f7e773 Replace mod text box by separate tab with workshop support (#263)
* Implement ModList tab which fetches and displays mod information from the workshop.

* ModListEditor: Implement drag and drop ordering, adding, removing and saving.

* Add SteamWorkshopService to VCS

* Add missing file to SteamworkshopService project.

* ModlistControl: Implement checkbox for hiding/showing dependency mods
disable until config is loaded.
design improvements.

* Add documentation for the new classes.

* Comply to naming conventions.

* Update Torch.Server.csproj

* Fix Mod.IsDependency not being serialized when saving

* Remove superfluous update of mod meta data.
Remove commented section in ConfigControl.xaml.

* Optimized SteamworkshopService according to commit review.

* Move SteamWorkshopService to Torch.Utils.SteamworkshopTools

* Remove debug output.

* Don't break stack trace with custom exception in SteamWorkshopTools.

* User ViewModel base class for ModItemInfo instead of implementing INotifyProperty directly.

* Wrap ModListControl in ScrollViewer.

* Rename SteamWorkshopTools utility to WebAPI.

* Revert steamkit call to use dynamic typing for clarity :/

* Mark webAPI based method for downloading workshop content as obsolete.

* Update Torch project definition.

* Disable building Torch client

* Update readme

* Change init order to ensure paths are initialized for plugins

* Reorder exception logging to reduce duplication

* Use thread safe queues in MtObservableCollectionBase

* Revert "Change init order to ensure paths are initialized for plugins"

This reverts commit 3f803b8107.

* Fix layout of ModListControl

* Combine Invokes to reduce allocations

* Replace string comparisons by string.Equals / string.IsNullOrEmpty

* Replace string comparisons by string.Equals / string.IsNullOrEmpty

* Use MtObservableList for Modlist to avoid race conditions.
2019-02-02 06:26:55 -05:00
Brant Martin
61307ce584 Merge branch 'Patron' 2019-02-02 06:25:40 -05:00
Jimmacle
8f755a5cfc Update Initializer.cs 2019-01-31 11:45:11 -08:00
Jimmacle
c3addd05f7 Keen why did you change the beta password 2019-01-31 08:46:19 -08:00
Jimmacle
bbcfc9fb07 Update jenkins-grab-se.ps1 2019-01-31 08:45:01 -08:00
John Gross
63ac99f97a Revert "Change init order to ensure paths are initialized for plugins"
This reverts commit 3f803b8107.
2019-01-25 13:16:14 -08:00
John Gross
6d29bce267 Use thread safe queues in MtObservableCollectionBase 2019-01-25 12:36:41 -08:00
John Gross
6b039288d5 Reorder exception logging to reduce duplication 2019-01-25 12:31:34 -08:00
John Gross
3f803b8107 Change init order to ensure paths are initialized for plugins 2019-01-25 12:22:30 -08:00
John Gross
8c7891809e Update readme 2019-01-21 16:11:44 -08:00
John Gross
30729049b3 Give Mr. Parenthesis a friend 2019-01-17 17:02:03 -08:00
John Gross
1a0f80dce7 Actually finish making Jenkins work 2019-01-17 16:07:13 -08:00
John Gross
6973bc8e7d Make Jenkins download playtest branch 2019-01-17 15:58:35 -08:00
John Gross
ae3edd67da Update chat schtuff 2019-01-17 15:52:16 -08:00
John Gross
b66db19c0a Fix post world generation behavior 2019-01-17 15:07:50 -08:00
John Gross
36b931f680 Fix compilation errors, disable XML warnings 2019-01-17 14:51:24 -08:00
John Gross
9c63054926 Add SteamCMD beta arguments 2019-01-17 10:29:05 -08:00
John Gross
4e2e58bb4c Merge branch 'master' into Patron 2019-01-16 21:17:47 -08:00
Brant Martin
ffc6a60ee9 Merge branch 'master' into Patron 2019-01-10 19:11:33 -05:00
Brant Martin
fa1a968b8f Merge branch 'master' into Patron 2019-01-10 09:29:29 -05:00
Brant Martin
471912759a Merge branch 'master' into Patron 2019-01-06 22:22:16 -05:00
Yannick
0b76ded5aa Jam this in a grid cuz rexxar didnt want to (#267) 2019-01-03 16:15:47 -05:00
sirhamsteralot
76aa95588e Merge branch 'Patron' of https://github.com/TorchAPI/Torch into Patron 2019-01-03 22:11:04 +01:00
Brant Martin
6618752b84 Merge branch 'master' into Patron 2019-01-03 15:59:34 -05:00
sirhamsteralot
af5f39af44 Jam this in a grid cuz rexxar didnt want to 2019-01-03 21:53:26 +01:00
sirhamsteralot
03ef57daeb Merge branch 'Patron' of https://github.com/TorchAPI/Torch 2019-01-03 21:46:43 +01:00
Brant Martin
a059d18195 Add promote/demote buttons to player tab.
Add player promoted event to IMultiplayerManagerServer
2019-01-03 15:41:41 -05:00
259 changed files with 14714 additions and 6320 deletions

115
.github/workflows/release.yaml vendored Normal file
View File

@@ -0,0 +1,115 @@
name: Release
on:
push:
branches: [master]
env:
BUILD_CONFIGURATION: Release
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
get-version:
name: Get Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@master
name: Checkout
with:
fetch-depth: 0
- name: Git Version
id: version
uses: paulhatch/semantic-version@v5.3.0
with:
tag_prefix: ''
major_pattern: 'breaking:'
minor_pattern: 'feature:'
build-nuget:
name: Build and Publish Nuget
runs-on: ubuntu-latest
needs: [get-version]
steps:
- uses: actions/checkout@master
name: Checkout
- uses: actions/setup-dotnet@v3
name: Setup dotnet
with:
dotnet-version: '8.0.x'
- name: Intall mono
run: |
curl -fsSL https://download.mono-project.com/repo/xamarin.gpg | gpg --dearmor -o /usr/share/keyrings/mono-official-stable.gpg
echo "deb [signed-by=/usr/share/keyrings/mono-official-stable.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" > /etc/apt/sources.list.d/mono-official-stable.list
apt-get update
apt-get install -y --no-install-recommends apt-transport-https mono-complete
- uses: nuget/setup-nuget@v1
name: Setup nuget cli
with:
nuget-version: '5.x'
- name: Restore dependencies
run: dotnet restore Torch.Server/Torch.Server.csproj --locked-mode
- name: Build
run: dotnet build Torch.Server/Torch.Server.csproj --no-restore -c ${{ env.BUILD_CONFIGURATION }} -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}"
- run: dotnet pack -c Release ./Torch.API/Torch.API.csproj -o pack -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}" --no-build
- run: dotnet pack -c Release ./Torch/Torch.csproj -o pack -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}" --no-build
- run: dotnet pack -c Release ./Torch.Server/Torch.Server.csproj -o pack -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}" --no-build
- run: mkdir blank && sed -i 's/torchVersion/${{ needs.get-version.outputs.version }}/g' Torch.Server.ReferenceAssemblies.net7.nuspec && nuget pack Torch.Server.ReferenceAssemblies.net7.nuspec -BasePath ./blank -OutputDirectory pack -NonInteractive -NoPackageAnalysis
- name: Install Sleet
run: dotnet tool install -g sleet --version 5.1.3
- name: Push Nuget Package
env:
SLEET_FEED_TYPE: s3
SLEET_FEED_PATH: https://nuget.storage.yandexcloud.net
SLEET_FEED_BUCKETNAME: nuget
SLEET_FEED_SERVICEURL: https://storage.yandexcloud.net
SLEET_FEED_ACCESSKEYID: ${{ secrets.S3_KEY_ID }}
SLEET_FEED_SECRETACCESSKEY: ${{ secrets.S3_KEY }}
run: /root/.dotnet/tools/sleet push ./pack
build:
name: Build and Publish Package
runs-on: ubuntu-latest
needs: [get-version]
steps:
- uses: actions/checkout@master
name: Checkout
- uses: actions/setup-dotnet@v3
name: Setup dotnet
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore Torch.Server/Torch.Server.csproj --locked-mode -r win-x64
- name: Publish
run: dotnet publish Torch.Server/Torch.Server.csproj --no-restore --sc -r win-x64 -c ${{ env.BUILD_CONFIGURATION }} -o ./publish -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}"
- uses: vimtor/action-zip@v1
name: Zip Release
with:
files: publish/
dest: torch-server.zip
- name: Create Release
uses: akkuman/gitea-release-action@v1
env:
NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18
with:
tag_name: ${{ needs.get-version.outputs.version }}
name: Release v${{ needs.get-version.outputs.version }}
body: ${{ steps.github_release.outputs.changelog }}
files: |-
./torch-server.zip

4
.gitignore vendored
View File

@@ -159,10 +159,6 @@ publish/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files

View File

@@ -1,33 +0,0 @@
# Torch 1.1.229.265
* Features
- Added more lenient version parsing for plugins (v#.# should work)
- Added countdown option to restart command (!restart [seconds])
* Fixes
- General fixes to work with the latest SE version
- Fixed config changes not saving
- (hopefully) Fixed issue causing crashes on servers using the Windows Classic theme
# Torch 1.1.207.7
* Notes
- This release makes significant changes to TorchConfig.xml. It has been renamed to Torch.cfg and has different options.
* Features
- Plugins, Torch, and the DS can now all update automatically
- Changed command prefix to !
- Added manual save command (thanks to Maldark)
- Added restart command
- Improved instance creation: now creates an entire skeleton instance with blank config
- Added instance name to console title
* Fixes
- Optimized UI so it's snappier and freezes less often
- Fixed NetworkManager.RaiseEvent overload that had an off-by-one bug
- Fixed chat window so it automatically scrolls down
# Torch 1.0.182.329
* Improved logging, logs now to go the Logs folder and aren't deleted on start
* Fixed chat tab not enabling with -autostart
* Fixed player list
* Watchdog time-out is now configurable in TorchConfig.xml
* Fixed infinario log spam
* Fixed crash when sending empty message from chat tab
* Fixed permissions on Torch commands
* Changed plugin StoragePath to the current instance path (per-instance configs)

8
Directory.Build.props Normal file
View File

@@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>
</Project>

View File

@@ -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

View File

@@ -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)
}

73
Jenkinsfile vendored
View File

@@ -1,73 +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}"
}
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*")*/
}
/* Disabled because they fail builds more often than they detect actual problems
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
]]
])
}
*/
}

View File

@@ -3,18 +3,22 @@
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 async="true">
<targets>
<default-wrapper xsi:type="AsyncWrapper" overflowAction="Block" optimizeBufferReuse="true" />
<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" />
<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:shortName=true}: ${var:logContent}" />
<target xsi:type="File" name="patch" layout="${var:logContent}" fileName="Logs\patch.log"/>
<target xsi:type="FlowDocument" name="wpf" layout="${var:logStamp} ${logger:shortName=true}: ${var:logContent}" />
<target xsi:type="LogViewerTarget" name="wpf" layout="[${level:uppercase=true}] ${logger:shortName=true}: ${var:logContent}" />
</targets>
<rules>
<!-- 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" />

View File

@@ -1,5 +1,3 @@
[![Discord](https://discordapp.com/api/guilds/230191591640268800/widget.png)](https://discord.gg/8uHZykr) [![Build Status](http://build.torchapi.net/job/Torch/job/Torch/job/master/badge/icon)](http://build.torchapi.net/job/Torch/job/Torch/job/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,16 +10,27 @@ 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
* Optimized in-game scripts (also newer compiler & language versions)
* Better configuration via cli arguments, environment variables or xml config
* Designed to run multiple instance from same install directory without having you to waste disk space
* Mostly compatible with original torch's plugins
### Discord
If you have any questions or issues please join our [discord](https://discord.gg/UyYFSe3TyQ)
### Installation
* Get the latest Torch release here: https://torchapi.net/download
* 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.
- If you already have a DS installed you can:
* Unzip the Torch files into the folder that contains the DedicatedServer64 folder.
* Pass path to game files using config parameter `gamePath`
# 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.
As a regular dotnet project with cli by running `dotnet build Torch.Server/Torch.Server.csproj`, with VS 2022 or higher, with JB Rider or Fleet.
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon. (https://www.patreon.com/TorchSE)
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon.
[![Patreon](http://i.imgur.com/VzzIMgn.png)](https://www.patreon.com/bePatron?u=847269)!

View File

@@ -1,13 +0,0 @@
:: This script creates a symlink to the game binaries to account for different installation directories on different systems.
@echo off
set /p path="Please enter the folder location of your SpaceEngineersDedicated.exe: "
cd %~dp0
mklink /J GameBinaries "%path%"
if errorlevel 1 goto Error
echo Done! You can now open the Torch solution without issue.
goto End
:Error
echo An error occured creating the symlink.
:End
pause

View File

@@ -0,0 +1,30 @@
using System.IO;
namespace Torch.API;
public interface IApplicationContext
{
/// <summary>
/// Directory contains torch binaries.
/// </summary>
public DirectoryInfo TorchDirectory { get; }
/// <summary>
/// Root directory for all game files.
/// </summary>
public DirectoryInfo GameFilesDirectory { get; }
/// <summary>
/// Directory contains game binaries.
/// </summary>
public DirectoryInfo GameBinariesDirectory { get; }
/// <summary>
/// Current instance directory.
/// </summary>
public DirectoryInfo InstanceDirectory { get; }
/// <summary>
/// Current instance name.
/// </summary>
public string InstanceName { get; }
/// <summary>
/// Application running in service mode.
/// </summary>
public bool IsService { get; }
}

View File

@@ -4,9 +4,11 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Torch.API.Managers;
using Torch.API.Session;
using VRage.Game.ModAPI;
using Version = SemanticVersioning.Version;
namespace Torch.API
{
@@ -15,30 +17,6 @@ namespace Torch.API
/// </summary>
public interface ITorchBase
{
/// <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>
/// Gets the currently running session instance, or null if none exists.
/// </summary>
@@ -48,6 +26,11 @@ namespace Torch.API
/// Configuration for the current instance.
/// </summary>
ITorchConfig Config { get; }
/// <summary>
/// Extended Configuration for the current instance.
/// </summary>
IConfiguration Configuration { get; }
/// <inheritdoc cref="IPluginManager"/>
[Obsolete]
@@ -65,7 +48,17 @@ namespace Torch.API
/// <summary>
/// The binary version of the current instance.
/// </summary>
InformationalVersion TorchVersion { get; }
Version TorchVersion { get; }
/// <summary>
/// Path of the dedicated instance folder.
/// </summary>
string InstancePath { get; }
/// <summary>
/// Name of the dedicated instance.
/// </summary>
string InstanceName { get; }
/// <summary>
/// Invoke an action on the game thread.
@@ -104,7 +97,7 @@ namespace Torch.API
/// <summary>
/// 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.
@@ -145,15 +138,12 @@ namespace Torch.API
/// </summary>
ServerState State { get; }
/// <summary>
/// Path of the dedicated instance folder.
/// </summary>
string InstancePath { get; }
/// <summary>
/// Raised when the server's Init() method has completed.
/// </summary>
event Action<ITorchServer> Initialized;
TimeSpan ElapsedPlayTime { get; set; }
}
/// <summary>

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Torch.API;
namespace Torch
{
@@ -8,17 +10,45 @@ 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; }
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; }
string LoginToken { get; set; }
UpdateSource UpdateSource { get; set; }
List<string> Packages { get; set; }
bool Save(string path = null);
void Save(string path = null);
}
public class UpdateSource
{
public UpdateSourceType SourceType { get; set; }
public string Url { get; set; }
public string Repository { get; set; }
public string Branch { get; set; }
}
public enum UpdateSourceType
{
Github,
Jenkins
}
}

View File

@@ -1,52 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Torch.API
{
/// <summary>
/// Version in the form v#.#.#.#-info
/// </summary>
public class InformationalVersion
{
public Version Version { get; set; }
public string[] Information { get; set; }
public static bool TryParse(string input, out InformationalVersion version)
{
version = default(InformationalVersion);
var trim = input.TrimStart('v');
var info = trim.Split('-');
if (!Version.TryParse(info[0], out Version result))
return false;
version = new InformationalVersion { Version = result };
if (info.Length > 1)
version.Information = info.Skip(1).ToArray();
return true;
}
/// <inheritdoc />
public override string ToString()
{
if (Information == null || Information.Length == 0)
return $"v{Version}";
return $"v{Version}-{string.Join("-", Information)}";
}
public static explicit operator InformationalVersion(Version v)
{
return new InformationalVersion { Version = v };
}
public static implicit operator Version(InformationalVersion v)
{
return v.Version;
}
}
}

View File

@@ -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>

View File

@@ -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; }
}
}

View File

@@ -0,0 +1,20 @@
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 WorldPath { get; }
MyObjectBuilder_SessionSettings KeenSessionSettings { get; }
MyObjectBuilder_Checkpoint KeenCheckpoint { get; }
}

View File

@@ -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>
@@ -42,5 +62,10 @@ namespace Torch.API.Managers
/// 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;
}
}

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.Loader;
using Torch.API.WebAPI.Plugins;
namespace Torch.API.Managers;
public interface IPackageManager : IManager
{
IReadOnlySet<Package> Packages { get; }
bool TryGetPackageAssemblies(Package package, [MaybeNullWhen(false)] out Assembly[] assemblies);
}

View File

@@ -14,6 +14,9 @@ namespace Torch.API.Managers
/// <summary>
/// Fired when plugins are loaded.
/// </summary>
/// <remarks>
/// Fired when plugins are loaded and immediately if subscribed after the plugins are loaded.
/// </remarks>
event Action<IReadOnlyCollection<ITorchPlugin>> PluginsLoaded;
/// <summary>

View File

@@ -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;

View File

@@ -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
}
}

View File

@@ -1,17 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Torch API")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Torch")]
[assembly: AssemblyCopyright("Copyright © Torch API 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

View File

@@ -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; }

View File

@@ -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;
}
}

View File

@@ -1,201 +1,27 @@
<?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>
<AssemblyTitle>Torch API</AssemblyTitle>
<Product>Torch</Product>
<Copyright>Copyright © Torch API 2017</Copyright>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<UseWpf>True</UseWpf>
</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>
</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>
<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>
<HintPath>..\GameBinaries\Sandbox.Common.dll</HintPath>
<Private>False</Private>
</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>
</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>
</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="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>
</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>
</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>
</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>
</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>
</Reference>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="NuGet.Commands" Version="6.8.0" />
<PackageReference Include="NuGet.DependencyResolver.Core" Version="6.8.0" />
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.203.505.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>compile</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Versioning\AssemblyVersion.cs">
<Link>Properties\AssemblyVersion.cs</Link>
</Compile>
<Compile Include="ConnectionState.cs" />
<Compile Include="InformationalVersion.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\GameSaveResult.cs" />
<Compile Include="Session\ITorchSession.cs" />
<Compile Include="Session\ITorchSessionManager.cs" />
<Compile Include="Session\TorchSessionState.cs" />
<Compile Include="TorchGameState.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
</Project>

View File

@@ -0,0 +1,8 @@
namespace Torch.API
{
public enum UGCServiceType
{
Steam,
EOS
}
}

View 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);
}
}
}
}

View 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());
}
}

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Threading.Tasks;
namespace Torch.API.WebAPI.Plugin;
public interface IPluginQuery
{
Task<PluginsResponse> QueryAll();
Task<PluginItem> QueryOne(Guid guid);
Task<bool> DownloadPlugin(Guid guid, string path = null);
Task<bool> DownloadPlugin(PluginItem item, string path = null);
}

View File

@@ -0,0 +1,81 @@
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading;
using System.Threading.Tasks;
using NLog;
namespace Torch.API.WebAPI.Plugin;
public class LegacyPluginQuery : IPluginQuery
{
private const string BASE_URL = "https://torchapi.com/";
private readonly HttpClient _client;
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
private LegacyPluginQuery()
{
_client = new()
{
BaseAddress = new(BASE_URL)
};
}
public static LegacyPluginQuery Instance { get; } = new();
public async Task<PluginsResponse> QueryAll()
{
return await _client.GetFromJsonAsync<PluginsResponse>("/api/plugins/", CancellationToken.None);
}
public async Task<PluginItem> QueryOne(Guid guid)
{
using var res = await _client.GetAsync($"/api/plugins/search/{guid}");
if (!res.IsSuccessStatusCode)
return null;
return await res.Content.ReadFromJsonAsync<PluginItem>();
}
public async Task<bool> DownloadPlugin(Guid 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(AppContext.BaseDirectory, "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 false;
}
return true;
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Text.Json.Serialization;
namespace Torch.API.WebAPI.Plugin;
public record PluginItem(Guid Id, string Name, string Author, string Description, string LatestVersion,
VersionItem[] Versions)
{
[JsonIgnore]
public bool Installed { get; set; }
}

View File

@@ -0,0 +1,3 @@
namespace Torch.API.WebAPI.Plugin;
public record PluginsResponse(PluginItem[] Plugins);

View File

@@ -0,0 +1,6 @@
using System.Text.Json.Serialization;
namespace Torch.API.WebAPI.Plugin;
public record VersionItem(string Version, string Note, [property: JsonPropertyName("is_beta")] bool IsBeta,
string Url);

View File

@@ -0,0 +1,11 @@
#nullable enable
using System.IO;
using System.Threading.Tasks;
namespace Torch.API.WebAPI.Plugins;
public interface IPackageItem
{
Task<Stream> OpenFileAsync();
public string FileName { get; }
}

View File

@@ -0,0 +1,12 @@
#nullable enable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Torch.API.WebAPI.Plugins;
public interface IPackageReader
{
Task<(IEnumerable<IPackageItem> Root, IReadOnlyDictionary<PackageDependency, IEnumerable<IPackageItem>> Dependencies)> GetItemsAsync();
}

View File

@@ -0,0 +1,11 @@
#nullable enable
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Torch.API.WebAPI.Plugins;
public interface IPackageResolver
{
Task<IEnumerable<Package>> ResolvePackagesAsync(IReadOnlyDictionary<string, string> packages);
Task<IPackageReader> GetPackageAsync(Package package);
}

View File

@@ -0,0 +1,87 @@
#nullable enable
using System;
using System.Threading.Tasks;
using NuGet.Common;
namespace Torch.API.WebAPI.Plugins;
internal class NLogLogger : ILogger
{
private readonly NLog.ILogger _logger;
public NLogLogger(NLog.ILogger logger)
{
_logger = logger;
}
public void LogDebug(string data)
{
_logger.Debug(data);
}
public void LogVerbose(string data)
{
_logger.Trace(data);
}
public void LogInformation(string data)
{
_logger.Info(data);
}
public void LogMinimal(string data)
{
_logger.Debug(data);
}
public void LogWarning(string data)
{
_logger.Warn(data);
}
public void LogError(string data)
{
_logger.Error(data);
}
public void LogInformationSummary(string data)
{
_logger.Info(data);
}
public void Log(LogLevel level, string data)
{
_logger.Log(ToNLogLevel(level), data);
}
private static NLog.LogLevel ToNLogLevel(LogLevel level)
{
return level switch
{
LogLevel.Debug => NLog.LogLevel.Debug,
LogLevel.Verbose => NLog.LogLevel.Trace,
LogLevel.Information => NLog.LogLevel.Info,
LogLevel.Minimal => NLog.LogLevel.Debug,
LogLevel.Warning => NLog.LogLevel.Warn,
LogLevel.Error => NLog.LogLevel.Error,
_ => throw new ArgumentOutOfRangeException(nameof(level), level, null)
};
}
public Task LogAsync(LogLevel level, string data)
{
Log(level, data);
return Task.CompletedTask;
}
public void Log(ILogMessage message)
{
_logger.Log(ToNLogLevel(message.Level), message.FormatWithCode);
}
public Task LogAsync(ILogMessage message)
{
Log(message);
return Task.CompletedTask;
}
}

View File

@@ -0,0 +1,10 @@
using System.Collections.Generic;
using NuGet.DependencyResolver;
using SemanticVersioning;
namespace Torch.API.WebAPI.Plugins;
public record Package(string Name, Version Version, IReadOnlySet<PackageDependency> Dependencies)
{
internal GraphItem<RemoteResolveResult> Graph { get; init; }
}

View File

@@ -0,0 +1,9 @@
using NuGet.DependencyResolver;
using SemanticVersioning;
namespace Torch.API.WebAPI.Plugins;
public record PackageDependency(string Name, Version Version, PackageDependencyKind Kind)
{
internal RemoteMatch Match { get; init; }
}

View File

@@ -0,0 +1,8 @@
namespace Torch.API.WebAPI.Plugins;
public enum PackageDependencyKind
{
None,
Transitive,
Direct
}

View File

@@ -0,0 +1,91 @@
#nullable enable
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using NuGet.Common;
using NuGet.DependencyResolver;
using NuGet.Frameworks;
using NuGet.Packaging;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;
namespace Torch.API.WebAPI.Plugins;
public class PackageReader : IPackageReader
{
private readonly Package _package;
private readonly SourceCacheContext _cacheContext;
private readonly ILogger _logger;
private readonly NuGetFramework _framework;
private readonly IFrameworkCompatibilityProvider _compatibilityProvider;
private readonly DirectoryInfo _packagesDirectory;
public PackageReader(Package package, SourceCacheContext cacheContext, ILogger logger, NuGetFramework framework,
IFrameworkCompatibilityProvider compatibilityProvider, DirectoryInfo packagesDirectory)
{
_package = package;
_cacheContext = cacheContext;
_logger = logger;
_framework = framework;
_compatibilityProvider = compatibilityProvider;
_packagesDirectory = packagesDirectory;
}
public async Task<(IEnumerable<IPackageItem> Root, IReadOnlyDictionary<PackageDependency, IEnumerable<IPackageItem>>
Dependencies)>
GetItemsAsync()
{
async Task<IEnumerable<IPackageItem>> GetPackageItemsAsync(string id, NuGetVersion version,
IRemoteDependencyProvider provider)
{
var downloader =
await provider.GetPackageDownloaderAsync(new(id, version), _cacheContext, _logger,
CancellationToken.None);
await downloader.CopyNupkgFileToAsync(Path.Combine(_packagesDirectory.FullName, $"{id}.{version}.nupkg"),
CancellationToken.None);
var frameworks = await downloader.ContentReader.GetReferenceItemsAsync(CancellationToken.None);
var items = frameworks.Where(b => _compatibilityProvider.IsCompatible(_framework, b.TargetFramework))
.MaxBy(b => b.TargetFramework.Version)?.Items;
return items?.Select(b => new PackageItem(b, downloader)) ?? ImmutableArray<PackageItem>.Empty;
}
var rootIdentity = _package.Graph.Key;
return (await GetPackageItemsAsync(rootIdentity.Name, rootIdentity.Version, _package.Graph.Data.Match.Provider),
await _package.Dependencies.ToAsyncEnumerable().SelectManyAwait(async b =>
(await GetPackageItemsAsync(
b.Match.Library.Name,
b.Match.Library.Version,
b.Match.Provider))
.ToAsyncEnumerable()
.Select(c => (b, c)))
.GroupBy(b => b.b, b => b.c)
.ToDictionaryAwaitAsync<IAsyncGrouping<PackageDependency, IPackageItem>, PackageDependency,
IEnumerable<IPackageItem>>(b => ValueTask.FromResult(b.Key),
async b => await b.ToArrayAsync()));
}
}
file class PackageItem : IPackageItem
{
private readonly string _path;
private readonly IPackageDownloader _downloader;
public string FileName => Path.GetFileName(_path);
public PackageItem(string path, IPackageDownloader downloader)
{
_path = path;
_downloader = downloader;
}
public Task<Stream> OpenFileAsync()
{
return _downloader.CoreReader.GetStreamAsync(_path, CancellationToken.None);
}
}

View File

@@ -0,0 +1,104 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using NLog;
using NuGet.Commands;
using NuGet.Configuration;
using NuGet.DependencyResolver;
using NuGet.Frameworks;
using NuGet.LibraryModel;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;
using Version = SemanticVersioning.Version;
namespace Torch.API.WebAPI.Plugins;
public class PackageResolver : IPackageResolver
{
private static readonly ILogger Log = LogManager.GetCurrentClassLogger();
private readonly NuGetFramework _framework = NuGetFramework.Parse("net7.0-windows7.0");
private readonly NLogLogger _logger = new(Log);
private readonly SourceCacheContext _sourceCacheContext = new();
private readonly RemoteWalkContext _remoteWalkContext;
private readonly DirectoryInfo _packagesDirectory;
private readonly IFrameworkCompatibilityProvider _compatibilityProvider = DefaultCompatibilityProvider.Instance;
public PackageResolver(IEnumerable<PackageSource> sources, DirectoryInfo packagesDirectory)
{
_packagesDirectory = packagesDirectory;
IReadOnlySet<PackageSource> packageSources = sources.Where(b => b.Type is PackageSourceType.NuGet).ToImmutableHashSet();
var mapping = new PackageSourceMapping(packageSources.ToDictionary(b => b.Name, b => b.Patterns));
_remoteWalkContext = new RemoteWalkContext(_sourceCacheContext, mapping, _logger);
foreach (var (name, url, _, _) in packageSources)
{
var packageSource = new NuGet.Configuration.PackageSource(url, name);
var sourceRepository = new SourceRepository(packageSource, new INuGetResourceProvider[]
{
new DownloadResourceV3Provider(),
new DependencyInfoResourceV3Provider(),
new ServiceIndexResourceV3Provider(),
new RemoteV3FindPackageByIdResourceProvider(),
new V3FeedListResourceProvider(),
new HttpSourceResourceProvider(),
new RegistrationResourceV3Provider(),
new HttpHandlerResourceV3Provider()
}.Select(b => new Lazy<INuGetResourceProvider>(b)), FeedType.HttpV3);
_remoteWalkContext.RemoteLibraryProviders.Add(
new SourceRepositoryDependencyProvider(sourceRepository, _logger, _sourceCacheContext, true, false));
}
}
public async Task<IEnumerable<Package>> ResolvePackagesAsync(
IReadOnlyDictionary<string, string> packages)
{
Log.Info("Restoring {0} packages", packages.Count);
var graphs = await Task.WhenAll(packages.Select(b =>
{
var (key, versionRange) = b;
var libraryRange = new LibraryRange(key, VersionRange.Parse(versionRange), LibraryDependencyTarget.All);
return ResolverUtility.FindLibraryEntryAsync(libraryRange, _framework, "win-x64",
_remoteWalkContext, CancellationToken.None);
}));
return await graphs.ToAsyncEnumerable().SelectAwait(async graph =>
{
return new Package(graph.Key.Name, Version.Parse(graph.Key.Version.ToFullString()),
await graph.Data.Dependencies
.ToAsyncEnumerable()
.SelectAwait(async b =>
{
var match = await ResolverUtility.FindLibraryByVersionAsync(
b.LibraryRange, _framework, _remoteWalkContext.RemoteLibraryProviders,
_sourceCacheContext, _logger, CancellationToken.None);
return new PackageDependency(
b.Name, Version.Parse(match.Library.Version.ToFullString()),
(PackageDependencyKind)b.ReferenceType)
{
Match = match
};
})
.ToHashSetAsync())
{
Graph = graph
};
}).ToArrayAsync();
}
public Task<IPackageReader> GetPackageAsync(Package package)
{
var reader = new PackageReader(package, _sourceCacheContext, _logger, _framework, _compatibilityProvider, _packagesDirectory);
return Task.FromResult<IPackageReader>(reader);
}
}

View File

@@ -0,0 +1,8 @@
using System.Collections.Generic;
namespace Torch.API.WebAPI.Plugins;
#nullable enable
public record PackageSource
#nullable restore
(string Name, string Url, IReadOnlyList<string> Patterns, PackageSourceType Type);

View File

@@ -0,0 +1,8 @@
#nullable enable
namespace Torch.API.WebAPI.Plugins;
public enum PackageSourceType
{
NuGet,
LegacyTorch
}

View File

@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;
using Version = SemanticVersioning.Version;
namespace Torch.API.WebAPI.Update;
public class GithubQuery : IUpdateQuery
{
private readonly HttpClient _client;
public GithubQuery(string url)
{
if (url == null) throw new ArgumentNullException(nameof(url));
_client = new()
{
BaseAddress = new(url),
DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher,
DefaultRequestHeaders =
{
{"User-Agent", "TorchAPI"}
}
};
}
public void Dispose()
{
_client?.Dispose();
}
public async Task<UpdateRelease> GetLatestReleaseAsync(string repository, string branch = null)
{
var response = await _client.GetFromJsonAsync<Release>($"/repos/{repository}/releases/latest", new JsonSerializerOptions(JsonSerializerDefaults.Web)
{
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
});
if (response is null)
throw new($"Unable to get latest release for {repository}");
return new(Version.Parse(response.TagName), response.Assets.First(b => b.Name == "torch-server.zip").BrowserDownloadUrl);
}
private record Asset(
string Url,
int Id,
string NodeId,
string Name,
string Label,
Uploader Uploader,
string ContentType,
string State,
int Size,
int DownloadCount,
DateTime CreatedAt,
DateTime UpdatedAt,
string BrowserDownloadUrl
);
private record Author(
string Login,
int Id,
string NodeId,
string AvatarUrl,
string GravatarId,
string Url,
string HtmlUrl,
string FollowersUrl,
string FollowingUrl,
string GistsUrl,
string StarredUrl,
string SubscriptionsUrl,
string OrganizationsUrl,
string ReposUrl,
string EventsUrl,
string ReceivedEventsUrl,
string Type,
bool SiteAdmin
);
private record Release(
string Url,
string AssetsUrl,
string UploadUrl,
string HtmlUrl,
int Id,
Author Author,
string NodeId,
string TagName,
string TargetCommitish,
string Name,
bool Draft,
bool Prerelease,
DateTime CreatedAt,
DateTime PublishedAt,
IReadOnlyList<Asset> Assets,
string TarballUrl,
string ZipballUrl,
string Body
);
private record Uploader(
string Login,
int Id,
string NodeId,
string AvatarUrl,
string GravatarId,
string Url,
string HtmlUrl,
string FollowersUrl,
string FollowingUrl,
string GistsUrl,
string StarredUrl,
string SubscriptionsUrl,
string OrganizationsUrl,
string ReposUrl,
string EventsUrl,
string ReceivedEventsUrl,
string Type,
bool SiteAdmin
);
}

View File

@@ -0,0 +1,9 @@
using System;
using System.Threading.Tasks;
namespace Torch.API.WebAPI.Update;
public interface IUpdateQuery : IDisposable
{
Task<UpdateRelease> GetLatestReleaseAsync(string repository, string branch = null);
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Torch.API.Utils;
using Version = SemanticVersioning.Version;
namespace Torch.API.WebAPI.Update
{
public class JenkinsQuery : IUpdateQuery
{
private const string ApiPath = "api/json";
private readonly HttpClient _client;
public JenkinsQuery(string url)
{
if (url == null) throw new ArgumentNullException(nameof(url));
_client = new()
{
BaseAddress = new(url)
};
}
public async Task<UpdateRelease> GetLatestReleaseAsync(string repository, string branch = null)
{
branch ??= "master";
var response = await _client.GetFromJsonAsync<BranchResponse>($"/job/{repository}/job/{branch}/{ApiPath}");
if (response is null)
throw new($"Unable to get latest release for {repository}");
var job = await _client.GetFromJsonAsync<Job>(
$"/job/{repository}/job/{branch}/{response.LastBuild.Number}/{ApiPath}");
if (job is null)
throw new($"Unable to get latest release for job {repository}/{response.LastBuild.Number}");
return new(job.Version, job.Url + job.Artifacts.First(b => b.FileName == "torch-server.zip").RelativePath);
}
public void Dispose()
{
_client?.Dispose();
}
}
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,
IReadOnlyList<Artifact> Artifacts);
public record Artifact(
string DisplayPath,
string FileName,
string RelativePath
);
}

View File

@@ -0,0 +1,5 @@
using SemanticVersioning;
namespace Torch.API.WebAPI.Update;
public record UpdateRelease(Version Version, string ArtifactUrl);

View File

@@ -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>

View File

@@ -0,0 +1,233 @@
{
"version": 1,
"dependencies": {
"net8.0-windows7.0": {
"Microsoft.Extensions.Configuration.Binder": {
"type": "Direct",
"requested": "[8.0.0, )",
"resolved": "8.0.0",
"contentHash": "mBMoXLsr5s1y2zOHWmKsE9veDcx8h1x/c3rz4baEdQKTeDcmQAPNbB54Pi/lhFO3K431eEq6PFbMgLaa6PHFfA==",
"dependencies": {
"Microsoft.Extensions.Configuration.Abstractions": "8.0.0"
}
},
"NLog": {
"type": "Direct",
"requested": "[5.2.8, )",
"resolved": "5.2.8",
"contentHash": "jAIELkWBs1CXFPp986KSGpDFQZHCFccO+LMbKBTTNm42KifaI1mYzFMFQQfuGmGMTrCx0TFPhDjHDE4cLAZWiQ=="
},
"NuGet.Commands": {
"type": "Direct",
"requested": "[6.8.0, )",
"resolved": "6.8.0",
"contentHash": "jTlbIYNXIiO25s/A2UMBHYhLmNm/lJP+/a/X4OJebejnSKmeKjXeCd9NYH+D9y21JMh3eS0khkCpPnLIgdHsCQ==",
"dependencies": {
"Microsoft.Extensions.FileProviders.Abstractions": "6.0.0",
"Microsoft.Extensions.FileSystemGlobbing": "6.0.0",
"NuGet.Credentials": "6.8.0",
"NuGet.ProjectModel": "6.8.0"
}
},
"NuGet.DependencyResolver.Core": {
"type": "Direct",
"requested": "[6.8.0, )",
"resolved": "6.8.0",
"contentHash": "dTdE5VmQnWfZU2tM4glgsO1ZpFZoEqLKUtpDkr11dkVV4nQn5/MqK9Wmvp/SbU1t7AoSEf7yIMAew9SHxganYA==",
"dependencies": {
"NuGet.Configuration": "6.8.0",
"NuGet.LibraryModel": "6.8.0",
"NuGet.Protocol": "6.8.0"
}
},
"SemanticVersioning": {
"type": "Direct",
"requested": "[2.0.2, )",
"resolved": "2.0.2",
"contentHash": "4EQgYdNZ92SyaO7YFk6olVnebF5V+jrHyMUjvPq89tLeMo8NSfgDF+6Zwq/lgh9j/0yfQp9Lkm0ZA0rUATCZFA=="
},
"SpaceEngineersDedicated.ReferenceAssemblies": {
"type": "Direct",
"requested": "[1.203.505.1, )",
"resolved": "1.203.505.1",
"contentHash": "YokcOxKdIvtJ2fYdkF48/wvbdaDlNl+bbUd11vkdPRdHaprRj5b2F1wUk7faL0J0UIX87lyhgC/HsNn9rHVbJw==",
"dependencies": {
"protobuf-net": "1.0.0"
}
},
"System.Linq.Async": {
"type": "Direct",
"requested": "[6.0.1, )",
"resolved": "6.0.1",
"contentHash": "0YhHcaroWpQ9UCot3Pizah7ryAzQhNvobLMSxeDIGmnXfkQn8u5owvpOH0K6EVB+z9L7u6Cc4W17Br/+jyttEQ==",
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "6.0.0"
}
},
"System.Text.Json": {
"type": "Direct",
"requested": "[8.0.0, )",
"resolved": "8.0.0",
"contentHash": "OdrZO2WjkiEG6ajEFRABTRCi/wuXQPxeV6g8xvUJqdxMvvuCCEk86zPla8UiIQJz3durtUEbNyY/3lIhS0yZvQ==",
"dependencies": {
"System.Text.Encodings.Web": "8.0.0"
}
},
"Microsoft.Bcl.AsyncInterfaces": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg=="
},
"Microsoft.Extensions.Configuration.Abstractions": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "3lE/iLSutpgX1CC0NOW70FJoGARRHbyKmG7dc0klnUZ9Dd9hS6N/POPWhKhMLCEuNN5nXEY5agmlFtH562vqhQ==",
"dependencies": {
"Microsoft.Extensions.Primitives": "8.0.0"
}
},
"Microsoft.Extensions.FileProviders.Abstractions": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "0pd4/fho0gC12rQswaGQxbU34jOS1TPS8lZPpkFCH68ppQjHNHYle9iRuHeev1LhrJ94YPvzcRd8UmIuFk23Qw==",
"dependencies": {
"Microsoft.Extensions.Primitives": "6.0.0"
}
},
"Microsoft.Extensions.FileSystemGlobbing": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "ip8jnL1aPiaPeKINCqaTEbvBFDmVx9dXQEBZ2HOBRXPD1eabGNqP/bKlsIcp7U2lGxiXd5xIhoFcmY8nM4Hdiw=="
},
"Microsoft.Extensions.Primitives": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g=="
},
"Newtonsoft.Json": {
"type": "Transitive",
"resolved": "13.0.3",
"contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ=="
},
"NuGet.Common": {
"type": "Transitive",
"resolved": "6.8.0",
"contentHash": "voNZyM5L5s0CCDPU//vXKQke0M8y6kGvG+0Ll6gc/xV7Jh1C3/5OhHRzvekxBS6a9DO/lsFhTZtyCkL6n9lHEw==",
"dependencies": {
"NuGet.Frameworks": "6.8.0"
}
},
"NuGet.Configuration": {
"type": "Transitive",
"resolved": "6.8.0",
"contentHash": "FFEoY1L9G+C74HfSYt6epHTIuS5xJ8D+d9LZ5nnqhujMoBlQgHphaCTfRlul+e/bNIkAp1fDObzsGlPmu3CKAg==",
"dependencies": {
"NuGet.Common": "6.8.0",
"System.Security.Cryptography.ProtectedData": "4.4.0"
}
},
"NuGet.Credentials": {
"type": "Transitive",
"resolved": "6.8.0",
"contentHash": "0Cp5iSgmweBKjDbywqNVVlVFCtjmt4z7ol5ED3hjMGNQp1HgthOZ+PSVD2xa+5rf4/in2Nt2/4W938KqreigJg==",
"dependencies": {
"NuGet.Protocol": "6.8.0"
}
},
"NuGet.Frameworks": {
"type": "Transitive",
"resolved": "6.8.0",
"contentHash": "cN9NyahKgYYScioH4CKn+TYj1eSODxd0RECFnQt6ZmzT6z7PfXlbYpVzbiPsxNgY23iNDMOVkSmOqNZyYxNlQA=="
},
"NuGet.LibraryModel": {
"type": "Transitive",
"resolved": "6.8.0",
"contentHash": "qdNqSa1E/VgpY95XJuLtJrSA74XpWCn5iGf/9r7FMa5smSZt7nClHcMrxOalfzilMKl4prUkE7AVw2AvKZ39Mg==",
"dependencies": {
"NuGet.Common": "6.8.0",
"NuGet.Versioning": "6.8.0"
}
},
"NuGet.Packaging": {
"type": "Transitive",
"resolved": "6.8.0",
"contentHash": "lyDnMCAWtoHNsNKGexIl6yHtyxuvn2j3rpKMrYYf86KwTV+JVY9eFIixNdwEPjBXBzWHQGpDKj9Im8v02t9AQQ==",
"dependencies": {
"Newtonsoft.Json": "13.0.3",
"NuGet.Configuration": "6.8.0",
"NuGet.Versioning": "6.8.0",
"System.Security.Cryptography.Pkcs": "6.0.4"
}
},
"NuGet.ProjectModel": {
"type": "Transitive",
"resolved": "6.8.0",
"contentHash": "4lXoQxLn2fAN+Yu9SHLRcjPCXNVj039FMXE9vUm14ZjCk889dGCEbUWtF3PUqqRpMGnp6IckDd8zubvXI4H1cw==",
"dependencies": {
"NuGet.DependencyResolver.Core": "6.8.0"
}
},
"NuGet.Protocol": {
"type": "Transitive",
"resolved": "6.8.0",
"contentHash": "Nfvij7QlEevDbuRCXkhCrHk1oJN+mYkmeVzNvS9hxNTmwdtHqB+zhUIMFBlbye3MUicgc4bbtLAwoF+EKjUvcg==",
"dependencies": {
"NuGet.Packaging": "6.8.0"
}
},
"NuGet.Versioning": {
"type": "Transitive",
"resolved": "6.8.0",
"contentHash": "WBu15cdv1lqKkPKXDQOEmEzwKemwrczKYlc2jtuZgRYiZ8TG8F4QzPYiE0Q9eVIpMSk8Aky7mUephf19HjBPOw=="
},
"protobuf-net": {
"type": "Transitive",
"resolved": "1.0.0",
"contentHash": "kTGOK0E87473sOImOjgZOnz3kTC2aMLffoRWQLYNuBLJnwNNmjanF9IkevZ9Q7yYLeABQfcF3BpeepuMntMVNw=="
},
"System.Formats.Asn1": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "T6fD00dQ3NTbPDy31m4eQUwKW84s03z0N2C8HpOklyeaDgaJPa/TexP4/SkORMSOwc7WhKifnA6Ya33AkzmafA=="
},
"System.Security.Cryptography.Pkcs": {
"type": "Transitive",
"resolved": "6.0.4",
"contentHash": "LGbXi1oUJ9QgCNGXRO9ndzBL/GZgANcsURpMhNR8uO+rca47SZmciS3RSQUvlQRwK3QHZSHNOXzoMUASKA+Anw==",
"dependencies": {
"System.Formats.Asn1": "6.0.0"
}
},
"System.Security.Cryptography.ProtectedData": {
"type": "Transitive",
"resolved": "4.4.0",
"contentHash": "cJV7ScGW7EhatRsjehfvvYVBvtiSMKgN8bOVI0bQhnF5bU7vnHVIsH49Kva7i7GWaWYvmEzkYVk1TC+gZYBEog=="
},
"System.Text.Encodings.Web": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ=="
}
},
"net8.0-windows7.0/win-x64": {
"System.Security.Cryptography.Pkcs": {
"type": "Transitive",
"resolved": "6.0.4",
"contentHash": "LGbXi1oUJ9QgCNGXRO9ndzBL/GZgANcsURpMhNR8uO+rca47SZmciS3RSQUvlQRwK3QHZSHNOXzoMUASKA+Anw==",
"dependencies": {
"System.Formats.Asn1": "6.0.0"
}
},
"System.Security.Cryptography.ProtectedData": {
"type": "Transitive",
"resolved": "4.4.0",
"contentHash": "cJV7ScGW7EhatRsjehfvvYVBvtiSMKgN8bOVI0bQhnF5bU7vnHVIsH49Kva7i7GWaWYvmEzkYVk1TC+gZYBEog=="
},
"System.Text.Encodings.Web": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ=="
}
}
}
}

View File

@@ -1,17 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Torch Client Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Torch")]
[assembly: AssemblyCopyright("Copyright © Torch API 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

View File

@@ -1,97 +0,0 @@
<?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')" />
<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>
<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>
<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>
</PropertyGroup>
<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" />
</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>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
</Project>

View File

@@ -1,94 +0,0 @@
using System;
using System.Collections.Generic;
using Torch.Client;
using Torch.Tests;
using Torch.Utils;
using Xunit;
namespace Torch.Client.Tests
{
public class TorchClientReflectionTest
{
static TorchClientReflectionTest()
{
TestUtils.Init();
}
private static ReflectionTestManager _manager;
private static ReflectionTestManager Manager()
{
if (_manager != null)
return _manager;
return _manager = new ReflectionTestManager().Init(typeof(TorchClient).Assembly);
}
public static IEnumerable<object[]> Getters => Manager().Getters;
public static IEnumerable<object[]> Setters => Manager().Setters;
public static IEnumerable<object[]> Invokers => Manager().Invokers;
public static IEnumerable<object[]> MemberInfo => Manager().MemberInfo;
public static IEnumerable<object[]> Events => Manager().Events;
#region Binding
[Theory]
[MemberData(nameof(Getters))]
public void TestBindingGetter(ReflectionTestManager.FieldRef field)
{
if (field.Field == null)
return;
Assert.True(ReflectedManager.Process(field.Field));
if (field.Field.IsStatic)
Assert.NotNull(field.Field.GetValue(null));
}
[Theory]
[MemberData(nameof(Setters))]
public void TestBindingSetter(ReflectionTestManager.FieldRef field)
{
if (field.Field == null)
return;
Assert.True(ReflectedManager.Process(field.Field));
if (field.Field.IsStatic)
Assert.NotNull(field.Field.GetValue(null));
}
[Theory]
[MemberData(nameof(Invokers))]
public void TestBindingInvoker(ReflectionTestManager.FieldRef field)
{
if (field.Field == null)
return;
Assert.True(ReflectedManager.Process(field.Field));
if (field.Field.IsStatic)
Assert.NotNull(field.Field.GetValue(null));
}
[Theory]
[MemberData(nameof(MemberInfo))]
public void TestBindingMemberInfo(ReflectionTestManager.FieldRef field)
{
if (field.Field == null)
return;
Assert.True(ReflectedManager.Process(field.Field));
if (field.Field.IsStatic)
Assert.NotNull(field.Field.GetValue(null));
}
[Theory]
[MemberData(nameof(Events))]
public void TestBindingEvents(ReflectionTestManager.FieldRef field)
{
if (field.Field == null)
return;
Assert.True(ReflectedManager.Process(field.Field));
if (field.Field.IsStatic)
((Func<ReflectedEventReplacer>)field.Field.GetValue(null)).Invoke();
}
#endregion
}
}

View File

@@ -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>

View File

@@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Engine.Multiplayer;
using Torch.API;
using Torch.API.Managers;
using Torch.Managers;
namespace Torch.Client.Manager
{
public class MultiplayerManagerClient : MultiplayerManagerBase, IMultiplayerManagerClient
{
/// <inheritdoc />
public MultiplayerManagerClient(ITorchBase torch) : base(torch) { }
/// <inheritdoc />
public override void Attach()
{
base.Attach();
MyMultiplayer.Static.ClientJoined += RaiseClientJoined;
}
/// <inheritdoc />
public override void Detach()
{
MyMultiplayer.Static.ClientJoined -= RaiseClientJoined;
base.Detach();
}
}
}

View File

@@ -1,58 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Engine.Multiplayer;
using Torch.API;
using Torch.API.Managers;
using Torch.Managers;
namespace Torch.Client.Manager
{
public class MultiplayerManagerLobby : MultiplayerManagerBase, IMultiplayerManagerServer
{
/// <inheritdoc />
public IReadOnlyList<ulong> BannedPlayers => new List<ulong>();
/// <inheritdoc />
public MultiplayerManagerLobby(ITorchBase torch) : base(torch) { }
/// <inheritdoc />
public void KickPlayer(ulong steamId) => Torch.Invoke(() => MyMultiplayer.Static.KickClient(steamId));
/// <inheritdoc />
public void BanPlayer(ulong steamId, bool banned = true) => Torch.Invoke(() => MyMultiplayer.Static.BanClient(steamId, banned));
/// <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 override void Attach()
{
base.Attach();
MyMultiplayer.Static.ClientJoined += RaiseClientJoined;
}
/// <inheritdoc/>
public override void Detach()
{
MyMultiplayer.Static.ClientJoined -= RaiseClientJoined;
base.Detach();
}
}
}

View File

@@ -1,194 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Forms;
using NLog;
using Torch.Utils;
using MessageBox = System.Windows.MessageBox;
namespace Torch.Client
{
public static class Program
{
public const string SpaceEngineersBinaries = "Bin64";
private static string _spaceEngInstallAlias = null;
public static string SpaceEngineersInstallAlias
{
get
{
// ReSharper disable once ConvertIfStatementToNullCoalescingExpression
if (_spaceEngInstallAlias == null)
{
// ReSharper disable once AssignNullToNotNullAttribute
_spaceEngInstallAlias = Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location),
"SpaceEngineersAlias");
}
return _spaceEngInstallAlias;
}
}
private const string _steamSpaceEngineersDirectory = @"steamapps\common\SpaceEngineers\";
private const string _spaceEngineersVerifyFile = SpaceEngineersBinaries + @"\SpaceEngineers.exe";
public const string ConfigName = "Torch.cfg";
private static Logger _log = LogManager.GetLogger("Torch");
#if DEBUG
[DllImport("kernel32.dll")]
private static extern void AllocConsole();
[DllImport("kernel32.dll")]
private static extern void FreeConsole();
#endif
public static void Main(string[] args)
{
#if DEBUG
try
{
AllocConsole();
#endif
if (!TorchLauncher.IsTorchWrapped())
{
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
{
FreeConsole();
}
#endif
}
private static void SetupSpaceEngInstallAlias()
{
string spaceEngineersDirectory = null;
// 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;
if (steamDir != null)
{
spaceEngineersDirectory = Path.Combine(steamDir, _steamSpaceEngineersDirectory);
// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
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)
{
var dialog = new System.Windows.Forms.FolderBrowserDialog
{
Description = "Please select the SpaceEngineers installation folder"
};
do
{
if (dialog.ShowDialog() != DialogResult.OK)
{
var ex = new FileNotFoundException(
"Unable to find the Space Engineers install directory, aborting");
_log.Fatal(ex);
LogManager.Flush();
throw ex;
}
spaceEngineersDirectory = dialog.SelectedPath;
if (File.Exists(Path.Combine(spaceEngineersDirectory, _spaceEngineersVerifyFile)))
break;
if (MessageBox.Show(
$"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.
}
if (!JunctionLink(SpaceEngineersInstallAlias, spaceEngineersDirectory))
{
var ex = new IOException(
$"Failed to create junction link {SpaceEngineersInstallAlias} => {spaceEngineersDirectory}. Aborting.");
_log.Fatal(ex);
LogManager.Flush();
throw ex;
}
string junctionVerify = Path.Combine(SpaceEngineersInstallAlias, _spaceEngineersVerifyFile);
if (!File.Exists(junctionVerify))
{
var ex = new FileNotFoundException(
$"Junction link is not working. File {junctionVerify} does not exist");
_log.Fatal(ex);
LogManager.Flush();
throw ex;
}
}
private static bool JunctionLink(string linkName, string targetDir)
{
var junctionLinkProc = new ProcessStartInfo("cmd.exe", $"/c mklink /J \"{linkName}\" \"{targetDir}\"")
{
WorkingDirectory = Directory.GetCurrentDirectory(),
UseShellExecute = false,
RedirectStandardOutput = true,
StandardOutputEncoding = Encoding.ASCII
};
Process cmd = Process.Start(junctionLinkProc);
// ReSharper disable once PossibleNullReferenceException
while (!cmd.HasExited)
{
string line = cmd.StandardOutput.ReadLine();
if (!string.IsNullOrWhiteSpace(line))
_log.Info(line);
Thread.Sleep(100);
}
if (cmd.ExitCode != 0)
_log.Error("Unable to create junction link {0} => {1}", linkName, targetDir);
return cmd.ExitCode == 0;
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var ex = (Exception) e.ExceptionObject;
_log.Error(ex);
LogManager.Flush();
MessageBox.Show(ex.StackTrace, ex.Message);
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void RunClient()
{
var client = new TorchClient();
try
{
client.Init();
}
catch (Exception e)
{
_log.Fatal("Torch encountered an error trying to initialize the game.");
_log.Fatal(e);
return;
}
client.Start();
}
}
}

View File

@@ -1,17 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Torch Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Torch")]
[assembly: AssemblyCopyright("Copyright © Torch API 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

View File

@@ -1,63 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Torch.Client.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// 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.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Torch.Client.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -1,26 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Torch.Client.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -1,181 +0,0 @@
<?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')" />
<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>
<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>
<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>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>torchicon.ico</ApplicationIcon>
</PropertyGroup>
<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>
</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>
</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="VRage">
<HintPath>..\GameBinaries\VRage.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRage.Game">
<HintPath>..\GameBinaries\VRage.Game.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRage.Game.XmlSerializers">
<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>
</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.Render">
<HintPath>..\GameBinaries\VRage.Render.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRage.Render11">
<HintPath>..\GameBinaries\VRage.Render11.dll</HintPath>
<Private>False</Private>
</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="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\" />
</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>
<Resource Include="torchicon.ico" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)"
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -1,92 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Windows;
using Sandbox;
using Sandbox.Engine.Multiplayer;
using Sandbox.Engine.Networking;
using Sandbox.Engine.Platform;
using Sandbox.Game;
using SpaceEngineers.Game;
using VRage.Steam;
using Torch.API;
using Torch.API.Managers;
using Torch.API.Session;
using Torch.Client.Manager;
using Torch.Client.UI;
using Torch.Session;
using VRage;
using VRage.FileSystem;
using VRage.GameServices;
using VRageRender;
using VRageRender.ExternalApp;
namespace Torch.Client
{
public class TorchClient : TorchBase, ITorchClient
{
protected override uint SteamAppId => 244850;
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);
sessionManager.AddFactory((x) => MyMultiplayer.Static is MyMultiplayerClientBase
? new MultiplayerManagerClient(this)
: null);
}
public override void Init()
{
Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias);
MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries);
Log.Info("Initializing Torch Client");
Config.InstancePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
SteamAppName);
base.Init();
OverrideMenus();
SetRenderWindowTitle($"Space Engineers v{GameVersion} with Torch v{TorchVersion}");
}
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"),
}
};
MyPerGameSettings.Credits.Departments.Insert(0, credits);
MyPerGameSettings.GUI.MainMenu = typeof(TorchMainMenuScreen);
}
private void SetRenderWindowTitle(string title)
{
MyRenderThread renderThread = MySandboxGame.Static?.GameRenderComponent?.RenderThread;
if (renderThread == null)
return;
FieldInfo renderWindowField = typeof(MyRenderThread).GetField("m_renderWindow",
BindingFlags.Instance | BindingFlags.NonPublic);
if (renderWindowField == null)
return;
var window =
renderWindowField.GetValue(MySandboxGame.Static.GameRenderComponent.RenderThread) as
System.Windows.Forms.Form;
if (window != null)
renderThread.Invoke(() => { window.Text = title; });
}
public override void Restart()
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Torch.Client
{
public class TorchClientConfig : ITorchConfig
{
// How do we want to handle client side config? It's radically different than the server.
public bool GetPluginUpdates { get; set; } = false;
public bool GetTorchUpdates { get; set; } = false;
public string InstanceName { get; set; } = "TorchClient";
public string InstancePath { get; set; }
public bool NoUpdate { get; set; } = true;
public List<string> Plugins { get; set; }
public bool ShouldUpdatePlugins { get; } = false;
public bool ShouldUpdateTorch { get; } = false;
public int TickTimeout { get; set; }
public bool Autostart { get; set; } = false;
public bool ForceUpdate { get; set; } = false;
public bool NoGui { get; set; } = false;
public bool RestartOnCrash { get; set; } = false;
public string WaitForPID { get; set; } = null;
public bool Save(string path = null)
{
return true;
}
}
}

View File

@@ -1,63 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Sandbox.Graphics;
using Sandbox.Graphics.GUI;
using Sandbox.Gui;
using VRage.Utils;
using VRageMath;
namespace Torch.Client
{
public class TorchConsoleScreen : MyGuiScreenBase
{
private MyGuiControlTextbox _textBox;
public override string GetFriendlyName()
{
return "Torch Console";
}
public TorchConsoleScreen() : base(isTopMostScreen: true)
{
BackgroundColor = new Vector4(0, 0, 0, 0.5f);
Size = new Vector2(0.5f);
RecreateControls(true);
}
public sealed override void RecreateControls(bool constructor)
{
Elements.Clear();
Elements.Add(new MyGuiControlLabel
{
Text = "Torch Console",
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
Position = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP)
});
Controls.Clear();
_textBox = new MyGuiControlTextbox
{
BorderEnabled = false,
Enabled = true,
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
Position = new Vector2(-0.5f)
};
Controls.Add(_textBox);
var pistonBtn = new MyGuiControlImageButton
{
Name = "TorchButton",
Text = "Torch",
HighlightType = MyGuiControlHighlightType.WHEN_CURSOR_OVER,
Visible = true,
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
};
Controls.Add(pistonBtn);
}
}
}

View File

@@ -1,38 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Graphics;
using Sandbox.Graphics.GUI;
using VRage.Utils;
using VRageMath;
namespace Torch.Client
{
public class TorchSettingsScreen : MyGuiScreenBase
{
public override string GetFriendlyName() => "Torch Settings";
public TorchSettingsScreen() : base(new Vector2(0.5f), null, Vector2.One, true)
{
RecreateControls(true);
}
public sealed override void RecreateControls(bool constructor)
{
base.RecreateControls(constructor);
AddCaption(MyStringId.GetOrCompute("Torch Settings"), null, new Vector2(0, 0), 1.2f);
var pluginList = new MyGuiControlListbox
{
VisibleRowsCount = 10,
};
foreach (var plugin in TorchBase.Instance.Plugins)
{
pluginList.Items.Add(new MyGuiControlListbox.Item(new StringBuilder(plugin.Name)));
}
Controls.Add(pluginList);
}
}
}

View File

@@ -1,56 +0,0 @@
#pragma warning disable 618
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Engine.Networking;
using Sandbox.Engine.Utils;
using Sandbox.Game;
using Sandbox.Game.Gui;
using Sandbox.Graphics;
using Sandbox.Graphics.GUI;
using Sandbox.Gui;
using SpaceEngineers.Game.GUI;
using Torch.Utils;
using VRage.Game;
using VRage.Utils;
using VRageMath;
namespace Torch.Client.UI
{
public class TorchMainMenuScreen : MyGuiScreenMainMenu
{
#pragma warning disable 169
[ReflectedGetter(Name = "m_elementGroup")]
private static Func<MyGuiScreenMainMenu, MyGuiControlElementGroup> _elementsGroup;
#pragma warning restore 169
public TorchMainMenuScreen() : this(false)
{
}
public TorchMainMenuScreen(bool pauseGame)
: base(pauseGame)
{
}
/// <inheritdoc />
public override void RecreateControls(bool constructor)
{
base.RecreateControls(constructor);
Vector2 minSizeGui = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;
Vector2 value = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, 54, 54) + new Vector2(minSizeGui.X / 2f, 0f) + new Vector2(15f, 0f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
MyGuiControlButton myGuiControlButton = MakeButton(value - 9 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
MyStringId.GetOrCompute("Torch"), TorchButtonClicked, MyCommonTexts.ToolTipExitToWindows);
Controls.Add(myGuiControlButton);
_elementsGroup.Invoke(this).Add(myGuiControlButton);
}
private void TorchButtonClicked(MyGuiControlButton obj)
{
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen<TorchNavScreen>());
}
}
}

View File

@@ -1,49 +0,0 @@
using Sandbox;
using Sandbox.Game.Gui;
using Sandbox.Graphics.GUI;
using VRage;
using VRage.Game;
using VRage.Utils;
using VRageMath;
namespace Torch.Client.UI
{
public class TorchNavScreen : MyGuiScreenBase
{
private MyGuiControlElementGroup _elementGroup;
public TorchNavScreen() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.35875f, 0.558333337f))
{
EnabledBackgroundFade = true;
RecreateControls(true);
}
public override void RecreateControls(bool constructor)
{
base.RecreateControls(constructor);
_elementGroup = new MyGuiControlElementGroup();
_elementGroup.HighlightChanged += ElementGroupHighlightChanged;
AddCaption(MyCommonTexts.ScreenCaptionOptions, null, null);
var value = new Vector2(0f, -m_size.Value.Y / 2f + 0.146f);
var num = 0;
var myGuiControlButton = new MyGuiControlButton(value + num++ * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenOptionsButtonGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, delegate(MyGuiControlButton sender)
{
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen<TorchSettingsScreen>());
}, GuiSounds.MouseClick, 1f, null);
Controls.Add(myGuiControlButton);
_elementGroup.Add(myGuiControlButton);
CloseButtonEnabled = true;
}
private void ElementGroupHighlightChanged(MyGuiControlElementGroup obj)
{
foreach (MyGuiControlBase current in _elementGroup)
if (current.HasFocus && obj.SelectedElement != current)
FocusedControl = obj.SelectedElement;
}
public override string GetFriendlyName() => "Torch";
public void OnBackClick(MyGuiControlButton sender) => CloseScreen();
}
}

View File

@@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Graphics.GUI;
using VRageMath;
namespace Torch.Client.UI
{
public class TorchSettingsScreen : MyGuiScreenBase
{
public TorchSettingsScreen() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR,
new Vector2(0.35875f, 0.558333337f))
{
EnabledBackgroundFade = true;
RecreateControls(true);
}
/// <inheritdoc />
public override string GetFriendlyName() => "Torch Settings";
public void OnBackClick(MyGuiControlButton sender) => CloseScreen();
}
}

View File

@@ -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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -1,26 +0,0 @@
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();
}
}
}

View File

@@ -0,0 +1,52 @@
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 (Delay <= 0)
{
MyAPIGateway.Multiplayer.JoinServer(Address);
return;
}
MyAPIGateway.Parallel.StartBackground(() =>
{
MyAPIGateway.Parallel.Sleep(Delay);
MyAPIGateway.Multiplayer.JoinServer(Address);
});
}
public override void ProcessServer()
{
}
}
}

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProtoBuf;
using ProtoBuf;
namespace Torch.Mod.Messages
{
@@ -11,41 +6,15 @@ namespace Torch.Mod.Messages
[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,
}
}

View File

@@ -1,142 +1,50 @@
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.Components;
using VRage.Game.ModAPI;
using VRage.Utils;
using Task = ParallelTasks.Task;
#if TORCH
using Torch.Utils;
using VRage.Library.Collections;
using System.Reflection;
#endif
namespace Torch.Mod
{
public static class ModCommunication
[MySessionComponentDescriptor(MyUpdateOrder.AfterSimulation)]
public class ModCommunication : MySessionComponentBase
{
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 const ulong MOD_ID = 2915950488;
private const ushort CHANNEL = 7654;
public static void Register()
public override void BeforeStart()
{
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.");
base.BeforeStart();
MyAPIGateway.Multiplayer.RegisterSecureMessageHandler(CHANNEL, MessageHandler);
}
public static void Unregister()
private void MessageHandler(ushort channel, byte[] data, ulong sender, bool fromServer)
{
MyLog.Default.WriteLineAndConsole("TORCH MOD: Unregistering mod communication.");
MyAPIGateway.Multiplayer?.UnregisterMessageHandler(NET_ID, MessageHandler);
_processing?.CompleteAdding();
_closing = true;
//_task.Wait();
if (!fromServer)
return;
var message = MyAPIGateway.Utilities.SerializeFromBinary<MessageBase>(data);
message.SenderId = sender;
if (MyAPIGateway.Multiplayer.IsServer) message.ProcessServer();
else message.ProcessClient();
}
private static void MessageHandler(byte[] bytes)
#if TORCH
[ReflectedMethodInfo(typeof(MyAPIUtilities), "VRage.Game.ModAPI.IMyUtilities.SerializeToBinary")]
private static MethodInfo _serializeMethod = null!;
private static readonly CacheList<IMyPlayer> Players = new();
private static byte[] Serialize(MessageBase message)
{
var m = _messagePool.Get();
m.CompressedData = bytes;
_processing.Add(m);
}
public static void DoProcessing()
{
while (!_closing)
{
try
{
var m = _processing.Take();
MyLog.Default.WriteLineAndConsole($"Processing message: {m.GetType().Name}");
if (m is IncomingMessage)
{
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 (MyAPIGateway.Multiplayer.IsServer)
i.ProcessServer();
else
i.ProcessClient();
}
else
{
var b = MyAPIGateway.Utilities.SerializeToBinary(m);
m.CompressedData = MyCompression.Compress(b);
MyAPIGateway.Utilities.InvokeOnGameThread(() =>
{
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: COMMUNICATION THREAD: EXIT SIGNAL RECEIVED!");
//exit signal received. Clean everything and GTFO
_processing?.Dispose();
_processing = null;
_messagePool?.Clean();
_messagePool = null;
_playerCache = null;
return (byte[])_serializeMethod.MakeGenericMethod(message.GetType())
.Invoke(MyAPIGateway.Utilities, new object[] { message });
}
public static void SendMessageTo(MessageBase message, ulong target)
@@ -144,12 +52,7 @@ namespace Torch.Mod
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);
MyAPIGateway.Multiplayer.SendMessageTo(CHANNEL, Serialize(message), target);
}
public static void SendMessageToClients(MessageBase message)
@@ -157,11 +60,7 @@ namespace Torch.Mod
if (!MyAPIGateway.Multiplayer.IsServer)
throw new Exception("Only server can send targeted messages");
if (_closing)
return;
message.TargetType = MessageTarget.AllClients;
_processing.Add(message);
MyAPIGateway.Multiplayer.SendMessageToOthers(CHANNEL, Serialize(message));
}
public static void SendMessageExcept(MessageBase message, params ulong[] ignoredUsers)
@@ -169,21 +68,20 @@ namespace Torch.Mod
if (!MyAPIGateway.Multiplayer.IsServer)
throw new Exception("Only server can send targeted messages");
if (_closing)
return;
using var players = Players;
MyAPIGateway.Multiplayer.Players.GetPlayers(players, player => !ignoredUsers.Contains(player.SteamUserId));
message.TargetType = MessageTarget.AllExcept;
message.Ignore = ignoredUsers;
_processing.Add(message);
var data = Serialize(message);
foreach (var player in players)
{
MyAPIGateway.Multiplayer.SendMessageTo(CHANNEL, data, player.SteamUserId);
}
}
public static void SendMessageToServer(MessageBase message)
{
if (_closing)
return;
message.TargetType = MessageTarget.Server;
_processing.Add(message);
throw new NotSupportedException();
}
#endif
}
}

View File

@@ -9,12 +9,11 @@
<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>

View File

@@ -7,7 +7,6 @@
<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" />
<PropertyGroup />
<Import Project="Torch.Mod.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

View File

@@ -1,37 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VRage.Game.Components;
namespace Torch.Mod
{
[MySessionComponentDescriptor(MyUpdateOrder.AfterSimulation)]
public class TorchModCore : MySessionComponentBase
{
public const ulong MOD_ID = 1406994352;
private static bool _init;
public override void UpdateAfterSimulation()
{
if (_init)
return;
_init = true;
ModCommunication.Register();
}
protected override void UnloadData()
{
try
{
ModCommunication.Unregister();
}
catch
{
//session unloading, don't care
}
}
}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Torch.Server.ReferenceAssemblies.net7</id>
<version>torchVersion</version>
<title>Torch Server Reference Assemblies</title>
<authors>zznty</authors>
<owners>zznty</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Torch Server Reference Assemblies (.NET 7 edition)</description>
<repository type="git" url="https://github.com/PveTeam/Torch" />
<dependencies>
<group targetFramework="net7.0-windows7.0">
<dependency id="SpaceEngineersDedicated.ReferenceAssemblies" version="1.203.22.3" />
<dependency id="Torch.Server" version="torchVersion" />
</group>
</dependencies>
<frameworkReferences>
<group targetFramework="net7.0-windows7.0">
<frameworkReference name="Microsoft.WindowsDesktop.App.WPF" />
</group>
</frameworkReferences>
</metadata>
</package>

View File

@@ -1,17 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Torch Server Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Torch")]
[assembly: AssemblyCopyright("Copyright © Torch API 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

View File

@@ -1,102 +1,26 @@
<?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>
<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>
<OutputPath>$(SolutionDir)\bin-test\$(Platform)\$(Configuration)\</OutputPath>
</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.Server.Tests.xml</DocumentationFile>
<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.ComponentModel.DataAnnotations" />
<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="VRage.Game, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\GameBinaries\VRage.Game.dll</HintPath>
</Reference>
<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>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="xunit" Version="2.6.5" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Versioning\AssemblyVersion.cs">
<Link>Properties\AssemblyVersion.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TorchServerReflectionTest.cs" />
<Compile Include="TorchServerSessionSettingsTest.cs" />
<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>
<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>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\TransformOnBuild.targets" />
</Project>

View File

@@ -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>

File diff suppressed because it is too large Load Diff

View File

@@ -41,8 +41,9 @@ namespace Torch.Server.Commands
[Command("add", "Add a Steam ID to the whitelist.")]
public void Add(ulong steamId)
{
if (Config.Whitelist.Add(steamId))
if (!Config.Whitelist.Contains(steamId))
{
Config.Whitelist.Add(steamId);
Context.Respond($"Added {steamId} to the whitelist.");
Config.Save();
}

View File

@@ -1,54 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Media;
using NLog;
using NLog.Targets;
namespace Torch.Server
{
/// <summary>
/// NLog target that writes to a <see cref="FlowDocument"/>.
/// </summary>
[Target("flowDocument")]
public sealed class FlowDocumentTarget : TargetWithLayout
{
private FlowDocument _document = new FlowDocument { Background = new SolidColorBrush(Colors.Black) };
private readonly Paragraph _paragraph = new Paragraph();
private readonly int _maxLines = 500;
public FlowDocument Document => _document;
public FlowDocumentTarget()
{
_document.Blocks.Add(_paragraph);
}
/// <inheritdoc />
protected override void Write(LogEventInfo logEvent)
{
_document.Dispatcher.BeginInvoke(() =>
{
var message = $"{Layout.Render(logEvent)}\n";
_paragraph.Inlines.Add(new Run(message) {Foreground = LogLevelColors[logEvent.Level]});
// A massive paragraph slows the UI down
if (_paragraph.Inlines.Count > _maxLines)
_paragraph.Inlines.Remove(_paragraph.Inlines.FirstInline);
});
}
private static readonly Dictionary<LogLevel, SolidColorBrush> LogLevelColors = new Dictionary<LogLevel, SolidColorBrush>
{
[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),
};
}
}

View File

@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
</Weavers>

View 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>

View File

@@ -5,88 +5,78 @@ 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 Microsoft.Extensions.Configuration;
using NLog;
using NLog.Targets;
using Sandbox.Engine.Utils;
using SpaceEngineers.Game;
using Torch.Utils;
using VRage.FileSystem;
using VRage.Library.Exceptions;
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 const string RUNSCRIPT = @"force_install_dir ../
login anonymous
app_update 298740
quit";
private TorchConfig _config;
private const string TOOL_DIR = "tool";
private const string TOOL_ZIP = "temp.zip";
private static readonly string TOOL_EXE = "steamcmd.exe";
private const string TOOL_ARGS = "+force_install_dir \"{0}\" +login anonymous +app_update 298740 +quit";
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(Persistent<TorchConfig> torchConfig)
{
_basePath = basePath;
Instance = this;
ConfigPersistent = torchConfig;
}
public bool Initialize(string[] args)
public bool Initialize(IConfiguration configuration)
{
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
// This is what happens when Keen is bad and puts extensions into the System namespace.
if (!Enumerable.Contains(args, "-noupdate"))
RunSteamCmd();
var basePath = new FileInfo(typeof(Program).Assembly.Location).Directory.ToString();
var apiSource = Path.Combine(basePath, "DedicatedServer64", "steam_api64.dll");
var apiTarget = Path.Combine(basePath, "steam_api64.dll");
if (!File.Exists(apiTarget))
File.Copy(apiSource, apiTarget);
_config = InitConfig();
if (!_config.Parse(args))
return false;
if (configuration.GetValue("getGameUpdates", true) && !configuration.GetValue("noupdate", false))
RunSteamCmdAsync(configuration).Wait();
if (!string.IsNullOrEmpty(_config.WaitForPID))
var processPid = configuration.GetValue<int>("waitForPid");
if (processPid != 0)
{
try
{
var pid = int.Parse(_config.WaitForPID);
var waitProc = Process.GetProcessById(pid);
var waitProc = Process.GetProcessById(processPid);
Log.Info("Continuing in 5 seconds.");
Log.Warn($"Waiting for process {pid} to close");
Log.Warn($"Waiting for process {processPid} to close");
while (!waitProc.HasExited)
{
Console.Write(".");
Thread.Sleep(1000);
}
}
catch
catch (Exception e)
{
// ignored
Log.Warn(e);
}
}
@@ -94,145 +84,98 @@ quit";
return true;
}
public void Run()
public void Run(IConfiguration configuration)
{
_server = new TorchServer(_config);
var init = Task.Run(() => _server.Init()).ContinueWith(x =>
{
if (!x.IsFaulted)
return;
_server = new TorchServer(Config, ApplicationContext.Current.InstanceDirectory.FullName, ApplicationContext.Current.InstanceName, configuration);
Log.Error("Error initializing server.");
LogException(x.Exception);
});
if (!_config.NoGui)
if (ApplicationContext.Current.IsService || Config.NoGui)
{
if (_config.Autostart)
init.ContinueWith(x => _server.Start());
Log.Info("Showing UI");
Console.SetOut(TextWriter.Null);
NativeMethods.FreeConsole();
new TorchUI(_server).ShowDialog();
}
else
{
init.Wait();
_server.Init();
_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;
#if !DEBUG
if (!Config.IndependentConsole)
{
Console.SetOut(TextWriter.Null);
NativeMethods.FreeConsole();
}
#endif
_server.Init();
var uiThread = new Thread(() =>
{
var ui = new TorchUI(_server);
SynchronizationContext.SetSynchronizationContext(
new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
ui.ShowDialog();
});
uiThread.SetApartmentState(ApartmentState.STA);
uiThread.Start();
if (Config.Autostart || Config.TempAutostart)
{
Config.TempAutostart = false;
_server.Start();
}
uiThread.Join();
}
}
public static void RunSteamCmd()
public static async Task RunSteamCmdAsync(IConfiguration configuration)
{
var log = LogManager.GetLogger("SteamCMD");
var path = configuration.GetValue<string>("steamToolPath") ?? ApplicationContext.Current.TorchDirectory
.CreateSubdirectory(TOOL_DIR).FullName;
if (!Directory.Exists(STEAMCMD_DIR))
if (!Directory.Exists(path))
{
Directory.CreateDirectory(STEAMCMD_DIR);
Directory.CreateDirectory(path);
}
if (!File.Exists(RUNSCRIPT_PATH))
File.WriteAllText(RUNSCRIPT_PATH, RUNSCRIPT);
if (!File.Exists(STEAMCMD_PATH))
var toolExe = Path.Combine(path, TOOL_EXE);
if (!File.Exists(toolExe))
{
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())
await using (var file = File.Create(TOOL_ZIP))
await using (var stream = await client.GetStreamAsync("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"))
await stream.CopyToAsync(file);
ZipFile.ExtractToDirectory(STEAMCMD_ZIP, STEAMCMD_DIR);
File.Delete(STEAMCMD_ZIP);
ZipFile.ExtractToDirectory(TOOL_ZIP, path);
File.Delete(TOOL_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(toolExe)
{
WorkingDirectory = Path.Combine(Directory.GetCurrentDirectory(), STEAMCMD_DIR),
UseShellExecute = false,
RedirectStandardOutput = true,
StandardOutputEncoding = Encoding.ASCII
Arguments = string.Format(TOOL_ARGS, configuration.GetValue("gamePath", "../")),
WorkingDirectory = path,
RedirectStandardOutput = true
};
var cmd = Process.Start(steamCmdProc);
// ReSharper disable once PossibleNullReferenceException
var cmd = Process.Start(steamCmdProc)!;
while (!cmd.HasExited)
{
log.Info(cmd.StandardOutput.ReadLine());
Thread.Sleep(100);
if (await cmd.StandardOutput.ReadLineAsync() is { } line)
log.Info(line);
}
}
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);
if (ex is AggregateException ag)
foreach (Exception e in ag.InnerExceptions)
LogException(e);
}
private void HandleException(object sender, UnhandledExceptionEventArgs e)
{
var ex = (Exception)e.ExceptionObject;
LogException(ex);
if (MyFakes.ENABLE_MINIDUMP_SENDING)
{
string path = Path.Combine(MyFileSystem.UserDataPath, "Minidump.dmp");
Log.Info($"Generating minidump at {path}");
MyMiniDump.Options options = MyMiniDump.Options.WithProcessThreadData | MyMiniDump.Options.WithThreadInfo;
MyMiniDump.Write(path, options, MyMiniDump.ExceptionInfo.Present);
}
LogManager.Flush();
if (_config.RestartOnCrash)
{
Console.WriteLine("Restarting in 5 seconds.");
Thread.Sleep(5000);
var exe = typeof(Program).Assembly.Location;
_config.WaitForPID = Process.GetCurrentProcess().Id.ToString();
Process.Start(exe, _config.ToString());
}
else
{
MessageBox.Show("Torch encountered a fatal error and needs to close. Please check the logs for details.");
}
Process.GetCurrentProcess().Kill();
}
}
}
}

View File

@@ -0,0 +1,56 @@
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 const int MAX_LINES = 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]));
if (LogEntries is not {Count: > MAX_LINES}) return;
for (var i = 0; LogEntries.Count > MAX_LINES; i++)
{
LogEntries.RemoveAt(i);
}
}
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;
}
}
}

View File

@@ -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)
{

View File

@@ -1,46 +1,95 @@
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;
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.ObjectBuilders.Private;
using VRage.Plugins;
namespace Torch.Server.Managers
{
public class InstanceManager : Manager
public class InstanceManager : Manager, IInstanceManager
{
private const string CONFIG_NAME = "SpaceEngineers-Dedicated.cfg";
private Action<ConfigDedicatedViewModel> _instanceLoaded;
/// <summary>
/// Gets or sets the instance loaded event.
/// </summary>
/// <remarks>
/// Called when the instance is loaded and immediately if subscribed after the instance is loaded.
/// </remarks>
public event Action<ConfigDedicatedViewModel> InstanceLoaded
{
add
{
var action = _instanceLoaded;
Action<ConfigDedicatedViewModel> action2;
do
{
action2 = action;
var action3 = (Action<ConfigDedicatedViewModel>)Delegate.Combine(action2, value);
action = Interlocked.CompareExchange(ref _instanceLoaded, action3, action2);
}
while (action != action2);
if (DedicatedConfig is not null)
value(DedicatedConfig);
}
remove
{
var action = _instanceLoaded;
Action<ConfigDedicatedViewModel> action2;
do
{
action2 = action;
var action3 = (Action<ConfigDedicatedViewModel>)Delegate.Remove(action2, value);
action = Interlocked.CompareExchange(ref _instanceLoaded, action3, action2);
}
while (action != action2);
}
}
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}");
@@ -53,24 +102,36 @@ 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);
DedicatedConfig = new ConfigDedicatedViewModel((MyConfigDedicated<MyObjectBuilder_SessionSettings>) MySandboxGame.ConfigDedicated);
var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));
var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.InstancePath, "Saves"));
foreach (var f in worldFolders)
{
if (!string.IsNullOrEmpty(f) && File.Exists(Path.Combine(f, "Sandbox.sbc")))
DedicatedConfig.Worlds.Add(new WorldViewModel(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(ex, "Failed to load world at path: " + f);
}
}
if (DedicatedConfig.Worlds.Count == 0)
@@ -81,20 +142,54 @@ namespace Torch.Server.Managers
SelectWorld(DedicatedConfig.LoadWorld ?? DedicatedConfig.Worlds.First().WorldPath, false);
InstanceLoaded?.Invoke(DedicatedConfig);
_instanceLoaded?.Invoke(DedicatedConfig);
}
public void SelectCreatedWorld(string worldPath)
{
WorldViewModel worldViewModel;
try
{
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;
DedicatedConfig.SelectedWorld = DedicatedConfig.Worlds.FirstOrDefault(x => x.WorldPath == worldPath);
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(ex, "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.Checkpoint.Mods.RemoveAll(m => m.PublishedFileId == TorchModCore.MOD_ID);
foreach (var m in DedicatedConfig.SelectedWorld.Checkpoint.Mods)
DedicatedConfig.Mods.Add(m.PublishedFileId);
DedicatedConfig.SelectedWorld.WorldConfiguration.Mods.RemoveAll(m => m.PublishedFileId == ModCommunication.MOD_ID);
foreach (var m in DedicatedConfig.SelectedWorld.WorldConfiguration.Mods)
DedicatedConfig.Mods.Add(new ModItemInfo(m));
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
}
}
@@ -106,9 +201,10 @@ namespace Torch.Server.Managers
{
DedicatedConfig.Mods.Clear();
//remove the Torch mod to avoid running multiple copies of it
DedicatedConfig.SelectedWorld.Checkpoint.Mods.RemoveAll(m => m.PublishedFileId == TorchModCore.MOD_ID);
foreach (var m in DedicatedConfig.SelectedWorld.Checkpoint.Mods)
DedicatedConfig.Mods.Add(m.PublishedFileId);
DedicatedConfig.SelectedWorld.WorldConfiguration.Mods.RemoveAll(m => m.PublishedFileId == ModCommunication.MOD_ID);
foreach (var m in DedicatedConfig.SelectedWorld.WorldConfiguration.Mods)
DedicatedConfig.Mods.Add(new ModItemInfo(m));
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
}
}
@@ -119,17 +215,16 @@ namespace Torch.Server.Managers
private void ImportWorldConfig(WorldViewModel world, bool modsOnly = true)
{
var sb = new StringBuilder();
foreach (var mod in world.Checkpoint.Mods)
sb.AppendLine(mod.PublishedFileId.ToString());
DedicatedConfig.Mods = world.Checkpoint.Mods.Select(x => x.PublishedFileId).ToList();
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.Checkpoint.Settings;
DedicatedConfig.SessionSettings = world.WorldConfiguration.Settings;
}
private void ImportWorldConfig(bool modsOnly = true)
@@ -151,7 +246,10 @@ namespace Torch.Server.Managers
return;
}
DedicatedConfig.Mods = checkpoint.Mods.Select(x => x.PublishedFileId).ToList();
var mods = new MtObservableList<ModItemInfo>();
foreach (var mod in checkpoint.Mods)
mods.Add(new ModItemInfo(mod));
DedicatedConfig.Mods = mods;
Log.Debug("Loaded mod list from world");
@@ -167,44 +265,40 @@ namespace Torch.Server.Managers
public void SaveConfig()
{
var cf = Torch.Config as TorchConfig;
if (cf?.ReservedPlayers?.Count > 0)
if (!((TorchServer)Torch).HasRun)
{
foreach (var res in cf.ReservedPlayers)
{
if (!DedicatedConfig.Reserved.Contains(res))
DedicatedConfig.Reserved.Add(res);
}
DedicatedConfig.Save(Path.Combine(Torch.InstancePath, CONFIG_NAME));
Log.Info("Saved dedicated config.");
}
DedicatedConfig.Save(Path.Combine(Torch.Config.InstancePath, CONFIG_NAME));
Log.Info("Saved dedicated config.");
try
{
var sandboxPath = Path.Combine(DedicatedConfig.LoadWorld, "Sandbox.sbc");
MyObjectBuilderSerializer.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
if (checkpoint == null)
var world = DedicatedConfig.SelectedWorld;
world.Checkpoint.SessionName = string.IsNullOrEmpty(world.Checkpoint.SessionName)
? Path.GetDirectoryName(DedicatedConfig.LoadWorld)
: world.Checkpoint.SessionName;
world.WorldConfiguration.Settings = DedicatedConfig.SessionSettings;
world.WorldConfiguration.Mods.Clear();
foreach (var mod in DedicatedConfig.Mods)
{
Log.Error($"Failed to load {DedicatedConfig.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {Torch.Config.InstancePath})");
return;
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());
checkpoint.SessionName = DedicatedConfig.WorldName;
checkpoint.Settings = DedicatedConfig.SessionSettings;
checkpoint.Mods.Clear();
foreach (var modId in DedicatedConfig.Mods)
checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId));
world.SaveSandbox();
MyObjectBuilderSerializer.SerializeXML(sandboxPath, false, checkpoint);
//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);
}
}
@@ -215,7 +309,7 @@ namespace Torch.Server.Managers
private void ValidateInstance(string path)
{
Directory.CreateDirectory(Path.Combine(path, "Saves"));
Directory.CreateDirectory(Path.Combine(path, "Mods"));
// Directory.CreateDirectory(Path.Combine(path, "Mods"));
var configPath = Path.Combine(path, CONFIG_NAME);
if (File.Exists(configPath))
return;
@@ -225,43 +319,81 @@ namespace Torch.Server.Managers
}
}
public class WorldViewModel : ViewModel
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;
public CheckpointViewModel Checkpoint { get; private set; }
private string _worldConfigPath;
private CheckpointViewModel _checkpoint;
public WorldViewModel(string worldPath)
public CheckpointViewModel Checkpoint
{
WorldPath = worldPath;
WorldSizeKB = new DirectoryInfo(worldPath).GetFiles().Sum(x => x.Length) / 1024;
_checkpointPath = Path.Combine(WorldPath, "Sandbox.sbc");
FolderName = Path.GetFileName(worldPath);
BeginLoadCheckpoint();
get
{
if (_checkpoint is null) LoadSandbox();
return _checkpoint;
}
private set => _checkpoint = value;
}
public async Task SaveCheckpointAsync()
public WorldConfigurationViewModel WorldConfiguration { get; private set; }
public WorldViewModel(string worldPath, bool loadFiles = true)
{
await Task.Run(() =>
try
{
using (var f = File.Open(_checkpointPath, FileMode.Create))
MyObjectBuilderSerializer.SerializeXML(f, Checkpoint);
});
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");
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
}
}
private void BeginLoadCheckpoint()
public void SaveSandbox()
{
//Task.Run(() =>
using (var f = File.Open(_checkpointPath, FileMode.Create))
MyObjectBuilderSerializerKeen.SerializeXML(f, Checkpoint);
using (var f = File.Open(_worldConfigPath, FileMode.Create))
MyObjectBuilderSerializerKeen.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))
{
Log.Info($"Preloading checkpoint {_checkpointPath}");
MyObjectBuilderSerializer.DeserializeXML(_checkpointPath, out MyObjectBuilder_Checkpoint checkpoint);
Checkpoint = new CheckpointViewModel(checkpoint);
OnPropertyChanged(nameof(Checkpoint));
}//);
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;
}
}
}
}

View File

@@ -10,8 +10,8 @@ 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;
@@ -62,6 +62,36 @@ namespace Torch.Server.Managers
});
}
/// <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);
@@ -81,23 +111,43 @@ namespace Torch.Server.Managers
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/>
@@ -107,19 +157,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;
@@ -134,6 +192,9 @@ namespace Torch.Server.Managers
[ReflectedStaticMethod(Type = typeof(MyGameService), Name = "GetServerAccountType")]
private static Func<ulong, MyGameServiceAccountType> _getServerAccountType;
[ReflectedMethod(Name = "ClientIsProfiling")]
private static Func<MyDedicatedServerBase, ulong, bool> _Profiling;
[ReflectedMethod(Name = "UserAccepted")]
private static Action<MyDedicatedServerBase, ulong> _userAcceptedImpl;
@@ -168,10 +229,10 @@ namespace Torch.Server.Managers
}
//Largely copied from SE
private void ValidateAuthTicketResponse(ulong steamId, JoinResult response, ulong steamOwner)
{
private void ValidateAuthTicketResponse(ulong steamId, JoinResult response, ulong steamOwner, string serviceName)
{
var state = new MyP2PSessionState();
MySteamService.Static.Peer2Peer.GetSessionState(steamId, ref state);
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);
@@ -179,8 +240,13 @@ namespace Torch.Server.Managers
_log.Debug($"ValidateAuthTicketResponse(user={steamId}, response={response}, owner={steamOwner}, permissions={promoteLevel})");
_log.Info($"Connection attempt by {steamId} from {ip}");
if (Torch.CurrentSession.KeenSession.OnlineMode == MyOnlineModeEnum.OFFLINE &&
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.");
@@ -254,6 +320,11 @@ 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;
@@ -298,4 +369,4 @@ namespace Torch.Server.Managers
#endregion
}
}
}

View 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.RemoteApiIP, MySandboxGame.ConfigDedicated.RemoteApiPort, MySandboxGame.ConfigDedicated.RemoteSecurityKey);
LogManager.GetCurrentClassLogger().Info($"Remote API started on port {myRemoteServer.Port}");
}
}
}
}

View File

@@ -0,0 +1,46 @@
using System.Reflection;
using NLog;
using Sandbox.Engine.Networking;
using Torch.API.Managers;
using Torch.Managers.PatchManager;
using Torch.Server;
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
if (!((TorchServer)TorchBase.Instance).HasRun)
return true;
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;
}
world.KeenCheckpoint.Settings = world.WorldConfiguration.Settings;
world.KeenCheckpoint.Mods = world.WorldConfiguration.Mods;
__result = world.Checkpoint;
return false;
}
}

View 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();
}
}
}

View 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;
}
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using NLog;
using Steamworks;
using Torch.Managers.PatchManager;
using Torch.Utils;
namespace Torch.Patches;
[PatchShim]
public static class SteamLoginPatch
{
private static readonly ILogger Log = LogManager.GetCurrentClassLogger();
[ReflectedMethodInfo(null, "LogOnAnonymous", TypeName = "VRage.Steam.MySteamGameServer, VRage.Steam")]
private static MethodInfo LoginMethod = null!;
public static void Patch(PatchContext context)
{
context.GetPattern(LoginMethod).AddPrefix();
}
private static bool Prefix()
{
#pragma warning disable CS0618
var token = TorchBase.Instance.Config.LoginToken;
#pragma warning restore CS0618
if (string.IsNullOrEmpty(token))
return true;
Log.Info("Logging in to Steam with GSLT");
SteamGameServer.LogOn(token);
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More