xEvilReeperx Posted November 10, 2015 Share Posted November 10, 2015 Still working great in 1.0.5, just needed a couple small additions and some changes to existing values to get the patcher working againMoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\u0003", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\u0004", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\u0005", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\u0006", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\a", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\b", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\t", 8, "Start");MoveInitializerIntoAwake(asm, "FlightIntegrator", "sunLayerMask", 24, "Start");MoveInitializerIntoAwake(asm, "GameSettings", "INPUT_DEVICES", 2, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u0019", 8, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u001A", 8, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u001B", 8, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u001C", 8, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u001D", 8, "Awake");MoveInitializerIntoAwake(asm, "MapView", "\r", 8, "Start");MoveInitializerIntoAwake(asm, "ModuleAblator", "\b\b", 8, "Start");MoveInitializerIntoAwake(asm, "PhysicsGlobals", "\u001d\u0002", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_MaterialQuadRelative", "\u001e\u0002", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_MaterialQuadRelative", "\u001f\u0002", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_MaterialQuadRelative", " \u0002", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_OceanFX", "\n\u0003", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_OceanFX", "\v\u0003", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_OceanFX", "\f\u0003", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_OceanFX", "\r\u0003", 8, "Awake");MoveInitializerIntoAwake(asm, "SkySphereControl", "\u0002", 8, "Start");MoveInitializerIntoAwake(asm, "SkySphereControl", "\u0003", 8, "Start");MoveInitializerIntoAwake(asm, "SkySphereControl", "\u0004", 8, "Start");MoveInitializerIntoAwake(asm, "SunShaderController", "\b", 8, "Start");MoveInitializerIntoAwake(asm, "SunShaderController", "\t", 8, "Start");MoveInitializerIntoAwake(asm, "SunShaderController", "\n", 8, "Start");MoveInitializerIntoAwake(asm, "SunShaderController", "\v", 8, "Start");MoveInitializerIntoAwake(asm, "UnderwaterTint", "colorID", 8, "Awake"); Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted November 12, 2015 Share Posted November 12, 2015 Still working great in 1.0.5, just needed a couple small additions and some changes to existing values to get the patcher working againMoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\u0003", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\u0004", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\u0005", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\u0006", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\a", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\b", 8, "Start");MoveInitializerIntoAwake(asm, "AtmosphereFromGround", "\t", 8, "Start");MoveInitializerIntoAwake(asm, "FlightIntegrator", "sunLayerMask", 24, "Start");MoveInitializerIntoAwake(asm, "GameSettings", "INPUT_DEVICES", 2, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u0019", 8, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u001A", 8, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u001B", 8, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u001C", 8, "Awake");MoveInitializerIntoAwake(asm, "HighLogic", "\u001D", 8, "Awake");MoveInitializerIntoAwake(asm, "MapView", "\r", 8, "Start");MoveInitializerIntoAwake(asm, "ModuleAblator", "\b\b", 8, "Start");MoveInitializerIntoAwake(asm, "PhysicsGlobals", "\u001d\u0002", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_MaterialQuadRelative", "\u001e\u0002", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_MaterialQuadRelative", "\u001f\u0002", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_MaterialQuadRelative", " \u0002", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_OceanFX", "\n\u0003", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_OceanFX", "\v\u0003", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_OceanFX", "\f\u0003", 8, "Awake");MoveInitializerIntoAwake(asm, "PQSMod_OceanFX", "\r\u0003", 8, "Awake");MoveInitializerIntoAwake(asm, "SkySphereControl", "\u0002", 8, "Start");MoveInitializerIntoAwake(asm, "SkySphereControl", "\u0003", 8, "Start");MoveInitializerIntoAwake(asm, "SkySphereControl", "\u0004", 8, "Start");MoveInitializerIntoAwake(asm, "SunShaderController", "\b", 8, "Start");MoveInitializerIntoAwake(asm, "SunShaderController", "\t", 8, "Start");MoveInitializerIntoAwake(asm, "SunShaderController", "\n", 8, "Start");MoveInitializerIntoAwake(asm, "SunShaderController", "\v", 8, "Start");MoveInitializerIntoAwake(asm, "UnderwaterTint", "colorID", 8, "Awake");I'm obviously doing something wrong.. I've re-compiled the patcher using above. When I try to run it it hangs.... nothing...Yes - using .NET3.5 running it in the managed folder, etc. Quote Link to comment Share on other sites More sharing options...
xEvilReeperx Posted November 12, 2015 Share Posted November 12, 2015 It's only hung on me if Mono.Cecil wasn't present. Here's my copy Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted November 12, 2015 Share Posted November 12, 2015 It's only hung on me if Mono.Cecil wasn't present. Here's my copyThanks, I figured out the problem. It was my virus checker. Quote Link to comment Share on other sites More sharing options...
Kobymaru Posted November 23, 2015 Share Posted November 23, 2015 Hey guys, I have followed the instructions and I managed to get my KSP into Devmode, patched the Mono.cecil, created an MDB file for my mod. However, when I start up KSP and Visual Studio 2015, I can not attach to the running Unity process. In VS2015 Debug->Attach Unity Debugger shows no Unity processes running. I can check with [CODE]netstat /b /a[/CODE], and indeed it shows that the KSP.exe process has a port in the "correct" range open (around 55000). But even if I add 127.0.0.1:<port> manually in the VS2015 dialog, the only thing that happens is that the mouse pointer turns into the waiting circle and then back to normal again. I don't really know where to look for errors here... Does anyone have Ideas how to fix that? ps.: What do the numbers in "PlayerConnectionConfigFile" mean? I have such a file in <KSP>/Launcher_Data, but the number is 792067676 instead of 803286173, like in the OP. Quote Link to comment Share on other sites More sharing options...
xEvilReeperx Posted November 23, 2015 Share Posted November 23, 2015 [quote name='Kobymaru']Hey guys, I have followed the instructions and I managed to get my KSP into Devmode, patched the Mono.cecil, created an MDB file for my mod. [snip] ... What do the numbers in "PlayerConnectionConfigFile" mean? I have such a file in <KSP>/Launcher_Data, but the number is 792067676 instead of 803286173, like in the OP.[/QUOTE] Did you create a PlayerConnectionConfigFile inside <KSP>/KSP_Data with the contents from the OP? Quote Link to comment Share on other sites More sharing options...
Kobymaru Posted November 24, 2015 Share Posted November 24, 2015 [quote name='xEvilReeperx']Did you create a PlayerConnectionConfigFile inside <KSP>/KSP_Data with the contents from the OP?[/QUOTE] I did not! I created it in <KSP> itself. Thanks for the hint! Aw man, this stuff is awesome :D Proper debugging for Plugins has got to be the best thing that happened to the Modding community in a while. ps.: All the info is in the thread, but I feel that the OP needs some updating. [COLOR="silver"][SIZE=1]- - - Updated - - -[/SIZE][/COLOR] Maybe sarbian can use this updated text for debugging. I added the patching step with a download to the patching tool and one note about converting PDB files that come out of Visual Studio 2015 [spoiler="New text for OP"]As we all know debugging plugin in KSP is mostly done with endless spam of Debug.Log or a bunch of custom windows we have to build. We also have [URL="http://forum.kerbalspaceprogram.com/threads/73586"]angavrilov method[/URL] but it require to recompile the whole mono and is a bit scary. So here is the result of a couple of days of experiment on my side to get a simple method working. So how do we get debugging to work for KSP ? Simply by using the tool that unity provides us. Unity as a debugging system for game that runs in development mode, which is not the case of KSP by default. So here is how to get that (Linux and OSX use read that part and I will explain the difference for you further down) [SIZE=3][B]KSP[/B][/SIZE] - First you need a [URL="http://unity3d.com/get-unity/download/archive"]Unity installation[/URL] using the exact same version as your current KSP ( For 0.90 you need Unity 4.5.5f1). That version is in the first line of the output_log.txt/Player.log. - Go to your Unity install for that version ( "C:\Program Files (x86)\Unity\Editor" most likely) and then go in the "Data\PlaybackEngines\windowsstandalonesupport\Variations\win32_development" sub-directory. Copy the "player_win.exe" file to your KSP dev install (next to KSP.exe) - Rename your KSP.exe into something else (or delete it). Rename "player_win.exe" in "KSP.exe" - In KSP_Data create a text file named "PlayerConnectionConfigFile" (no extension !) and paste that line into it (it makes the mono debugger starts its listening port): [code]listen 803286173 1 1[/code] - Launch that KSP and check that you have "Developement Build" in your lower right corner - Your KSP will hang now with some errors, because you need to patch Mono.Cecil.dll. Close it, and download the current Patcher from [URL="https://github.com/seanmcdougall/KspDevModePatcher/releases"]here[/URL]. Unpack it and place KspDevModePatcher.exe into <KSP>/KSP_Data/Managed. Run the patcher from the command line. If the patching succeeded, your KSP should start up properly. - Compile your plugin in "Debug" configuration to get the "MyPlugin.dll" [B]AND[/B] the "MyPlugin.pdb" (for VS) or the "MyPlugin.dll.mdb" (MonoDevelop or mono cmd line) . Copy them in your usual GameData dir - If you compile with VS you have to generate the mono debug information. From a command line (edit the KSP path). [B]That cmd line must be run from the same dir as the dll[/B] : [code]"C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\bin\cli.bat" "C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.0\pdb2mdb.exe" MyPlugin.dll[/code] Note that if you use Visual Studio 2015, you need a newer version of the pdb2mdb executable than is provided in the Unity 4.6.4f1 (KSP 1.0.5) installation. For that, get a recent version of Mono from [URL="http://www.mono-project.com/download/"]here [/URL]and install it somewhere. The pdb executable will be in <MonoInstallDirector>\Mono\bin . - You will get a "MyPlugin.dll.mdb" file in next to your dll. We are now ready on KSP side. To make your life easier you should add the copy of the dll, pdb and generation of the mdb in your project post build script since they need to be refreshed for each build. [SIZE=3][B]Visual Studio [/B][/SIZE] You need a version that allows plugin. So either a 201x Pro or [URL="https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx"]Visual Studio Community 2013[/URL] (it is free). You also have to install the [URL="http://unityvs.com/"]Unity VS[/URL] extension. It is free too. Get the one for your VS version and install it. Once you have that you will have a "Attach Unity Debugger" in the Debug menu. So launch KSP and use that menu to attach VS to it. You should get an orange bar at the bottom of VS and the context should switch to debugging. You now have all the usual debugging tools (breakpoint, step by step, watches)... [SIZE=3][B]MonoDevelop[/B][/SIZE] In the "Run" menu you have "Attach to Process". It opens a windows where you should have "Unity Debugger" selected on the lower part and you can select your KSP process to attach to. It should switch to the debugging context [SIZE=3][B]Profiling[/B][/SIZE] If you have a Unity Pro license you can attach the profiler to KSP. Unfortunately you can't attach the Unity 5 profiler (which is free) to a Unity 4.x process. Unless there is an other magic trick that I did not find. [SIZE=3][B]Linux and OSX[/B][/SIZE] The steps are the same. The only difference is the directory where you get the executable. If you are on Linux you will just need to copy some files, so use a VM to install Unity or ask a friend. - OSX : <Unity>/Data/PlaybackEngines/macstandalonesupport/ (here I have no idea if KSP is a universal or macosx32 binary. Try and report so I can edit) - Linux : <Unity>/Data/PlaybackEngines/linuxstandalonesupport/linux32_withgfx_development or linux64_withgfx_development. Get the LinuxPlayer file, copy it to your KSP install and rename it KSP.x86 or KSP.x86_64 depending on the directory you got it from and make sure you set it +x [SIZE=3][B]Missing Unity debugger for MonoDevelop (Custom install or Linux)[/B][/SIZE] If you installed MonoDevelop yourself you most likely do not have the Unity Debugger installed. Go in Tools->Addin Manager and install the Unity Soft Debugger addon (I did not test those steps so I would like some feedback)[/spoiler] Quote Link to comment Share on other sites More sharing options...
sarbian Posted November 24, 2015 Author Share Posted November 24, 2015 Sorry about that, I was quite sure I added a note about the VS 2015 steps in the OP and it turn out I did not. Thanks for the edits, I just used them. Quote Link to comment Share on other sites More sharing options...
rbray89 Posted December 2, 2015 Share Posted December 2, 2015 Thank you ! This helps considerably! Quote Link to comment Share on other sites More sharing options...
Unit327 Posted December 5, 2015 Share Posted December 5, 2015 (edited) Thanks for this. Does anyone know where to grab the monodevelop Unity Soft Debugger addon for linux? It doesn't show up in the list of available addons for me on monodevelop v4.0.12. I've added the alpha repo, still no joy. I found this but the download doesn't appear to work. I guess there is always the source code but there's got to be an easier way. EDIT: I was using an older version of monodevelop. I've since installed the latest version from the mono projects debian repositories, and now the "attach to process" option is available. I am going to assume that the "Utilities for use with Unity" plugin includes the soft debugger and move on for now. I run into a problem with the latest mono cecil patcher though: [KspDevModePatcher:DEBUG:9B0D4949] IL_0048: ldc.i4 27566 [KspDevModePatcher:DEBUG:9B0D4949] IL_004d: call System.String A.\u000d\u0010::\u0002(System.Int32) [KspDevModePatcher:ERROR:9B0D4949] Exception while trying to patch assembly: Sequence contains no matching element Full log here. Might clone the patcher repo and see if I can fix it. Edited December 5, 2015 by Unit327 more info Quote Link to comment Share on other sites More sharing options...
Unit327 Posted December 5, 2015 Share Posted December 5, 2015 Ok so I managed to get this working on linux (mint 16). Here's how: Install mono and monodevelop from here instead of the default repositories grab the source to the unity soft debugger run bash build-mpacks.sh (you may need to edit this script to point it to /usr/lib/monodevelop/bin/mdtool.exe) open monodevelop, addins, and install MonoDevelop.Debugger.Soft.Unity_5.9.1.mpack from the file you created in the last step. If you bug me enough I can upload it for you. Use wine (I used playonlinux) to install the unity3d editor delete KSP.x86_64 copy Unity/Editor/Data/PlaybackEngines/linuxstandalonesupport/Variations/linux64_withgfx_development/LinuxPlayer to KSP.x86_64 run the KspDevModePatcher in KSP_Data/Managed. For some reason I had to change the source code for it to use these field names. Run KSP.x86_64 Open monodevelop to your mod's solution. Run->attach to process Scroll all the way to the bottom. You will only have the gdb debugger available for most processes, but there should be one where it switches to "Unity Debugger". This is not the KSP_x86_64 process, it will be listed separately! set a breakpoint, enjoy debugging! Quote Link to comment Share on other sites More sharing options...
Youen Posted December 6, 2015 Share Posted December 6, 2015 First of all, this is just amazing work, proper debugging tools for KSP modding, at last! This will make my life so much easier, thanks a lot :-) I have an issue though, when I use the development player_win.exe, I can indeed debug my mod, but it turns out FAR (Ferram Aerospace Research) stops working. The mod loads (the icon is visible in game), but everything acts as if there was no aerodynamic model at all (no drag, no lift, as if there was no atmosphere on Kerbin anymore). If I restore the original KSP.exe, it works again (even if I keep the patched DLL). Anyone saw that issue? Any idea what is going on? Since I'm working on a mod that interacts with FAR, it would help a lot to be able to debug with FAR installed... Quote Link to comment Share on other sites More sharing options...
sarbian Posted December 7, 2015 Author Share Posted December 7, 2015 You should see some message in the log about "main thread". The game block when you access some Unity call from a static constructor or a thread. This is why we have to patch the game with the patcher. it moves some static constructor calls to other places (it may degrade perf since those were in static construction so they are only init once) FAR may do that. Quote Link to comment Share on other sites More sharing options...
Valerian Posted December 7, 2015 Share Posted December 7, 2015 Just to say that I have been using this since a long time, it helped me a lot, especially since I started doing things such as reflection and extracting data from materials/shaders. I'm thankful that you kept updating it and even created a patch to fix the assembly for it to work with recent KSP versions. Quote Link to comment Share on other sites More sharing options...
m4v Posted February 1, 2016 Share Posted February 1, 2016 (edited) On 5/12/2015 at 3:13 AM, Unit327 said: Install mono and monodevelop from here instead of the default repositories For some reason installing monodevelop from there conflicts with mono-gmcs (Ubuntu). How do you compile for .NET 3.5 without gmcs? Edited February 1, 2016 by m4v Quote Link to comment Share on other sites More sharing options...
sarbian Posted February 1, 2016 Author Share Posted February 1, 2016 (edited) 9 minutes ago, m4v said: For some reason installing monodevelop from there conflicts with mono-gmcs (Ubuntu). How do you compile for .NET 3.5 without gmcs? mcs -sdk:2 Edit : you can see a full cmd line here : https://ksp.sarbian.com/jenkins/job/SmokeScreen/52/console Edit 2 : or you can grab roslyn and use it to compile Cmd line exemple here (the /home/roslyn/csc.exe line) and binary here. That would also allow you to use C# 6 Edited February 1, 2016 by sarbian Quote Link to comment Share on other sites More sharing options...
timmers_uk Posted February 2, 2016 Share Posted February 2, 2016 FYI I was unable to run the patcher successfully on the current 1.0.5 win32 KSP, as the patcher couldn't find the ModuleAblator initializer. I recompiled having commented out the offending line, it patched the rest ok, and KSP seems to have come up successfully //MoveInitializerIntoAwake(asm, "ModuleAblator", "\b\b", 8, "Start"); Quote Link to comment Share on other sites More sharing options...
sarbian Posted February 3, 2016 Author Share Posted February 3, 2016 Are you sure you are on build 1028 of KSP ? Quote Link to comment Share on other sites More sharing options...
RockyTV Posted February 6, 2016 Share Posted February 6, 2016 (edited) On 02/02/2016 at 6:35 PM, timmers_uk said: FYI I was unable to run the patcher successfully on the current 1.0.5 win32 KSP, as the patcher couldn't find the ModuleAblator initializer. I recompiled having commented out the offending line, it patched the rest ok, and KSP seems to have come up successfully //MoveInitializerIntoAwake(asm, "ModuleAblator", "\b\b", 8, "Start"); I'm getting the same error, on win32. On 03/02/2016 at 6:42 AM, sarbian said: Are you sure you are on build 1028 of KSP ? Yes, I'm running build 1028. Edited February 6, 2016 by RockyTV Quote Link to comment Share on other sites More sharing options...
timmers_uk Posted February 8, 2016 Share Posted February 8, 2016 (edited) On 03/02/2016 at 8:42 AM, sarbian said: Are you sure you are on build 1028 of KSP ? Yep I'm on build 1028, and since commenting out that line and rebuilding (the patcher), my debugging seems to be happy enough. Edited February 8, 2016 by timmers_uk Quote Link to comment Share on other sites More sharing options...
sarbian Posted February 8, 2016 Author Share Posted February 8, 2016 I just checked and the "\b\b" is right. I don't know why it does not work for you but if you can debug then I guess it is fine. Quote Link to comment Share on other sites More sharing options...
timmers_uk Posted February 27, 2016 Share Posted February 27, 2016 On 2/8/2016 at 0:29 PM, sarbian said: I just checked and the "\b\b" is right. I don't know why it does not work for you but if you can debug then I guess it is fine. Yep np, this is all witchcraft anyway, so possibly a little unpredictability is expected Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted March 31, 2016 Share Posted March 31, 2016 Any ideas on getting this working for KSP 1.1 given Unity 5 is not Mono driven. Quote Link to comment Share on other sites More sharing options...
Padishar Posted March 31, 2016 Share Posted March 31, 2016 16 minutes ago, JPLRepo said: Any ideas on getting this working for KSP 1.1 given Unity 5 is not Mono driven. Huh? I think you'll find it is... Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted March 31, 2016 Share Posted March 31, 2016 25 minutes ago, Padishar said: Huh? I think you'll find it is... I meant is now linked to the VS environment. Mono is there... I guess has anyone tried to get this fired up for 1.1? Otherwise I'll start looking at it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.