What is "FAssertMsg"?

it is used to launch a pop up with the message with a compiled debug version of the dll . However to get it work you need a debug exe ( not provided ) . i've tried with a final debug version and get a ctd in 1/2 message .

Perhaps a skilled programmer know a way to use them .

Tcho !
 
So are FAssert needed for anything, outside of what you just mentioned? I.e., can we basically delete all FAssert calls and compile without error?
 
Seems there is a checkbox in-game somewhere to 'Show Debug' or somesuch, I wonder if it shows FAssertMsg text when enabled? I haven't played with this. It's internal debug code and would be very handy to figure out how to make it work.
 
If you have a setup to compile your own sdk, you can choose to compile it in "debug" mode or "final release" mode. In "final release" mode, the FAssertMsg calls are ignored. This is the way most mods do their final releases. For debugging possible crashes, developers often compile in debug mode. In this case, theoretically, all of the FAssertMsgs represent real problems in the software which should be fixed.

In practice, some of the FAssertMsgs are just "noise" in debug mode. However, I can think of no reason why you would bother to go through and delete all of them; since any one of them may be useful for something, this seems like a bad maneuver.

It should never matter to you, but the definition of FAssertMsg can be found in FAssert.h.

Why are you interested in deleting all these calls?
 
it is used to launch a pop up with the message with a compiled debug version of the dll . However to get it work you need a debug exe ( not provided ) . i've tried with a final debug version and get a ctd in 1/2 message .

Perhaps a skilled programmer know a way to use them .

Tcho !

No, you only need a debug DLL to use them. They're rather useful with debug dll's and can quickly point out silly mistakes in your code (like accidentally switching the parameters of a function call...)
 
I am using VS 2003 to write and debug the SDK.

What is the procedure to enable FAssertMsg text?
 
I am using VS 2003 to write and debug the SDK.

What is the procedure to enable FAssertMsg text?

Nothing. They will appear in a message box (They are very very obvious) when something goes wrong. As long as you are using a debug build, they will appear when the condition inside the Fassert is false.

For instance, if you wanted to see a Fassert message, you could add this to CvCity::doTurn()

Code:
FAssertMsg(false, "This is a test!");
 
Interesting, I have been doing this for a few years, and have had crashes while play-testing while debug is enabled, i.e. with a debug build, monitoring the Civ4 process etc., and have never seen these messages.
 
Interesting, I have been doing this for a few years, and have had crashes while play-testing while debug is enabled, i.e. with a debug build, monitoring the Civ4 process etc., and have never seen these messages.

Dividing by zero just crashes instantly, as does trying to look up info on a NONE-type object (-1).
 
Interesting, I have been doing this for a few years, and have had crashes while play-testing while debug is enabled, i.e. with a debug build, monitoring the Civ4 process etc., and have never seen these messages.

At a minimum, you must get a popup when the game first loads which says "DLL enabled", or something close to that, correct? If not, then I don't think you are actually getting a debug DLL linked up.

The mod I am working on currently, Dune Wars, is built on top of RevDCM, and I get about a dozen assert dialogs like this at the end of each turn. The *goal* of asserts is that an assert should be triggered just before any crash. But, it takes an awful lot of programming to ensure that. The asserts in the civ sdk mostly come when range checking array access. If an array has valid values from 0 ... N, and an access function takes an int to index the array, it uses FAssertMsg to complain if the int is less than 0 or greater than N. As pointed out above, you can easily make lots of programming errors without related asserts. (Not you personally, of course, but I do all the time :) )
 
At a minimum, you must get a popup when the game first loads which says "DLL enabled", or something close to that, correct? If not, then I don't think you are actually getting a debug DLL linked up.

The mod I am working on currently, Dune Wars, is built on top of RevDCM, and I get about a dozen assert dialogs like this at the end of each turn. The *goal* of asserts is that an assert should be triggered just before any crash. But, it takes an awful lot of programming to ensure that. The asserts in the civ sdk mostly come when range checking array access. If an array has valid values from 0 ... N, and an access function takes an int to index the array, it uses FAssertMsg to complain if the int is less than 0 or greater than N. As pointed out above, you can easily make lots of programming errors without related asserts. (Not you personally, of course, but I do all the time :) )

The Dll Enabled popup was added by BULL, and actually means nothing. It annoyed me so much that I commented it out. After commenting out the 4 asserts that AI AutoPlay triggers and WoC likes to cause, debugging has become much less annoying.
 
You can link the Debug DLL without any announcement Popup. I have never seen one, and I use debug builds VERY frequently.

You can easily get a ton of crashes without every seeing an Assert message if the crash is in the code you wrote, and you didn't add any assert messages. They are kinda the "Sticky Note" for a programmer to slip into his work where he didn't make it ROCK SOLID unable to crash, but was relatively certain that all the code elsewhere was written to not use it improperly. So he leaves a little note saying what improper use would be so that when he runs a debug build it will check certain facts for him automatically.

