Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Snail on August 08, 2010, 09:05:08 pm

Title: WTF possible bug since retail found
Post by: Snail on August 08, 2010, 09:05:08 pm
There seems to be a bug in the weapons loadout thingy in FRED that has been here since retail. The maximum number of missiles that can be stored in a bank differs between FRED and FreeSpace 2.

To verify go into FRED and load up a Boanerges with full Cyclops - 2/6/6. In the in-game weapons loading screen, the same loadout gets you 3/7/7.


Is this mantis-worthy?
Title: Re: WTF possible bug since retail found
Post by: FUBAR-BDHR on August 08, 2010, 09:34:47 pm
Sounds like a rounding issue.  Since you said it's a bug and confirmed in retail even mantis should have been your first stop.
Title: Re: WTF possible bug since retail found
Post by: Bobboau on August 09, 2010, 12:40:16 am
and since it's been in since retail, it means it cannot be fixed, or we could say it's a fred bug.
Title: Re: WTF possible bug since retail found
Post by: Mongoose on August 09, 2010, 12:49:03 am
If it's just a matter of FRED not displaying the correct max loadouts, though, I don't think fixing it would have any negative effects.  The correct number of missiles would still display in-game as always, right?
Title: Re: WTF possible bug since retail found
Post by: FelixJim on August 09, 2010, 09:05:11 am
If anyone's interested, as far as I can make out the tables suggest that the Boanerges should be able to carry 2.666666.../6.6666666..../6.6666666... Cyclops bombs. Looks like a rounding error to me too.
Title: Re: WTF possible bug since retail found
Post by: chief1983 on August 09, 2010, 10:47:00 am
I thought this was brought up about six months ago and it was on Kara's list to fix at some point, since he was very familiar with the loadout screen.
Title: Re: WTF possible bug since retail found
Post by: Snail on August 09, 2010, 11:47:28 am
I thought this was brought up about six months ago and it was on Kara's list to fix at some point, since he was very familiar with the loadout screen.
Oh. We'll leave it at that then.
Title: Re: WTF possible bug since retail found
Post by: chief1983 on August 09, 2010, 11:50:13 am
Well, if it's still a bug it probably needs to be in Mantis, if it isn't already.  Might even assign it to him.
Title: Re: WTF possible bug since retail found
Post by: Goober5000 on August 09, 2010, 05:51:58 pm
It's definitely a bug, but if we fix it, it should be on the FRED end, so that FRED matches what is seen in FS2.
Title: Re: WTF possible bug since retail found
Post by: chief1983 on August 09, 2010, 06:23:19 pm
Sorry, the FRED loadout menu is what I meant by loadout screen.
Title: Re: WTF possible bug since retail found
Post by: karajorma on August 10, 2010, 03:00:35 am
It's definitely a bug, but if we fix it, it should be on the FRED end, so that FRED matches what is seen in FS2.

Problem with that is that based on what FelixJim said the problem is actually a rounding error in the game and not in FRED. If the Boanerges with full Cyclops has a 3/7/7 loadout that's more than the table says it should have. But we can't change that without throwing off the balance for every single missile and ship bank in the game.
Title: Re: WTF possible bug since retail found
Post by: headdie on August 10, 2010, 04:09:01 am
is it possible to copy the code that calculates the load numbers from FS2 to FRED if they are different? 

on a side note I ran a little test

I Fredded a mission with just alpha wing 2 fighters and beta wing 3 fighter
Alpha 1 - herc II
Alpha 2 - Boa with max loadout of cyclops#short
Beta 1 - Boa as Alpha 2 but with the missile banks set to 1/3/3
Beta 2 - Boa as Alpha 2 but with number of missiles reduced then added 2/6/6
Beta 3 - Boa as Alpha 2 but with the missile numbers manually set to 2/6/6 by using numeric keypad

Within FS2 loadout I got the following
Alpha 1 - I changed to Boa and loaded with cyclops#short and got 3/7/7
Alpha 2 - 3/7/7
Beta 1 - 1/3/3
Beta 2 - 3/7/7
Beta 3 - 3/7/7

