Jump to content

How to bug fix a mod?


Recommended Posts

I need to learn how to bug fix some mods as lately the quality of mods are really bad due to the constant forking and making a huge mess. So im taking that first stride to enter the fears of the DLL .  I have Visual Studio and tried to edit some lines of bad code , but it doesnt work cuz I have no way to edit the DLL, only a source folder that the modder provides. The DLL I edited outputted the same file size ,but it refused to work. I think thats why the plug in does not run is I cannot use source folders as those are tied that persons computer setup aka referencing breaks and a whole host of other issues. Im not trying to make a plugin , I just need access into the DLL to change a few lines. I think the way I was doing it was only to be used when creating a new mod. What a waste of time, but hoping there is a correct/fast solution?

Link to comment
Share on other sites

2 hours ago, lextacy said:

lately the quality of mods are really bad due to the constant forking and making a huge mess. 

That may be related to people who don't know what they are doing writing the fix. Glad to see someone is stepping up the game !

Link to comment
Share on other sites

As far as I know you cannot edit a dll directly; everything in there is in a 'compiled', 'byte-code', or 'instruction language' state, and can only really be viewed through decompilers which still does not allow you to change things around.

You will need to download the source files and setup the project -just as if you were the mod creator-.  Only then will you be able to recompile and have it output a proper working .dll file.

For -most- KSP mods this is as simple as setting up a VS project/solution (setting the .NET version properly), dropping the source into the folders, and linking to the proper Unity and KSP .dll files (many tutorials exist for doing this).  Some mods may require a more complicate setup with additional libraries to download and link up; others may even have special compile-time setups (e.g. build-scripts) that need to be used properly.  You may need to contact the mod author to get more information regarding those setups.

Link to comment
Share on other sites

What Shadowmage said.

Get the source code, open it in Visual Studio, edit the code as you like, then build it to get the "fixed" DLL.

Or even better:  if you can narrow down the problem and come up with a well-defined and reproducible use case that's definitely caused by a bug in one particular mod, post the info to the mod's forum thread.  There's a good chance the author will fix the problem promptly and post it.

Here's a recent example of this I ran into.  I found a bug in Kopernicus, reported it, got an immediate reply that a fix was checked in.

Granted, that's a mod author who's really on the ball.  But seriously, if you find a bug in a mod, report it to the author!

Edited by Snark
Link to comment
Share on other sites

Monodevelop is an alternative to Visual Studios - either can be used to create a DLL. I suspect most developers on Windows use Visual Studio (but not positive).

Edited by wasml
Link to comment
Share on other sites

14 hours ago, lextacy said:

Thanks guys your help is getting me in a good direction. Still might have a few more questions though. What about this thing called Monodevelop ? Was I suppose to use that instead?  

I have no idea about Monodevelop or how well it works.  Personally, I'd use Visual Studio, it's free and extremely professional/well-done.  I expect it's also what most mod authors use, so if you have questions, you're more likely to get answers.  Do you have some reason not to use Visual Studio?

Link to comment
Share on other sites

6 hours ago, Snark said:

I have no idea about Monodevelop or how well it works.  Personally, I'd use Visual Studio, it's free and extremely professional/well-done.  I expect it's also what most mod authors use, so if you have questions, you're more likely to get answers.  Do you have some reason not to use Visual Studio?

no no , I started out my project with VS, I took the source folder and used its .sln file to load up the project. Made my edits to the .cs files. Then hit Run to compile. Got a .dll . Said .dll did not get recognized by the game. I do like using VS though. Tried monodev and hated it. 

Link to comment
Share on other sites

Just now, lextacy said:

no no , I started out my project with VS, I took the source folder and used its .sln file to load up the project. Made my edits to the .cs files. Then hit Run to compile. Got a .dll . Said .dll did not get recognized by the game. I do like using VS though. Tried monodev and hated it. 

How do you mean, "did not get recognized"?  Did the built DLL have the same name as the original DLL?  Did you copy it to put it in the same location as the original DLL?

I've written mods with VS and the DLLs work just fine. :)

Link to comment
Share on other sites

10 hours ago, Snark said:

How do you mean, "did not get recognized"?  Did the built DLL have the same name as the original DLL?  Did you copy it to put it in the same location as the original DLL?

I've written mods with VS and the DLLs work just fine. :)

yup and yup !  The game doesnt crash or anything, just the mod wont show up in the VAB

Link to comment
Share on other sites

In that case, probably a typo somewhere means KSP doesn't recognize it.

First, goto the output_log.txt and check the load sequence. KSP lists all the .dll files it finds and loads, yours is in there correct?

Next go over your flight scene code as to why it's not working. As a first step I'd add a Debug.Log("Flight Scene Loaded"); line in the Update() method so that it will spam your log if it loads.

D.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...