Jump to content

[0.17] Fuel Transfer Mod V 0.2.2


younata

Recommended Posts

Appears this is incompatible with:

Looked at his code, and he's ...erm... modifying the stock classes directly, which I didn't think was possible, but it's causing a problem when your mod goes to check for a stock fuel/rcs tank.

The skinny:

(in FuelTransferCore)

-You're using ".GetType() == typeof(FuelTank)" which compares the runtime type of the part against the unmodified runtime type of the stock FuelTank class.

-He's modifying the runtime type of the stock parts, including the tanks.

-Result is you find no tanks, and the list for transfer is empty.

I had to exclude the MuMech roboparts for a plugin I did, and found "part.ClassName" is set to the name of the class the part uses, and is just a string; bypassing typing, and multi-plugin dependencies. So I changed your stock tank checks(3 sets?) to:

.ClassName == "FuelTank"

and

.ClassName == "RCSFuelTank"

recompiled, and it all seems to work out in game.

Here's the modified .cs file:

https://dl.dropbox.com/u/74137297/FuelTransferModule.cs

I'm running into this problem. How do I use this file?

Link to comment
Share on other sites

Appears this is incompatible with:

Looked at his code, and he's ...erm... modifying the stock classes directly, which I didn't think was possible, but it's causing a problem when your mod goes to check for a stock fuel/rcs tank.

The skinny:

(in FuelTransferCore)

-You're using ".GetType() == typeof(FuelTank)" which compares the runtime type of the part against the unmodified runtime type of the stock FuelTank class.

-He's modifying the runtime type of the stock parts, including the tanks.

-Result is you find no tanks, and the list for transfer is empty.

I had to exclude the MuMech roboparts for a plugin I did, and found "part.ClassName" is set to the name of the class the part uses, and is just a string; bypassing typing, and multi-plugin dependencies. So I changed your stock tank checks(3 sets?) to:

.ClassName == "FuelTank"

and

.ClassName == "RCSFuelTank"

recompiled, and it all seems to work out in game.

Here's the modified .cs file:

https://dl.dropbox.com/u/74137297/FuelTransferModule.cs

Can someone make this to a working .dll???

I can`t refill my tanker and rescue Jeb. *sniff*

Link to comment
Share on other sites

I sent the author a message, but haven't heard back in an hour or so, so impatience personified(me) just compiled my fix for using this with MajiirKerbalLib.

Here's the fixed version:

https://dl.dropbox.com/u/74137297/KFuelTransferFix.dll

Note: Filename has been changed to avoid crossing the streams.

Instructions: Drop this dll into your plugins folder and Move "FuelTransferMod.dll" somewhere safe. Do not use both at the same time.

When Younata comes back and fixes this, just delete "KFuelTransferFix.dll" and forget about it.

code is here again:

https://dl.dropbox.com/u/74137297/FuelTransferModule.cs

All I did was change the tank testing to use the Part.Classname string instead of runtime type comparison.

Link to comment
Share on other sites

Yes nice. Im thinking of having Kethane stations on the mun/minmus and everytime a craft has a lack of fuel the kethane from the station will replenish it(much like a mun gas station).

Can be also usefull for trips to Duna and Eve(well if u miss the mun and u cant refuel you go starvin')

Link to comment
Share on other sites

Looked at his code, and he's ...erm... modifying the stock classes directly, which I didn't think was possible

:cool:

, but it's causing a problem when your mod goes to check for a stock fuel/rcs tank.

The skinny:

(in FuelTransferCore)

-You're using ".GetType() == typeof(FuelTank)" which compares the runtime type of the part against the unmodified runtime type of the stock FuelTank class.

-He's modifying the runtime type of the stock parts, including the tanks.

-Result is you find no tanks, and the list for transfer is empty.

I have bolded the real problem. That is, simply put, the wrong way to check for type constraints in C#.

I had to exclude the MuMech roboparts for a plugin I did, and found "part.ClassName" is set to the name of the class the part uses, and is just a string; bypassing typing, and multi-plugin dependencies. So I changed your stock tank checks(3 sets?) to:

.ClassName == "FuelTank"

and

.ClassName == "RCSFuelTank"

recompiled, and it all seems to work out in game.

I applaud your timeliness and resourcefulness, but I must emphasize that this is also a wrong way to check for type constraints in C#. I have submitted a pull request on Github with the correct fix and an explanation.

By the way, if you find plugin compatibility issues, please notify both plugin authors! (I did suspect this plugin would have a compatibility issue with MajiirKerbalLib, but I didn't suspect someone would have already found it.) :)

Edited by Majiir
Link to comment
Share on other sites

:cool:

I have bolded the real problem. That is, simply put, the wrong way to check for type constraints in C#.

I applaud your timeliness and resourcefulness, but I must emphasize that this is also a wrong way to check for type constraints in C#. I have submitted a pull request on Github with the correct fix and an explanation.

By the way, if you find plugin compatibility issues, please notify both plugin authors! (I did suspect this plugin would have a compatibility issue with MajiirKerbalLib, but I didn't suspect someone would have already found it.) :)

Oh, hey. There was activity here. I was only aware of this issue when Majiir submitted his pull request to me.

Right, so I've accepted Majiir's pull request. The main plugin supports this now. It's also good to know what the c#-ian way of doing things is.

But, yeah, you can redownload 0.2.2 at http://rachelbrindle.com/ksp/FuelTransferModule.zip.

The permalink is http://rachelbrindle.com/ksp/FuelTransferModule-0.2.2.zip

Sorry for the inconvenience.

Link to comment
Share on other sites

Right, so I've accepted Majiir's pull request.

Cheers!

Sorry for the inconvenience.

Not a problem! I didn't mean to sound annoyed, by the way; I just wanted to be very clear in case someone wasn't paying close attention.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...