Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Goober5000 on January 22, 2004, 07:27:40 pm

Title: Fixing the Afterburner Bug
Post by: Goober5000 on January 22, 2004, 07:27:40 pm
Well, after getting no response from Beowulf, I thought I'd ask the general SCP community.

Everybody who is getting the afterburner bug (the afterburner button not working in Windows 2000 or Windows XP) can you please download and try the following builds?

In chronological order:
3.2: http://fs2source.warpcore.org/releases/fs2_open-3.2.zip
3.3: http://fs2source.warpcore.org/exes/fs2_open3_3.exe
3.4: http://fs2source.warpcore.org/exes/fs2_open_3.4.zip
3.5: http://fs2source.warpcore.org/exes/fs2_open_3_5.exe
3.5.1: http://fs2source.warpcore.org/exes/fs2_open_3_5_1.exe
3.5.3: http://fs2source.warpcore.org/exes/fs2_open_3_5_3_unofficial.exe
3.5.5: http://fs2source.warpcore.org/exes/3.5.5.zip

Try each of the builds and report back which SCP version the bug is first seen on.  Please also mention whether it appears in retail FS2.
Title: Fixing the Afterburner Bug
Post by: karajorma on January 23, 2004, 04:49:58 am
Don't know if you saw it Goober but that problem may have been fixed

Quote
Originally posted by Gravaton
Heh seems the assembler wasn't as tough as I thought it would be, I seem to have found a possible fix for the issue.  Here's the relevant chunk again (code/io/timer.cpp lines 292-308):

#if defined(_MSC_VER)
   // Timing in milliseconds.
   _asm   mov edx, temp_large.HighPart
   _asm   mov eax, temp_large.LowPart

   //_asm   shld    edx, eax, 16            ; Keep 32+11 bits
   //_asm   shl     eax, 16         
   // edx:eax = number of 1.19Mhz pulses elapsed.
   _asm   mov     ebx, Timer_freq
   // Make sure we won't divide overflow.  Make time wrap at about 9 hours
sub_again:
   _asm   sub     edx, ebx   ; subtract until negative...
   _asm   jns     sub_again   ; ...to prevent divide overflow...
   _asm   add     edx, ebx   ; ...then add in to get correct value.
   _asm   div     ebx
   //eax = milliseconds elapsed...
   _asm mov tmp, eax

tmp is an int, and the problem SEEMS to be that, on my system, at the end of this block eax is equal to a number around 33,000,000.  This, when moved into tmp (which is a regular int) gets taken to be a negative number of about -9,000,000.  And at that point everyone gets all sad.  The solution I've found is to turn tmp into an unsigned int (as there's no way any of the system timer functions would EVER be returning a value less then zero according to MSDN specs), and also turn the "now" variable (in code/ship/afterburner.cpp line ) for the afterburner into an unsigned int as well.  This worked.

Then I realized that all that NEEDS to be changed is the "now" variable, as the timer function will return a signed int that can be converted to unsigned without losing any data.  Tried it, tested it, it works.

So to sum it up, changing the declaration of now (code/ship/afterburner.cpp line 242) from "int" to "unsigned int" seems to fix this problem on my machine.  The scope of this change SEEMS to be restricted to the problem area alone, but I'd once again like to reiterate that I'm not very familiar with the project overall and it's theoretically possible that this could break something or many things.

But just maybe I fixed it ;)

Dave
Title: Fixing the Afterburner Bug
Post by: Goober5000 on January 23, 2004, 10:15:18 am
That's interesting.  I'll need someone with Win2000 or WinXP to confirm it.
Title: Fixing the Afterburner Bug
Post by: illum on January 23, 2004, 02:05:54 pm
Just to confirm that I also have this problem (Win XP, Radeon 9800 Pro 1gig Ram ..la di da)
When pressing the afterburner it merely makes a engine shutdown sound and accelerates to normal top speed. I assume this is the problem. :)
Hope its been fixed for the next version, have tried both 3.5.5 and the build available on the "Latest" thread. Odd I didn't have this problem on Windows 2000.


