Implemented HUD dial whitelisting.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3370 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
62456b09f6
commit
3df2a3e3dd
@ -288,20 +288,8 @@
|
||||
"fuelLeakRate_number"
|
||||
);
|
||||
|
||||
hud_methods =
|
||||
hud_dial_methods =
|
||||
(
|
||||
// accepted keys
|
||||
"crosshairs",
|
||||
"crosshair_scale",
|
||||
"crosshair_width",
|
||||
"crosshair_color",
|
||||
"legends",
|
||||
"overall_alpha",
|
||||
"reticle_target_sensitive",
|
||||
"cloak_indicator_on_status_light",
|
||||
"dials",
|
||||
|
||||
// possible dials
|
||||
"drawTrumbles:",
|
||||
"drawTargetReticle:",
|
||||
"drawScanner:",
|
||||
|
@ -201,7 +201,7 @@ MA 02110-1301, USA.
|
||||
GLfloat z1;
|
||||
GLfloat line_width;
|
||||
|
||||
NSString *hudName;
|
||||
NSString *hudName;
|
||||
|
||||
GLfloat overallAlpha;
|
||||
|
||||
|
@ -170,6 +170,8 @@ OOINLINE void GLColorWithOverallAlpha(const GLfloat *color, GLfloat alpha)
|
||||
|
||||
if (sFontTexture == nil) InitTextEngine();
|
||||
|
||||
hudName = [hudFileName copy];
|
||||
|
||||
// init arrays
|
||||
dialArray = [[NSMutableArray alloc] initWithCapacity:16]; // alloc retains
|
||||
legendArray = [[NSMutableArray alloc] initWithCapacity:16]; // alloc retains
|
||||
@ -203,8 +205,6 @@ OOINLINE void GLColorWithOverallAlpha(const GLfloat *color, GLfloat alpha)
|
||||
|
||||
cloakIndicatorOnStatusLight = [hudinfo oo_boolForKey:@"cloak_indicator_on_status_light" defaultValue:YES];
|
||||
|
||||
if (hudFileName != nil) hudName = [[NSString stringWithString:hudFileName] retain];
|
||||
|
||||
last_transmitter = NO_TARGET;
|
||||
|
||||
_crosshairOverrides = [[hudinfo oo_dictionaryForKey:@"crosshairs"] retain];
|
||||
@ -407,11 +407,29 @@ OOINLINE void GLColorWithOverallAlpha(const GLfloat *color, GLfloat alpha)
|
||||
|
||||
- (void) addDial:(NSDictionary *) info
|
||||
{
|
||||
if ([info oo_stringForKey:SELECTOR_KEY] != nil)
|
||||
static NSSet *allowedSelectors = nil;
|
||||
if (allowedSelectors == nil)
|
||||
{
|
||||
SEL _selector = NSSelectorFromString([info oo_stringForKey:SELECTOR_KEY]);
|
||||
if ([self respondsToSelector:_selector]) [dialArray addObject:info];
|
||||
NSDictionary *whitelist = [ResourceManager whitelistDictionary];
|
||||
allowedSelectors = [[NSSet alloc] initWithArray:[whitelist oo_arrayForKey:@"hud_dial_methods"]];
|
||||
}
|
||||
|
||||
NSString *dialSelector = [info oo_stringForKey:SELECTOR_KEY];
|
||||
if (dialSelector == nil)
|
||||
{
|
||||
OOLogERR(@"hud.dial.noSelector", @"HUD dial in %@ is missing selector.", hudName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (![allowedSelectors containsObject:dialSelector])
|
||||
{
|
||||
OOLogERR(@"hud.dial.invalidSelector", @"HUD dial in %@ uses selector \"%@\" which is not in whitelist, and will be ignored.", hudName, dialSelector);
|
||||
return;
|
||||
}
|
||||
|
||||
NSAssert2([self respondsToSelector:NSSelectorFromString(dialSelector)], @"HUD dial in %@ uses selector \"%@\" which is in whitelist, but not implemented.", hudName, dialSelector);
|
||||
|
||||
[dialArray addObject:info];
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ static NSString * const kCacheKeyCaches = @"caches";
|
||||
enum
|
||||
{
|
||||
kEndianTagValue = 0x0123456789ABCDEFULL,
|
||||
kFormatVersionValue = 39
|
||||
kFormatVersionValue = 40
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user