Has anyone else had crashes due to Assertion Failure in Campaing_types.h?[message #245227]
|
Wed, 24 February 2010 21:12
|
|
Mythrell |
|
Messages:78
Registered:May 2008 Location: Mikkeli, Finland |
|
|
I'm experiencing random crash in my latest mod SVN version with following error in stderr.txt:
{ 1229756 } Assertion Failure [Line 11 in Build/Strategic/Campaign_Types.h]
Has anyone else had anything like this or have I caused it myself? I shouldn't have touched anything what would cause those in that particular function but that is possible, I just can't seem to be able to find the cause.
It's starting to bug me, seriously :computer2:
Report message to a moderator
|
Corporal
|
|
|
|
|
|
|
|
Re: Has anyone else had crashes due to Assertion Failure in Campaing_types.h?[message #251276]
|
Mon, 10 May 2010 01:10
|
|
The_Bob |
|
Messages:415
Registered:May 2009 Location: Behind you. |
|
|
Here's a gem that seems to go off only on the msvc++ compatible version made by birdlfu - although in theory, it should cause problems everywhere.
In strategic_movement.cc, in function PlayersBetweenTheseSectors() there's this block:
INT16 const sec_prev = SECTOR(g.ubPrevX, g.ubPrevY);
INT16 const sec_cur = SECTOR(g.ubSectorX, g.ubSectorY);
INT16 const sec_next = SECTOR(g.ubNextX, g.ubNextY);
which works fine most of the time, however when the function is called to display possible retreat locations, g.ubNextX and g.ubNextY equal zero - because the group has already arrived and has no next sector to go to. This should cause an ass failure in the SECTOR macro:
static inline UINT SECTOR(UINT const x, UINT const y)
{
Assert(1 <= x && x <= 16);
Assert(1 <= y && y <= 16);
return (y - 1) * 16 + x - 1;
}
My fix for that is to replace the line
INT16 const sec_next = SECTOR(g.ubNextX, g.ubNextY);
with
INT16 sec_next = 0;
if (g.ubNextX > 0 && g.ubNextY > 0)
{
sec_next = SECTOR(g.ubNextX, g.ubNextY);
}
which fixes the problem in this instance.
My two additional points are:
1 - there are many places in the code where ubNextX and ubNextY are checked for being zero, and there may be even more where they are not - perhaps the SECTOR macro assertions ought to be relaxed and allow for a situation where both sector coordinates are zero and return 0 (as in sector 1,1).
2 - in the mingw version the assertions do nothing in this case - the line INT16 const sec_next = SECTOR(g.ubNextX, g.ubNextY); with both variables equal zero yields
which is undesirable, although seems harmless in that specific situation. Still, that is a signed value in a place where only unsigned ones should be allowed.
[Updated on: Mon, 10 May 2010 01:14] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|