* Changed required.plist version parsing to treat version strings as series of integers separated by points. This allows: - correct parsing of bug-fix versions like 1.67.1 - correctly sorting 1.100 after 1.99. * Deleted just about all commented-out NSLog()s (several hundred), and some other commented-out code. (commented-out or #ifdefed-out code with no indication of when you might want to reinstate it is worse than useless.) * Ensured that most NSLog()s will at least include their class/module in their message class. * Renamed Universe's -recycledOrNew:, -getShipWithRole: and -getShip: to -allocRecycledOrNewEntity:, -newShipWithRole: and -newShipWithName: to better match Objective-C coding conventions. (Methods whose result needs releasing should always be called alloc*, copy*, retain* or new*.) * Replaced -[Universe generateSystemDescription] with DescriptionForSystem(). * Replaced -[Universe getRandomDigrams] with RandomDigrams(). * Replaced +[Universe systemSeedString] with StringFromRandomSeed(). * Replaced [Universe entityZero] with [PlayerEntity sharedPlayer]. * Replaced scriptedUniverse in ScriptEngine with [Universe sharedUniverse]. * Removed HAVE_SOUND. If you're porting to a platform without sound, use a no-op implementation of OOSound. * Removed all (commented-out) NSBeep()s. * Made settings caching in OOLog actually work. Doing complete message class setting resolution every time OOLog() was called was around 2% of our per-frame cost. (With this fixed, cache hit rate is well over 99% after a few seconds of play.) *headdesk* (It may also be worth moving the settings-check into the macro, to avoid evaluating parameters for log messages that are never seen, but this might cause obscure bugs due to the parameters having side effects.) Stuff that should have been in revision 859: * Replaced all occurrences of -[Universe expandDescription:forSystem:] with ExpandDescriptionForSeed() and ExpandDescriptionForCurrentSystem(). * Replaced -[Universe expandDescriptionWithLocals:forSystem:withLocalVariables:] with ExpandDescriptionsWithLocalsForSystemSeed() and ExpandDescriptionsWithLocalsForCurrentSystem(). git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@872 127b21dd-08f5-0310-b4b7-95ae10353056
85 lines
3.1 KiB
Objective-C
85 lines
3.1 KiB
Objective-C
/*
|
|
|
|
OOStringParsing.h
|
|
|
|
Various functions for interpreting values from strings.
|
|
|
|
Oolite
|
|
Copyright (C) 2004-2007 Giles C Williams and contributors
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import "OOMaths.h"
|
|
#import "legacy_random.h"
|
|
|
|
@class Entity;
|
|
|
|
|
|
NSMutableArray *ScanTokensFromString(NSString *values);
|
|
|
|
// Note: these functions will leave their out values untouched if they fail (and return NO). They will not log an error if passed a NULL string (but will return NO). This means they can be used to, say, read dictionary entries which might not exist. They also ignore any extra components in the string.
|
|
BOOL ScanVectorFromString(NSString *xyzString, Vector *outVector);
|
|
BOOL ScanQuaternionFromString(NSString *wxyzString, Quaternion *outQuaternion);
|
|
BOOL ScanVectorAndQuaternionFromString(NSString *xyzwxyzString, Vector *outVector, Quaternion *outQuaternion);
|
|
|
|
Vector VectorFromString(NSString *xyzString, Vector defaultValue);
|
|
Quaternion QuaternionFromString(NSString *wxyzString, Quaternion defaultValue);
|
|
|
|
NSString *StringFromPoint(NSPoint point);
|
|
NSPoint PointFromString(NSString *xyString);
|
|
|
|
Random_Seed RandomSeedFromString(NSString *abcdefString);
|
|
NSString *StringFromRandomSeed(Random_Seed seed);
|
|
|
|
|
|
NSString *ExpandDescriptionForSeed(NSString *text, Random_Seed seed);
|
|
NSString *ExpandDescriptionForCurrentSystem(NSString *text);
|
|
|
|
NSString *ExpandDescriptionsWithLocalsForSystemSeed(NSString *text, Random_Seed seed, NSDictionary *locals);
|
|
NSString *ExpandDescriptionsWithLocalsForCurrentSystem(NSString *text, NSDictionary *locals);
|
|
|
|
NSString *DescriptionForSystem(Random_Seed seed);
|
|
NSString *DescriptionForCurrentSystem(void);
|
|
|
|
// target and localVariables are optional; target will default to the player.
|
|
NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *localVariables);
|
|
|
|
NSString *RandomDigrams(void);
|
|
|
|
|
|
@interface NSString (OOUtilities)
|
|
|
|
// Case-insensitive match of [self pathExtension]
|
|
- (BOOL)pathHasExtension:(NSString *)extension;
|
|
- (BOOL)pathHasExtensionInArray:(NSArray *)extensions;
|
|
|
|
@end
|
|
|
|
|
|
// Given a string of the form 1.2.3.4 (with arbitrarily many components), return an array of unsigned ints.
|
|
NSArray *ComponentsFromVersionString(NSString *string);
|
|
|
|
/* Compare two arrays of unsigned int NSNumbers, as returned by
|
|
ComponentsFromVersionString().
|
|
|
|
Components are ordered from most to least significant, and a missing
|
|
component is treated as 0. Thus "1.7" < "1.60", and "1.2.3.0" == "1.2.3".
|
|
*/
|
|
NSComparisonResult CompareVersions(NSArray *version1, NSArray *version2);
|