[1.2b3] cat broken. renders mod impossible to update.

These are old bug reports that have been closed.
Locked
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Fri Sep 27, 2013 2:58 am

In previous versions cat could append numbers to strings. The variable armor mass limits for one of my mod ships used this to access staticdata.

Even after accounting for the change from gArmorSegment to (@ gdata 'armorSeg) I'm getting

Code: Select all

09/26/2013 19:53:35	Exception in cat; arg = ("maxArmorMass" (@ gData "armorSeg"))
09/26/2013 19:53:35	Exception in cat; arg = ("maxArmorMass" (@ gData "armorSeg")) [("maxArmorMass" (@ gData "armorSeg"))] ### (cat "maxArmorMass" (@ gData "armorSeg")) ###
Literally is the new Figuratively

george moromisato
Developer
Developer
Posts: 2877
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Mon Sep 30, 2013 6:21 pm

Atarlost wrote:In previous versions cat could append numbers to strings. The variable armor mass limits for one of my mod ships used this to access staticdata.

Even after accounting for the change from gArmorSegment to (@ gdata 'armorSeg) I'm getting

Code: Select all

09/26/2013 19:53:35	Exception in cat; arg = ("maxArmorMass" (@ gData "armorSeg"))
09/26/2013 19:53:35	Exception in cat; arg = ("maxArmorMass" (@ gData "armorSeg")) [("maxArmorMass" (@ gData "armorSeg"))] ### (cat "maxArmorMass" (@ gData "armorSeg")) ###
I think there is a bug with gData being corrupted. Could you try (print gData) and see what you get in console output?

User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Tue Oct 01, 2013 12:39 am

george moromisato wrote:
Atarlost wrote:In previous versions cat could append numbers to strings. The variable armor mass limits for one of my mod ships used this to access staticdata.

Even after accounting for the change from gArmorSegment to (@ gdata 'armorSeg) I'm getting

Code: Select all

09/26/2013 19:53:35	Exception in cat; arg = ("maxArmorMass" (@ gData "armorSeg"))
09/26/2013 19:53:35	Exception in cat; arg = ("maxArmorMass" (@ gData "armorSeg")) [("maxArmorMass" (@ gData "armorSeg"))] ### (cat "maxArmorMass" (@ gData "armorSeg")) ###
I think there is a bug with gData being corrupted. Could you try (print gData) and see what you get in console output?
No I can't. Or at least not and get any console output.

The code where this is happening is

Code: Select all

;(setq CshpCanInstallArmor shpCanInstallArmor)
(setq shpCanInstallArmor (lambda (theShip theArmor) 
	(block nil
(pring gData)
		(if (objGetStaticData theShip (cat "maxArmorMass" (@ gData 'armorSeg)))
			(if (ls (objGetStaticData theShip (cat "maxArmorMass" (@ gData 'armorSeg))) (itmGetMass theArmor))
				1
				0
			)
			(CshpCanInstallArmor theship theArmor)
		)
	)
;))
This is code that worked just fine in 1.1 apart from the change from gArmorSegment to (@ gdata 'armorseg) and the addition of the requested print statement.

And the error I'm getting plastered across the right dockscreen panel and in debug.log is

Code: Select all

No binding for symbol [gCheckMilitaryID] ### (and gCheckMilitaryID (itmHasModifier thisItem "Military") (not (objGetItems gPlayerShip "*+MilitaryID"))) ###
And if I try to install more than one segment of armor when the code in question isn't commented out I get a CTD.
Literally is the new Figuratively

User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Tue Oct 15, 2013 7:07 am

This is still broken.

I need to have access to the variable formerly known as gArmorSegment in any location shpCanInstallArmor can be called from in order to update an existing mod to the new API. This worked in 1.1.
Literally is the new Figuratively

george moromisato
Developer
Developer
Posts: 2877
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Wed Oct 16, 2013 3:18 am

Atarlost wrote:This is still broken.

I need to have access to the variable formerly known as gArmorSegment in any location shpCanInstallArmor can be called from in order to update an existing mod to the new API. This worked in 1.1.
This is tricky to fix because we don't always know what armor segment we're installing. A function may call shpCanInstallArmor without having to know where it is being installed. For example, we might call it just to make a list of possible armor segments.

It looks like you're trying to have variable armor limits. We might need a <CanBeInstalled> event on ship classes or maybe even a <GlobalCanBeInstalled>. Would one of those solve your problem?

User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Wed Oct 16, 2013 6:30 am

george moromisato wrote:
Atarlost wrote:This is still broken.

I need to have access to the variable formerly known as gArmorSegment in any location shpCanInstallArmor can be called from in order to update an existing mod to the new API. This worked in 1.1.
This is tricky to fix because we don't always know what armor segment we're installing. A function may call shpCanInstallArmor without having to know where it is being installed. For example, we might call it just to make a list of possible armor segments.

It looks like you're trying to have variable armor limits. We might need a <CanBeInstalled> event on ship classes or maybe even a <GlobalCanBeInstalled>. Would one of those solve your problem?
Yes, but (a) this worked in 1.1 and (b) how can you install an armor segment if you don't know what slot to install in?
Literally is the new Figuratively

george moromisato
Developer
Developer
Posts: 2877
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Wed Oct 16, 2013 4:14 pm

Atarlost wrote:Yes, but (a) this worked in 1.1 and (b) how can you install an armor segment if you don't know what slot to install in?
I believe this worked in 1.1 because of a side-effect: that callers of shpCanInstallArmor happen to set gArmorSegment before the call. But there is no requirement that all callers do this.

What we need to do instead, I think, is to add a parameter to shpCanInstallArmor that includes the armor segment. Then we need to add the events above to allow you to implement your mass checks. [I don't think overriding a function is sustainable: you can't guarantee that you will be the only one doing it.]

User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Wed Oct 16, 2013 7:46 pm

george moromisato wrote:
Atarlost wrote:Yes, but (a) this worked in 1.1 and (b) how can you install an armor segment if you don't know what slot to install in?
I believe this worked in 1.1 because of a side-effect: that callers of shpCanInstallArmor happen to set gArmorSegment before the call. But there is no requirement that all callers do this.
I don't think it ever made sense to call it from a context in which gArmorSegment was undefined. The only reason to call it was to replace an armor segment and that required defining gArmorSegment.

On sustainability I think it's less an issue than you think so long as behavior is preserved.

If both overrides are local they should default through when they don't see the marker that tells them to not just run the version previously defined and both should work just fine unless both markers are present.

If the other override is global their priority is undefined whether through overriding the function or through implementing <CanBeInstalled> and <GlobalCanBeInstalled>.

An event would work for armor because the function only has two outputs, but I'm concerned that an event for devices would make dealing with objCanInstallItem harder because it has multiple possible outputs both for success and failure.
Literally is the new Figuratively

Locked