Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: krevett62 on February 10, 2017, 01:16:44 pm

Title: Small FRED bug
Post by: krevett62 on February 10, 2017, 01:16:44 pm
Hello I noticed a small problem in FRED.
When you set the number of missiles on a ship other than the default, it is saved as a % of the bank capacity in the mission file. For example if a ship can carry 3 missiles of a type in a bank and you set the number to 2 in FRED, it'll be saved with the number 66 in secondarybanks. But if you open the weapon tab again, the number is now 1 in this example. If you close the weapon tab and open it again, the number is now 0.
The problem is probably caused by the way rounding the number is handled in FRED.

To repoduce the issue, use for my example a secondary weapon with cargo size of 4.0 in a ship with a secondarybank capacity of 15.
On the loadout screen, the ship can carry up to 4 missiles (15/4=3.75 so rounded to 4) but in FRED the max is 3 (rounded down even if the decimal is > 0.5), and if you set 2, close the tab then open it again it will display 1. Rince and repeat...

Edit: I forgot, I'm using the stable 3.7.4 version of FRED.
Title: Re: Small FRED bug
Post by: Yarn on February 10, 2017, 06:43:20 pm
Confirmed in both retail and the February 10, 2017 nightly. I think I also found the lines where the incorrect rounding occurs. Expect a pull request on GitHub shortly.

For anyone else who wants to test this, I found that this happens with the GTF Ulysses and the Harpoon if the number of Harpoons isn't a multiple of 4.

EDIT: Here's the PR: https://github.com/scp-fs2open/fs2open.github.com/pull/1213 (https://github.com/scp-fs2open/fs2open.github.com/pull/1213)
Title: Re: Small FRED bug
Post by: Yarn on February 11, 2017, 05:27:20 pm
The fix for your first issue (where missile counts in the weapons dialog sometimes drop) will be in the next nightly build. Keep in mind, however, that if a bank can hold more than 100 missiles, not every missile count is possible. (For example, the GTF Myrmidon can carry 160 Tempests in its third bank. If you try to load 159 Tempests in that bank, it will end up having only 158 Tempests. But at least that count won't keep dropping.)

As for your second issue:
To repoduce the issue, use for my example a secondary weapon with cargo size of 4.0 in a ship with a secondarybank capacity of 15.
On the loadout screen, the ship can carry up to 4 missiles (15/4=3.75 so rounded to 4) but in FRED the max is 3 (rounded down even if the decimal is > 0.5),
Of course, this discrepancy should be fixed, but the question is whether to fix the game or FRED. Technically, FRED is handling this correctly (after all, if a truck's capacity is 3.75 tons, it shouldn't be able to hold four 1-ton crates), but the in-game behavior goes all the way back to retail, and I'm sure there are missions that depend on this behavior for proper balance. Thus, I think FRED should be changed to match the game, but I'd like to hear from others before I make a pull request.
Title: Re: Small FRED bug
Post by: krevett62 on February 11, 2017, 06:07:30 pm
Personnaly I would stick to the game behavior as you said probably for game balance reasons as number are rounded like this since retail it seems.
Anyway thanks for the fix!
Title: Re: Small FRED bug
Post by: AdmiralRalwood on February 11, 2017, 07:47:31 pm
As for your second issue:
To repoduce the issue, use for my example a secondary weapon with cargo size of 4.0 in a ship with a secondarybank capacity of 15.
On the loadout screen, the ship can carry up to 4 missiles (15/4=3.75 so rounded to 4) but in FRED the max is 3 (rounded down even if the decimal is > 0.5),
Of course, this discrepancy should be fixed, but the question is whether to fix the game or FRED. Technically, FRED is handling this correctly (after all, if a truck's capacity is 3.75 tons, it shouldn't be able to hold four 1-ton crates), but the in-game behavior goes all the way back to retail, and I'm sure there are missions that depend on this behavior for proper balance. Thus, I think FRED should be changed to match the game, but I'd like to hear from others before I make a pull request.
Your reasoning makes sense to me (and it would not be the first time a discrepancy between FSO and FRED was resolved in favour of the former).
Title: Re: Small FRED bug
Post by: Yarn on February 12, 2017, 11:24:44 pm
Here's the PR that fixes the second issue: https://github.com/scp-fs2open/fs2open.github.com/pull/1223 (https://github.com/scp-fs2open/fs2open.github.com/pull/1223)