If you find that you don't say "Oh crap! I have to go fix that!" after seeing an Assert message, that is a sign that you either don't understand what that message is there for, or that it is no longer important and you ought to remove it to save yourself the bother of clicking to Ignore.

EDIT: Ah, good thing Afforess pre-posted me :) Odd thing to add, but apparently the main programmer of BULL liked confirmation. Though if you launch Civ from VS then VS itself gives you the confirmation in the Output window.
 
You can link the Debug DLL without any announcement Popup. I have never seen one, and I use debug builds VERY frequently.

You can easily get a ton of crashes without every seeing an Assert message if the crash is in the code you wrote, and you didn't add any assert messages. They are kinda the "Sticky Note" for a programmer to slip into his work where he didn't make it ROCK SOLID unable to crash, but was relatively certain that all the code elsewhere was written to not use it improperly. So he leaves a little note saying what improper use would be so that when he runs a debug build it will check certain facts for him automatically.

If you find that you don't say "Oh crap! I have to go fix that!" after seeing an Assert message, that is a sign that you either don't understand what that message is there for, or that it is no longer important and you ought to remove it to save yourself the bother of clicking to Ignore.

Heh, I noticed a few notes to "Jason" a programmer that worked on Animations and formations with units in some Fassert messages. Lol.

But asserts are pretty hand, they are usually a D'oh! moment when I realize that I forgot to check that it wasn't a NONE-type object...
EDIT: Ah, good thing Afforess pre-posted me :) Odd thing to add, but apparently the main programmer of BULL liked confirmation. Though if you launch Civ from VS then VS itself gives you the confirmation in the Output window.

I'm sure EF will be here to defend this decision... I never saw it useful, it popped up even when I didn't attach the dll...
 
Actually, that code was copied from HOF when I was working on BUFFY initially. I rarely run a debug build, but if I remember I'll remove that message when I get home tonight. There's no need for it.

Why do I rarely run a debug build? Habit. In my day job I write server software that needs to have extensive logging code throughout that we leave in the code. It is easily disabled by setting the logging level, so we don't take it out. I created the same mechanism in Python via BugUtil.debug()/info()/warn()/error()/fatal(). In the SDK I have been removing my temporary logging only because I don't feel like writing a robust configurable logging system in C++. ;)

In any case, most of the errors I get while adding features to BULL are easily diagnosed by seeing what happens in-game. That comes from experience, and I highly recommend using debug builds and the interactive debugger for most modders. Also, most of the code I write is interface code where I'm not changing the game state; thus asserts are less useful. I do, however, put asserts into the CvCity functions that provide the "building actual effects" values, ensuring you pass in a valid building/yield/commerce type etc.
 
Why do I rarely run a debug build? Habit. In my day job I write server software that needs to have extensive logging code throughout that we leave in the code. It is easily disabled by setting the logging level, so we don't take it out. I created the same mechanism in Python via BugUtil.debug()/info()/warn()/error()/fatal(). In the SDK I have been removing my temporary logging only because I don't feel like writing a robust configurable logging system in C++. ;)

So you did get a job? Glad to hear it! :)

By the way, when you say "Day Job", does that mean you have a "Night Job" too? Mild mannered programmer by day, superhero by night kinda deal? :lol:

I do, however, put asserts into the CvCity functions that provide the "building actual effects" values, ensuring you pass in a valid building/yield/commerce type etc.

Or when I forget to add my latest modifiers into the actual effects, and the values mismatch... :mischief:
 
So you did get a job? Glad to hear it! :)

Thanks. If you look at the BUG/BULL commit logs, you could probably figure out when I started. :) It was back in early October IIRC.

By the way, when you say "Day Job", does that mean you have a "Night Job" too? Mild mannered programmer by day, superhero by night kinda deal? :lol:

I have the perfect lifestyle for a programmer . . . I'm a vampire! :D

Or when I forget to add my latest modifiers into the actual effects, and the values mismatch... :mischief:

Hmm, that gives me an idea for a debug tool. At the start of processBuilding(), capture the current yield, commerce, health, happiness, :gp:, and defense values, add the results from calling the getAddtional...ByBuilding() functions, and compare to the new values after processing the building. This would let you detect when you've left out a building modifier from those functions but only be practical if those functions truly captured all building sources.

Try to remind me to do this later if I forget. It wouldn't be too hard to implement if you wanted to give it a shot. It would look something like this for yields:

Code:
void CvCity::processBuilding(...)
{
    int aiYields[NUM_YIELDS];
    for (int i = 0; i < NUM_YIELDS; i++)
    {
        aiYields[i] = getYieldRate((YieldTypes)i) + getAdditionalYieldByBuilding(eBuilding, (YieldTypes)i);
    }

    ...

    for (int i = 0; i < NUM_YIELDS; i++)
    {
        FAssertMsg(aiYields[i] == getYieldRate((YieldTypes)i), "new yield mismatches expected value");
    }
}
 
Top Bottom