Keep up the great work!
Title: Fixing the Afterburner Bug
Post by: phreak on January 23, 2004, 03:40:46 pm
really?  hell even i can fix that problem.
Title: Fixing the Afterburner Bug
Post by: Lt.Cannonfodder on January 23, 2004, 03:52:45 pm
Quote
Originally posted by illum
Just to confirm that I also have this problem (Win XP, Radeon 9800 Pro 1gig Ram ..la di da)
When pressing the afterburner it merely makes a engine shutdown sound and accelerates to normal top speed. I assume this is the problem. :)
Hope its been fixed for the next version, have tried both 3.5.5 and the build available on the "Latest" thread. Odd I didn't have this problem on Windows 2000.


Keep up the great work!


Targetting illum. Target locked. Fire.

:welcome:

:D
Title: Fixing the Afterburner Bug
Post by: BobtheFerret on January 23, 2004, 09:05:14 pm
I have this same problem.  Wondering if a slightly altered build could be released to help fix this (because it's a relatively simple thing to fix I gather?).

I'd be willing to help test it :)
Title: Fixing the Afterburner Bug
Post by: RandomTiger on January 24, 2004, 06:26:36 am
Assembler, yuk!
Title: Fixing the Afterburner Bug
Post by: illum on January 24, 2004, 11:46:31 am
Quote
Originally posted by Lt.Cannonfodder


Targetting illum. Target locked. Fire.



Ack That'll teach me to break radio cover and stop lurking. :eek:

Yes if 3.6 isn't imminent or close, a fixed built would be most welcome. Thankyouverymuch. :)
Title: Re: Fixing the Afterburner Bug
Post by: Beowulf on January 24, 2004, 04:51:22 pm
Quote
Originally posted by Goober5000
Well, after getting no response from Beowulf, I thought I'd ask the general SCP community.

Everybody who is getting the afterburner bug (the afterburner button not working in Windows 2000 or Windows XP) can you please download and try the following builds?

In chronological order:
3.2: http://fs2source.warpcore.org/releases/fs2_open-3.2.zip
3.3: http://fs2source.warpcore.org/exes/fs2_open3_3.exe
3.4: http://fs2source.warpcore.org/exes/fs2_open_3.4.zip
3.5: http://fs2source.warpcore.org/exes/fs2_open_3_5.exe
3.5.1: http://fs2source.warpcore.org/exes/fs2_open_3_5_1.exe
3.5.3: http://fs2source.warpcore.org/exes/fs2_open_3_5_3_unofficial.exe
3.5.5: http://fs2source.warpcore.org/exes/3.5.5.zip

Try each of the builds and report back which SCP version the bug is first seen on.  Please also mention whether it appears in retail FS2.


Hey man, sorry for my leave of absence. I've had more work than usual lately.

I've tried out those builds, sent you the info as a PM. Thanks.

~Beowulf
Title: Fixing the Afterburner Bug
Post by: Goober5000 on January 24, 2004, 06:40:41 pm
Hm.  From what Beowulf said, none of those builds work... even 3.2.  So it definitely sounds like an OS-specific thing.  The signed/unsigned theory sounds good, but we'd have to see if it affects anything else.
Title: Fixing the Afterburner Bug
Post by: phreak on January 24, 2004, 08:37:17 pm
well it is a one line potential fix.  line 241, afterburner.cpp
Title: Fixing the Afterburner Bug
Post by: Bobboau on January 24, 2004, 08:44:50 pm
if that's a local variable I don't see hoe it could break anything else
Title: Fixing the Afterburner Bug
Post by: Vasudan Admiral on January 24, 2004, 09:52:39 pm
same thing happens to me (win XP pro with none of the patches applied)
and the AB didn't work in ANY of those builds at all, and even worse, seems to have stopped in the original exe despite a clean install. :shaking:
Title: Fixing the Afterburner Bug
Post by: StratComm on January 24, 2004, 10:49:49 pm
Did you remember to set compatability mode on the clean install?  It's always been needed.

EDIT: That's actually not true now that I think about it.  My afterburners have worked perfectly WITHOUT compatability mode since the Launcher or maybe even earlier.  You are running from the Launcher, right?
Title: Fixing the Afterburner Bug
Post by: Vasudan Admiral on January 24, 2004, 10:58:45 pm
tried both the original launcher and RT's one. neither one fixes it :(

and compatability set to win98 does nothing at all for the original exe, and last time i checked, crashes FS open before it even opens.