Attempt to fix native exception when a commander dictionary was requested while not docked. Refers to issue #203.

This commit is contained in:
AnotherCommander 2016-08-19 17:39:36 +02:00
parent 675731ab18
commit cc6a88d93a

View File

@ -852,7 +852,6 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
- (NSDictionary *) commanderDataDictionary
{
NSAssert([self isDocked], @"Cannot create commander data dictionary unless docked.");
int i;
NSMutableDictionary *result = [NSMutableDictionary dictionary];
@ -1069,9 +1068,16 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
// docked station
StationEntity *dockedStation = [self dockedStation];
[result setObject:[dockedStation primaryRole] forKey:@"docked_station_role"];
HPVector dpos = [dockedStation position];
[result setObject:ArrayFromHPVector(dpos) forKey:@"docked_station_position"];
[result setObject:dockedStation != nil ? [dockedStation primaryRole]:@"" forKey:@"docked_station_role"];
if (dockedStation)
{
HPVector dpos = [dockedStation position];
[result setObject:ArrayFromHPVector(dpos) forKey:@"docked_station_position"];
}
else
{
[result setObject:[NSArray array] forKey:@"docked_station_position"];
}
[result setObject:[UNIVERSE getStationMarkets] forKey:@"station_markets"];
// scenario information