the Beta wing results show this bug has implications for the Fredder being able to fine control the loadout of a given ship if using numbers near the maximum capacity.  I'm guessing fred and/or the game makes an assumption somewhere that a maximum number in fred is meant to be a maximum number in FS2 which as we have seen can be bigger and might be more than the Fredder wants
Title: Re: WTF possible bug since retail found
Post by: FelixJim on August 10, 2010, 04:25:57 am
It's definitely a bug, but if we fix it, it should be on the FRED end, so that FRED matches what is seen in FS2.

Problem with that is that based on what FelixJim said the problem is actually a rounding error in the game and not in FRED. If the Boanerges with full Cyclops has a 3/7/7 loadout that's more than the table says it should have. But we can't change that without throwing off the balance for every single missile and ship bank in the game.
In a sense, there isn't really a rounding error at all. Both FRED and FS are rounding perfectly correctly, but using different rounding systems. FRED is taking the floor when rounding, whilst FS is taking the nearest integer (rounding up in a tie break). Rounding down makes more sense from a realism point of view (if you only have space for two-thirds of a cyclops, no amount of pushing is going to squeeze another one in), but rounding to the nearest integer may be better from a balance point of view (a ship with a bank capacity of 19 should have roughly twice the secondary capacity of one with only 10, and working with a bomb of cargo size 10, for example, you'd hope for the second to be able to carry two).
Title: Re: WTF possible bug since retail found
Post by: karajorma on August 10, 2010, 07:12:31 am
is it possible to copy the code that calculates the load numbers from FS2 to FRED if they are different? 

It's almost certainly doable and probably a matter of a tiny little change. The problem is that it's a change in the wrong direction. Although I understand FelixJim's point above I tend to go with the realistic point of view. If I've made a weapons bay with a cargo space of 14 I shouldn't be able to squeeze 3 size 5 weapons into it. Problem is that FS2 currently allows you to do just that and always has done.

If the problem was FRED then this could be fixed in a few minutes. But the problem isn't FRED. FRED does things correctly. Changing things means making FRED make the same mistake FS2 does.

Can you post that mission BTW? I'd like to see what is actually being written into the mission file.
Title: Re: WTF possible bug since retail found
Post by: chief1983 on August 10, 2010, 09:37:33 am
AI Profiles flag to fix the bug?  Add support to FRED and FS2 to both do it either way, based on that.  Then we don't break any existing stuff but anyone who wants the bug fixed in their own campaigns can do so.
Title: Re: WTF possible bug since retail found
Post by: headdie on August 10, 2010, 10:32:52 am
mission is attached below loudout.fs2

here is something interesting i spotted in loudout.fs2 when i decided to open it up in an attempt to pre-empt karajorma, remember Beta 1 was the ship with the secondary banks set to about half of its capacity while Beta 2 had full banks.  The +Secondary Banks: line and the line below are the most interesting.
Code: [Select]
$Name: Beta 1 ;! Object #2
$Class: GTB Boanerges
$Team: Friendly
$Location: 45.171978, 0.000013, 5.690553
$Orientation:
1.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000,
0.000000, 0.000000, 1.000000
$AI Behavior: None
$Cargo 1:  XSTR("Nothing", -1)
+Initial Velocity: 33
+Initial Hull: 100
+Subsystem: Pilot
+Secondary Banks: ( "Cyclops#short" "Cyclops#short" "Cyclops#short" )
+Sbank Ammo: ( 50 50 50 )
$Arrival Location: Hyperspace
$Arrival Cue: ( false )
$Departure Location: Hyperspace
$Departure Cue: ( false )
$Determination: 10
+Flags: ( "cargo-known" )
+Flags2: ( )
+Respawn priority: 0
+Group: 0
+Use Table Score:
+Score: 10

$Name: Beta 2 ;! Object #3
$Class: GTB Boanerges
$Team: Friendly
$Location: 92.663002, -0.000000, -0.947957
$Orientation:
1.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000,
0.000000, 0.000000, 1.000000
$AI Behavior: None
$Cargo 1:  XSTR("Nothing", -1)
+Initial Velocity: 33
+Initial Hull: 100
+Subsystem: Pilot
+Secondary Banks: ( "Cyclops#short" "Cyclops#short" "Cyclops#short" )
$Arrival Location: Hyperspace
$Arrival Cue: ( false )
$Departure Location: Hyperspace
$Departure Cue: ( false )
$Determination: 10
+Flags: ( "cargo-known" )
+Flags2: ( )
+Respawn priority: 0
+Group: 0
+Use Table Score:
+Score: 10

