RemoteTechnologiesGroup / RemoteTech

Community developed continuation of Kerbal Space Program's RemoteTech mod.
http://remotetechnologiesgroup.github.io/RemoteTech
GNU General Public License v2.0
235 stars 102 forks source link

API - Accept a Guid with AddGroundStation, rather than generating one #588

Closed AlphaAsh closed 8 years ago

AlphaAsh commented 8 years ago

Regarding the API, one possible addition I'd like is a parameter for setting a Guid with AddGroundStation, that over-rides the one generated by RT.

An overloaded method would probably suffice. That'd make it a lot easier for interfacing mods to keep track of persistency their side. Especially when they have their own keys for tracking stations. (Kerbal Konstructs uses radial position converted to a string.)

Also, I've noted there's some limitations on parsing Guids in Unity's implementation of C#. It'd be very handy to be able to provide a key that isn't a Guid. Like the aforementioned example I gave. You'd have to trust up to a point that what's being passed is unique. Relying on a type that's such a restrictive bear to handle is making life hard over here :)

AlphaAsh commented 8 years ago

Thanks to my much more experienced code genius wife you can ignore my BS about Guid and parsing but it'd still be handy to pass a Guid with AddGroundStation, rather than have one generated. I married well.

d4rksh4de commented 8 years ago

If you want to use your own IDs, you can just keep a map of them. Yes, one mod may provide a unique IDs, but this is a shared resource and it doesn't guarantee that there is no conflict with IDs provided by other mods.

AlphaAsh commented 8 years ago

Yup, thanks to my better half it looks like I should be able to map Guids that RT spits out.

tomekpiotrowski commented 8 years ago

Ahh... writing KSP mods with your wife... you're livin' the dream man, never forget that :)

AlphaAsh commented 8 years ago

It's going on my grave-stone. "He modded games with his wife. He was one really lucky bastard."

AlphaAsh commented 8 years ago

I know it's a closed issue but after mucking about mapping Guids that RT spits out I realised something. "...it doesn't guarantee that there is no conflict with IDs provided by other mods" This is pretty nonsense. Doesn't matter whether I'm passing you a Guid, or you're passing me a Guid, the chances of another mod stepping on it are the same.

AlphaAsh commented 8 years ago

Also, what other mod? And who cares?

d4rksh4de commented 8 years ago

Doesn't matter whether I'm passing you a Guid, or you're passing me a Guid, the chances of another mod stepping on it are the same.

It does, nothing stops you/other mod reusing a Guid when creating a new resource. So, there is a problem, I have to deal with duplicate Guids then, check/overwrite/throw exception/etc. If I generate and manage Guids, I can guarantee that everything that goes out is unique.

Also, what other mod? And who cares?

I guess you will care if MyFancyPolarGroundStation mod uses hard-coded Guid value to add new ground station and by accident it overwrites one of your ground station's Guid and your ground station disappears.

AlphaAsh commented 8 years ago

Paranoid coding. You aren't managing bank accounts.

AlphaAsh commented 8 years ago

"I have to deal with duplicate Guids then, check/overwrite/throw exception/etc." And you already do.

d4rksh4de commented 8 years ago

Feel free to submit a PR if you feel that your solution is better than the current one.

AlphaAsh commented 8 years ago

No thank you. Feel free to take a look at my fork of RT. I'm not going to push code at you that I'm still testing and that purposefully circumvents a lot of RT's functions.