# HG changeset patch # User koda # Date 1289598433 -3600 # Node ID e033cf015b2c2ac822a9274c47411b1386d480da # Parent b697a26ed5385cb12834ff9ba0643438aab18501 redo once again file updating, moving stuff around diff -r b697a26ed538 -r e033cf015b2c hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Fri Nov 12 22:38:05 2010 +0100 +++ b/hedgewars/GSHandlers.inc Fri Nov 12 22:47:13 2010 +0100 @@ -761,15 +761,16 @@ ); if trail <> nil then begin - trail^.dX := Gear^.X.QWordValue / _1.QWordValue; - trail^.dY := Gear^.Y.QWordValue / _1.QWordValue; + // http://mantis.freepascal.org/view.php?id=17714 hits again + trail^.dX := Gear^.X.QWordValue / SignAs(_1,_1).QWordValue; + trail^.dY := Gear^.Y.QWordValue / SignAs(_1,_1).QWordValue; // reached edge of land. assume infinite beam. Extend it way out past camera if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then begin - trail^.dX := trail^.dX + (CurrentHedgehog^.Gear^.dX * LAND_WIDTH).QWordValue / _1.QWordValue; - trail^.dY := trail^.dY + (CurrentHedgehog^.Gear^.dY * LAND_WIDTH).QWordValue / _1.QWordValue; + trail^.dX := trail^.dX + (CurrentHedgehog^.Gear^.dX * LAND_WIDTH).QWordValue / SignAs(_1,_1).QWordValue; + trail^.dY := trail^.dY + (CurrentHedgehog^.Gear^.dY * LAND_WIDTH).QWordValue / SignAs(_1,_1).QWordValue; end; trail^.Timer := 200; diff -r b697a26ed538 -r e033cf015b2c hedgewars/GearDrawing.inc --- a/hedgewars/GearDrawing.inc Fri Nov 12 22:38:05 2010 +0100 +++ b/hedgewars/GearDrawing.inc Fri Nov 12 22:47:13 2010 +0100 @@ -4,7 +4,6 @@ sign, hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt; // hedgehog, crosshair, temp, sprite, direction dx, dy, ax, ay, aAngle, dAngle, hAngle, lx, ly: real; // laser, change defaultPos, HatVisible: boolean; - VertexBuffer: array [0..1] of TVertex2f; HH: PHedgehog; CurWeapon: PAmmo; begin diff -r b697a26ed538 -r e033cf015b2c project_files/HedgewarsMobile/Classes/CommodityFunctions.h --- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.h Fri Nov 12 22:38:05 2010 +0100 +++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.h Fri Nov 12 22:47:13 2010 +0100 @@ -60,9 +60,6 @@ #define DEFAULT_NETGAME_PORT 46631 -void createTeamNamed (NSString *nameWithoutExt); -void createWeaponNamed (NSString *nameWithoutExt, int type); -void createSchemeNamed (NSString *nameWithoutExt); void print_free_memory (void); void playSound (NSString *snd); void popError (const char *title, const char *message); diff -r b697a26ed538 -r e033cf015b2c project_files/HedgewarsMobile/Classes/CommodityFunctions.m --- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.m Fri Nov 12 22:38:05 2010 +0100 +++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.m Fri Nov 12 22:47:13 2010 +0100 @@ -28,169 +28,6 @@ #import "AudioToolbox/AudioToolbox.h" #import "PascalImports.h" -void createTeamNamed (NSString *nameWithoutExt) { - NSString *teamsDirectory = TEAMS_DIRECTORY(); - - if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { - [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory - withIntermediateDirectories:NO - attributes:nil - error:NULL]; - } - - NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: HW_getMaxNumberOfHogs()]; - - for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) { - NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i]; - NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:0],@"level", - hogName,@"hogname", @"NoHat",@"hat", nil]; - [hogName release]; - [hedgehogs addObject:hog]; - [hog release]; - } - - NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"hash", - @"Statue",@"grave", @"Plane",@"fort", @"Default",@"voicepack", - @"hedgewars",@"flag", hedgehogs,@"hedgehogs", nil]; - [hedgehogs release]; - - NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; - - [theTeam writeToFile:teamFile atomically:YES]; - [teamFile release]; - [theTeam release]; -} - -void createWeaponNamed (NSString *nameWithoutExt, int type) { - NSString *weaponsDirectory = WEAPONS_DIRECTORY(); - - if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { - [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory - withIntermediateDirectories:NO - attributes:nil - error:NULL]; - } - - NSDictionary *theWeapon = nil; - switch (type) { - case 0: //default - theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: - @"9391929422199121032235111001201000000211110101011",@"ammostore_initialqt", - @"0405040541600655546554464776576666666155510101117",@"ammostore_probability", - @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", - @"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil]; - break; - case 1: //crazy - theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: - @"9999999999999999992999999999999999299999999909999",@"ammostore_initialqt", - @"1111110111111111111111111111111111111111111101111",@"ammostore_probability", - @"0000000000000000000000000000000000000000000000000",@"ammostore_delay", - @"1311110312111111123114111111111111111211110101111",@"ammostore_crate", nil]; - break; - case 2: //pro mode - theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: - @"9090009000000000000009000000000000000000000000000",@"ammostore_initialqt", - @"0000000000000000000000000000000000000000000000000",@"ammostore_probability", - @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", - @"1111111111111111111111111111111111111111100101111",@"ammostore_crate", nil]; - break; - case 3: //shoppa - theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: - @"0000009900000000000000000000000000000000000000000",@"ammostore_initialqt", - @"4444410044244402210112121222422000000002000400010",@"ammostore_probability", - @"0000000000000000000000000000000000000000000000000",@"ammostore_delay", - @"1111111111111111111111111111111111111111101101111",@"ammostore_crate", nil]; - break; - case 4: //clean slate - theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: - @"1010009000010000011000000000000000000000000000001",@"ammostore_initialqt", - @"0405040541600655546554464776576666666155510101117",@"ammostore_probability", - @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", - @"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil]; - break; - case 5: //minefield - theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: - @"0000009900090000000300000000000000000000000000000",@"ammostore_initialqt", - @"0000000000000000000000000000000000000000000000000",@"ammostore_probability", - @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", - @"1111111111111111111111111111111111111111111101111",@"ammostore_crate", nil]; - break; - default: - NSLog(@"Nope"); - break; - } - - NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; - - [theWeapon writeToFile:weaponFile atomically:YES]; - [weaponFile release]; - [theWeapon release]; -} - -void createSchemeNamed (NSString *nameWithoutExt) { - NSString *schemesDirectory = SCHEMES_DIRECTORY(); - - if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { - [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory - withIntermediateDirectories:NO - attributes:nil - error:NULL]; - } - - NSMutableArray *basicArray = [[NSMutableArray alloc] initWithObjects: - [NSNumber numberWithInt:100], //initialhealth - [NSNumber numberWithInt:45], //turntime - [NSNumber numberWithInt:100], //damagemodifier - [NSNumber numberWithInt:15], //suddendeathtimeout - [NSNumber numberWithInt:47], //waterrise - [NSNumber numberWithInt:5], //healthdecrease - [NSNumber numberWithInt:5], //cratedrops - [NSNumber numberWithInt:35], //healthprob - [NSNumber numberWithInt:25], //healthamount - [NSNumber numberWithInt:3], //minestime - [NSNumber numberWithInt:4], //minesnumber - [NSNumber numberWithInt:0], //dudmines - [NSNumber numberWithInt:2], //explosives - nil]; - - NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithObjects: - [NSNumber numberWithBool:NO], //fortmode - [NSNumber numberWithBool:NO], //divideteam - [NSNumber numberWithBool:NO], //solidland - [NSNumber numberWithBool:NO], //addborder - [NSNumber numberWithBool:NO], //lowgravity - [NSNumber numberWithBool:NO], //lasersight - [NSNumber numberWithBool:NO], //invulnerable - [NSNumber numberWithBool:NO], //resethealth - [NSNumber numberWithBool:NO], //vampirism - [NSNumber numberWithBool:NO], //karma - [NSNumber numberWithBool:NO], //artillery - [NSNumber numberWithBool:YES], //randomorder - [NSNumber numberWithBool:NO], //king - [NSNumber numberWithBool:NO], //placehedgehogs - [NSNumber numberWithBool:NO], //clansharesammo - [NSNumber numberWithBool:NO], //disablegirders - [NSNumber numberWithBool:NO], //disablelandobjects - [NSNumber numberWithBool:NO], //aisurvival - [NSNumber numberWithBool:NO], //infattack - [NSNumber numberWithBool:NO], //resetweaps - [NSNumber numberWithBool:NO], //perhogammo - nil]; - - NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: - basicArray,@"basic", - gamemodArray,@"gamemod", - nil]; - [gamemodArray release]; - [basicArray release]; - - NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; - - [theScheme writeToFile:schemeFile atomically:YES]; - [schemeFile release]; - [theScheme release]; -} - BOOL inline rotationManager (UIInterfaceOrientation interfaceOrientation) { if (IS_IPAD()) return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || diff -r b697a26ed538 -r e033cf015b2c project_files/HedgewarsMobile/Classes/CreationChamber.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/HedgewarsMobile/Classes/CreationChamber.h Fri Nov 12 22:47:13 2010 +0100 @@ -0,0 +1,26 @@ +/* + * Hedgewars-iOS, a Hedgewars port for iOS devices + * Copyright (c) 2009-2010 Vittorio Giovara + * + * 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; version 2 of the License + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * File created on 12/11/2010. + */ + + +#import + +void createTeamNamed (NSString *nameWithoutExt); +void createWeaponNamed (NSString *nameWithoutExt, int type); +void createSchemeNamed (NSString *nameWithoutExt); \ No newline at end of file diff -r b697a26ed538 -r e033cf015b2c project_files/HedgewarsMobile/Classes/CreationChamber.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/HedgewarsMobile/Classes/CreationChamber.m Fri Nov 12 22:47:13 2010 +0100 @@ -0,0 +1,193 @@ +/* + * Hedgewars-iOS, a Hedgewars port for iOS devices + * Copyright (c) 2009-2010 Vittorio Giovara + * + * 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; version 2 of the License + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * File created on 12/11/2010. + */ + + +#import "CreationChamber.h" + +void createTeamNamed (NSString *nameWithoutExt) { + NSString *teamsDirectory = TEAMS_DIRECTORY(); + + if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { + [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory + withIntermediateDirectories:NO + attributes:nil + error:NULL]; + } + + NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: HW_getMaxNumberOfHogs()]; + + for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) { + NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i]; + NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:0],@"level", + hogName,@"hogname", + @"NoHat",@"hat", + nil]; + [hogName release]; + [hedgehogs addObject:hog]; + [hog release]; + } + + NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys: + @"0",@"hash", + @"Statue",@"grave", + @"Plane",@"fort", + @"Default",@"voicepack", + @"hedgewars",@"flag", + hedgehogs,@"hedgehogs", + nil]; + [hedgehogs release]; + + NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; + + [theTeam writeToFile:teamFile atomically:YES]; + [teamFile release]; + [theTeam release]; +} + +void createWeaponNamed (NSString *nameWithoutExt, int type) { + NSString *weaponsDirectory = WEAPONS_DIRECTORY(); + + if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { + [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory + withIntermediateDirectories:NO + attributes:nil + error:NULL]; + } + + NSDictionary *theWeapon = nil; + switch (type) { + case 0: //default + theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: + @"9391929422199121032235111001201000000211110101011",@"ammostore_initialqt", + @"0405040541600655546554464776576666666155510101117",@"ammostore_probability", + @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", + @"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil]; + break; + case 1: //crazy + theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: + @"9999999999999999992999999999999999299999999909999",@"ammostore_initialqt", + @"1111110111111111111111111111111111111111111101111",@"ammostore_probability", + @"0000000000000000000000000000000000000000000000000",@"ammostore_delay", + @"1311110312111111123114111111111111111211110101111",@"ammostore_crate", nil]; + break; + case 2: //pro mode + theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: + @"9090009000000000000009000000000000000000000000000",@"ammostore_initialqt", + @"0000000000000000000000000000000000000000000000000",@"ammostore_probability", + @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", + @"1111111111111111111111111111111111111111100101111",@"ammostore_crate", nil]; + break; + case 3: //shoppa + theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: + @"0000009900000000000000000000000000000000000000000",@"ammostore_initialqt", + @"4444410044244402210112121222422000000002000400010",@"ammostore_probability", + @"0000000000000000000000000000000000000000000000000",@"ammostore_delay", + @"1111111111111111111111111111111111111111101101111",@"ammostore_crate", nil]; + break; + case 4: //clean slate + theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: + @"1010009000010000011000000000000000000000000000001",@"ammostore_initialqt", + @"0405040541600655546554464776576666666155510101117",@"ammostore_probability", + @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", + @"1311110312111111123114111111111111111211111101111",@"ammostore_crate", nil]; + break; + case 5: //minefield + theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: + @"0000009900090000000300000000000000000000000000000",@"ammostore_initialqt", + @"0000000000000000000000000000000000000000000000000",@"ammostore_probability", + @"0000000000000205500000040007004000000000200000000",@"ammostore_delay", + @"1111111111111111111111111111111111111111111101111",@"ammostore_crate", nil]; + break; + default: + NSLog(@"Nope"); + break; + } + + NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; + + [theWeapon writeToFile:weaponFile atomically:YES]; + [weaponFile release]; + [theWeapon release]; +} + +void createSchemeNamed (NSString *nameWithoutExt) { + NSString *schemesDirectory = SCHEMES_DIRECTORY(); + + if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { + [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory + withIntermediateDirectories:NO + attributes:nil + error:NULL]; + } + + NSMutableArray *basicArray = [[NSMutableArray alloc] initWithObjects: + [NSNumber numberWithInt:100], //initialhealth + [NSNumber numberWithInt:45], //turntime + [NSNumber numberWithInt:100], //damagemodifier + [NSNumber numberWithInt:15], //suddendeathtimeout + [NSNumber numberWithInt:47], //waterrise + [NSNumber numberWithInt:5], //healthdecrease + [NSNumber numberWithInt:5], //cratedrops + [NSNumber numberWithInt:35], //healthprob + [NSNumber numberWithInt:25], //healthamount + [NSNumber numberWithInt:3], //minestime + [NSNumber numberWithInt:4], //minesnumber + [NSNumber numberWithInt:0], //dudmines + [NSNumber numberWithInt:2], //explosives + nil]; + + NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithObjects: + [NSNumber numberWithBool:NO], //fortmode + [NSNumber numberWithBool:NO], //divideteam + [NSNumber numberWithBool:NO], //solidland + [NSNumber numberWithBool:NO], //addborder + [NSNumber numberWithBool:NO], //lowgravity + [NSNumber numberWithBool:NO], //lasersight + [NSNumber numberWithBool:NO], //invulnerable + [NSNumber numberWithBool:NO], //resethealth + [NSNumber numberWithBool:NO], //vampirism + [NSNumber numberWithBool:NO], //karma + [NSNumber numberWithBool:NO], //artillery + [NSNumber numberWithBool:YES], //randomorder + [NSNumber numberWithBool:NO], //king + [NSNumber numberWithBool:NO], //placehedgehogs + [NSNumber numberWithBool:NO], //clansharesammo + [NSNumber numberWithBool:NO], //disablegirders + [NSNumber numberWithBool:NO], //disablelandobjects + [NSNumber numberWithBool:NO], //aisurvival + [NSNumber numberWithBool:NO], //infattack + [NSNumber numberWithBool:NO], //resetweaps + [NSNumber numberWithBool:NO], //perhogammo + nil]; + + NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: + basicArray,@"basic", + gamemodArray,@"gamemod", + nil]; + [gamemodArray release]; + [basicArray release]; + + NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; + + [theScheme writeToFile:schemeFile atomically:YES]; + [schemeFile release]; + [theScheme release]; +} diff -r b697a26ed538 -r e033cf015b2c project_files/HedgewarsMobile/Classes/MainMenuViewController.m --- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Fri Nov 12 22:38:05 2010 +0100 +++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Fri Nov 12 22:47:13 2010 +0100 @@ -20,7 +20,7 @@ #import "MainMenuViewController.h" -#import "CommodityFunctions.h" +#import "CreationChamber.h" #import "SDL_uikitappdelegate.h" #import "PascalImports.h" #import "GameConfigViewController.h" @@ -35,84 +35,67 @@ return rotationManager(interfaceOrientation); } -// using a different thread for audio 'cos it's slow --(void) initAudioThread { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - // do somthing in the future - [pool release]; -} - // check if some configuration files are already set; if they are present it means that the current copy must be updated -(void) createNecessaryFiles { - NSError *err = nil; - NSString *directoryToCheck, *fileToCheck, *fileToUpdate; + NSString *sourceFile, *destinationFile; NSString *resDir = [[NSBundle mainBundle] resourcePath]; DLog(@"Creating necessary files"); - // create an empty saves directory by deleting the previous one (saves are incompatible between releases) + // SAVES - just delete and overwrite if ([[NSFileManager defaultManager] fileExistsAtPath:SAVES_DIRECTORY()]) [[NSFileManager defaultManager] removeItemAtPath:SAVES_DIRECTORY() error:NULL]; [[NSFileManager defaultManager] createDirectoryAtPath:SAVES_DIRECTORY() withIntermediateDirectories:NO attributes:nil error:NULL]; - // if the settings file is already present, we merge current preferences with the update - fileToCheck = [NSString stringWithFormat:@"%@/Settings/settings.plist",resDir]; + // SETTINGS FILE - merge when present + NSString *baseSettingsFile = [NSString stringWithFormat:@"%@/Settings/settings.plist",resDir]; if ([[NSFileManager defaultManager] fileExistsAtPath:SETTINGS_FILE()]) { NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()]; - NSMutableDictionary *update = [[NSMutableDictionary alloc] initWithContentsOfFile:fileToCheck]; + NSMutableDictionary *update = [[NSMutableDictionary alloc] initWithContentsOfFile:baseSettingsFile]; + // the order of what adds what is important [update addEntriesFromDictionary:settings]; [settings release]; [update writeToFile:SETTINGS_FILE() atomically:YES]; [update release]; } else - [[NSFileManager defaultManager] copyItemAtPath:fileToCheck toPath:SETTINGS_FILE() error:&err]; - - // TODO: scrap this and always copy the bundled files; update exisising ones in some way - // if the teams are already present we merge the old teams, else we copy new teams - directoryToCheck = [NSString stringWithFormat:@"%@/Settings/Teams",resDir]; - if ([[NSFileManager defaultManager] fileExistsAtPath:TEAMS_DIRECTORY()]) { - for (NSString *str in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryToCheck error:&err]) { - fileToCheck = [NSString stringWithFormat:@"%@/%@",TEAMS_DIRECTORY(),str]; - fileToUpdate = [NSString stringWithFormat:@"%@/Settings/Teams/%@",resDir,str]; - if ([[NSFileManager defaultManager] fileExistsAtPath:fileToCheck]) { - NSDictionary *team = [[NSDictionary alloc] initWithContentsOfFile:fileToCheck]; - NSMutableDictionary *update = [[NSMutableDictionary alloc] initWithContentsOfFile:fileToUpdate]; - [update addEntriesFromDictionary:team]; - [team release]; - [update writeToFile:fileToCheck atomically:YES]; - [update release]; - } else - [[NSFileManager defaultManager] copyItemAtPath:fileToUpdate toPath:fileToCheck error:&err]; - } - } else - [[NSFileManager defaultManager] copyItemAtPath:directoryToCheck toPath:TEAMS_DIRECTORY() error:&err]; - - // TODO: scrap this and always copy the bundled files; update exisising ones in some way - // the same holds for schemes (but they're dictionaries containing arrays) - directoryToCheck = [NSString stringWithFormat:@"%@/Settings/Schemes",resDir]; - if ([[NSFileManager defaultManager] fileExistsAtPath:SCHEMES_DIRECTORY()]) { - for (NSString *str in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryToCheck error:nil]) { - fileToCheck = [NSString stringWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),str]; - fileToUpdate = [NSString stringWithFormat:@"%@/Settings/Schemes/%@",resDir,str]; - if ([[NSFileManager defaultManager] fileExistsAtPath:fileToCheck]) { - NSDictionary *scheme = [[NSDictionary alloc] initWithContentsOfFile:fileToCheck]; - NSDictionary *update = [[NSDictionary alloc] initWithContentsOfFile:fileToUpdate]; - if ([[update objectForKey:@"basic"] count] > [[scheme objectForKey:@"basic"] count] || - [[update objectForKey:@"gamemod"] count] > [[scheme objectForKey:@"gamemod"] count]) - [update writeToFile:fileToCheck atomically:YES]; - [update release]; - [scheme release]; - } else - [[NSFileManager defaultManager] copyItemAtPath:fileToUpdate toPath:fileToCheck error:&err]; - } - } else - [[NSFileManager defaultManager] copyItemAtPath:directoryToCheck toPath:SCHEMES_DIRECTORY() error:&err]; - - // weapons are autoupdated at runtime but it's better to update then every new version + [[NSFileManager defaultManager] copyItemAtPath:baseSettingsFile toPath:SETTINGS_FILE() error:NULL]; + + // TEAMS - update exisiting teams with new format + if ([[NSFileManager defaultManager] fileExistsAtPath:TEAMS_DIRECTORY()] == NO) { + [[NSFileManager defaultManager] createDirectoryAtPath:TEAMS_DIRECTORY() + withIntermediateDirectories:YES + attributes:nil + error:NULL]; + // we copy teams only the first time because it's unlikely that newer ones are going to be added + NSString *baseTeamsDir = [NSString stringWithFormat:@"%@/Settings/Teams",resDir]; + for (NSString *str in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:baseTeamsDir error:NULL]) { + sourceFile = [baseTeamsDir stringByAppendingString:str]; + destinationFile = [TEAMS_DIRECTORY() stringByAppendingString:str]; + [[NSFileManager defaultManager] copyItemAtPath:sourceFile toPath:destinationFile error:NULL]; + } + } + // TODO: is merge needed? + + // SCHEMES - update old stuff and add new stuff + if ([[NSFileManager defaultManager] fileExistsAtPath:SCHEMES_DIRECTORY()] == NO) + [[NSFileManager defaultManager] createDirectoryAtPath:SCHEMES_DIRECTORY() + withIntermediateDirectories:YES + attributes:nil + error:NULL]; + // TODO: do the merge if necessary + // we overwrite the default ones because it is likely that new modes are added every release + NSString *baseSchemesDir = [NSString stringWithFormat:@"%@/Settings/Schemes",resDir]; + for (NSString *str in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:baseSchemesDir error:NULL]) { + sourceFile = [baseSchemesDir stringByAppendingString:str]; + destinationFile = [SCHEMES_DIRECTORY() stringByAppendingString:str]; + [[NSFileManager defaultManager] copyItemAtPath:sourceFile toPath:destinationFile error:NULL]; + } + + // WEAPONS - always overwrite if ([[NSFileManager defaultManager] fileExistsAtPath:WEAPONS_DIRECTORY()] == NO) [[NSFileManager defaultManager] createDirectoryAtPath:WEAPONS_DIRECTORY() withIntermediateDirectories:YES attributes:nil - error:&err]; + error:NULL]; createWeaponNamed(@"Default", 0); createWeaponNamed(@"Crazy", 1); createWeaponNamed(@"Pro mode", 2); @@ -120,10 +103,7 @@ createWeaponNamed(@"Clean slate", 4); createWeaponNamed(@"Minefield", 5); - if (err != nil) - DLog(@"%@", err); - else - DLog(@"Success"); + DLog(@"Success"); } #pragma mark - diff -r b697a26ed538 -r e033cf015b2c project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m --- a/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Fri Nov 12 22:38:05 2010 +0100 +++ b/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Fri Nov 12 22:47:13 2010 +0100 @@ -20,7 +20,7 @@ #import "SchemeSettingsViewController.h" -#import "CommodityFunctions.h" +#import "CreationChamber.h" #import "SingleSchemeViewController.h" @implementation SchemeSettingsViewController diff -r b697a26ed538 -r e033cf015b2c project_files/HedgewarsMobile/Classes/TeamSettingsViewController.m --- a/project_files/HedgewarsMobile/Classes/TeamSettingsViewController.m Fri Nov 12 22:38:05 2010 +0100 +++ b/project_files/HedgewarsMobile/Classes/TeamSettingsViewController.m Fri Nov 12 22:47:13 2010 +0100 @@ -20,8 +20,8 @@ #import "TeamSettingsViewController.h" +#import "CreationChamber.h" #import "SingleTeamViewController.h" -#import "CommodityFunctions.h" @implementation TeamSettingsViewController @synthesize listOfTeams; diff -r b697a26ed538 -r e033cf015b2c project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m --- a/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m Fri Nov 12 22:38:05 2010 +0100 +++ b/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m Fri Nov 12 22:47:13 2010 +0100 @@ -20,7 +20,7 @@ #import "WeaponSettingsViewController.h" -#import "CommodityFunctions.h" +#import "CreationChamber.h" #import "SingleWeaponViewController.h" @implementation WeaponSettingsViewController diff -r b697a26ed538 -r e033cf015b2c project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj --- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Fri Nov 12 22:38:05 2010 +0100 +++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Fri Nov 12 22:47:13 2010 +0100 @@ -25,6 +25,7 @@ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD14FF0DC6FC520079059D /* OpenGLES.framework */; }; 28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD15070DC6FC5B0079059D /* QuartzCore.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + 61006F95128DE31F00EBA7F7 /* CreationChamber.m in Sources */ = {isa = PBXBuildFile; fileRef = 61006F94128DE31F00EBA7F7 /* CreationChamber.m */; }; 610D5FB21270E2660033333A /* Icon-Small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 61F7A43411E290650040BA66 /* Icon-Small@2x.png */; }; 610D5FB31270E26C0033333A /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 61F7A43611E290650040BA66 /* Icon@2x.png */; }; 611D9BFB12497E9800008271 /* SavedGamesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 611D9BF912497E9800008271 /* SavedGamesViewController.m */; }; @@ -730,6 +731,8 @@ 28FD14FF0DC6FC520079059D /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 28FD15070DC6FC5B0079059D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 32CA4F630368D1EE00C91783 /* Hedgewars_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Hedgewars_Prefix.pch; sourceTree = ""; }; + 61006F93128DE31F00EBA7F7 /* CreationChamber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CreationChamber.h; path = Classes/CreationChamber.h; sourceTree = ""; }; + 61006F94128DE31F00EBA7F7 /* CreationChamber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CreationChamber.m; path = Classes/CreationChamber.m; sourceTree = ""; }; 611D9BF812497E9800008271 /* SavedGamesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SavedGamesViewController.h; sourceTree = ""; }; 611D9BF912497E9800008271 /* SavedGamesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SavedGamesViewController.m; sourceTree = ""; }; 611D9BFA12497E9800008271 /* SavedGamesViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = SavedGamesViewController.xib; path = ../Resources/SavedGamesViewController.xib; sourceTree = ""; }; @@ -1023,6 +1026,8 @@ 6165922D11CA9BD500D6E256 /* UIImageExtra.m */, 61D2059F127CDD1100ABD83E /* ObjcExports.h */, 61D205A0127CDD1100ABD83E /* ObjcExports.m */, + 61006F93128DE31F00EBA7F7 /* CreationChamber.h */, + 61006F94128DE31F00EBA7F7 /* CreationChamber.m */, ); name = "Other Sources"; sourceTree = ""; @@ -2284,6 +2289,7 @@ 61DE8F221257EB1100B80214 /* AmmoMenuViewController.m in Sources */, 61399013125D19C0003C2DC0 /* uMobile.pas in Sources */, 61D205A1127CDD1100ABD83E /* ObjcExports.m in Sources */, + 61006F95128DE31F00EBA7F7 /* CreationChamber.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };