Added exception checks in OOLog(). Exceptions caught in [Universe update:] now report context at entity granularity.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1500 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
aa77a4fc6c
commit
b9d729fb01
@ -90,6 +90,7 @@ SOFTWARE.
|
||||
#define OOLOG_BAD_SETTING 1
|
||||
#define OOLOG_BAD_DEFAULT_SETTING 1
|
||||
#define OOLOG_BAD_POP_INDENT 1
|
||||
#define OOLOG_EXCEPTION_IN_LOG 1
|
||||
|
||||
|
||||
// Used to track OOLogPushIndent()/OOLogPopIndent() state.
|
||||
@ -433,12 +434,12 @@ void OOLogWithFunctionFileAndLineAndArguments(NSString *inMessageClass, const ch
|
||||
#endif
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NS_DURING
|
||||
// Do argument substitution
|
||||
formattedMessage = [[[NSString alloc] initWithFormat:inFormat arguments:inArguments] autorelease];
|
||||
|
||||
// Apply various prefix options
|
||||
#ifndef OOLOG_NO_FILE_NAME
|
||||
#ifndef OOLOG_NO_FILE_NAME
|
||||
if (sShowFileAndLine && inFile != NULL)
|
||||
{
|
||||
if (sShowFunction)
|
||||
@ -451,7 +452,7 @@ void OOLogWithFunctionFileAndLineAndArguments(NSString *inMessageClass, const ch
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
if (sShowFunction)
|
||||
{
|
||||
@ -508,6 +509,9 @@ void OOLogWithFunctionFileAndLineAndArguments(NSString *inMessageClass, const ch
|
||||
}
|
||||
|
||||
OOLogOutputHandlerPrint(formattedMessage);
|
||||
NS_HANDLER
|
||||
OOLogInternal(OOLOG_EXCEPTION_IN_LOG, @"***** Exception thrown during logging: %@ : %@", [localException name], [localException reason]);
|
||||
NS_ENDHANDLER
|
||||
|
||||
[pool release];
|
||||
}
|
||||
@ -679,6 +683,7 @@ static void OOLogInternal_(const char *inFunction, NSString *inFormat, ...)
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NS_DURING
|
||||
va_start(args, inFormat);
|
||||
formattedMessage = [[[NSString alloc] initWithFormat:inFormat arguments:args] autorelease];
|
||||
va_end(args);
|
||||
@ -687,6 +692,9 @@ static void OOLogInternal_(const char *inFunction, NSString *inFormat, ...)
|
||||
if (sShowApplication) formattedMessage = [NSString stringWithFormat:@"%@: %@", APPNAME, formattedMessage];
|
||||
|
||||
OOLogOutputHandlerPrint(formattedMessage);
|
||||
NS_HANDLER
|
||||
fprintf(stderr, "***** Exception in OOLogInternal_(): %s : %s", [[localException name] UTF8String], [[localException reason] UTF8String]);
|
||||
NS_ENDHANDLER
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
@ -5303,29 +5303,27 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
|
||||
for (i = 0; i < ent_count; i++)
|
||||
{
|
||||
Entity *thing = my_entities[i];
|
||||
#ifndef NDEBUG
|
||||
update_stage = [NSString stringWithFormat:@"update:entity[%@]", [thing shortDescription]];
|
||||
#endif
|
||||
|
||||
[thing update:delta_t];
|
||||
|
||||
// maintain sorted lists
|
||||
|
||||
// maintain distance-from-player list
|
||||
double z_distance = thing->zero_distance;
|
||||
|
||||
// zero_index first..
|
||||
int index = thing->zero_index;
|
||||
while ((index > 0)&&(z_distance < sortedEntities[index - 1]->zero_distance))
|
||||
while (index > 0 && z_distance < sortedEntities[index - 1]->zero_distance)
|
||||
{
|
||||
sortedEntities[index] = sortedEntities[index - 1]; // bubble up the list, usually by just one position
|
||||
sortedEntities[index - 1 ] = thing;
|
||||
sortedEntities[index - 1] = thing;
|
||||
thing->zero_index = index - 1;
|
||||
sortedEntities[index]->zero_index = index;
|
||||
index--;
|
||||
}
|
||||
|
||||
// done maintaining sorted lists
|
||||
|
||||
// update deterministic AI
|
||||
|
||||
if (thing->isShip)
|
||||
if ([thing isShip])
|
||||
{
|
||||
AI* theShipsAI = [(ShipEntity *)thing getAI];
|
||||
if (theShipsAI)
|
||||
@ -5333,6 +5331,9 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
|
||||
double thinkTime = [theShipsAI nextThinkTime];
|
||||
if ((universal_time > thinkTime)||(thinkTime == 0.0))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
update_stage = [NSString stringWithFormat:@"update:think[%@]", [thing shortDescription]];
|
||||
#endif
|
||||
[theShipsAI setNextThinkTime:universal_time + [theShipsAI thinkTimeInterval]];
|
||||
[theShipsAI think];
|
||||
}
|
||||
@ -5340,10 +5341,12 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
|
||||
}
|
||||
}
|
||||
|
||||
// Maintain x/y/z order lists
|
||||
update_stage = @"updating linked lists";
|
||||
for (i = 0; i < ent_count; i++)
|
||||
{
|
||||
[my_entities[i] updateLinkedLists];
|
||||
|
||||
}
|
||||
|
||||
// detect collisions and light ships that can see the sun
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user