| // only if error reporting is enabled. | // only if error reporting is enabled. | ||||
| if (expression.result != nil) { | if (expression.result != nil) { | ||||
| [formattedString appendFormat:@" = %@", expression.result]; | [formattedString appendFormat:@" = %@", expression.result]; | ||||
| } else if (_legacyModeErrorReportingEnabled == YES && | |||||
| expression.errorBitMask != 0) { | |||||
| [formattedString appendFormat:((__builtin_popcountl(expression.errorBitMask) == 1) ? @" [ERROR: %@]" : @" [ERRORS: %@]"), | |||||
| } else if ( _legacyModeErrorReportingEnabled == YES | |||||
| && expression.errorBitMask != 0) { | |||||
| [formattedString appendFormat:((__builtin_popcountl(expression.errorBitMask) == 1) | |||||
| ? @" [ERROR: %@]" | |||||
| : @" [ERRORS: %@]"), | |||||
| [SA_DiceFormatter descriptionForErrors:expression.errorBitMask]]; | [SA_DiceFormatter descriptionForErrors:expression.errorBitMask]]; | ||||
| } | } | ||||
| is printed along with the rolls. | is printed along with the rolls. | ||||
| For this reasons, when we recursively retrieve the string representations | For this reasons, when we recursively retrieve the string representations | ||||
| of sub-expressions, we call this method, not legacyStringFromExpression:. | |||||
| of sub-expressions, we call this method, not -[legacyStringFromExpression:]. | |||||
| */ | */ | ||||
| switch (expression.type) { | switch (expression.type) { | ||||
| } | } | ||||
| NSMutableArray <NSString *> *errorDescriptions = [NSMutableArray array]; | NSMutableArray <NSString *> *errorDescriptions = [NSMutableArray array]; | ||||
| for (int i = 0; i <= 18; i++) { | |||||
| if ((errorBitMask & 1 << i) == 0) continue; | |||||
| NSString *errorName = NSStringFromSA_DiceExpressionError((SA_DiceExpressionError) 1 << i); | |||||
| for (int i = 0; i <= 19; i++) { | |||||
| if ((errorBitMask & (1 << i)) == 0) | |||||
| continue; | |||||
| NSString *errorName = NSStringFromSA_DiceExpressionError((SA_DiceExpressionError) (1 << i)); | |||||
| [errorDescriptions addObject:(_errorDescriptions[errorName] ?: errorName)]; | [errorDescriptions addObject:(_errorDescriptions[errorName] ?: errorName)]; | ||||
| } | } | ||||