Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Cross-Platform Development => Topic started by: karajorma on May 03, 2009, 06:26:16 am

Title: Need someone to test this
Post by: karajorma on May 03, 2009, 06:26:16 am
I added a second macro similar to Assert which also includes a message (similar to Warning and Error) earlier today. It seems to work just fine on Windows but as I can't compile stubs.cpp I've got no idea if I've done something wrong for the other platforms.

Can someone take a look at the patch I've attached and check it compiles and works fine. To test it, simply pick a fighter from the tables and change the $Default PBanks: ( "x") entry to $Default PBanks: ( "")

[attachment deleted by evil Tolwyn]
Title: Re: Need someone to test this
Post by: portej05 on May 03, 2009, 07:16:22 am
Disclaimer: I haven't tested this, and I'm not sure of its usage in the system!

This might suffer from the same problem that FRED2 is having - very long message boxes.
Title: Re: Need someone to test this
Post by: karajorma on May 03, 2009, 08:29:36 am
It might but it doesn't have to.

Basically the difference is that instead of getting an error message like this
Code: [Select]
Assertion Failed!
---------------------------
Assert: sip->primary_bank_weapons[i] >= 0
File: Ship.cpp
Line: 3853
Call stack:

You can now add a message to the assertion so you get this

Code: [Select]
Assertion Failed!
---------------------------
Assert: sip->primary_bank_weapons[i] >= 0
File: Ship.cpp
Line: 3853

Ship Class Ulysses has no $Default PBanks supplied for bank 0
Call stack:


Which is much more useful when tracking down errors. The first one requires a coder to explain exactly what went wrong. The second one can be fairly easily interpreted by anyone who knows how to edit tables. As long as people aren't silly with what they put in the message it shouldn't cause an increase in the long message boxes as all it adds is an extra line or two.

In other cases we could use it to output a little more information about the state of a few key variables at the time of the assertion. That wouldn't be much use to the end user but it can save the coder minutes or even hours when it comes to tracking down the cause of a bug and may even make it unnecessary to replicate the bug.
Title: Re: Need someone to test this
Post by: Dragon on May 03, 2009, 09:29:45 am
Looks like solution of lot of my problems ,thanks Kajorama.
Now I only need to know how to make it work.
Title: Re: Need someone to test this
Post by: ShadowGorrath on May 03, 2009, 11:34:31 am
Would be very useful to me ;)
Title: Re: Need someone to test this
Post by: karajorma on May 03, 2009, 11:43:35 am
Probably not so much for the error you posted earlier. There's not much useful information you can actually give for that assertion since the function actually causing it doesn't know which ship it is reading the data for.

But in the long run, it probably will help you.
Title: Re: Need someone to test this
Post by: karajorma on May 04, 2009, 02:43:08 pm
You know, if no one tests this I'm just going to assume it works. :p
Title: Re: Need someone to test this
Post by: taylor on May 04, 2009, 03:27:34 pm
I haven't tested it, but the patch looks ok to me at least. :)
Title: Re: Need someone to test this
Post by: karajorma on May 04, 2009, 05:02:09 pm
I noticed I missed a small but important change. I only tested the debug version and forgot to change

Code: [Select]
#if defined(NDEBUG)
#define Assert(x) do {} while (0)

to

Code: [Select]
#if defined(NDEBUG)
#define Assert(x) do {} while (0)
#define Assertion(x, y, ...) do {} while (0)

Without that release won't build. :)
Title: Re: Need someone to test this
Post by: Aardwolf on May 10, 2009, 08:47:39 pm
I'll give it a try.

If I don't post again in a bit, my computer asplode. That or I forgot about this.

Edit: Wait... what am I doing responding to a post in Cross-Platform Development? Anyway, I've got it compiled now (for Windows) so I'll try it...
Title: Re: Need someone to test this
Post by: karajorma on May 11, 2009, 04:08:41 am
It works for Windows. :) But I suppose there is no such thing as an unnecessary bug test. :)
Title: Re: Need someone to test this
Post by: Aardwolf on May 11, 2009, 07:53:41 pm
I couldn't remember where MSVC put the EXE, and didn't bother to go looking for it.
Title: Re: Need someone to test this
Post by: chief1983 on May 12, 2009, 08:35:59 pm
Usually puts it in the root level of the drive the project is on, and in the project folder itself in the Debug or Release folders.
Title: Re: Need someone to test this
Post by: Aardwolf on July 09, 2009, 06:31:01 pm
:bump:

I know this is the non-Windows board, but... has anything been done with this? Has it been committed?

Because right now windows_stub (where the applied patch was) is the only folder in my /code directory that isn't identical to what's in trunk...
Title: Re: Need someone to test this
Post by: chief1983 on July 09, 2009, 06:36:41 pm
Yeah I think this is in now.