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
-
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]
-
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.
-
It might but it doesn't have to.
Basically the difference is that instead of getting an error message like this
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
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.
-
Looks like solution of lot of my problems ,thanks Kajorama.
Now I only need to know how to make it work.
-
Would be very useful to me ;)
-
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.
-
You know, if no one tests this I'm just going to assume it works. :p
-
I haven't tested it, but the patch looks ok to me at least. :)
-
I noticed I missed a small but important change. I only tested the debug version and forgot to change
#if defined(NDEBUG)
#define Assert(x) do {} while (0)
to
#if defined(NDEBUG)
#define Assert(x) do {} while (0)
#define Assertion(x, y, ...) do {} while (0)
Without that release won't build. :)
-
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...
-
It works for Windows. :) But I suppose there is no such thing as an unnecessary bug test. :)
-
I couldn't remember where MSVC put the EXE, and didn't bother to go looking for it.
-
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.
-
: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...
-
Yeah I think this is in now.