now based on what i noticed above i made loadout2.fs2 changing beta 1 to 1/3/0 (I tried to get 1/5/1 but fred wouldn't let me set it like that which I think might be tied into what I will talk about below)

Code: [Select]
$Name: Beta 1 ;! Object #2
$Class: GTB Boanerges
$Team: Friendly
$Location: 45.171978, 0.000013, 5.690553
$Orientation:
1.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000,
0.000000, 0.000000, 1.000000
$AI Behavior: None
$Cargo 1:  XSTR("Nothing", -1)
+Initial Velocity: 33
+Initial Hull: 100
+Subsystem: Pilot
+Secondary Banks: ( "Cyclops#short" "Cyclops#short" "Cyclops#short" )
+Sbank Ammo: ( 50 66 0 )
$Arrival Location: Hyperspace
$Arrival Cue: ( false )
$Departure Location: Hyperspace
$Departure Cue: ( false )
$Determination: 10
+Flags: ( "cargo-known" )
+Flags2: ( )
+Respawn priority: 0
+Group: 0
+Use Table Score:
+Score: 10

it looks like the loadouts are being stored as percentages in the mission file and it looks like only in whole percentages which is why it wouldn't let me use the loadout I originally wanted to test .  Also anything set to 100% of the secondary capacity is not saved so the game assumes the 100% denying the fredder the opportunity to manually set it

[attachment deleted by ninja]
Title: Re: WTF possible bug since retail found
Post by: karajorma on August 10, 2010, 02:12:37 pm
AI Profiles flag to fix the bug?

Wouldn't work. AI_Profiles have no effect in FRED nor should they. What would happen if you loaded a mission with 100% ammo in one profile and then saved it out with a profile where you'd forgotten to define this flag? And then what would happen when you realised the issue and fixed the profile?

It would be a mess.

Quote
Add support to FRED and FS2 to both do it either way, based on that.  Then we don't break any existing stuff but anyone who wants the bug fixed in their own campaigns can do so.

I'm toying with the idea of adding a global section to the top of Ships.tbl for stuff like this. Basically anything you defined there would affect all the ships in the mod. There are too many stupid things ending up in the AI_Profiles which then have to be copied to all the other profiles you make. There's no reason for it either. Who is going to make a mod where the maximum loadout of a ship class changes from mission to mission when using the same weapons.

You should be able to fix these sort of bugs with a single entry in one table and never have to bother about them again. That suggests something loaded on game load rather than mission load to me. It also has the effect of not buggering FRED about either since both of them would get their information on what to do from the same source.
Title: Re: WTF possible bug since retail found
Post by: chief1983 on August 10, 2010, 02:33:06 pm
Actually the suggestion I heard previously was to split out the nonsense AI_Profiles stuff into just a mod config file/table or something.  I don't think ships.tbl makes any more sense either really.
Title: Re: WTF possible bug since retail found
Post by: karajorma on August 10, 2010, 03:01:48 pm
Well in this case it's something that only affects ships but I'm in favour of adding a mod config table and have been for ages. This sort of nonsense should be defined once and forgotten about.
Title: Re: WTF possible bug since retail found
Post by: pecenipicek on August 10, 2010, 03:03:12 pm
i throw in my vote for a mod config table as well
Title: Re: WTF possible bug since retail found
Post by: headdie on August 11, 2010, 05:55:15 am
how does this sit for a solution to this problem

Fred sets a flag in any new mission created by it which call it something like "Use New Loadout behaviour:  # " where the hash isreplace with 0 or 1 as appropriate, the flag can be controlled by a control in mission spec editor.

The game then reads the flag, if it's absent or 0 then it uses the retail loadout behaviour, if its 1 then is used the code with the correct rounding
Title: Re: WTF possible bug since retail found
Post by: FelixJim on August 11, 2010, 07:54:19 am
The fix, wherever it ends up, ought to be a check one box/edit one table/do one whatever thing for an entire mod. There's really no need to support mission-by-mission control. Is there?
Title: Re: WTF possible bug since retail found
Post by: Qent on August 11, 2010, 10:20:45 am
I'm reluctant to call FRED's rounding "correct," as it is canonical that, e.g., Myrmidons can load eleven Trebuchets. Unless the new way of describing secondary capacity is helpful for a mod, all that remains is to have FRED display and alter the actual number of missiles seen in the game.

As far as realism goes, secondary capacity doesn't necessarily translate to physical space. There could be other considerations like storage and feeding mechanisms, ship compatibility, or the "instability of antimatter," and the number that the GTVA gives pilots happens to describe how many missiles can be carried if you round to the nearest integer.

So... just my $0.02 I guess.
Title: Re: WTF possible bug since retail found
Post by: chief1983 on August 11, 2010, 10:39:27 am
It's canonical unfortunately because of a bug in FS2.  The table doesn't say, 11 trebuchets.  It say, you have X space, and trebs take up Y space each, but even though it's physically impossible to put in more than floor(X/Y), we'll let you have one more if it's close.  Now, why no one noticed that when working on FS2, I have no idea, because you'd think the tablers would have caught that it didn't make any sense.  Or maybe it did lead to the result they wanted, even if it is stupid.
Title: Re: WTF possible bug since retail found
Post by: Qent on August 11, 2010, 10:52:23 am
I thought I addressed that in the second half of my post.
Title: Re: WTF possible bug since retail found
Post by: headdie on August 11, 2010, 11:32:35 am
the problem we have is that while FRED is rounding down as we would expect FS2 seems to be rounding up on some occasions. so in the examples shown a bomber with 40, 100, 100 points of capacity tabled and a weapon tabled with a capacity usage of 15.0 points per missile.  this means the boa has a mathematical capacity of 2.666, 6.666, 6.666. Cyclops.

Fred is rounding down at all times which is what you would expect I.E. you cant load 2/3 of a missile on the ship, FS2 is rounding these numbers up which looks like you are getting a third of a missile for free.

and as for how this was missed, it's easy, you set the loadout in fred and expect FS to mirror fred, an error like this is what you expect the original devs to have picked up on when designing the code.  I wonder if FS1 had this problem, unfortunately I no longer have my copy to find out.
Title: Re: WTF possible bug since retail found
Post by: FelixJim on August 11, 2010, 12:08:56 pm
I repeat: balancing. Realism is sacrificed throughout FS for the sake of balancing, and I don't see why this ought to be any different.
Title: Re: WTF possible bug since retail found
Post by: FUBAR-BDHR on August 11, 2010, 02:22:59 pm
Another solution might be to just show the actual percentage being held.  Well ideally enter the amount as a percentage (since that is the way it's stored in the mission file) and display the calculated amount based on FS2 calculations in FRED.  So if you actually wanted a 2,6,6 loadout on the Boa you would just set to  75,90,90 and 2,3,3 would be displayed. 
Title: Re: WTF possible bug since retail found
Post by: Goober5000 on August 11, 2010, 03:30:02 pm
I think we're being overly pedantic here.  Let's just accept the rounding as a clever way to allow the user to carry more ordnance than he should, by rights, be able to; and just change FRED to use the same behavior.  There's no need for yet another flag.  If mods care enough that this bothers them, they can tweak the weapon and cargo sizes to suit them.
Title: Re: WTF possible bug since retail found
Post by: The E on August 11, 2010, 03:36:18 pm
Agreed.
Title: Re: WTF possible bug since retail found
Post by: chief1983 on August 11, 2010, 04:28:06 pm
Yeah if you just use exponential values for everything now, you don't even need to worry about it either way.
Title: Re: WTF possible bug since retail found
Post by: FUBAR-BDHR on August 11, 2010, 04:56:14 pm
Wasn't the issue that if you wanted to set it to 2,6,6 you couldn't? 
Title: Re: WTF possible bug since retail found
Post by: headdie on August 12, 2010, 04:44:03 am
yes that issue did crop up when looking into this
Title: Re: WTF possible bug since retail found
Post by: karajorma on August 12, 2010, 05:23:20 am
I think we're being overly pedantic here.  Let's just accept the rounding as a clever way to allow the user to carry more ordnance than he should, by rights, be able to; and just change FRED to use the same behavior.  There's no need for yet another flag.  If mods care enough that this bothers them, they can tweak the weapon and cargo sizes to suit them.

I tend to disagree. Setting FRED up to always round up completely breaks the expected outcome when setting up a new weapon. Asking a mod to tweak cargo sizes is completely ridiculous since it would set up a never ending cycle of tweaks. As soon as you tweaked the size of a weapon you'd find it changed the number in every other ship. When you tweaked the ships it would require that you tweak all the other weapons to fit again.
Title: Re: WTF possible bug since retail found
Post by: Tomo on August 12, 2010, 01:06:17 pm
I'm with Goober here.

If I understand correctly, the basic issue is that FRED and FS2 currently calculate loadout capacity differently.

If FRED indicates differently to FS2, then FRED is wrong.
FRED should use the same method as FS2 (whatever that may be) of determining capacity.
- This will not actually have any effect on existing missions, because the in-game capacity is already being worked out by FS2 using FS2's algorithm.

It's also irrelevant whether it makes sense or not, because when you are playing the game, that's the loadout you can have.

If it's rounded to nearest instead of floor, that's fine - modders are presumably already taking that into account, because it is what happens when they playtest the game.

You'd be really surprised if FRED and the game indicated different values for ship hitpoints or any other ship property - this is no different.
Title: Re: WTF possible bug since retail found
Post by: karajorma on August 12, 2010, 01:36:21 pm
Fine. Then he can fix it. :p
Title: Re: WTF possible bug since retail found
Post by: chief1983 on August 12, 2010, 01:59:06 pm
If modders _had_ taken it into account, they would have said something about the difference in the first place and the bug wouldn't exist.

But, regardless of what the mission designer thought he was giving the ship, the playtester and balancers never saw that and only saw what was in game.  The fact that this bug exists at all actually really pisses me off, and I so want to fix it 'right', but I get that we can't go unbalancing every existing balanced mission ever made, and the numbers do need to match up.  I still think it would be nice to be able to enable a fix for this bug per mod that affects FRED and FS2 both, but I'd rather see FRED changed than FS2 if it has to be only one way.
Title: Re: WTF possible bug since retail found
Post by: Qent on August 12, 2010, 02:03:03 pm
If modders _had_ taken it into account, they would have said something about the difference in the first place and the bug wouldn't exist.
It's likely that the reason is that partial loadouts aren't very common.
Title: Re: WTF possible bug since retail found
Post by: headdie on August 12, 2010, 04:18:49 pm
i reckon there is 2-3 missions in retail between fs1, st and fs2 using partial loadouts
Title: Re: WTF possible bug since retail found
Post by: FUBAR-BDHR on August 12, 2010, 04:39:28 pm
Yea I still don't think you can even do partial load outs in multi.  You couldn't do it in single in 3.6.10 if you could load out wingmen either.  Not even sure if that one was fixed. 
Title: Re: WTF possible bug since retail found
Post by: Goober5000 on August 30, 2010, 06:14:21 pm
:bump:

Well bleh.  I took a look at this, and there are no fewer than three different functions that are called to calculate the number of missiles that will fit into one bank.  And they all do different things. :-/  I'm not sure I can change one of them without causing a cascade effect on something else, such as the total number of missiles available for the entire squadron.
Title: Re: WTF possible bug since retail found
Post by: FUBAR-BDHR on August 30, 2010, 06:34:04 pm
Well since those totals are already written to the .fs2 files loadout would it even be an issue with existing missions?  Even loading and saving the missions should not change those totals.
Title: Re: WTF possible bug since retail found
Post by: headdie on September 02, 2010, 04:29:19 am
the problem is looking at the mission files in notepad number of missiles loaded are stored as percentages of the total cappacity instead of hard numbers so if we change the way the game calculates the number of missiles a ship can carry it will effect the number of missiles taken into the mission.