Fractal Softworks Forum
August 18, 2018, 05:15:26 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: New blog post: Raids, Bombardments, and Planetary Defenses (08/16/18); In-dev patch notes for Starsector 0.9a (06/01/18);Starsector 0.8.1a is out!
 
   Home   Help Search Login Register  
Pages: 1 ... 258 259 [260] 261 262 263
  Print  
Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 548352 times)
xenoargh
Admiral
*****
Posts: 4303

Not a super-villain in real life.


View Profile
« Reply #3885 on: May 17, 2018, 08:55:30 AM »

Quote
Could WeakHashMap work after game load? I want the member will be automaticlly expired to prevent memory leak.
If the operation's terminated at the end of OnGameLoad() and there isn't any data associated with it still in use by other code, the Garbage Collector should clear it automatically.
Logged

Check out my SS projects Smiley
Alex
Administrator
Admiral
*****
Posts: 11743


View Profile
« Reply #3886 on: May 17, 2018, 09:20:46 AM »

It might, but why do it this way at all?

In my own stuff I have code like this:

Code: (java)

public static final String KEY = "$core_genericMissionManager";
   
public static GenericMissionManager getInstance() {
   Object test = Global.getSector().getMemoryWithoutUpdate().get(KEY);
   return (GenericMissionManager) test;
}
   
public GenericMissionManager() {
   super();
   Global.getSector().getMemoryWithoutUpdate().set(KEY, this);
}


So you never actually need a static reference to the instance.
Logged
Originem
Commander
***
Posts: 171


Dancing like a boss.


View Profile
« Reply #3887 on: May 17, 2018, 08:38:41 PM »

So you never actually need a static reference to the instance.

Well that's my code habit lol
Logged

Everything belong to AL once and for all.
Alex
Administrator
Admiral
*****
Posts: 11743


View Profile
« Reply #3888 on: May 17, 2018, 10:25:21 PM »

Fair enough, just in this case it doesn't seem like a good idea. Looking through the WeakHashMap javadoc, there are ways to mess this up and (in this case) end up with a memory leak. And since you're already putting it into persistent data...
Logged
Originem
Commander
***
Posts: 171


Dancing like a boss.


View Profile
« Reply #3889 on: May 18, 2018, 07:37:04 AM »

Fair enough, just in this case it doesn't seem like a good idea. Looking through the WeakHashMap javadoc, there are ways to mess this up and (in this case) end up with a memory leak. And since you're already putting it into persistent data...
hmm, I will have a try to see if it works.
Btw what's the difference between memory and persistent data in saving information
Logged

Everything belong to AL once and for all.
Alex
Administrator
Admiral
*****
Posts: 11743


View Profile
« Reply #3890 on: May 18, 2018, 08:59:54 AM »

Btw what's the difference between memory and persistent data in saving information

No real difference. getPersistentData() was just around before I added the memory stuff, which also has other uses.
Logged
Sarissofoi
Commander
***
Posts: 148



View Profile
« Reply #3891 on: May 18, 2018, 09:20:24 AM »

Is possible to make a carrier to carry a frigate instead of fighter wing?
Frigate that behave like normal frigate not like a fighter wing.
Logged

xenoargh
Admiral
*****
Posts: 4303

Not a super-villain in real life.


View Profile
« Reply #3892 on: May 18, 2018, 12:58:47 PM »

Not without some serious coding-fu.  I built a "missile launcher" that launched Frigates at one point, though... so yeah, doable, just not easy.
Logged

Check out my SS projects Smiley
Sarissofoi
Commander
***
Posts: 148



View Profile
« Reply #3893 on: May 19, 2018, 02:44:57 AM »

Not without some serious coding-fu.  I built a "missile launcher" that launched Frigates at one point, though... so yeah, doable, just not easy.
That its hilarious actually.
Let me precise my question.
Can it would be possible to make carriers launch small vessels size of frigates that have collision?
Logged

Soren
Admiral
*****
Posts: 503


Totally Not Omega


View Profile
« Reply #3894 on: May 19, 2018, 09:47:23 AM »

You can try it for yourself, change the collision class of a fighter wing.

Mind you, it doesn't precisely work...
Logged

"The law, in its majestic equality, forbids the rich as well as the poor to sleep under bridges, to beg in the streets, and to steal bread."
xenoargh
Admiral
*****
Posts: 4303

Not a super-villain in real life.


View Profile
« Reply #3895 on: May 19, 2018, 02:21:23 PM »

Quote
Can it would be possible to make carriers launch small vessels size of frigates that have collision?
Yes.  What it launched was, technically, a Missile, that I used code to replace with a Frigate immediately.  Not a Fighter or a Wing.

That's not the hard part; the hard part was weird- it was making sure said Frigates weren't added to the player's fleet at the end of the fight, if they survived. 

Anyhow, yes, this is all possible, yes.  Easy... nope.
Logged

Check out my SS projects Smiley
MajorTheRed
Commander
***
Posts: 110


View Profile
« Reply #3896 on: May 19, 2018, 06:46:20 PM »

A quick one, easy to answer, not easy to explain clearly. Can a mod modify a value of something in the core game? The question can be divided into two smaller one. Are duplicate of files possible. And does the mod has priority over the core game in this case?

Two exemples:
-Let say I want to modify the caracteristic of the Wolf frigate (armor, speed, etc...). Can I copy paste its value in th ship.csv of my mod and just change the relevant value.
-Same thing with a hull mod. Let sayI just want to change the rengebonus of the targeting core. Can I copy-paste the relevant file in my mod folder, change the relevant value, and the game will take in consideration the file in the mod? Or will the game just crash because of duplicatas?
Logged
Alex
Administrator
Admiral
*****
Posts: 11743


View Profile
« Reply #3897 on: May 19, 2018, 06:51:21 PM »

-Let say I want to modify the caracteristic of the Wolf frigate (armor, speed, etc...). Can I copy paste its value in th ship.csv of my mod and just change the relevant value.

Yes; just make sure the ship ID matches.

-Same thing with a hull mod. Let sayI just want to change the rengebonus of the targeting core. Can I copy-paste the relevant file in my mod folder, change the relevant value, and the game will take in consideration the file in the mod? Or will the game just crash because of duplicatas?

You'll have to add a line to your mod's hull_mods.csv to point that hullmod to a different implementation script, one provided by your mod.
Logged
Originem
Commander
***
Posts: 171


Dancing like a boss.


View Profile
« Reply #3898 on: May 22, 2018, 02:34:27 AM »

So how could I know if a FleetMemberAPI is removed in other places? If I put it into a Map, the reference will be continue, so when could I remove it.
Logged

Everything belong to AL once and for all.
Alex
Administrator
Admiral
*****
Posts: 11743


View Profile
« Reply #3899 on: May 22, 2018, 10:38:57 AM »

So how could I know if a FleetMemberAPI is removed in other places? If I put it into a Map, the reference will be continue, so when could I remove it.

I'm mainly talking about not using a static reference to the instance. That just strikes me as a very bad idea.

Also, make sure that your BowlData does not refer to the fleet member, or to anything that may refer to the fleet member indirectly, as that would prevent it from getting garbage collected.
Logged
Pages: 1 ... 258 259 [260] 261 262 263
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2006-2011, Simple Machines
Simple Audio Video Embedder
Valid XHTML 1.0! Valid CSS!