Fixed exception wrapping in conjunction with OOJS_BEGIN_FULL_NATIVE. Added missing implementation of [commander_bounty].
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5402 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
5bf9884011
commit
9bf8bd8b10
@ -28,6 +28,7 @@ MA 02110-1301, USA.
|
||||
#import "Universe.h"
|
||||
#import "OOCollectionExtractors.h"
|
||||
#import "OOConstToString.h"
|
||||
#import "OOStringParsing.h"
|
||||
|
||||
|
||||
@implementation PlayerEntity (ScriptMethods)
|
||||
@ -326,6 +327,36 @@ MA 02110-1301, USA.
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Implements string expansion code [credits_number].
|
||||
- (NSString *) creditsFormattedForSubstitution
|
||||
{
|
||||
return OOStringFromDeciCredits([self deciCredits], YES, NO);
|
||||
}
|
||||
|
||||
|
||||
/* Implements string expansion code [_oo_legacy_credits_number].
|
||||
|
||||
Literal uses of [credits_number] in legacy scripts are converted to
|
||||
[_oo_legacy_credits_number] in the script sanitizer. These are shown
|
||||
unlocalized because legacy scripts may use it for arithmetic.
|
||||
*/
|
||||
- (NSString *) creditsFormattedForLegacySubstitution
|
||||
{
|
||||
OOCreditsQuantity tenthsOfCredits = [self deciCredits];
|
||||
unsigned long long integerCredits = tenthsOfCredits / 10;
|
||||
unsigned long long tenths = tenthsOfCredits % 10;
|
||||
|
||||
return [NSString stringWithFormat:@"%llu.%llu", integerCredits, tenths];
|
||||
}
|
||||
|
||||
|
||||
// Implements string expansion code [commander_bounty].
|
||||
- (NSString *) commanderBountyAsString
|
||||
{
|
||||
return [NSString stringWithFormat:@"%i", [self legalStatus]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -452,6 +452,8 @@ static NSString *ExpandStringKey(OOStringExpansionContext *context, NSString *ke
|
||||
SEL selector = NSMapGet(specials, key);
|
||||
if (selector != NULL)
|
||||
{
|
||||
NSCAssert2([PLAYER respondsToSelector:selector], @"Special string expansion selector %@ for [%@] is not implemented.", NSStringFromSelector(selector), key);
|
||||
|
||||
value = [PLAYER performSelector:selector];
|
||||
if (value != nil)
|
||||
{
|
||||
@ -543,6 +545,8 @@ static NSMapTable *SpecialSubstitutionSelectors(void)
|
||||
These substitution keys map to methods on the player entity. They
|
||||
have higher precedence than descriptions.plist entries, but lower
|
||||
than explicit overrides.
|
||||
|
||||
All of these methods return strings.
|
||||
*/
|
||||
|
||||
static NSMapTable *specials = NULL;
|
||||
|
@ -313,9 +313,6 @@ static NSMapTable *SpecialSubstitutionSelectors(void)
|
||||
These substitution keys map to methods on the player entity. They
|
||||
have higher precedence than descriptions.plist entries, but lower
|
||||
than explicit overrides.
|
||||
|
||||
creditsFormattedForSubstitution is defined below, the rest are in
|
||||
PlayerEntityLegacyScriptEngine.m.
|
||||
*/
|
||||
|
||||
struct { NSString *key; SEL selector; } selectors[] =
|
||||
@ -341,27 +338,6 @@ static NSMapTable *SpecialSubstitutionSelectors(void)
|
||||
}
|
||||
|
||||
|
||||
@implementation PlayerEntity (OOStringParsingSubstition)
|
||||
|
||||
- (NSString *) creditsFormattedForSubstitution
|
||||
{
|
||||
return OOStringFromDeciCredits([self deciCredits], YES, NO);
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) creditsFormattedForLegacySubstitution
|
||||
{
|
||||
// Unlocalized because legacy scripts may use it for arithmetic.
|
||||
OOCreditsQuantity tenthsOfCredits = [self deciCredits];
|
||||
unsigned long long integerCredits = tenthsOfCredits / 10;
|
||||
unsigned long long tenths = tenthsOfCredits % 10;
|
||||
|
||||
return [NSString stringWithFormat:@"%llu.%llu", integerCredits, tenths];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/*
|
||||
SLOW_CODE
|
||||
ExpandDescriptionsWithOptions() is one of our heaviest symbols in warm
|
||||
|
@ -125,20 +125,32 @@ void OOJSUnreachable(const char *function, const char *file, unsigned line) NO_
|
||||
{ \
|
||||
OOJSPauseTimeLimiter(); \
|
||||
JSContext *oojsRequestContext = (context); \
|
||||
jsrefcount oojsRequestRefCount = JS_SuspendRequest(oojsRequestContext);
|
||||
jsrefcount oojsRequestRefCount = JS_SuspendRequest(oojsRequestContext); \
|
||||
@try \
|
||||
{
|
||||
|
||||
#define OOJS_END_FULL_NATIVE \
|
||||
JS_ResumeRequest(oojsRequestContext, oojsRequestRefCount); \
|
||||
OOJSResumeTimeLimiter(); \
|
||||
} \
|
||||
@finally \
|
||||
{ \
|
||||
JS_ResumeRequest(oojsRequestContext, oojsRequestRefCount); \
|
||||
OOJSResumeTimeLimiter(); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define OOJS_BEGIN_FULL_NATIVE(context) \
|
||||
{ \
|
||||
(void)(context); \
|
||||
OOJSPauseTimeLimiter(); \
|
||||
@try \
|
||||
{
|
||||
|
||||
#define OOJS_END_FULL_NATIVE \
|
||||
OOJSResumeTimeLimiter(); \
|
||||
} \
|
||||
@finally \
|
||||
{ \
|
||||
OOJSResumeTimeLimiter(); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user