Open Dunbaratu opened 11 years ago
This is tricky. As far as I know you can't debug a mod on KSP, but I could be wrong.
The way I get around this is I built a windows form project that instantiates a fake kOS CPU without a part. It works but it crashes if you try to do anything that requires unity to be present. For example you can't use R() because it makes use of Unity's quaternion class.
Nevertheless, it allows me to debug some of the most important stuff before firing it up in KSP.
Hmm. Well do you have any advice on how to discover the culprit when the KSP log is claiming there's a null reference somewhere? I'm used to operating in the Java world where there's enough symbol table information in the executable CLASS files for the default exception handler to know which line number each bit of executable code came from (so when compiled with default debug mode on, if a null pointer exception happens you get to see a filename and line number of the offending statement.)
One of my KOS scripts is causing KSP to give a null pointer exception when I run it and I am having a hard time trying to trace it down to what part of KOS's C# code is doing it. This was my primary motivation for downloading Visual Studio and the github code for this mod. I was hoping to find what exactly causes it. I suspect this null pointer exception is the reason everything starts going haywire after that and my KSP freezes, and my persistence file gets some parts of the ship deleted from it and so on.
I did de-install all mods other that KOS to prove it's not some other mod's fault.
I'm sorry for making this an "issue" but that's just because I don't know how else to ask it.
I'm a very experienced programmer. But with almost no experience at all on Windows. I come mostly from the UNIX world. I've used Java a lot, and C++ a lot, but never C#. I keep running into problems where my KOS scripts cause the mod to completely hang KSP altogether (meaning I need to kill KSP from the task manager and I need to go to an earlier save game when I re-load because it corrupted the vessel's entry in the persistence file as it got stuck). There's almost no information I can obtain to narrow down why it's hanging. It seems to be something wrong with the either the LOG function or the Volume manipulation commands like RENAME or SWITCH or COPY. I can't narrow it down because every time I attempt to simplify it down to an example that has trimmed away everything unrelated to the problem, it ends up working just fine.
So I'm ready to bite the bullet and install the whole thing, including what I need to be a modder, just so I can walk through the KOS mod's code to see what on earth is wrong and perhaps contirbute a fix in a pull request, or at the very least be able to point out where it is.
So my question is: To those of you who've done this... What pieces do I need, and are they pay-ware or free-ware, and if I pay what's the cost? I don't have a C# programming environment. I don't have the KSP modding libraries. What stuff would I need to get started on this?