Fixed bug #18055 : Pending message overflow for thargoids, -> crash

A fuller message is printed on the log, the last AI message is discarded instead of joining the deferred messages stack, and Oolite carries on, rather than crashing horribly.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4621 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Marc 2011-10-14 21:17:34 +00:00
parent e54d7a5c82
commit 1968e30e2c

View File

@ -597,14 +597,15 @@ static AIStackElement *sStack = NULL;
{
if ([[self owner] universalID] == NO_TARGET) return; // don't think until launched
if ([pendingMessages count] > 32)
if (EXPECT_NOT([pendingMessages count] > 32))
{
OOLogERR(@"ai.message.failed.overflow", @"AI pending messages overflow for '%@'; pending messages:\n%@", ownerDesc, pendingMessages);
[NSException raise:@"OoliteException"
format:@"AI pendingMessages overflow for %@", ownerDesc];
// Generate the error, but don't crash Oolite! Fixes bug #18055 - Pending message overflow for thargoids, -> crash !
OOLogERR(@"ai.message.failed.overflow", @"AI message \"%@\" received by '%@' AI while pending messages stack full; message discarded. Pending messages:\n%@", ms, ownerDesc, pendingMessages);
}
else
{
[pendingMessages addObject:ms];
}
[pendingMessages addObject:ms];
}