Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: [0.8.1a] Bug with replacing rulecmd scripts in jar file  (Read 1639 times)

Pushover

  • Captain
  • ****
  • Posts: 292
    • View Profile
[0.8.1a] Bug with replacing rulecmd scripts in jar file
« on: May 04, 2018, 01:01:25 AM »

Not sure if this belongs in the modded support, since this seems to be a bug related to writing a mod?

I have a replacement for NGCAddStandardStartingScript.java in my (total conversion) mod's jar file, but it does not appear to get called. Instead, the base game's NGCAddStandardStartingScript is getting called.


I am trying to rebuild the sector entirely. I can successfully remove almost all the systems, but Galatia is a minor problem, since it is used by the tutorial and NGCAddStandardStartingScript (and rules.csv). When I remove Galatia from SectorGen (and economy.json), I get the following error:

Code
55054 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.rulecmd.NGCAddStandardStartingScript$1.run(NGCAddStandardStartingScript.java:89)
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.N.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.supernew.o00000(Unknown Source)
at com.fs.starfarer.ui.oooO.processInput(Unknown Source)
at com.fs.starfarer.ui.Stringsuper.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

This makes sense, since the code being run in com.fs.starfarer.api.impl.campaign.rulecmd.NGCAddStandardStartingScript.java is as follows:
Code
88					StarSystemAPI system = Global.getSector().getStarSystem("galatia");
89 PlanetAPI ancyra = (PlanetAPI) system.getEntityById("ancyra");
Since I removed Galatia, system is null, so I get a NPE.

However, inside my jar file I have a replacement to com.fs.starfarer.api.impl.campaign.rulecmd.NGCAddStartingStandardScript.java. From my understanding, anything in my jar file should replace the game's version of the file (as data.scripts.world.SectorGen.java gets replaced by my jar file). This does not appear to be the case, since in my modified version of NGCAddStartingStandardScript, line 89 is just a curly brace, and the game keeps crashing with the same error (same line).


My workaround is to create a NGCAddStartingStandardScript2.java, which is an exact copy of my version of NGCAddStartingStandardScript.java, and change my rules.csv to call this instead of NGCAddStartingStandardScript. This is working, which implies to me that NGCAddStartingStandardScript is not getting replaced by my jar file.

I can provide the source files to my mod if needed.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: [0.8.1a] Bug with replacing rulecmd scripts in jar file
« Reply #1 on: May 04, 2018, 06:12:29 AM »

Java classes in the compiled .jar (including the rulescmd scripts) can't be overridden by a mod, only the Janino-handled files in data/scripts.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.8.1a] Bug with replacing rulecmd scripts in jar file
« Reply #2 on: May 04, 2018, 07:19:42 AM »

(Yeah, this belongs in modding.)

To follow up on what Histidine said, what you want to do is change the rules file so it does not call this command on game start.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: [0.8.1a] Bug with replacing rulecmd scripts in jar file
« Reply #3 on: May 04, 2018, 03:11:57 PM »

(Yeah, this belongs in modding.)

To follow up on what Histidine said, what you want to do is change the rules file so it does not call this command on game start.

Feel free to PM me if you need any help with this, I have done it for my TC.
Logged