Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: [1] 2

Author Topic: [0.97a] Planet Search  (Read 86537 times)

andylizi

  • Ensign
  • *
  • Posts: 11
    • View Profile
[0.97a] Planet Search
« on: December 15, 2021, 07:02:33 AM »

Planet Search




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.


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]
« Last Edit: February 28, 2024, 01:00:53 PM by andylizi »
Logged

Oni

  • Captain
  • ****
  • Posts: 383
    • View Profile
Re: [0.95a] Planet Search
« Reply #1 on: December 15, 2021, 09:44:43 AM »

... you are a Saint.
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: [0.95a] Planet Search
« Reply #2 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...
« Last Edit: December 15, 2021, 11:22:58 AM by Jaghaimo »
Logged

andylizi

  • Ensign
  • *
  • Posts: 11
    • View Profile
Re: [0.95a] Planet Search
« Reply #3 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.
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: [0.95a] Planet Search
« Reply #4 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.
« Last Edit: December 16, 2021, 02:15:13 AM by Jaghaimo »
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: [0.95a] Planet Search
« Reply #6 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.
Logged

LinWasTaken

  • Commander
  • ***
  • Posts: 189
    • View Profile
Re: [0.95a] Planet Search
« Reply #7 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?

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: [0.95a] Planet Search
« Reply #8 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?).
« Last Edit: December 16, 2021, 06:14:41 AM by Jaghaimo »
Logged

LinWasTaken

  • Commander
  • ***
  • Posts: 189
    • View Profile
Re: [0.95a] Planet Search
« Reply #9 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?)

andylizi

  • Ensign
  • *
  • Posts: 11
    • View Profile
Re: [0.95a] Planet Search
« Reply #10 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. 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):
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:
  • Minecraft, famous for its lack of an official API, publishes its obfuscation mappings "in an effort to help make modding the game easier", with the restriction that one may only use these mappings for "development purposes" and may not "redistribute the mappings complete and unmodified" or share the deobfuscated source code. Even before that, they acquiesce in the existence of MCP and Forge.
  • Don't Starve is written and distributed in unobfuscated Lua source files, so there isn't a concept of "reverse-engineering".
  • Rimworld "provides a bunch of code snippets in ../Source/, relative to your Rimworld installation. Since this isn't a lot, one might want to take a look at the game's full source code. RimWorld's EULA allows you to decompile the game for personal use. It's recommended to read it." Patching the game code is done by using a library called Harmony.
  • Factorio provides Lua APIs that can satisfy most modding needs; there's no need for reverse-engineering. No to mention is basically impossible to do so to a C++ game.
  • Kerbal Space Program similarly provides a highly complete C# API.
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 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
« Last Edit: December 16, 2021, 12:48:25 PM by andylizi »
Logged

PreConceptor

  • Commander
  • ***
  • Posts: 142
    • View Profile
Re: [0.95a] Planet Search
« Reply #11 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
Logged

andylizi

  • Ensign
  • *
  • Posts: 11
    • View Profile
Re: [0.95a] Planet Search
« Reply #12 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!
Logged

TontonBoo

  • Ensign
  • *
  • Posts: 41
    • View Profile
Re: [0.95a] Planet Search
« Reply #13 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.
Logged

PreConceptor

  • Commander
  • ***
  • Posts: 142
    • View Profile
Re: [0.95a] Planet Search
« Reply #14 on: January 12, 2022, 04:36:32 PM »

Thanks for the report. It's now fixed in v1.0.1!

That was quick, thanks!
Logged
Pages: [1] 2