Fractal Softworks Forum

Starsector => Mods => Topic started by: andylizi on December 15, 2021, 07:02:33 AM

Title: [0.97a] Planet Search
Post by: andylizi on December 15, 2021, 07:02:33 AM
Planet Search

(https://img.shields.io/github/downloads/andylizi/starsector-planet-search/total?style=for-the-badge) (https://github.com/andylizi/starsector-planet-search/releases) (https://img.shields.io/github/license/andylizi/starsector-planet-search?label=source&style=for-the-badge) (https://github.com/andylizi/starsector-planet-search) (https://img.shields.io/badge/version%20checker-v1.2.2-blue?style=for-the-badge) (https://fractalsoftworks.com/forum/index.php?topic=8181.0)

(https://i.imgur.com/haEb5DZ.png)

This mod adds a search box to the planet list. That's all. It works as you'd expect. No more scrolling around, muttering ABCs under your breath, no more! Why this isn't in the base game is something I'll never understand.

It's a utility mod and can be added or removed at any time.


Download: https://github.com/andylizi/starsector-planet-search/releases

Version v1.2.2 supports 0.97a and later.
Version v1.2.1 supports 0.96a and later.
Version v1.2.0 supports 0.95.1a and later.
Version v1.1.0 supports 0.9.1a and later.


There's a somewhat similar mod called Explore the Galaxy that allows you to search for ideal colony systems using various filter conditions. Check it out here. (https://fractalsoftworks.com/forum/index.php?topic=21800.0)


Changelog
v1.2.2 - Bump the game version to 0.97a. There are no code changes.
v1.2.1 - Drop support for versions below 0.96a; Relicense to MPL-2.0
v1.2.0 - Support localization via strings.json; Drop support for versions below 0.95.1a
v1.1.0 - Fix a crash related to map dragging; Add version checker support
v1.0.1 - Fix filter showing up on the planet info view
v1.0.0 - Initial release
[close]
Title: Re: [0.95a] Planet Search
Post by: Oni on December 15, 2021, 09:44:43 AM
... you are a Saint.
Title: Re: [0.95a] Planet Search
Post by: Jaghaimo on December 15, 2021, 11:07:59 AM
Another nice modification. Could you have a look at Explore the Galaxy mod and add similar functionality?

Haven't looked at the code yet, wondering how much is possible...
Title: Re: [0.95a] Planet Search
Post by: andylizi on December 15, 2021, 11:37:01 AM
Another nice modification. Could you have a look at Explore the Galaxy mod and add similar functionality?

That's an excellent idea for a mod and I would definitely try it out… if Explore the Galaxy haven't done it already. I mean, sure, a GUI is much more user-friendly and easy to use than EtG's command interface, but for the intended use case — searching for ideal colony systems, it's not like we do it that often anyway. It'd be a lot of effort to write a GUI (using reflection, no less) for something that will only be used a few times every save, I'm not sure it would be worth it.
Title: Re: [0.95a] Planet Search
Post by: Jaghaimo on December 15, 2021, 11:52:37 AM
No, Atlantic hasn't started doing it. We've been planning on merging his mod with Stelnet and building this via intel ui. Admittedly, this screen is a better place, more so that we don't have distance/direction widget in TooltipMakerAPI, nor planet view...

Edit: Read the code. While I do understand what is happening, I do not know how to even start "opening" core ui for extension the way you do it. I have a feeling there's a great opportunity here for some form of reflection lib which other modders could contribute to and/or use to wrote new creative mods (specifically UI based).
Compared to this https://github.com/razuhl/SSMSQoL yours is much subtler and finer use of reflection.

Edit 2: Do you mind if I steal some of your code? Ideally, would love to just use a lib of some sort (see above edit), but lacking that I can copy some of your classes instead. What I want to do is to replace your text field with normal button, and upon click show interaction dialog with (now easily moddable, since no reflection needed) filtering UI. On dialog close, either a new List<PlanetAPI> is generated & displayed, or a new dynamic filter is added and used for filtering.
Title: Re: [0.95a] Planet Search
Post by: LinWasTaken on December 16, 2021, 03:58:13 AM
https://preview.redd.it/mpyzb6hdxeu61.jpg?auto=webp&s=567559f5b7a8b60fa373b6ab249564cc2587fe79
Title: Re: [0.95a] Planet Search
Post by: SafariJohn on December 16, 2021, 04:21:16 AM
I would be wary of using andylizi's techniques - I think the code dances on the line of what is and isn't allowed.


Why this isn't in the base game is something I'll never understand.

Word.
Title: Re: [0.95a] Planet Search
Post by: LinWasTaken on December 16, 2021, 05:53:10 AM
I would be wary of using andylizi's techniques - I think the code dances on the line of what is and isn't allowed.
why would it not be allowed?
Title: Re: [0.95a] Planet Search
Post by: Jaghaimo on December 16, 2021, 06:12:18 AM
I would be wary of using andylizi's techniques - I think the code dances on the line of what is and isn't allowed.
why would it not be allowed?

Alex disables (some) reflection and (some) file operations. Using parts he did not (or could not) disable could be forbidden. Until he chimes in, though, it is a gray area. As such, committing to a mod that depends on these techniques could be disastrous for the mod itself (e.g. removed from the forums?).
Title: Re: [0.95a] Planet Search
Post by: LinWasTaken on December 16, 2021, 07:18:10 AM
I would be wary of using andylizi's techniques - I think the code dances on the line of what is and isn't allowed.
why would it not be allowed?

Alex disables (some) reflection and (some) file operations. Using parts he did not (or could not) disable could be forbidden. Until he chimes in, though, it is a gray area. As such, committing to a mod that depends on these techniques could be disastrous for the mod itself (e.g. removed from the forums?).
that answer just brings more questions like :
what is considered a gray area mod?
what problems would it lead too?(possibility of malware?)
Title: Re: [0.95a] Planet Search
Post by: andylizi on December 16, 2021, 12:44:50 PM
I would be wary of using andylizi's techniques - I think the code dances on the line of what is and isn't allowed.
why would it not be allowed?

Alex disables (some) reflection and (some) file operations. Using parts he did not (or could not) disable could be forbidden. Until he chimes in, though, it is a gray area. As such, committing to a mod that depends on these techniques could be disastrous for the mod itself (e.g. removed from the forums?).

Yeah, it's a bit of grey area. Regarding the use of reflection, however, I would argue that restrictions as a security precaution is not a good idea in the first place, at least not in its current form.

This is based on the idea that an incomplete and easily bypassable security measure is worst than no security measure at all. It can lure users into a false sense of safety, when the fact is that running untrusted code from the Internet is fundamentally unsafe (unless it's in an industrial grade, battle-tested sandbox, like a modern browser).

For example, the game currently forbids file IO and reflection operation using a custom ClassLoader. Even if we pretend there's no way to bypass those, a malicious attacker can still write:
Code
Runtime.getRuntime().exec("format C:");
which is not forbidden, and much more dangerous than just "file IO"!

Now this isn't to say there's no solution. The "accepted" way to sandbox against malicious code is by setting up a Security Manager (https://docs.oracle.com/javase/7/docs/technotes/guides/security/permissions.html). This is not trivial and difficult to do properly, and newer versions of Java are already planning to remove it entirely (JEP 411: Deprecate the Security Manager for Removal (https://openjdk.java.net/jeps/411)):
Quote
The threat of accidental vulnerabilities in local code is almost impossible to address with the Security Manager. Many of the claims that the Security Manager is widely used to secure local code do not stand up to scrutiny; it is used far less in production than many people assume. There are many reasons for its lack of use……

But let's assume, for the sake of the argument, that we managed to set up a flawless Security Manager or other equivalent measures. Would that mean a mod can't act maliciously anymore? Well, there's still nothing to stop a mod from deleting a player's fleet and other assets "the legit way", and then saving the game… It's pure pettiness, but impossible to guard against.






I hesitate to address this, but the use of reflection is actually not the biggest problem of this kind of technique. The problem is, to use reflection to modify the game effectively, it necessarily requires privileged knowledge of the game's internal working. One of the ways to acquire this knowledge is by reverse-engineering, which clearly violates Starsector's User License:
Quote
You agree that you will not, under any circumstances:

a. In whole or in part, copy or reproduce (except as provided herein), translate,
   reverse engineer, derive source code from, modify, disassemble, decompile, or
   create derivative works based on the Game;
(Which I definitely did not do, of course. I actually got this knowledge from a dream I had, do you know? It was a very informative dream. ;) )

(Honestly, the legal status of mods is already a bit vague in my opinion. For example,
Quote
A "Mod" is defined as a set of graphics, data, and/or sound assets that adds new
content to or otherwise modifies the Game, but does not include the Game, and
requires the Game in order to be used.
This excludes all mods that contain scripts, as executable code obviously can't be counted as "graphics, data, and/or sound assets". It was last updated in 2012, maybe there aren't scripting APIs back then?)

Regarding creating mods by reverse-engineering, different games take different stances:So in the end, what is considered acceptable depends on the game developer. It's understandable if Alex decides he doesn't want these kinds of mods in his game after all. My intention for developing this mod and the similar Dialog Minimap (https://fractalsoftworks.com/forum/index.php?topic=23199.0) is to solve the pet peeves I have while playing, and I released it on the idea that other people could have the same issues. It'd be a pity, but ultimately not a big loss.



Edit 2: Do you mind if I steal some of your code? Ideally, would love to just use a lib of some sort (see above edit), but lacking that I can copy some of your classes instead. What I want to do is to replace your text field with normal button, and upon click show interaction dialog with (now easily moddable, since no reflection needed) filtering UI. On dialog close, either a new List<PlanetAPI> is generated & displayed, or a new dynamic filter is added and used for filtering.
Sure! You're welcome to it, if you still want to after the above.  :D
Title: Re: [0.95a] Planet Search
Post by: PreConceptor on January 11, 2022, 09:12:00 PM
minor bug: when going from the Map to showing system info the search and sort from the planet list is overlayed on the system info
Title: Re: [0.95a] Planet Search
Post by: andylizi on January 12, 2022, 03:56:17 AM
minor bug: when going from the Map to showing system info the search and sort from the planet list is overlayed on the system info

Thanks for the report. It's now fixed in v1.0.1!
Title: Re: [0.95a] Planet Search
Post by: TontonBoo on January 12, 2022, 11:54:16 AM
Code
The whole of andylizi's post about modding and malicious code (a bit big to quote properly)

Very interesting read. I had no idea. I thought games were executed in a safe-ish environment of their own and could not access core system files or functions that easily. Thanks for the clarification. And thanks to Jaghaimo for the warning.
Title: Re: [0.95a] Planet Search
Post by: PreConceptor on January 12, 2022, 04:36:32 PM
Thanks for the report. It's now fixed in v1.0.1!

That was quick, thanks!
Title: Re: [0.95a] Planet Search
Post by: Alex on January 13, 2022, 10:57:30 AM
Well done, this is good stuff :)

Just wanted to make a quick reply:

Yeah, it's a bit of grey area. Regarding the use of reflection, however, I would argue that restrictions as a security precaution is not a good idea in the first place, at least not in its current form.

This is based on the idea that an incomplete and easily bypassable security measure is worst than no security measure at all. It can lure users into a false sense of safety, when the fact is that running untrusted code from the Internet is fundamentally unsafe (unless it's in an industrial grade, battle-tested sandbox, like a modern browser).

I'm acutely aware of this, and the restrictions are not a security precaution (as you say, they're incomplete and basically entirely useless as that), and aren't presented to the player as such (or at all)! They're mainly there because it's fairly likely that your average modder could write file IO code that would mess up a user's system *by accident*. Even an otherwise excellent programmer could easily make a mistake like this if they don't have a properly careful mindset when writing, say, code that handles file deletion. So this is in place there to prevent half-baked attempts and signpost "don't do this" to someone with more experience that *could* bypass it. Someone malicious could find a way around pretty much no matter what, and this isn't concerned with that at all.

If there's some functionality that I could add to the API that would make life easier, btw, that'd be the best way to go - then I can put some effort into making sure that code is "safe" and more modders could benefit from being able to use it.

Edit:
Why this isn't in the base game is something I'll never understand.

Haha! Fair, fair. (The real reason: that bit of the UI is *old* at this point.)
Title: Re: [0.95a] Planet Search
Post by: Usinaru on January 14, 2022, 12:59:39 PM
How is this not vanilla already? Thanks !!!
Title: Re: [0.95a] Planet Search
Post by: Jaghaimo on January 14, 2022, 01:56:13 PM
Quote
If there's some functionality that I could add to the API that would make life easier, btw, that'd be the best way to go - then I can put some effort into making sure that code is "safe" and more modders could benefit from being able to use it.

Being able to (officially) mod base game UI would be a game-changer (ba-dum-ts)! It could be split into being able to modify existing vanilla UI, and being able to introduce new UI components. Probably the latter first, so that then existing UI can be rewritten using this new exposed API (thus automatically becoming modable).
Title: Re: [0.95a] Planet Search
Post by: Fuegoredux on January 19, 2022, 10:28:20 PM
This is great! Save a huge amount of time looking through planets.

Two places that would benefit from a search feature is the codex and the ship simulator selection. Would these be a possibility in the future?
Title: Re: [0.95a] Planet Search
Post by: andylizi on January 19, 2022, 11:25:05 PM
Two places that would benefit from a search feature is the codex and the ship simulator selection. Would these be a possibility in the future?

Yeah, there're lots of places in the game that can benefit from a search function. Unfortunately I don't think my method is very… realistic, so to speak. If I were Alex, I could've implemented planet search the "correct" way literally within 10 minutes. But since I'm not him (last time I checked), I had had to spend days on this hacky mod chanting black magic. What's worse, it will almost certainly become obsolete (https://fractalsoftworks.com/forum/index.php?topic=23199.0) at some time in the future.

All that to say, it'd be way more realistic to just ask Alex for these features, and I'm confident they'll be added to the base game eventually. I did this mod because I wanted that time to be now, and my first instinct as a programmer whenever a piece of software annoys me is to Fix It Myself™ (and maybe send a PR afterward). It was a nice challenge by itself, but doing it for everything is a bit much…

(It'd be really nice if I could name this mod "Search Everything" though……)
Title: Re: [0.95.1a] Planet Search
Post by: chus on June 30, 2022, 12:28:02 AM
Hi,

Is it possible for you to add the ability to filter unexplored ruins? Cause sometime you will get survey data from probe/survey ship/derelict ship about a planet, and it might cause people to miss the planet if they are not careful enough...

Thank you!!
Title: Re: [0.95.1a] Planet Search
Post by: lili on July 02, 2022, 02:32:54 AM
hai nihao
youmeiyou xingqu lai yuanxingxinghao(Starsector) zhongwen luntan https://www.fossic.org/ (https://www.fossic.org/)
jintian kandao youren banyun le nide mod, suoyi bijiao haoqi
suishi huanying :)
Title: Re: [0.95.1a] Planet Search
Post by: andylizi on July 02, 2022, 02:59:53 AM
Hi,

Is it possible for you to add the ability to filter unexplored ruins? Cause sometime you will get survey data from probe/survey ship/derelict ship about a planet, and it might cause people to miss the planet if they are not careful enough...

Thank you!!

Unfortunately this feels a bit out of scope to me. If I support filtering for one specific condition, then there'd be no reason to not support every other kind of conditions, and that's a bit too much work for me. So for the sake of consistency, I'd perfer not adding it.



hai nihao
youmeiyou xingqu lai yuanxingxinghao(Starsector) zhongwen luntan https://www.fossic.org/ (https://www.fossic.org/)
jintian kandao youren banyun le nide mod, suoyi bijiao haoqi
suishi huanying :)

Thanks for bringing this to my attention. I don't really mind though. I have registered an account there before, but then decided I don't want to bother with their forum rules about publishing mods.
Title: Re: [0.95.1a] Planet Search
Post by: FreeBubbles on September 16, 2022, 11:53:07 AM
Add a filter for "market conditions" in the planets list please.
Title: Re: [0.95.1a] Planet Search
Post by: kokuto on May 13, 2023, 09:58:30 PM
Will this be updated for 0.96?
Title: Re: [0.95.1a] Planet Search
Post by: andylizi on May 14, 2023, 01:04:03 AM
Will this be updated for 0.96?

Done! Please update to the latest version ;D
Title: Re: [0.96a] Planet Search
Post by: jericho on August 30, 2023, 07:47:06 PM
I might just be dumb but how do i download this mod? I've gone to the link but then i get stuck and don't know how to move from there.
Title: Re: [0.96a] Planet Search
Post by: andylizi on August 30, 2023, 08:04:44 PM
I might just be dumb but how do i download this mod? I've gone to the link but then i get stuck and don't know how to move from there.

Ah, sorry for the confusion! You need to click and expand "Assets", then "PlanetSearch-1.2.1.zip"
Title: Re: [0.96a] Planet Search
Post by: Meeps on February 26, 2024, 04:49:35 PM
Currently doesn't seem to work in 0.97 with version swap. On load it leads crash.
Title: Re: [0.96a] Planet Search
Post by: andylizi on February 28, 2024, 12:47:30 PM
Currently doesn't seem to work in 0.97 with version swap. On load it leads crash.

I tried it just now and it seemed to work without problem. Can you provided more information regarding the crash?